Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] zboot: enable arm64 kexec_load for zboot image
@ 2023-09-11 18:37 Dave Young
  2023-09-11 18:37 ` [PATCH 2/2] zboot: add loongarch kexec_load support Dave Young
  2023-09-13  0:54 ` [PATCH 1/2] zboot: enable arm64 kexec_load for zboot image Pingfan Liu
  0 siblings, 2 replies; 4+ messages in thread
From: Dave Young @ 2023-09-11 18:37 UTC (permalink / raw)
  To: kexec; +Cc: Simon Horman, Pingfan Liu

kexec_file_load support of zboot kernel image decompressed the vmlinuz,
so in kexec_load code just load the kernel with reading the decompressed
kernel fd into a new buffer and use it directly.

Signed-off-by: Dave Young <dyoung@redhat.com>
---
 include/kexec-pe-zboot.h               |  3 ++-
 kexec/arch/arm64/kexec-vmlinuz-arm64.c | 20 ++++++++++++++++++--
 kexec/kexec-pe-zboot.c                 |  4 +++-
 kexec/kexec.c                          |  2 +-
 kexec/kexec.h                          |  1 +
 5 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/include/kexec-pe-zboot.h b/include/kexec-pe-zboot.h
index e2e0448a81f2..374916cbe883 100644
--- a/include/kexec-pe-zboot.h
+++ b/include/kexec-pe-zboot.h
@@ -11,5 +11,6 @@ struct linux_pe_zboot_header {
 	uint32_t compress_type;
 };
 
-int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd);
+int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd,
+		off_t *kernel_size);
 #endif
diff --git a/kexec/arch/arm64/kexec-vmlinuz-arm64.c b/kexec/arch/arm64/kexec-vmlinuz-arm64.c
index c0ee47c8f50a..8f378d8fa6d0 100644
--- a/kexec/arch/arm64/kexec-vmlinuz-arm64.c
+++ b/kexec/arch/arm64/kexec-vmlinuz-arm64.c
@@ -34,6 +34,7 @@
 #include "arch/options.h"
 
 static int kernel_fd = -1;
+static off_t decompressed_size;
 
 /* Returns:
  * -1 : in case of error/invalid format (not a valid PE+compressed ZBOOT format.
@@ -72,7 +73,7 @@ int pez_arm64_probe(const char *kernel_buf, off_t kernel_size)
 		return -1;
 	}
 
-	ret = pez_prepare(buf, buf_sz, &kernel_fd);
+	ret = pez_prepare(buf, buf_sz, &kernel_fd, &decompressed_size);
 
 	if (!ret) {
 	    /* validate the arm64 specific header */
@@ -98,8 +99,23 @@ bad_header:
 int pez_arm64_load(int argc, char **argv, const char *buf, off_t len,
 			struct kexec_info *info)
 {
+	char *kbuf;
+
 	info->kernel_fd = kernel_fd;
-	return image_arm64_load(argc, argv, buf, len, info);
+	if (kernel_fd > 0 && decompressed_size > 0) {
+		off_t nread;
+
+		kbuf = slurp_fd(kernel_fd, NULL, decompressed_size, &nread);
+		if (!kbuf || nread != decompressed_size) {
+			dbgprintf("%s: failed.\n", __func__);
+			return -1;
+		}
+	} else {
+		dbgprintf("%s: wrong file descriptor.\n", __func__);
+		return -1;
+	}
+
+	return image_arm64_load(argc, argv, kbuf, decompressed_size, info);
 }
 
 void pez_arm64_usage(void)
diff --git a/kexec/kexec-pe-zboot.c b/kexec/kexec-pe-zboot.c
index 2f2e052b76c5..3abd17d9fe59 100644
--- a/kexec/kexec-pe-zboot.c
+++ b/kexec/kexec-pe-zboot.c
@@ -37,7 +37,8 @@
  *
  * 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 pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd,
+		off_t *kernel_size)
 {
 	int ret = -1;
 	int fd = 0;
@@ -110,6 +111,7 @@ int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd)
 		goto fail_bad_header;
 	}
 
+	*kernel_size = decompressed_size;
 	dbgprintf("%s: done\n", __func__);
 
 	ret = 0;
diff --git a/kexec/kexec.c b/kexec/kexec.c
index c3b182e254e0..1edbd349c86d 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -489,7 +489,7 @@ static int add_backup_segments(struct kexec_info *info,
 	return 0;
 }
 
-static char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread)
+char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread)
 {
 	char *buf;
 	off_t progress;
diff --git a/kexec/kexec.h b/kexec/kexec.h
index ed3b499a80f2..093338969c57 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -267,6 +267,7 @@ extern void die(const char *fmt, ...)
 	__attribute__ ((format (printf, 1, 2)));
 extern void *xmalloc(size_t size);
 extern void *xrealloc(void *ptr, size_t size);
+extern char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread);
 extern char *slurp_file(const char *filename, off_t *r_size);
 extern char *slurp_file_mmap(const char *filename, off_t *r_size);
 extern char *slurp_file_len(const char *filename, off_t size, off_t *nread);
-- 
2.37.2


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] zboot: add loongarch kexec_load support
  2023-09-11 18:37 [PATCH 1/2] zboot: enable arm64 kexec_load for zboot image Dave Young
@ 2023-09-11 18:37 ` Dave Young
  2023-09-13  0:54 ` [PATCH 1/2] zboot: enable arm64 kexec_load for zboot image Pingfan Liu
  1 sibling, 0 replies; 4+ messages in thread
From: Dave Young @ 2023-09-11 18:37 UTC (permalink / raw)
  To: kexec; +Cc: Simon Horman, Pingfan Liu

From: "dyoung@redhat.com" <dyoung@redhat.com>

Copy arm64 code and change for loongarch so that the kexec -c can load
a zboot image.
Note: probe zboot image first otherwise the pei-loongarch file type will
be used.

Signed-off-by: Dave Young <dyoung@redhat.com>
---
 kexec/arch/loongarch/Makefile              |  1 +
 kexec/arch/loongarch/image-header.h        |  1 +
 kexec/arch/loongarch/kexec-loongarch.c     |  1 +
 kexec/arch/loongarch/kexec-loongarch.h     |  4 +
 kexec/arch/loongarch/kexec-pez-loongarch.c | 88 ++++++++++++++++++++++
 5 files changed, 95 insertions(+)
 create mode 100644 kexec/arch/loongarch/kexec-pez-loongarch.c

diff --git a/kexec/arch/loongarch/Makefile b/kexec/arch/loongarch/Makefile
index 3b33b9693287..cee7e569a2a2 100644
--- a/kexec/arch/loongarch/Makefile
+++ b/kexec/arch/loongarch/Makefile
@@ -6,6 +6,7 @@ loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-elf-loongarch.c
 loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-pei-loongarch.c
 loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-elf-rel-loongarch.c
 loongarch_KEXEC_SRCS += kexec/arch/loongarch/crashdump-loongarch.c
+loongarch_KEXEC_SRCS += kexec/arch/loongarch/kexec-pez-loongarch.c
 
 loongarch_MEM_REGIONS = kexec/mem_regions.c
 
diff --git a/kexec/arch/loongarch/image-header.h b/kexec/arch/loongarch/image-header.h
index 3b7576552685..223d81f77d9f 100644
--- a/kexec/arch/loongarch/image-header.h
+++ b/kexec/arch/loongarch/image-header.h
@@ -33,6 +33,7 @@ struct loongarch_image_header {
 };
 
 static const uint8_t loongarch_image_pe_sig[2] = {'M', 'Z'};
+static const uint8_t loongarch_pe_machtype[6] = {'P','E', 0x0, 0x0, 0x64, 0x62};
 
 /**
  * loongarch_header_check_pe_sig - Helper to check the loongarch image header.
diff --git a/kexec/arch/loongarch/kexec-loongarch.c b/kexec/arch/loongarch/kexec-loongarch.c
index f47c99861674..62ff8fd1aeb7 100644
--- a/kexec/arch/loongarch/kexec-loongarch.c
+++ b/kexec/arch/loongarch/kexec-loongarch.c
@@ -165,6 +165,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 
 struct file_type file_type[] = {
 	{"elf-loongarch", elf_loongarch_probe, elf_loongarch_load, elf_loongarch_usage},
+	{"pez-loongarch", pez_loongarch_probe, pez_loongarch_load, pez_loongarch_usage},
 	{"pei-loongarch", pei_loongarch_probe, pei_loongarch_load, pei_loongarch_usage},
 };
 int file_types = sizeof(file_type) / sizeof(file_type[0]);
diff --git a/kexec/arch/loongarch/kexec-loongarch.h b/kexec/arch/loongarch/kexec-loongarch.h
index 5120a26fd513..2c7624f2fd3a 100644
--- a/kexec/arch/loongarch/kexec-loongarch.h
+++ b/kexec/arch/loongarch/kexec-loongarch.h
@@ -27,6 +27,10 @@ int pei_loongarch_probe(const char *buf, off_t len);
 int pei_loongarch_load(int argc, char **argv, const char *buf, off_t len,
 	struct kexec_info *info);
 void pei_loongarch_usage(void);
+int pez_loongarch_probe(const char *kernel_buf, off_t kernel_size);
+int pez_loongarch_load(int argc, char **argv, const char *buf, off_t len,
+		       struct kexec_info *info);
+void pez_loongarch_usage(void);
 
 int loongarch_process_image_header(const struct loongarch_image_header *h);
 
diff --git a/kexec/arch/loongarch/kexec-pez-loongarch.c b/kexec/arch/loongarch/kexec-pez-loongarch.c
new file mode 100644
index 000000000000..6d94a405d54a
--- /dev/null
+++ b/kexec/arch/loongarch/kexec-pez-loongarch.c
@@ -0,0 +1,88 @@
+/*
+ * LoongArch PE compressed Image (vmlinuz, ZBOOT) support.
+ * Based on arm64 code
+ */
+
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include "kexec.h"
+#include "kexec-loongarch.h"
+#include <kexec-pe-zboot.h>
+#include "arch/options.h"
+
+static int kernel_fd = -1;
+static off_t decompressed_size;
+
+/* Returns:
+ * -1 : in case of error/invalid format (not a valid PE+compressed ZBOOT format.
+ */
+int pez_loongarch_probe(const char *kernel_buf, off_t kernel_size)
+{
+	int ret = -1;
+	const struct loongarch_image_header *h;
+	char *buf;
+	off_t buf_sz;
+
+	buf = (char *)kernel_buf;
+	buf_sz = kernel_size;
+	if (!buf)
+		return -1;
+	h = (const struct loongarch_image_header *)buf;
+
+	dbgprintf("%s: PROBE.\n", __func__);
+	if (buf_sz < sizeof(struct loongarch_image_header)) {
+		dbgprintf("%s: Not large enough to be a PE image.\n", __func__);
+		return -1;
+	}
+	if (!loongarch_header_check_pe_sig(h)) {
+		dbgprintf("%s: Not an PE image.\n", __func__);
+		return -1;
+	}
+
+	if (buf_sz < sizeof(struct loongarch_image_header) + h->pe_header) {
+		dbgprintf("%s: PE image offset larger than image.\n", __func__);
+		return -1;
+	}
+
+	if (memcmp(&buf[h->pe_header],
+		   loongarch_pe_machtype, sizeof(loongarch_pe_machtype))) {
+		dbgprintf("%s: PE header doesn't match machine type.\n", __func__);
+		return -1;
+	}
+
+	ret = pez_prepare(buf, buf_sz, &kernel_fd, &decompressed_size);
+
+	/* Fixme: add sanity check of the decompressed kernel before return */
+	return ret;
+}
+
+int pez_loongarch_load(int argc, char **argv, const char *buf, off_t len,
+			struct kexec_info *info)
+{
+	char *kbuf;
+
+	info->kernel_fd = kernel_fd;
+	if (kernel_fd > 0 && decompressed_size > 0) {
+		off_t nread;
+
+		kbuf = slurp_fd(kernel_fd, NULL, decompressed_size, &nread);
+		if (!kbuf || nread != decompressed_size) {
+			dbgprintf("%s: failed.\n", __func__);
+			return -1;
+		}
+	} else {
+		dbgprintf("%s: wrong file descriptor.\n", __func__);
+		return -1;
+	}
+
+	return pei_loongarch_load(argc, argv, kbuf, decompressed_size, info);
+}
+
+void pez_loongarch_usage(void)
+{
+	printf(
+"     An LoongArch vmlinuz, PE image of a compressed, little endian.\n"
+"     kernel, built with ZBOOT enabled.\n\n");
+}
-- 
2.37.2


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] zboot: enable arm64 kexec_load for zboot image
  2023-09-11 18:37 [PATCH 1/2] zboot: enable arm64 kexec_load for zboot image Dave Young
  2023-09-11 18:37 ` [PATCH 2/2] zboot: add loongarch kexec_load support Dave Young
@ 2023-09-13  0:54 ` Pingfan Liu
  2023-09-13  6:48   ` Dave Young
  1 sibling, 1 reply; 4+ messages in thread
From: Pingfan Liu @ 2023-09-13  0:54 UTC (permalink / raw)
  To: Dave Young; +Cc: kexec, Simon Horman

On Mon, Sep 11, 2023 at 6:37 PM Dave Young <dyoung@redhat.com> wrote:
>
> kexec_file_load support of zboot kernel image decompressed the vmlinuz,
> so in kexec_load code just load the kernel with reading the decompressed
> kernel fd into a new buffer and use it directly.
>
> Signed-off-by: Dave Young <dyoung@redhat.com>
> ---
>  include/kexec-pe-zboot.h               |  3 ++-
>  kexec/arch/arm64/kexec-vmlinuz-arm64.c | 20 ++++++++++++++++++--
>  kexec/kexec-pe-zboot.c                 |  4 +++-
>  kexec/kexec.c                          |  2 +-
>  kexec/kexec.h                          |  1 +
>  5 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/include/kexec-pe-zboot.h b/include/kexec-pe-zboot.h
> index e2e0448a81f2..374916cbe883 100644
> --- a/include/kexec-pe-zboot.h
> +++ b/include/kexec-pe-zboot.h
> @@ -11,5 +11,6 @@ struct linux_pe_zboot_header {
>         uint32_t compress_type;
>  };
>
> -int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd);
> +int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd,
> +               off_t *kernel_size);
>  #endif
> diff --git a/kexec/arch/arm64/kexec-vmlinuz-arm64.c b/kexec/arch/arm64/kexec-vmlinuz-arm64.c
> index c0ee47c8f50a..8f378d8fa6d0 100644
> --- a/kexec/arch/arm64/kexec-vmlinuz-arm64.c
> +++ b/kexec/arch/arm64/kexec-vmlinuz-arm64.c
> @@ -34,6 +34,7 @@
>  #include "arch/options.h"
>
>  static int kernel_fd = -1;
> +static off_t decompressed_size;
>
>  /* Returns:
>   * -1 : in case of error/invalid format (not a valid PE+compressed ZBOOT format.
> @@ -72,7 +73,7 @@ int pez_arm64_probe(const char *kernel_buf, off_t kernel_size)
>                 return -1;
>         }
>
> -       ret = pez_prepare(buf, buf_sz, &kernel_fd);
> +       ret = pez_prepare(buf, buf_sz, &kernel_fd, &decompressed_size);
>
>         if (!ret) {
>             /* validate the arm64 specific header */
> @@ -98,8 +99,23 @@ bad_header:
>  int pez_arm64_load(int argc, char **argv, const char *buf, off_t len,
>                         struct kexec_info *info)
>  {
> +       char *kbuf;
> +
>         info->kernel_fd = kernel_fd;
> -       return image_arm64_load(argc, argv, buf, len, info);
> +       if (kernel_fd > 0 && decompressed_size > 0) {
> +               off_t nread;
> +
> +               kbuf = slurp_fd(kernel_fd, NULL, decompressed_size, &nread);
> +               if (!kbuf || nread != decompressed_size) {
> +                       dbgprintf("%s: failed.\n", __func__);
> +                       return -1;
> +               }
> +       } else {
> +               dbgprintf("%s: wrong file descriptor.\n", __func__);
> +               return -1;
> +       }
> +
> +       return image_arm64_load(argc, argv, kbuf, decompressed_size, info);
>  }
>
>  void pez_arm64_usage(void)
> diff --git a/kexec/kexec-pe-zboot.c b/kexec/kexec-pe-zboot.c
> index 2f2e052b76c5..3abd17d9fe59 100644
> --- a/kexec/kexec-pe-zboot.c
> +++ b/kexec/kexec-pe-zboot.c
> @@ -37,7 +37,8 @@
>   *
>   * 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 pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd,
> +               off_t *kernel_size)
>  {
>         int ret = -1;
>         int fd = 0;
> @@ -110,6 +111,7 @@ int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd)
>                 goto fail_bad_header;
>         }
>
> +       *kernel_size = decompressed_size;
>         dbgprintf("%s: done\n", __func__);
>
>         ret = 0;
> diff --git a/kexec/kexec.c b/kexec/kexec.c
> index c3b182e254e0..1edbd349c86d 100644
> --- a/kexec/kexec.c
> +++ b/kexec/kexec.c
> @@ -489,7 +489,7 @@ static int add_backup_segments(struct kexec_info *info,
>         return 0;
>  }
>
> -static char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread)
> +char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread)
>  {
>         char *buf;
>         off_t progress;
> diff --git a/kexec/kexec.h b/kexec/kexec.h
> index ed3b499a80f2..093338969c57 100644
> --- a/kexec/kexec.h
> +++ b/kexec/kexec.h
> @@ -267,6 +267,7 @@ extern void die(const char *fmt, ...)
>         __attribute__ ((format (printf, 1, 2)));
>  extern void *xmalloc(size_t size);
>  extern void *xrealloc(void *ptr, size_t size);
> +extern char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread);
>  extern char *slurp_file(const char *filename, off_t *r_size);
>  extern char *slurp_file_mmap(const char *filename, off_t *r_size);
>  extern char *slurp_file_len(const char *filename, off_t size, off_t *nread);
> --
> 2.37.2
>

LGTM,
Reviewed-by: Pingfan Liu <piliu@redhat.com>


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] zboot: enable arm64 kexec_load for zboot image
  2023-09-13  0:54 ` [PATCH 1/2] zboot: enable arm64 kexec_load for zboot image Pingfan Liu
@ 2023-09-13  6:48   ` Dave Young
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Young @ 2023-09-13  6:48 UTC (permalink / raw)
  To: Pingfan Liu; +Cc: kexec, Simon Horman

Hi,

On Wed, 13 Sept 2023 at 08:54, Pingfan Liu <piliu@redhat.com> wrote:
>
> On Mon, Sep 11, 2023 at 6:37 PM Dave Young <dyoung@redhat.com> wrote:
> >
> > kexec_file_load support of zboot kernel image decompressed the vmlinuz,
> > so in kexec_load code just load the kernel with reading the decompressed
> > kernel fd into a new buffer and use it directly.
> >
> > Signed-off-by: Dave Young <dyoung@redhat.com>
> > ---
> >  include/kexec-pe-zboot.h               |  3 ++-
> >  kexec/arch/arm64/kexec-vmlinuz-arm64.c | 20 ++++++++++++++++++--
> >  kexec/kexec-pe-zboot.c                 |  4 +++-
> >  kexec/kexec.c                          |  2 +-
> >  kexec/kexec.h                          |  1 +
> >  5 files changed, 25 insertions(+), 5 deletions(-)
> >
> > diff --git a/include/kexec-pe-zboot.h b/include/kexec-pe-zboot.h
> > index e2e0448a81f2..374916cbe883 100644
> > --- a/include/kexec-pe-zboot.h
> > +++ b/include/kexec-pe-zboot.h
> > @@ -11,5 +11,6 @@ struct linux_pe_zboot_header {
> >         uint32_t compress_type;
> >  };
> >
> > -int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd);
> > +int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd,
> > +               off_t *kernel_size);
> >  #endif
> > diff --git a/kexec/arch/arm64/kexec-vmlinuz-arm64.c b/kexec/arch/arm64/kexec-vmlinuz-arm64.c
> > index c0ee47c8f50a..8f378d8fa6d0 100644
> > --- a/kexec/arch/arm64/kexec-vmlinuz-arm64.c
> > +++ b/kexec/arch/arm64/kexec-vmlinuz-arm64.c
> > @@ -34,6 +34,7 @@
> >  #include "arch/options.h"
> >
> >  static int kernel_fd = -1;
> > +static off_t decompressed_size;
> >
> >  /* Returns:
> >   * -1 : in case of error/invalid format (not a valid PE+compressed ZBOOT format.
> > @@ -72,7 +73,7 @@ int pez_arm64_probe(const char *kernel_buf, off_t kernel_size)
> >                 return -1;
> >         }
> >
> > -       ret = pez_prepare(buf, buf_sz, &kernel_fd);
> > +       ret = pez_prepare(buf, buf_sz, &kernel_fd, &decompressed_size);
> >
> >         if (!ret) {
> >             /* validate the arm64 specific header */
> > @@ -98,8 +99,23 @@ bad_header:
> >  int pez_arm64_load(int argc, char **argv, const char *buf, off_t len,
> >                         struct kexec_info *info)
> >  {
> > +       char *kbuf;
> > +
> >         info->kernel_fd = kernel_fd;
> > -       return image_arm64_load(argc, argv, buf, len, info);
> > +       if (kernel_fd > 0 && decompressed_size > 0) {
> > +               off_t nread;
> > +
> > +               kbuf = slurp_fd(kernel_fd, NULL, decompressed_size, &nread);
> > +               if (!kbuf || nread != decompressed_size) {

Today in another test I found that this breaks the kexec_file_load
because the slurp_fd() closed the kernel_fd after readding out the
buffer,  I will send another version soon, also cleanup a bit about
this function.

Thanks for reviewing.

> > +                       dbgprintf("%s: failed.\n", __func__);
> > +                       return -1;
> > +               }
> > +       } else {
> > +               dbgprintf("%s: wrong file descriptor.\n", __func__);
> > +               return -1;
> > +       }
> > +
> > +       return image_arm64_load(argc, argv, kbuf, decompressed_size, info);
> >  }
> >
> >  void pez_arm64_usage(void)
> > diff --git a/kexec/kexec-pe-zboot.c b/kexec/kexec-pe-zboot.c
> > index 2f2e052b76c5..3abd17d9fe59 100644
> > --- a/kexec/kexec-pe-zboot.c
> > +++ b/kexec/kexec-pe-zboot.c
> > @@ -37,7 +37,8 @@
> >   *
> >   * 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 pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd,
> > +               off_t *kernel_size)
> >  {
> >         int ret = -1;
> >         int fd = 0;
> > @@ -110,6 +111,7 @@ int pez_prepare(const char *crude_buf, off_t buf_sz, int *kernel_fd)
> >                 goto fail_bad_header;
> >         }
> >
> > +       *kernel_size = decompressed_size;
> >         dbgprintf("%s: done\n", __func__);
> >
> >         ret = 0;
> > diff --git a/kexec/kexec.c b/kexec/kexec.c
> > index c3b182e254e0..1edbd349c86d 100644
> > --- a/kexec/kexec.c
> > +++ b/kexec/kexec.c
> > @@ -489,7 +489,7 @@ static int add_backup_segments(struct kexec_info *info,
> >         return 0;
> >  }
> >
> > -static char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread)
> > +char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread)
> >  {
> >         char *buf;
> >         off_t progress;
> > diff --git a/kexec/kexec.h b/kexec/kexec.h
> > index ed3b499a80f2..093338969c57 100644
> > --- a/kexec/kexec.h
> > +++ b/kexec/kexec.h
> > @@ -267,6 +267,7 @@ extern void die(const char *fmt, ...)
> >         __attribute__ ((format (printf, 1, 2)));
> >  extern void *xmalloc(size_t size);
> >  extern void *xrealloc(void *ptr, size_t size);
> > +extern char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread);
> >  extern char *slurp_file(const char *filename, off_t *r_size);
> >  extern char *slurp_file_mmap(const char *filename, off_t *r_size);
> >  extern char *slurp_file_len(const char *filename, off_t size, off_t *nread);
> > --
> > 2.37.2
> >
>
> LGTM,
> Reviewed-by: Pingfan Liu <piliu@redhat.com>
>


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-13  6:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-11 18:37 [PATCH 1/2] zboot: enable arm64 kexec_load for zboot image Dave Young
2023-09-11 18:37 ` [PATCH 2/2] zboot: add loongarch kexec_load support Dave Young
2023-09-13  0:54 ` [PATCH 1/2] zboot: enable arm64 kexec_load for zboot image Pingfan Liu
2023-09-13  6:48   ` Dave Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox