[PATCH v3 09/11] arm64: kdump: exclude non-dumpable reserved memory regions from vmcore

Will Deacon will at kernel.org
Fri May 29 08:08:41 PDT 2026


On Wed, May 27, 2026 at 11:29:15AM +0800, Wandun Chen wrote:
> From: Wandun Chen <chenwandun at lixiang.com>
> 
> Reserved memory regions are excluded from vmcore by default unless
> marked dumpable. Honor the dumpable flag to filter out device firmware
> regions (e.g., GPU, DSP, modem) reserved via device tree, since they
> typically contain data not useful for kernel crash analysis and can
> significantly increase vmcore size.
> 
> Use of_reserved_mem_kdump_exclude() to perform the exclusion, and
> pre-size the crash_mem array via of_reserved_mem_kdump_nr_ranges().
> 
> Signed-off-by: Wandun Chen <chenwandun at lixiang.com>
> Tested-by: Meijing Zhao <zhaomeijing at lixiang.com>
> ---
>  arch/arm64/kernel/machine_kexec_file.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
> index e31fabed378a..1d65320c6ba4 100644
> --- a/arch/arm64/kernel/machine_kexec_file.c
> +++ b/arch/arm64/kernel/machine_kexec_file.c
> @@ -17,6 +17,7 @@
>  #include <linux/memblock.h>
>  #include <linux/of.h>
>  #include <linux/of_fdt.h>
> +#include <linux/of_reserved_mem.h>
>  #include <linux/slab.h>
>  #include <linux/string.h>
>  #include <linux/types.h>
> @@ -51,6 +52,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)
> @@ -75,6 +77,10 @@ static int prepare_elf_headers(void **addr, unsigned long *sz)
>  			goto out;
>  	}
>  
> +	ret = of_reserved_mem_kdump_exclude(cmem);
> +	if (ret)
> +		goto out;
> +
>  	ret = crash_prepare_elf64_headers(cmem, true, addr, sz);

This looks fine to me:

Acked-by: Will Deacon <will at kernel.org>

Although I do wonder whether there's scope to consolidate some of the
arch code here. Now that you have a helper for reserved memory, perhaps
the core code could also handle the crashkernel reservation itself as
well? If the arch code passed in its number of memory regions, the
core code could take care of (a) allocating the crash_mem ranges array
(b) excluding the crashkernel and (c) excluding the reserved regions
(the part you have here).

Obviously that would be follow-up work, but the fact that you're having
to apply basically the same diff to three architectures is a bit of a
giveaway that this could benefit from some wider cleanup.

Will



More information about the kexec mailing list