Enable crash hotplug support on powerpc
Subsystems (2)
v3 cover Enable crash hotplug support on powerpc
The primary goal of this patch series is to enable crash hotplug on powerpc architecture for the kexec_load system call.
The first patch in the series introduces a new kexec flag added in the kernel to generalize crash hotplug support. The second patch enables crash hotplug support on PowerPC for kexec_load system call. The third patch updates the documentation about crash hotplug support.
Changes log:
v4:
- Do not remove the KEXEC_UPDATE_ELFCOREHDR kexec flag. It is needed to maintain backward compatibility on x86. 1/3
- Send the KEXEC_UPDATE_ELFCOREHDR kexec flag for x86, and for the rest of the architectures, send KEXEC_CRASH_HOTPLUG_SUPPORT to enable crash hotplug support kexec_load system call. 1/3
- Since there is a significant change in 1/3, hence Hari's Acked-by is removed form only first patch. 1/3
- Rename and reorder the function arch_do_exclude_segment() parameters as suggested. 1/3
- Keep the implementation of arch_do_exclude_segment() function same
for x86_64 and i386. 1/3
v3:
https://lists.infradead.org/pipermail/kexec/2024-July/030361.html
- Updated --hotplug option description 3/3
v2:
https://lists.infradead.org/pipermail/kexec/2024-June/030309.html
- Find CPUs in the system using the /sys/devices/system/cpu/present sysfs instead of traversing all nodes under /proc/device-tree/cpus. 2/3
- Added a new function to find present CPUs in the system. 2/3
- Removed unnecessary NULL check on seg_ptr from arch_do_exclude_segment(). 2/3
- Updated --hotplug option description 3/3
v1:
https://lists.infradead.org/pipermail/kexec/2024-May/030051.html
Sourabh Jain (3):
kexec_load: Use new kexec flag for hotplug support powerpc/kexec_load: add hotplug support doc/hotplug: update man and --help
kexec/arch/arm/kexec-arm.c | 5 + kexec/arch/arm64/kexec-arm64.c | 5 + kexec/arch/cris/kexec-cris.c | 4 + kexec/arch/hppa/kexec-hppa.c | 5 + kexec/arch/i386/kexec-x86.c | 8 + kexec/arch/ia64/kexec-ia64.c | 4 + kexec/arch/loongarch/kexec-loongarch.c | 5 + kexec/arch/m68k/kexec-m68k.c | 5 + kexec/arch/mips/kexec-mips.c | 4 + kexec/arch/ppc/kexec-ppc.c | 4 + kexec/arch/ppc64/crashdump-ppc64.c | 16 +- kexec/arch/ppc64/fdt.c | 236 ++++++++++++++++++++++++- kexec/arch/ppc64/include/arch/fdt.h | 2 +- kexec/arch/ppc64/kexec-elf-ppc64.c | 2 +- kexec/arch/ppc64/kexec-ppc64.c | 12 ++ kexec/arch/s390/kexec-s390.c | 5 + kexec/arch/sh/kexec-sh.c | 5 + kexec/arch/x86_64/kexec-x86_64.c | 8 + kexec/kexec-syscall.h | 1 + kexec/kexec.8 | 8 +- kexec/kexec.c | 44 ++++- kexec/kexec.h | 2 + 22 files changed, 373 insertions(+), 17 deletions(-)
Signature · 7 lines
2.45.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v3 1/3 kexec_load: Use new kexec flag for hotplug support
Kernel commit 79365026f869 (crash: add a new kexec flag for hotplug support) has introduced a new kexec flag to generalize hotplug support. The newly introduced kexec flags for hotplug allow architectures to exclude all the required kexec segments from SHA calculation so that the kernel can update them on hotplug events. This was not possible earlier with the KEXEC_UPDATE_ELFCOREHDR kexec flags since it was added only for the elfcorehdr segment.
To enable architectures to control the list of kexec segments to exclude when hotplug support is enabled, add a new architecture-specific function named arch_do_exclude_segment. During the SHA calculation, this function gets called to let the architecture decide whether a specific kexec segment should be considered for SHA calculation or not.
Note: To avoid breaking backward compatibility, the new kexec flag KEXEC_CRASH_HOTPLUG_SUPPORT is not used for x86 for now.
--- kexec/arch/arm/kexec-arm.c | 5 ++++ kexec/arch/arm64/kexec-arm64.c | 5 ++++ kexec/arch/cris/kexec-cris.c | 4 +++ kexec/arch/hppa/kexec-hppa.c | 5 ++++ kexec/arch/i386/kexec-x86.c | 8 ++++++ kexec/arch/ia64/kexec-ia64.c | 4 +++ kexec/arch/loongarch/kexec-loongarch.c | 5 ++++ kexec/arch/m68k/kexec-m68k.c | 5 ++++ kexec/arch/mips/kexec-mips.c | 4 +++ kexec/arch/ppc/kexec-ppc.c | 4 +++ kexec/arch/ppc64/kexec-ppc64.c | 5 ++++ kexec/arch/s390/kexec-s390.c | 5 ++++ kexec/arch/sh/kexec-sh.c | 5 ++++ kexec/arch/x86_64/kexec-x86_64.c | 8 ++++++ kexec/kexec-syscall.h | 1 + kexec/kexec.c | 40 ++++++++++++++++++++++---- kexec/kexec.h | 2 ++ 17 files changed, 109 insertions(+), 6 deletions(-)
kexec/arch/arm/kexec-arm.c +5 -0
@@ -148,3 +148,8 @@ int have_sysfs_fdt(void) {return !access (SYSFS_FDT ,F_OK ); } + +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/arm64/kexec-arm64.c +5 -0
@@ -1363,3 +1363,8 @@ void arch_reuse_initrd(void)void arch_update_purgatory (struct kexec_info *UNUSED (info )) { } + +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/cris/kexec-cris.c +4 -0
@@ -109,3 +109,7 @@ unsigned long add_buffer(struct kexec_info *info, const void *buf, buf_min, buf_max, buf_end, 1); } +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/hppa/kexec-hppa.c +5 -0
@@ -146,3 +146,8 @@ unsigned long virt_to_phys(unsigned long addr) {return addr - phys_offset; } + +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/i386/kexec-x86.c +8 -0
@@ -208,3 +208,11 @@ void arch_update_purgatory(struct kexec_info *info)elf_rel_set_symbol (&info->rhdr,"panic_kernel" , &panic_kernel,sizeof (panic_kernel)); } + +int arch_do_exclude_segment (struct kexec_info *info,struct kexec_segment *segment) +{ +if (info->elfcorehdr == (unsigned long ) segment->mem) +return 1 ; + +return 0 ; +}
kexec/arch/ia64/kexec-ia64.c +4 -0
@@ -245,3 +245,7 @@ void arch_update_purgatory(struct kexec_info *UNUSED(info)) { } +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/loongarch/kexec-loongarch.c +5 -0
@@ -381,3 +381,8 @@ unsigned long add_buffer(struct kexec_info *info, const void *buf,return add_buffer_phys_virt (info, buf, bufsz, memsz, buf_align, buf_min, buf_max, buf_end,1 ); } + +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/m68k/kexec-m68k.c +5 -0
@@ -108,3 +108,8 @@ void add_segment(struct kexec_info *info, const void *buf, size_t bufsz, {add_segment_phys_virt (info, buf, bufsz, base, memsz,1 ); } + +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/mips/kexec-mips.c +4 -0
@@ -189,3 +189,7 @@ unsigned long add_buffer(struct kexec_info *info, const void *buf, buf_min, buf_max, buf_end, 1); } +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/ppc/kexec-ppc.c +4 -0
@@ -966,3 +966,7 @@ void arch_update_purgatory(struct kexec_info *UNUSED(info)) { } +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/ppc64/kexec-ppc64.c +5 -0
@@ -967,3 +967,8 @@ int arch_compat_trampoline(struct kexec_info *UNUSED(info))void arch_update_purgatory (struct kexec_info *UNUSED (info )) { } + +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/s390/kexec-s390.c +5 -0
@@ -267,3 +267,8 @@ int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) {return parse_iomem_single ("Crash kernel\n" , start, end); } + +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/sh/kexec-sh.c +5 -0
@@ -257,3 +257,8 @@ unsigned long add_buffer(struct kexec_info *info, const void *buf,return add_buffer_phys_virt (info, buf, bufsz, memsz, buf_align, buf_min, buf_max, buf_end,1 ); } + +int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +{ +return 0 ; +}
kexec/arch/x86_64/kexec-x86_64.c +8 -0
@@ -188,3 +188,11 @@ void arch_update_purgatory(struct kexec_info *info)elf_rel_set_symbol (&info->rhdr,"panic_kernel" , &panic_kernel,sizeof (panic_kernel)); } + +int arch_do_exclude_segment (struct kexec_info *info,struct kexec_segment *segment) +{ +if (info->elfcorehdr == (unsigned long ) segment->mem) +return 1 ; + +return 0 ; +}
kexec/kexec-syscall.h +1 -0
@@ -113,6 +113,7 @@ static inline long kexec_file_load(int kernel_fd, int initrd_fd,#define KEXEC_ON_CRASH 0x00000001#define KEXEC_PRESERVE_CONTEXT 0x00000002#define KEXEC_UPDATE_ELFCOREHDR 0x00000004 +#define KEXEC_CRASH_HOTPLUG_SUPPORT 0x00000008#define KEXEC_ARCH_MASK 0xffff0000/* Flags for kexec file based system call */
kexec/kexec.c +34 -6
@@ -701,10 +701,13 @@ static void update_purgatory(struct kexec_info *info)continue ; } -/* Don't include elfcorehdr in the checksum, if hotplug -* support enabled. +/* +* Let architecture decide which segments to exclude from checksum +* if hotplug support is enabled. */ -if (do_hotplug && (info->segment[i].mem == (void *)info->elfcorehdr)) { +if (do_hotplug &&arch_do_exclude_segment (info, &info->segment[i])) { +dbgprintf ("Skipping segment mem: 0x%lx from SHA calculation\n" , + (unsigned long )info->segment[i].mem);continue ; }
@@ -1419,6 +1422,30 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,return ret; } +/* +* Hotplug support for x86 in the kernel was added with the +* `KEXEC_UPDATE_ELFCOREHDR` kexec bit, and later it was generalized +* with the `KEXEC_CRASH_HOTPLUG_SUPPORT` kexec bit. +* +* Passing the `KEXEC_CRASH_HOTPLUG_SUPPORT` kexec bit to kernel +* versions 6.5 to 6.9 on x86 with the `kexec_load` system call will +* fail with `-EINVAL`. +* +* So for now, pass `KEXEC_UPDATE_ELFCOREHDR` for x86, and for other +* architectures, use the `KEXEC_CRASH_HOTPLUG_SUPPORT` kexec bit. But +* in the future, we can decide to get rid of `KEXEC_UPDATE_ELFCOREHDR`. +* +* NOTE: Xen KEXEC_LIVE_UPDATE and KEXEC_UPDATE_ELFCOREHDR collide +*/ +static inline unsigned long get_hotplug_kexec_flag (void ) +{ +#if defined(__i386__) || defined(__x86_64__) +return KEXEC_UPDATE_ELFCOREHDR ; +#else +return KEXEC_CRASH_HOTPLUG_SUPPORT ; +#endif +} +static void print_crashkernel_region_size (void ) {uint64_t start =0 , end =0 ;
@@ -1651,7 +1678,6 @@ int main(int argc, char *argv[])die ("--load-live-update can only be used with xen\n" ); } -/* NOTE: Xen KEXEC_LIVE_UPDATE and KEXEC_UPDATE_ELFCOREHDR collide */ if (do_hotplug) {const char *ces ="/sys/kernel/crash_elfcorehdr_size" ;char *buf, *endptr =NULL ;
@@ -1665,8 +1691,10 @@ int main(int argc, char *argv[])if (!elfcorehdrsz || (endptr && *endptr !='\0' ))die ("Path %s does not exist, the kernel needs CONFIG_CRASH_HOTPLUG\n" , ces);dbgprintf ("ELFCOREHDR_SIZE %lu\n" , elfcorehdrsz); -/* Indicate to the kernel it is ok to modify the elfcorehdr */ - kexec_flags |=KEXEC_UPDATE_ELFCOREHDR ; +/* Indicate to the kernel it is ok to modify the relevant kexec segments */ + + kexec_flags |=get_hotplug_kexec_flag (); + } fileind = optind;
kexec/kexec.h +2 -0
@@ -307,6 +307,8 @@ extern int do_hotplug;#define BOOTLOADER_VERSION PACKAGE_VERSIONvoid arch_usage (void ); +/* Return non-zero if segment needs to be excluded from SHA calculation, else 0. */ +int arch_do_exclude_segment (struct kexec_info *info,struct kexec_segment *segment);int arch_process_options (int argc,char **argv);int arch_compat_trampoline (struct kexec_info *info);void arch_update_purgatory (struct kexec_info *info);
Signature · 7 lines
2.45.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v3 1/3] kexec_load: Use new kexec flag for hotplug support
Hi Sourabh,
Quoted 8 lines · Sourabh Jain
Kernel commit
79365026f869(crash: add a new kexec flag for hotplug support) has introduced a new kexec flag to generalize hotplug support. The newly introduced kexec flags for hotplug allow architectures to exclude all the required kexec segments from SHA calculation so that the kernel can update them on hotplug events. This was not possible earlier with theKEXEC_UPDATE_ELFCOREHDRkexec flags since it was added only for the elfcorehdr segment.
Quoted 8 lines
To enable architectures to control the list of kexec segments to exclude when hotplug support is enabled, add a new architecture-specific function named
arch_do_exclude_segment. During the SHA calculation, this function gets called to let the architecture decide whether a specific kexec segment should be considered for SHA calculation or not.Note: To avoid breaking backward compatibility, the new kexec flag
KEXEC_CRASH_HOTPLUG_SUPPORTis not used for x86 for now.
For x86, both KEXEC_UPDATE_ELFCOREHDR and KEXEC_CRASH_HOTPLUG_SUPPORT should be OK for kexec_file_load. Your change will make a difference between kexec_load and kexec_file_load. But I agree with you on the backward cmpatibility with KEXEC_CRASH_HOTPLUG_SUPPORT flag.
Anyway, if it's in a hurry to catch up with Simon's new release, this is fine, we can change it later. Otherwise, we may be better to remove the difference, namely, not making x86 only be able to accept KEXEC_UPDATE_ELFCOREHDR flag on kexec_load. My personal opinion.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v3 1/3] kexec_load: Use new kexec flag for hotplug support
Hello Baoquan,
Quoted 17 lines · Baoquan He
Hi Sourabh,
Quoted 14 lines · Sourabh Jain
Kernel commit
79365026f869(crash: add a new kexec flag for hotplug support) has introduced a new kexec flag to generalize hotplug support. The newly introduced kexec flags for hotplug allow architectures to exclude all the required kexec segments from SHA calculation so that the kernel can update them on hotplug events. This was not possible earlier with theKEXEC_UPDATE_ELFCOREHDRkexec flags since it was added only for the elfcorehdr segment.To enable architectures to control the list of kexec segments to exclude when hotplug support is enabled, add a new architecture-specific function named
arch_do_exclude_segment. During the SHA calculation, this function gets called to let the architecture decide whether a specific kexec segment should be considered for SHA calculation or not.
Quoted 4 lines
Quoted 2 lines
Note: To avoid breaking backward compatibility, the new kexec flag
KEXEC_CRASH_HOTPLUG_SUPPORTis not used for x86 for now.For x86, both
KEXEC_UPDATE_ELFCOREHDRandKEXEC_CRASH_HOTPLUG_SUPPORTshould be OK forkexec_file_load.
Do we even need these flags for kexec_file_load at all?
My understanding is that these flags are only needed for the kexec_load system call.
Quoted 2 lines
Your change will make a difference
betweenkexec_loadandkexec_file_load.
I am confused by the above statement.
Given that we don't even send any of the above flags for kexec_file_load, I am not sure how these changes make a difference between the two system calls.
Quoted 5 lines
But I agree with you on the
backward cmpatibility withKEXEC_CRASH_HOTPLUG_SUPPORTflag.Anyway, if it's in a hurry to catch up with Simon's new release, this is fine, we can change it later.
It would be great if we could consider this patch series for the next release, but not at the cost of breaking any backward compatibility for x86. If you think these changes are breaking anything for any kernel version, I would prefer to update my patch series.
Quoted 3 lines
Otherwise, we may be better to remove the
difference, namely, not making x86 only be able to acceptKEXEC_UPDATE_ELFCOREHDRflag onkexec_load. My personal opinion
On x86, passing the KEXEC_CRASH_HOTPLUG_SUPPORT kexec bit to kernel versions 6.5 to 6.9 with the kexec_load system call will fail with -EINVAL. However, from kernel 6.10 onward, both KEXEC_UPDATE_ELFCOREHDR and KEXEC_CRASH_HOTPLUG_SUPPORT kexec bits are acceptable for x86.
My proposal is to use KEXEC_UPDATE_ELFCOREHDR on x86 for some time (maybe a couple of kernel releases), and eventually switch to KEXEC_CRASH_HOTPLUG_SUPPORT for x86 as well.
This proposal of shifting to the KEXEC_CRASH_HOTPLUG_SUPPORT kexec bit for x86 is also mentioned in the comment for the get_hotplug_kexec_flag function.
Please let me know your opinion.
Thanks,
Sourabh Jain
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v3 1/3] kexec_load: Use new kexec flag for hotplug support
Quoted 20 lines · Sourabh Jain
Hello Baoquan,
Quoted 17 lines · Baoquan He
Hi Sourabh,
Quoted 14 lines · Sourabh Jain
Kernel commit
79365026f869(crash: add a new kexec flag for hotplug support) has introduced a new kexec flag to generalize hotplug support. The newly introduced kexec flags for hotplug allow architectures to exclude all the required kexec segments from SHA calculation so that the kernel can update them on hotplug events. This was not possible earlier with theKEXEC_UPDATE_ELFCOREHDRkexec flags since it was added only for the elfcorehdr segment.To enable architectures to control the list of kexec segments to exclude when hotplug support is enabled, add a new architecture-specific function named
arch_do_exclude_segment. During the SHA calculation, this function gets called to let the architecture decide whether a specific kexec segment should be considered for SHA calculation or not.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Note: To avoid breaking backward compatibility, the new kexec flag
KEXEC_CRASH_HOTPLUG_SUPPORTis not used for x86 for now.For x86, both
KEXEC_UPDATE_ELFCOREHDRandKEXEC_CRASH_HOTPLUG_SUPPORTshould be OK forkexec_file_load.Do we even need these flags for
kexec_file_loadat all?
My understanding is that these flags are only needed for thekexec_loadsystem call.
Oh, sorry, my bad, I must have mixed this with KEXEC_FILE_DEBUG I earlier added when I checked this patchset. I think everything is like what you said.
Quoted 39 lines
Quoted 4 lines
Your change will make a difference
betweenkexec_loadandkexec_file_load.I am confused by the above statement.
Given that we don't even send any of the above flags for
kexec_file_load, I am not
sure how these changes make a difference between the two system calls.Quoted 5 lines
But I agree with you on the
backward cmpatibility withKEXEC_CRASH_HOTPLUG_SUPPORTflag.Anyway, if it's in a hurry to catch up with Simon's new release, this is fine, we can change it later.
It would be great if we could consider this patch series for the next release, but not at
the cost of breaking any backward compatibility for x86. If you think these changes are
breaking anything for any kernel version, I would prefer to update my patch series.Quoted 3 lines
Otherwise, we may be better to remove the
difference, namely, not making x86 only be able to acceptKEXEC_UPDATE_ELFCOREHDRflag onkexec_load. My personal opinionOn x86, passing the
KEXEC_CRASH_HOTPLUG_SUPPORTkexec bit to kernel versions 6.5 to 6.9
with thekexec_loadsystem call will fail with-EINVAL. However, from kernel 6.10 onward,
bothKEXEC_UPDATE_ELFCOREHDRandKEXEC_CRASH_HOTPLUG_SUPPORTkexec bits are acceptable for x86.My proposal is to use
KEXEC_UPDATE_ELFCOREHDRon x86 for some time (maybe a couple of kernel releases),
and eventually switch toKEXEC_CRASH_HOTPLUG_SUPPORTfor x86 as well.
Quoted 5 lines
This proposal of shifting to the
KEXEC_CRASH_HOTPLUG_SUPPORTkexec bit for x86 is also mentioned in the
comment for theget_hotplug_kexec_flagfunction.Please let me know your opinion.
It sounds like a good plan, thanks for the effort.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v3 1/3] kexec_load: Use new kexec flag for hotplug support
In reply to Sourabh JainQuoted 35 lines · Sourabh Jain
Kernel commit
79365026f869(crash: add a new kexec flag for hotplug support) has introduced a new kexec flag to generalize hotplug support. The newly introduced kexec flags for hotplug allow architectures to exclude all the required kexec segments from SHA calculation so that the kernel can update them on hotplug events. This was not possible earlier with theKEXEC_UPDATE_ELFCOREHDRkexec flags since it was added only for the elfcorehdr segment.To enable architectures to control the list of kexec segments to exclude when hotplug support is enabled, add a new architecture-specific function named
arch_do_exclude_segment. During the SHA calculation, this function gets called to let the architecture decide whether a specific kexec segment should be considered for SHA calculation or not.Note: To avoid breaking backward compatibility, the new kexec flag
KEXEC_CRASH_HOTPLUG_SUPPORTis not used for x86 for now.Cc Aditya Gupta <[email protected]>Cc Baoquan He <[email protected]>Cc Coiby Xu <[email protected]>Cc Hari Bathini <[email protected]>Cc Mahesh Salgaonkar <[email protected]>Cc Simon Horman <[email protected]>Signed-off-by Sourabh Jain <[email protected]>--- kexec/arch/arm/kexec-arm.c | 5 ++++ kexec/arch/arm64/kexec-arm64.c | 5 ++++ kexec/arch/cris/kexec-cris.c | 4 +++ kexec/arch/hppa/kexec-hppa.c | 5 ++++ kexec/arch/i386/kexec-x86.c | 8 ++++++ kexec/arch/ia64/kexec-ia64.c | 4 +++ kexec/arch/loongarch/kexec-loongarch.c | 5 ++++ kexec/arch/m68k/kexec-m68k.c | 5 ++++ kexec/arch/mips/kexec-mips.c | 4 +++ kexec/arch/ppc/kexec-ppc.c | 4 +++
Quoted 8 lines
kexec/arch/ppc64/kexec-ppc64.c | 5 ++++ kexec/arch/s390/kexec-s390.c | 5 ++++ kexec/arch/sh/kexec-sh.c | 5 ++++ kexec/arch/x86_64/kexec-x86_64.c | 8 ++++++ kexec/kexec-syscall.h | 1 + kexec/kexec.c | 40 ++++++++++++++++++++++---- kexec/kexec.h | 2 ++ 17 files changed, 109 insertions(+), 6 deletions(-)
LGTM,
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v3 1/3] kexec_load: Use new kexec flag for hotplug support
Hello Baoquan,
Quoted 44 lines · Baoquan He
Quoted 35 lines · Sourabh Jain
Kernel commit
79365026f869(crash: add a new kexec flag for hotplug support) has introduced a new kexec flag to generalize hotplug support. The newly introduced kexec flags for hotplug allow architectures to exclude all the required kexec segments from SHA calculation so that the kernel can update them on hotplug events. This was not possible earlier with theKEXEC_UPDATE_ELFCOREHDRkexec flags since it was added only for the elfcorehdr segment.To enable architectures to control the list of kexec segments to exclude when hotplug support is enabled, add a new architecture-specific function named
arch_do_exclude_segment. During the SHA calculation, this function gets called to let the architecture decide whether a specific kexec segment should be considered for SHA calculation or not.Note: To avoid breaking backward compatibility, the new kexec flag
KEXEC_CRASH_HOTPLUG_SUPPORTis not used for x86 for now.Cc Aditya Gupta <[email protected]>Cc Baoquan He <[email protected]>Cc Coiby Xu <[email protected]>Cc Hari Bathini <[email protected]>Cc Mahesh Salgaonkar <[email protected]>Cc Simon Horman <[email protected]>Signed-off-by Sourabh Jain <[email protected]>--- kexec/arch/arm/kexec-arm.c | 5 ++++ kexec/arch/arm64/kexec-arm64.c | 5 ++++ kexec/arch/cris/kexec-cris.c | 4 +++ kexec/arch/hppa/kexec-hppa.c | 5 ++++ kexec/arch/i386/kexec-x86.c | 8 ++++++ kexec/arch/ia64/kexec-ia64.c | 4 +++ kexec/arch/loongarch/kexec-loongarch.c | 5 ++++ kexec/arch/m68k/kexec-m68k.c | 5 ++++ kexec/arch/mips/kexec-mips.c | 4 +++ kexec/arch/ppc/kexec-ppc.c | 4 +++Quoted 8 lines
kexec/arch/ppc64/kexec-ppc64.c | 5 ++++ kexec/arch/s390/kexec-s390.c | 5 ++++ kexec/arch/sh/kexec-sh.c | 5 ++++ kexec/arch/x86_64/kexec-x86_64.c | 8 ++++++ kexec/kexec-syscall.h | 1 + kexec/kexec.c | 40 ++++++++++++++++++++++---- kexec/kexec.h | 2 ++ 17 files changed, 109 insertions(+), 6 deletions(-)
Quoted 3 lines
LGTM,
Acked-by Baoquan He <[email protected]>
Thank you for the Ack.
- Sourabh Jain
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v3 2/3 powerpc/kexec_load: add hotplug support
In reply to Sourabh JainKernel commits b741092d5976 ("powerpc/crash: add crash CPU hotplug support") and 849599b702ef ("powerpc/crash: add crash memory hotplug support") added crash CPU/Memory hotplug support on PowerPC. This patch extends that support for the kexec_load syscall.
During CPU/Memory hotplug events on PowerPC, two kexec segments, elfcorehdr, and FDT, get updated by the kernel. To ensure the kernel can safely update these two kexec segments for the kdump image loaded using the kexec_load system call, the following changes are made:
1. Extra size is allocated for both elfcorehdr and FDT to accommodate additional resources in the future. For the elfcorehdr, the size hint is taken from /sys/kernel/crash_elfcorehdr_size sysfs, while for FDT, extra size is allocated to hold possible CPU nodes.
2. Both elfcorehdr and FDT are skipped from SHA calculation.
--- kexec/arch/ppc64/crashdump-ppc64.c | 16 +- kexec/arch/ppc64/fdt.c | 236 +++++++++++++++++++++++++++- kexec/arch/ppc64/include/arch/fdt.h | 2 +- kexec/arch/ppc64/kexec-elf-ppc64.c | 2 +- kexec/arch/ppc64/kexec-ppc64.c | 9 +- 5 files changed, 258 insertions(+), 7 deletions(-)
kexec/arch/ppc64/crashdump-ppc64.c +13 -3
@@ -476,7 +476,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, uint64_t max_addr, unsigned long min_base) { void *tmp; -unsigned long sz; +unsigned long sz, memsz;uint64_t elfcorehdr;int nr_ranges, align =1024 , i;unsigned long long end;
@@ -531,8 +531,18 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, } } - elfcorehdr =add_buffer (info, tmp, sz, sz, align, min_base, - max_addr,1 ); + memsz = sz; +/* To support --hotplug, replace the calculated memsz with the value +* from /sys/kernel/crash_elfcorehdr_size and align it correctly. +*/ +if (do_hotplug) { +if (elfcorehdrsz > sz) + memsz =_ALIGN (elfcorehdrsz, align); + } + +/* Record the location of the elfcorehdr for hotplug handling */ + info->elfcorehdr = elfcorehdr =add_buffer (info, tmp, sz, memsz, align, + min_base, max_addr,1 );reserve (elfcorehdr, sz);/* modify and store the cmdline in a global array. This is later * read by flatten_device_tree and modified if required
kexec/arch/ppc64/fdt.c +235 -1
258 lines not on this page · raw message
kexec/arch/ppc64/include/arch/fdt.h +1 -1
@@ -3,6 +3,6 @@#include <sys/types.h> -int fixup_dt (char **fdt,off_t *size); +int fixup_dt (char **fdt,off_t *size,unsigned long kexec_flags);#endif
kexec/arch/ppc64/kexec-elf-ppc64.c +1 -1
@@ -345,7 +345,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,create_flatten_tree (&seg_buf, &seg_size, cmdline); } - result =fixup_dt (&seg_buf, &seg_size); + result =fixup_dt (&seg_buf, &seg_size, info->kexec_flags);if (result <0 )return result;
kexec/arch/ppc64/kexec-ppc64.c +8 -1
@@ -24,6 +24,7 @@#include <errno.h> #include <stdint.h> #include <string.h> +#include <libfdt.h> #include <sys/stat.h> #include <sys/types.h> #include <dirent.h>
@@ -968,7 +969,13 @@ void arch_update_purgatory(struct kexec_info *UNUSED(info)) { } -int arch_do_exclude_segment (struct kexec_info *UNUSED (info ),struct kexec_segment *UNUSED (segment )) +int arch_do_exclude_segment (struct kexec_info *info,struct kexec_segment *segment) { +if (info->elfcorehdr == (unsigned long ) segment->mem) +return 1 ; + +if (segment->buf &&fdt_magic (segment->buf) ==FDT_MAGIC ) +return 1 ; +return 0 ; }
Signature · 7 lines
2.45.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v3 3/3 doc/hotplug: update man and --help
In reply to Sourabh JainUpdate the man page and --help option to make the description of the --hotplug option easier to understand.
--- kexec/kexec.8 | 8 ++++---- kexec/kexec.c | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-)
kexec/kexec.8 +4 -4
@@ -140,10 +140,10 @@ Open a help file for .BR kexec . .TP .B \-\-hotplug -Setup for kernel modification of the elfcorehdr. This option performs -the steps needed to support kernel updates to the elfcorehdr in the -presence of hot un/plug and/or on/offline events. This option only -useful for KEXEC_LOAD syscall. +Setup kexec segments such that kernel can safely update them on CPU/Memory +hot add/remove events. If this option is enabled, kernel does in-kernel +update of kexec segments on CPU/Memory hot add/remove events, thus avoiding +the need to reload kdump kernel. .TP .B \-i\ (\-\-no-checks) Fast reboot, no memory integrity checks.
kexec/kexec.c +3 -1
@@ -1093,7 +1093,9 @@ void usage(void)" back to the compatibility syscall when file based\n" " syscall is not supported or the kernel did not\n" " understand the image (default)\n" -" --hotplug Setup for kernel modification of elfcorehdr.\n" +" --hotplug Do in-kernel update of kexec segments on CPU/Memory\n" +" hot add/remove events, avoiding the need to reload\n" +" kdump kernel on online/offline events.\n" " -d, --debug Enable debugging to help spot a failure.\n" " -S, --status Return 1 if the type (by default crash) is loaded,\n" " 0 if not.\n"
Signature · 7 lines
2.45.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 35 lines · Sourabh Jain
The primary goal of this patch series is to enable crash hotplug on powerpc architecture for the
kexec_loadsystem call.The first patch in the series introduces a new kexec flag added in the kernel to generalize crash hotplug support. The second patch enables crash hotplug support on PowerPC for
kexec_loadsystem call. The third patch updates the documentation about crash hotplug support.Changes log:
v4:
- Do not remove theKEXEC_UPDATE_ELFCOREHDRkexec flag. It is needed to maintain backward compatibility on x86. 1/3
- Send theKEXEC_UPDATE_ELFCOREHDRkexec flag for x86, and for the rest of the architectures, sendKEXEC_CRASH_HOTPLUG_SUPPORTto enable crash hotplug supportkexec_loadsystem call. 1/3
- Since there is a significant change in 1/3, hence Hari's Acked-by is removed form only first patch. 1/3
- Rename and reorder the functionarch_do_exclude_segment()parameters as suggested. 1/3
- Keep the implementation ofarch_do_exclude_segment()function samefor x86_64 and i386. 1/3v3:
https://lists.infradead.org/pipermail/kexec/2024-July/030361.html
- Updated --hotplug option description 3/3v2:
https://lists.infradead.org/pipermail/kexec/2024-June/030309.html
- Find CPUs in the system using the/sys/devices/system/cpu/presentsysfs instead of traversing all nodes under/proc/device-tree/cpus. 2/3
- Added a new function to find present CPUs in the system. 2/3
- Removed unnecessary NULL check onseg_ptrfromarch_do_exclude_segment(). 2/3
- Updated --hotplug option description 3/3
Quoted 2 lines
v1:
https://lists.infradead.org/pipermail/kexec/2024-May/030051.html
Thanks Sourabh,
Series applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec