Skip to contentSkip to conversation

arm64: zboot support

PATCH Superseded Pingfan Liu 2 participants 13 messages Jul 24, 2023 – Aug 3, 2023

Subsystems (2)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover arm64: zboot support

As more complicated capsule kernel format occurs like zboot, where the compressed kernel is stored as a payload. The straight forward decompression can not meet the demand.

As the first step, on aarch64, reading in the kernel file in a probe method and decide how to unfold the content by the method itself.

This series consists of two parts
[1/5], simplify the current aarch64 image probe
[2-5/5], return the kernel fd by the image load interface, and let the handling of zboot image built on it. (Thanks for Dave Young, who contributes the original idea and the code)

To ease the review, a branch is accessable at https://github.com/pfliu/kexec-tools.git
branch zbootV6

To: [email protected]
Cc: Dave Young <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
v5 -> v6
introduce kexec_info.kernel_fd and return the fd through image load
interface.

Jeremy Linton (3):
kexec/zboot: Add arch independent zboot support
arm64: Add ZBOOT PE containing compressed image support
arm64: Hook up the ZBOOT support as vmlinuz

Pingfan Liu (2):
kexec/arm64: Simplify the code for zImage
kexec: Introduce a member kernel_fd in kexec_info

 include/kexec-pe-zboot.h               |  15 ++
 kexec/Makefile                         |   1 +
 kexec/arch/arm64/Makefile              |   2 +-
 kexec/arch/arm64/image-header.h        |   1 +
 kexec/arch/arm64/kexec-arm64.c         |   2 +-
 kexec/arch/arm64/kexec-arm64.h         |   8 +-
 kexec/arch/arm64/kexec-image-arm64.c   |   2 +-
 kexec/arch/arm64/kexec-vmlinuz-arm64.c | 110 ++++++++++++
 kexec/arch/arm64/kexec-zImage-arm64.c  | 226 -------------------------
 kexec/kexec-pe-zboot.c                 | 131 ++++++++++++++
 kexec/kexec.c                          |  50 ++++--
 kexec/kexec.h                          |   1 +
 12 files changed, 298 insertions(+), 251 deletions(-)
 create mode 100644 include/kexec-pe-zboot.h
 create mode 100644 kexec/arch/arm64/kexec-vmlinuz-arm64.c
 delete mode 100644 kexec/arch/arm64/kexec-zImage-arm64.c
 create mode 100644 kexec/kexec-pe-zboot.c
Signature · 7 lines
2.31.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

PATCH v6 1/5 kexec/arm64: Simplify the code for zImage

Inside zimage_probe(), it uncompresses the kernel and performs some check, similar to image_probe(). Taking a close look, the uncompressing has already executed before the image probe is called. What is missing here is to provide a fd, pointing to an uncompressed kernel image.

This patch creates a memfd based on the result produced by slurp_decompress_file(), and finally simplify the logical of the probe for aarch64.

The credit goes to the Dave Young, who contributes the original code.

To: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 kexec/arch/arm64/Makefile             |   3 +-
 kexec/arch/arm64/kexec-arm64.c        |   1 -
 kexec/arch/arm64/kexec-arm64.h        |   6 -
 kexec/arch/arm64/kexec-image-arm64.c  |   2 +-
 kexec/arch/arm64/kexec-zImage-arm64.c | 226 --------------------------
 kexec/kexec.c                         |  42 +++--
 6 files changed, 26 insertions(+), 254 deletions(-)
 delete mode 100644 kexec/arch/arm64/kexec-zImage-arm64.c
kexec/arch/arm64/Makefile +1 -2
index d27c8ee..9d9111c 100644
@@ -15,8 +15,7 @@ arm64_KEXEC_SRCS += \
 	kexec/arch/arm64/kexec-arm64.c \
 	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-image-arm64.c
 
 arm64_UIMAGE = kexec/kexec-uImage.c
 
