linux/arch/powerpc
Sourabh Jain 849599b702 powerpc/crash: add crash memory hotplug support
Extend the arch crash hotplug handler, as introduced by the patch title
("powerpc: add crash CPU hotplug support"), to also support memory
add/remove events.

Elfcorehdr describes the memory of the crash kernel to capture the
kernel; hence, it needs to be updated if memory resources change due to
memory add/remove events. Therefore, arch_crash_handle_hotplug_event()
is updated to recreate the elfcorehdr and replace it with the previous
one on memory add/remove events.

The memblock list is used to prepare the elfcorehdr. In the case of
memory hot remove, the memblock list is updated after the arch crash
hotplug handler is triggered, as depicted in Figure 1. Thus, the
hot-removed memory is explicitly removed from the crash memory ranges
to ensure that the memory ranges added to elfcorehdr do not include the
hot-removed memory.

    Memory remove
          |
          v
    Offline pages
          |
          v
 Initiate memory notify call <----> crash hotplug handler
 chain for MEM_OFFLINE event
          |
          v
 Update memblock list

 	Figure 1

There are two system calls, `kexec_file_load` and `kexec_load`, used to
load the kdump image. A few changes have been made to ensure that the
kernel can safely update the elfcorehdr component of the kdump image for
both system calls.

For the kexec_file_load syscall, kdump image is prepared in the kernel.
To support an increasing number of memory regions, the elfcorehdr is
built with extra buffer space to ensure that it can accommodate
additional memory ranges in future.

For the kexec_load syscall, the elfcorehdr is updated only if the
KEXEC_CRASH_HOTPLUG_SUPPORT kexec flag is passed to the kernel by the
kexec tool. Passing this flag to the kernel indicates that the
elfcorehdr is built to accommodate additional memory ranges and the
elfcorehdr segment is not considered for SHA calculation, making it safe
to update.

The changes related to this feature are kept under the CRASH_HOTPLUG
config, and it is enabled by default.

Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Acked-by: Hari Bathini <hbathini@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240326055413.186534-7-sourabhjain@linux.ibm.com
2024-04-23 15:00:04 +10:00
..
boot USB/Thunderbolt changes for 6.9-rc1 2024-03-21 12:35:20 -07:00
configs powerpc: Add allmodconfig for all 32-bit sub-arches 2024-03-03 22:20:29 +11:00
crypto crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00
include powerpc/crash: add crash memory hotplug support 2024-04-23 15:00:04 +10:00
kernel powerpc/kdump: Split KEXEC_CORE and CRASH_DUMP dependency 2024-03-17 13:34:00 +11:00
kexec powerpc/crash: add crash memory hotplug support 2024-04-23 15:00:04 +10:00
kvm powerpc updates for 6.9 2024-03-15 17:53:48 -07:00
lib powerpc: xor_vmx: Add '-mhard-float' to CFLAGS 2024-03-07 00:13:28 +11:00
math-emu powerpc/math-emu: Inhibit W=1 warnings 2022-09-08 11:11:18 +10:00
mm powerpc: Handle error in mark_rodata_ro() and mark_initmem_nx() 2024-03-17 13:33:21 +11:00
net powerpc/bpf: use bpf_jit_binary_pack_[alloc|finalize|free] 2023-10-23 20:33:19 +11:00
perf powerpc/hv-gpci: Fix the H_GET_PERF_COUNTER_INFO hcall return value checks 2024-03-03 23:05:21 +11:00
platforms powerpc/kdump: Split KEXEC_CORE and CRASH_DUMP dependency 2024-03-17 13:34:00 +11:00
purgatory powerpc/purgatory: remove PGO flags 2023-06-12 11:31:50 -07:00
sysdev powerpc updates for 6.9 2024-03-15 17:53:48 -07:00
tools powerpc/tools: Pass -mabi=elfv2 to gcc-check-mprofile-kernel.sh 2023-10-20 17:46:33 +11:00
xmon powerpc updates for 6.9 2024-03-15 17:53:48 -07:00
Kbuild
Kconfig powerpc/crash: add crash CPU hotplug support 2024-04-23 15:00:04 +10:00
Kconfig.debug powerpc/ps3: move udbg_shutdown_ps3gelic prototype 2023-11-21 12:06:50 +11:00
Makefile powerpc updates for 6.9 2024-03-15 17:53:48 -07:00
Makefile.postlink kbuild: remove ARCH_POSTLINK from module builds 2023-10-28 21:10:08 +09:00