Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package kexec-tools for openSUSE:Factory 
checked in at 2023-09-08 21:14:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/kexec-tools (Old)
 and      /work/SRC/openSUSE:Factory/.kexec-tools.new.1766 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "kexec-tools"

Fri Sep  8 21:14:53 2023 rev:150 rq:1109228 version:2.0.27

Changes:
--------
--- /work/SRC/openSUSE:Factory/kexec-tools/kexec-tools.changes  2023-07-04 
15:22:00.526071794 +0200
+++ /work/SRC/openSUSE:Factory/.kexec-tools.new.1766/kexec-tools.changes        
2023-09-08 21:14:56.601188940 +0200
@@ -1,0 +2,16 @@
+Wed Sep  6 09:10:09 UTC 2023 - Petr Tesařík <p...@tesarici.cz>
+
+- update to 2.0.27:
+  * ppc64: add --reuse-cmdline parameter support
+  * kexec: make -a the default
+  * x86: add devicetree support
+  * ppc64: document elf-ppc64 options and --dt-no-old-root
+  * LoongArch: kdump: set up kernel image segment
+  * arm64: zboot support
+
+-------------------------------------------------------------------
+Tue Aug  8 08:08:08 UTC 2023 - o...@aepfle.de
+
+- Disable Xen support in ALP
+
+-------------------------------------------------------------------

Old:
----
  kexec-tools-2.0.26.tar.sign
  kexec-tools-2.0.26.tar.xz

New:
----
  kexec-tools-2.0.27.tar.sign
  kexec-tools-2.0.27.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ kexec-tools.spec ++++++
--- /var/tmp/diff_new_pack.g1EDXI/_old  2023-09-08 21:14:58.321250414 +0200
+++ /var/tmp/diff_new_pack.g1EDXI/_new  2023-09-08 21:14:58.325250557 +0200
@@ -17,16 +17,15 @@
 
 
 # Temporarily bump version to aid package split
-%global realversion 2.0.26
 Name:           kexec-tools
-Version:        %{realversion}.0
+Version:        2.0.27
 Release:        0
 Summary:        Tools for loading replacement kernels into memory
 License:        GPL-2.0-or-later
 Group:          System/Kernel
 URL:            https://projects.horms.net/projects/kexec/
-Source:         
https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{realversion}.tar.xz
-Source1:        
https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{realversion}.tar.sign
+Source:         
https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz
+Source1:        
https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.sign
 Source2:        kexec-tools.keyring
 Source3:        kexec-load.service
 Source4:        %{name}-rpmlintrc
@@ -45,10 +44,14 @@
 Requires(post): suse-module-tools
 Requires(postun):suse-module-tools
 %{?systemd_requires}
+%if 0%{?suse_version} == 1600
+# No Xen
+%else
 %ifarch         x86_64
 BuildRequires:  pkgconfig
 BuildRequires:  xen-devel
 %endif
+%endif
 
 %description
 Kexec is a user space utility for loading another kernel and asking the
@@ -57,7 +60,7 @@
 the loaded kernel after it panics.
 
 %prep
-%setup -q -n %{name}-%{realversion}
+%setup -q -n %{name}-%{version}
 %autopatch -p1
 
 %build

++++++ kexec-tools-2.0.26.tar.xz -> kexec-tools-2.0.27.tar.xz ++++++
++++ 7205 lines of diff (skipped)
++++    retrying with extended exclude list
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/configure.ac new/kexec-tools-2.0.27/configure.ac
--- old/kexec-tools-2.0.26/configure.ac 2022-12-21 16:28:33.000000000 +0100
+++ new/kexec-tools-2.0.27/configure.ac 2023-08-28 09:50:03.000000000 +0200
@@ -4,7 +4,7 @@
 dnl 
 
 dnl ---Required
-AC_INIT(kexec-tools, 2.0.26)
+AC_INIT(kexec-tools, 2.0.27)
 AC_CONFIG_AUX_DIR(./config)
 AC_CONFIG_HEADERS([include/config.h])
 AC_LANG(C)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/include/Makefile new/kexec-tools-2.0.27/include/Makefile
--- old/kexec-tools-2.0.26/include/Makefile     2022-11-18 16:11:40.000000000 
+0100
+++ new/kexec-tools-2.0.27/include/Makefile     2023-08-11 09:28:08.000000000 
+0200
@@ -1,6 +1,7 @@
 dist += include/Makefile               \
        include/config.h                \
        include/config.h.in             \
+       include/kexec-pe-zboot.h        \
        include/kexec-uImage.h          \
        include/x86/x86-linux.h         \
        include/x86/mb_info.h           \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/include/config.h new/kexec-tools-2.0.27/include/config.h
--- old/kexec-tools-2.0.26/include/config.h     2022-12-21 16:29:24.000000000 
+0100
+++ new/kexec-tools-2.0.27/include/config.h     2023-08-28 09:50:58.000000000 
+0200
@@ -11,7 +11,7 @@
 #define HAVE_INTTYPES_H 1
 
 /* The kexec_status call is available */
-#define HAVE_KEXEC_CMD_STATUS 1
+/* #undef HAVE_KEXEC_CMD_STATUS */
 
 /* Define to 1 if you have the `dl' library (-ldl). */
 /* #undef HAVE_LIBDL */
@@ -20,17 +20,17 @@
 /* #undef HAVE_LIBLZMA */
 
 /* Define to 1 if you have the `xenctrl' library (-lxenctrl). */
-#define HAVE_LIBXENCTRL 1
+/* #undef HAVE_LIBXENCTRL */
 
 /* Define to 1 if you have the `z' library (-lz). */
 #define HAVE_LIBZ 1
 
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
 /* Define to 1 if you have the <stdint.h> header file. */
 #define HAVE_STDINT_H 1
 
+/* Define to 1 if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
 /* Define to 1 if you have the <stdlib.h> header file. */
 #define HAVE_STDLIB_H 1
 
@@ -56,7 +56,7 @@
 #define PACKAGE_NAME "kexec-tools"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "kexec-tools 2.0.26"
+#define PACKAGE_STRING "kexec-tools 2.0.27"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "kexec-tools"
@@ -65,9 +65,11 @@
 #define PACKAGE_URL ""
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "2.0.26"
+#define PACKAGE_VERSION "2.0.27"
 
-/* Define to 1 if you have the ANSI C header files. */
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
+   required in a freestanding environment). This macro is provided for
+   backward compatibility; new code need not use it. */
 #define STDC_HEADERS 1
 
 /* Define to include gamecube support */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/include/config.h.in 
new/kexec-tools-2.0.27/include/config.h.in
--- old/kexec-tools-2.0.26/include/config.h.in  2022-01-14 15:31:22.000000000 
+0100
+++ new/kexec-tools-2.0.27/include/config.h.in  2023-08-28 09:50:46.000000000 
+0200
@@ -24,12 +24,12 @@
 /* Define to 1 if you have the `z' library (-lz). */
 #undef HAVE_LIBZ
 
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
 /* Define to 1 if you have the <stdlib.h> header file. */
 #undef HAVE_STDLIB_H
 
