* [PATCH] powerpc/kdump: Add support for crashkernel CMA reservation
@ 2025-10-22 10:25 Sourabh Jain
2025-10-23 0:24 ` kernel test robot
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sourabh Jain @ 2025-10-22 10:25 UTC (permalink / raw)
To: linuxppc-dev
Cc: Sourabh Jain, Baoquan he, Jiri Bohac, Hari Bathini,
Madhavan Srinivasan, Mahesh Salgaonkar, Michael Ellerman,
Ritesh Harjani (IBM), Shivang Upadhyay
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
To ensure proper CMA reservation, reserve_crashkernel_cma() is called
after pageblock_order is initialized.
Cc: Baoquan he <bhe@redhat.com>
Cc: Jiri Bohac <jbohac@suse.cz>
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/include/asm/kexec.h | 7 +++++++
arch/powerpc/kernel/setup-common.c | 4 +++-
arch/powerpc/kexec/core.c | 11 ++++++++++-
arch/powerpc/kexec/ranges.c | 16 +++++++++++++++-
4 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index 4bbf9f699aaa..c158ffbfeadb 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -51,9 +51,16 @@
#ifndef __ASSEMBLER__
#include <asm/reg.h>
+#include <linux/crash_reserve.h>
typedef void (*crash_shutdown_t)(void);
+#ifdef CRASHKERNEL_CMA
+void kdump_cma_reserve(void);
+#else
+static inline void kdump_cma_reserve(void) { }
+#endif
+
#ifdef CONFIG_KEXEC_CORE
struct kimage;
struct pt_regs;
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 68d47c53876c..1279e8777366 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -35,6 +35,7 @@
#include <linux/of_irq.h>
#include <linux/hugetlb.h>
#include <linux/pgtable.h>
+#include <linux/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();
diff --git a/arch/powerpc/kexec/core.c b/arch/powerpc/kexec/core.c
index d1a2d755381c..3328b1acd875 100644
--- a/arch/powerpc/kexec/core.c
+++ b/arch/powerpc/kexec/core.c
@@ -33,6 +33,9 @@ void machine_kexec_cleanup(struct kimage *image)
{
}
+
+static unsigned long long cma_size;
+
/*
* Do not allocate memory (or fail in any way) in machine_kexec().
* We are past the point of no return, committed to rebooting now.
@@ -110,7 +113,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, &cma_size, NULL);
if (ret)
return;
@@ -130,6 +133,12 @@ void __init arch_reserve_crashkernel(void)
reserve_crashkernel_generic(crash_size, crash_base, 0, false);
}
+void __init kdump_cma_reserve(void)
+{
+ if (cma_size)
+ reserve_crashkernel_cma(cma_size);
+}
+
int __init overlaps_crashkernel(unsigned long start, unsigned long size)
{
return (start + size) > crashk_res.start && start <= crashk_res.end;
diff --git a/arch/powerpc/kexec/ranges.c b/arch/powerpc/kexec/ranges.c
index 3702b0bdab14..dad58fc38251 100644
--- a/arch/powerpc/kexec/ranges.c
+++ b/arch/powerpc/kexec/ranges.c
@@ -515,7 +515,7 @@ int get_exclude_memory_ranges(struct crash_mem **mem_ranges)
*/
int get_usable_memory_ranges(struct crash_mem **mem_ranges)
{
- int ret;
+ int ret, i;
/*
* Early boot failure observed on guests when low memory (first memory
@@ -528,6 +528,13 @@ int get_usable_memory_ranges(struct crash_mem **mem_ranges)
if (ret)
goto out;
+ for (i = 0; i < crashk_cma_cnt; i++) {
+ ret = add_mem_range(mem_ranges, crashk_cma_ranges[i].start,
+ crashk_cma_ranges[i].end);
+ if (ret)
+ goto out;
+ }
+
ret = add_rtas_mem_range(mem_ranges);
if (ret)
goto out;
@@ -595,6 +602,13 @@ int get_crash_memory_ranges(struct crash_mem **mem_ranges)
if (ret)
goto out;
+ for (i = 0; i < crashk_cma_cnt; ++i) {
+ ret = crash_exclude_mem_range(tmem, crashk_cma_ranges[i].start,
+ crashk_cma_ranges[i].end);
+ if (ret)
+ goto out;
+ }
+
/*
* FIXME: For now, stay in parity with kexec-tools but if RTAS/OPAL
* regions are exported to save their context at the time of
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc/kdump: Add support for crashkernel CMA reservation
2025-10-22 10:25 [PATCH] powerpc/kdump: Add support for crashkernel CMA reservation Sourabh Jain
@ 2025-10-23 0:24 ` kernel test robot
2025-10-23 1:39 ` kernel test robot
2025-10-23 2:03 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-10-23 0:24 UTC (permalink / raw)
To: Sourabh Jain, linuxppc-dev
Cc: oe-kbuild-all, Sourabh Jain, Baoquan he, Jiri Bohac, Hari Bathini,
Madhavan Srinivasan, Mahesh Salgaonkar, Michael Ellerman,
Ritesh Harjani (IBM), Shivang Upadhyay
Hi Sourabh,
kernel test robot noticed the following build errors:
[auto build test ERROR on powerpc/next]
[also build test ERROR on powerpc/fixes linus/master v6.18-rc2 next-20251022]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sourabh-Jain/powerpc-kdump-Add-support-for-crashkernel-CMA-reservation/20251022-182711
base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
patch link: https://lore.kernel.org/r/20251022102531.657147-1-sourabhjain%40linux.ibm.com
patch subject: [PATCH] powerpc/kdump: Add support for crashkernel CMA reservation
config: powerpc-allnoconfig (https://download.01.org/0day-ci/archive/20251023/202510230817.h1gNa0VV-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251023/202510230817.h1gNa0VV-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510230817.h1gNa0VV-lkp@intel.com/
All errors (new ones prefixed by >>):
arch/powerpc/kernel/setup-common.c: In function 'setup_arch':
>> arch/powerpc/kernel/setup-common.c:1004:9: error: implicit declaration of function 'kdump_cma_reserve'; did you mean 'kvm_cma_reserve'? [-Wimplicit-function-declaration]
1004 | kdump_cma_reserve();
| ^~~~~~~~~~~~~~~~~
| kvm_cma_reserve
vim +1004 arch/powerpc/kernel/setup-common.c
976
977 /* Print various info about the machine that has been gathered so far. */
978 print_system_info();
979
980 klp_init_thread_info(&init_task);
981
982 setup_initial_init_mm(_stext, _etext, _edata, _end);
983 /* sched_init() does the mmgrab(&init_mm) for the primary CPU */
984 VM_WARN_ON(cpumask_test_cpu(smp_processor_id(), mm_cpumask(&init_mm)));
985 cpumask_set_cpu(smp_processor_id(), mm_cpumask(&init_mm));
986 inc_mm_active_cpus(&init_mm);
987 mm_iommu_init(&init_mm);
988
989 irqstack_early_init();
990 exc_lvl_early_init();
991 emergency_stack_init();
992
993 mce_init();
994 smp_release_cpus();
995
996 initmem_init();
997
998 /*
999 * Reserve large chunks of memory for use by CMA for kdump, fadump, KVM and
1000 * hugetlb. These must be called after initmem_init(), so that
1001 * pageblock_order is initialised.
1002 */
1003 fadump_cma_init();
> 1004 kdump_cma_reserve();
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc/kdump: Add support for crashkernel CMA reservation
2025-10-22 10:25 [PATCH] powerpc/kdump: Add support for crashkernel CMA reservation Sourabh Jain
2025-10-23 0:24 ` kernel test robot
@ 2025-10-23 1:39 ` kernel test robot
2025-10-23 2:03 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-10-23 1:39 UTC (permalink / raw)
To: Sourabh Jain, linuxppc-dev
Cc: llvm, oe-kbuild-all, Sourabh Jain, Baoquan he, Jiri Bohac,
Hari Bathini, Madhavan Srinivasan, Mahesh Salgaonkar,
Michael Ellerman, Ritesh Harjani (IBM), Shivang Upadhyay
Hi Sourabh,
kernel test robot noticed the following build warnings:
[auto build test WARNING on powerpc/next]
[also build test WARNING on powerpc/fixes linus/master v6.18-rc2 next-20251022]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sourabh-Jain/powerpc-kdump-Add-support-for-crashkernel-CMA-reservation/20251022-182711
base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
patch link: https://lore.kernel.org/r/20251022102531.657147-1-sourabhjain%40linux.ibm.com
patch subject: [PATCH] powerpc/kdump: Add support for crashkernel CMA reservation
config: powerpc-randconfig-002-20251023 (https://download.01.org/0day-ci/archive/20251023/202510230923.E37rbvtF-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 754ebc6ebb9fb9fbee7aef33478c74ea74949853)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251023/202510230923.E37rbvtF-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510230923.E37rbvtF-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> arch/powerpc/kexec/core.c:37:27: warning: unused variable 'cma_size' [-Wunused-variable]
37 | static unsigned long long cma_size;
| ^~~~~~~~
1 warning generated.
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for HOTPLUG_CPU
Depends on [n]: SMP [=y] && (PPC_PSERIES [=n] || PPC_PMAC [=n] || PPC_POWERNV [=n] || FSL_SOC_BOOKE [=n])
Selected by [y]:
- PM_SLEEP_SMP [=y] && SMP [=y] && (ARCH_SUSPEND_POSSIBLE [=y] || ARCH_HIBERNATION_POSSIBLE [=y]) && PM_SLEEP [=y]
vim +/cma_size +37 arch/powerpc/kexec/core.c
35
36
> 37 static unsigned long long cma_size;
38
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc/kdump: Add support for crashkernel CMA reservation
2025-10-22 10:25 [PATCH] powerpc/kdump: Add support for crashkernel CMA reservation Sourabh Jain
2025-10-23 0:24 ` kernel test robot
2025-10-23 1:39 ` kernel test robot
@ 2025-10-23 2:03 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-10-23 2:03 UTC (permalink / raw)
To: Sourabh Jain, linuxppc-dev
Cc: oe-kbuild-all, Sourabh Jain, Baoquan he, Jiri Bohac, Hari Bathini,
Madhavan Srinivasan, Mahesh Salgaonkar, Michael Ellerman,
Ritesh Harjani (IBM), Shivang Upadhyay
Hi Sourabh,
kernel test robot noticed the following build errors:
[auto build test ERROR on powerpc/next]
[also build test ERROR on powerpc/fixes linus/master v6.18-rc2 next-20251022]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sourabh-Jain/powerpc-kdump-Add-support-for-crashkernel-CMA-reservation/20251022-182711
base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
patch link: https://lore.kernel.org/r/20251022102531.657147-1-sourabhjain%40linux.ibm.com
patch subject: [PATCH] powerpc/kdump: Add support for crashkernel CMA reservation
config: powerpc64-randconfig-002-20251023 (https://download.01.org/0day-ci/archive/20251023/202510230903.b7vsK8xg-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 10.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251023/202510230903.b7vsK8xg-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510230903.b7vsK8xg-lkp@intel.com/
All errors (new ones prefixed by >>):
>> arch/powerpc/kexec/core.c:136:13: error: redefinition of 'kdump_cma_reserve'
136 | void __init kdump_cma_reserve(void)
| ^~~~~~~~~~~~~~~~~
In file included from include/linux/kexec.h:38,
from arch/powerpc/kexec/core.c:10:
arch/powerpc/include/asm/kexec.h:61:20: note: previous definition of 'kdump_cma_reserve' was here
61 | static inline void kdump_cma_reserve(void) { }
| ^~~~~~~~~~~~~~~~~
vim +/kdump_cma_reserve +136 arch/powerpc/kexec/core.c
135
> 136 void __init kdump_cma_reserve(void)
137 {
138 if (cma_size)
139 reserve_crashkernel_cma(cma_size);
140 }
141
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-23 2:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 10:25 [PATCH] powerpc/kdump: Add support for crashkernel CMA reservation Sourabh Jain
2025-10-23 0:24 ` kernel test robot
2025-10-23 1:39 ` kernel test robot
2025-10-23 2:03 ` kernel test robot
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).