From e2ffd1d4de78a165c8b9a4540378d5783cc9109b Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Thu, 4 Aug 2005 17:48:46 +0530 Subject: elf headers fill virtual address for linearly mapped region o For i386, Physical memory upto 896MB is linearly mapped. Hence virtual addresses for linearly mapped region are known. o This patch sets the appropriate virtual addresses in core headers for linearly mapped region. o Enables gdb to debug linearly mapped region without any special user space utility. Otherwise, capture tools first need to analyze the core image (Read page tables and/or vm areas) and determine virtual addresses for memory chunks and then regenerate the elf headers suitable for debugging with gdb. o Some cases like 4G/4G split deviate from 896MB linearly mapped region and might have different value for PAGE_OFFSET. Probably its a good idea to export the linear region from kernel and use that instead of hard coding it. Signed-off-by: Vivek Goyal Signed-off-by: Maneesh Soni --- kexec/arch/i386/crashdump-x86.c | 26 ++++++++++++++++++++++++-- kexec/arch/i386/crashdump-x86.h | 3 +++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c index b718ca0..e469c1d 100644 --- a/kexec/arch/i386/crashdump-x86.c +++ b/kexec/arch/i386/crashdump-x86.c @@ -108,10 +108,22 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) /* First 640K already registered */ if (start >= 0x00000000 && end <= 0x0009ffff) continue; + crash_memory_range[memory_ranges].start = start; crash_memory_range[memory_ranges].end = end; crash_memory_range[memory_ranges].type = type; memory_ranges++; + + /* Segregate linearly mapped region. */ + if ((MAXMEM - 1) >= start && (MAXMEM - 1) <= end) { + crash_memory_range[memory_ranges-1].end = MAXMEM -1; + + /* Add segregated region. */ + crash_memory_range[memory_ranges].start = MAXMEM; + crash_memory_range[memory_ranges].end = end; + crash_memory_range[memory_ranges].type = type; + memory_ranges++; + } } fclose(fp); if (exclude_crash_reserve_region(&memory_ranges) < 0) @@ -523,7 +535,12 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, phdr->p_offset = info->backup_start; else phdr->p_offset = mstart; - phdr->p_vaddr = phdr->p_paddr = mstart; + /* Handle linearly mapped region.*/ + if (mend <= (MAXMEM - 1)) + phdr->p_vaddr = mstart + PAGE_OFFSET; + else + phdr->p_vaddr = -1ULL; + phdr->p_paddr = mstart; phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; /* Do we need any alignment of segments? */ phdr->p_align = 0; @@ -614,7 +631,12 @@ static int prepare_crash_memory_elf32_headers(struct kexec_info *info, phdr->p_offset = info->backup_start; else phdr->p_offset = mstart; - phdr->p_vaddr = phdr->p_paddr = mstart; + /* Handle linearly mapped region.*/ + if (mend <= (MAXMEM - 1)) + phdr->p_vaddr = mstart + PAGE_OFFSET; + else + phdr->p_vaddr = ULONG_MAX; + phdr->p_paddr = mstart; phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; /* Do we need any alignment of segments? */ phdr->p_align = 0; diff --git a/kexec/arch/i386/crashdump-x86.h b/kexec/arch/i386/crashdump-x86.h index 0d4baec..de6c248 100644 --- a/kexec/arch/i386/crashdump-x86.h +++ b/kexec/arch/i386/crashdump-x86.h @@ -7,6 +7,9 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline, #define PAGE_OFFSET 0xc0000000 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) +#define __VMALLOC_RESERVE (128 << 20) +#define MAXMEM (-PAGE_OFFSET-__VMALLOC_RESERVE) + #define CRASH_MAX_MEMMAP_NR (KEXEC_MAX_SEGMENTS + 1) #define CRASH_MAX_MEMORY_RANGES (MAX_MEMORY_RANGES + 2) -- cgit