@@ -66,7 +66,9 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
-/* Define to 1 if you have the ANSI C header files. */
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
+   required in a freestanding environment). This macro is provided for
+   backward compatibility; new code need not use it. */
 #undef STDC_HEADERS
 
 /* Define to include gamecube support */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/include/kexec-pe-zboot.h 
new/kexec-tools-2.0.27/include/kexec-pe-zboot.h
--- old/kexec-tools-2.0.26/include/kexec-pe-zboot.h     1970-01-01 
01:00:00.000000000 +0100
+++ new/kexec-tools-2.0.27/include/kexec-pe-zboot.h     2023-08-11 
09:28:08.000000000 +0200
@@ -0,0 +1,15 @@
+#ifndef __KEXEC_PE_ZBOOT_H__
+#define __KEXEC_PE_ZBOOT_H__
+
+/* see drivers/firmware/efi/libstub/zboot-header.S */
+struct linux_pe_zboot_header {
+       uint32_t mz_magic;
+       uint32_t image_type;
+       uint32_t payload_offset;
+       uint32_t payload_size;
+       uint32_t reserved[2];
+       uint32_t compress_type;
+};
+
+int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd);
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/Makefile new/kexec-tools-2.0.27/kexec/Makefile
--- old/kexec-tools-2.0.26/kexec/Makefile       2022-11-18 16:11:40.000000000 
+0100
+++ new/kexec-tools-2.0.27/kexec/Makefile       2023-08-11 09:28:08.000000000 
+0200
@@ -17,6 +17,7 @@
 KEXEC_SRCS_base += kexec/kexec-elf-core.c
 KEXEC_SRCS_base += kexec/kexec-elf-rel.c
 KEXEC_SRCS_base += kexec/kexec-elf-boot.c
+KEXEC_SRCS_base += kexec/kexec-pe-zboot.c
 KEXEC_SRCS_base += kexec/kexec-iomem.c
 KEXEC_SRCS_base += kexec/firmware_memmap.c
 KEXEC_SRCS_base += kexec/crashdump.c
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/arm64/Makefile 
new/kexec-tools-2.0.27/kexec/arch/arm64/Makefile
--- old/kexec-tools-2.0.26/kexec/arch/arm64/Makefile    2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/arm64/Makefile    2023-08-11 
09:28:08.000000000 +0200
@@ -16,7 +16,7 @@
        kexec/arch/arm64/kexec-elf-arm64.c \
        kexec/arch/arm64/kexec-uImage-arm64.c \
        kexec/arch/arm64/kexec-image-arm64.c \
-       kexec/arch/arm64/kexec-zImage-arm64.c
+       kexec/arch/arm64/kexec-vmlinuz-arm64.c
 
 arm64_UIMAGE = kexec/kexec-uImage.c
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/arm64/image-header.h 
new/kexec-tools-2.0.27/kexec/arch/arm64/image-header.h
--- old/kexec-tools-2.0.26/kexec/arch/arm64/image-header.h      2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/arm64/image-header.h      2023-08-11 
09:28:08.000000000 +0200
@@ -37,6 +37,7 @@
 
 static const uint8_t arm64_image_magic[4] = {'A', 'R', 'M', 0x64U};
 static const uint8_t arm64_image_pe_sig[2] = {'M', 'Z'};
+static const uint8_t arm64_pe_machtype[6] = {'P','E', 0x0, 0x0, 0x64, 0xAA};
 static const uint64_t arm64_image_flag_be = (1UL << 0);
 static const uint64_t arm64_image_flag_page_size = (3UL << 1);
 static const uint64_t arm64_image_flag_placement = (1UL << 3);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/arm64/kexec-arm64.c 
new/kexec-tools-2.0.27/kexec/arch/arm64/kexec-arm64.c
--- old/kexec-tools-2.0.26/kexec/arch/arm64/kexec-arm64.c       2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/arm64/kexec-arm64.c       2023-08-11 
09:28:08.000000000 +0200
@@ -74,7 +74,7 @@
        {"vmlinux", elf_arm64_probe, elf_arm64_load, elf_arm64_usage},
        {"Image", image_arm64_probe, image_arm64_load, image_arm64_usage},
        {"uImage", uImage_arm64_probe, uImage_arm64_load, uImage_arm64_usage},
-       {"zImage", zImage_arm64_probe, zImage_arm64_load, zImage_arm64_usage},
+       {"vmlinuz", pez_arm64_probe, pez_arm64_load, pez_arm64_usage},
 };
 
 int file_types = sizeof(file_type) / sizeof(file_type[0]);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/arm64/kexec-arm64.h 
new/kexec-tools-2.0.27/kexec/arch/arm64/kexec-arm64.h
--- old/kexec-tools-2.0.26/kexec/arch/arm64/kexec-arm64.h       2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/arm64/kexec-arm64.h       2023-08-11 
09:28:08.000000000 +0200
@@ -44,10 +44,10 @@
                      struct kexec_info *info);
 void uImage_arm64_usage(void);
 
-int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size);
-int zImage_arm64_load(int argc, char **argv, const char *kernel_buf,
-       off_t kernel_size, struct kexec_info *info);
-void zImage_arm64_usage(void);
+int pez_arm64_probe(const char *kernel_buf, off_t kernel_size);
+int pez_arm64_load(int argc, char **argv, const char *buf, off_t len,
+                       struct kexec_info *info);
+void pez_arm64_usage(void);
 
 
 extern off_t initrd_base;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/arm64/kexec-image-arm64.c 