kexec/arch/arm64/kexec-arm64.c +0 -1
index ec6df4b..a830ec7 100644
@@ -74,7 +74,6 @@ struct file_type file_type[] = {
 	{"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},
 };
 
 int file_types = sizeof(file_type) / sizeof(file_type[0]);
kexec/arch/arm64/kexec-arm64.h +0 -6
index 5eb9fc0..d29b1b3 100644
@@ -44,12 +44,6 @@ int uImage_arm64_load(int argc, char **argv, const char *buf, off_t len,
 		      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);
-
-
 extern off_t initrd_base;
 extern off_t initrd_size;
 
kexec/arch/arm64/kexec-image-arm64.c +1 -1
index aa8f2e2..a196747 100644
@@ -114,6 +114,6 @@ exit:
 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");
 }
kexec/arch/arm64/kexec-zImage-arm64.c deleted +0 -226

226 lines not on this page · raw message

kexec/kexec.c +24 -18

61 lines not on this page · raw message

Signature · 7 lines
2.31.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#2 lore raw

PATCH v6 2/5 kexec: Introduce a member kernel_fd in kexec_info

In reply to Pingfan Liu

Utilize the image load interface to export the kernel fd, which points to the uncompressed kernel and will be passed to kexec_file_load.

The credit goes to the Dave Young, who contributes the original code.

To: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 kexec/kexec.c | 8 ++++++++
 kexec/kexec.h | 1 +
 2 files changed, 9 insertions(+)
kexec/kexec.c +8 -0
index d132eb5..c3b182e 100644
@@ -1292,6 +1292,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,
 	info.kexec_flags = flags;
 
 	info.file_mode = 1;
+	info.kernel_fd = -1;
 	info.initrd_fd = -1;
 
 	if (!is_kexec_file_load_implemented())
@@ -1337,6 +1338,13 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,
 		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.
kexec/kexec.h +1 -0
index 0d820ad..ed3b499 100644
@@ -164,6 +164,7 @@ struct kexec_info {
 	unsigned long file_mode :1;
 
 	/* Filled by kernel image processing code */
+	int kernel_fd;
 	int initrd_fd;
 	char *command_line;
 	int command_line_len;
Signature · 7 lines
2.31.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#3 lore raw

PATCH v6 3/5 kexec/zboot: Add arch independent zboot support

In reply to Pingfan Liu

From: Jeremy Linton <[email protected]>

The linux kernel CONFIG_ZBOOT option creates self decompressing PE kernel images. So this means that kexec should have a generic understanding of the format which may be used by multiple arches.

So lets add an arch independent validation
and decompression routine.

[Modified by Pingfan to export kernel fd]

To: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 include/kexec-pe-zboot.h |  15 +++++
 kexec/Makefile           |   1 +
 kexec/kexec-pe-zboot.c   | 131 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+)
 create mode 100644 include/kexec-pe-zboot.h
 create mode 100644 kexec/kexec-pe-zboot.c
include/kexec-pe-zboot.h new file +15 -0
new file mode 100644
index 0000000..c588ca2
@@ -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
kexec/Makefile +1 -0
index 8a52e8d..11682bf 100644
@@ -17,6 +17,7 @@ KEXEC_SRCS_base += kexec/kexec-elf-exec.c
 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
kexec/kexec-pe-zboot.c new file +131 -0

131 lines not on this page · raw message

Signature · 7 lines
2.31.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#4 lore raw

Re: [PATCHv6 3/5] kexec/zboot: Add arch independent zboot support

Quoted 7 lines · Pingfan Liu

From: Jeremy Linton <[email protected]>

The linux kernel CONFIG_ZBOOT option creates self decompressing PE kernel images. So this means that kexec should have a generic understanding of the format which may be used by multiple arches.

Quoted 6 lines

So lets add an arch independent validation and decompression routine.

[Modified by Pingfan to export kernel fd]

Hi Pingfan,

unfortunately this causes a build failure on hppa.

