kexec-tools, x86: E820 memmap pass for kdump
Subsystems (2)
cover kexec-tools, x86: E820 memmap pass for kdump
Hi, All
When kaslr comes in and kdump is broken, it seems about the right time to use E820 instead of memmap=exactmap to pass memmap for kdump for the default memmap passing mechanism:
http://lists.infradead.org/pipermail/kexec/2014-February/011048.html
Unfortunately, saved_max_pfn still got its user out there (calgry pci, it looks like the only one). So for backward compatibility, I'm introducing a new option --pass-memmap-cmdline to force kexec-tools to pass memmap=exactmap, the old way.
Any comment is appreciate!
WANG Chao (4):
add macro dbgprint_mem_range
x86: Store memory ranges globally used for crash kernel to boot into
x86: add --pass-memmap-cmdline option
x86: Pass memory range via E820 for kdump
kexec/arch/i386/crashdump-x86.c | 159 +++++++++++++++------------ kexec/arch/i386/crashdump-x86.h | 6 +- kexec/arch/i386/include/arch/options.h | 2 + kexec/arch/i386/kexec-x86-common.c | 6 +- kexec/arch/i386/kexec-x86.c | 4 + kexec/arch/i386/kexec-x86.h | 1 + kexec/arch/i386/x86-linux-setup.c | 195 ++++++++++++++++++++++++--------- kexec/arch/i386/x86-linux-setup.h | 1 + kexec/arch/x86_64/kexec-x86_64.c | 5 + kexec/kexec.h | 10 ++ 10 files changed, 260 insertions(+), 129 deletions(-)
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 1/4 add macro dbgprint_mem_range
dbgprint_mem_range is used for printing the given memory range under debugging mode.
--- kexec/arch/i386/kexec-x86-common.c | 6 +----- kexec/kexec.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-)
kexec/arch/i386/kexec-x86-common.c +1 -5
@@ -374,11 +374,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges, mem_max = end; } -dbgprintf ("MEMORY RANGES\n" ); -for (i =0 ; i < *ranges; i++) { -dbgprintf ("%016Lx-%016Lx (%d)\n" , (*range)[i].start, - (*range)[i].end, (*range)[i].type); - } +dbgprint_mem_range ("MEMORY RANGES" , *range, *ranges);return ret; }
kexec/kexec.h +10 -0
@@ -121,6 +121,16 @@ do { \fprintf (stderr, __VA_ARGS__); \ } while(0) +#define dbgprint_mem_range (prefix, mr, nr_mr) \ +do { \ + int i; \ + dbgprintf(prefix "\n"); \ + for (i = 0; i < nr_mr; i++) { \ + dbgprintf("%016llx-%016llx (%d)\n", (mr)[i].start, \ + (mr)[i].end, (mr)[i].type); \ + } \ +} while (0) +struct kexec_segment {const void *buf;size_t bufsz;
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 1/4] add macro dbgprint_mem_range
On Thu, Feb 13, 2014 at 09:10:52PM +0800, WANG Chao wrote:
[..]
Quoted 8 lines
kexec/kexec.h +0
-0@@ -121,6 +121,16 @@ do { \fprintf (stderr, __VA_ARGS__); \ }while (0 )
kexec/kexec.h do { \ · line 133
Quoted 10 lines
kexec/kexec.h +10
-0+#define dbgprint_mem_range (prefix, mr, nr_mr) \ +do { \ + int i; \ + dbgprintf(prefix "\n"); \ + for (i = 0; i < nr_mr; i++) { \ + dbgprintf("%016llx-%016llx (%d)\n", (mr)[i].start, \ + (mr)[i].end, (mr)[i].type); \ + } \ +} while (0) +
Can we make it a function instead of macro?
Vivek
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 1/4] add macro dbgprint_mem_range
Quoted 11 lines · Vivek Goyal
On Thu, Feb 13, 2014 at 09:10:52PM +0800, WANG Chao wrote:
[..]
Quoted 8 lines
kexec/kexec.h +0
-0@@ -121,6 +121,16 @@ do { \fprintf (stderr, __VA_ARGS__); \ }while (0 )
Quoted 12 lines
kexec/kexec.h do { \ · line 133
Quoted 10 lines
kexec/kexec.h +10
-0+#define dbgprint_mem_range (prefix, mr, nr_mr) \ +do { \ + int i; \ + dbgprintf(prefix "\n"); \ + for (i = 0; i < nr_mr; i++) { \ + dbgprintf("%016llx-%016llx (%d)\n", (mr)[i].start, \ + (mr)[i].end, (mr)[i].type); \ + } \ +} while (0) +Can we make it a function instead of macro?
Sure. Will put it in kexec.c
Thanks
WANG Chao
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH 2/4 x86: Store memory ranges globally used for crash kernel to boot into
In reply to WANG ChaoUse these two variables to store the memory ranges and the number of memory ranges for crash kernel to boot into:
struct memory_range crash_memory_range;
int crash_memory_range;
crash_memory_range also will store RANGE_RESERVED ranges which is discarded previously, but will be filtered out when exactmap case.
These two variables are not static now, so can be used in other file later.
--- kexec/arch/i386/crashdump-x86.c | 136 ++++++++++++++++++++++------------------ kexec/arch/i386/crashdump-x86.h | 5 +- 2 files changed, 79 insertions(+), 62 deletions(-)
kexec/arch/i386/crashdump-x86.c +75 -61
@@ -179,7 +179,8 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end);/* Stores a sorted list of RAM memory ranges for which to create elf headers. * A separate program header is created for backup region */ -static struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES ]; +struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES ]; +int crash_memory_ranges;/* Memory region reserved for storing panic kernel and other data. */ #define CRASH_RESERVED_MEM_NR 8
@@ -201,7 +202,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, int kexec_flags, unsigned long lowmem_limit) { const char *iomem = proc_iomem(); -int memory_ranges =0 , gart =0 , i; +int gart =0 , i;char line[MAX_LINE ];FILE *fp;unsigned long long start, end;
@@ -218,7 +219,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,char *str;int type, consumed, count; -if (memory_ranges >=CRASH_MAX_MEMORY_RANGES ) +if (crash_memory_ranges >=CRASH_MAX_MEMORY_RANGES )break ; count =sscanf (line,"%Lx-%Lx : %n" , &start, &end, &consumed);
@@ -230,6 +231,8 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,/* Only Dumping memory of type System RAM. */ if (memcmp (str,"System RAM\n" ,11 ) ==0 ) { type =RANGE_RAM ; + }else if (memcmp (str,"reserved\n" ,9 ) ==0 ) { + type =RANGE_RESERVED ; }else if (memcmp (str,"ACPI Tables\n" ,12 ) ==0 ) {/* * ACPI Tables area need to be passed to new
@@ -250,17 +253,17 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,continue ; } - crash_memory_range[memory_ranges].start = start; - crash_memory_range[memory_ranges].end = end; - crash_memory_range[memory_ranges].type = type; + crash_memory_range[crash_memory_ranges].start = start; + crash_memory_range[crash_memory_ranges].end = end; + crash_memory_range[crash_memory_ranges].type = type; -segregate_lowmem_region (&memory_ranges, lowmem_limit); +segregate_lowmem_region (&crash_memory_ranges, lowmem_limit); - memory_ranges++; + crash_memory_ranges++; }fclose (fp);if (kexec_flags &KEXEC_PRESERVE_CONTEXT ) { -for (i =0 ; i < memory_ranges; i++) { +for (i =0 ; i < crash_memory_ranges; i++) {if (crash_memory_range[i].end >0x0009ffff ) { crash_reserved_mem[0 ].start = \ crash_memory_range[i].start;
@@ -278,17 +281,17 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, }for (i =0 ; i < crash_reserved_mem_nr; i++) -if (exclude_region (&memory_ranges, crash_reserved_mem[i].start, +if (exclude_region (&crash_memory_ranges, crash_reserved_mem[i].start, crash_reserved_mem[i].end) <0 )return -1 ;if (gart) {/* exclude GART region if the system has one */ -if (exclude_region (&memory_ranges, gart_start, gart_end) <0 ) +if (exclude_region (&crash_memory_ranges, gart_start, gart_end) <0 )return -1 ; } *range = crash_memory_range; - *ranges = memory_ranges; + *ranges = crash_memory_ranges;return 0 ; }
@@ -324,7 +327,7 @@ static int get_crash_memory_ranges_xen(struct memory_range **range, } *range = crash_memory_range; - *ranges = j; + *ranges = crash_memory_ranges = j;qsort (*range, *ranges,sizeof (struct memory_range ), compare_ranges);
@@ -417,8 +420,8 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end)/* Adds a segment from list of memory regions which new kernel can use to * boot. Segment start and end should be aligned to 1K boundary. */ -static int add_memmap (struct memory_range *memmap_p,unsigned long long addr, -size_t size) +static int add_memmap (struct memory_range *memmap_p,int *nr_range, +unsigned long long addr,size_t size) {int i, j, nr_entries =0 , tidx =0 , align =1024 ;unsigned long long mstart, mend;
@@ -450,29 +453,23 @@ static int add_memmap(struct memory_range *memmap_p, unsigned long long addr,else if (addr > mend) tidx = i+1 ; } -/* Insert the memory region. */ -for (j = nr_entries-1 ; j >= tidx; j--) - memmap_p[j+1 ] = memmap_p[j]; - memmap_p[tidx].start = addr; - memmap_p[tidx].end = addr + size -1 ; +/* Insert the memory region. */ +for (j = nr_entries-1 ; j >= tidx; j--) + memmap_p[j+1 ] = memmap_p[j]; + memmap_p[tidx].start = addr; + memmap_p[tidx].end = addr + size -1 ; + memmap_p[tidx].type =RANGE_RAM ; + *nr_range = nr_entries +1 ; -dbgprintf ("Memmap after adding segment\n" ); -for (i =0 ; i <CRASH_MAX_MEMMAP_NR ; i++) { - mstart = memmap_p[i].start; - mend = memmap_p[i].end; -if (mstart ==0 && mend ==0 ) -break ; -dbgprintf ("%016llx - %016llx\n" , - mstart, mend); - } +dbgprint_mem_range ("Memmap after adding segment" , memmap_p, *nr_range);return 0 ; }/* Removes a segment from list of memory regions which new kernel can use to * boot. Segment start and end should be aligned to 1K boundary. */ -static int delete_memmap (struct memory_range *memmap_p,unsigned long long addr, -size_t size) +static int delete_memmap (struct memory_range *memmap_p,int *nr_range, +unsigned long long addr,size_t size) {int i, j, nr_entries =0 , tidx =-1 , operation =0 , align =1024 ;unsigned long long mstart, mend;
@@ -534,24 +531,17 @@ static int delete_memmap(struct memory_range *memmap_p, unsigned long long addr,for (j = nr_entries-1 ; j > tidx; j--) memmap_p[j+1 ] = memmap_p[j]; memmap_p[tidx+1 ] = temp_region; + *nr_range = nr_entries +1 ; }if ((operation ==-1 ) && tidx >=0 ) {/* Delete the exact match memory region. */ for (j = i+1 ; j <CRASH_MAX_MEMMAP_NR ; j++) memmap_p[j-1 ] = memmap_p[j]; memmap_p[j-1 ].start = memmap_p[j-1 ].end =0 ; + *nr_range = nr_entries -1 ; } -dbgprintf ("Memmap after deleting segment\n" ); -for (i =0 ; i <CRASH_MAX_MEMMAP_NR ; i++) { - mstart = memmap_p[i].start; - mend = memmap_p[i].end; -if (mstart ==0 && mend ==0 ) { -break ; - } -dbgprintf ("%016llx - %016llx\n" , - mstart, mend); - } +dbgprint_mem_range ("Memmap after deleting segment" , memmap_p, *nr_range);return 0 ; }
@@ -626,6 +616,9 @@ static int cmdline_add_memmap(char *cmdline, struct memory_range *memmap_p)/* All regions traversed. */ break ; +if (memmap_p[i].type !=RANGE_RAM ) +continue ; +/* A region is not worth adding if region size < 100K. It eats * up precious command line length. */ if ((endk - startk) < min_sizek)
@@ -797,6 +790,25 @@ static void get_backup_area(struct kexec_info *info, info->backup_src_size =BACKUP_SRC_END -BACKUP_SRC_START +1 ; } +static void exclude_ram (struct memory_range *mr,int *nr_mr) +{ +int ranges, i, j, m; + + ranges = *nr_mr; +for (i =0 , j =0 ; i < ranges; i++) { +if (mr[j].type ==RANGE_RAM ) { +dbgprintf ("Remove RAM %016llx-%016llxx: (%d)\n" , mr[j].start, mr[j].end, mr[j].type); +for (m = j; m < *nr_mr; m++) + mr[m] = mr[m+1 ]; + (*nr_mr)--; + }else { + j++; + } + } + +dbgprint_mem_range ("After remove RAM" , mr, *nr_mr); +} +/* 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.
@@ -807,7 +819,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,void *tmp;unsigned long sz, bufsz, memsz, elfcorehdr;int nr_ranges =0 , align =1024 , i; -struct memory_range *mem_range, *memmap_p; +struct memory_range *mem_range;struct crash_elf_info elf_info;unsigned kexec_arch;
@@ -850,10 +862,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,get_backup_area (info, mem_range, nr_ranges); -dbgprintf ("CRASH MEMORY RANGES\n" ); - -for (i =0 ; i < nr_ranges; ++i) -dbgprintf ("%016Lx-%016Lx\n" , mem_range[i].start, mem_range[i].end); +dbgprint_mem_range ("CRASH MEMORY RANGES" , mem_range, nr_ranges);/* * if the core type has not been set on command line, set it here
@@ -878,17 +887,6 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,if (get_kernel_vaddr_and_size (info, &elf_info))return -1 ; -/* Memory regions which panic kernel can safely use to boot into */ - sz = (sizeof (struct memory_range ) *CRASH_MAX_MEMMAP_NR ); - memmap_p =xmalloc (sz); -memset (memmap_p,0 , sz); -add_memmap (memmap_p, info->backup_src_start, info->backup_src_size); -for (i =0 ; i < crash_reserved_mem_nr; i++) { - sz = crash_reserved_mem[i].end - crash_reserved_mem[i].start +1 ; -if (add_memmap (memmap_p, crash_reserved_mem[i].start, sz) <0 ) -return ENOCRASHKERNEL ; - } -/* Create a backup region segment to store backup data*/ if (!(info->kexec_flags &KEXEC_PRESERVE_CONTEXT )) { sz =_ALIGN (info->backup_src_size, align);
@@ -898,8 +896,6 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, 0, max_addr, -1);dbgprintf ("Created backup segment at 0x%lx\n" , info->backup_start); -if (delete_memmap (memmap_p, info->backup_start, sz) <0 ) -return EFAILED ; }/* Create elf header segment and store crash image data. */
@@ -915,6 +911,23 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, ELF_CORE_HEADER_ALIGN) < 0)return EFAILED ; } + +/* Memory regions which panic kernel can safely use to boot into */ +exclude_ram (crash_memory_range, &crash_memory_ranges); + +add_memmap (crash_memory_range, &crash_memory_ranges, info->backup_src_start, info->backup_src_size); +for (i =0 ; i < crash_reserved_mem_nr; i++) { + sz = crash_reserved_mem[i].end - crash_reserved_mem[i].start +1 ; +if (add_memmap (crash_memory_range, &crash_memory_ranges, crash_reserved_mem[i].start, sz) <0 ) +return ENOCRASHKERNEL ; + } + +/* exclude backup region from crash dump memory range */ + sz =_ALIGN (info->backup_src_size, align); +if (delete_memmap (crash_memory_range, &crash_memory_ranges, info->backup_start, sz) <0 ) { +return EFAILED ; + } +/* the size of the elf headers allocated is returned in 'bufsz' */ /* Hack: With some ld versions (GNU ld version 2.14.90.0.4 20030523),
@@ -934,9 +947,9 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, elfcorehdr =add_buffer (info, tmp, bufsz, memsz, align, min_base, max_addr,-1 );dbgprintf ("Created elf header segment at 0x%lx\n" , elfcorehdr); -if (delete_memmap (memmap_p, elfcorehdr, memsz) <0 ) +if (delete_memmap (crash_memory_range, &crash_memory_ranges, elfcorehdr, memsz) <0 )return -1 ; -cmdline_add_memmap (mod_cmdline, memmap_p); +cmdline_add_memmap (mod_cmdline, crash_memory_range);if (!bzImage_support_efi_boot)cmdline_add_efi (mod_cmdline);cmdline_add_elfcorehdr (mod_cmdline, elfcorehdr);
@@ -951,6 +964,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, end = mem_range[i].end;cmdline_add_memmap_acpi (mod_cmdline, start, end); } +return 0 ; }
kexec/arch/i386/crashdump-x86.h +4 -1
@@ -20,7 +20,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,/* Kernel text size */ #define X86_64_KERNEL_TEXT_SIZE (512UL*1024*1024) -#define CRASH_MAX_MEMMAP_NR (KEXEC_MAX_SEGMENTS + 1) +#define CRASH_MAX_MEMMAP_NR CRASH_MAX_MEMORY_RANGES#define CRASH_MAX_MEMORY_RANGES (MAX_MEMORY_RANGES + 2)/* Backup Region, First 640K of System RAM. */
@@ -28,4 +28,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,#define BACKUP_SRC_END 0x0009ffff#define BACKUP_SRC_SIZE (BACKUP_SRC_END - BACKUP_SRC_START + 1) +extern struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES ]; +extern int crash_memory_ranges; +#endif /* CRASHDUMP_X86_H */
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 2/4] x86: Store memory ranges globally used for crash kernel to boot into
On Thu, Feb 13, 2014 at 09:10:53PM +0800, WANG Chao wrote:
[..]
kexec/arch/i386/crashdump-x86.c static int get_crash_memory_ranges(struct memory_range **range, int *ranges, · line 235
Quoted 6 lines
kexec/arch/i386/crashdump-x86.c +2
-0@@ -230,6 +231,8 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,/* Only Dumping memory of type System RAM. */ if (memcmp (str,"System RAM\n" ,11 ) ==0 ) { type =RANGE_RAM ; + }else if (memcmp (str,"reserved\n" ,9 ) ==0 ) { + type =RANGE_RESERVED ;
Hi Chao,
Can we take up the issue of passing reserved ranges to second kernel in a separate patchset. I had noticed higher memory usage due to that and it might have been something else.
It might be easier to handle one thing at a time. Let us first start passing the memory range we pass on command line through bootparams and once that gets merged and stablizes, write a patchset to start passing reserved memory ranges if need be.
Thanks
Vivek
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 2/4] x86: Store memory ranges globally used for crash kernel to boot into
Quoted 12 lines · Vivek Goyal
On Thu, Feb 13, 2014 at 09:10:53PM +0800, WANG Chao wrote:
[..]
kexec/arch/i386/crashdump-x86.c static int get_crash_memory_ranges(struct memory_range **range, int *ranges, · line 235
Quoted 6 lines
kexec/arch/i386/crashdump-x86.c +2
-0@@ -230,6 +231,8 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,/* Only Dumping memory of type System RAM. */ if (memcmp (str,"System RAM\n" ,11 ) ==0 ) { type =RANGE_RAM ; + }else if (memcmp (str,"reserved\n" ,9 ) ==0 ) { + type =RANGE_RESERVED ;Hi Chao,
Quoted 3 lines
Can we take up the issue of passing reserved ranges to second kernel in a separate patchset. I had noticed higher memory usage due to that and it might have been something else.
OK. That can be done later.
Quoted 5 lines
It might be easier to handle one thing at a time. Let us first start passing the memory range we pass on command line through bootparams and once that gets merged and stablizes, write a patchset to start passing reserved memory ranges if need be.
Cliff once sent a patch to pass reserved range to 2nd kernel (reverted eventually due to its dependency on another patch which needed to revert). In the patch he mentioned that some devices (PCI>0) on UV2 would fail without passing reserved range:
http://lists.infradead.org/pipermail/kexec/2013-February/007924.html
I don't dive into this issue. However I think as long as these reserved ranges are provided by the firmware, it could be useful in 2nd kernel, at least potentially.
Anyway this reserved ranges issue could be addressed later. I'll cut it out in next update.
Thanks
WANG Chao
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH 3/4 x86: add --pass-memmap-cmdline option
In reply to WANG Chao--pass-memmap-cmdline is used for pass memmap=exactmap cmdline for 2nd kernel. Later we will use this option to disable passing E820 memmap method but use the old exactmap method.
--- kexec/arch/i386/include/arch/options.h | 2 ++ kexec/arch/i386/kexec-x86.c | 4 ++++ kexec/arch/i386/kexec-x86.h | 1 + kexec/arch/i386/x86-linux-setup.h | 1 + kexec/arch/x86_64/kexec-x86_64.c | 5 +++++ 5 files changed, 13 insertions(+)
kexec/arch/i386/include/arch/options.h +2 -0
@@ -30,6 +30,7 @@#define OPT_VGA (OPT_ARCH_MAX+8)#define OPT_REAL_MODE (OPT_ARCH_MAX+9)#define OPT_ENTRY_32BIT (OPT_ARCH_MAX+10) +#define OPT_PASS_MEMMAP_CMDLINE (OPT_ARCH_MAX+11)/* Options relevant to the architecture (excluding loader-specific ones): */ #define KEXEC_ARCH_OPTIONS \
@@ -41,6 +42,7 @@ { "console-serial", 0, 0, OPT_CONSOLE_SERIAL }, \ { "elf32-core-headers", 0, 0, OPT_ELF32_CORE }, \ { "elf64-core-headers", 0, 0, OPT_ELF64_CORE }, \ + { "pass-memmap-cmdline", 0, 0, OPT_PASS_MEMMAP_CMDLINE }, \ #define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR ""
kexec/arch/i386/kexec-x86.c +4 -0
@@ -54,6 +54,7 @@ void arch_usage(void)" --console-serial Enable the serial console\n" " --elf32-core-headers Prepare core headers in ELF32 format\n" " --elf64-core-headers Prepare core headers in ELF64 format\n" +" --pass--memmap-cmdline Pass memory map via command line in kexec on panic case\n" ); }
@@ -64,6 +65,7 @@ struct arch_options_t arch_options = { .console_vga = 0, .console_serial = 0, .core_header_type = CORE_TYPE_UNDEF, + .pass_memmap_cmdline = 0, };int arch_process_options (int argc,char **argv)
@@ -133,6 +135,8 @@ int arch_process_options(int argc, char **argv)case OPT_ELF64_CORE : arch_options.core_header_type =CORE_TYPE_ELF64 ;break ; +case OPT_PASS_MEMMAP_CMDLINE : + arch_options.pass_memmap_cmdline =1 ; } }/* Reset getopt for the next pass; called in other source modules */
kexec/arch/i386/kexec-x86.h +1 -0
@@ -50,6 +50,7 @@ struct arch_options_t {uint8_t console_vga;uint8_t console_serial;enum coretype core_header_type; +uint8_t pass_memmap_cmdline; };int multiboot_x86_probe (const char *buf,off_t len);
kexec/arch/i386/x86-linux-setup.h +1 -0
@@ -30,5 +30,6 @@ void setup_linux_system_parameters(struct kexec_info *info,/* command line parameter may be appended by purgatory */ #define PURGATORY_CMDLINE_SIZE 64extern int bzImage_support_efi_boot; +extern int pass_memmap_cmdline;#endif /* X86_LINUX_SETUP_H */
kexec/arch/x86_64/kexec-x86_64.c +5 -0
@@ -53,6 +53,7 @@ void arch_usage(void)" --serial-baud=<baud_rate> Specify the serial port baud rate\n" " --console-vga Enable the vga console\n" " --console-serial Enable the serial console\n" +" --pass-memmap-cmdline Pass memory map via command line in kexec on panic case\n" ); }
@@ -63,6 +64,7 @@ struct arch_options_t arch_options = { .console_vga = 0, .console_serial = 0, .core_header_type = CORE_TYPE_ELF64, + .pass_memmap_cmdline = 0, };int arch_process_options (int argc,char **argv)
@@ -126,6 +128,9 @@ int arch_process_options(int argc, char **argv) } arch_options.serial_baud = value;break ; +case OPT_PASS_MEMMAP_CMDLINE : + arch_options.pass_memmap_cmdline =1 ; +break ; } }/* Reset getopt for the next pass; called in other source modules */
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 1/1 x86: Pass memory range via E820 for kdump
In reply to WANG Chaocommand line size is restricted by kernel, sometimes memmap=exactmap has too many memory ranges to pass to cmdline. A better approach, to pass the memory ranges for crash kernel to boot into, is filling the memory ranges into E820.
boot_params only got 128 slots for E820 map to fit in, when the number of memory map exceeds 128, use setup_data to pass the rest as extended E820 memory map.
kexec boot could also benefit from setup_data in case E820 memory map exceeds 128.
Now this new approach becomes default instead of memmap=exactmap. saved_max_pfn users can specify --pass-memmap-cmdline to use the exactmap approach.
--- kexec/arch/i386/crashdump-x86.c | 25 +++-- kexec/arch/i386/crashdump-x86.h | 1 + kexec/arch/i386/x86-linux-setup.c | 195 +++++++++++++++++++++++++++----------- 3 files changed, 158 insertions(+), 63 deletions(-)
kexec/arch/i386/crashdump-x86.c +15 -10
@@ -182,6 +182,8 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end);struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES ];int crash_memory_ranges; +int pass_memmap_cmdline; +/* Memory region reserved for storing panic kernel and other data. */ #define CRASH_RESERVED_MEM_NR 8static struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR ];
@@ -949,20 +951,23 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,dbgprintf ("Created elf header segment at 0x%lx\n" , elfcorehdr);if (delete_memmap (crash_memory_range, &crash_memory_ranges, elfcorehdr, memsz) <0 )return -1 ; -cmdline_add_memmap (mod_cmdline, crash_memory_range);if (!bzImage_support_efi_boot)cmdline_add_efi (mod_cmdline);cmdline_add_elfcorehdr (mod_cmdline, elfcorehdr); -/* Inform second kernel about the presence of ACPI tables. */ -for (i =0 ; i <CRASH_MAX_MEMORY_RANGES ; i++) { -unsigned long start, end; -if ( !( mem_range[i].type ==RANGE_ACPI - || mem_range[i].type ==RANGE_ACPI_NVS ) ) -continue ; - start = mem_range[i].start; - end = mem_range[i].end; -cmdline_add_memmap_acpi (mod_cmdline, start, end); + pass_memmap_cmdline = arch_options.pass_memmap_cmdline; +if (pass_memmap_cmdline) { +cmdline_add_memmap (mod_cmdline, crash_memory_range); +/* Inform second kernel about the presence of ACPI tables. */ +for (i =0 ; i <CRASH_MAX_MEMORY_RANGES ; i++) { +unsigned long start, end; +if ( !( mem_range[i].type ==RANGE_ACPI + || mem_range[i].type ==RANGE_ACPI_NVS ) ) +continue ; + start = mem_range[i].start; + end = mem_range[i].end; +cmdline_add_memmap_acpi (mod_cmdline, start, end); + } }return 0 ;
kexec/arch/i386/crashdump-x86.h +1 -0
@@ -30,5 +30,6 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,extern struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES ];extern int crash_memory_ranges; +extern int pass_memmap_cmdline;#endif /* CRASHDUMP_X86_H */
kexec/arch/i386/x86-linux-setup.c +142 -53
247 lines not on this page · raw message
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec