Re: [PATCH v4 09/10] riscv: kdump: exclude non-dumpable reserved memory regions from vmcore
From: Wandun <hidden>
Date: 2026-06-30 12:00:33
Also in:
kexec, linux-devicetree, linux-iommu, linux-riscv, lkml, loongarch
On 6/30/26 19:12, Pratyush Yadav wrote:
On Tue, Jun 30 2026, Wandun Chen wrote:quoted
From: Wandun Chen <redacted> Apply the same non-dumpable reserved memory filtering to RISC-V 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 <redacted> --- arch/riscv/kernel/machine_kexec_file.c | 4 ++++ 1 file changed, 4 insertions(+)diff --git a/arch/riscv/kernel/machine_kexec_file.c b/arch/riscv/kernel/machine_kexec_file.c index 59d4bbc848a8..25359d583bc3 100644 --- a/arch/riscv/kernel/machine_kexec_file.c +++ b/arch/riscv/kernel/machine_kexec_file.c@@ -10,6 +10,7 @@ #include <linux/elf.h> #include <linux/slab.h> #include <linux/of.h> +#include <linux/of_reserved_mem.h> #include <linux/libfdt.h> #include <linux/types.h> #include <linux/memblock.h>@@ -64,6 +65,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz) nr_ranges = 1; /* For exclusion of crashkernel region */ walk_system_ram_res(0, -1, &nr_ranges, get_nr_ram_ranges_callback); + nr_ranges += of_reserved_mem_kdump_nr_ranges(); cmem = kmalloc_flex(*cmem, ranges, nr_ranges); if (!cmem)@@ -77,6 +79,8 @@ static int prepare_elf_headers(void **addr, unsigned long *sz) /* Exclude crashkernel region */ ret = crash_exclude_mem_range(cmem, crashk_res.start, crashk_res.end); + if (!ret) + ret = of_reserved_mem_kdump_exclude(cmem); if (!ret) ret = crash_prepare_elf64_headers(cmem, true, addr, sz);Nit: can you do the usual pattern of if (err) goto err; instead?
Sure, will fix in the next version. Best regards, Wandun
So this would look like:
/* Exclude crashkernel region */
ret = crash_exclude_mem_range(cmem, crashk_res.start, crashk_res.end);
if (ret)
goto out;
ret = of_reserved_mem_kdump_exclude(cmem);
if (ret)
goto out;
ret = crash_prepare_elf64_headers(cmem, true, addr, sz);
out:
...
With this,
Acked-by: Pratyush Yadav <pratyush@kernel.org>