new/kexec-tools-2.0.27/kexec/arch/arm64/kexec-image-arm64.c
--- old/kexec-tools-2.0.26/kexec/arch/arm64/kexec-image-arm64.c 2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/arm64/kexec-image-arm64.c 2023-08-11 
09:28:08.000000000 +0200
@@ -114,6 +114,6 @@
 void image_arm64_usage(void)
 {
        printf(
-"     An ARM64 binary image, uncompressed, big or little endian.\n"
+"     An ARM64 binary image, compressed or not, big or little endian.\n"
 "     Typically an Image file.\n\n");
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/arm64/kexec-vmlinuz-arm64.c 
new/kexec-tools-2.0.27/kexec/arch/arm64/kexec-vmlinuz-arm64.c
--- old/kexec-tools-2.0.26/kexec/arch/arm64/kexec-vmlinuz-arm64.c       
1970-01-01 01:00:00.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/arm64/kexec-vmlinuz-arm64.c       
2023-08-11 09:28:08.000000000 +0200
@@ -0,0 +1,110 @@
+/*
+ * ARM64 PE compressed Image (vmlinuz, ZBOOT) support.
+ *
+ * Several distros use 'make zinstall' rule inside
+ * 'arch/arm64/boot/Makefile' to install the arm64
+ * ZBOOT compressed file inside the boot destination
+ * directory (for e.g. /boot).
+ *
+ * Currently we cannot use kexec_file_load() to load vmlinuz
+ * PE images that self decompress.
+ *
+ * To support ZBOOT, we should:
+ * a). Copy the compressed contents of vmlinuz to a temporary file.
+ * b). Decompress (gunzip-decompress) the contents inside the
+ *     temporary file.
+ * c). Validate the resulting image and write it back to the
+ *     temporary file.
+ * d). Pass the 'fd' of the temporary file to the kernel space.
+ *
+ * Note this, module doesn't provide a _load() function instead
+ * relying on image_arm64_load() to load the resulting decompressed
+ * image.
+ *
+ * So basically the kernel space still gets a decompressed
+ * kernel image to load via kexec-tools.
+ */
+
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include "kexec-arm64.h"
+#include <kexec-pe-zboot.h>
+#include "arch/options.h"
+
+static int kernel_fd = -1;
+
+/* Returns:
+ * -1 : in case of error/invalid format (not a valid PE+compressed ZBOOT 
format.
+ */
+int pez_arm64_probe(const char *kernel_buf, off_t kernel_size)
+{
+       int ret = -1;
+       const struct arm64_image_header *h;
+       char *buf;
+       off_t buf_sz;
+
+       buf = (char *)kernel_buf;
+       buf_sz = kernel_size;
+       if (!buf)
+               return -1;
+       h = (const struct arm64_image_header *)buf;
+
+       dbgprintf("%s: PROBE.\n", __func__);
+       if (buf_sz < sizeof(struct arm64_image_header)) {
+               dbgprintf("%s: Not large enough to be a PE image.\n", __func__);
+               return -1;
+       }
+       if (!arm64_header_check_pe_sig(h)) {
+               dbgprintf("%s: Not an PE image.\n", __func__);
+               return -1;
+       }
+
+       if (buf_sz < sizeof(struct arm64_image_header) + h->pe_header) {
+               dbgprintf("%s: PE image offset larger than image.\n", __func__);
+               return -1;
+       }
+
+       if (memcmp(&buf[h->pe_header],
+                  arm64_pe_machtype, sizeof(arm64_pe_machtype))) {
+               dbgprintf("%s: PE header doesn't match machine type.\n", 
__func__);
+               return -1;
+       }
+
+       ret = pez_prepare(buf, buf_sz, &kernel_fd);
+
+       if (!ret) {
+           /* validate the arm64 specific header */
+           struct arm64_image_header hdr_check;
+           if (read(kernel_fd, &hdr_check, sizeof(hdr_check)) != 
sizeof(hdr_check))
+               goto bad_header;
+
+           lseek(kernel_fd, 0, SEEK_SET);
+
+           if (!arm64_header_check_magic(&hdr_check)) {
+               dbgprintf("%s: Bad arm64 image header.\n", __func__);
+               goto bad_header;
+           }
+       }
+
+       return ret;
+bad_header:
+       close(kernel_fd);
+       free(buf);
+       return -1;
+}
+
+int pez_arm64_load(int argc, char **argv, const char *buf, off_t len,
+                       struct kexec_info *info)
+{
+       info->kernel_fd = kernel_fd;
+       return image_arm64_load(argc, argv, buf, len, info);
+}
+
+void pez_arm64_usage(void)
+{
+       printf(
+"     An ARM64 vmlinuz, PE image of a compressed, little endian.\n"
+"     kernel, built with ZBOOT enabled.\n\n");
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/arm64/kexec-zImage-arm64.c 
new/kexec-tools-2.0.27/kexec/arch/arm64/kexec-zImage-arm64.c
--- old/kexec-tools-2.0.26/kexec/arch/arm64/kexec-zImage-arm64.c        
2022-11-18 16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/arm64/kexec-zImage-arm64.c        
1970-01-01 01:00:00.000000000 +0100
@@ -1,226 +0,0 @@
-/*
- * ARM64 kexec zImage (Image.gz) support.
- *
- * Several distros use 'make zinstall' rule inside
- * 'arch/arm64/boot/Makefile' to install the arm64
- * Image.gz compressed file inside the boot destination
- * directory (for e.g. /boot).
- *
- * Currently we cannot use kexec_file_load() to load vmlinuz
- * (or Image.gz).
- *
- * To support Image.gz, we should:
- * a). Copy the contents of Image.gz to a temporary file.
- * b). Decompress (gunzip-decompress) the contents inside the
- *     temporary file.
- * c). Pass the 'fd' of the temporary file to the kernel space.
- *
- * So basically the kernel space still gets a decompressed
- * kernel image to load via kexec-tools.
- */
-
-#define _GNU_SOURCE
-
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdlib.h>
-#include "crashdump-arm64.h"
-#include "image-header.h"
-#include "kexec.h"
-#include "kexec-arm64.h"
-#include "kexec-syscall.h"
-#include "kexec-zlib.h"
-#include "arch/options.h"
-
-#define FILENAME_IMAGE         "/tmp/ImageXXXXXX"
-
-/* Returns:
- * -1 : in case of error/invalid format (not a valid Image.gz format.
- * fd : File descriptor of the temp file containing the decompressed
- *      Image.
- */
-int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size)
-{
-       int ret = -1;
-       int fd = 0;
-       int kernel_fd = 0;
-       char *fname = NULL;
-       char *kernel_uncompressed_buf = NULL;
-       const struct arm64_image_header *h;
-
-       if (!is_zlib_file(kernel_buf, &kernel_size)) {
-               dbgprintf("%s: Not an zImage file (Image.gz).\n", __func__);
-               return -1;
-       }
-
-       if (!(fname = strdup(FILENAME_IMAGE))) {
-               dbgprintf("%s: Can't duplicate strings %s\n", __func__,
-                               fname);
-               return -1;
-       }
-
-       if ((fd = mkstemp(fname)) < 0) {
-               dbgprintf("%s: Can't open file %s\n", __func__,
-                               fname);
-               ret = -1;
-               goto fail_mkstemp;
-       }
-
-       kernel_uncompressed_buf =
-               (char *) calloc(kernel_size, sizeof(off_t));
-       if (!kernel_uncompressed_buf) {
-               dbgprintf("%s: Can't calloc %ld bytes\n",
-                               __func__, kernel_size);
-               ret= -ENOMEM;
-               goto fail_calloc;
-       }
-
-       /* slurp in the input kernel */
-       dbgprintf("%s: ", __func__);
-       kernel_uncompressed_buf = slurp_decompress_file(kernel_buf,
-                                                       &kernel_size);
-
-       /* check for correct header magic */
-       if (kernel_size < sizeof(struct arm64_image_header)) {
-               dbgprintf("%s: No arm64 image header.\n", __func__);
-               ret = -1;
-               goto fail_bad_header;
-       }
-
-       h = (const struct arm64_image_header *)(kernel_uncompressed_buf);
-
-       if (!arm64_header_check_magic(h)) {
-               dbgprintf("%s: Bad arm64 image header.\n", __func__);
-               ret = -1;
-               goto fail_bad_header;
-       }
-
-       if (write(fd, kernel_uncompressed_buf,
-                               kernel_size) != kernel_size) {
-               dbgprintf("%s: Can't write the uncompressed file %s\n",
-                               __func__, fname);
-               ret = -1;
-               goto fail_bad_header;
-       }
-
-       close(fd);
-
-       /* Open the tmp file again, this time in O_RDONLY mode, as
-        * opening the file in O_RDWR and calling kexec_file_load()
-        * causes the kernel to return -ETXTBSY
-        */
-       kernel_fd = open(fname, O_RDONLY);
-       if (kernel_fd == -1) {
-               dbgprintf("%s: Failed to open file %s\n",
-                               __func__, fname);
-               ret = -1;
-               goto fail_bad_header;
-       }
-
-       unlink(fname);
-
-       free(kernel_uncompressed_buf);
-       free(fname);
-
-       return kernel_fd;
-
-fail_bad_header:
-       free(kernel_uncompressed_buf);
-
-fail_calloc:
-       if (fd >= 0)
-               close(fd);
-
-       unlink(fname);
-
-fail_mkstemp:
-       free(fname);
-
-       return ret;
-}
-
-int zImage_arm64_load(int argc, char **argv, const char *kernel_buf,
-       off_t kernel_size, struct kexec_info *info)
-{
-       const struct arm64_image_header *header;
-       unsigned long kernel_segment;
-       int result;
-
-       if (info->file_mode) {
-               if (arm64_opts.initrd) {
-                       info->initrd_fd = open(arm64_opts.initrd, O_RDONLY);
-                       if (info->initrd_fd == -1) {
-                               fprintf(stderr,
-                                       "Could not open initrd file %s:%s\n",
-                                       arm64_opts.initrd, strerror(errno));
-                               result = EFAILED;
-                               goto exit;
-                       }
-               }
-
-               if (arm64_opts.command_line) {
-                       info->command_line = (char *)arm64_opts.command_line;
-                       info->command_line_len =
-                                       strlen(arm64_opts.command_line) + 1;
-               }
-
-               return 0;
-       }
-
-       header = (const struct arm64_image_header *)(kernel_buf);
-
-       if (arm64_process_image_header(header))
-               return EFAILED;
-
-       kernel_segment = arm64_locate_kernel_segment(info);
-
-       if (kernel_segment == ULONG_MAX) {
-               dbgprintf("%s: Kernel segment is not allocated\n", __func__);
-               result = EFAILED;
-               goto exit;
-       }
-
-       dbgprintf("%s: kernel_segment: %016lx\n", __func__, kernel_segment);
-       dbgprintf("%s: text_offset:    %016lx\n", __func__,
-               arm64_mem.text_offset);
-       dbgprintf("%s: image_size:     %016lx\n", __func__,
-               arm64_mem.image_size);
-       dbgprintf("%s: phys_offset:    %016lx\n", __func__,
-               arm64_mem.phys_offset);
-       dbgprintf("%s: vp_offset:      %016lx\n", __func__,
-               arm64_mem.vp_offset);
-       dbgprintf("%s: PE format:      %s\n", __func__,
-               (arm64_header_check_pe_sig(header) ? "yes" : "no"));
-
-       /* create and initialize elf core header segment */
-       if (info->kexec_flags & KEXEC_ON_CRASH) {
-               result = load_crashdump_segments(info);
-               if (result) {
-                       dbgprintf("%s: Creating eflcorehdr failed.\n",
-                                                               __func__);
-                       goto exit;
-               }
-       }
-
-       /* load the kernel */
-       add_segment_phys_virt(info, kernel_buf, kernel_size,
-                       kernel_segment + arm64_mem.text_offset,
-                       arm64_mem.image_size, 0);
-
-       /* load additional data */
-       result = arm64_load_other_segments(info, kernel_segment
-               + arm64_mem.text_offset);
-
-exit:
-       if (result)
-               fprintf(stderr, "kexec: load failed.\n");
-       return result;
-}
-
-void zImage_arm64_usage(void)
-{
-       printf(
-"     An ARM64 zImage, compressed, big or little endian.\n"
-"     Typically an Image.gz or Image.lzma file.\n\n");
-}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/i386/include/arch/options.h 
new/kexec-tools-2.0.27/kexec/arch/i386/include/arch/options.h
--- old/kexec-tools-2.0.26/kexec/arch/i386/include/arch/options.h       
2022-11-18 16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/i386/include/arch/options.h       
2023-05-24 13:47:18.000000000 +0200
@@ -33,6 +33,7 @@
 #define OPT_PASS_MEMMAP_CMDLINE        (OPT_ARCH_MAX+11)
 #define OPT_NOEFI              (OPT_ARCH_MAX+12)
 #define OPT_REUSE_VIDEO_TYPE   (OPT_ARCH_MAX+13)
+#define OPT_DTB                        (OPT_ARCH_MAX+14)
 
 /* Options relevant to the architecture (excluding loader-specific ones): */
 #define KEXEC_ARCH_OPTIONS \
@@ -76,7 +77,8 @@
        { "args-none",          0, NULL, OPT_ARGS_NONE },       \
        { "module",             1, 0, OPT_MOD },                \
        { "real-mode",          0, NULL, OPT_REAL_MODE },       \
-       { "entry-32bit",        0, NULL, OPT_ENTRY_32BIT },
+       { "entry-32bit",        0, NULL, OPT_ENTRY_32BIT },     \
+       { "dtb",                1, NULL, OPT_DTB },
 
 #define KEXEC_ALL_OPT_STR KEXEC_ARCH_OPT_STR
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/i386/kexec-beoboot-x86.c 
new/kexec-tools-2.0.27/kexec/arch/i386/kexec-beoboot-x86.c
--- old/kexec-tools-2.0.26/kexec/arch/i386/kexec-beoboot-x86.c  2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/i386/kexec-beoboot-x86.c  2023-08-01 
08:52:18.000000000 +0200
@@ -125,7 +125,7 @@
                kernel,        bb_header.kernel_size,
                command_line,  bb_header.cmdline_size,
                initrd,        bb_header.initrd_size,
-               real_mode_entry);
+               0, 0, real_mode_entry);
 
        return result;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/i386/kexec-bzImage.c 
