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. Not doing so makes sense for bare metal boot, as it 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 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. The downside is that two signatures are needed for UEFI secure boot: one for the decompressed image and one for the compressed images, as they are both PE/COFF EFI executables that are launched by the firmware. But that is actually the whole point, so it is simply the other side of the same coin. Related discussion going on here: https://lore.kernel.org/all/20220430090518.3127980-22-chenhuacai@xxxxxxxxxxx/ Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Huacai Chen <chenhuacai@xxxxxxxxxxx> Ard Biesheuvel (4): efi: stub: add prototypes for load_image and start_image efi: stub: split off printk() routines efi: stub: implement generic EFI zboot arm64: efi: enable generic EFI compressed boot arch/arm64/Makefile | 5 + arch/arm64/boot/Makefile | 17 ++- drivers/firmware/efi/Kconfig | 6 + drivers/firmware/efi/libstub/Makefile | 4 +- drivers/firmware/efi/libstub/efi-stub-helper.c | 141 ----------------- drivers/firmware/efi/libstub/efistub.h | 8 +- drivers/firmware/efi/libstub/printk.c | 158 ++++++++++++++++++++ drivers/firmware/efi/libstub/zboot-header.S | 88 +++++++++++ drivers/firmware/efi/libstub/zboot.c | 86 +++++++++++ drivers/firmware/efi/libstub/zboot.lds | 44 ++++++ 10 files changed, 412 insertions(+), 145 deletions(-) create mode 100644 drivers/firmware/efi/libstub/printk.c create mode 100644 drivers/firmware/efi/libstub/zboot-header.S create mode 100644 drivers/firmware/efi/libstub/zboot.c create mode 100644 drivers/firmware/efi/libstub/zboot.lds -- 2.30.2