[PATCH v1 3/8] s390/kexec: Pass crashkernel CMA ranges to the kdump kernel

From: Mikhail Zaslonko

Date: Thu Nov 12 2026 - 06:37:07 EST


Store the crashkernel CMA ranges in the parmarea of the kdump kernel,
next to oldmem_base and oldmem_size, when it is loaded with
kexec_file_load().

The ranges use 64 of the 72 bytes of pad1, which is enough for the four
ranges the generic code reserves at most. They are sorted by address
and unused entries are zero. Older kernels ignore pad1 and kernel images
have it zeroed, so old and new kernels still work together.

For kexec_load(), kexec-tools would have to fill in the ranges. It can
read them from /sys/kernel/kexec_crash_cma_ranges.

Co-developed-by: Vasily Gorbik <gor@xxxxxxxxxxxxx>
Signed-off-by: Vasily Gorbik <gor@xxxxxxxxxxxxx>
Signed-off-by: Mikhail Zaslonko <zaslonko@xxxxxxxxxxxxx>
---
arch/s390/include/asm/setup.h | 9 ++++++++-
arch/s390/kernel/machine_kexec_file.c | 5 +++++
arch/s390/kernel/setup.c | 5 ++++-
3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/arch/s390/include/asm/setup.h b/arch/s390/include/asm/setup.h
index cbf60ade741d..7e992f3953b1 100644
--- a/arch/s390/include/asm/setup.h
+++ b/arch/s390/include/asm/setup.h
@@ -23,12 +23,18 @@
#define STARTUP_KDUMP_OFFSET 0x10010

#define LEGACY_COMMAND_LINE_SIZE 896
+#define CRASHK_CMA_ENTRIES 4

#ifndef __ASSEMBLER__

#include <asm/lowcore.h>
#include <asm/types.h>

+struct crashk_cma_range {
+ unsigned long start;
+ unsigned long size;
+};
+
struct parmarea {
unsigned long ipl_device; /* 0x10400 */
unsigned long initrd_start; /* 0x10408 */
@@ -37,7 +43,8 @@ struct parmarea {
unsigned long oldmem_size; /* 0x10420 */
unsigned long kernel_version; /* 0x10428 */
unsigned long max_command_line_size; /* 0x10430 */
- char pad1[0x10480-0x10438]; /* 0x10438 - 0x10480 */
+ struct crashk_cma_range crashk_cma[CRASHK_CMA_ENTRIES]; /* 0x10438 - 0x10478 */
+ char pad1[0x10480-0x10478]; /* 0x10478 - 0x10480 */
char command_line[COMMAND_LINE_SIZE]; /* 0x10480 */
};

diff --git a/arch/s390/kernel/machine_kexec_file.c b/arch/s390/kernel/machine_kexec_file.c
index 6f0852d5a3a9..198e0d736aa0 100644
--- a/arch/s390/kernel/machine_kexec_file.c
+++ b/arch/s390/kernel/machine_kexec_file.c
@@ -282,6 +282,11 @@ void *kexec_file_add_components(struct kimage *image,
if (image->type == KEXEC_TYPE_CRASH) {
data.parm->oldmem_base = crashk_res.start;
data.parm->oldmem_size = crashk_res.end - crashk_res.start + 1;
+ BUILD_BUG_ON(ARRAY_SIZE(data.parm->crashk_cma) < CRASHK_CMA_RANGES_MAX);
+ for (int i = 0; i < crashk_cma_cnt; i++) {
+ data.parm->crashk_cma[i].start = crashk_cma_ranges[i].start;
+ data.parm->crashk_cma[i].size = range_len(&crashk_cma_ranges[i]);
+ }
}
#endif

diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 0251bd35954a..3c1c66e6c281 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -663,8 +663,11 @@ static void __init reserve_crashkernel(void)
* A kdump kernel is handed the CMA ranges of the crashed kernel
* instead of reserving its own.
*/
- if (!oldmem_data.start)
+ if (!oldmem_data.start) {
reserve_crashkernel_cma(cma_size);
+ /* the ranges are handed over in ascending order */
+ sort_range(crashk_cma_ranges, crashk_cma_cnt);
+ }
#endif
}

--
2.55.0