From: Wandun Chen <[email protected]> From: Wandun Chen <[email protected]>
Apply the same non-dumpable reserved memory filtering to LoongArch kdump as was done for arm64. Use of_reserved_mem_kdump_exclude() to drop flagged regions from the elfcorehdr PT_LOAD segments, and of_reserved_mem_kdump_nr_ranges() to pre-size the crash_mem array. Signed-off-by: Wandun Chen <[email protected]> --- arch/loongarch/kernel/machine_kexec_file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/loongarch/kernel/machine_kexec_file.c b/arch/loongarch/kernel/machine_kexec_file.c index 5584b798ba46..c5cead362d2d 100644 --- a/arch/loongarch/kernel/machine_kexec_file.c +++ b/arch/loongarch/kernel/machine_kexec_file.c @@ -14,6 +14,7 @@ #include <linux/kernel.h> #include <linux/kexec.h> #include <linux/memblock.h> +#include <linux/of_reserved_mem.h> #include <linux/slab.h> #include <linux/string.h> #include <linux/types.h> @@ -67,6 +68,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz) nr_ranges = 2; /* for exclusion of crashkernel region */ for_each_mem_range(i, &start, &end) nr_ranges++; + nr_ranges += of_reserved_mem_kdump_nr_ranges(); cmem = kmalloc_flex(*cmem, ranges, nr_ranges); if (!cmem) @@ -91,6 +93,10 @@ static int prepare_elf_headers(void **addr, unsigned long *sz) goto out; } + ret = of_reserved_mem_kdump_exclude(cmem); + if (ret < 0) + goto out; + ret = crash_prepare_elf64_headers(cmem, true, addr, sz); out: -- 2.43.0