new/kexec-tools-2.0.27/kexec/arch/i386/kexec-bzImage.c
--- old/kexec-tools-2.0.26/kexec/arch/i386/kexec-bzImage.c      2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/i386/kexec-bzImage.c      2023-08-01 
08:52:18.000000000 +0200
@@ -95,6 +95,7 @@
                "    --reuse-cmdline       Use kernel command line from running 
system.\n"
                "    --initrd=FILE         Use FILE as the kernel's initial 
ramdisk.\n"
                "    --ramdisk=FILE        Use FILE as the kernel's initial 
ramdisk.\n"
+               "    --dtb=FILE            Use FILE as devicetree.\n"
                );
        
 }
@@ -103,6 +104,7 @@
        const char *kernel, off_t kernel_len,
        const char *command_line, off_t command_line_len,
        const char *initrd, off_t initrd_len,
+       const char *dtb, off_t dtb_len,
        int real_mode_entry)
 {
        struct x86_linux_header setup_header;
@@ -373,6 +375,10 @@
                setup_linux_system_parameters(info, real_mode);
        }
 
+       if (dtb) {
+               setup_linux_dtb(info, real_mode, dtb, dtb_len);
+       }
+
        return 0;
 }
        
@@ -381,13 +387,15 @@
 {
        char *command_line = NULL;
        char *tmp_cmdline = NULL;
-       const char *ramdisk, *append = NULL;
+       const char *ramdisk, *append = NULL, *dtb;
        char *ramdisk_buf;
        off_t ramdisk_length;
        int command_line_len;
        int real_mode_entry;
        int opt;
        int result;
+       char *dtb_buf;
+       off_t dtb_length;
 
        /* See options.h -- add any more there, too. */
        static const struct option options[] = {
@@ -398,6 +406,7 @@
                { "initrd",             1, 0, OPT_RAMDISK },
                { "ramdisk",            1, 0, OPT_RAMDISK },
                { "real-mode",          0, 0, OPT_REAL_MODE },
+               { "dtb",                1, 0, OPT_DTB },
                { 0,                    0, 0, 0 },
        };
        static const char short_options[] = KEXEC_ARCH_OPT_STR "d";
@@ -405,6 +414,8 @@
        real_mode_entry = 0;
        ramdisk = 0;
        ramdisk_length = 0;
+       dtb = 0;
+       dtb_length = 0;
        while((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) 
{
                switch(opt) {
                default:
@@ -424,6 +435,9 @@
                case OPT_REAL_MODE:
                        real_mode_entry = 1;
                        break;
+               case OPT_DTB:
+                       dtb = optarg;
+                       break;
                }
        }
        command_line = concat_cmdline(tmp_cmdline, append);
@@ -441,10 +455,15 @@
        if (ramdisk) {
                ramdisk_buf = slurp_file(ramdisk, &ramdisk_length);
        }
+       dtb_buf = 0;
+       if (dtb) {
+               dtb_buf = slurp_file(dtb, &dtb_length);
+       }
        result = do_bzImage_load(info,
                buf, len,
                command_line, command_line_len,
                ramdisk_buf, ramdisk_length,
+               dtb_buf, dtb_length,
                real_mode_entry);
 
        free(command_line);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/i386/kexec-x86.h 
new/kexec-tools-2.0.27/kexec/arch/i386/kexec-x86.h
--- old/kexec-tools-2.0.26/kexec/arch/i386/kexec-x86.h  2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/i386/kexec-x86.h  2023-08-01 
08:52:18.000000000 +0200
@@ -79,6 +79,7 @@
        const char *kernel, off_t kernel_len,
        const char *command_line, off_t command_line_len,
        const char *initrd, off_t initrd_len,
+       const char *dtb, off_t dtb_len,
        int real_mode_entry);
 
 int beoboot_probe(const char *buf, off_t len);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/i386/x86-linux-setup.c 
new/kexec-tools-2.0.27/kexec/arch/i386/x86-linux-setup.c
--- old/kexec-tools-2.0.26/kexec/arch/i386/x86-linux-setup.c    2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/i386/x86-linux-setup.c    2023-05-24 
13:47:18.000000000 +0200
@@ -954,3 +954,18 @@
        /* Always try to fill acpi_rsdp_addr */
        real_mode->acpi_rsdp_addr = get_acpi_rsdp();
 }
+
+void setup_linux_dtb(struct kexec_info *info, struct x86_linux_param_header 
*real_mode,
+                                  const char *dtb_buf, int dtb_len)
+{
+       struct setup_data *sd;
+
+       sd = xmalloc(sizeof(struct setup_data) + dtb_len);
+       sd->next = 0;
+       sd->len = dtb_len;
+       sd->type = SETUP_DTB;
+       memcpy(sd->data, dtb_buf, dtb_len);
+
+
+       add_setup_data(info, real_mode, sd);
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/i386/x86-linux-setup.h 
new/kexec-tools-2.0.27/kexec/arch/i386/x86-linux-setup.h
--- old/kexec-tools-2.0.26/kexec/arch/i386/x86-linux-setup.h    2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/i386/x86-linux-setup.h    2023-05-24 
13:47:18.000000000 +0200
@@ -21,6 +21,8 @@
 }
 void setup_linux_system_parameters(struct kexec_info *info,
        struct x86_linux_param_header *real_mode);
+void setup_linux_dtb(struct kexec_info *info, struct x86_linux_param_header 
*real_mode,
+                                  const char *dtb_buf, int dtb_len);
 int get_bootparam(void *buf, off_t offset, size_t size);
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/loongarch/crashdump-loongarch.c 
new/kexec-tools-2.0.27/kexec/arch/loongarch/crashdump-loongarch.c
--- old/kexec-tools-2.0.26/kexec/arch/loongarch/crashdump-loongarch.c   
2022-11-18 16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/loongarch/crashdump-loongarch.c   
2023-05-24 13:47:18.000000000 +0200
@@ -183,6 +183,28 @@
        return 0;
 }
 
+/*
+ * e_entry and p_paddr are actually in virtual address space.
+ * Those values will be translated to physcal addresses by using
+ * virt_to_phys() in add_segment().
+ * So let's fix up those values for later use so the memory base will be
+ * correctly replaced with crash_reserved_mem[usablemem_rgns.size - 1].start.
+ */
+void fixup_elf_addrs(struct mem_ehdr *ehdr)
+{
+       struct mem_phdr *phdr;
+       int i;
+
+       ehdr->e_entry += crash_reserved_mem[usablemem_rgns.size - 1].start;
+
+       for (i = 0; i < ehdr->e_phnum; i++) {
+               phdr = &ehdr->e_phdr[i];
+               if (phdr->p_type != PT_LOAD)
+                       continue;
+               phdr->p_paddr += crash_reserved_mem[usablemem_rgns.size - 
1].start;
+       }
+}
+
 int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
 {
        if (!usablemem_rgns.size)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/loongarch/crashdump-loongarch.h 
new/kexec-tools-2.0.27/kexec/arch/loongarch/crashdump-loongarch.h
--- old/kexec-tools-2.0.26/kexec/arch/loongarch/crashdump-loongarch.h   
2022-11-18 16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/loongarch/crashdump-loongarch.h   
2023-05-24 13:47:18.000000000 +0200
@@ -8,6 +8,7 @@
 
 int load_crashdump_segments(struct kexec_info *info);
 int is_crashkernel_mem_reserved(void);
+void fixup_elf_addrs(struct mem_ehdr *ehdr);
 int get_crash_kernel_load_range(uint64_t *start, uint64_t *end);
 
 #define PAGE_OFFSET    0x9000000000000000ULL
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/loongarch/kexec-elf-loongarch.c 
new/kexec-tools-2.0.27/kexec/arch/loongarch/kexec-elf-loongarch.c
--- old/kexec-tools-2.0.26/kexec/arch/loongarch/kexec-elf-loongarch.c   
2022-11-18 16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/loongarch/kexec-elf-loongarch.c   
2023-08-01 08:52:18.000000000 +0200
@@ -90,6 +90,14 @@
                }
        }
 
+       /* load the kernel */
+       if (info->kexec_flags & KEXEC_ON_CRASH)
+               /*
+                * offset addresses in elf header in order to load
+                * vmlinux (elf_exec) into crash kernel's memory.
+                */
+               fixup_elf_addrs(&ehdr);
+
        info->entry = (void *)virt_to_phys(ehdr.e_entry);
 
        result = elf_exec_load(&ehdr, info);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/loongarch/kexec-loongarch.c 
