Skip to content

RFC efi: Implement generic zboot support

Ard Biesheuvel linux-efi lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3efi/libstub: x86: Split off pieces shared with zbootarch/x86/include/asm/efi.h drivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/x86-stub.c +1 more+625 -5850 replies
2/3efi/zboot: x86: Implement EFI zboot supportarch/x86/Makefile arch/x86/include/asm/efi.h arch/x86/kernel/head_64.S +9 more+375 -120 replies
3/3efi/zboot: x86: Clear NX restrictions on populated code regionsarch/x86/kernel/head_64.S drivers/firmware/efi/libstub/x86-zboot.c+31 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/3] efi: Implement generic zboot support

This series is a proof-of-concept that implements support for the EFI zboot decompressor for x86. It replaces the ordinary decompressor, and instead, performs the decompression, KASLR randomization and the 4/5 level paging switch while running in the execution context of EFI.

This simplifies things substantially, and makes it straight-forward to abide by stricter future requirements related to the use of writable and executable memory under EFI, which will come into effect on x86 systems that are certified as being 'more secure', and ship with an even shinier Windows sticker.

This is an alternative approach to the work being proposed by Evgeny [0] that makes rather radical changes to the existing decompressor, which has accumulated too many features already, e.g., related to confidential compute etc.

EFI zboot images can be booted in two ways:
- by EFI firmware, which loads and starts it as an ordinary EFI application, just like the existing EFI stub (with which it shares most of its code);
- by a non-EFI loader that parses the image header for the compression metadata, and decompresses the image into memory and boots it.

Realistically, the second option is unlikely to ever be used on x86, given that it already has its existing bzImage, but the first option is a good choice for distros that target EFI boot only (and some distros switched to this format already for arm64). The fact that EFI zboot is implemented in the same way on arm64, RISC-V, LoongArch and [shortly] ARM helps with maintenance, not only of the kernel itself, but also the tooling around it relating to kexec, code signing, deployment, etc.

Series can be pulled from [1], which contains some prerequisite patches that are only tangentially related.

[0] https://lore.kernel.org/all/[email protected]/
[1] https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=efi-x86-zboot

Cc Evgeniy Baskov <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Alexey Khoroshilov <[email protected]>
Cc Peter Jones <[email protected]>
Cc Gerd Hoffmann <[email protected]>
Cc Dave Young <[email protected]>
Cc Mario Limonciello <[email protected]>
Cc Kees Cook <[email protected]>
Cc Tom Lendacky <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Linus Torvalds <[email protected]>

Ard Biesheuvel (3):
efi/libstub: x86: Split off pieces shared with zboot efi/zboot: x86: Implement EFI zboot support efi/zboot: x86: Clear NX restrictions on populated code regions

 arch/x86/Makefile                              |  18 +-
 arch/x86/include/asm/efi.h                     |  10 +
 arch/x86/kernel/head_64.S                      |  15 +
 arch/x86/zboot/Makefile                        |  29 +
 drivers/firmware/efi/Kconfig                   |   2 +-
 drivers/firmware/efi/libstub/Makefile          |  15 +-
 drivers/firmware/efi/libstub/Makefile.zboot    |   2 +-
 drivers/firmware/efi/libstub/efi-stub-helper.c |   3 +
 drivers/firmware/efi/libstub/x86-stub.c        | 592 +------------------
 drivers/firmware/efi/libstub/x86-zboot.c       | 322 ++++++++++
 drivers/firmware/efi/libstub/x86.c             | 612 ++++++++++++++++++++
 drivers/firmware/efi/libstub/zboot.c           |   3 +-
 drivers/firmware/efi/libstub/zboot.lds         |   5 +
 13 files changed, 1031 insertions(+), 597 deletions(-)
 create mode 100644 arch/x86/zboot/Makefile
 create mode 100644 drivers/firmware/efi/libstub/x86-zboot.c
 create mode 100644 drivers/firmware/efi/libstub/x86.c
Signature · 1 line
2.39.2