../../kexec/kexec-pe-zboot.c:31:10: fatal error: kexec-pe-zboot.h: No such file or directory
31 | #include <kexec-pe-zboot.h>

      |          ^~~~~~~~~~~~~~~~~~

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#5 lore raw

Re: [PATCHv6 3/5] kexec/zboot: Add arch independent zboot support

Hi Simon,

Thanks for the try. Please see the comment below.

Quoted 18 lines · Simon Horman
Quoted 7 lines · Pingfan Liu

From: Jeremy Linton <[email protected]>

The linux kernel CONFIG_ZBOOT option creates self decompressing PE kernel images. So this means that kexec should have a generic understanding of the format which may be used by multiple arches.

Quoted 6 lines

So lets add an arch independent validation and decompression routine.

[Modified by Pingfan to export kernel fd]

Hi Pingfan,

Quoted 8 lines

unfortunately this causes a build failure on hppa.

../../kexec/kexec-pe-zboot.c:31:10: fatal error: kexec-pe-zboot.h: No such file or directory
31 | #include <kexec-pe-zboot.h>

      |          ^~~~~~~~~~~~~~~~~~

It is not related to cross-compiling. Actually, I have tried to simplify the test matrix, which limits the compilation only on x86_64. And I got the similar error [1]

The workflow control file is [2], which clips out all arches except x86_64. But I can successfully build it on the Fedora system with the following bash script, which is based on the github's build log. So maybe it is a bug with the compiling tools?

kexec_tools_dir="./"

mkdir $kexec_tools_dir/_build \
         $kexec_tools_dir/_build/sub \
         $kexec_tools_dir/_inst \
         $kexec_tools_dir/_dest
chmod a-w $kexec_tools_dir
test -d $kexec_tools_dir/_build
INSTALL_BASE=$(cd $kexec_tools_dir/_inst && pwd | sed -e
's,^[^:\\/]:[\\/],/,') &&\
        DESTDIR="$kexec_tools_dir/_dest" && \
        cd $kexec_tools_dir/_build/sub && \
                ../../configure \
                 \
                --srcdir=../.. --prefix="$INSTALL_BASE" && \
        make  -j8

[1]: https://github.com/pfliu/kexec-tools/actions/runs/5737254109/job/15548520863
[2]: https://github.com/pfliu/kexec-tools/blob/zbootV6/.github/workflows/main.yml

Thanks,

Pingfan

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw

Re: [PATCHv6 3/5] kexec/zboot: Add arch independent zboot support

Quoted 59 lines · Pingfan Liu

Hi Simon,

Thanks for the try. Please see the comment below.

Quoted 18 lines · Simon Horman
Quoted 7 lines · Pingfan Liu

From: Jeremy Linton <[email protected]>

The linux kernel CONFIG_ZBOOT option creates self decompressing PE kernel images. So this means that kexec should have a generic understanding of the format which may be used by multiple arches.

Quoted 6 lines

So lets add an arch independent validation and decompression routine.

[Modified by Pingfan to export kernel fd]

Hi Pingfan,

Quoted 8 lines

unfortunately this causes a build failure on hppa.

../../kexec/kexec-pe-zboot.c:31:10: fatal error: kexec-pe-zboot.h: No such file or directory
31 | #include <kexec-pe-zboot.h>

      |          ^~~~~~~~~~~~~~~~~~

It is not related to cross-compiling. Actually, I have tried to simplify the test matrix, which limits the compilation only on x86_64. And I got the similar error [1]

The workflow control file is [2], which clips out all arches except x86_64. But I can successfully build it on the Fedora system with the following bash script, which is based on the github's build log. So maybe it is a bug with the compiling tools?

kexec_tools_dir="./"

mkdir $kexec_tools_dir/_build \
         $kexec_tools_dir/_build/sub \
         $kexec_tools_dir/_inst \
         $kexec_tools_dir/_dest
