mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikhail Zaslonko <zaslonko@linux.ibm.com>
To: Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Baoquan He <baoquan.he@linux.dev>,
	Mike Rapoport <rppt@kernel.org>,
	Pasha Tatashin <pasha.tatashin@soleen.com>,
	Pratyush Yadav <pratyush@kernel.org>,
	Dave Young <ruirui.yang@linux.dev>, Jiri Bohac <jbohac@suse.cz>,
	Jonathan Corbet <corbet@lwn.net>,
	Usama Arif <usama.arif@linux.dev>,
	linux-s390@vger.kernel.org, kexec@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v1 6/8] s390/kdump: Use crashkernel CMA memory in the kdump kernel
Date: Thu, 12 Nov 2026 12:21:03 +0100	[thread overview]
Message-ID: <20261112112105.1169118-7-zaslonko@linux.ibm.com> (raw)
In-Reply-To: <20261112112105.1169118-1-zaslonko@linux.ibm.com>

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@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Mikhail Zaslonko <zaslonko@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


  parent reply	other threads:[~2026-11-12 11:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 11:20 [PATCH v1 0/8] s390/kdump: Add crashkernel CMA support Mikhail Zaslonko
2026-11-12 11:20 ` [PATCH v1 1/8] s390/kdump: Enable crashkernel CMA infrastructure Mikhail Zaslonko
2026-11-12 11:20 ` [PATCH v1 2/8] s390/kdump: Reserve crashkernel CMA memory Mikhail Zaslonko
2026-11-12 11:21 ` [PATCH v1 3/8] s390/kexec: Pass crashkernel CMA ranges to the kdump kernel Mikhail Zaslonko
2026-11-12 11:21 ` [PATCH v1 4/8] s390/boot: Allow additional usable memory ranges Mikhail Zaslonko
2026-11-12 11:21 ` [PATCH v1 5/8] s390/kdump: Exclude crashkernel CMA memory from vmcore Mikhail Zaslonko
2026-11-12 11:21 ` Mikhail Zaslonko [this message]
2026-11-12 11:21 ` [PATCH v1 7/8] s390/kdump: Skip the crashkernel CMA DMA wait Mikhail Zaslonko
2026-11-12 11:21 ` [PATCH v1 8/8] Documentation: kdump: Add s390 to crashkernel CMA Mikhail Zaslonko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261112112105.1169118-7-zaslonko@linux.ibm.com \
    --to=zaslonko@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=baoquan.he@linux.dev \
    --cc=corbet@lwn.net \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=jbohac@suse.cz \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=pratyush@kernel.org \
    --cc=rppt@kernel.org \
    --cc=ruirui.yang@linux.dev \
    --cc=usama.arif@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®