Skip to content

efi: Combine stub functionality with zboot decompressor

Ard Biesheuvel linux-efi 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest21 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21arm64: efi: Move dcache cleaning of loaded image out of efi_enter_kernel()arch/arm64/kernel/efi-entry.S arch/arm64/kernel/image-vars.h drivers/firmware/efi/libstub/arm64-stub.c+9 -113 replies
2/21arm64: efi: Avoid dcache_clean_poc() altogether in efi_enter_kernel()arch/arm64/kernel/efi-entry.S+29 -282 replies
3/21arm64: efi: Move efi-entry.S into the libstub source directoryarch/arm64/kernel/Makefile drivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/arm64-entry.S+3 -141 reply
4/21efi: libstub: Remove zboot signing from build optionsdrivers/firmware/efi/Kconfig drivers/firmware/efi/libstub/Makefile.zboot+4 -470 replies
5/21efi: libstub: Drop randomization of runtime memory mapdrivers/firmware/efi/libstub/efi-stub.c+0 -290 replies
6/21efi: libstub: Drop handling of EFI properties tabledrivers/firmware/efi/libstub/efi-stub.c+0 -130 replies
7/21efi: libstub: Deduplicate ftrace command line argument filteringdrivers/firmware/efi/libstub/Makefile+6 -90 replies
8/21efi: libstub: Use local strncmp() implementation unconditionallyarch/arm64/kernel/image-vars.h arch/riscv/kernel/image-vars.h drivers/firmware/efi/libstub/string.c+0 -40 replies
9/21efi: libstub: Clone memcmp() into the stubarch/arm64/kernel/image-vars.h arch/loongarch/kernel/image-vars.h arch/riscv/kernel/image-vars.h +2 more+19 -130 replies
10/21efi: libstub: Enable efi_printk() in zboot decompressorarch/arm64/kernel/image-vars.h arch/loongarch/kernel/image-vars.h arch/riscv/kernel/image-vars.h +5 more+198 -1730 replies
11/21efi: loongarch: Drop exports of unused string routinesarch/loongarch/kernel/image-vars.h+0 -50 replies
12/21efi: libstub: Move screen_info handling to common codearch/arm/include/asm/efi.h arch/arm/kernel/efi.c arch/arm64/include/asm/efi.h +11 more+121 -940 replies
13/21efi: libstub: Provide local implementations of strrchr() and memchr()arch/arm64/kernel/image-vars.h arch/riscv/kernel/image-vars.h drivers/firmware/efi/libstub/Makefile +1 more+64 -50 replies
14/21efi: libstub: Factor out EFI stub entrypoint into separate filedrivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/efi-stub-entry.c drivers/firmware/efi/libstub/efi-stub.c +1 more+101 -640 replies
15/21efi: libstub: Add image code and data size to the zimage metadatadrivers/firmware/efi/libstub/Makefile.zboot drivers/firmware/efi/libstub/zboot-header.S+13 -150 replies
16/21efi: libstub: Factor out min alignment and preferred kernel load addressarch/arm64/include/asm/efi.h arch/loongarch/include/asm/efi.h arch/riscv/include/asm/efi.h +3 more+39 -230 replies
17/21efi/riscv: libstub: Split off kernel image relocation for builtin stubarch/riscv/include/asm/efi.h drivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/riscv-stub.c +1 more+108 -750 replies
18/21efi/arm64: libstub: Split off kernel image relocation for builtin stubdrivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/arm64-entry.S drivers/firmware/efi/libstub/arm64-stub.c +2 more+78 -290 replies
19/21efi/loongarch: Don't jump to kernel entry via the old imagearch/loongarch/include/asm/efi.h drivers/firmware/efi/libstub/loongarch-stub.c+26 -90 replies
20/21efi/loongarch: libstub: Split off kernel image relocation for builtin stubdrivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/loongarch-stub.c drivers/firmware/efi/libstub/loongarch.c+82 -670 replies
21/21efi: libstub: Merge zboot decompressor with the ordinary stubdrivers/firmware/efi/libstub/file.c drivers/firmware/efi/libstub/zboot.c+74 -2280 replies

Reviews trailers per patch

3 of 21 patches have a Reviewed-by or Acked-by.

PatchCatalin Marinas
1/21A-b
2/21A-b
3/21A-b
4/21
5/21
6/21
7/21
8/21
9/21
10/21
11/21
12/21
13/21
14/21
15/21
16/21
17/21
18/21
19/21
20/21
21/21

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/21] efi: Combine stub functionality with zboot decompressor

The EFI zboot decompression code that has been merged into v6.1-rc1 is fully generic, and relies on the EFI stub inside the encapsulated image to implement the actual EFI boot sequence. While this works fine, it has some drawbacks that we might prefer to fix:
- executing the EFI stub of the inner image requires that it is signed if secure boot is enabled, which is a bit of a hassle, given that signing the image must occur during the build;
- decompressing a PE/COFF image and calling LoadImage() on it means that it gets copied again, and potentially yet another time if the placement does not meet per-arch requirements.

Given that the zboot decompressor and the EFI stub are built from the same set of objects in the libstub static library, we can make things a bit simpler, by incorporating everything the stub does into the zboot decompressor, and only handing off to the decompressed image after ExitBootServices(). This removes the need for signing the inner image, and allows us to decompress the image directly into the intended location in memory.

This involves some refactoring, to remove the dependency on symbols that are only defined when linking directly to vmlinux, such as string and memory compare routines, and section boundaries of the core kernel.

While at it, remove some functionality if it's not worth the effort making it work on both code paths, such as the EFI properties table, and the randomization of the UEFI runtime regions.

Since image signing no longer needs to occur during the build, let's also drop the support for invoking sbsign during the build on both the inner image and the decompressor. (I intend to send that patch as a fix for v6.1 so we don't add zombie Kconfig symbols to a LTS kernel)

Cc Matthew Garrett <[email protected]>
Cc Peter Jones <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Palmer Dabbelt <[email protected]>
Cc Atish Patra <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Huacai Chen <[email protected]>
Cc Xi Ruoyao <[email protected]>
Cc Lennart Poettering <[email protected]>
Cc Jeremy Linton <[email protected]>
Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>

Ard Biesheuvel (21):
arm64: efi: Move dcache cleaning of loaded image out of
efi_enter_kernel()
arm64: efi: Avoid dcache_clean_poc() altogether in efi_enter_kernel()
arm64: efi: Move efi-entry.S into the libstub source directory
efi: libstub: Remove zboot signing from build options
efi: libstub: Drop randomization of runtime memory map
efi: libstub: Drop handling of EFI properties table
efi: libstub: Deduplicate ftrace command line argument filtering
efi: libstub: Use local strncmp() implementation unconditionally
efi: libstub: Clone memcmp() into the stub
efi: libstub: Enable efi_printk() in zboot decompressor
efi: loongarch: Drop exports of unused string routines
efi: libstub: Move screen_info handling to common code
efi: libstub: Provide local implementations of strrchr() and memchr()
efi: libstub: Factor out EFI stub entrypoint into separate file
efi: libstub: Add image code and data size to the zimage metadata
efi: libstub: Factor out min alignment and preferred kernel load
address
efi/riscv: libstub: Split off kernel image relocation for builtin stub efi/arm64: libstub: Split off kernel image relocation for builtin stub efi/loongarch: Don't jump to kernel entry via the old image efi/loongarch: libstub: Split off kernel image relocation for builtin
stub
efi: libstub: Merge zboot decompressor with the ordinary stub

 arch/arm/include/asm/efi.h                     |   3 -
 arch/arm/kernel/efi.c                          |  31 +-
 arch/arm64/include/asm/efi.h                   |  15 +-
 arch/arm64/kernel/Makefile                     |   9 +-
 arch/arm64/kernel/efi-entry.S                  |  69 -----
 arch/arm64/kernel/image-vars.h                 |   8 -
 arch/loongarch/include/asm/efi.h               |  14 +-
 arch/loongarch/kernel/efi.c                    |  24 +-
 arch/loongarch/kernel/image-vars.h             |   8 -
 arch/riscv/include/asm/efi.h                   |  13 +-
 arch/riscv/kernel/image-vars.h                 |   6 -
 drivers/firmware/efi/Kconfig                   |  22 --
 drivers/firmware/efi/efi-init.c                |  21 +-
 drivers/firmware/efi/efi.c                     |   5 +
 drivers/firmware/efi/libstub/Makefile          |  30 +-
 drivers/firmware/efi/libstub/Makefile.zboot    |  53 +---
 drivers/firmware/efi/libstub/arm32-stub.c      |  37 ---
 drivers/firmware/efi/libstub/arm64-entry.S     |  69 +++++
 drivers/firmware/efi/libstub/arm64-stub.c      |  49 +---
 drivers/firmware/efi/libstub/arm64.c           |  61 ++++
 drivers/firmware/efi/libstub/efi-stub-entry.c  |  65 +++++
 drivers/firmware/efi/libstub/efi-stub-helper.c | 143 ---------
 drivers/firmware/efi/libstub/efi-stub.c        | 140 +++------
 drivers/firmware/efi/libstub/efistub.h         |  15 +
 drivers/firmware/efi/libstub/file.c            |  18 --
 drivers/firmware/efi/libstub/intrinsics.c      |  18 ++
 drivers/firmware/efi/libstub/loongarch-stub.c  |  89 ++----
 drivers/firmware/efi/libstub/loongarch.c       |  80 +++++
 drivers/firmware/efi/libstub/printk.c          | 154 ++++++++++
 drivers/firmware/efi/libstub/riscv-stub.c      |  96 +-----
 drivers/firmware/efi/libstub/riscv.c           |  98 +++++++
 drivers/firmware/efi/libstub/screen_info.c     |  56 ++++
 drivers/firmware/efi/libstub/string.c          |  95 +++++-
 drivers/firmware/efi/libstub/zboot-header.S    |   2 +-
 drivers/firmware/efi/libstub/zboot.c           | 307 +++++---------------
 include/linux/efi.h                            |   2 +-
 36 files changed, 972 insertions(+), 953 deletions(-)
 delete mode 100644 arch/arm64/kernel/efi-entry.S
 create mode 100644 drivers/firmware/efi/libstub/arm64-entry.S
 create mode 100644 drivers/firmware/efi/libstub/arm64.c
 create mode 100644 drivers/firmware/efi/libstub/efi-stub-entry.c
 create mode 100644 drivers/firmware/efi/libstub/loongarch.c
 create mode 100644 drivers/firmware/efi/libstub/printk.c
 create mode 100644 drivers/firmware/efi/libstub/riscv.c
 create mode 100644 drivers/firmware/efi/libstub/screen_info.c
Signature · 1 line
2.35.1