From 3c0feb10d25d6da4d97c929c8e23582cd2d13c2e2e9f0fab0f2cc4be5d6959dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Tue, 15 Apr 2025 20:10:40 +0200 Subject: [PATCH] Sync from SUSE:SLFO:1.1 kexec-tools revision 50db5a46eaadf5ecb7b573355aa00474 --- ...b008fde783fd0cc2cc266bd1c9cf35e99a0e.patch | 112 ++++++++++++++++++ kexec-dont-use-kexec_file_load-on-xen.patch | 59 +++++++++ kexec-tools-2.0.27.tar.sign | Bin 0 -> 566 bytes kexec-tools-2.0.27.tar.xz | 3 + kexec-tools-2.0.30.tar.sign | Bin 566 -> 0 bytes kexec-tools-2.0.30.tar.xz | 3 - kexec-tools-disable-test.patch | 10 +- kexec-tools-riscv-hotplug.patch | 23 ---- kexec-tools.changes | 70 +---------- kexec-tools.spec | 18 ++- 10 files changed, 186 insertions(+), 112 deletions(-) create mode 100644 6419b008fde783fd0cc2cc266bd1c9cf35e99a0e.patch create mode 100644 kexec-dont-use-kexec_file_load-on-xen.patch create mode 100644 kexec-tools-2.0.27.tar.sign create mode 100644 kexec-tools-2.0.27.tar.xz delete mode 100644 kexec-tools-2.0.30.tar.sign delete mode 100644 kexec-tools-2.0.30.tar.xz delete mode 100644 kexec-tools-riscv-hotplug.patch diff --git a/6419b008fde783fd0cc2cc266bd1c9cf35e99a0e.patch b/6419b008fde783fd0cc2cc266bd1c9cf35e99a0e.patch new file mode 100644 index 0000000..b2f2e98 --- /dev/null +++ b/6419b008fde783fd0cc2cc266bd1c9cf35e99a0e.patch @@ -0,0 +1,112 @@ +From 6419b008fde783fd0cc2cc266bd1c9cf35e99a0e Mon Sep 17 00:00:00 2001 +From: Julien Olivain +Date: Sat, 23 Sep 2023 18:46:06 +0200 +Subject: kexec: provide a memfd_create() wrapper if not present in libc + +Commit 714fa115 "kexec/arm64: Simplify the code for zImage" introduced +a use of the memfd_create() system call, included in version +kexec-tools v2.0.27. + +This system call was introduced in kernel commit [1], first included +in kernel v3.17 (released on 2014-10-05). + +The memfd_create() glibc wrapper function was added much later in +commit [2], first included in glibc version 2.27 (released on +2018-02-01). + +This direct use memfd_create() introduced a requirement on +Kernel >= 3.17 and glibc >= 2.27. + +There is old toolchains like [3] for example (which ships gcc 7.3.1, +glibc 2.25 and includes kernel v4.10 headers), that can still be used +to build newer kernels. Even if such toolchains can be seen as +outdated, they are is still claimed as supported by recent kernel. +For example, Kernel v6.5.5 has a requirement on gcc version 5.1 and +greater. See [4]. + +Moreover, kexec-tools <= 2.0.26 could be compiled using recent +toolchains with alternative libc (e.g. uclibc-ng, musl) which are not +providing the memfd_create() wrapper. + +When compiling kexec-tools v2.0.27 with a toolchain not providing the +memfd_create() syscall wrapper, the compilation fail with message: + + kexec/kexec.c: In function 'copybuf_memfd': + kexec/kexec.c:645:7: warning: implicit declaration of function 'memfd_create'; did you mean 'SYS_memfd_create'? [-Wimplicit-function-declaration] + fd = memfd_create("kernel", MFD_ALLOW_SEALING); + ^~~~~~~~~~~~ + SYS_memfd_create + kexec/kexec.c:645:30: error: 'MFD_ALLOW_SEALING' undeclared (first use in this function); did you mean '_PC_ALLOC_SIZE_MIN'? + fd = memfd_create("kernel", MFD_ALLOW_SEALING); + ^~~~~~~~~~~~~~~~~ + _PC_ALLOC_SIZE_MIN + +In order to let kexec-tools compile in a wider range of configurations, +this commit adds a memfd_create() function check in autoconf configure +script, and adds a system call wrapper which will be used if the +function is not available. With this commit, the environment +requirement is relaxed to only kernel >= v3.17. + +Note: this issue was found in kexec-tools integration in Buildroot [5] +using the command "utils/test-pkg -a -p kexec", which tests many +toolchain/arch combinations. + +[1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9183df25fe7b194563db3fec6dc3202a5855839c +[2] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=59d2cbb1fe4b8601d5cbd359c3806973eab6c62d +[3] https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz +[4] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/process/changes.rst?h=v6.5.5#n32 +[5] https://buildroot.org/ + +Signed-off-by: Julien Olivain +Signed-off-by: Simon Horman +--- + configure.ac | 3 +++ + kexec/kexec.c | 11 +++++++++++ + 2 files changed, 14 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 352eefee..602de79b 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -208,6 +208,9 @@ if test "$ac_cv_lib_xenctrl_xc_kexec_load" = yes ; then + AC_MSG_NOTICE([The kexec_status call is not available])) + fi + ++dnl Check if libc has the memfd_create() syscall wrapper ++AC_CHECK_FUNCS([memfd_create]) ++ + dnl ---Sanity checks + if test "$CC" = "no"; then AC_MSG_ERROR([cc not found]); fi + if test "$CPP" = "no"; then AC_MSG_ERROR([cpp not found]); fi +diff --git a/kexec/kexec.c b/kexec/kexec.c +index fdb4c984..08edfca2 100644 +--- a/kexec/kexec.c ++++ b/kexec/kexec.c +@@ -31,6 +31,10 @@ + #include + #include + #include ++#ifndef HAVE_MEMFD_CREATE ++#include ++#include ++#endif + #include + #include + #include +@@ -640,6 +644,13 @@ char *slurp_decompress_file(const char *filename, off_t *r_size) + return kernel_buf; + } + ++#ifndef HAVE_MEMFD_CREATE ++static int memfd_create(const char *name, unsigned int flags) ++{ ++ return syscall(SYS_memfd_create, name, flags); ++} ++#endif ++ + static int copybuf_memfd(const char *kernel_buf, size_t size) + { + int fd, count; +-- +cgit + diff --git a/kexec-dont-use-kexec_file_load-on-xen.patch b/kexec-dont-use-kexec_file_load-on-xen.patch new file mode 100644 index 0000000..5c18f79 --- /dev/null +++ b/kexec-dont-use-kexec_file_load-on-xen.patch @@ -0,0 +1,59 @@ +From: Jiri Bohac +Subject: [PATCH] kexec: dont use kexec_file_load on XEN +Patch-mainline: 94fbe64fb22d61726ca0c0996987574b6c783c19 +References: bsc#1218590 + +Since commit 29fe5067ed07 ("kexec: make -a the default") +kexec tries the kexec_file_load syscall first and only falls back to kexec_load on +selected error codes. + +This effectively breaks kexec on XEN, unless -c is pecified to force the kexec_load +syscall. + +The XEN-specific functions (xen_kexec_load / xen_kexec_unload) are only called +from my_load / k_unload, i.e. the kexec_load code path. + +With -p (panic kernel) kexec_file_load on XEN fails with -EADDRNOTAVAIL (crash +kernel reservation is ignored by the kernel on XEN), which is not in the list +of return codes that cause the fallback to kexec_file. + +Without -p kexec_file_load actualy leads to a kernel oops on v6.4.0 +(needs to be dubugged separately). + +Signed-off-by: Jiri Bohac +Fixes: 29fe5067ed07 ("kexec: make -a the default") +--- + kexec/kexec.8 | 1 + + kexec/kexec.c | 4 ++++ + 2 files changed, 5 insertions(+) + +diff --git a/kexec/kexec.8 b/kexec/kexec.8 +index b969cea..9e995fe 100644 +--- a/kexec/kexec.8 ++++ b/kexec/kexec.8 +@@ -162,6 +162,7 @@ Specify that the new kernel is of this + .TP + .BI \-s\ (\-\-kexec-file-syscall) + Specify that the new KEXEC_FILE_LOAD syscall should be used exclusively. ++Ignored on XEN. + .TP + .BI \-c\ (\-\-kexec-syscall) + Specify that the old KEXEC_LOAD syscall should be used exclusively. +diff --git a/kexec/kexec.c b/kexec/kexec.c +index 08edfca..9d0ec46 100644 +--- a/kexec/kexec.c ++++ b/kexec/kexec.c +@@ -1685,6 +1685,10 @@ int main(int argc, char *argv[]) + } + } + } ++ if (xen_present()) { ++ do_kexec_file_syscall = 0; ++ do_kexec_fallback = 0; ++ } + if (do_kexec_file_syscall) { + if (do_load_jump_back_helper && !do_kexec_fallback) + die("--load-jump-back-helper not supported with kexec_file_load\n"); +-- +2.43.0 + diff --git a/kexec-tools-2.0.27.tar.sign b/kexec-tools-2.0.27.tar.sign new file mode 100644 index 0000000000000000000000000000000000000000000000000000000000000000..097cd18d65c90245dd288295b43da8e48ba8a28dac6d23b3f0f5be24f1ce28a5 GIT binary patch literal 566 zcmV-60?GY}0y6{v0SW*e79j-UeA%J(tiu0G{&I!a&tz$8H&4C=0%Yt`eEcs@##=YZMi8AV}?k=)cQ zegdHZPE^Lf_^j<{CxhJU$wi62xKt98L?{sJdH?Y&As3*3lsAKxc~Vrt=tl*NJthrM zcEWR_i=XnQZB!)dBD)MSP_ZafS|K)5P2cJFj-ow(EY?eh^FdQ-_7cPY^TA#Oq!a?? z`r6Uh3rQ^+7Hi&9hwCr)&J_uq{iTTQgLEVt9;ST|7$+DK{U2<`Z)z=@UoK6_zlWC; zKb>7h$E^qn*a7C7%Q$ya-93=UPq)WoR9Tg>x)+Fy^^ro~cQBkzk1u3Zpmbq_F$-hM zyN8Pb;=nfpUSY2|gU~Kf2|OJ3s$+f~A+|!Z6lguBOLCcKjS}@G0*TqsdK+!)0TWzS EZh##JGXMYp literal 0 HcmV?d00001 diff --git a/kexec-tools-2.0.27.tar.xz b/kexec-tools-2.0.27.tar.xz new file mode 100644 index 0000000..ee552a7 --- /dev/null +++ b/kexec-tools-2.0.27.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38d78bcfa33a88928324b57dc81f50c1dfc279eede45e80957ca18f4e84b8187 +size 308540 diff --git a/kexec-tools-2.0.30.tar.sign b/kexec-tools-2.0.30.tar.sign deleted file mode 100644 index eafe42855c0c6d23d70bd65ff52e97e1d0c6d8b9d96922bdbdf2c70a108bc142..0000000000000000000000000000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 566 zcmV-60?GY}0y6{v0SW*e79j-UeA%J(tiu0G{&I!a&tz$8H&4C=0%uLJ`2Y$D5ZBLS zX=*o5zUQq_7#8dxfsS2)@QR`?W3B_WI<-pNi&c~HQ=)Lpn? zqDXJMzK>EEALE2mZ-4p**k{xs z;rb0=#6o3y;O-SUe@O%Ev1Ep#v zSA8t&CM_`n)=y=Vm)(*w9%M>lF2dwT975j`OG*!ed$Bmp@j_8fC5|JK$rMjbR -Subject: riscv: fix build with hotplug support -Upstream: not yet, blocked by base RISC-V patches - -Commit 3c47f384f1c4 ("kexec_load: Use new kexec flag for hotplug support") -adds a new architecture-specific function named arch_do_exclude_segment. -Since RISC-V does not yet implement hotplug updates in the kernel, add a -trivial definition of this function to kexec-tools. - -Signed-off-by: Petr Tesarik -Index: kexec-tools-2.0.29/kexec/arch/riscv/kexec-riscv.c -=================================================================== ---- kexec-tools-2.0.29.orig/kexec/arch/riscv/kexec-riscv.c -+++ kexec-tools-2.0.29/kexec/arch/riscv/kexec-riscv.c -@@ -362,3 +362,8 @@ int arch_compat_trampoline(struct kexec_ - 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; -+} diff --git a/kexec-tools.changes b/kexec-tools.changes index f031466..e3a45b4 100644 --- a/kexec-tools.changes +++ b/kexec-tools.changes @@ -1,73 +1,5 @@ ------------------------------------------------------------------- -Wed Jan 22 16:24:47 UTC 2025 - Dominique Leuenberger - -- Drop rcFOO symlinks for CODE16 (PED-266). - -------------------------------------------------------------------- -Wed Jan 1 01:01:01 UTC 2025 - olaf@aepfle.de - -- force -std=gnu99 because C99 because the code uses features - -------------------------------------------------------------------- -Mon Dec 30 14:17:03 UTC 2024 - Petr Tesařík - -- update to 2.0.30: - * arm64: Support UKI image format - * bug fixes - -------------------------------------------------------------------- -Fri Sep 13 13:13:13 UTC 2024 - olaf@aepfle.de - -- To create rckexec-reload, the service binary is required at - build time. This binary is provided by aaa_base. Make sure this - package is available during build. - -------------------------------------------------------------------- -Mon Aug 12 11:15:32 UTC 2024 - Petr Tesařík - -- update to 2.0.29: - * update man and --help - * powerpc/kexec_load: add hotplug support - * kexec_load: Use new kexec flag for hotplug support - * x86-linux-setup.c: Use POSIX basename API - * LoongArch: fix load command line segment error - * LoongArch: add multi crash kernel segment support - * LoongArch: fix kernel image size error - * Arm: Fix add_buffer_phys_virt() align issue - * Fix incorrect Free Software Foundation address in the license - * util_lib/elf_info.c: fix a warning - * kexec_file: add kexec_file flag to support debug printing - * workflow: update to use checkout@v4 -- drop kexec-dont-use-kexec_file_load-on-xen.patch, upstream -- drop fix-building-on-x86_64-with-binutils-2.41.patch, upstream -- kexec-tools-riscv-hotplug.patch: Fix build for riscv64. - -------------------------------------------------------------------- -Wed Mar 6 16:46:15 UTC 2024 - Jiri Bohac - -- update to 2.0.28: - * LoongArch: Load vmlinux.efi to the link address - * LoongArch: Fix an issue with relocatable vmlinux - * m68k: fix getrandom() use with uclibc - * lzma: Relax memory limit for lzma decompressor - * kexec: ppc64: print help to stdout instead of stderr - * kexec/loongarch64: fix 'make dist' file loss issue - * crashdump/x86: set the elfcorehdr segment size for hotplug - * crashdump/x86: identify elfcorehdr segment for hotplug - * crashdump: exclude elfcorehdr segment from digest for hotplug - * crashdump: setup general hotplug support - * crashdump: introduce the hotplug command line options - * kexec: define KEXEC_UPDATE_ELFCOREHDR - * kexec: update manpage with explicit mention of clean kexec - * zboot: add loongarch kexec_load support - * zboot: enable arm64 kexec_load for zboot image -- drop 6419b008fde783fd0cc2cc266bd1c9cf35e99a0e.patch, upstream -- add fix-building-on-x86_64-with-binutils-2.41.patch: - * fix assembling on binutils >= 2.42 -- refresh kexec-tools-disable-test.patch - -------------------------------------------------------------------- -Fri Jan 19 16:50:42 UTC 2024 - Jiri Bohac +Thu Jan 25 17:38:17 UTC 2024 - Jiri Bohac - add kexec-dont-use-kexec_file_load-on-xen.patch: kexec: don't use kexec_file_load on xen (bsc#1218590) diff --git a/kexec-tools.spec b/kexec-tools.spec index 330d1be..d57d8c7 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,7 +1,7 @@ # # spec file for package kexec-tools # -# Copyright (c) 2025 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ # Temporarily bump version to aid package split Name: kexec-tools -Version: 2.0.30 +Version: 2.0.27 Release: 0 Summary: Tools for loading replacement kernels into memory License: GPL-2.0-or-later @@ -29,13 +29,13 @@ Source1: https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{versio Source2: kexec-tools.keyring Source3: kexec-load.service Source4: %{name}-rpmlintrc +Patch0: 6419b008fde783fd0cc2cc266bd1c9cf35e99a0e.patch Patch3: %{name}-disable-test.patch Patch4: %{name}-vmcoreinfo-in-xen.patch # https://patchwork.kernel.org/project/linux-riscv/patch/20190416123233.4779-1-mick@ics.forth.gr/ Patch5: %{name}-riscv64.patch Patch10: %{name}-SYS_getrandom.patch -Patch11: %{name}-riscv-hotplug.patch -BuildRequires: aaa_base +Patch11: kexec-dont-use-kexec_file_load-on-xen.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: systemd-rpm-macros @@ -44,7 +44,7 @@ BuildRequires: zlib-devel #!BuildIgnore: gcc-PIE Requires: perl-Bootloader >= 1.6 Requires(post): suse-module-tools -Requires(postun): suse-module-tools +Requires(postun):suse-module-tools %{?systemd_requires} %if 0%{?suse_version} == 1600 # No Xen @@ -67,8 +67,8 @@ the loaded kernel after it panics. %build autoreconf -fvi -export CFLAGS="%{optflags} -fPIC -std=gnu99" -export BUILD_CFLAGS="%{optflags} -std=gnu99" +export CFLAGS="%{optflags} -fPIC" +export BUILD_CFLAGS="%{optflags}" export LDFLAGS="-pie" %configure %make_build @@ -77,10 +77,8 @@ export LDFLAGS="-pie" %make_install mkdir -p %{buildroot}/%{_unitdir} install -m644 %{SOURCE3} %{buildroot}/%{_unitdir} -%if 0%{?suse_version} < 1600 mkdir -p %{buildroot}/%{_sbindir} ln -s service %{buildroot}%{_sbindir}/rckexec-load -%endif %if 0%{?suse_version} < 1550 mkdir -p %{buildroot}/sbin ln -s %{_sbindir}/kexec %{buildroot}/sbin @@ -122,9 +120,7 @@ ln -s %{_sbindir}/kexec %{buildroot}/sbin %if 0%{?suse_version} < 1550 /sbin/kexec %endif -%if 0%{?suse_version} < 1600 %{_sbindir}/rckexec-load -%endif %{_sbindir}/kexec %{_sbindir}/vmcore-dmesg %{_unitdir}/kexec-load.service