From f4c1caaa97a2e019ccc00ab63e390c60d1c9454c Mon Sep 17 00:00:00 2001 From: Bhupesh Sharma Date: Mon, 15 Jul 2019 11:32:56 +0530 Subject: kexec/arm64: Add support for handling zlib compressed (Image.gz) image Currently the kexec_file_load() support for arm64 doesn't allow handling zlib compressed (i.e. Image.gz) image. Since most distributions use 'make zinstall' rule inside 'arch/arm64/boot/Makefile' to install the arm64 Image.gz compressed file inside the boot destination directory (for e.g. /boot), currently we cannot use kexec_file_load() to load vmlinuz (or Image.gz): # file /boot/vmlinuz /boot/vmlinuz: gzip compressed data, was "Image", <..snip..>, max compression, from Unix, original size 21945120 Now, since via kexec_file_load() we pass the 'fd' of Image.gz (compressed file) via the following command line ... # kexec -s -l /boot/vmlinuz-`uname -r` --initrd=/boot/initramfs-`uname -r`.img --reuse-cmdline ... kernel returns -EINVAL error value, as it is not able to locate the magic number =0x644d5241, which is expected in the 64-byte header of the decompressed kernel image. We can fix this in user-space kexec-tools, which handles an 'Image.gz' being passed via kexec_file_load(), using an approach as follows: a). Copy the contents of Image.gz to a temporary file. b). Decompress (gunzip-decompress) the contents inside the temporary file. c). Pass the 'fd' of the temporary file to the kernel space. So basically the kernel space still gets a decompressed kernel image to load via kexec-tools I tested this patch for the following three use-cases: 1. Uncompressed Image file: #kexec -s -l Image --initrd=/boot/initramfs-`uname -r`.img --reuse-cmdline 2. Signed Image file: #kexec -s -l Image.signed --initrd=/boot/initramfs-`uname -r`.img --reuse-cmdline 3. zlib compressed Image.gz file: #kexec -s -l /boot/vmlinuz-`uname -r` --initrd=/boot/initramfs-`uname -r`.img --reuse-cmdline Signed-off-by: Bhupesh Sharma Signed-off-by: Simon Horman --- kexec/arch/arm64/kexec-image-arm64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'kexec/arch/arm64/kexec-image-arm64.c') diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c index 685a993..aa8f2e2 100644 --- a/kexec/arch/arm64/kexec-image-arm64.c +++ b/kexec/arch/arm64/kexec-image-arm64.c @@ -114,6 +114,6 @@ exit: void image_arm64_usage(void) { printf( -" An ARM64 binary image, compressed or not, big or little endian.\n" -" Typically an Image, Image.gz or Image.lzma file.\n\n"); +" An ARM64 binary image, uncompressed, big or little endian.\n" +" Typically an Image file.\n\n"); } -- cgit