new/kexec-tools-2.0.27/kexec/arch/loongarch/kexec-loongarch.c
--- old/kexec-tools-2.0.26/kexec/arch/loongarch/kexec-loongarch.c       
2022-11-18 16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/loongarch/kexec-loongarch.c       
2023-05-24 13:47:18.000000000 +0200
@@ -253,7 +253,8 @@
                unsigned long hole_end;
 
                hole = (crash_reserved_mem[usablemem_rgns.size - 1].start < 
mem_min ?
-                               mem_min : 
crash_reserved_mem[usablemem_rgns.size - 1].start);
+                               mem_min : 
crash_reserved_mem[usablemem_rgns.size - 1].start) +
+                               loongarch_mem.text_offset;
                hole = _ALIGN_UP(hole, MiB(1));
                hole_end = hole + loongarch_mem.text_offset + 
loongarch_mem.image_size;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/loongarch/kexec-pei-loongarch.c 
new/kexec-tools-2.0.27/kexec/arch/loongarch/kexec-pei-loongarch.c
--- old/kexec-tools-2.0.26/kexec/arch/loongarch/kexec-pei-loongarch.c   
2022-11-18 16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/loongarch/kexec-pei-loongarch.c   
2023-08-01 08:52:18.000000000 +0200
@@ -66,6 +66,13 @@
 
        kernel_entry = virt_to_phys(loongarch_header_kernel_entry(header));
 
+       if (info->kexec_flags & KEXEC_ON_CRASH)
+               /*
+                * offset addresses in order to load vmlinux.efi into
+                * crash kernel's memory.
+                */
+               kernel_entry += crash_reserved_mem[usablemem_rgns.size - 
1].start;
+
        dbgprintf("%s: kernel_segment: %016lx\n", __func__, kernel_segment);
        dbgprintf("%s: kernel_entry:   %016lx\n", __func__, kernel_entry);
        dbgprintf("%s: image_size:     %016lx\n", __func__,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/ppc64/include/arch/options.h 
new/kexec-tools-2.0.27/kexec/arch/ppc64/include/arch/options.h
--- old/kexec-tools-2.0.26/kexec/arch/ppc64/include/arch/options.h      
2022-11-18 16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/ppc64/include/arch/options.h      
2023-05-24 13:47:18.000000000 +0200
@@ -10,6 +10,7 @@
 #define OPT_RAMDISK            (OPT_ARCH_MAX+1)
 #define OPT_DEVICETREEBLOB     (OPT_ARCH_MAX+2)
 #define OPT_ARGS_IGNORE                (OPT_ARCH_MAX+3)
+#define OPT_REUSE_CMDLINE      (OPT_ARCH_MAX+4)
 
 /* Options relevant to the architecture (excluding loader-specific ones): */
 #define KEXEC_ARCH_OPTIONS \
@@ -41,7 +42,8 @@
        { "initrd",             1, NULL, OPT_RAMDISK },         \
        { "devicetreeblob",     1, NULL, OPT_DEVICETREEBLOB },  \
        { "dtb",                1, NULL, OPT_DEVICETREEBLOB },  \
-       { "args-linux",         0, NULL, OPT_ARGS_IGNORE },
+       { "args-linux",         0, NULL, OPT_ARGS_IGNORE },     \
+       { "reuse-cmdline",      0, NULL, OPT_REUSE_CMDLINE },
 
 #define KEXEC_ALL_OPT_STR KEXEC_OPT_STR
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/ppc64/kexec-elf-ppc64.c 
new/kexec-tools-2.0.27/kexec/arch/ppc64/kexec-elf-ppc64.c
--- old/kexec-tools-2.0.26/kexec/arch/ppc64/kexec-elf-ppc64.c   2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/ppc64/kexec-elf-ppc64.c   2023-08-01 
08:52:18.000000000 +0200
@@ -95,6 +95,8 @@
 {
        int ret = 0;
        char *cmdline, *dtb;
+       char *append_cmdline = NULL;
+       char *reuse_cmdline = NULL;
        int opt, cmdline_len = 0;
 
        /* See options.h -- add any more there, too. */
@@ -107,6 +109,7 @@
                { "devicetreeblob",     1, NULL, OPT_DEVICETREEBLOB },
                { "dtb",                1, NULL, OPT_DEVICETREEBLOB },
                { "args-linux",         0, NULL, OPT_ARGS_IGNORE },
+               { "reuse-cmdline",      0, NULL, OPT_REUSE_CMDLINE},
                { 0,                    0, NULL, 0 },
        };
 
@@ -125,7 +128,7 @@
                        if (opt < OPT_ARCH_MAX)
                                break;
                case OPT_APPEND:
-                       cmdline = optarg;
+                       append_cmdline = optarg;
                        break;
                case OPT_RAMDISK:
                        ramdisk = optarg;
@@ -135,6 +138,9 @@
                        break;
                case OPT_ARGS_IGNORE:
                        break;
+               case OPT_REUSE_CMDLINE:
+                       reuse_cmdline = get_command_line();
+                       break;
                }
        }
 
@@ -144,6 +150,10 @@
        if (reuse_initrd)
                die("--reuseinitrd not supported with --kexec-file-syscall.\n");
 
+       cmdline = concat_cmdline(reuse_cmdline, append_cmdline);
+       if (!reuse_cmdline)
+               free(reuse_cmdline);
+
        if (cmdline) {
                cmdline_len = strlen(cmdline) + 1;
        } else {
@@ -175,6 +185,8 @@
 {
        struct mem_ehdr ehdr;
        char *cmdline, *modified_cmdline = NULL;
+       char *reuse_cmdline = NULL;
+       char *append_cmdline = NULL;
        const char *devicetreeblob;
        uint64_t max_addr, hole_addr;
        char *seg_buf = NULL;
@@ -204,6 +216,7 @@
                { "devicetreeblob",     1, NULL, OPT_DEVICETREEBLOB },
                { "dtb",                1, NULL, OPT_DEVICETREEBLOB },
                { "args-linux",         0, NULL, OPT_ARGS_IGNORE },
+               { "reuse-cmdline",      0, NULL, OPT_REUSE_CMDLINE},
                { 0,                    0, NULL, 0 },
        };
 
@@ -229,7 +242,7 @@
                        if (opt < OPT_ARCH_MAX)
                                break;
                case OPT_APPEND:
-                       cmdline = optarg;
+                       append_cmdline = optarg;
                        break;
                case OPT_RAMDISK:
                        ramdisk = optarg;
@@ -239,9 +252,16 @@
                        break;
                case OPT_ARGS_IGNORE:
                        break;
+               case OPT_REUSE_CMDLINE:
+                       reuse_cmdline = get_command_line();
+                       break;
                }
        }
 
