Dominique Leuenberger 2024-03-07 17:27:59 +00:00 committed by Git OBS Bridge
commit 68277e667f
9 changed files with 123 additions and 121 deletions

View File

@ -1,112 +0,0 @@
From 6419b008fde783fd0cc2cc266bd1c9cf35e99a0e Mon Sep 17 00:00:00 2001
From: Julien Olivain <ju.o@free.fr>
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 <ju.o@free.fr>
Signed-off-by: Simon Horman <horms@kernel.org>
---
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 <sys/mount.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifndef HAVE_MEMFD_CREATE
+#include <linux/memfd.h>
+#include <sys/syscall.h>
+#endif
#include <sys/reboot.h>
#include <sys/mman.h>
#include <unistd.h>
@@ -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

View File

@ -0,0 +1,88 @@
From: Michel Lind <salimma@fedoraproject.org>
Subject: Fix building on x86_64 with binutils 2.41
Git-commit: 328de8e00e298f00d7ba6b25dc3950147e9642e6
Patch-mainline:
References:
Acked-by: Jiri Bohac <jbohac@suse.cz>
Newer versions of the GNU assembler (observed with binutils 2.41) will
complain about the ".arch i386" in files assembled with "as --64",
with the message "Error: 64bit mode not supported on 'i386'".
Fix by moving ".arch i386" below the relevant ".code32" directive, so
that the assembler is no longer expecting 64-bit instructions to be used
by the time that the ".arch i386" directive is encountered.
Based on similar iPXE fix:
https://github.com/ipxe/ipxe/commit/6ca597eee
Signed-off-by: Michel Lind <michel@michel-slm.name>
Signed-off-by: Simon Horman <horms@kernel.org>
diff --git a/purgatory/arch/i386/entry32-16-debug.S b/purgatory/arch/i386/entry32-16-debug.S
index 5167944..12e1164 100644
--- a/purgatory/arch/i386/entry32-16-debug.S
+++ b/purgatory/arch/i386/entry32-16-debug.S
@@ -25,10 +25,10 @@
.globl entry16_debug_pre32
.globl entry16_debug_first32
.globl entry16_debug_old_first32
- .arch i386
.balign 16
entry16_debug:
.code32
+ .arch i386
/* Compute where I am running at (assumes esp valid) */
call 1f
1: popl %ebx
diff --git a/purgatory/arch/i386/entry32-16.S b/purgatory/arch/i386/entry32-16.S
index c051aab..eace095 100644
--- a/purgatory/arch/i386/entry32-16.S
+++ b/purgatory/arch/i386/entry32-16.S
@@ -20,10 +20,10 @@
#undef i386
.text
.globl entry16, entry16_regs
- .arch i386
.balign 16
entry16:
.code32
+ .arch i386
/* Compute where I am running at (assumes esp valid) */
call 1f
1: popl %ebx
diff --git a/purgatory/arch/i386/entry32.S b/purgatory/arch/i386/entry32.S
index f7a494f..8ce9e31 100644
--- a/purgatory/arch/i386/entry32.S
+++ b/purgatory/arch/i386/entry32.S
@@ -20,10 +20,10 @@
#undef i386
.text
- .arch i386
.globl entry32, entry32_regs
entry32:
.code32
+ .arch i386
/* Setup a gdt that should that is generally usefully */
lgdt %cs:gdt
diff --git a/purgatory/arch/i386/setup-x86.S b/purgatory/arch/i386/setup-x86.S
index 201bb2c..a212eed 100644
--- a/purgatory/arch/i386/setup-x86.S
+++ b/purgatory/arch/i386/setup-x86.S
@@ -21,10 +21,10 @@
#undef i386
.text
- .arch i386
.globl purgatory_start
purgatory_start:
.code32
+ .arch i386
/* Load a gdt so I know what the segment registers are */
lgdt %cs:gdt
--
2.43.0

Binary file not shown.

BIN
kexec-tools-2.0.27.tar.xz (Stored with Git LFS)

Binary file not shown.

BIN
kexec-tools-2.0.28.tar.sign Normal file

Binary file not shown.

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d2f0ef872f39e2fe4b1b01feb62b0001383207239b9f8041f98a95564161d053
size 312524

View File

@ -8,10 +8,12 @@ Fedora). Also one less file for usr_merge
Makefile.in | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
--- a/Makefile.in
+++ b/Makefile.in
@@ -173,8 +173,11 @@ PSRCS:=$(foreach s, $(SRCS), $(PACKAGE_N
PGSRCS:=$(foreach s, $(GENERATED_SRCS), $(PACKAGE_NAME)-$(PACKAGE_VERSION)/$(s))
Index: kexec-tools-2.0.28/Makefile.in
===================================================================
--- kexec-tools-2.0.28.orig/Makefile.in
+++ kexec-tools-2.0.28/Makefile.in
@@ -181,8 +181,11 @@ TARBALL.gz=$(TARBALL).gz
SRCS:= $(dist)
MAN_PAGES:=$(KEXEC_MANPAGE) $(VMCORE_DMESG_MANPAGE)
-BINARIES_i386:=$(KEXEC_TEST)

View File

@ -1,3 +1,27 @@
-------------------------------------------------------------------
Wed Mar 6 16:46:15 UTC 2024 - Jiri Bohac <jbohac@suse.com>
- 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 <jbohac@suse.com>

View File

@ -18,7 +18,7 @@
# Temporarily bump version to aid package split
Name: kexec-tools
Version: 2.0.27
Version: 2.0.28
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: kexec-dont-use-kexec_file_load-on-xen.patch
Patch12: fix-building-on-x86_64-with-binutils-2.41.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: systemd-rpm-macros