chmod a-w $kexec_tools_dir
test -d $kexec_tools_dir/_build
INSTALL_BASE=$(cd $kexec_tools_dir/_inst && pwd | sed -e
's,^[^:\\/]:[\\/],/,') &&\
        DESTDIR="$kexec_tools_dir/_dest" && \
        cd $kexec_tools_dir/_build/sub && \
                ../../configure \
                 \
                --srcdir=../.. --prefix="$INSTALL_BASE" && \
        make  -j8
Quoted 2 lines

[1]: https://github.com/pfliu/kexec-tools/actions/runs/5737254109/job/15548520863
[2]: https://github.com/pfliu/kexec-tools/blob/zbootV6/.github/workflows/main.yml

Thanks,

I guess that kexec-pe-zboot.h is missing in the build environment for the GitHub actions, but present in your Fedora environment.

Could you take a look and see where your copy of kexec-pe-zboot.h came from?

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#7 lore raw

Re: [PATCHv6 3/5] kexec/zboot: Add arch independent zboot support

Quoted 63 lines · Simon Horman
Quoted 59 lines · Pingfan Liu

Hi Simon,

Thanks for the try. Please see the comment below.

Quoted 18 lines · Simon Horman
Quoted 7 lines · Pingfan Liu

From: Jeremy Linton <[email protected]>

The linux kernel CONFIG_ZBOOT option creates self decompressing PE kernel images. So this means that kexec should have a generic understanding of the format which may be used by multiple arches.

Quoted 6 lines

So lets add an arch independent validation and decompression routine.

[Modified by Pingfan to export kernel fd]

Hi Pingfan,

Quoted 8 lines

unfortunately this causes a build failure on hppa.

../../kexec/kexec-pe-zboot.c:31:10: fatal error: kexec-pe-zboot.h: No such file or directory
31 | #include <kexec-pe-zboot.h>

      |          ^~~~~~~~~~~~~~~~~~

It is not related to cross-compiling. Actually, I have tried to simplify the test matrix, which limits the compilation only on x86_64. And I got the similar error [1]

The workflow control file is [2], which clips out all arches except x86_64. But I can successfully build it on the Fedora system with the following bash script, which is based on the github's build log. So maybe it is a bug with the compiling tools?

kexec_tools_dir="./"

mkdir $kexec_tools_dir/_build \
         $kexec_tools_dir/_build/sub \
         $kexec_tools_dir/_inst \
         $kexec_tools_dir/_dest
chmod a-w $kexec_tools_dir
test -d $kexec_tools_dir/_build
INSTALL_BASE=$(cd $kexec_tools_dir/_inst && pwd | sed -e
's,^[^:\\/]:[\\/],/,') &&\
        DESTDIR="$kexec_tools_dir/_dest" && \
        cd $kexec_tools_dir/_build/sub && \
                ../../configure \
                 \
                --srcdir=../.. --prefix="$INSTALL_BASE" && \
        make  -j8
Quoted 2 lines

[1]: https://github.com/pfliu/kexec-tools/actions/runs/5737254109/job/15548520863
[2]: https://github.com/pfliu/kexec-tools/blob/zbootV6/.github/workflows/main.yml

Quoted 7 lines

Thanks,

I guess that kexec-pe-zboot.h is missing in the build environment for the GitHub actions, but present in your Fedora environment.

Could you take a look and see where your copy of kexec-pe-zboot.h came from?

Actually it seems to be added by this patch (sorry for not noticing)! So I guess it is an include path problem.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#8 lore raw

Re: [PATCHv6 3/5] kexec/zboot: Add arch independent zboot support

Quoted 66 lines · Simon Horman
Quoted 65 lines · Simon Horman
Quoted 59 lines · Pingfan Liu

Hi Simon,

Thanks for the try. Please see the comment below.

Quoted 18 lines · Simon Horman
Quoted 7 lines · Pingfan Liu

From: Jeremy Linton <[email protected]>

The linux kernel CONFIG_ZBOOT option creates self decompressing PE kernel images. So this means that kexec should have a generic understanding of the format which may be used by multiple arches.

Quoted 6 lines

So lets add an arch independent validation and decompression routine.

[Modified by Pingfan to export kernel fd]

Hi Pingfan,

Quoted 8 lines

unfortunately this causes a build failure on hppa.

../../kexec/kexec-pe-zboot.c:31:10: fatal error: kexec-pe-zboot.h: No such file or directory
31 | #include <kexec-pe-zboot.h>

      |          ^~~~~~~~~~~~~~~~~~

It is not related to cross-compiling. Actually, I have tried to simplify the test matrix, which limits the compilation only on x86_64. And I got the similar error [1]

The workflow control file is [2], which clips out all arches except x86_64. But I can successfully build it on the Fedora system with the following bash script, which is based on the github's build log. So maybe it is a bug with the compiling tools?

kexec_tools_dir="./"

mkdir $kexec_tools_dir/_build \
         $kexec_tools_dir/_build/sub \
         $kexec_tools_dir/_inst \
         $kexec_tools_dir/_dest
chmod a-w $kexec_tools_dir
test -d $kexec_tools_dir/_build
INSTALL_BASE=$(cd $kexec_tools_dir/_inst && pwd | sed -e
's,^[^:\\/]:[\\/],/,') &&\
        DESTDIR="$kexec_tools_dir/_dest" && \
        cd $kexec_tools_dir/_build/sub && \
                ../../configure \
                 \
                --srcdir=../.. --prefix="$INSTALL_BASE" && \
        make  -j8
Quoted 2 lines

[1]: https://github.com/pfliu/kexec-tools/actions/runs/5737254109/job/15548520863
[2]: https://github.com/pfliu/kexec-tools/blob/zbootV6/.github/workflows/main.yml

Thanks,

Quoted 8 lines
Quoted 5 lines

I guess that kexec-pe-zboot.h is missing in the build environment for the GitHub actions, but present in your Fedora environment.

Could you take a look and see where your copy of kexec-pe-zboot.h came from?

Actually it seems to be added by this patch (sorry for not noticing)! So I guess it is an include path problem.

I think I have found the problem.
The kexec-tools build system is a bit unusual,
and the new file, kexec-pe-zboot.h, was not included in distribution tarballs. Thus the build failures.

I think you can resolve that by squashing the following into this patch.

include/Makefile +1 -0
@@ -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		\

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#9 lore raw

Re: [PATCHv6 3/5] kexec/zboot: Add arch independent zboot support

Quoted 74 lines · Simon Horman
Quoted 72 lines · Simon Horman
Quoted 70 lines · Simon Horman
Quoted 59 lines · Pingfan Liu

Hi Simon,

Thanks for the try. Please see the comment below.

Quoted 18 lines · Simon Horman
Quoted 7 lines · Pingfan Liu

From: Jeremy Linton <[email protected]>

The linux kernel CONFIG_ZBOOT option creates self decompressing PE kernel images. So this means that kexec should have a generic understanding of the format which may be used by multiple arches.

Quoted 6 lines

So lets add an arch independent validation and decompression routine.

[Modified by Pingfan to export kernel fd]

Hi Pingfan,

Quoted 8 lines

unfortunately this causes a build failure on hppa.

../../kexec/kexec-pe-zboot.c:31:10: fatal error: kexec-pe-zboot.h: No such file or directory
31 | #include <kexec-pe-zboot.h>

      |          ^~~~~~~~~~~~~~~~~~

It is not related to cross-compiling. Actually, I have tried to simplify the test matrix, which limits the compilation only on x86_64. And I got the similar error [1]

The workflow control file is [2], which clips out all arches except x86_64. But I can successfully build it on the Fedora system with the following bash script, which is based on the github's build log. So maybe it is a bug with the compiling tools?

kexec_tools_dir="./"

mkdir $kexec_tools_dir/_build \
         $kexec_tools_dir/_build/sub \
         $kexec_tools_dir/_inst \
         $kexec_tools_dir/_dest
