From 1572b91da7c4512d111a340185914c34acb0a139 Mon Sep 17 00:00:00 2001 From: Pingfan Liu Date: Thu, 3 Aug 2023 10:41:49 +0800 Subject: kexec: Introduce a member kernel_fd in kexec_info 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. Signed-off-by: Pingfan Liu Co-authored-by: Dave Young Signed-off-by: Dave Young Signed-off-by: Simon Horman --- kexec/kexec.c | 8 ++++++++ kexec/kexec.h | 1 + 2 files changed, 9 insertions(+) diff --git a/kexec/kexec.c b/kexec/kexec.c index d132eb53..c3b182e2 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -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. diff --git a/kexec/kexec.h b/kexec/kexec.h index 0d820ada..ed3b499a 100644 --- a/kexec/kexec.h +++ b/kexec/kexec.h @@ -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; -- cgit 1.2.3-korg