[PATCH 1/3] kexec_load: Use new kexec flag for hotplug support
by 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 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.
Given that the KEXEC_UPDATE_ELFCOREHDR is no longer required and was
colliding with the KEXEC_LIVE_UPDATE update flag, it is removed.
Cc: Aditya Gupta <adityag(a)linux.ibm.com>
Cc: Baoquan He <bhe(a)redhat.com>
Cc: Coiby Xu <coxu(a)redhat.com>
Cc: Hari Bathini <hbathini(a)linux.ibm.com>
Cc: Mahesh Salgaonkar <mahesh(a)linux.ibm.com>
Signed-off-by: Sourabh Jain <sourabhjain(a)linux.ibm.com>
---
kexec/arch/arm/kexec-arm.c | 5 +++++
kexec/arch/arm64/kexec-arm64.c | 4 ++++
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 | 5 +++++
kexec/kexec-syscall.h | 2 +-
kexec/kexec.c | 14 ++++++++------
kexec/kexec.h | 2 ++
17 files changed, 79 insertions(+), 7 deletions(-)
diff --git a/kexec/arch/arm/kexec-arm.c b/kexec/arch/arm/kexec-arm.c
index 49f35b1..34531f9 100644
--- a/kexec/arch/arm/kexec-arm.c
+++ b/kexec/arch/arm/kexec-arm.c
@@ -148,3 +148,8 @@ int have_sysfs_fdt(void)
{
return !access(SYSFS_FDT, F_OK);
}
+
+int arch_do_exclude_segment(struct kexec_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
index 4a67b0d..9d052b0 100644
--- a/kexec/arch/arm64/kexec-arm64.c
+++ b/kexec/arch/arm64/kexec-arm64.c
@@ -1363,3 +1363,7 @@ void arch_reuse_initrd(void)
void arch_update_purgatory(struct kexec_info *UNUSED(info))
{
}
+int arch_do_exclude_segment(struct kexec_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/cris/kexec-cris.c b/kexec/arch/cris/kexec-cris.c
index 3b69709..7f09121 100644
--- a/kexec/arch/cris/kexec-cris.c
+++ b/kexec/arch/cris/kexec-cris.c
@@ -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_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/hppa/kexec-hppa.c b/kexec/arch/hppa/kexec-hppa.c
index 77c9739..a64dc3d 100644
--- a/kexec/arch/hppa/kexec-hppa.c
+++ b/kexec/arch/hppa/kexec-hppa.c
@@ -146,3 +146,8 @@ unsigned long virt_to_phys(unsigned long addr)
{
return addr - phys_offset;
}
+
+int arch_do_exclude_segment(struct kexec_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/i386/kexec-x86.c b/kexec/arch/i386/kexec-x86.c
index 444cb69..b4947a0 100644
--- a/kexec/arch/i386/kexec-x86.c
+++ b/kexec/arch/i386/kexec-x86.c
@@ -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_segment *seg_ptr, struct kexec_info *info)
+{
+ if (info->elfcorehdr == (unsigned long) seg_ptr->mem)
+ return 1;
+
+ return 0;
+}
diff --git a/kexec/arch/ia64/kexec-ia64.c b/kexec/arch/ia64/kexec-ia64.c
index 418d997..8d9c1f3 100644
--- a/kexec/arch/ia64/kexec-ia64.c
+++ b/kexec/arch/ia64/kexec-ia64.c
@@ -245,3 +245,7 @@ void arch_update_purgatory(struct kexec_info *UNUSED(info))
{
}
+int arch_do_exclude_segment(struct kexec_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/loongarch/kexec-loongarch.c b/kexec/arch/loongarch/kexec-loongarch.c
index 32a42d2..9a50ff6 100644
--- a/kexec/arch/loongarch/kexec-loongarch.c
+++ b/kexec/arch/loongarch/kexec-loongarch.c
@@ -378,3 +378,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_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/m68k/kexec-m68k.c b/kexec/arch/m68k/kexec-m68k.c
index cb54927..0c7dbaf 100644
--- a/kexec/arch/m68k/kexec-m68k.c
+++ b/kexec/arch/m68k/kexec-m68k.c
@@ -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_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c
index d8cbea8..94224ee 100644
--- a/kexec/arch/mips/kexec-mips.c
+++ b/kexec/arch/mips/kexec-mips.c
@@ -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(const void *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/ppc/kexec-ppc.c b/kexec/arch/ppc/kexec-ppc.c
index 03bec36..c8af870 100644
--- a/kexec/arch/ppc/kexec-ppc.c
+++ b/kexec/arch/ppc/kexec-ppc.c
@@ -966,3 +966,7 @@ void arch_update_purgatory(struct kexec_info *UNUSED(info))
{
}
+int arch_do_exclude_segment(struct kexec_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/ppc64/kexec-ppc64.c b/kexec/arch/ppc64/kexec-ppc64.c
index bd5274c..fb27b6b 100644
--- a/kexec/arch/ppc64/kexec-ppc64.c
+++ b/kexec/arch/ppc64/kexec-ppc64.c
@@ -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_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/s390/kexec-s390.c b/kexec/arch/s390/kexec-s390.c
index 33ba6b9..0561ee7 100644
--- a/kexec/arch/s390/kexec-s390.c
+++ b/kexec/arch/s390/kexec-s390.c
@@ -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_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/sh/kexec-sh.c b/kexec/arch/sh/kexec-sh.c
index ce341c8..f84c40c 100644
--- a/kexec/arch/sh/kexec-sh.c
+++ b/kexec/arch/sh/kexec-sh.c
@@ -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_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/arch/x86_64/kexec-x86_64.c b/kexec/arch/x86_64/kexec-x86_64.c
index ffd84f0..42af90a 100644
--- a/kexec/arch/x86_64/kexec-x86_64.c
+++ b/kexec/arch/x86_64/kexec-x86_64.c
@@ -188,3 +188,8 @@ 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_segment *UNUSED(seg_ptr), struct kexec_info *UNUSED(info))
+{
+ return 0;
+}
diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h
index 73e5254..4675c46 100644
--- a/kexec/kexec-syscall.h
+++ b/kexec/kexec-syscall.h
@@ -112,7 +112,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 */
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 222f79e..034cea6 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -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->segment[i], info)) {
+ dbgprintf("Skipping segment mem: 0x%lx from SHA calculation\n",
+ (unsigned long)info->segment[i].mem);
continue;
}
@@ -1651,7 +1654,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 +1667,8 @@ 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 |= KEXEC_CRASH_HOTPLUG_SUPPORT;
}
fileind = optind;
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 1004aff..2d758c9 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -307,6 +307,8 @@ extern int do_hotplug;
#define BOOTLOADER_VERSION PACKAGE_VERSION
void arch_usage(void);
+/* Return non-zero if segment needs to be excluded from SHA calculation, else 0. */
+int arch_do_exclude_segment(struct kexec_segment *seg_ptr, struct kexec_info *info);
int arch_process_options(int argc, char **argv);
int arch_compat_trampoline(struct kexec_info *info);
void arch_update_purgatory(struct kexec_info *info);
--
2.44.0
6 hours, 13 minutes
Development of Fedora kexec-tools migrating to
github.com/rhkdump/kdump-utils
by Coiby Xu
Hi All,
From now on, you are expected to send your patches by creating a pull
request against https://github.com/rhkdump/kdump-utils instead of to this
mailing list. And if you want to receive patches or discussions, you can
welcome to click the "Watch" button on the GitHub project homepage.
As some of you have noticed, we are splitting Fedora kexec-tools into
three packages kdump-utils, kexec-tools and makedumpfile [1] and we were
asked to establish an upstream repo for kdump-utils. Since this mailing
list has been mostly used for developments of kdump-utils, the name of
the mailing list (kexec) no loner makes sense.
More importantly, we'd like to take this opportunity to switch to a git
forge based workflow in order to have the following benefits,
1. Automate testing and releasing i.e. continuous integration (CI) and
continuous delivery (CD).
- We are going to enable unit tests and integration tests so whenever
you create a PR or make some changes to that PR, they will be
triggered automatically. In this way, we can prevent/catch problems
early by testing as early and as often as possible. This will also
make your development experience more enjoyable as fast feedback is
provided by the results of the automated tests.
- We also plan to automate releasing the Fedora packages.
2. Make it easier to collocate with other contributors as many projects
related to our project including those which we depend on or which
depend on our project have already used GitHub.
3. Make it easy to track patches. In the past, we occasionally lost
track of some patches sent to the mailing list. With the help of
GitHub, this issue can be prevented.
FAQ
###
1. What about https://src.fedoraproject.org/rpms/kexec-tools.git?
This repo and future rpms/kdump-utils.git will be merely for work
related to packaging.
2. How can I view the patches locally maybe for code review?
There are two ways. The first is to fetch pull/ID/head,
```
git fetch origin pull/ID/head:BRANCH_NAME
git switch BRANCH_NAME
```
Or you download the patches and apply them manually,
```
wget https://github.com/rhkdump/kdump-utils/pull/ID.patch
git am ID.patch
```
3. What if I want to add an in-line comment on the commit message?
Unfortunately, GitHub code review currently misses this feature [3].
We think this is an important feature and have left a comment [3].
And you are also welcome to leave an comment on [3] to let GitHub
hear your voice.
[1] https://src.fedoraproject.org/rpms/kexec-tools/pull-request/17
[2] https://docs.github.com/en/pull-requests/collaborating-with-pull-requests...
[3] https://github.com/orgs/community/discussions/56449
--
Best regards,
Coiby
1 week, 1 day
Re: [PATCH] mkdumprd:Fix makedumpfile parameter check.
by Coiby Xu
On Wed, Apr 24, 2024 at 08:11:12AM GMT, Mamoru Nishibe (Fujitsu) wrote:
>If only "makedumpfile" is written in "core_collector" of /etc/kdump.conf
>and try to run makedumpfile without options,
>"makedumpfile --check-params" fails and terminates abnormally.
>
> # grep ^core_collector /etc/kdump.conf
> core_collector makedumpfile
> # /usr/bin/kdumpctl start
> :
> Commandline parameter is invalid.
> Try `makedumpfile --help' for more information.
> kdump: makedumpfile parameter check failed.
> kdump: mkdumprd: failed to make kdump initrd
> kdump: Starting kdump: [FAILED]
>
>On the other hand, "makedumpfile --check-params" works fine without any options.
>
> # makedumpfile --check-params vmcore dumpfile
> # echo $?
> 0
>
>In addition, before verify_core_collector() was implemented,
>initial RAM for kdump was successfully created using only "core_collector makedumpfile".
>I consider it a regression.
>
>This is due to a parameter extraction error in verify_core_collector().
>Fix it to correctly extract only the options as follows.
>
>Signed-off-by: Mamoru Nishibe <nishibe.mamoru(a)fujitsu.com>
The patch has been applied with a Fixes tag added,
Fixes: a1c28126 ("mkdumprd: Use makedumpfile --check-params option")
thank you!
>
>---
> mkdumprd | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/mkdumprd b/mkdumprd
>index 31c4b76..27eed5e 100644
>--- a/mkdumprd
>+++ b/mkdumprd
>@@ -256,7 +256,7 @@ check_user_configured_target()
> verify_core_collector()
> {
> local _cmd="${1%% *}"
>- local _params="${1#* }"
>+ local _params="${1#${_cmd}}"
>
> if [[ $_cmd != "makedumpfile" ]]; then
> if is_raw_dump_target; then
>--
>_______________________________________________
>kexec mailing list -- kexec(a)lists.fedoraproject.org
>To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
>Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
>List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
>List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
>Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
--
Best regards,
Coiby
1 week, 5 days