chmod a-w $kexec_tools_dir
test -d $kexec_tools_dir/_build
INSTALL_BASE=$(cd $kexec_tools_dir/_inst && pwd | sed -e
's,^[^:\\/]:[\\/],/,') &&\
        DESTDIR="$kexec_tools_dir/_dest" && \
        cd $kexec_tools_dir/_build/sub && \
                ../../configure \
                 \
                --srcdir=../.. --prefix="$INSTALL_BASE" && \
        make  -j8
Quoted 2 lines

[1]: https://github.com/pfliu/kexec-tools/actions/runs/5737254109/job/15548520863
[2]: https://github.com/pfliu/kexec-tools/blob/zbootV6/.github/workflows/main.yml

Thanks,

I guess that kexec-pe-zboot.h is missing in the build environment for the GitHub actions, but present in your Fedora environment.

Could you take a look and see where your copy of kexec-pe-zboot.h came from?

Quoted 8 lines
Quoted 2 lines

Actually it seems to be added by this patch (sorry for not noticing)! So I guess it is an include path problem.

I think I have found the problem.
The kexec-tools build system is a bit unusual,
and the new file, kexec-pe-zboot.h, was not included in distribution tarballs. Thus the build failures.

Unexpectedly, and thank for your insight.

Quoted 7 lines

I think you can resolve that by squashing the following into this patch.

include/Makefile line 7

Quoted 7 lines
include/Makefile +1 -0
@@ -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           \

After applying this patch, the github workflow successfully finished. I will send out V7 immediately.

Appreciate for your kind help again.

Thanks,

Pingfan

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#10 lore raw

Re: [PATCHv6 3/5] kexec/zboot: Add arch independent zboot support

Quoted 104 lines · Pingfan Liu
Quoted 74 lines · Simon Horman
Quoted 72 lines · Simon Horman
Quoted 70 lines · Simon Horman
Quoted 59 lines · Pingfan Liu

Hi Simon,

Thanks for the try. Please see the comment below.

Quoted 18 lines · Simon Horman
Quoted 7 lines · Pingfan Liu

From: Jeremy Linton <[email protected]>

The linux kernel CONFIG_ZBOOT option creates self decompressing PE kernel images. So this means that kexec should have a generic understanding of the format which may be used by multiple arches.

Quoted 6 lines

So lets add an arch independent validation and decompression routine.

[Modified by Pingfan to export kernel fd]

Hi Pingfan,

Quoted 8 lines

unfortunately this causes a build failure on hppa.

../../kexec/kexec-pe-zboot.c:31:10: fatal error: kexec-pe-zboot.h: No such file or directory
31 | #include <kexec-pe-zboot.h>

      |          ^~~~~~~~~~~~~~~~~~

It is not related to cross-compiling. Actually, I have tried to simplify the test matrix, which limits the compilation only on x86_64. And I got the similar error [1]

The workflow control file is [2], which clips out all arches except x86_64. But I can successfully build it on the Fedora system with the following bash script, which is based on the github's build log. So maybe it is a bug with the compiling tools?

kexec_tools_dir="./"

mkdir $kexec_tools_dir/_build \
         $kexec_tools_dir/_build/sub \
         $kexec_tools_dir/_inst \
         $kexec_tools_dir/_dest
chmod a-w $kexec_tools_dir
test -d $kexec_tools_dir/_build
INSTALL_BASE=$(cd $kexec_tools_dir/_inst && pwd | sed -e
's,^[^:\\/]:[\\/],/,') &&\
        DESTDIR="$kexec_tools_dir/_dest" && \
        cd $kexec_tools_dir/_build/sub && \
                ../../configure \
                 \
                --srcdir=../.. --prefix="$INSTALL_BASE" && \
        make  -j8
Quoted 2 lines

[1]: https://github.com/pfliu/kexec-tools/actions/runs/5737254109/job/15548520863
[2]: https://github.com/pfliu/kexec-tools/blob/zbootV6/.github/workflows/main.yml

Thanks,

