arm64: support more than one crash kernel regions
Subsystems (2)
PATCH 1/1 arm64: support more than one crash kernel regions
When crashkernel is reserved above 4G in memory, kernel should reserve some amount of low memory for swiotlb and some DMA buffers. So there may be two crash kernel regions, one is below 4G, the other is above 4G.
Currently, there is only one crash kernel region on arm64, and pass "linux,usable-memory-range = <BASE SIZE>" property to crash dump kernel. Now, we pass
"linux,usable-memory-range = <BASE1 SIZE1 BASE2 SIZE2>" to crash dump kernel to support two crash kernel regions and load crash kernel high.
--- kexec/arch/arm64/crashdump-arm64.c | 44 +++++++++++++++++------------ kexec/arch/arm64/crashdump-arm64.h | 3 +- kexec/arch/arm64/kexec-arm64.c | 57 +++++++++++++++++++++++++++++--------- 3 files changed, 72 insertions(+), 32 deletions(-)
kexec/arch/arm64/crashdump-arm64.c +26 -18
@@ -32,11 +32,11 @@ static struct memory_ranges system_memory_rgns = { };/* memory range reserved for crashkernel */ -struct memory_range crash_reserved_mem; +struct memory_range crash_reserved_mem[CRASH_MAX_RESERVED_RANGES ];struct memory_ranges usablemem_rgns = { .size =0 , - .max_size =1 , - .ranges = &crash_reserved_mem, + .max_size =CRASH_MAX_RESERVED_RANGES , + .ranges = crash_reserved_mem, };struct memory_range elfcorehdr_mem;
@@ -108,7 +108,7 @@ int is_crashkernel_mem_reserved(void)if (!usablemem_rgns.size)kexec_iomem_for_each_line (NULL , iomem_range_callback,NULL ); -return crash_reserved_mem.start != crash_reserved_mem.end; +return usablemem_rgns.size; }/*
@@ -122,6 +122,8 @@ int is_crashkernel_mem_reserved(void)*/ static int crash_get_memory_ranges (void ) { +int i; +/* * First read all memory regions that can be considered as * system memory including the crash area.
@@ -129,16 +131,19 @@ static int crash_get_memory_ranges(void)if (!usablemem_rgns.size)kexec_iomem_for_each_line (NULL , iomem_range_callback,NULL ); -/* allow only a single region for crash dump kernel */ -if (usablemem_rgns.size !=1 ) +/* allow one or two region for crash dump kernel */ +if (!usablemem_rgns.size)return -EINVAL ; -dbgprint_mem_range ("Reserved memory range" , &crash_reserved_mem,1 ); +dbgprint_mem_range ("Reserved memory range" , + usablemem_rgns.ranges, usablemem_rgns.size); -if (mem_regions_exclude (&system_memory_rgns, &crash_reserved_mem)) { -fprintf (stderr, -"Error: Number of crash memory ranges excedeed the max limit\n" ); -return -ENOMEM ; +for (i =0 ; i < usablemem_rgns.size; i++) { +if (mem_regions_exclude (&system_memory_rgns, &crash_reserved_mem[i])) { +fprintf (stderr, +"Error: Number of crash memory ranges excedeed the max limit\n" ); +return -ENOMEM ; + } }/*
@@ -199,7 +204,8 @@ int load_crashdump_segments(struct kexec_info *info)return EFAILED ; elfcorehdr =add_buffer_phys_virt (info, buf, bufsz, bufsz,0 , - crash_reserved_mem.start, crash_reserved_mem.end, + crash_reserved_mem[usablemem_rgns.size -1 ].start, + crash_reserved_mem[usablemem_rgns.size -1 ].end,-1 ,0 ); elfcorehdr_mem.start = elfcorehdr;
@@ -217,21 +223,23 @@ int load_crashdump_segments(struct kexec_info *info)* virt_to_phys() in add_segment(). * So let's fix up those values for later use so the memory base * (arm64_mm.phys_offset) will be correctly replaced with -* crash_reserved_mem.start. +* crash_reserved_mem[usablemem_rgns.size - 1].start. */ void fixup_elf_addrs (struct mem_ehdr *ehdr) {struct mem_phdr *phdr;int i; - ehdr->e_entry += - arm64_mem.phys_offset + crash_reserved_mem.start; + ehdr->e_entry += -arm64_mem.phys_offset + + crash_reserved_mem[usablemem_rgns.size -1 ].start;for (i =0 ; i < ehdr->e_phnum; i++) { phdr = &ehdr->e_phdr[i];if (phdr->p_type !=PT_LOAD )continue ; phdr->p_paddr += - (-arm64_mem.phys_offset + crash_reserved_mem.start); + (-arm64_mem.phys_offset + + crash_reserved_mem[usablemem_rgns.size -1 ].start); } }
@@ -240,11 +248,11 @@ int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)if (!usablemem_rgns.size)kexec_iomem_for_each_line (NULL , iomem_range_callback,NULL ); -if (!crash_reserved_mem.end) +if (!usablemem_rgns.size)return -1 ; - *start = crash_reserved_mem.start; - *end = crash_reserved_mem.end; + *start = crash_reserved_mem[usablemem_rgns.size -1 ].start; + *end = crash_reserved_mem[usablemem_rgns.size -1 ].end;return 0 ; }
kexec/arch/arm64/crashdump-arm64.h +2 -1
@@ -15,9 +15,10 @@#include "kexec.h" #define CRASH_MAX_MEMORY_RANGES 32 +#define CRASH_MAX_RESERVED_RANGES 8extern struct memory_ranges usablemem_rgns; -extern struct memory_range crash_reserved_mem; +extern struct memory_range crash_reserved_mem[];extern struct memory_range elfcorehdr_mem;extern int load_crashdump_segments (struct kexec_info *info);
kexec/arch/arm64/kexec-arm64.c +44 -13
103 lines not on this page · raw message
Signature · 7 lines
2.7.4 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 5 lines · Chen Zhou
When crashkernel is reserved above 4G in memory, kernel should reserve some amount of low memory for swiotlb and some DMA buffers. So there may be two crash kernel regions, one is below 4G, the other is above 4G.
Quoted 8 lines
Currently, there is only one crash kernel region on arm64, and pass "linux,usable-memory-range = <BASE SIZE>" property to crash dump kernel. Now, we pass
"linux,usable-memory-range = <BASE1 SIZE1 BASE2 SIZE2>" to crash dump kernel to support two crash kernel regions and load crash kernel high.Signed-off-by Chen Zhou <[email protected]>
Sorry for letting this slip through the cracks.
Please let me know if this is still relevant.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Hi Simon,
Quoted 13 lines · Simon Horman
Quoted 12 lines · Chen Zhou
When crashkernel is reserved above 4G in memory, kernel should reserve some amount of low memory for swiotlb and some DMA buffers. So there may be two crash kernel regions, one is below 4G, the other is above 4G.
Currently, there is only one crash kernel region on arm64, and pass "linux,usable-memory-range = <BASE SIZE>" property to crash dump kernel. Now, we pass
"linux,usable-memory-range = <BASE1 SIZE1 BASE2 SIZE2>" to crash dump kernel to support two crash kernel regions and load crash kernel high.
Quoted 5 lines
Quoted 1 line
Signed-off-by Chen Zhou <[email protected]>Sorry for letting this slip through the cracks.
Please let me know if this is still relevant.
This is still relevant and the kernel patches are still under discussion.
Thanks,
Chen Zhou
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec