Skip to contentSkip to conversation

powerpc/kdump: Add support for crashkernel CMA reservation

PATCH Applied Sourabh Jain 3 participants 4 messages Nov 7, 2025 – Nov 21, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v7 1/1 powerpc/kdump: Add support for crashkernel CMA reservation

Commit 35c18f2933c5 ("Add a new optional ",cma" suffix to the crashkernel= command line option") and commit ab475510e042 ("kdump:
implement reserve_crashkernel_cma") added CMA support for kdump crashkernel reservation.

Extend crashkernel CMA reservation support to powerpc.

The following changes are made to enable CMA reservation on powerpc:

- Parse and obtain the CMA reservation size along with other crashkernel parameters
- Call reserve_crashkernel_cma() to allocate the CMA region for kdump
- Include the CMA-reserved ranges in the usable memory ranges for the kdump kernel to use.
- Exclude the CMA-reserved ranges from the crash kernel memory to prevent them from being exported through /proc/vmcore.

With the introduction of the CMA crashkernel regions, crash_exclude_mem_range() needs to be called multiple times to exclude both crashk_res and crashk_cma_ranges from the crash memory ranges. To avoid repetitive logic for validating mem_ranges size and handling reallocation when required, this functionality is moved to a new wrapper function crash_exclude_mem_range_guarded().

To ensure proper CMA reservation, reserve_crashkernel_cma() is called after pageblock_order is initialized.

Update kernel-parameters.txt to document CMA support for crashkernel on powerpc architecture.

Cc Baoquan he <[email protected]>
Cc Jiri Bohac <[email protected]>
Cc Hari Bathini <[email protected]>
Cc Madhavan Srinivasan <[email protected]>
Cc Mahesh Salgaonkar <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Ritesh Harjani (IBM) <[email protected]>
Cc Shivang Upadhyay <[email protected]>

---
Changelog:

v6 -> v7
https://lore.kernel.org/all/[email protected]/
- declare crashk_cma_size static

---
 .../admin-guide/kernel-parameters.txt         |  2 +-
 arch/powerpc/include/asm/kexec.h              |  2 +
 arch/powerpc/kernel/setup-common.c            |  4 +-
 arch/powerpc/kexec/core.c                     | 10 ++++-
 arch/powerpc/kexec/ranges.c                   | 43 ++++++++++++++-----
 5 files changed, 47 insertions(+), 14 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +1 -1
index 6c42061ca20e..1c10190d583d 100644
@@ -1013,7 +1013,7 @@
 			It will be ignored when crashkernel=X,high is not used
 			or memory reserved is below 4G.
 	crashkernel=size[KMG],cma
-			[KNL, X86] Reserve additional crash kernel memory from
+			[KNL, X86, ppc] Reserve additional crash kernel memory from
 			CMA. This reservation is usable by the first system's
 			userspace memory and kernel movable allocations (memory
 			balloon, zswap). Pages allocated from this memory range
arch/powerpc/include/asm/kexec.h +2 -0
index 4bbf9f699aaa..bd4a6c42a5f3 100644
@@ -115,9 +115,11 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt, struct crash_mem
 #ifdef CONFIG_CRASH_RESERVE
 int __init overlaps_crashkernel(unsigned long start, unsigned long size);
 extern void arch_reserve_crashkernel(void);
+extern void kdump_cma_reserve(void);
 #else
 static inline void arch_reserve_crashkernel(void) {}
 static inline int overlaps_crashkernel(unsigned long start, unsigned long size) { return 0; }
+static inline void kdump_cma_reserve(void) { }
 #endif
 
 #if defined(CONFIG_CRASH_DUMP)
arch/powerpc/kernel/setup-common.c +3 -1
index 68d47c53876c..c8c42b419742 100644
@@ -35,6 +35,7 @@
 #include <linux/of_irq.h>
 #include <linux/hugetlb.h>
 #include <linux/pgtable.h>
+#include <asm/kexec.h>
 #include <asm/io.h>
 #include <asm/paca.h>
 #include <asm/processor.h>
@@ -995,11 +996,12 @@ void __init setup_arch(char **cmdline_p)
 	initmem_init();
 
 	/*
-	 * Reserve large chunks of memory for use by CMA for fadump, KVM and
+	 * Reserve large chunks of memory for use by CMA for kdump, fadump, KVM and
 	 * hugetlb. These must be called after initmem_init(), so that
 	 * pageblock_order is initialised.
 	 */
 	fadump_cma_init();
+	kdump_cma_reserve();
 	kvm_cma_reserve();
 	gigantic_hugetlb_cma_reserve();
 
arch/powerpc/kexec/core.c +9 -1
index d1a2d755381c..e59bdfcc6463 100644
@@ -59,6 +59,8 @@ void machine_kexec(struct kimage *image)
 
 #ifdef CONFIG_CRASH_RESERVE
 
+static unsigned long long crashk_cma_size;
+
 static unsigned long long __init get_crash_base(unsigned long long crash_base)
 {
 
@@ -110,7 +112,7 @@ void __init arch_reserve_crashkernel(void)
 
 	/* use common parsing */
 	ret = parse_crashkernel(boot_command_line, total_mem_sz, &crash_size,
-				&crash_base, NULL, NULL, NULL);
+				&crash_base, NULL, &crashk_cma_size, NULL);
 
 	if (ret)
 		return;
@@ -130,6 +132,12 @@ void __init arch_reserve_crashkernel(void)
 	reserve_crashkernel_generic(crash_size, crash_base, 0, false);
 }
 
