[PATCH v2 0/6] powerpc/crash: use generic crashkernel reservation

Sourabh Jain
2025-01-21T11:55:09Z

Commit 0ab97169aa05 ("crash_core: add generic function to do
reservation") added a generic function to reserve crashkernel memory.
So let's use the same function on powerpc and remove the
architecture-specific code that essentially does the same thing.

The generic crashkernel reservation also provides a way to split the
crashkernel reservation into high and low memory reservations, which can
be enabled for powerpc in the future.

Additionally move powerpc to use generic APIs to locate memory hole for
kexec segments while loading kdump kernel.

Patch series summary:
=====================
Patch 1-3: generic changes
Patch 4-5: powerpc changes
Patch 6: generic + powerpc changes

Changelog:

v1 Resend:
- Rebased on top of 6.13-rc6

v2:
- 01/06 new patch, fixes a bug with ELF load address
It was posted in community as individual path but
since it align with this patch series so include here:
https://lore.kernel.org/all/20241210091314.185785-1-sourabhjain@linux.ibm.com/
- Fixed a typo 06/06
- Added Acked-by and Reviewed-by tags
- Rebased it on 6.13
- It was suggested to try HAVE_ARCH_ADD_CRASH_RES_TO_IOMEM_EARLY and
see if 03/06 patch can be avoided:
https://lore.kernel.org/all/Z35gnO2N%2FLFt1E7E@MiWiFi-R3L-srv/
But after adding HAVE_ARCH_ADD_CRASH_RES_TO_IOMEM_EARLY the issue
persisted and kernel prints below logs on boot:

[ 0.646339] ------------[ cut here ]------------
[ 0.646351] WARNING: CPU: 0 PID: 1 at arch/powerpc/mm/mem.c:379
add_system_ram_resources+0xf0/0x15c
[ 0.646369] Modules linked in:
[ 0.646376] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted
6.13.0-rc6+ #1
[ 0.646386] Hardware name: IBM,9105-22A POWER10 (architected)
0x800200 0xf000006 of:IBM,FW1060.00 (NL1060_027) hv:phyp pSeries
[ 0.646397] NIP: c000000002016b3c LR: c000000002016b34 CTR:
0000000000000000
[ 0.646406] REGS: c000000004817920 TRAP: 0700 Not tainted
(6.13.0-rc6+)
e8/0x15c (unreliable)
[ 0.646603] [c000000004817c20] [c000000000010a4c]
do_one_initcall+0x7c/0x39c
[ 0.646618] [c000000004817d00] [c000000002005418]
do_initcalls+0x144/0x18c
0x290
[ 0.646648] [c000000004817df0] [c0000000000110f4]
kernel_init+0x2c/0x1b8
+0x14/0x1c
[ 0.646676] --- interrupt: 0 at 0x0
010020
[ 0.646720] ---[ end trace 0000000000000000 ]---

So 03/06 is not removed from patch series.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Baoquan he <bhe@redhat.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
CC: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: kexec@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: sourabhjain@linux.ibm.com

Sourabh Jain (6):
kexec: Initialize ELF lowest address to ULONG_MAX
crash: remove an unused argument from reserve_crashkernel_generic()
crash: let arch decide crash memory export to iomem_resource
powerpc/kdump: preserve user-specified memory limit
powerpc/crash: use generic crashkernel reservation
crash: option to let arch decide mem range is usable

arch/arm64/mm/init.c | 6 +-
arch/loongarch/kernel/setup.c | 5 +-
arch/powerpc/Kconfig | 3 +
arch/powerpc/include/asm/crash_reserve.h | 18 ++
arch/powerpc/include/asm/kexec.h | 10 +-
arch/powerpc/kernel/prom.c | 2 +-
arch/powerpc/kexec/core.c | 96 ++++-----
arch/powerpc/kexec/file_load_64.c | 259 +----------------------
arch/riscv/mm/init.c | 6 +-
arch/x86/kernel/setup.c | 6 +-
include/linux/crash_reserve.h | 22 +-
include/linux/kexec.h | 9 +
kernel/crash_reserve.c | 12 +-
kernel/kexec_elf.c | 2 +-
kernel/kexec_file.c | 12 ++
15 files changed, 128 insertions(+), 340 deletions(-)
create mode 100644 arch/powerpc/include/asm/crash_reserve.h

--
2.47.1