crash: add a new kexec flag for hotplug support

Commit a72bbec70d ("crash: hotplug support for kexec_load()")
introduced a new kexec flag, `KEXEC_UPDATE_ELFCOREHDR`. Kexec tool uses
this flag to indicate to the kernel that it is safe to modify the
elfcorehdr of the kdump image loaded using the kexec_load system call.

However, it is possible that architectures may need to update kexec
segments other then elfcorehdr. For example, FDT (Flatten Device Tree)
on PowerPC. Introducing a new kexec flag for every new kexec segment
may not be a good solution. Hence, a generic kexec flag bit,
`KEXEC_CRASH_HOTPLUG_SUPPORT`, is introduced to share the CPU/Memory
hotplug support intent between the kexec tool and the kernel for the
kexec_load system call.

Now we have two kexec flags that enables crash hotplug support for
kexec_load system call. First is KEXEC_UPDATE_ELFCOREHDR (only used in
x86), and second is KEXEC_CRASH_HOTPLUG_SUPPORT (for all architectures).

To simplify the process of finding and reporting the crash hotplug
support the following changes are introduced.

1. Define arch specific function to process the kexec flags and
   determine crash hotplug support

2. Rename the @update_elfcorehdr member of struct kimage to
   @hotplug_support and populate it for both kexec_load and
   kexec_file_load syscalls, because architecture can update more than
   one kexec segment

3. Let generic function crash_check_hotplug_support report hotplug
   support for loaded kdump image based on value of @hotplug_support

To bring the x86 crash hotplug support in line with the above points,
the following changes have been made:

- Introduce the arch_crash_hotplug_support function to process kexec
  flags and determine crash hotplug support

- Remove the arch_crash_hotplug_[cpu|memory]_support functions

Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Acked-by: Baoquan He <bhe@redhat.com>
Acked-by: Hari Bathini <hbathini@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240326055413.186534-3-sourabhjain@linux.ibm.com
This commit is contained in:
Sourabh Jain
2024-03-26 11:24:09 +05:30
committed by Michael Ellerman
parent 118005713e
commit 79365026f8
10 changed files with 48 additions and 44 deletions

View File

@ -402,20 +402,26 @@ int crash_load_segments(struct kimage *image)
#undef pr_fmt
#define pr_fmt(fmt) "crash hp: " fmt
/* These functions provide the value for the sysfs crash_hotplug nodes */
#ifdef CONFIG_HOTPLUG_CPU
int arch_crash_hotplug_cpu_support(void)
int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags)
{
return crash_check_update_elfcorehdr();
}
#endif
#ifdef CONFIG_MEMORY_HOTPLUG
int arch_crash_hotplug_memory_support(void)
{
return crash_check_update_elfcorehdr();
}
#ifdef CONFIG_KEXEC_FILE
if (image->file_mode)
return 1;
#endif
/*
* Initially, crash hotplug support for kexec_load was added
* with the KEXEC_UPDATE_ELFCOREHDR flag. Later, this
* functionality was expanded to accommodate multiple kexec
* segment updates, leading to the introduction of the
* KEXEC_CRASH_HOTPLUG_SUPPORT kexec flag bit. Consequently,
* when the kexec tool sends either of these flags, it indicates
* that the required kexec segment (elfcorehdr) is excluded from
* the SHA calculation.
*/
return (kexec_flags & KEXEC_UPDATE_ELFCOREHDR ||
kexec_flags & KEXEC_CRASH_HOTPLUG_SUPPORT);
}
unsigned int arch_crash_get_elfcorehdr_size(void)
{