+void __init kdump_cma_reserve(void)
+{
+	if (crashk_cma_size)
+		reserve_crashkernel_cma(crashk_cma_size);
+}
+
 int __init overlaps_crashkernel(unsigned long start, unsigned long size)
 {
 	return (start + size) > crashk_res.start && start <= crashk_res.end;
arch/powerpc/kexec/ranges.c +32 -11

77 lines not on this page · raw message

Signature · 1 line
2.51.1
reviewer Reviewed-by on v7 1/1
#1 lore raw
Quoted 7 lines · Sourabh Jain

Commit 35c18f2933c5 ("Add a new optional ",cma" suffix to the crashkernel= command line option") and commit ab475510e042 ("kdump:
implement reserve_crashkernel_cma") added CMA support for kdump crashkernel reservation.

Extend crashkernel CMA reservation support to powerpc.

Yup, would be nice to see this support landing in powerpc!

Quoted 40 lines

The following changes are made to enable CMA reservation on powerpc:

- Parse and obtain the CMA reservation size along with other crashkernel parameters
- Call reserve_crashkernel_cma() to allocate the CMA region for kdump
- Include the CMA-reserved ranges in the usable memory ranges for the kdump kernel to use.
- Exclude the CMA-reserved ranges from the crash kernel memory to prevent them from being exported through /proc/vmcore.

With the introduction of the CMA crashkernel regions, crash_exclude_mem_range() needs to be called multiple times to exclude both crashk_res and crashk_cma_ranges from the crash memory ranges. To avoid repetitive logic for validating mem_ranges size and handling reallocation when required, this functionality is moved to a new wrapper function crash_exclude_mem_range_guarded().

To ensure proper CMA reservation, reserve_crashkernel_cma() is called after pageblock_order is initialized.

Update kernel-parameters.txt to document CMA support for crashkernel on powerpc architecture.

Cc Baoquan he <[email protected]>
Cc Jiri Bohac <[email protected]>
Cc Hari Bathini <[email protected]>
Cc Madhavan Srinivasan <[email protected]>
Cc Mahesh Salgaonkar <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Ritesh Harjani (IBM) <[email protected]>
Cc Shivang Upadhyay <[email protected]>

---
Changelog:

v6 -> v7
https://lore.kernel.org/all/[email protected]/
- declare crashk_cma_size static

Quoted 7 lines
---
 .../admin-guide/kernel-parameters.txt         |  2 +-
 arch/powerpc/include/asm/kexec.h              |  2 +
 arch/powerpc/kernel/setup-common.c            |  4 +-
 arch/powerpc/kexec/core.c                     | 10 ++++-
 arch/powerpc/kexec/ranges.c                   | 43 ++++++++++++++-----
 5 files changed, 47 insertions(+), 14 deletions(-)

Although my reviewed by may not count much here since I am not deeply familiar with arch/powerpc/kexec/** part..

But FWIW, the patch overall looks logical to me.
Keeping cma reservation in setup_arch() is the right thing to do to avoid issues like these in past [1]. The error handling logic and the loop logic for handling CMA ranges also looks correct to me.

So feel free to add:

[1]: https://lore.kernel.org/linuxppc-dev/3ae208e48c0d9cefe53d2dc4f593388067405b7d.1729146153.git.ritesh.list@gmail.com/

#2 lore raw
Quoted 66 lines · Ritesh Harjani (IBM)
Quoted 7 lines · Sourabh Jain

Commit 35c18f2933c5 ("Add a new optional ",cma" suffix to the crashkernel= command line option") and commit ab475510e042 ("kdump:
implement reserve_crashkernel_cma") added CMA support for kdump crashkernel reservation.

Extend crashkernel CMA reservation support to powerpc.

Yup, would be nice to see this support landing in powerpc!

Quoted 40 lines

The following changes are made to enable CMA reservation on powerpc:

- Parse and obtain the CMA reservation size along with other crashkernel parameters
- Call reserve_crashkernel_cma() to allocate the CMA region for kdump
- Include the CMA-reserved ranges in the usable memory ranges for the kdump kernel to use.
- Exclude the CMA-reserved ranges from the crash kernel memory to prevent them from being exported through /proc/vmcore.

With the introduction of the CMA crashkernel regions, crash_exclude_mem_range() needs to be called multiple times to exclude both crashk_res and crashk_cma_ranges from the crash memory ranges. To avoid repetitive logic for validating mem_ranges size and handling reallocation when required, this functionality is moved to a new wrapper function crash_exclude_mem_range_guarded().

To ensure proper CMA reservation, reserve_crashkernel_cma() is called after pageblock_order is initialized.

Update kernel-parameters.txt to document CMA support for crashkernel on powerpc architecture.

Cc Baoquan he <[email protected]>
Cc Jiri Bohac <[email protected]>
Cc Hari Bathini <[email protected]>
Cc Madhavan Srinivasan <[email protected]>
Cc Mahesh Salgaonkar <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Ritesh Harjani (IBM) <[email protected]>
Cc Shivang Upadhyay <[email protected]>

---
Changelog:

v6 -> v7
https://lore.kernel.org/all/[email protected]/
- declare crashk_cma_size static

Quoted 7 lines
---
  .../admin-guide/kernel-parameters.txt         |  2 +-
  arch/powerpc/include/asm/kexec.h              |  2 +
  arch/powerpc/kernel/setup-common.c            |  4 +-
  arch/powerpc/kexec/core.c                     | 10 ++++-
  arch/powerpc/kexec/ranges.c                   | 43 ++++++++++++++-----
  5 files changed, 47 insertions(+), 14 deletions(-)

Although my reviewed by may not count much here since I am not deeply familiar with arch/powerpc/kexec/** part..

But FWIW, the patch overall looks logical to me.
Keeping cma reservation in setup_arch() is the right thing to do to avoid issues like these in past [1]. The error handling logic and the loop logic for handling CMA ranges also looks correct to me.

Quoted 4 lines

So feel free to add:

[1]: https://lore.kernel.org/linuxppc-dev/3ae208e48c0d9cefe53d2dc4f593388067405b7d.1729146153.git.ritesh.list@gmail.com/

Thanks for the Review Ritesh.

- Sourabh Jain

maintainer Applied
#3 lore raw
In reply to Sourabh Jain
Quoted 8 lines · Sourabh Jain

Commit 35c18f2933c5 ("Add a new optional ",cma" suffix to the crashkernel= command line option") and commit ab475510e042 ("kdump:
implement reserve_crashkernel_cma") added CMA support for kdump crashkernel reservation.

Extend crashkernel CMA reservation support to powerpc.

[...]

Applied to powerpc/next.

[1/1] powerpc/kdump: Add support for crashkernel CMA reservation

      https://git.kernel.org/powerpc/c/b4a96ab50f368afc2360ff539a20254ca2c9a889

Thanks