From: Pingfan Liu <piliu@redhat.com>
To: kexec@lists.infradead.org
Cc: Pingfan Liu <piliu@redhat.com>,
horms@verge.net.au, ardb@kernel.org, jeremy.linton@arm.com
Subject: [PATCH 3/5] arm64: change the prototype of image probe function
Date: Fri, 5 May 2023 10:54:35 +0800 [thread overview]
Message-ID: <20230505025438.11943-4-piliu@redhat.com> (raw)
In-Reply-To: <20230505025438.11943-1-piliu@redhat.com>
Changing the aarch64 probe's prototype from
typedef int (probe_t)(const char *kernel_buf, off_t kernel_size);
to
typedef int (probe_t)(const char *kernel_buf, off_t kernel_size, struct kexec_info *info);
Later, info can be used to return both the file descriptor and parsed kernel
buffer. The fd is passed to sys_kexec_file_load, and the parsed kernel
buffer is used by image's load function.
Signed-off-by: Pingfan Liu <piliu@redhat.com>
To: kexec@lists.infradead.org
Cc: horms@verge.net.au
Cc: ardb@kernel.org
Cc: jeremy.linton@arm.com
---
kexec/arch/arm/kexec-arm.h | 4 ++--
kexec/arch/arm/kexec-uImage-arm.c | 2 +-
kexec/arch/arm64/kexec-arm64.h | 8 ++++----
kexec/arch/arm64/kexec-elf-arm64.c | 2 +-
kexec/arch/arm64/kexec-image-arm64.c | 2 +-
kexec/arch/arm64/kexec-uImage-arm64.c | 2 +-
kexec/arch/arm64/kexec-zImage-arm64.c | 2 +-
kexec/kexec.c | 15 +++++++++++++--
kexec/kexec.h | 6 ++++++
9 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/kexec/arch/arm/kexec-arm.h b/kexec/arch/arm/kexec-arm.h
index a74cce2..18069f3 100644
--- a/kexec/arch/arm/kexec-arm.h
+++ b/kexec/arch/arm/kexec-arm.h
@@ -9,12 +9,12 @@
extern off_t initrd_base, initrd_size;
-int zImage_arm_probe(const char *buf, off_t len);
+int zImage_arm_probe(const char *buf, off_t len, struct kexec_info *info);
int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
struct kexec_info *info);
void zImage_arm_usage(void);
-int uImage_arm_probe(const char *buf, off_t len);
+int uImage_arm_probe(const char *buf, off_t len, struct kexec_info *info);
int uImage_arm_load(int argc, char **argv, const char *buf, off_t len,
struct kexec_info *info);
extern int have_sysfs_fdt(void);
diff --git a/kexec/arch/arm/kexec-uImage-arm.c b/kexec/arch/arm/kexec-uImage-arm.c
index 03c2f4d..d955eb3 100644
--- a/kexec/arch/arm/kexec-uImage-arm.c
+++ b/kexec/arch/arm/kexec-uImage-arm.c
@@ -9,7 +9,7 @@
#include "../../kexec.h"
#include "kexec-arm.h"
-int uImage_arm_probe(const char *buf, off_t len)
+int uImage_arm_probe(const char *buf, off_t len, struct kexec_info *info)
{
return uImage_probe_kernel(buf, len, IH_ARCH_ARM);
}
diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h
index 5eb9fc0..88bb508 100644
--- a/kexec/arch/arm64/kexec-arm64.h
+++ b/kexec/arch/arm64/kexec-arm64.h
@@ -29,22 +29,22 @@
#define NOT_KV_ADDR (0x0)
#define NOT_PADDR (ULONGLONG_MAX)
-int elf_arm64_probe(const char *kernel_buf, off_t kernel_size);
+int elf_arm64_probe(const char *kernel_buf, off_t kernel_size, struct kexec_info *info);
int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
off_t kernel_size, struct kexec_info *info);
void elf_arm64_usage(void);
-int image_arm64_probe(const char *kernel_buf, off_t kernel_size);
+int image_arm64_probe(const char *kernel_buf, off_t kernel_size, struct kexec_info *info);
int image_arm64_load(int argc, char **argv, const char *kernel_buf,
off_t kernel_size, struct kexec_info *info);
void image_arm64_usage(void);
-int uImage_arm64_probe(const char *buf, off_t len);
+int uImage_arm64_probe(const char *buf, off_t len, struct kexec_info *info);
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_probe(const char *kernel_buf, off_t kernel_size, struct kexec_info *info);
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);
diff --git a/kexec/arch/arm64/kexec-elf-arm64.c b/kexec/arch/arm64/kexec-elf-arm64.c
index e14f8e9..9238dd5 100644
--- a/kexec/arch/arm64/kexec-elf-arm64.c
+++ b/kexec/arch/arm64/kexec-elf-arm64.c
@@ -16,7 +16,7 @@
#include "kexec-elf.h"
#include "kexec-syscall.h"
-int elf_arm64_probe(const char *kernel_buf, off_t kernel_size)
+int elf_arm64_probe(const char *kernel_buf, off_t kernel_size, struct kexec_info *info)
{
struct mem_ehdr ehdr;
int result;
diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c
index aa8f2e2..84aca72 100644
--- a/kexec/arch/arm64/kexec-image-arm64.c
+++ b/kexec/arch/arm64/kexec-image-arm64.c
@@ -14,7 +14,7 @@
#include "kexec-syscall.h"
#include "arch/options.h"
-int image_arm64_probe(const char *kernel_buf, off_t kernel_size)
+int image_arm64_probe(const char *kernel_buf, off_t kernel_size, struct kexec_info *info)
{
const struct arm64_image_header *h;
diff --git a/kexec/arch/arm64/kexec-uImage-arm64.c b/kexec/arch/arm64/kexec-uImage-arm64.c
index c466913..f5b94c8 100644
--- a/kexec/arch/arm64/kexec-uImage-arm64.c
+++ b/kexec/arch/arm64/kexec-uImage-arm64.c
@@ -9,7 +9,7 @@
#include "../../kexec.h"
#include "kexec-arm64.h"
-int uImage_arm64_probe(const char *buf, off_t len)
+int uImage_arm64_probe(const char *buf, off_t len, struct kexec_info *info)
{
int ret;
diff --git a/kexec/arch/arm64/kexec-zImage-arm64.c b/kexec/arch/arm64/kexec-zImage-arm64.c
index 166d7ef..7877741 100644
--- a/kexec/arch/arm64/kexec-zImage-arm64.c
+++ b/kexec/arch/arm64/kexec-zImage-arm64.c
@@ -40,7 +40,7 @@
* fd : File descriptor of the temp file containing the decompressed
* Image.
*/
-int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size)
+int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size, struct kexec_info *info)
{
int ret = -1;
int fd = 0;
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 614cd1d..116fb4a 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -742,14 +742,25 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
return -1;
} else {
/* make sure our file is really of that type */
+#ifndef __aarch64__
if (file_type[i].probe(kernel_buf, kernel_size) < 0)
guess_only = 1;
+#else
+ if (file_type[i].probe(kernel_buf, kernel_size, &info) < 0)
+ guess_only = 1;
+
+#endif
}
}
if (!type || guess_only) {
for (i = 0; i < file_types; i++) {
+#ifndef __aarch64__
if (file_type[i].probe(kernel_buf, kernel_size) == 0)
break;
+#else
+ if (file_type[i].probe(kernel_buf, kernel_size, &info) == 0)
+ break;
+#endif
}
if (i == file_types) {
fprintf(stderr, "Cannot determine the file type "
@@ -1304,12 +1315,12 @@ static int do_kexec_file_load(int fileind, int argc, char **argv,
#ifdef __aarch64__
/* handle Image.gz like cases */
if (is_zlib_file(kernel, &kernel_size)) {
- if ((ret = file_type[i].probe(kernel, kernel_size)) >= 0) {
+ if ((ret = file_type[i].probe(kernel, kernel_size, &info)) >= 0) {
kernel_fd = ret;
break;
}
} else
- if (file_type[i].probe(kernel_buf, kernel_size) >= 0)
+ if (file_type[i].probe(kernel_buf, kernel_size, &info) >= 0)
break;
#else
if (file_type[i].probe(kernel_buf, kernel_size) >= 0)
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 0d820ad..6e8430e 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -191,7 +191,13 @@ unsigned long locate_hole(struct kexec_info *info,
unsigned long hole_min, unsigned long hole_max,
int hole_end);
+#ifndef __aarch64__
typedef int (probe_t)(const char *kernel_buf, off_t kernel_size);
+#else
+typedef int (probe_t)(const char *kern_fname, off_t kernel_size,
+ struct kexec_info *info);
+#endif
+
typedef int (load_t )(int argc, char **argv,
const char *kernel_buf, off_t kernel_size,
struct kexec_info *info);
--
2.31.1
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2023-05-05 2:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 2:54 [PATCH 0/5] arm64: zboot support Pingfan Liu
2023-05-05 2:54 ` [PATCH 1/5] kexec: Adding missing free for kernel_buf Pingfan Liu
2023-05-05 15:32 ` Simon Horman
2023-05-05 2:54 ` [PATCH 2/5] arm64/zImage: Remove unnecessary allocation for kernel_uncompressed_buf Pingfan Liu
2023-05-05 2:54 ` Pingfan Liu [this message]
2023-05-05 15:42 ` [PATCH 3/5] arm64: change the prototype of image probe function Simon Horman
2023-05-06 3:14 ` Pingfan Liu
2023-05-05 2:54 ` [PATCH 4/5] arm64: Scatter the logic of reading of kernel file into each probe Pingfan Liu
2023-05-05 2:54 ` [PATCH 4/5] arm64: Scatter the " Pingfan Liu
2023-05-05 22:38 ` [PATCH 0/5] arm64: zboot support Jeremy Linton
2023-05-06 3:12 ` Pingfan Liu
2023-05-06 3:05 ` [PATCH 5/5] arm64: add support for zboot image Pingfan Liu
2023-05-12 3:10 ` [PATCH 0/5] arm64: zboot support Pingfan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230505025438.11943-4-piliu@redhat.com \
--to=piliu@redhat.com \
--cc=ardb@kernel.org \
--cc=horms@verge.net.au \
--cc=jeremy.linton@arm.com \
--cc=kexec@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox