From c06753313db7f18ff98c0f0fdeb2aa1209ed2564 Mon Sep 17 00:00:00 2001 From: David Daney Date: Thu, 12 Oct 2017 14:02:27 -0700 Subject: kexec-tools: mips: Use proper page_offset for OCTEON CPUs. The OCTEON family of MIPS64 CPUs uses a PAGE_OFFSET of 0x8000000000000000ULL, which is differs from other CPUs. Scan /proc/cpuinfo to see if the current system is "Octeon", if so, patch the page_offset so that usable kdump core files are produced. Signed-off-by: David Daney Signed-off-by: Simon Horman --- kexec/arch/mips/crashdump-mips.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c index 9ab041a..fc92e64 100644 --- a/kexec/arch/mips/crashdump-mips.c +++ b/kexec/arch/mips/crashdump-mips.c @@ -318,6 +318,30 @@ static struct crash_elf_info elf_info32 = { lowmem_limit : MAXMEM, }; +static int patch_elf_info(void) +{ + const char cpuinfo[] = "/proc/cpuinfo"; + char line[MAX_LINE]; + FILE *fp; + + fp = fopen(cpuinfo, "r"); + if (!fp) { + fprintf(stderr, "Cannot open %s: %s\n", + cpuinfo, strerror(errno)); + return -1; + } + while (fgets(line, sizeof(line), fp) != 0) { + if (strncmp(line, "cpu model", 9) == 0) { + /* OCTEON uses a different page_offset. */ + if (strstr(line, "Octeon")) + elf_info64.page_offset = 0x8000000000000000ULL; + break; + } + } + fclose(fp); + return 0; +} + /* Loads additional segments in case of a panic kernel is being loaded. * One segment for backup region, another segment for storing elf headers * for crash memory image. @@ -334,6 +358,9 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, struct crash_elf_info *elf_info = &elf_info32; unsigned long start_offset = 0x80000000UL; + if (patch_elf_info()) + return -1; + if (arch_options.core_header_type == CORE_TYPE_ELF64) { elf_info = &elf_info64; crash_create = crash_create_elf64_headers; -- cgit