From: Sourabh Jain <sourabhjain@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>,
Baoquan he <bhe@redhat.com>,
Hari Bathini <hbathini@linux.ibm.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Mahesh Salgaonkar <mahesh@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
Shivang Upadhyay <shivangu@linux.ibm.com>
Subject: [PATCH 3/4] powerpc/kdump: consider high crashkernel memory if enabled
Date: Mon, 27 Oct 2025 20:43:37 +0530 [thread overview]
Message-ID: <20251027151338.819957-4-sourabhjain@linux.ibm.com> (raw)
In-Reply-To: <20251027151338.819957-1-sourabhjain@linux.ibm.com>
The next patch adds high crashkernel reservation support on powerpc, so
kdump setup is updated to handle high crashkernel while loading the kdump
kernel.
With high crashkernel reservation, the crashkernel is split into two
regions: low crashkernel and high crashkernel. To ensure kdump loads
properly with the split reservation, the following changes are made:
- Load the kdump image in high memory if enabled
- Include both low and high crashkernel regions in usable memory
ranges for the kdump kernel
- Exclude both low and high crashkernel regions from crashkernel memory
to prevent them from being exported through /proc/vmcore
Cc: Baoquan he <bhe@redhat.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Cc: Shivang Upadhyay <shivangu@linux.ibm.com>
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
---
arch/powerpc/kexec/elf_64.c | 10 +++++++---
arch/powerpc/kexec/file_load_64.c | 5 +++--
arch/powerpc/kexec/ranges.c | 24 +++++++++++++++++++++---
3 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c
index 5d6d616404cf..ab84ff6d3685 100644
--- a/arch/powerpc/kexec/elf_64.c
+++ b/arch/powerpc/kexec/elf_64.c
@@ -52,9 +52,13 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
if (IS_ENABLED(CONFIG_CRASH_DUMP) && image->type == KEXEC_TYPE_CRASH) {
/* min & max buffer values for kdump case */
kbuf.buf_min = pbuf.buf_min = crashk_res.start;
- kbuf.buf_max = pbuf.buf_max =
- ((crashk_res.end < ppc64_rma_size) ?
- crashk_res.end : (ppc64_rma_size - 1));
+
+ if (crashk_low_res.end)
+ kbuf.buf_max = pbuf.buf_max = crashk_res.end;
+ else
+ kbuf.buf_max = pbuf.buf_max =
+ ((crashk_res.end < ppc64_rma_size) ?
+ crashk_res.end : (ppc64_rma_size - 1));
}
ret = kexec_elf_load(image, &ehdr, &elf_info, &kbuf, &kernel_load_addr);
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index e7ef8b2a2554..d45f5748e75c 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -746,6 +746,7 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt, struct crash_mem
int i, nr_ranges, ret;
#ifdef CONFIG_CRASH_DUMP
+ uint64_t crashk_start;
/*
* Restrict memory usage for kdump kernel by setting up
* usable memory ranges and memory reserve map.
@@ -765,8 +766,8 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt, struct crash_mem
* Ensure we don't touch crashed kernel's memory except the
* first 64K of RAM, which will be backed up.
*/
- ret = fdt_add_mem_rsv(fdt, BACKUP_SRC_END + 1,
- crashk_res.start - BACKUP_SRC_SIZE);
+ crashk_start = crashk_low_res.end ? crashk_low_res.start : crashk_res.start;
+ ret = fdt_add_mem_rsv(fdt, BACKUP_SRC_END + 1, crashk_start - BACKUP_SRC_SIZE);
if (ret) {
pr_err("Error reserving crash memory: %s\n",
fdt_strerror(ret));
diff --git a/arch/powerpc/kexec/ranges.c b/arch/powerpc/kexec/ranges.c
index c61aa96f0942..53e52e1f07c8 100644
--- a/arch/powerpc/kexec/ranges.c
+++ b/arch/powerpc/kexec/ranges.c
@@ -524,9 +524,20 @@ int get_usable_memory_ranges(struct crash_mem **mem_ranges)
* Also, crashed kernel's memory must be added to reserve map to
* avoid kdump kernel from using it.
*/
- ret = add_mem_range(mem_ranges, 0, crashk_res.end + 1);
- if (ret)
- goto out;
+ if (crashk_low_res.end) {
+ ret = add_mem_range(mem_ranges, 0, crashk_low_res.end + 1);
+ if (ret)
+ goto out;
+
+ ret = add_mem_range(mem_ranges, crashk_res.start,
+ crashk_res.end - crashk_res.start + 1);
+ if (ret)
+ goto out;
+ } else {
+ ret = add_mem_range(mem_ranges, 0, crashk_res.end + 1);
+ if (ret)
+ goto out;
+ }
for (i = 0; i < crashk_cma_cnt; i++) {
ret = add_mem_range(mem_ranges, crashk_cma_ranges[i].start,
@@ -610,6 +621,13 @@ int get_crash_memory_ranges(struct crash_mem **mem_ranges)
if (ret)
goto out;
+ if (crashk_low_res.end) {
+ ret = crash_exclude_mem_range_guarded(mem_ranges, crashk_low_res.start,
+ crashk_low_res.end);
+ if (ret)
+ goto out;
+ }
+
for (i = 0; i < crashk_cma_cnt; ++i) {
ret = crash_exclude_mem_range_guarded(mem_ranges, crashk_cma_ranges[i].start,
crashk_cma_ranges[i].end);
--
2.51.0
next prev parent reply other threads:[~2025-10-27 15:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 15:13 [PATCH 0/4] powerpc/kdump: Support high crashkernel reservation Sourabh Jain
2025-10-27 15:13 ` [PATCH 1/4] powerpc/mmu: do MMU type discovery before " Sourabh Jain
2025-10-31 4:53 ` Ritesh Harjani
2025-10-27 15:13 ` [PATCH 2/4] powerpc: move to 64-bit RTAS Sourabh Jain
2025-10-29 12:52 ` Sourabh Jain
2025-10-27 15:13 ` Sourabh Jain [this message]
2025-10-27 15:13 ` [PATCH 4/4] powerpc/kdump: add support for high crashkernel reservation Sourabh Jain
2025-10-28 6:23 ` [PATCH 0/4] powerpc/kdump: Support " Baoquan he
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=20251027151338.819957-4-sourabhjain@linux.ibm.com \
--to=sourabhjain@linux.ibm.com \
--cc=bhe@redhat.com \
--cc=hbathini@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mahesh@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=ritesh.list@gmail.com \
--cc=shivangu@linux.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).