+       cmdline = concat_cmdline(reuse_cmdline, append_cmdline);
+       if (!reuse_cmdline)
+               free(reuse_cmdline);
+
        if (!cmdline)
                fprintf(stdout, "Warning: append= option is not passed. Using 
the first kernel root partition\n");
 
@@ -469,6 +489,7 @@
        fprintf(stderr, "     --devicetreeblob=<filename> Specify device tree 
blob file.\n");
        fprintf(stderr, "                                 ");
        fprintf(stderr, "Not applicable while using --kexec-file-syscall.\n");
+       fprintf(stderr, "     --reuse-cmdline Use kernel command line from 
running system.\n");
        fprintf(stderr, "     --dtb=<filename> same as --devicetreeblob.\n");
 
        fprintf(stderr, "elf support is still broken\n");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/arch/x86_64/kexec-bzImage64.c 
new/kexec-tools-2.0.27/kexec/arch/x86_64/kexec-bzImage64.c
--- old/kexec-tools-2.0.26/kexec/arch/x86_64/kexec-bzImage64.c  2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/arch/x86_64/kexec-bzImage64.c  2023-08-01 
08:52:18.000000000 +0200
@@ -386,7 +386,7 @@
        if (entry_16bit || entry_32bit)
                result = do_bzImage_load(info, buf, len, command_line,
                                        command_line_len, ramdisk_buf,
-                                       ramdisk_length, entry_16bit);
+                                       ramdisk_length, 0, 0, entry_16bit);
        else
                result = do_bzImage64_load(info, buf, len, command_line,
                                        command_line_len, ramdisk_buf,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/kexec-pe-zboot.c 
new/kexec-tools-2.0.27/kexec/kexec-pe-zboot.c
--- old/kexec-tools-2.0.26/kexec/kexec-pe-zboot.c       1970-01-01 
01:00:00.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/kexec-pe-zboot.c       2023-08-11 
09:28:08.000000000 +0200
@@ -0,0 +1,131 @@
+/*
+ * Generic PE compressed Image (vmlinuz, ZBOOT) support.
+ *
+ * Several distros use 'make zinstall' with CONFIG_ZBOOT
+ * enabled to create UEFI PE images that contain
+ * a decompressor and a compressed kernel image.
+ *
+ * Currently we cannot use kexec_file_load() to load vmlinuz
+ * PE images that self decompress.
+ *
+ * To support ZBOOT, we should:
+ * a). Copy the compressed contents of vmlinuz to a temporary file.
+ * b). Decompress (gunzip-decompress) the contents inside the
+ *     temporary file.
+ * c). Validate the resulting image and write it back to the
+ *     temporary file.
+ * d). Pass the 'fd' of the temporary file to the kernel space.
+ *
+ * This module contains the arch independent code for the above,
+ * arch specific PE and image checks should wrap calls
+ * to functions in this module.
+ */
+
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "kexec.h"
+#include <kexec-pe-zboot.h>
+
+#define FILENAME_IMAGE         "/tmp/ImageXXXXXX"
+
+/*
+ * Returns -1 : in case of error/invalid format (not a valid PE+compressed 
ZBOOT format.
+ *
+ * crude_buf: the content, which is read from the kernel file without any 
processing
+ */
+int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd)
+{
+       int ret = -1;
+       int fd = 0;
+       char *fname = NULL;
+       char *kernel_uncompressed_buf = NULL;
+       off_t decompressed_size = 0;
+       const struct linux_pe_zboot_header *z;
+
+       z = (const struct linux_pe_zboot_header *)(crude_buf);
+
+       if (memcmp(&z->image_type, "zimg", sizeof(z->image_type))) {
+               dbgprintf("%s: PE doesn't contain a compressed kernel.\n", 
__func__);
+               return -1;
+       }
+
+       /*
+        * At the moment its possible to create images with more compression
+        * algorithms than are supported here, error out if we detect that.
+        */
+       if (memcmp(&z->compress_type, "gzip", 4) &&
+           memcmp(&z->compress_type, "lzma", 4)) {
+               dbgprintf("%s: kexec can only decompress gziped and lzma 
images.\n", __func__);
+               return -1;
+       }
+
+       if (buf_sz < z->payload_offset + z->payload_size) {
+               dbgprintf("%s: PE too small to contain complete payload.\n", 
__func__);
+               return -1;
+       }
+
+       if (!(fname = strdup(FILENAME_IMAGE))) {
+               dbgprintf("%s: Can't duplicate strings\n", __func__);
+               return -1;
+       }
+
+       if ((fd = mkstemp(fname)) < 0) {
+               dbgprintf("%s: Can't open file %s\n", __func__, fname);
+               ret = -1;
+               goto fail_mkstemp;
+       }
+
+       if (write(fd, &crude_buf[z->payload_offset],
+                 z->payload_size) != z->payload_size) {
+               dbgprintf("%s: Can't write the compressed file %s\n",
+                               __func__, fname);
+               ret = -1;
+               goto fail_write;
+       }
+
+       kernel_uncompressed_buf = slurp_decompress_file(fname,
+                                                       &decompressed_size);
+
+       dbgprintf("%s: decompressed size %ld\n", __func__, decompressed_size);
+
+       lseek(fd, 0, SEEK_SET);
+
+       if (write(fd,  kernel_uncompressed_buf,
+                 decompressed_size) != decompressed_size) {
+               dbgprintf("%s: Can't write the decompressed file %s\n",
+                               __func__, fname);
+               ret = -1;
+               goto fail_bad_header;
+       }
+
+       *kernel_fd = open(fname, O_RDONLY);
+       if (*kernel_fd == -1) {
+               dbgprintf("%s: Failed to open file %s\n",
+                               __func__, fname);
+               ret = -1;
+               goto fail_bad_header;
+       }
+
+       dbgprintf("%s: done\n", __func__);
+
+       ret = 0;
+       goto fail_write;
+
+fail_bad_header:
+       free(kernel_uncompressed_buf);
+
+fail_write:
+       if (fd >= 0)
+               close(fd);
+
+       unlink(fname);
+
+fail_mkstemp:
+       free(fname);
+
+       return ret;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/kexec-syscall.h 
new/kexec-tools-2.0.27/kexec/kexec-syscall.h
--- old/kexec-tools-2.0.26/kexec/kexec-syscall.h        2022-11-18 
16:11:40.000000000 +0100
+++ new/kexec-tools-2.0.27/kexec/kexec-syscall.h        2023-05-24 
13:47:18.000000000 +0200
@@ -59,7 +59,7 @@
 #endif
 #endif /*ifndef __NR_kexec_load*/
 
-#ifdef __arm__
+#if defined(__arm__) || defined(__loongarch__)
 #undef __NR_kexec_file_load
 #endif
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/kexec.8 new/kexec-tools-2.0.27/kexec/kexec.8
--- old/kexec-tools-2.0.26/kexec/kexec.8        2022-11-18 16:11:40.000000000 
+0100
+++ new/kexec-tools-2.0.27/kexec/kexec.8        2023-05-24 13:47:18.000000000 
+0200
@@ -151,14 +151,14 @@
 Specify that the new KEXEC_FILE_LOAD syscall should be used exclusively.
 .TP
 .BI \-c\ (\-\-kexec-syscall)
-Specify that the old KEXEC_LOAD syscall should be used exclusively (the 
default).
+Specify that the old KEXEC_LOAD syscall should be used exclusively.
 .TP
 .BI \-a\ (\-\-kexec-syscall-auto)
 Try the new KEXEC_FILE_LOAD syscall first and when it is not supported or the
 kernel does not understand the supplied image fall back to the old KEXEC_LOAD
 interface.
 
-There is no one single interface that always works.
+There is no one single interface that always works, so this is the default.
 
 KEXEC_FILE_LOAD is required on systems that use locked-down secure boot to
 verify the kernel signature.  KEXEC_LOAD may be also disabled in the kernel
@@ -335,6 +335,37 @@
 .I "arg1 arg2 ..."
 This parameter can be specified multiple times.
 .RE
+.PP
+.B elf-ppc64
+.RS
+.TP
+.BI \-\-reuse-cmdline
+Use the kernel command line from the running system.
+.TP
+.BI \-\-command\-line= string
+Set the kernel command line to
+.IR string.
+.TP
+.BI \-\-append= string
+Set the kernel command line to
+.IR string.
+.TP
+.BI \-\-ramdisk= file
+Use
+.IR file
+as the initial RAM disk.
+.TP
+.BI \-\-initrd= file
+Use
+.IR file
+as the initial RAM disk.
+.TP
+.BI \-\-devicetreeblob= file
+Specify device tree blob file. Not applicable while using --kexec-file-syscall.
+.TP
+.BI \-\-dtb= file
+Specify device tree blob file. Not applicable while using --kexec-file-syscall.
+.RE
 
 .SH ARCHITECTURE OPTIONS
 .TP
@@ -362,3 +393,7 @@
 Specify the
 .I baud rate
 of the serial port.
+.TP
+.BI \-\-dt\-no\-old\-root
+Do not reuse old kernel root=<device>
+param while creating flatten device tree.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/kexec.c new/kexec-tools-2.0.27/kexec/kexec.c
--- old/kexec-tools-2.0.26/kexec/kexec.c        2022-11-18 16:11:40.000000000 
+0100
+++ new/kexec-tools-2.0.27/kexec/kexec.c        2023-08-11 09:28:08.000000000 
+0200
@@ -638,6 +638,21 @@
        return kernel_buf;
 }
 
+static int copybuf_memfd(const char *kernel_buf, size_t size)
+{
+       int fd, count;
+
+       fd = memfd_create("kernel", MFD_ALLOW_SEALING);
+       if (fd == -1)
+               return fd;
+
+       count = write(fd, kernel_buf, size);
+       if (count < 0)
+               return -1;
+
+       return fd;
+}
+
 static void update_purgatory(struct kexec_info *info)
 {
        static const uint8_t null_buf[256];
@@ -1049,11 +1064,11 @@
               "                      to original kernel.\n"
               " -s, --kexec-file-syscall Use file based syscall for kexec 
operation\n"
               " -c, --kexec-syscall  Use the kexec_load syscall for for 
compatibility\n"
-              "                      with systems that don't support -s 
(default)\n"
+              "                      with systems that don't support -s\n"
               " -a, --kexec-syscall-auto  Use file based syscall for kexec and 
fall\n"
               "                      back to the compatibility syscall when 
file based\n"
               "                      syscall is not supported or the kernel 
did not\n"
-              "                      understand the image\n"
+              "                      understand the image (default)\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"
@@ -1277,6 +1292,7 @@
        info.kexec_flags = flags;
 
        info.file_mode = 1;
+       info.kernel_fd = -1;
        info.initrd_fd = -1;
 
        if (!is_kexec_file_load_implemented())
@@ -1290,31 +1306,22 @@
 
        kernel = argv[fileind];
 
-       kernel_fd = open(kernel, O_RDONLY);
-       if (kernel_fd == -1) {
-               fprintf(stderr, "Failed to open file %s:%s\n", kernel,
+       /* slurp in the input kernel */
+       kernel_buf = slurp_decompress_file(kernel, &kernel_size);
+       if (!kernel_buf) {
+               fprintf(stderr, "Failed to decompress file %s:%s\n", kernel,
                                strerror(errno));
                return EFAILED;
        }
-
-       /* slurp in the input kernel */
-       kernel_buf = slurp_decompress_file(kernel, &kernel_size);
+       kernel_fd = copybuf_memfd(kernel_buf, kernel_size);
+       if (kernel_fd < 0) {
+               fprintf(stderr, "Failed to copy decompressed buf\n");
+               return EFAILED;
+       }
 
        for (i = 0; i < file_types; i++) {
-#ifdef __aarch64__
-               /* handle Image.gz like cases */
-               if (is_zlib_file(kernel, &kernel_size)) {
-                       if ((ret = file_type[i].probe(kernel, kernel_size)) >= 
0) {
-                               kernel_fd = ret;
-                               break;
-                       }
-               } else
-                       if (file_type[i].probe(kernel_buf, kernel_size) >= 0)
-                               break;
-#else
                if (file_type[i].probe(kernel_buf, kernel_size) >= 0)
                        break;
-#endif
        }
 
        if (i == file_types) {
@@ -1331,6 +1338,13 @@
                return ret;
        }
 
+       /*
+       * image type specific load functioin detect the capsule kernel type
+       * and create another fd for file load. For example the zboot kernel.
+       */
+       if (info.kernel_fd != -1)
+               kernel_fd = info.kernel_fd;
+
        /*
         * If there is no initramfs, set KEXEC_FILE_NO_INITRAMFS flag so that
         * kernel does not return error with negative initrd_fd.
@@ -1407,8 +1421,8 @@
        int do_ifdown = 0, skip_ifdown = 0;
        int do_unload = 0;
        int do_reuse_initrd = 0;
-       int do_kexec_file_syscall = 0;
-       int do_kexec_fallback = 0;
+       int do_kexec_file_syscall = 1;
+       int do_kexec_fallback = 1;
        int skip_checks = 0;
        int do_status = 0;
        void *entry = 0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec/kexec.h new/kexec-tools-2.0.27/kexec/kexec.h
--- old/kexec-tools-2.0.26/kexec/kexec.h        2022-11-18 16:11:40.000000000 
+0100
+++ new/kexec-tools-2.0.27/kexec/kexec.h        2023-08-11 09:28:08.000000000 
+0200
@@ -164,6 +164,7 @@
        unsigned long file_mode :1;
 
        /* Filled by kernel image processing code */
+       int kernel_fd;
        int initrd_fd;
        char *command_line;
        int command_line_len;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/kexec-tools-2.0.26/kexec-tools.spec new/kexec-tools-2.0.27/kexec-tools.spec
--- old/kexec-tools-2.0.26/kexec-tools.spec     2022-12-21 16:30:24.000000000 
+0100
+++ new/kexec-tools-2.0.27/kexec-tools.spec     2023-08-28 09:53:33.000000000 
+0200
@@ -1,6 +1,6 @@
 Summary: Load one kernel from another
 Name: kexec-tools
-Version: 2.0.26
+Version: 2.0.27
 Release: 0
 License: GPL
 Group: Development/Tools

Reply via email to