Skip to content

x86/efi/mixed: Decouple from legacy decompressor

Ard Biesheuvel linux-efi lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 6 repliesIn review
  2. v16 patches 1 replySuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7x86/efistub: Merge PE and handover entrypointsarch/x86/boot/compressed/efi_mixed.S drivers/firmware/efi/libstub/x86-stub.c+30 -380 replies
2/7x86/efi/mixed: Check CPU compatibility without relying on verify_cpu()arch/x86/boot/compressed/efi_mixed.S+9 -130 replies
3/7x86/efi/mixed: Factor out and clean up long mode entryarch/x86/boot/compressed/efi_mixed.S+15 -140 replies
4/7x86/efi/mixed: Set up 1:1 mapping of lower 4GiB in the stubarch/x86/boot/compressed/efi_mixed.S+29 -00 replies
5/7x86/efi/mixed: Remove dependency on legacy startup_32 codearch/x86/boot/compressed/efi_mixed.S arch/x86/boot/compressed/head_64.S+65 -1690 replies
6/7x86/efi/mixed: Simplify and document thunking logicarch/x86/boot/compressed/efi_mixed.S+37 -400 replies
7/7x86/efi/mixed: Move mixed mode startup code into libstubarch/x86/boot/compressed/Makefile drivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/x86-mixed.S+3 -10 replies

Reviews trailers per patch

None of the 7 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchIngo Molnar
SeriesA-b
1/7
2/7
3/7
4/7
5/7
6/7
7/7

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/7] x86/efi/mixed: Decouple from legacy decompressor

From: Ard Biesheuvel <[email protected]>

Since commit

a1b87d54f4e4 ("x86/efistub: Avoid legacy decompressor when doing EFI boot")

booting via the EFI stub no longer relies on the legacy decompressor, and instead, the kernel proper is decompressed by code executing in the context of the EFI boot services, and subsequently invoked directly.

The only remaining dependency is the EFI mixed mode startup code, which makes a detour via the legacy decompressor's 32-bit entrypoint, in order to obtain a 1:1 mapping of memory, which is a prerequisite for 64-bit execution on x86.

This detour requires some fiddly setup on the part of the mixed mode startup code, which has to stash the firmware stack pointer and boot arguments in memory, and create a fake struct boot_params to trick the code in startup_32 to behave as intended.

This dependency also impedes reuse of the EFI stub code in other contexts, such as generic EFI zboot, which will reuse the EFI stub but not the legacy decompressor.

So remove this dependency, by replacing this detour with a minimal reimplementation of the 1:1 mapping code. With some further cleanup applied on top, the line count drops substantially, but without loss of functionality. The resulting code can operate independently from the legacy decompressor, and is therefore moved out of arch/x86/boot/ and into the EFI libstub/ directory.

Changes since v1 [0]:
- Create new long mode GDT that extends the firmware's 32-bit only GDT so that preserving/restoring data segment selectors or swapping out GDTs and IDTs is no longer needed at all.
- Rebase onto v6.14-rc1

[0] https://lore.kernel.org/all/[email protected]/

Ard Biesheuvel (7):
x86/efistub: Merge PE and handover entrypoints x86/efi/mixed: Check CPU compatibility without relying on verify_cpu() x86/efi/mixed: Factor out and clean up long mode entry x86/efi/mixed: Set up 1:1 mapping of lower 4GiB in the stub x86/efi/mixed: Remove dependency on legacy startup_32 code x86/efi/mixed: Simplify and document thunking logic x86/efi/mixed: Move mixed mode startup code into libstub

 arch/x86/boot/compressed/Makefile        |   1 -
 arch/x86/boot/compressed/efi_mixed.S     | 341 --------------------
 arch/x86/boot/compressed/head_64.S       |   7 -
 drivers/firmware/efi/libstub/Makefile    |   3 +
 drivers/firmware/efi/libstub/x86-mixed.S | 253 +++++++++++++++
 drivers/firmware/efi/libstub/x86-stub.c  |  52 +--
 6 files changed, 285 insertions(+), 372 deletions(-)
 delete mode 100644 arch/x86/boot/compressed/efi_mixed.S
 create mode 100644 drivers/firmware/efi/libstub/x86-mixed.S
Signature · 1 line
2.48.1.362.g079036d154-goog