[PATCH v1 6/8] s390/kdump: Use crashkernel CMA memory in the kdump kernel
Mikhail Zaslonko
zaslonko at linux.ibm.com
Thu Nov 12 03:21:03 PST 2026
A kdump kernel limits ident_map_size to the crashkernel size, so it
can't use the crashkernel CMA memory above it.
Don't limit ident_map_size when CMA ranges are passed. Instead, add the
crashkernel memory and the CMA ranges as usable memory ranges. All
other memory is treated as a memory hole.
The CMA memory is then mapped, added to memblock and freed to the buddy
allocator like any other memory. As the boot allocator starts at
ident_map_size, decompressor allocations such as page tables, the KASAN
shadow and the initrd moved by rescue_initrd() come from the CMA memory
first.
Like oldmem_base and oldmem_size, the ranges are used as passed by the
crashed kernel.
Co-developed-by: Vasily Gorbik <gor at linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor at linux.ibm.com>
Signed-off-by: Mikhail Zaslonko <zaslonko at linux.ibm.com>
---
arch/s390/boot/startup.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/arch/s390/boot/startup.c b/arch/s390/boot/startup.c
index 111b146a3332..dba1dfc0ee49 100644
--- a/arch/s390/boot/startup.c
+++ b/arch/s390/boot/startup.c
@@ -197,6 +197,22 @@ static void deploy_kernel(void *output)
}
#endif
+static void setup_usable_memory(void)
+{
+ unsigned long start;
+ int i;
+
+ if (!IS_ENABLED(CONFIG_CRASH_DUMP) || !oldmem_data.start) {
+ physmem_add_usable_range(0, ident_map_size);
+ return;
+ }
+ physmem_add_usable_range(0, oldmem_data.size);
+ for (i = 0; i < ARRAY_SIZE(oldmem_data.crashk_cma) && oldmem_data.crashk_cma[i].size; i++) {
+ start = oldmem_data.crashk_cma[i].start;
+ physmem_add_usable_range(start, start + oldmem_data.crashk_cma[i].size);
+ }
+}
+
static void rescue_initrd(unsigned long min, unsigned long max)
{
unsigned long old_addr, addr, size;
@@ -270,8 +286,9 @@ static void kaslr_adjust_got(unsigned long offset)
* 2. CONFIG_MAX_PHYSMEM_BITS - the maximum size of physical memory the
* kernel is able to support.
* 3. "mem=" kernel command line option which limits physical memory usage.
- * 4. OLDMEM_BASE which is a kdump memory limit when the kernel is executed as
- * crash kernel.
+ * 4. OLDMEM_SIZE limits the identity map to primary crashkernel memory
+ * when OLDMEM_BASE is set and no crashkernel CMA ranges are passed.
+ * With CMA ranges, setup_usable_memory() selects the usable ranges.
* 5. "hsa" size which is a memory limit when the kernel is executed during
* zfcp/nvme dump.
*/
@@ -287,7 +304,9 @@ static void setup_ident_map_size(unsigned long max_physmem_end)
#ifdef CONFIG_CRASH_DUMP
if (oldmem_data.start) {
__kaslr_enabled = 0;
- ident_map_size = min(ident_map_size, oldmem_data.size);
+ /* no CMA ranges handed over to the crashkernel */
+ if (!oldmem_data.crashk_cma[0].size)
+ ident_map_size = min(ident_map_size, oldmem_data.size);
boot_debug("kdump memory limit: 0x%016lx\n", oldmem_data.size);
} else if (ipl_block_valid && is_ipl_block_dump()) {
__kaslr_enabled = 0;
@@ -545,8 +564,7 @@ void startup_kernel(void)
setup_ident_map_size(max_physmem_end);
setup_vmalloc_size();
asce_limit = setup_kernel_memory_layout(kernel_size);
- /* got final ident_map_size, physmem allocations could be performed now */
- physmem_add_usable_range(0, ident_map_size);
+ setup_usable_memory();
physmem_set_alloc_limit(ident_map_size);
detect_physmem_online_ranges(max_physmem_end);
save_ipl_cert_comp_list();
--
2.55.0
More information about the kexec
mailing list