I guess that kexec-pe-zboot.h is missing in the build environment for the GitHub actions, but present in your Fedora environment.

Could you take a look and see where your copy of kexec-pe-zboot.h came from?

Quoted 8 lines
Quoted 2 lines

Actually it seems to be added by this patch (sorry for not noticing)! So I guess it is an include path problem.

I think I have found the problem.
The kexec-tools build system is a bit unusual,
and the new file, kexec-pe-zboot.h, was not included in distribution tarballs. Thus the build failures.

Unexpectedly, and thank for your insight.

Quoted 7 lines

I think you can resolve that by squashing the following into this patch.

include/Makefile line 7

Quoted 7 lines
include/Makefile +1 -0
@@ -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           \

After applying this patch, the github workflow successfully finished. I will send out V7 immediately.

Quoted 1 line

Appreciate for your kind help again.

Thanks, I see v7 now.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#11 lore raw

PATCH v6 4/5 arm64: Add ZBOOT PE containing compressed image support

In reply to Pingfan Liu

From: Jeremy Linton <[email protected]>

The kernel EFI stub ZBOOT feature creates a PE that contains a compressed linux kernel image. The stub when run in a valid UEFI environment then decompresses the resulting image and executes it.

Support these image formats with kexec as well to avoid having to keep an alternate kernel image around.

This patch adds a the _probe(), _load() and usage() routines needed for kexec to understand this format.

[Modified by Pingfan to export kernel fd with load method]

To: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 kexec/arch/arm64/image-header.h        |   1 +
 kexec/arch/arm64/kexec-vmlinuz-arm64.c | 110 +++++++++++++++++++++++++
 2 files changed, 111 insertions(+)
 create mode 100644 kexec/arch/arm64/kexec-vmlinuz-arm64.c
kexec/arch/arm64/image-header.h +1 -0
index 158d411..26bb02f 100644
@@ -37,6 +37,7 @@ struct arm64_image_header {
 
 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);
kexec/arch/arm64/kexec-vmlinuz-arm64.c new file +110 -0

110 lines not on this page · raw message

Signature · 7 lines
2.31.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#12 lore raw

PATCH v6 5/5 arm64: Hook up the ZBOOT support as vmlinuz

In reply to Pingfan Liu

From: Jeremy Linton <[email protected]>

Add the previously defined _probe() and _usage() routines to the kexec file types table, and build the new module.

It should be noted that this "vmlinuz" support reuses the "Image" support to actually load the resulting image after it has been decompressed to a temporary file.

To: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 kexec/arch/arm64/Makefile      | 3 ++-
 kexec/arch/arm64/kexec-arm64.c | 1 +
 kexec/arch/arm64/kexec-arm64.h | 6 ++++++
 3 files changed, 9 insertions(+), 1 deletion(-)
kexec/arch/arm64/Makefile +2 -1
index 9d9111c..59212f1 100644
@@ -15,7 +15,8 @@ arm64_KEXEC_SRCS += \
 	kexec/arch/arm64/kexec-arm64.c \
 	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-image-arm64.c \
+	kexec/arch/arm64/kexec-vmlinuz-arm64.c
 
 arm64_UIMAGE = kexec/kexec-uImage.c
 
kexec/arch/arm64/kexec-arm64.c +1 -0
index a830ec7..4a67b0d 100644
@@ -74,6 +74,7 @@ struct file_type file_type[] = {
 	{"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},
+	{"vmlinuz", pez_arm64_probe, pez_arm64_load, pez_arm64_usage},
 };
 
 int file_types = sizeof(file_type) / sizeof(file_type[0]);
kexec/arch/arm64/kexec-arm64.h +6 -0
index d29b1b3..95fb5c2 100644
@@ -44,6 +44,12 @@ int uImage_arm64_load(int argc, char **argv, const char *buf, off_t len,
 		      struct kexec_info *info);
 void uImage_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;
 extern off_t initrd_size;
 
Signature · 7 lines
2.31.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec