* [PATCH v4 00/10] kdump: reduce vmcore size and capture time
@ 2026-06-30 7:47 Wandun Chen
2026-06-30 7:47 ` [PATCH v4 01/10] kexec/crash: provide crash_exclude_mem_range() stub when CONFIG_CRASH_DUMP=n Wandun Chen
` (9 more replies)
0 siblings, 10 replies; 17+ messages in thread
From: Wandun Chen @ 2026-06-30 7:47 UTC (permalink / raw)
To: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing
Cc: catalin.marinas, will, alex, akpm, pasha.tatashin, pratyush,
ruirui.yang, m.szyprowski, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
On SoCs that carve out large firmware-owned reserved memory (GPU
firmware, DSP, modem, camera ISP, NPU, ...), kdump currently dumps
those carveouts as part of system RAM even though their contents are
firmware state that is not useful for kernel crash analysis.
This series introduces an opt-in 'dumpable' flag [1] on struct
reserved_mem and uses it to filter the elfcorehdr PT_LOAD ranges on
DT-based architectures (arm64, riscv, loongarch). By default reserved
regions are treated as non-dumpable; CMA regions are explicitly opted
in because their pages are returned to the buddy allocator and may
carry key crash-analysis data.
Since the reserved memory regions are filtered out, the vmcore is
smaller in size and faster to produce. The reserved memory
has already been filtered out in x86; the optimizations in this series
apply to systems that use DTS such as arm64/riscv/loongarch.
The series is organized as follows:
Patches 1-4: Small prepare changes and cleanups.
Patches 5: Add dumpable flag to opt-in vmcore.
Patches 6: Append /memreserve/ entries into reserved_mem[].
Patch 7: Add generic kdump helpers.
Patches 8-10: Wire the helpers into arm64, riscv and loongarch kdump
elfcorehdr preparation.
v3 --> v4:
1. Rebase this series on v7.2-rc1.
2. Add two cleanup patches (patch 02/03).
3. Simplify patch 03 to avoid checking whether initial_boot_params is
NULL multiple times, suggested by Rob.
v2 --> v3:
1. Fix out-of-bounds issue if device tree lacks /reserved-memory node.[2]
2. Fix UAF issue when alloc_reserved_mem_array() fails.
3. Add some prepare patches.
v1 --> v2:
1. v1 added an opt-out DT property ('linux,no-dump'). Per Rob's
feedback [1], v2 drop that property and exclude reserve memory
by default.
2. Split some prepared patches from the original patches.
3. Address coding-style comments on patch 5 from Rob.
[1] https://lore.kernel.org/lkml/20260506144542.GA2072596-robh@kernel.org/
[2] https://sashiko.dev/#/patchset/20260520091844.592753-1-chenwandun%40lixiang.com?part=4
Wandun Chen (10):
kexec/crash: provide crash_exclude_mem_range() stub when
CONFIG_CRASH_DUMP=n
of: reserved_mem: dedup and relocate reserved-memory messages
of: reserved_mem: skip late scan when no regions are reserved
of: reserved_mem: split alloc_reserved_mem_array() from
fdt_scan_reserved_mem_late()
of: reserved_mem: add dumpable flag to opt-in vmcore
of: reserved_mem: save /memreserve/ entries into the reserved_mem
array
of: reserved_mem: add kdump helpers to exclude non-dumpable regions
arm64: kdump: exclude non-dumpable reserved memory regions from vmcore
riscv: kdump: exclude non-dumpable reserved memory regions from vmcore
loongarch: kdump: exclude non-dumpable reserved memory regions from
vmcore
arch/arm64/kernel/machine_kexec_file.c | 6 ++
arch/loongarch/kernel/machine_kexec_file.c | 6 ++
arch/riscv/kernel/machine_kexec_file.c | 4 +
drivers/of/fdt.c | 11 ++-
drivers/of/of_private.h | 3 +
drivers/of/of_reserved_mem.c | 108 ++++++++++++++++++---
include/linux/crash_core.h | 6 ++
include/linux/of_reserved_mem.h | 15 +++
kernel/dma/contiguous.c | 1 +
9 files changed, 142 insertions(+), 18 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v4 01/10] kexec/crash: provide crash_exclude_mem_range() stub when CONFIG_CRASH_DUMP=n
2026-06-30 7:47 [PATCH v4 00/10] kdump: reduce vmcore size and capture time Wandun Chen
@ 2026-06-30 7:47 ` Wandun Chen
2026-06-30 11:05 ` Pratyush Yadav
2026-06-30 7:47 ` [PATCH v4 02/10] of: reserved_mem: dedup and relocate reserved-memory messages Wandun Chen
` (8 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Wandun Chen @ 2026-06-30 7:47 UTC (permalink / raw)
To: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing
Cc: catalin.marinas, will, alex, akpm, pasha.tatashin, pratyush,
ruirui.yang, m.szyprowski, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
Prepare for an upcoming change that excludes non-dumpable reserved
regions from the kdump vmcore and will call crash_exclude_mem_range()
from generic, non-arch code.
No functional change.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
---
include/linux/crash_core.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h
index c1dee3f971a9..0033d4777648 100644
--- a/include/linux/crash_core.h
+++ b/include/linux/crash_core.h
@@ -87,6 +87,12 @@ static inline int kexec_should_crash(struct task_struct *p) { return 0; }
static inline int kexec_crash_loaded(void) { return 0; }
static inline void crash_save_cpu(struct pt_regs *regs, int cpu) {};
static inline int kimage_crash_copy_vmcoreinfo(struct kimage *image) { return 0; };
+static inline int crash_exclude_mem_range(struct crash_mem *mem,
+ unsigned long long mstart,
+ unsigned long long mend)
+{
+ return 0;
+}
#endif /* CONFIG_CRASH_DUMP*/
#ifdef CONFIG_CRASH_DM_CRYPT
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v4 02/10] of: reserved_mem: dedup and relocate reserved-memory messages
2026-06-30 7:47 [PATCH v4 00/10] kdump: reduce vmcore size and capture time Wandun Chen
2026-06-30 7:47 ` [PATCH v4 01/10] kexec/crash: provide crash_exclude_mem_range() stub when CONFIG_CRASH_DUMP=n Wandun Chen
@ 2026-06-30 7:47 ` Wandun Chen
2026-06-30 7:47 ` [PATCH v4 03/10] of: reserved_mem: skip late scan when no regions are reserved Wandun Chen
` (7 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Wandun Chen @ 2026-06-30 7:47 UTC (permalink / raw)
To: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing
Cc: catalin.marinas, will, alex, akpm, pasha.tatashin, pratyush,
ruirui.yang, m.szyprowski, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
In both fdt_scan_reserved_mem and fdt_scan_reserved_mem_late, there
are identical check-related print messages. Consolidate these messages
by moving them all into the fdt_scan_reserved_mem function.
No functional change.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
---
drivers/of/of_reserved_mem.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 82222bd45ac6..42649dc3613f 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -270,19 +270,15 @@ void __init fdt_scan_reserved_mem_late(void)
return;
node = fdt_path_offset(fdt, "/reserved-memory");
- if (node < 0) {
- pr_info("Reserved memory: No reserved-memory node in the DT\n");
+ if (node < 0)
return;
- }
/* Attempt dynamic allocation of a new reserved_mem array */
if (alloc_reserved_mem_array())
return;
- if (__reserved_mem_check_root(node)) {
- pr_err("Reserved memory: unsupported node format, ignoring\n");
+ if (__reserved_mem_check_root(node))
return;
- }
fdt_for_each_subnode(child, fdt, node) {
const __be32 *prop;
@@ -337,6 +333,7 @@ int __init fdt_scan_reserved_mem(void)
node = fdt_path_offset(fdt, "/reserved-memory");
if (node < 0) {
+ pr_info("Reserved memory: No reserved-memory node in the DT\n");
total_reserved_mem_cnt = 0;
return -ENODEV;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v4 03/10] of: reserved_mem: skip late scan when no regions are reserved
2026-06-30 7:47 [PATCH v4 00/10] kdump: reduce vmcore size and capture time Wandun Chen
2026-06-30 7:47 ` [PATCH v4 01/10] kexec/crash: provide crash_exclude_mem_range() stub when CONFIG_CRASH_DUMP=n Wandun Chen
2026-06-30 7:47 ` [PATCH v4 02/10] of: reserved_mem: dedup and relocate reserved-memory messages Wandun Chen
@ 2026-06-30 7:47 ` Wandun Chen
2026-06-30 7:47 ` [PATCH v4 04/10] of: reserved_mem: split alloc_reserved_mem_array() from fdt_scan_reserved_mem_late() Wandun Chen
` (6 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Wandun Chen @ 2026-06-30 7:47 UTC (permalink / raw)
To: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing
Cc: catalin.marinas, will, alex, akpm, pasha.tatashin, pratyush,
ruirui.yang, m.szyprowski, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
When total_reserved_mem_cnt is 0, there is no /reserved-memory node
so fdt_scan_reserved_mem_late() have nothing to do, so return -ENODEV
directly from alloc_reserved_mem_array() in this case.
No functional change.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
---
drivers/of/of_reserved_mem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 42649dc3613f..e1bd35115cc1 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -76,7 +76,7 @@ static int __init alloc_reserved_mem_array(void)
int ret;
if (!total_reserved_mem_cnt)
- return 0;
+ return -ENODEV;
alloc_size = array_size(total_reserved_mem_cnt, sizeof(*new_array));
if (alloc_size == SIZE_MAX) {
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v4 04/10] of: reserved_mem: split alloc_reserved_mem_array() from fdt_scan_reserved_mem_late()
2026-06-30 7:47 [PATCH v4 00/10] kdump: reduce vmcore size and capture time Wandun Chen
` (2 preceding siblings ...)
2026-06-30 7:47 ` [PATCH v4 03/10] of: reserved_mem: skip late scan when no regions are reserved Wandun Chen
@ 2026-06-30 7:47 ` Wandun Chen
2026-06-30 7:47 ` [PATCH v4 05/10] of: reserved_mem: add dumpable flag to opt-in vmcore Wandun Chen
` (5 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Wandun Chen @ 2026-06-30 7:47 UTC (permalink / raw)
To: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing
Cc: catalin.marinas, will, alex, akpm, pasha.tatashin, pratyush,
ruirui.yang, m.szyprowski, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
Prepare for storing /memreserve/ entries in the reserved_mem array.
alloc_reserved_mem_array was skipped if the device tree lacks a
/reserved-memory node, pointer 'reserved_mem' continues to reference
the reserved_mem_array which lives in __initdata, storing
/memreserve/ entries into reserved_mem_array would result in metadata
loss, and an out-of-bounds memory access will occur if the device
tree contains more than MAX_RESERVED_REGIONS /memreserve/ entries.
So split alloc_reserved_mem_array() from fdt_scan_reserved_mem_late(),
and call alloc_reserved_mem_array() whether or not there is a
/reserved-memory node.
No functional change.
The actual /memreserve/ population is added in a follow-up patch.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
---
drivers/of/fdt.c | 7 +++++--
drivers/of/of_private.h | 1 +
drivers/of/of_reserved_mem.c | 11 ++---------
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 26f66046cc32..b97775f6c9d4 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1282,8 +1282,11 @@ void __init unflatten_device_tree(void)
{
void *fdt = initial_boot_params;
- /* Save the statically-placed regions in the reserved_mem array */
- fdt_scan_reserved_mem_late();
+ /* Attempt dynamic allocation of a new reserved_mem array */
+ if (!alloc_reserved_mem_array()) {
+ /* Save the statically-placed regions in the reserved_mem array */
+ fdt_scan_reserved_mem_late();
+ }
/* Populate an empty root node when bootloader doesn't provide one */
if (!fdt) {
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 0ae16da066e2..81c8ec9378b9 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -187,6 +187,7 @@ static inline struct device_node *__of_get_dma_parent(const struct device_node *
int fdt_scan_reserved_mem(void);
void __init fdt_scan_reserved_mem_late(void);
+int __init alloc_reserved_mem_array(void);
bool of_fdt_device_is_available(const void *blob, unsigned long node);
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index e1bd35115cc1..f6c02b37deb7 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -69,13 +69,13 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
* the initial static array is copied over to this new array and
* the new array is used from this point on.
*/
-static int __init alloc_reserved_mem_array(void)
+int __init alloc_reserved_mem_array(void)
{
struct reserved_mem *new_array;
size_t alloc_size, copy_size, memset_size;
int ret;
- if (!total_reserved_mem_cnt)
+ if (!initial_boot_params || !total_reserved_mem_cnt)
return -ENODEV;
alloc_size = array_size(total_reserved_mem_cnt, sizeof(*new_array));
@@ -266,17 +266,10 @@ void __init fdt_scan_reserved_mem_late(void)
phys_addr_t base, size;
int node, child;
- if (!fdt)
- return;
-
node = fdt_path_offset(fdt, "/reserved-memory");
if (node < 0)
return;
- /* Attempt dynamic allocation of a new reserved_mem array */
- if (alloc_reserved_mem_array())
- return;
-
if (__reserved_mem_check_root(node))
return;
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v4 05/10] of: reserved_mem: add dumpable flag to opt-in vmcore
2026-06-30 7:47 [PATCH v4 00/10] kdump: reduce vmcore size and capture time Wandun Chen
` (3 preceding siblings ...)
2026-06-30 7:47 ` [PATCH v4 04/10] of: reserved_mem: split alloc_reserved_mem_array() from fdt_scan_reserved_mem_late() Wandun Chen
@ 2026-06-30 7:47 ` Wandun Chen
2026-06-30 7:47 ` [PATCH v4 06/10] of: reserved_mem: save /memreserve/ entries into the reserved_mem array Wandun Chen
` (4 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Wandun Chen @ 2026-06-30 7:47 UTC (permalink / raw)
To: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing
Cc: catalin.marinas, will, alex, akpm, pasha.tatashin, pratyush,
ruirui.yang, m.szyprowski, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
Add a 'dumpable' flag to struct reserved_mem so the kernel can decide
whether a reserved area should be included in the kdump vmcore. Most
reserved regions are owned by devices and do not contain data useful
for kernel crash analysis, so excluding them by default is the right
behaviour.
Reusable CMA regions are different: pages in a CMA region are handed
back to the buddy allocator and may contain key data for crash
analysis, so set dumpable to true in rmem_cma_setup().
Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/all/20260506144542.GA2072596-robh@kernel.org/
---
include/linux/of_reserved_mem.h | 1 +
kernel/dma/contiguous.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index e8b20b29fa68..55a67cee41ea 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -15,6 +15,7 @@ struct reserved_mem {
phys_addr_t base;
phys_addr_t size;
void *priv;
+ bool dumpable;
};
struct reserved_mem_ops {
diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index f754079a287d..63ff134dadd4 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -565,6 +565,7 @@ static int __init rmem_cma_setup(unsigned long node, struct reserved_mem *rmem)
dma_contiguous_default_area = cma;
rmem->priv = cma;
+ rmem->dumpable = true;
pr_info("Reserved memory: created CMA memory pool at %pa, size %ld MiB\n",
&rmem->base, (unsigned long)rmem->size / SZ_1M);
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v4 06/10] of: reserved_mem: save /memreserve/ entries into the reserved_mem array
2026-06-30 7:47 [PATCH v4 00/10] kdump: reduce vmcore size and capture time Wandun Chen
` (4 preceding siblings ...)
2026-06-30 7:47 ` [PATCH v4 05/10] of: reserved_mem: add dumpable flag to opt-in vmcore Wandun Chen
@ 2026-06-30 7:47 ` Wandun Chen
2026-06-30 7:47 ` [PATCH v4 07/10] of: reserved_mem: add kdump helpers to exclude non-dumpable regions Wandun Chen
` (3 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Wandun Chen @ 2026-06-30 7:47 UTC (permalink / raw)
To: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing
Cc: catalin.marinas, will, alex, akpm, pasha.tatashin, pratyush,
ruirui.yang, m.szyprowski, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
/memreserve/ is used by firmware or bootloaders, such regions hold no
useful data for crash analysis, they should be excluded from the
kdump vmcore, so save /memreserve/ entries into the reserved_mem array
for later exclusion.
If a /memreserve/ entry overlaps any dumpable reserved region, mark
the whole memreserve entry dumpable as well. This may keep slightly
more memory in vmcore than strictly necessary, but avoids splitting
entries and never drops data that may be useful for crash analysis.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
drivers/of/fdt.c | 4 +++
drivers/of/of_private.h | 2 ++
drivers/of/of_reserved_mem.c | 52 ++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index b97775f6c9d4..3e478d29e247 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -497,6 +497,7 @@ void __init early_init_fdt_scan_reserved_mem(void)
int n;
int res;
u64 base, size;
+ int nr_memreserve = 0;
if (!initial_boot_params)
return;
@@ -514,7 +515,9 @@ void __init early_init_fdt_scan_reserved_mem(void)
if (!size)
break;
memblock_reserve(base, size);
+ nr_memreserve++;
}
+ fdt_reserved_mem_account_memreserve(nr_memreserve);
}
/**
@@ -1286,6 +1289,7 @@ void __init unflatten_device_tree(void)
if (!alloc_reserved_mem_array()) {
/* Save the statically-placed regions in the reserved_mem array */
fdt_scan_reserved_mem_late();
+ fdt_reserved_mem_save_memreserve_entries();
}
/* Populate an empty root node when bootloader doesn't provide one */
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 81c8ec9378b9..a67929c0a6ec 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -188,6 +188,8 @@ static inline struct device_node *__of_get_dma_parent(const struct device_node *
int fdt_scan_reserved_mem(void);
void __init fdt_scan_reserved_mem_late(void);
int __init alloc_reserved_mem_array(void);
+void __init fdt_reserved_mem_account_memreserve(int n);
+void __init fdt_reserved_mem_save_memreserve_entries(void);
bool of_fdt_device_is_available(const void *blob, unsigned long node);
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index f6c02b37deb7..9db0502989c3 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -251,6 +251,43 @@ static void __init __rmem_check_for_overlap(void)
}
}
+static void __init fdt_reserved_mem_add_memreserve(phys_addr_t base,
+ phys_addr_t size)
+{
+ struct reserved_mem *rmem;
+ bool dumpable = false;
+ int i;
+
+ if (reserved_mem_count == total_reserved_mem_cnt) {
+ pr_err("not enough space for memreserve regions.\n");
+ return;
+ }
+
+ for (i = 0; i < reserved_mem_count; i++) {
+ rmem = &reserved_mem[i];
+
+ if (!rmem->dumpable)
+ continue;
+
+ if (base < rmem->base + rmem->size && rmem->base < base + size) {
+ dumpable = true;
+ break;
+ }
+ }
+
+ rmem = &reserved_mem[reserved_mem_count];
+ rmem->base = base;
+ rmem->size = size;
+ rmem->dumpable = dumpable;
+
+ reserved_mem_count++;
+}
+
+void __init fdt_reserved_mem_account_memreserve(int n)
+{
+ total_reserved_mem_cnt += n;
+}
+
/**
* fdt_scan_reserved_mem_late() - Scan FDT and initialize remaining reserved
* memory regions.
@@ -305,6 +342,21 @@ void __init fdt_scan_reserved_mem_late(void)
__rmem_check_for_overlap();
}
+void __init fdt_reserved_mem_save_memreserve_entries(void)
+{
+ const void *fdt = initial_boot_params;
+ u64 base, size;
+ int n;
+
+ for (n = 0; ; n++) {
+ if (fdt_get_mem_rsv(fdt, n, &base, &size))
+ break;
+ if (!size)
+ break;
+ fdt_reserved_mem_add_memreserve(base, size);
+ }
+}
+
static int __init __reserved_mem_alloc_size(unsigned long node, const char *uname);
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v4 07/10] of: reserved_mem: add kdump helpers to exclude non-dumpable regions
2026-06-30 7:47 [PATCH v4 00/10] kdump: reduce vmcore size and capture time Wandun Chen
` (5 preceding siblings ...)
2026-06-30 7:47 ` [PATCH v4 06/10] of: reserved_mem: save /memreserve/ entries into the reserved_mem array Wandun Chen
@ 2026-06-30 7:47 ` Wandun Chen
2026-06-30 11:06 ` Pratyush Yadav
2026-06-30 7:47 ` [PATCH v4 08/10] arm64: kdump: exclude non-dumpable reserved memory regions from vmcore Wandun Chen
` (2 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Wandun Chen @ 2026-06-30 7:47 UTC (permalink / raw)
To: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing
Cc: catalin.marinas, will, alex, akpm, pasha.tatashin, pratyush,
ruirui.yang, m.szyprowski, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
Add two helpers to exclude non-dumpable regions for arch-specific
code.
- of_reserved_mem_kdump_nr_ranges() returns the count of regions
that are not dumpable. Each excluded region may split an existing
crash_mem range into two, so callers use this to calculate
crash_mem allocation size.
- of_reserved_mem_kdump_exclude() walks reserved_mem[] and calls
crash_exclude_mem_range() for every non-dumpable region.
Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
---
drivers/of/of_reserved_mem.c | 34 +++++++++++++++++++++++++++++++++
include/linux/of_reserved_mem.h | 14 ++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 9db0502989c3..c83ef88dffe2 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -24,6 +24,7 @@
#include <linux/slab.h>
#include <linux/memblock.h>
#include <linux/kmemleak.h>
+#include <linux/crash_core.h>
#include "of_private.h"
@@ -856,6 +857,39 @@ struct reserved_mem *of_reserved_mem_lookup(struct device_node *np)
}
EXPORT_SYMBOL_GPL(of_reserved_mem_lookup);
+/*
+ * Count non-dumpable reserved regions. Excluding each one may split a
+ * crash_mem range in two, callers use this to size the allocation.
+ */
+unsigned int of_reserved_mem_kdump_nr_ranges(void)
+{
+ unsigned int i, n = 0;
+
+ for (i = 0; i < reserved_mem_count; i++)
+ if (reserved_mem[i].size && !reserved_mem[i].dumpable)
+ n++;
+ return n;
+}
+
+/* Exclude non-dumpable reserved regions from @cmem. */
+int of_reserved_mem_kdump_exclude(struct crash_mem *cmem)
+{
+ unsigned int i;
+ int ret;
+
+ for (i = 0; i < reserved_mem_count; i++) {
+ struct reserved_mem *r = &reserved_mem[i];
+
+ if (!r->size || r->dumpable)
+ continue;
+ ret = crash_exclude_mem_range(cmem, r->base,
+ r->base + r->size - 1);
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+
/**
* of_reserved_mem_region_to_resource() - Get a reserved memory region as a resource
* @np: node containing 'memory-region' property
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index 55a67cee41ea..70db99f1fbff 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -8,6 +8,7 @@
struct of_phandle_args;
struct reserved_mem_ops;
struct resource;
+struct crash_mem;
struct reserved_mem {
const char *name;
@@ -48,6 +49,9 @@ int of_reserved_mem_region_to_resource_byname(const struct device_node *np,
const char *name, struct resource *res);
int of_reserved_mem_region_count(const struct device_node *np);
+unsigned int of_reserved_mem_kdump_nr_ranges(void);
+int of_reserved_mem_kdump_exclude(struct crash_mem *cmem);
+
#else
#define RESERVEDMEM_OF_DECLARE(name, compat, ops) \
@@ -92,6 +96,16 @@ static inline int of_reserved_mem_region_count(const struct device_node *np)
{
return 0;
}
+
+static inline unsigned int of_reserved_mem_kdump_nr_ranges(void)
+{
+ return 0;
+}
+
+static inline int of_reserved_mem_kdump_exclude(struct crash_mem *cmem)
+{
+ return 0;
+}
#endif
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v4 08/10] arm64: kdump: exclude non-dumpable reserved memory regions from vmcore
2026-06-30 7:47 [PATCH v4 00/10] kdump: reduce vmcore size and capture time Wandun Chen
` (6 preceding siblings ...)
2026-06-30 7:47 ` [PATCH v4 07/10] of: reserved_mem: add kdump helpers to exclude non-dumpable regions Wandun Chen
@ 2026-06-30 7:47 ` Wandun Chen
2026-06-30 11:06 ` Pratyush Yadav
2026-06-30 7:47 ` [PATCH v4 09/10] riscv: " Wandun Chen
2026-06-30 7:47 ` [PATCH v4 10/10] loongarch: " Wandun Chen
9 siblings, 1 reply; 17+ messages in thread
From: Wandun Chen @ 2026-06-30 7:47 UTC (permalink / raw)
To: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing
Cc: catalin.marinas, will, alex, akpm, pasha.tatashin, pratyush,
ruirui.yang, m.szyprowski, robin.murphy
From: Wandun Chen <chenwandun@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@lixiang.com>
Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
Acked-by: Will Deacon <will@kernel.org>
---
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);
out:
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v4 09/10] riscv: kdump: exclude non-dumpable reserved memory regions from vmcore
2026-06-30 7:47 [PATCH v4 00/10] kdump: reduce vmcore size and capture time Wandun Chen
` (7 preceding siblings ...)
2026-06-30 7:47 ` [PATCH v4 08/10] arm64: kdump: exclude non-dumpable reserved memory regions from vmcore Wandun Chen
@ 2026-06-30 7:47 ` Wandun Chen
2026-06-30 11:12 ` Pratyush Yadav
2026-06-30 7:47 ` [PATCH v4 10/10] loongarch: " Wandun Chen
9 siblings, 1 reply; 17+ messages in thread
From: Wandun Chen @ 2026-06-30 7:47 UTC (permalink / raw)
To: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing
Cc: catalin.marinas, will, alex, akpm, pasha.tatashin, pratyush,
ruirui.yang, m.szyprowski, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
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 <chenwandun@lixiang.com>
---
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);
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v4 10/10] loongarch: kdump: exclude non-dumpable reserved memory regions from vmcore
2026-06-30 7:47 [PATCH v4 00/10] kdump: reduce vmcore size and capture time Wandun Chen
` (8 preceding siblings ...)
2026-06-30 7:47 ` [PATCH v4 09/10] riscv: " Wandun Chen
@ 2026-06-30 7:47 ` Wandun Chen
2026-06-30 11:13 ` Pratyush Yadav
9 siblings, 1 reply; 17+ messages in thread
From: Wandun Chen @ 2026-06-30 7:47 UTC (permalink / raw)
To: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing
Cc: catalin.marinas, will, alex, akpm, pasha.tatashin, pratyush,
ruirui.yang, m.szyprowski, robin.murphy
From: Wandun Chen <chenwandun@lixiang.com>
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 <chenwandun@lixiang.com>
---
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..4b918c3d4a28 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)
+ goto out;
+
ret = crash_prepare_elf64_headers(cmem, true, addr, sz);
out:
--
2.43.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v4 01/10] kexec/crash: provide crash_exclude_mem_range() stub when CONFIG_CRASH_DUMP=n
2026-06-30 7:47 ` [PATCH v4 01/10] kexec/crash: provide crash_exclude_mem_range() stub when CONFIG_CRASH_DUMP=n Wandun Chen
@ 2026-06-30 11:05 ` Pratyush Yadav
0 siblings, 0 replies; 17+ messages in thread
From: Pratyush Yadav @ 2026-06-30 11:05 UTC (permalink / raw)
To: Wandun Chen
Cc: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing, catalin.marinas, will,
alex, akpm, pasha.tatashin, pratyush, ruirui.yang, m.szyprowski,
robin.murphy
On Tue, Jun 30 2026, Wandun Chen wrote:
> From: Wandun Chen <chenwandun@lixiang.com>
>
> Prepare for an upcoming change that excludes non-dumpable reserved
> regions from the kdump vmcore and will call crash_exclude_mem_range()
> from generic, non-arch code.
>
> No functional change.
>
> Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
Acked-by: Pratyush Yadav <pratyush@kernel.org>
[...]
--
Regards,
Pratyush Yadav
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v4 07/10] of: reserved_mem: add kdump helpers to exclude non-dumpable regions
2026-06-30 7:47 ` [PATCH v4 07/10] of: reserved_mem: add kdump helpers to exclude non-dumpable regions Wandun Chen
@ 2026-06-30 11:06 ` Pratyush Yadav
0 siblings, 0 replies; 17+ messages in thread
From: Pratyush Yadav @ 2026-06-30 11:06 UTC (permalink / raw)
To: Wandun Chen
Cc: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing, catalin.marinas, will,
alex, akpm, pasha.tatashin, pratyush, ruirui.yang, m.szyprowski,
robin.murphy
On Tue, Jun 30 2026, Wandun Chen wrote:
> From: Wandun Chen <chenwandun@lixiang.com>
>
> Add two helpers to exclude non-dumpable regions for arch-specific
> code.
>
> - of_reserved_mem_kdump_nr_ranges() returns the count of regions
> that are not dumpable. Each excluded region may split an existing
> crash_mem range into two, so callers use this to calculate
> crash_mem allocation size.
>
> - of_reserved_mem_kdump_exclude() walks reserved_mem[] and calls
> crash_exclude_mem_range() for every non-dumpable region.
>
> Signed-off-by: Wandun Chen <chenwandun@lixiang.com>
> Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
Acked-by: Pratyush Yadav <pratyush@kernel.org>
[...]
--
Regards,
Pratyush Yadav
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v4 08/10] arm64: kdump: exclude non-dumpable reserved memory regions from vmcore
2026-06-30 7:47 ` [PATCH v4 08/10] arm64: kdump: exclude non-dumpable reserved memory regions from vmcore Wandun Chen
@ 2026-06-30 11:06 ` Pratyush Yadav
0 siblings, 0 replies; 17+ messages in thread
From: Pratyush Yadav @ 2026-06-30 11:06 UTC (permalink / raw)
To: Wandun Chen
Cc: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing, catalin.marinas, will,
alex, akpm, pasha.tatashin, pratyush, ruirui.yang, m.szyprowski,
robin.murphy
On Tue, Jun 30 2026, Wandun Chen wrote:
> From: Wandun Chen <chenwandun@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@lixiang.com>
> Tested-by: Meijing Zhao <zhaomeijing@lixiang.com>
> Acked-by: Will Deacon <will@kernel.org>
Acked-by: Pratyush Yadav <pratyush@kernel.org>
[...]
--
Regards,
Pratyush Yadav
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v4 09/10] riscv: kdump: exclude non-dumpable reserved memory regions from vmcore
2026-06-30 7:47 ` [PATCH v4 09/10] riscv: " Wandun Chen
@ 2026-06-30 11:12 ` Pratyush Yadav
2026-06-30 12:00 ` Wandun
0 siblings, 1 reply; 17+ messages in thread
From: Pratyush Yadav @ 2026-06-30 11:12 UTC (permalink / raw)
To: Wandun Chen
Cc: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing, catalin.marinas, will,
alex, akpm, pasha.tatashin, pratyush, ruirui.yang, m.szyprowski,
robin.murphy
On Tue, Jun 30 2026, Wandun Chen wrote:
> From: Wandun Chen <chenwandun@lixiang.com>
>
> 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 <chenwandun@lixiang.com>
> ---
> 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?
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>
--
Regards,
Pratyush Yadav
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v4 10/10] loongarch: kdump: exclude non-dumpable reserved memory regions from vmcore
2026-06-30 7:47 ` [PATCH v4 10/10] loongarch: " Wandun Chen
@ 2026-06-30 11:13 ` Pratyush Yadav
0 siblings, 0 replies; 17+ messages in thread
From: Pratyush Yadav @ 2026-06-30 11:13 UTC (permalink / raw)
To: Wandun Chen
Cc: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing, catalin.marinas, will,
alex, akpm, pasha.tatashin, pratyush, ruirui.yang, m.szyprowski,
robin.murphy
On Tue, Jun 30 2026, Wandun Chen wrote:
> From: Wandun Chen <chenwandun@lixiang.com>
>
> 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 <chenwandun@lixiang.com>
Acked-by: Pratyush Yadav <pratyush@kernel.org>
[...]
--
Regards,
Pratyush Yadav
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v4 09/10] riscv: kdump: exclude non-dumpable reserved memory regions from vmcore
2026-06-30 11:12 ` Pratyush Yadav
@ 2026-06-30 12:00 ` Wandun
0 siblings, 0 replies; 17+ messages in thread
From: Wandun @ 2026-06-30 12:00 UTC (permalink / raw)
To: Pratyush Yadav
Cc: chenhuacai, kernel, pjw, palmer, aou, robh, saravanak, bhe, rppt,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
devicetree, kexec, iommu, zhaomeijing, catalin.marinas, will,
alex, akpm, pasha.tatashin, ruirui.yang, m.szyprowski,
robin.murphy
On 6/30/26 19:12, Pratyush Yadav wrote:
> On Tue, Jun 30 2026, Wandun Chen wrote:
>
>> From: Wandun Chen <chenwandun@lixiang.com>
>>
>> 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 <chenwandun@lixiang.com>
>> ---
>> 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>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2026-06-30 12:00 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 7:47 [PATCH v4 00/10] kdump: reduce vmcore size and capture time Wandun Chen
2026-06-30 7:47 ` [PATCH v4 01/10] kexec/crash: provide crash_exclude_mem_range() stub when CONFIG_CRASH_DUMP=n Wandun Chen
2026-06-30 11:05 ` Pratyush Yadav
2026-06-30 7:47 ` [PATCH v4 02/10] of: reserved_mem: dedup and relocate reserved-memory messages Wandun Chen
2026-06-30 7:47 ` [PATCH v4 03/10] of: reserved_mem: skip late scan when no regions are reserved Wandun Chen
2026-06-30 7:47 ` [PATCH v4 04/10] of: reserved_mem: split alloc_reserved_mem_array() from fdt_scan_reserved_mem_late() Wandun Chen
2026-06-30 7:47 ` [PATCH v4 05/10] of: reserved_mem: add dumpable flag to opt-in vmcore Wandun Chen
2026-06-30 7:47 ` [PATCH v4 06/10] of: reserved_mem: save /memreserve/ entries into the reserved_mem array Wandun Chen
2026-06-30 7:47 ` [PATCH v4 07/10] of: reserved_mem: add kdump helpers to exclude non-dumpable regions Wandun Chen
2026-06-30 11:06 ` Pratyush Yadav
2026-06-30 7:47 ` [PATCH v4 08/10] arm64: kdump: exclude non-dumpable reserved memory regions from vmcore Wandun Chen
2026-06-30 11:06 ` Pratyush Yadav
2026-06-30 7:47 ` [PATCH v4 09/10] riscv: " Wandun Chen
2026-06-30 11:12 ` Pratyush Yadav
2026-06-30 12:00 ` Wandun
2026-06-30 7:47 ` [PATCH v4 10/10] loongarch: " Wandun Chen
2026-06-30 11:13 ` Pratyush Yadav
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox