kexec-tools, x86: E820 memmap pass for kdump
Subsystems (2)
v5 cover kexec-tools, x86: E820 memmap pass for kdump
Hi, all
(Sorry for this late update. I was occupied with something else)
This patchset enables passing memory map via E820 map on x86 platform instead of memmap=exactmap. It's a better design and will solve the following problem so far:
- kernel cmdline is limited resource and large machines tend to have many memory ranges that may excceed kernel cmdline limit size.
- kASLR doesn't work with memmap=exactmap, because kASLR happens early than user defined memmap=exactmap takes effect.
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.
This patchset contains massive updates from the previous one. I take some suggestions from reviewers. I try to split the changes into smaller pieces and keep the whole change as minimal as I can so it wouldn't be too harsh to review the patch.
Any comment is appreciate!
v5->v4:
Dave:
- separate add_setup_data() to another patch
Vivek:
- adding comments for setup_data
- store crash memory range info golobally in kexec_info
v3->v4:
Linn: check return value of malloc (use xmalloc).
me: fix dbgprintf_mem_range.
v2->v3:
Linn:
- do not free sd (setup_data) buffer.
- reuse code in setup_e820 and setup_e820_ext.
v1->v2:
Vivek:
- Use function instead of macro for dbgprint_mem_range
- Do not pass reserved memory range for kdump. It could addressed later separately.
WANG Chao (10):
x86, cleanup: fix indent
x86, cleanup: add extra arguments to add_memmap() and delete_memmap() x86, cleanup: add other types of memory range for 2nd kernel boot to
memmap_p
x86, cleanup: add_memmap() only do alignment check on RANGE_RAM x86, cleanup: use dbgprint_mem_range for memory range debugging x86, cleanup: increase CRASH_MAX_MEMMAP_NR up to
CRASH_MAX_MEMORY_RANGES
x86, cleanup: Store crash memory ranges kexec_info
x86, cleanup: Add a funtion add_setup_data()
x86: add --pass-memmap-cmdline option
x86: Pass memory range via E820 for kdump
kexec/arch/i386/crashdump-x86.c | 79 +++++++-------- kexec/arch/i386/crashdump-x86.h | 2 +- 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.c | 175 ++++++++++++++++++++++----------- kexec/arch/i386/x86-linux-setup.h | 1 + kexec/arch/x86_64/kexec-x86_64.c | 5 + kexec/kexec.h | 2 + 9 files changed, 171 insertions(+), 100 deletions(-)
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 1/10 x86, cleanup: fix indent
--- kexec/arch/i386/crashdump-x86.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
kexec/arch/i386/crashdump-x86.c +5 -5
@@ -509,11 +509,11 @@ 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 ;dbgprintf ("Memmap after adding segment\n" );for (i =0 ; i <CRASH_MAX_MEMMAP_NR ; i++) {
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 2/10 x86, cleanup: add extra arguments to add_memmap() and delete_memmap()
In reply to WANG ChaoThis change will be used later:
add_memmap(.., int *nr_memmap, .., int type);delete_memmap(.., int *nr_memmap, ..);
--- kexec/arch/i386/crashdump-x86.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
kexec/arch/i386/crashdump-x86.c +13 -9
@@ -476,8 +476,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_memmap_p, +unsigned long long addr,size_t size,int type) {int i, j, nr_entries =0 , tidx =0 , align =1024 ;unsigned long long mstart, mend;
@@ -514,6 +514,8 @@ static int add_memmap(struct memory_range *memmap_p, unsigned long long addr, memmap_p[j+1 ] = memmap_p[j]; memmap_p[tidx].start = addr; memmap_p[tidx].end = addr + size -1 ; + memmap_p[tidx].type = type; + *nr_memmap_p = nr_entries +1 ;dbgprintf ("Memmap after adding segment\n" );for (i =0 ; i <CRASH_MAX_MEMMAP_NR ; i++) {
@@ -530,8 +532,8 @@ static int add_memmap(struct memory_range *memmap_p, unsigned long long addr,/* 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_memmap_p, +unsigned long long addr,size_t size) {int i, j, nr_entries =0 , tidx =-1 , operation =0 , align =1024 ;unsigned long long mstart, mend;
@@ -593,12 +595,14 @@ 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_memmap_p = 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_memmap_p = nr_entries -1 ; }dbgprintf ("Memmap after deleting segment\n" );
@@ -865,7 +869,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; +int nr_ranges =0 , nr_memmap_p =0 , align =1024 , i;struct memory_range *mem_range, *memmap_p;struct crash_elf_info elf_info;unsigned kexec_arch;
@@ -941,10 +945,10 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, 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); +add_memmap (memmap_p, &nr_memmap_p, info->backup_src_start, info->backup_src_size,RANGE_RAM );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 ) +if (add_memmap (memmap_p, &nr_memmap_p, crash_reserved_mem[i].start, sz,RANGE_RAM ) <0 )return ENOCRASHKERNEL ; }
@@ -957,7 +961,7 @@ 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 ) +if (delete_memmap (memmap_p, &nr_memmap_p, info->backup_start, sz) <0 )return EFAILED ; }
@@ -993,7 +997,7 @@ 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 (memmap_p, &nr_memmap_p, elfcorehdr, memsz) <0 )return -1 ;cmdline_add_memmap (mod_cmdline, memmap_p);if (!bzImage_support_efi_boot)
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 02/10] x86, cleanup: add extra arguments to add_memmap() and delete_memmap()
Quoted 15 lines · WANG Chao
This change will be used later:
add_memmap(.., int *nr_memmap, .., int type);delete_memmap(.., int *nr_memmap, ..);Signed-off-by WANG Chao <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)kexec/arch/i386/crashdump-x86.c +0
-0
kexec/arch/i386/crashdump-x86.c static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end) · line 480
Quoted 7 lines
kexec/arch/i386/crashdump-x86.c +2
-2@@ -476,8 +476,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_memmap_p, +unsigned long long addr,size_t size,int type)
Maybe nr_memmap is better than nr_memmap_p?
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 02/10] x86, cleanup: add extra arguments to add_memmap() and delete_memmap()
Quoted 17 lines · Dave Young
Quoted 16 lines · WANG Chao
This change will be used later:
add_memmap(.., int *nr_memmap, .., int type);delete_memmap(.., int *nr_memmap, ..);Signed-off-by WANG Chao <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)kexec/arch/i386/crashdump-x86.c +0
-0@@ -476,8 +476,8 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end)
Quoted 8 lines
kexec/arch/i386/crashdump-x86.c static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end) · line 480
Quoted 6 lines
kexec/arch/i386/crashdump-x86.c +2
-2/* 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_memmap_p, +unsigned long long addr,size_t size,int type)Maybe
nr_memmapis better thannr_memmap_p?
Sure. Will rename. I thought nr_memmap_p vs. memmap_p looked more no-brainer.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 3/10 x86, cleanup: add other types of memory range for 2nd kernel boot to memmap_p
In reply to WANG ChaoNow memmap_p contains all the memory range for 2nd kernel boot.
--- kexec/arch/i386/crashdump-x86.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kexec/arch/i386/crashdump-x86.c +4 -1
@@ -1006,12 +1006,15 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,/* Inform second kernel about the presence of ACPI tables. */ for (i =0 ; i <CRASH_MAX_MEMORY_RANGES ; i++) { -unsigned long start, end; +unsigned long start, end, size, type;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; + type = mem_range[i].type; + size = end - start; +add_memmap (memmap_p, &nr_memmap_p, start, size, type);cmdline_add_memmap_acpi (mod_cmdline, start, end); }return 0 ;
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 03/10] x86, cleanup: add other types of memory range for 2nd kernel boot to memmap_p
Quoted 1 line · WANG Chao
Now
memmap_pcontains all the memory range for 2nd kernel boot.
Hi, the patch description is not infomative, I still do not get the idea why this patch is need, what it is doing..
Quoted 13 lines
Signed-off-by WANG Chao <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)kexec/arch/i386/crashdump-x86.c +0
-0@@ -1006,12 +1006,15 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,/* Inform second kernel about the presence of ACPI tables. */
kexec/arch/i386/crashdump-x86.c int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, · line 1016
Quoted 10 lines
kexec/arch/i386/crashdump-x86.c +3
-1for (i =0 ; i <CRASH_MAX_MEMORY_RANGES ; i++) { -unsigned long start, end; +unsigned long start, end, size, type;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; + type = mem_range[i].type; + size = end - start;
Probably size = end - start + 1;
Quoted 7 lines
kexec/arch/i386/crashdump-x86.c +1
-0+add_memmap (memmap_p, &nr_memmap_p, start, size, type);cmdline_add_memmap_acpi (mod_cmdline, start, end); }return 0 ;Signature · 1 line
1.8.5.3
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 03/10] x86, cleanup: add other types of memory range for 2nd kernel boot to memmap_p
Quoted 18 lines · Dave Young
Quoted 1 line · WANG Chao
Now
memmap_pcontains all the memory range for 2nd kernel boot.Hi, the patch description is not infomative, I still do not get the idea why this patch is need, what it is doing..
Quoted 12 lines
Signed-off-by WANG Chao <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)kexec/arch/i386/crashdump-x86.c +0
-0@@ -1006,12 +1006,15 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
Quoted 13 lines
kexec/arch/i386/crashdump-x86.c int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, · line 1016
Quoted 11 lines
kexec/arch/i386/crashdump-x86.c +3
-1/* Inform second kernel about the presence of ACPI tables. */ for (i =0 ; i <CRASH_MAX_MEMORY_RANGES ; i++) { -unsigned long start, end; +unsigned long start, end, size, type;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; + type = mem_range[i].type; + size = end - start;Probably size = end - start + 1;
Right. end is inclusive. Will fix.
Quoted 8 lines
Quoted 8 lines
kexec/arch/i386/crashdump-x86.c +1
-0+add_memmap (memmap_p, &nr_memmap_p, start, size, type);cmdline_add_memmap_acpi (mod_cmdline, start, end); }return 0 ;Signature · 1 line
1.8.5.3
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 4/10 x86, cleanup: add_memmap() only do alignment check on RANGE_RAM
In reply to WANG Chao--- kexec/arch/i386/crashdump-x86.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kexec/arch/i386/crashdump-x86.c +2 -2
@@ -482,8 +482,8 @@ static int add_memmap(struct memory_range *memmap_p, int *nr_memmap_p,int i, j, nr_entries =0 , tidx =0 , align =1024 ;unsigned long long mstart, mend; -/* Do alignment check. */ -if ((addr%align) || (size%align)) +/* Do alignment check if it's RANGE_RAM */ +if ((type ==RANGE_RAM ) && ((addr%align) || (size%align)))return -1 ;/* Make sure at least one entry in list is free. */
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 5/10 x86, cleanup: use dbgprint_mem_range for memory range debugging
In reply to WANG Chao--- kexec/arch/i386/crashdump-x86.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-)
kexec/arch/i386/crashdump-x86.c +3 -23
@@ -517,15 +517,7 @@ static int add_memmap(struct memory_range *memmap_p, int *nr_memmap_p, memmap_p[tidx].type = type; *nr_memmap_p = 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_memmap_p);return 0 ; }
@@ -605,16 +597,7 @@ static int delete_memmap(struct memory_range *memmap_p, int *nr_memmap_p, *nr_memmap_p = 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_memmap_p);return 0 ; }
@@ -913,10 +896,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
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 05/10] x86, cleanup: use dbgprint_mem_range for memory range debugging
Wang Chao,
Quoted 46 lines · WANG Chao
Signed-off-by WANG Chao <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-)kexec/arch/i386/crashdump-x86.c +2
-19@@ -517,15 +517,7 @@ static int add_memmap(struct memory_range *memmap_p, int *nr_memmap_p, memmap_p[tidx].type = type; *nr_memmap_p = 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_memmap_p);return 0 ; }@@ -605,16 +597,7 @@ static int delete_memmap(struct memory_range *memmap_p, int *nr_memmap_p, *nr_memmap_p = 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_memmap_p);return 0 ; }@@ -913,10 +896,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
kexec/arch/i386/crashdump-x86.c int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, · line 902
Quoted 10 lines
kexec/arch/i386/crashdump-x86.c +1
-4get_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
Is the definition for dbgprint_mem_range() missing? It was added in patch v4 1/4 but I do not see it in this set.
Linn
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 05/10] x86, cleanup: use dbgprint_mem_range for memory range debugging
Quoted 2 lines
Is the definition for
dbgprint_mem_range()missing? It was added in patch v4 1/4 but I do not see it in this set.
I think that one has been merged by Simon..
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 05/10] x86, cleanup: use dbgprint_mem_range for memory range debugging
Quoted 4 lines · Dave Young
Quoted 2 lines
Is the definition for
dbgprint_mem_range()missing? It was added in patch v4 1/4 but I do not see it in this set.I think that one has been merged by Simon..
Yes, Simon has picked up this one.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 6/10 x86, cleanup: increase CRASH_MAX_MEMMAP_NR up to CRASH_MAX_MEMORY_RANGES
In reply to WANG ChaoCRASH_MAX_MEMMAP_NR now is defined (KEXEC_MAX_SEGMENTS + 2) which is way lower than the memmap we can pass to 2nd kernel.
--- kexec/arch/i386/crashdump-x86.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/arch/i386/crashdump-x86.h +1 -1
@@ -20,8 +20,8 @@ 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_MEMORY_RANGES (MAX_MEMORY_RANGES + 2) +#define CRASH_MAX_MEMMAP_NR CRASH_MAX_MEMORY_RANGES/* Backup Region, First 640K of System RAM. */ #define BACKUP_SRC_START 0x00000000
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 6/10 x86, cleanup: Store crash memory ranges kexec_info
In reply to WANG ChaoAdd two new members to kexec_info structure:
struct memory_range *crash_range
int nr_crash_ranges;
crash_range contains the memory ranges used to boot 2nd kernel. nr_crash_ranges contains the count of the crash memory ranges.
--- kexec/arch/i386/crashdump-x86.c | 6 ++++++ kexec/kexec.h | 2 ++ 2 files changed, 8 insertions(+)
kexec/arch/i386/crashdump-x86.c +6 -0
@@ -997,6 +997,12 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,add_memmap (memmap_p, &nr_memmap_p, start, size, type);cmdline_add_memmap_acpi (mod_cmdline, start, end); } + +/* Store 2nd kernel boot memory ranges for later reference in +* x86-setup-linux.c: setup_linux_system_parameters() */ + info->crash_range = memmap_p; + info->nr_crash_ranges = nr_memmap_p; +return 0 ; }
kexec/kexec.h +2 -0
@@ -148,6 +148,8 @@ struct kexec_info {int nr_segments;struct memory_range *memory_range;int memory_ranges; +struct memory_range *crash_range; +int nr_crash_ranges;void *entry;struct mem_ehdr rhdr;unsigned long backup_start;
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 06/10] x86, cleanup: Store crash memory ranges kexec_info
Quoted 36 lines · WANG Chao
Add two new members to
kexec_infostructure:struct
memory_range*crash_range
intnr_crash_ranges;
crash_rangecontains the memory ranges used to boot 2nd kernel.nr_crash_rangescontains the count of the crash memory ranges.Signed-off-by WANG Chao <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 6 ++++++ kexec/kexec.h | 2 ++ 2 files changed, 8 insertions(+)kexec/arch/i386/crashdump-x86.c +6
-0@@ -997,6 +997,12 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,add_memmap (memmap_p, &nr_memmap_p, start, size, type);cmdline_add_memmap_acpi (mod_cmdline, start, end); } + +/* Store 2nd kernel boot memory ranges for later reference in +* x86-setup-linux.c: setup_linux_system_parameters() */ + info->crash_range = memmap_p; + info->nr_crash_ranges = nr_memmap_p; +return 0 ; }kexec/kexec.h +0
-0
kexec/kexec.h struct kexec_info { · line 152
Quoted 5 lines
kexec/kexec.h +2
-0@@ -148,6 +148,8 @@ struct kexec_info {int nr_segments;struct memory_range *memory_range;int memory_ranges; +struct memory_range *crash_range; +int nr_crash_ranges;
Is the memory_range field used in crash case? If not how about reuse the field for crash ranges.
Quoted 6 lines
kexec/kexec.h +0
-0void *entry;struct mem_ehdr rhdr;unsigned long backup_start;Signature · 1 line
1.8.5.3
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 06/10] x86, cleanup: Store crash memory ranges kexec_info
Quoted 32 lines · Dave Young
Quoted 31 lines · WANG Chao
Add two new members to
kexec_infostructure:struct
memory_range*crash_range
intnr_crash_ranges;
crash_rangecontains the memory ranges used to boot 2nd kernel.nr_crash_rangescontains the count of the crash memory ranges.Signed-off-by WANG Chao <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 6 ++++++ kexec/kexec.h | 2 ++ 2 files changed, 8 insertions(+)kexec/arch/i386/crashdump-x86.c +6
-0@@ -997,6 +997,12 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,add_memmap (memmap_p, &nr_memmap_p, start, size, type);cmdline_add_memmap_acpi (mod_cmdline, start, end); } + +/* Store 2nd kernel boot memory ranges for later reference in +* x86-setup-linux.c: setup_linux_system_parameters() */ + info->crash_range = memmap_p; + info->nr_crash_ranges = nr_memmap_p; +return 0 ; }
Quoted 12 lines
kexec/kexec.h struct kexec_info { · line 152
Quoted 10 lines
kexec/kexec.h +2
-0@@ -148,6 +148,8 @@ struct kexec_info {int nr_segments;struct memory_range *memory_range;int memory_ranges; +struct memory_range *crash_range; +int nr_crash_ranges;Is the
memory_rangefield used in crash case? If not how about reuse the field for crash ranges.
We need memory_range field in the --pass-memmap-cmdline case.
Quoted 7 lines
Quoted 7 lines
kexec/kexec.h +0
-0void *entry;struct mem_ehdr rhdr;unsigned long backup_start;Signature · 1 line
1.8.5.3
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 06/10] x86, cleanup: Store crash memory ranges kexec_info
Quoted 46 lines · WANG Chao
Quoted 32 lines · Dave Young
Quoted 31 lines · WANG Chao
Add two new members to
kexec_infostructure:struct
memory_range*crash_range
intnr_crash_ranges;
crash_rangecontains the memory ranges used to boot 2nd kernel.nr_crash_rangescontains the count of the crash memory ranges.Signed-off-by WANG Chao <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 6 ++++++ kexec/kexec.h | 2 ++ 2 files changed, 8 insertions(+)kexec/arch/i386/crashdump-x86.c +6
-0@@ -997,6 +997,12 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,add_memmap (memmap_p, &nr_memmap_p, start, size, type);cmdline_add_memmap_acpi (mod_cmdline, start, end); } + +/* Store 2nd kernel boot memory ranges for later reference in +* x86-setup-linux.c: setup_linux_system_parameters() */ + info->crash_range = memmap_p; + info->nr_crash_ranges = nr_memmap_p; +return 0 ; }Quoted 12 lines
kexec/kexec.h struct kexec_info { · line 152
Quoted 10 lines
kexec/kexec.h +2
-0@@ -148,6 +148,8 @@ struct kexec_info {int nr_segments;struct memory_range *memory_range;int memory_ranges; +struct memory_range *crash_range; +int nr_crash_ranges;Is the
memory_rangefield used in crash case? If not how about reuse the field for crash ranges.
Quoted 1 line
We need
memory_rangefield in the --pass-memmap-cmdline case.
I can not think out why it is needed. In case memmap=exactmap the e820 should be totally ignored.
It's my understanding for the user defined memmap, but there's could be other tricks.. Could you test kdump for dropping the e820 passing with memmap=exactmap?
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 06/10] x86, cleanup: Store crash memory ranges kexec_info
Quoted 47 lines · Dave Young
Quoted 46 lines · WANG Chao
Quoted 44 lines · Dave Young
Quoted 36 lines · WANG Chao
Add two new members to
kexec_infostructure:struct
memory_range*crash_range
intnr_crash_ranges;
crash_rangecontains the memory ranges used to boot 2nd kernel.nr_crash_rangescontains the count of the crash memory ranges.Signed-off-by WANG Chao <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 6 ++++++ kexec/kexec.h | 2 ++ 2 files changed, 8 insertions(+)kexec/arch/i386/crashdump-x86.c +6
-0@@ -997,6 +997,12 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,add_memmap (memmap_p, &nr_memmap_p, start, size, type);cmdline_add_memmap_acpi (mod_cmdline, start, end); } + +/* Store 2nd kernel boot memory ranges for later reference in +* x86-setup-linux.c: setup_linux_system_parameters() */ + info->crash_range = memmap_p; + info->nr_crash_ranges = nr_memmap_p; +return 0 ; }kexec/kexec.h +0
-0kexec/kexec.h struct kexec_info { · line 152
Quoted 5 lines
kexec/kexec.h +2
-0@@ -148,6 +148,8 @@ struct kexec_info {int nr_segments;struct memory_range *memory_range;int memory_ranges; +struct memory_range *crash_range; +int nr_crash_ranges;Is the
memory_rangefield used in crash case? If not how about reuse the field for crash ranges.
Quoted 3 lines
Quoted 1 line
We need
memory_rangefield in the --pass-memmap-cmdline case.I can not think out why it is needed. In case memmap=exactmap the e820 should be totally ignored.
Actually, we use this e820 to calculate saved_max_pfn.
In memmap=exactmap case, we pass two kinds of e820:
- e820 in boot_params filled with 1st kernel's memmap
- User defined exactmap in kernel cmdline
Quoted 3 lines
It's my understanding for the user defined memmap, but there's could be other tricks.. Could you test kdump for dropping the e820 passing with memmap=exactmap?
We can't get rid of passing 1st kernel's memmap as long as saved_max_pfn is still in use in calgary iommu.
And that's why I introduce --pass-memmap-cmdline as a fallback method for calgary iommu user with older kernel.
Thanks
WANG Chao
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 06/10] x86, cleanup: Store crash memory ranges kexec_info
Quoted 61 lines · WANG Chao
Quoted 47 lines · Dave Young
Quoted 46 lines · WANG Chao
Quoted 44 lines · Dave Young
Quoted 36 lines · WANG Chao
Add two new members to
kexec_infostructure:struct
memory_range*crash_range
intnr_crash_ranges;
crash_rangecontains the memory ranges used to boot 2nd kernel.nr_crash_rangescontains the count of the crash memory ranges.Signed-off-by WANG Chao <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 6 ++++++ kexec/kexec.h | 2 ++ 2 files changed, 8 insertions(+)kexec/arch/i386/crashdump-x86.c +6
-0@@ -997,6 +997,12 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,add_memmap (memmap_p, &nr_memmap_p, start, size, type);cmdline_add_memmap_acpi (mod_cmdline, start, end); } + +/* Store 2nd kernel boot memory ranges for later reference in +* x86-setup-linux.c: setup_linux_system_parameters() */ + info->crash_range = memmap_p; + info->nr_crash_ranges = nr_memmap_p; +return 0 ; }kexec/kexec.h +0
-0kexec/kexec.h struct kexec_info { · line 152
Quoted 5 lines
kexec/kexec.h +2
-0@@ -148,6 +148,8 @@ struct kexec_info {int nr_segments;struct memory_range *memory_range;int memory_ranges; +struct memory_range *crash_range; +int nr_crash_ranges;Is the
memory_rangefield used in crash case? If not how about reuse the field for crash ranges.Quoted 3 lines
Quoted 1 line
We need
memory_rangefield in the --pass-memmap-cmdline case.I can not think out why it is needed. In case memmap=exactmap the e820 should be totally ignored.
Actually, we use this e820 to calculate
saved_max_pfn.In memmap=exactmap case, we pass two kinds of e820:
- e820 in
boot_paramsfilled with 1st kernel's memmap
- User defined exactmap in kernel cmdlineQuoted 1 line
Quoted 8 lines
Quoted 2 lines
It's my understanding for the user defined memmap, but there's could be other tricks.. Could you test kdump for dropping the e820 passing with memmap=exactmap?
We can't get rid of passing 1st kernel's memmap as long as
saved_max_pfnis still in use in calgary iommu.And that's why I introduce --pass-memmap-cmdline as a fallback method for calgary iommu user with older kernel.
Ok, I got it. Thanks the explanation.
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 7/10 x86, cleanup: Add a funtion add_setup_data()
In reply to WANG Chaoadd_setup_data() is used to add an instance to the single linked list of setup_data structure.
--- kexec/arch/i386/x86-linux-setup.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
kexec/arch/i386/x86-linux-setup.c +20 -6
@@ -603,6 +603,22 @@ struct efi_info { };/* +* Add another instance to single linked list of struct setup_data. +* Please refer to kernel Documentation/x86/boot.txt for more details +* about setup_data structure. +*/ +static void add_setup_data (struct kexec_info *info, +struct x86_linux_param_header *real_mode, +struct setup_data *sd) +{ +int sdsize =sizeof (struct setup_data ) + sd->len; + + sd->next = real_mode->setup_data; + real_mode->setup_data =add_buffer (info, sd, sdsize, sdsize,getpagesize (), +0x100000 ,ULONG_MAX ,INT_MAX ); +} + +/* * setup_efi_data will collect below data and pass them to 2nd kernel. * 1) SMBIOS, fw_vendor, runtime, config_table, they are passed via x86 * setup_data.
@@ -611,11 +627,11 @@ struct efi_info {static int setup_efi_data (struct kexec_info *info,struct x86_linux_param_header *real_mode) { -int64_t setup_data_paddr, memmap_paddr; +int64_t memmap_paddr;struct setup_data *sd;struct efi_setup_data *esd;struct efi_mem_descriptor *maps; -int nr_maps, size, sdsize, ret =0 ; +int nr_maps, size, ret =0 ;struct efi_info *ei = (struct efi_info *)real_mode->efi_info; ret =access ("/sys/firmware/efi/systab" ,F_OK );
@@ -648,10 +664,8 @@ static int setup_efi_data(struct kexec_info *info, sd->len =sizeof (*esd);memcpy (sd->data, esd,sizeof (*esd));free (esd); - sdsize = sd->len +sizeof (struct setup_data ); - setup_data_paddr =add_buffer (info, sd, sdsize, sdsize,getpagesize (), -0x100000 ,ULONG_MAX ,INT_MAX ); - real_mode->setup_data = setup_data_paddr; + +add_setup_data (info, real_mode, sd); size = nr_maps *sizeof (struct efi_mem_descriptor ); memmap_paddr = add_buffer(info, maps, size, size, getpagesize(),
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 7/10 x86, cleanup: Store crash memory ranges kexec_info
In reply to WANG ChaoAdd two new members to kexec_info structure:
struct memory_range *crash_range
int nr_crash_ranges;
crash_range contains the memory ranges used to boot 2nd kernel. nr_crash_ranges contains the count of the crash memory ranges.
--- kexec/arch/i386/crashdump-x86.c | 6 ++++++ kexec/kexec.h | 2 ++ 2 files changed, 8 insertions(+)
kexec/arch/i386/crashdump-x86.c +6 -0
@@ -997,6 +997,12 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,add_memmap (memmap_p, &nr_memmap_p, start, size, type);cmdline_add_memmap_acpi (mod_cmdline, start, end); } + +/* Store 2nd kernel boot memory ranges for later reference in +* x86-setup-linux.c: setup_linux_system_parameters() */ + info->crash_range = memmap_p; + info->nr_crash_ranges = nr_memmap_p; +return 0 ; }
kexec/kexec.h +2 -0
@@ -148,6 +148,8 @@ struct kexec_info {int nr_segments;struct memory_range *memory_range;int memory_ranges; +struct memory_range *crash_range; +int nr_crash_ranges;void *entry;struct mem_ehdr rhdr;unsigned long backup_start;
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 8/10 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/x86_64/kexec-x86_64.c | 5 +++++ 4 files changed, 12 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/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 v5 8/10 x86, cleanup: Add a funtion add_setup_data()
In reply to WANG Chaoadd_setup_data() is used to add an instance to the single linked list of setup_data structure.
--- kexec/arch/i386/x86-linux-setup.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
kexec/arch/i386/x86-linux-setup.c +20 -6
@@ -603,6 +603,22 @@ struct efi_info { };/* +* Add another instance to single linked list of struct setup_data. +* Please refer to kernel Documentation/x86/boot.txt for more details +* about setup_data structure. +*/ +static void add_setup_data (struct kexec_info *info, +struct x86_linux_param_header *real_mode, +struct setup_data *sd) +{ +int sdsize =sizeof (struct setup_data ) + sd->len; + + sd->next = real_mode->setup_data; + real_mode->setup_data =add_buffer (info, sd, sdsize, sdsize,getpagesize (), +0x100000 ,ULONG_MAX ,INT_MAX ); +} + +/* * setup_efi_data will collect below data and pass them to 2nd kernel. * 1) SMBIOS, fw_vendor, runtime, config_table, they are passed via x86 * setup_data.
@@ -611,11 +627,11 @@ struct efi_info {static int setup_efi_data (struct kexec_info *info,struct x86_linux_param_header *real_mode) { -int64_t setup_data_paddr, memmap_paddr; +int64_t memmap_paddr;struct setup_data *sd;struct efi_setup_data *esd;struct efi_mem_descriptor *maps; -int nr_maps, size, sdsize, ret =0 ; +int nr_maps, size, ret =0 ;struct efi_info *ei = (struct efi_info *)real_mode->efi_info; ret =access ("/sys/firmware/efi/systab" ,F_OK );
@@ -648,10 +664,8 @@ static int setup_efi_data(struct kexec_info *info, sd->len =sizeof (*esd);memcpy (sd->data, esd,sizeof (*esd));free (esd); - sdsize = sd->len +sizeof (struct setup_data ); - setup_data_paddr =add_buffer (info, sd, sdsize, sdsize,getpagesize (), -0x100000 ,ULONG_MAX ,INT_MAX ); - real_mode->setup_data = setup_data_paddr; + +add_setup_data (info, real_mode, sd); size = nr_maps *sizeof (struct efi_mem_descriptor ); memmap_paddr = add_buffer(info, maps, size, size, getpagesize(),
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v5 9/10 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/x86_64/kexec-x86_64.c | 5 +++++ 4 files changed, 12 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/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 v5 9/10 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. And also memmap=exactmap and kASLR doesn't work together.
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 | 6 +- kexec/arch/i386/x86-linux-setup.c | 149 +++++++++++++++++++++++++------------- kexec/arch/i386/x86-linux-setup.h | 1 + 3 files changed, 103 insertions(+), 53 deletions(-)
kexec/arch/i386/crashdump-x86.c +4 -2
@@ -979,7 +979,8 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,dbgprintf ("Created elf header segment at 0x%lx\n" , elfcorehdr);if (delete_memmap (memmap_p, &nr_memmap_p, elfcorehdr, memsz) <0 )return -1 ; -cmdline_add_memmap (mod_cmdline, memmap_p); +if (arch_options.pass_memmap_cmdline) +cmdline_add_memmap (mod_cmdline, memmap_p);if (!bzImage_support_efi_boot)cmdline_add_efi (mod_cmdline);cmdline_add_elfcorehdr (mod_cmdline, elfcorehdr);
@@ -995,7 +996,8 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, type = mem_range[i].type; size = end - start;add_memmap (memmap_p, &nr_memmap_p, start, size, type); -cmdline_add_memmap_acpi (mod_cmdline, start, end); +if (arch_options.pass_memmap_cmdline) +cmdline_add_memmap_acpi (mod_cmdline, start, end); }/* Store 2nd kernel boot memory ranges for later reference in
kexec/arch/i386/x86-linux-setup.c +98 -51
179 lines not on this page · raw message
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 struct arch_options_t arch_options;#endif /* X86_LINUX_SETUP_H */
Signature · 7 lines
1.8.5.3 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 09/10] x86: Pass memory range via E820 for kdump
Quoted 79 lines · WANG Chao
command line size is restricted by kernel, sometimes memmap=exactmap has too many memory ranges to pass to cmdline. And also memmap=exactmap and kASLR doesn't work together.
A better approach, to pass the memory ranges for crash kernel to boot into, is filling the memory ranges into E820.
boot_paramsonly got 128 slots for E820 map to fit in, when the number of memory map exceeds 128, usesetup_datato pass the rest as extended E820 memory map.kexec boot could also benefit from
setup_datain case E820 memory map exceeds 128.Now this new approach becomes default instead of memmap=exactmap.
saved_max_pfnusers can specify --pass-memmap-cmdline to use the exactmap approach.Signed-off-by WANG Chao <[email protected]>Tested-by Linn Crosetto <[email protected]>Reviewed-by Linn Crosetto <[email protected]>Signed-off-by WANG Chao <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 6 +- kexec/arch/i386/x86-linux-setup.c | 149 +++++++++++++++++++++++++------------- kexec/arch/i386/x86-linux-setup.h | 1 + 3 files changed, 103 insertions(+), 53 deletions(-)kexec/arch/i386/crashdump-x86.c +4
-2@@ -979,7 +979,8 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,dbgprintf ("Created elf header segment at 0x%lx\n" , elfcorehdr);if (delete_memmap (memmap_p, &nr_memmap_p, elfcorehdr, memsz) <0 )return -1 ; -cmdline_add_memmap (mod_cmdline, memmap_p); +if (arch_options.pass_memmap_cmdline) +cmdline_add_memmap (mod_cmdline, memmap_p);if (!bzImage_support_efi_boot)cmdline_add_efi (mod_cmdline);cmdline_add_elfcorehdr (mod_cmdline, elfcorehdr);@@ -995,7 +996,8 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, type = mem_range[i].type; size = end - start;add_memmap (memmap_p, &nr_memmap_p, start, size, type); -cmdline_add_memmap_acpi (mod_cmdline, start, end); +if (arch_options.pass_memmap_cmdline) +cmdline_add_memmap_acpi (mod_cmdline, start, end); }/* Store 2nd kernel boot memory ranges for later reference in kexec/arch/i386/x86-linux-setup.c +5
-2@@ -36,8 +36,6 @@#include "x86-linux-setup.h" #include "../../kexec/kexec-syscall.h" -#define SETUP_EFI 4 -void init_linux_parameters (struct x86_linux_param_header *real_mode) {/* Fill in the values that are usually provided by the kernel. */ @@ -502,6 +500,11 @@ struct efi_setup_data {struct setup_data {uint64_t next;uint32_t type; +#define SETUP_NONE 0 +#define SETUP_E820_EXT 1 +#define SETUP_DTB 2 +#define SETUP_PCI 3 +#define SETUP_EFI 4uint32_t len;uint8_t data[0 ]; } __attribute__((packed));@@ -684,6 +687,98 @@ out:return ret;
kexec/arch/i386/x86-linux-setup.c out: · line 697
Quoted 10 lines
kexec/arch/i386/x86-linux-setup.c +8
-0} +static void add_e820_map_from_mr (struct x86_linux_param_header *real_mode, +struct e820entry *e820,struct memory_range *range,int nr_range) +{ +int i; + +for (i =0 ; i < nr_range; i++) { + e820[i].addr = range[i].start; + e820[i].size = range[i].end - range[i].start;
I see it's same as original code but I still feel it should be end - start + 1;
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 09/10] x86: Pass memory range via E820 for kdump
Quoted 12 lines · Dave Young
kexec/arch/i386/x86-linux-setup.c out: · line 697
Quoted 9 lines
kexec/arch/i386/x86-linux-setup.c +8
-0+static void add_e820_map_from_mr (struct x86_linux_param_header *real_mode, +struct e820entry *e820,struct memory_range *range,int nr_range) +{ +int i; + +for (i =0 ; i < nr_range; i++) { + e820[i].addr = range[i].start; + e820[i].size = range[i].end - range[i].start;I see it's same as original code but I still feel it should be end - start + 1;
I can't see how it could possibly be +1.
How do you encode range[].end? If it is inclusive it should be end - start - 1, if it is a semiclosed range (the normal thing in computer contexts) then the code above is correct.
-hpa
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 09/10] x86: Pass memory range via E820 for kdump
Quoted 14 lines · H. Peter Anvin
Quoted 12 lines · Dave Young
kexec/arch/i386/x86-linux-setup.c out: · line 697
Quoted 9 lines
kexec/arch/i386/x86-linux-setup.c +8
-0+static void add_e820_map_from_mr (struct x86_linux_param_header *real_mode, +struct e820entry *e820,struct memory_range *range,int nr_range) +{ +int i; + +for (i =0 ; i < nr_range; i++) { + e820[i].addr = range[i].start; + e820[i].size = range[i].end - range[i].start;I see it's same as original code but I still feel it should be end - start + 1;
Quoted 5 lines
I can't see how it could possibly be +1.
How do you encode range[].end? If it is inclusive it should be end - start - 1, if it is a semiclosed range (the normal thing in computer contexts) then the code above is correct.
Say the first range from my /proc/iomem:
00000000-00000fff : reserved
Shouldn't the size be 0x1000? It looks like closed range instead of semiclosed range.
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 09/10] x86: Pass memory range via E820 for kdump
Quoted 15 lines · Dave Young
Quoted 14 lines · H. Peter Anvin
Quoted 12 lines · Dave Young
kexec/arch/i386/x86-linux-setup.c out: · line 697
Quoted 9 lines
kexec/arch/i386/x86-linux-setup.c +8
-0+static void add_e820_map_from_mr (struct x86_linux_param_header *real_mode, +struct e820entry *e820,struct memory_range *range,int nr_range) +{ +int i; + +for (i =0 ; i < nr_range; i++) { + e820[i].addr = range[i].start; + e820[i].size = range[i].end - range[i].start;I see it's same as original code but I still feel it should be end - start + 1;
Quoted 5 lines
Quoted 5 lines
I can't see how it could possibly be +1.
How do you encode range[].end? If it is inclusive it should be end - start - 1, if it is a semiclosed range (the normal thing in computer contexts) then the code above is correct.
I obviously got the above backwards in my head. Please ignore.
Quoted 5 lines
Say the first range from my
/proc/iomem:
00000000-00000fff : reservedShouldn't the size be
0x1000? It looks like closed range instead of semiclosed range.
You're right. I thought we mangled the contents for /proc/iomem, but we actually keep the contents as a closed range.
So never mind me! -ENOBRAINTODAY.
-hpa
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 09/10] x86: Pass memory range via E820 for kdump
In reply to Dave YoungQuoted 17 lines · Dave Young
Quoted 16 lines · H. Peter Anvin
Quoted 12 lines · Dave Young
kexec/arch/i386/x86-linux-setup.c out: · line 697
Quoted 9 lines
kexec/arch/i386/x86-linux-setup.c +8
-0+static void add_e820_map_from_mr (struct x86_linux_param_header *real_mode, +struct e820entry *e820,struct memory_range *range,int nr_range) +{ +int i; + +for (i =0 ; i < nr_range; i++) { + e820[i].addr = range[i].start; + e820[i].size = range[i].end - range[i].start;I see it's same as original code but I still feel it should be end - start + 1;
I can't see how it could possibly be +1.
Quoted 8 lines
Quoted 3 lines
How do you encode range[].end? If it is inclusive it should be end - start - 1, if it is a semiclosed range (the normal thing in computer contexts) then the code above is correct.
Say the first range from my
/proc/iomem:
00000000-00000fff : reservedShouldn't the size be
0x1000? It looks like closed range instead of semiclosed range.
You're right. range[].end is inclusive and size should be (end - start + 1)
I'll fix it.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v5 09/10] x86: Pass memory range via E820 for kdump
Quoted 22 lines · WANG Chao
Quoted 21 lines · Dave Young
Quoted 19 lines · H. Peter Anvin
Quoted 12 lines · Dave Young
kexec/arch/i386/x86-linux-setup.c out: · line 697
Quoted 9 lines
kexec/arch/i386/x86-linux-setup.c +8
-0+static void add_e820_map_from_mr (struct x86_linux_param_header *real_mode, +struct e820entry *e820,struct memory_range *range,int nr_range) +{ +int i; + +for (i =0 ; i < nr_range; i++) { + e820[i].addr = range[i].start; + e820[i].size = range[i].end - range[i].start;I see it's same as original code but I still feel it should be end - start + 1;
I can't see how it could possibly be +1.
How do you encode range[].end? If it is inclusive it should be end - start - 1, if it is a semiclosed range (the normal thing in computer contexts) then the code above is correct.
Quoted 6 lines
Quoted 4 lines
Say the first range from my
/proc/iomem:
00000000-00000fff : reservedShouldn't the size be
0x1000? It looks like closed range instead of semiclosed range.You're right. range[].end is inclusive and size should be (end - start + 1)
In kexec path, memory range .end is exclusive however. I think it should also be updated to inclusive to unify the encoding of memory range for both kexec and kdump.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 60 lines · WANG Chao
Hi, all
(Sorry for this late update. I was occupied with something else)
This patchset enables passing memory map via E820 map on x86 platform instead of memmap=exactmap. It's a better design and will solve the following problem so far:
- kernel cmdline is limited resource and large machines tend to have many memory ranges that may excceed kernel cmdline limit size.
- kASLR doesn't work with memmap=exactmap, because kASLR happens early than user defined memmap=exactmap takes effect.Unfortunately,
saved_max_pfnstill 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.This patchset contains massive updates from the previous one. I take some suggestions from reviewers. I try to split the changes into smaller pieces and keep the whole change as minimal as I can so it wouldn't be too harsh to review the patch.
Any comment is appreciate!
v5->v4:
Dave:
- separateadd_setup_data()to another patch
Vivek:
- adding comments forsetup_data
- store crash memory range info golobally inkexec_info
v3->v4:
Linn: check return value of malloc (use xmalloc).
me: fixdbgprintf_mem_range.
v2->v3:
Linn:
- do not free sd (setup_data) buffer.
- reuse code insetup_e820andsetup_e820_ext.
v1->v2:
Vivek:
- Use function instead of macro fordbgprint_mem_range
- Do not pass reserved memory range for kdump. It could addressed later separately.WANG Chao (10):
x86, cleanup: fix indent
x86, cleanup: add extra arguments toadd_memmap()anddelete_memmap()x86, cleanup: add other types of memory range for 2nd kernel boot to
memmap_p
x86, cleanup:add_memmap()only do alignment check onRANGE_RAMx86, cleanup: usedbgprint_mem_rangefor memory range debugging x86, cleanup: increaseCRASH_MAX_MEMMAP_NRup to
CRASH_MAX_MEMORY_RANGES
x86, cleanup: Store crash memory rangeskexec_info
x86, cleanup: Add a funtionadd_setup_data()
x86: add --pass-memmap-cmdline option
x86: Pass memory range via E820 for kdump
Quoted 10 lines
kexec/arch/i386/crashdump-x86.c | 79 +++++++-------- kexec/arch/i386/crashdump-x86.h | 2 +- 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.c | 175 ++++++++++++++++++++++----------- kexec/arch/i386/x86-linux-setup.h | 1 + kexec/arch/x86_64/kexec-x86_64.c | 5 + kexec/kexec.h | 2 + 9 files changed, 171 insertions(+), 100 deletions(-)
Hi,
Here is what I received, seems there's some duplicate patches?
2535 T 04/10 WANG Chao [PATCH v5 00/10] kexec-tools, x86: E820 memmap pass for kdump 2536 T 04/10 WANG Chao [PATCH v5 01/10] x86, cleanup: fix indent 2537 T 04/10 WANG Chao [PATCH v5 02/10] x86, cleanup: add extra arguments to add_memmap() and delete_memmap() 2538 T 04/10 WANG Chao [PATCH v5 03/10] x86, cleanup: add other types of memory range for 2nd kernel boot to memmap_ 2539 T 04/10 WANG Chao [PATCH v5 04/10] x86, cleanup: add_memmap() only do alignment check on RANGE_RAM 2540 T 04/10 WANG Chao [PATCH v5 05/10] x86, cleanup: use dbgprint_mem_range for memory range debugging 2541 T 04/10 WANG Chao [PATCH v5 06/10] x86, cleanup: increase CRASH_MAX_MEMMAP_NR up to CRASH_MAX_MEMORY_RANGES 2542 T 04/10 WANG Chao [PATCH v5 06/10] x86, cleanup: Store crash memory ranges kexec_info 2543 T 04/10 WANG Chao [PATCH v5 07/10] x86, cleanup: Add a funtion add_setup_data() 2544 T 04/10 WANG Chao [PATCH v5 07/10] x86, cleanup: Store crash memory ranges kexec_info
There's another [PATCH v5 06/10] x86, cleanup: Store crash memory ranges kexec_info
2545 T 04/10 WANG Chao [PATCH v5 08/10] x86: add --pass-memmap-cmdline option 2546 T 04/10 WANG Chao [PATCH v5 08/10] x86, cleanup: Add a funtion add_setup_data()
There's another [PATCH v5 07/10] x86, cleanup: Add a funtion add_setup_data()
2547 T 04/10 WANG Chao [PATCH v5 09/10] x86: add --pass-memmap-cmdline option 2548 T 04/10 WANG Chao [PATCH v5 09/10] x86: Pass memory range via E820 for kdump
Thanks
Dave
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 72 lines · Dave Young
Quoted 60 lines · WANG Chao
Hi, all
(Sorry for this late update. I was occupied with something else)
This patchset enables passing memory map via E820 map on x86 platform instead of memmap=exactmap. It's a better design and will solve the following problem so far:
- kernel cmdline is limited resource and large machines tend to have many memory ranges that may excceed kernel cmdline limit size.
- kASLR doesn't work with memmap=exactmap, because kASLR happens early than user defined memmap=exactmap takes effect.Unfortunately,
saved_max_pfnstill 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.This patchset contains massive updates from the previous one. I take some suggestions from reviewers. I try to split the changes into smaller pieces and keep the whole change as minimal as I can so it wouldn't be too harsh to review the patch.
Any comment is appreciate!
v5->v4:
Dave:
- separateadd_setup_data()to another patch
Vivek:
- adding comments forsetup_data
- store crash memory range info golobally inkexec_info
v3->v4:
Linn: check return value of malloc (use xmalloc).
me: fixdbgprintf_mem_range.
v2->v3:
Linn:
- do not free sd (setup_data) buffer.
- reuse code insetup_e820andsetup_e820_ext.
v1->v2:
Vivek:
- Use function instead of macro fordbgprint_mem_range
- Do not pass reserved memory range for kdump. It could addressed later separately.WANG Chao (10):
x86, cleanup: fix indent
x86, cleanup: add extra arguments toadd_memmap()anddelete_memmap()x86, cleanup: add other types of memory range for 2nd kernel boot to
memmap_p
x86, cleanup:add_memmap()only do alignment check onRANGE_RAMx86, cleanup: usedbgprint_mem_rangefor memory range debugging x86, cleanup: increaseCRASH_MAX_MEMMAP_NRup to
CRASH_MAX_MEMORY_RANGES
x86, cleanup: Store crash memory rangeskexec_info
x86, cleanup: Add a funtionadd_setup_data()
x86: add --pass-memmap-cmdline option
x86: Pass memory range via E820 for kdumpQuoted 10 lines
kexec/arch/i386/crashdump-x86.c | 79 +++++++-------- kexec/arch/i386/crashdump-x86.h | 2 +- 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.c | 175 ++++++++++++++++++++++----------- kexec/arch/i386/x86-linux-setup.h | 1 + kexec/arch/x86_64/kexec-x86_64.c | 5 + kexec/kexec.h | 2 + 9 files changed, 171 insertions(+), 100 deletions(-)
Quoted 3 lines
Hi,
Here is what I received, seems there's some duplicate patches?
Sorry, I rearranged some patches and forget to remove the old one.
I'll resend. Thanks for noticing me.
Thanks
WANG Chao
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 13 lines · WANG Chao
Hi, all
(Sorry for this late update. I was occupied with something else)
This patchset enables passing memory map via E820 map on x86 platform instead of memmap=exactmap. It's a better design and will solve the following problem so far:
- kernel cmdline is limited resource and large machines tend to have many memory ranges that may excceed kernel cmdline limit size.
- kASLR doesn't work with memmap=exactmap, because kASLR happens early than user defined memmap=exactmap takes effect.
Quoted 8 lines
Unfortunately,
saved_max_pfnstill 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.This patchset contains massive updates from the previous one. I take some suggestions from reviewers. I try to split the changes into smaller pieces and keep the whole change as minimal as I can so it wouldn't be too harsh to review the patch.
I messed up this patchset and ended up with some duplicated patches :(
Please ignore this patchset and take a look at the other series I just sent out with "RESEND" suject prefix.
Thanks
WANG Chao
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec