Skip to content

efi: disentangle the generic EFI stub from FDT

Ard Biesheuvel linux-efi loongarch stable 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 18 repliesIn review
  2. v112 patches 27 repliesSuperseded

Changes in v2 from the cover letter

- to ease merging this with the loongarch tree, drop unrelated cleanup changes, which will be merged separately;
- drop the patch to enable DT for hw descriptions - it will be picked up again later
- avoid creating the INITRD table if no initrd was actually loaded;
- incorporate feedback from Huacai on the arch/loongarch changes;
- other minor tweaks.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8efi: libstub: drop pointless get_memory_map() calldrivers/firmware/efi/libstub/fdt.c+0 -80 replies
2/8efi: libstub: avoid efi_get_memory_map() for allocating the virt mapdrivers/firmware/efi/libstub/efi-stub.c drivers/firmware/efi/libstub/efistub.h drivers/firmware/efi/libstub/fdt.c+49 -230 replies
3/8efi: libstub: simplify efi_get_memory_map() and struct efi_boot_memmapdrivers/firmware/efi/libstub/arm64-stub.c drivers/firmware/efi/libstub/efi-stub-helper.c drivers/firmware/efi/libstub/efistub.h +6 more+85 -1570 replies
4/8efi: libstub: remove pointless goto kludgedrivers/firmware/efi/libstub/efi-stub-helper.c+7 -150 replies
5/8efi: libstub: unify initrd loading between architecturesDocumentation/arm/uefi.rst drivers/firmware/efi/efi.c drivers/firmware/efi/libstub/efi-stub-helper.c +5 more+85 -1000 replies
6/8efi: libstub: remove DT dependency from generic stubdrivers/firmware/efi/libstub/efi-stub.c drivers/firmware/efi/libstub/efistub.h drivers/firmware/efi/libstub/fdt.c+60 -610 replies
7/8efi: libstub: install boot-time memory map as config tabledrivers/firmware/efi/libstub/arm64-stub.c drivers/firmware/efi/libstub/efi-stub-helper.c drivers/firmware/efi/libstub/efistub.h +4 more+31 -80 replies
8/8efi/loongarch: libstub: remove dependency on flattened DTarch/loongarch/Kconfig arch/loongarch/include/asm/bootinfo.h arch/loongarch/kernel/efi.c +5 more+95 -2818 replies

Reviews trailers per patch

1 of 8 patches has a Reviewed-by or Acked-by.

PatchHuacai Chen
1/8
2/8
3/8
4/8
5/8
6/8
7/8
8/8A-b

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

Read the v2 thread

Cover letter [PATCH v2 0/8] efi: disentangle the generic EFI stub from FDT

EFI architectures other than x86 rely on FDT to pass information between the stub and the core kernel. In hindsight, this is probably a mistake, given the issues around abuse of the internal ABI, and potential inconsistencies between two sources of information that both originate in the firmware (memory map, command line, etc)

Another reason for avoiding updates to the DT is the fact that it interferes with secure boot and measured boot. Even if we measure the original firmware provided DT into the TPM, the DT that the kernel receives is a completely different blob, and verifying it against the TPM event log is currently impossible.

So let's start hacking away at this, and refactor the generic stub so that all the FDT pieces are isolated in a singe source file, and rely on generic EFI config tables for passing the initrd base and size. Ultimately, this should permit all EFI architectures doing DT boot to perform the handover to the core kernel in a different way, and pass on the firmware provided DT unmodified, but this requires some future work for ARM/arm64 and RISC-V.

However, we can easily convert the newly added LoongArch code to adopt this approach, and to consume the DT strictly for hardware descriptions (if not doing ACPI boot), and pass the initrd, memory map and everything else via EFI config tables. Generating empty DTBs on ACPI platforms will no longer be needed.

The first six patches as well as patch #10 are general cleanup, and can be merged separately. The remaining patches refactor the FDT code in the EFI stub so that we can avoid it on platforms that don't need it for other reasons. Finally, LoongArch is updated to use DT only for hardware descriptions when doing EFI boot.

Changes since v1:
- to ease merging this with the loongarch tree, drop unrelated cleanup changes, which will be merged separately;
- drop the patch to enable DT for hw descriptions - it will be picked up again later
- avoid creating the INITRD table if no initrd was actually loaded;
- incorporate feedback from Huacai on the arch/loongarch changes;
- other minor tweaks.

Cc Arnd Bergmann <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Huacai Chen <[email protected]>
Cc Xi Ruoyao <[email protected]>

Ard Biesheuvel (8):
efi: libstub: drop pointless get_memory_map() call
efi: libstub: avoid efi_get_memory_map() for allocating the virt map
efi: libstub: simplify efi_get_memory_map() and struct efi_boot_memmap
efi: libstub: remove pointless goto kludge
efi: libstub: unify initrd loading between architectures
efi: libstub: remove DT dependency from generic stub
efi: libstub: install boot-time memory map as config table efi/loongarch: libstub: remove dependency on flattened DT

 Documentation/arm/uefi.rst                     |   4 -
 arch/loongarch/Kconfig                         |   3 -
 arch/loongarch/include/asm/bootinfo.h          |   2 +-
 arch/loongarch/kernel/efi.c                    |  30 +++-
 arch/loongarch/kernel/env.c                    |  13 +-
 arch/loongarch/kernel/head.S                   |   2 +
 arch/loongarch/kernel/setup.c                  |   4 +-
 drivers/firmware/efi/efi.c                     |  15 ++
 drivers/firmware/efi/libstub/Makefile          |  13 +-
 drivers/firmware/efi/libstub/arm64-stub.c      |  19 +--
 drivers/firmware/efi/libstub/efi-stub-helper.c | 139 ++++++++--------
 drivers/firmware/efi/libstub/efi-stub.c        |  90 ++++------
 drivers/firmware/efi/libstub/efistub.h         |  28 +---
 drivers/firmware/efi/libstub/fdt.c             | 176 +++++++++++---------
 drivers/firmware/efi/libstub/loongarch-stub.c  |  56 ++++++-
 drivers/firmware/efi/libstub/mem.c             |  93 +++++------
 drivers/firmware/efi/libstub/randomalloc.c     |  25 +--
 drivers/firmware/efi/libstub/relocate.c        |  21 +--
 drivers/firmware/efi/libstub/x86-stub.c        |  30 +---
 include/linux/efi.h                            |  15 ++
 20 files changed, 395 insertions(+), 383 deletions(-)
Signature · 1 line
2.35.1