summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Daney <david.daney@cavium.com>2017-10-12 14:02:27 -0700
committerSimon Horman <horms@verge.net.au>2017-10-18 07:16:21 +0200
commitc06753313db7f18ff98c0f0fdeb2aa1209ed2564 (patch)
treef104b6de50718b1db25819ad9d27b7d225065af8
parent77e769bd1d1f8e2442bb9a62895e2de8f9cbb4b6 (diff)
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 <david.daney@cavium.com> Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--kexec/arch/mips/crashdump-mips.c27
1 files changed, 27 insertions, 0 deletions
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;