Skip to content

Commit

Permalink
kexec: Introduce a member kernel_fd in kexec_info
Browse files Browse the repository at this point in the history
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 <piliu@redhat.com>
Co-authored-by: Dave Young <dyoung@redhat.com>
To: kexec@lists.infradead.org
Cc: horms@verge.net.au
Cc: ardb@kernel.org
Cc: jeremy.linton@arm.com
Signed-off-by: Simon Horman <horms@kernel.org>
  • Loading branch information
2 people authored and horms committed Aug 3, 2023
1 parent 88b8bb8 commit 5c62f53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kexec/kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions kexec/kexec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5c62f53

Please sign in to comment.