Generic EFI Compressed Boot Support Prepped Ahead Of Linux 6.1

Written by Michael Larabel in Linux Kernel on 25 September 2022 at 05:32 AM EDT. Add A Comment
LINUX KERNEL
Linux kernel developer Ard Biesheuvel has been working on a patch series implementing EFI generic compressed boot support that can be easily used by architectures like AArch64, LoongArch, and RISC-V.

Queued into Linux's EFI "next" branch ahead of the Linux 6.1 merge window opening up in early july is generic EFI compressed boot support. Biesheuvel explained of the motivation and reasoning for this work:
Relatively modern architectures such as arm64 or RISC-V don't implement a self-decompressing kernel, and leave it up to the bootloader to decompress the compressed image before executing it. For bare metal boot, this policy makes sense, as a self-decompressing image essentially duplicates a lot of fiddly preparation work to create a 1:1 mapping and set up the C runtime, and to discover or infer where DRAM lives from device trees or other firmware tables.

For EFI boot, the situation is a bit different: the EFI entrypoint is called with a 1:1 cached mapping covering all of DRAM already active, and with a stack, a heap, a memory map and boot services to load and start images. This means it is rather trivial to implement a self-decompressing wrapper for EFI boot in a generic manner, and reuse it across architectures that implement EFI boot.

At this stage the code is wired up successfully for ARM64, LoongArch, and RISC-V but requires little architecture-specific work and could be adapted for additional architectures later. Or the new EFI_ZBOOT sums it up as:
Create the bootable image as an EFI application that carries the actual kernel image in compressed form, and decompresses it into memory before executing it via LoadImage/StartImage EFI boot service calls. For compatibility with non-EFI loaders, the payload can be decompressed and executed by the loader as well, provided that the loader implements the decompression algorithm and that non-EFI boot is supported by the encapsulated image. (The compression algorithm used is described in the zboot image header)

Gzip / LZ4 / LZMA / LZO / XZ / Zstd are among the possible compression algorithms. The feature is under the new EFI_ZBOOT option and does allow signing of the image as well for UEFI Secure Boot.

Those interested in more details on this generic compressed boot support for EFI can find the patches queued up now in EFI.git ahead of the upcoming Linux 6.1 merge window.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week