Skip to content

efi: Expose loaded image properties via info struct

Ard Biesheuvel linux-arm-kernel linux-efi linux-riscv loongarch stable 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest15 patches 13 repliesIn review
  2. v210 patches 12 repliesSuperseded
  3. v15 patches 3 repliesSuperseded

Changes in v3 from the cover letter

- Add some additional fixes for RISC-V, which deviates from other architectures wrt its section markers. These patches have been sent out separately as well [0] as they will likely be taken through the RISC-V tree.
- Pass an efi_image_pointer to efi_stub_common() that points to the version inside the loaded image, so that its relative references accurately describe vmlinux in memory before boot.
- Avoid weak linkage hacks to derive the kernel entrypoint, and instead, always use the entrypoint passed via efi_image_info
- Use efi_image_info for sysfb_display_info so that efifb earlycon works much earlier on zboot
- Drop changes related to the previous bullet that are now no longer needed
- Add acks from Jason

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15efi/zboot: arm64: Add missing barrier after cache maintenancedrivers/firmware/efi/libstub/arm64.c+1 -00 replies
2/15riscv: Use _stext not _text to denote the start of kernel codearch/riscv/kernel/setup.c+1 -11 reply
3/15riscv: Make _text point to the start of the kernel imagearch/riscv/kernel/vmlinux.lds.S+1 -11 reply
4/15efi/riscv: Rename __init_text_end to __inittext_end like other archsarch/riscv/include/asm/sections.h arch/riscv/kernel/image-vars.h arch/riscv/kernel/vmlinux.lds.S +1 more+5 -50 replies
5/15efi/libstub: Avoid _end section marker in library codedrivers/firmware/efi/libstub/kaslr.c+1 -11 reply
6/15efi/libstub: Capture loaded image information in struct efi_image_infoarch/arm64/kernel/efi-header.S arch/loongarch/kernel/head.S arch/riscv/kernel/head.S +12 more+145 -331 reply
7/15efi/libstub: Pass kernel entrypoint down to efi_enter_kernel()arch/arm/boot/compressed/head.S drivers/firmware/efi/libstub/arm32-stub.c drivers/firmware/efi/libstub/arm64.c +5 more+18 -372 replies
8/15efi/libstub: arm64: Use struct efi_image_info to access image propertiesarch/arm64/kernel/image-vars.h drivers/firmware/efi/libstub/arm64-stub.c+9 -342 replies
9/15efi/libstub: loongarch: Use struct efi_image_info to access image propertiesarch/loongarch/kernel/image-vars.h drivers/firmware/efi/libstub/loongarch-stub.c drivers/firmware/efi/libstub/loongarch.c+1 -201 reply
10/15efi/libstub: riscv: Use struct efi_image_info to access image propertiesarch/riscv/kernel/image-vars.h drivers/firmware/efi/libstub/riscv-stub.c+6 -271 reply
11/15efi/libstub: Make efi_remap_image() return efi_status_tdrivers/firmware/efi/libstub/efi-stub-helper.c drivers/firmware/efi/libstub/efistub.h+12 -70 replies
12/15efi/zboot: Disentangle efi_remap_image() from efi_cache_sync_image()drivers/firmware/efi/libstub/arm64.c drivers/firmware/efi/libstub/zboot-decompress-gzip.c drivers/firmware/efi/libstub/zboot-decompress-zstd.c +1 more+13 -70 replies
13/15efi/libstub: arm64: Drop zboot code_size hackarch/arm64/boot/Makefile arch/arm64/kernel/image-vars.h drivers/firmware/efi/libstub/arm64.c +1 more+1 -140 replies
14/15efi: Make config table based primary display handover ARM-only againarch/arm/kernel/efi.c arch/loongarch/kernel/efi.c drivers/firmware/efi/efi-init.c +8 more+90 -1191 reply
15/15Revert "efi: earlycon: Reprobe after parsing config tables"drivers/firmware/efi/earlycon.c include/linux/efi.h+3 -141 reply

Reviews trailers per patch

14 of 15 patches have a Reviewed-by or Acked-by.

PatchJason Gunthorpe
SeriesT-b
1/15
2/15R-b
3/15R-b
4/15R-b
5/15R-b
6/15R-b
7/15R-b
8/15R-b
9/15R-b
10/15R-b
11/15R-b
12/15R-b
13/15R-b
14/15R-b
15/15R-b

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

Read the v3 thread

Cover letter [PATCH v3 00/15] efi: Expose loaded image properties via info struct

From: Ard Biesheuvel <[email protected]>

Clean up the arm64 build script and linker hacks that zboot uses to obtain properties of the loaded image (which it cannot access directly via a relative reference like the ordinary EFI stub).

Instead, define a generic struct efi_image_info, and expose its offset in the loaded image in a similar manner, but without relying on explicit linker script exports.

Populate the struct with section markers that all architecture use for loading the kernel image at boot, so that all the linker exports can be dropped for them.

Changes since v2:
- Add some additional fixes for RISC-V, which deviates from other architectures wrt its section markers. These patches have been sent out separately as well [0] as they will likely be taken through the RISC-V tree.
- Pass an efi_image_pointer to efi_stub_common() that points to the version inside the loaded image, so that its relative references accurately describe vmlinux in memory before boot.
- Avoid weak linkage hacks to derive the kernel entrypoint, and instead, always use the entrypoint passed via efi_image_info
- Use efi_image_info for sysfb_display_info so that efifb earlycon works much earlier on zboot
- Drop changes related to the previous bullet that are now no longer needed
- Add acks from Jason

Changes since v1:
- drop arm64 image header changes
- move efi_image_info out of __efistub_ scope so it can access vmlinux symbols directly
- implement in a generic manner for all architectures that support zboot
- address Sashiko comments

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

Ard Biesheuvel (15):
efi/zboot: arm64: Add missing barrier after cache maintenance
riscv: Use _stext not _text to denote the start of kernel code
riscv: Make _text point to the start of the kernel image efi/riscv: Rename __init_text_end to __inittext_end like other archs efi/libstub: Avoid _end section marker in library code efi/libstub: Capture loaded image information in struct efi_image_info efi/libstub: Pass kernel entrypoint down to efi_enter_kernel() efi/libstub: arm64: Use struct efi_image_info to access image
properties
efi/libstub: loongarch: Use struct efi_image_info to access image
properties
efi/libstub: riscv: Use struct efi_image_info to access image
properties
efi/libstub: Make efi_remap_image() return efi_status_t efi/zboot: Disentangle efi_remap_image() from efi_cache_sync_image() efi/libstub: arm64: Drop zboot code_size hack
efi: Make config table based primary display handover ARM-only again Revert "efi: earlycon: Reprobe after parsing config tables"

 arch/arm/boot/compressed/head.S                      |  2 +-
 arch/arm/kernel/efi.c                                | 27 ++++++++
 arch/arm64/boot/Makefile                             |  3 -
 arch/arm64/kernel/efi-header.S                       |  2 +
 arch/arm64/kernel/image-vars.h                       | 14 ----
 arch/loongarch/kernel/efi.c                          | 20 +-----
 arch/loongarch/kernel/head.S                         |  1 +
 arch/loongarch/kernel/image-vars.h                   |  4 --
 arch/riscv/include/asm/sections.h                    |  2 +-
 arch/riscv/kernel/head.S                             |  1 +
 arch/riscv/kernel/image-vars.h                       |  8 ---
 arch/riscv/kernel/setup.c                            |  2 +-
 arch/riscv/kernel/vmlinux.lds.S                      |  6 +-
 drivers/firmware/efi/earlycon.c                      | 16 +----
 drivers/firmware/efi/efi-init.c                      | 24 ++-----
 drivers/firmware/efi/efi.c                           |  5 --
 drivers/firmware/efi/libstub/Makefile                |  3 +-
 drivers/firmware/efi/libstub/Makefile.zboot          | 11 ++-
 drivers/firmware/efi/libstub/arm32-stub.c            | 48 ++++++++++++-
 drivers/firmware/efi/libstub/arm64-stub.c            | 44 ++++++------
 drivers/firmware/efi/libstub/arm64.c                 | 23 ++-----
 drivers/firmware/efi/libstub/efi-stub-entry.c        | 27 ++------
 drivers/firmware/efi/libstub/efi-stub-helper.c       | 15 +++--
 drivers/firmware/efi/libstub/efi-stub.c              | 26 +++++--
 drivers/firmware/efi/libstub/efistub.h               | 71 +++++++++++++++++---
 drivers/firmware/efi/libstub/fdt.c                   |  5 +-
 drivers/firmware/efi/libstub/image_info.S            | 19 ++++++
 drivers/firmware/efi/libstub/kaslr.c                 |  2 +-
 drivers/firmware/efi/libstub/loongarch-stub.c        | 12 +---
 drivers/firmware/efi/libstub/loongarch.c             | 10 +--
 drivers/firmware/efi/libstub/primary_display.c       | 56 ---------------
 drivers/firmware/efi/libstub/riscv-stub.c            | 27 +++-----
 drivers/firmware/efi/libstub/riscv.c                 | 16 +----
 drivers/firmware/efi/libstub/zboot-decompress-gzip.c |  2 -
 drivers/firmware/efi/libstub/zboot-decompress-zstd.c |  2 -
 drivers/firmware/efi/libstub/zboot.c                 | 28 ++++++--
 drivers/firmware/efi/libstub/zboot.lds               |  6 +-
 include/linux/efi.h                                  |  1 -
 38 files changed, 289 insertions(+), 302 deletions(-)
 create mode 100644 drivers/firmware/efi/libstub/image_info.S
 delete mode 100644 drivers/firmware/efi/libstub/primary_display.c

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.56.0.611.g1030f0b940-goog