From 40805e393b2fc84551a6705e1890e995e3ee8320 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Fri, 24 May 2019 14:23:21 +0800 Subject: crashdump/x86: Use new introduce helper for getting RSDP Use the new introduce helper for getting RSDP, this ensures RSDP is always accessible and avoid code duplication. Signed-off-by: Kairui Song Signed-off-by: Simon Horman --- kexec/arch/i386/crashdump-x86.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c index 140f45bb..a2aea31f 100644 --- a/kexec/arch/i386/crashdump-x86.c +++ b/kexec/arch/i386/crashdump-x86.c @@ -787,35 +787,19 @@ static int sysfs_efi_runtime_map_exist(void) /* Appends 'acpi_rsdp=' commandline for efi boot crash dump */ static void cmdline_add_efi(char *cmdline) { - FILE *fp; - int cmdlen, len; - char line[MAX_LINE], *s; - const char *acpis = " acpi_rsdp="; + uint64_t acpi_rsdp; + char acpi_rsdp_buf[MAX_LINE]; - fp = fopen("/sys/firmware/efi/systab", "r"); - if (!fp) - return; + acpi_rsdp = get_acpi_rsdp(); - while(fgets(line, sizeof(line), fp) != 0) { - /* ACPI20= always goes before ACPI= */ - if ((strstr(line, "ACPI20=")) || (strstr(line, "ACPI="))) { - line[strlen(line) - 1] = '\0'; - s = strchr(line, '='); - s += 1; - len = strlen(s) + strlen(acpis); - cmdlen = strlen(cmdline) + len; - if (cmdlen > (COMMAND_LINE_SIZE - 1)) - die("Command line overflow\n"); - strcat(cmdline, acpis); - strcat(cmdline, s); - dbgprintf("Command line after adding efi\n"); - dbgprintf("%s\n", cmdline); + if (!acpi_rsdp) + return; - break; - } - } + sprintf(acpi_rsdp_buf, " acpi_rsdp=0x%lx", acpi_rsdp); + if (strlen(cmdline) + strlen(acpi_rsdp_buf) > (COMMAND_LINE_SIZE - 1)) + die("Command line overflow\n"); - fclose(fp); + strcat(cmdline, acpi_rsdp_buf); } static void get_backup_area(struct kexec_info *info, -- cgit 1.2.3-korg