From ff11422804cd03494cc98691eecd3909ea09ab6f Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Fri, 3 Mar 2023 17:01:09 +0100 Subject: hw: arm: Support direct boot for Linux/arm64 EFI zboot images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fedora 39 will ship its arm64 kernels in the new generic EFI zboot format, using gzip compression for the payload. For doing EFI boot in QEMU, this is completely transparent, as the firmware or bootloader will take care of this. However, for direct kernel boot without firmware, we will lose the ability to boot such distro kernels unless we deal with the new format directly. EFI zboot images contain metadata in the header regarding the placement of the compressed payload inside the image, and the type of compression used. This means we can wire up the existing gzip support without too much hassle, by parsing the header and grabbing the payload from inside the loaded zboot image. Cc: Peter Maydell Cc: Alex Bennée Cc: Richard Henderson Cc: Philippe Mathieu-Daudé Signed-off-by: Ard Biesheuvel Message-id: 20230303160109.3626966-1-ardb@kernel.org Reviewed-by: Peter Maydell [PMM: tweaked comment formatting, fixed checkpatch nits] Signed-off-by: Peter Maydell --- hw/arm/boot.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'hw/arm/boot.c') diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 1e021c4a34..50e5141116 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -926,6 +926,12 @@ static uint64_t load_aarch64_image(const char *filename, hwaddr mem_base, return -1; } size = len; + + /* Unpack the image if it is a EFI zboot image */ + if (unpack_efi_zboot_image(&buffer, &size) < 0) { + g_free(buffer); + return -1; + } } /* check the arm64 magic header value -- very old kernels may not have it */ -- cgit 1.4.1