[RFC v1 8/8] crash hp: Add x86 crash hotplug support for bzImage

From: Eric DeVolder
Date: Thu Nov 18 2021 - 12:51:12 EST


The few changes to kexec-bzimage64.c are to record information needed
in advance of when a hotplug event occurs. This information is recorded
when the crash/capture kernel is loaded.

In particular, the index of the purgatory segment, and the handful of
register context values needed by purgatory, are recorded.

Signed-off-by: Eric DeVolder <eric.devolder@xxxxxxxxxx>
---
arch/x86/kernel/kexec-bzimage64.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c
index 170d0fd68b1f..1886c215215d 100644
--- a/arch/x86/kernel/kexec-bzimage64.c
+++ b/arch/x86/kernel/kexec-bzimage64.c
@@ -378,6 +378,10 @@ static void *bzImage64_load(struct kimage *image, char *kernel,
* Load purgatory. For 64bit entry point, purgatory code can be
* anywhere.
*/
+#ifdef CONFIG_CRASH_HOTPLUG
+ /* Record the index of the purgatory segment */
+ image->arch.hp.purg_index = image->nr_segments;
+#endif
ret = kexec_load_purgatory(image, &pbuf);
if (ret) {
pr_err("Loading purgatory failed\n");
@@ -488,6 +492,14 @@ static void *bzImage64_load(struct kimage *image, char *kernel,
if (ret)
goto out_free_params;

+#ifdef CONFIG_CRASH_HOTPLUG
+ /* Save for use on hotplug to patch up purgatory context */
+ image->arch.hp.rbx = regs64.rbx;
+ image->arch.hp.rsi = regs64.rsi;
+ image->arch.hp.rip = regs64.rip;
+ image->arch.hp.rsp = regs64.rsp;
+#endif
+
ret = setup_boot_parameters(image, params, bootparam_load_addr,
efi_map_offset, efi_map_sz,
efi_setup_data_offset);
--
2.27.0