Skip to content

EFI stub early spring cleaning part 2

Ard Biesheuvel linux-efi 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest19 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19efi/libstub/x86: Remove pointless zeroing of apm_bios_infoarch/x86/boot/compressed/eboot.c+0 -50 replies
2/19efi/libstub/x86: Avoid overflowing code32_start on PE entryarch/x86/boot/compressed/eboot.c+18 -220 replies
3/19efi/libstub: Use hidden visiblity for all source filesarch/arm64/include/asm/efi.h drivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/arm64-stub.c +1 more+8 -113 replies
4/19efi/libstub/arm: Relax FDT alignment requirementarch/arm64/include/asm/efi.h drivers/firmware/efi/libstub/fdt.c+1 -120 replies
5/19efi/libstub: Move memory map handling and allocation routines to mem.cdrivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/efi-stub-helper.c drivers/firmware/efi/libstub/mem.c+320 -3140 replies
6/19efi/libstub: Simplify efi_high_alloc() and rename to efi_allocate_pages()drivers/firmware/efi/libstub/efi-stub-helper.c drivers/firmware/efi/libstub/fdt.c drivers/firmware/efi/libstub/mem.c +1 more+23 -910 replies
7/19efi/libstub/x86: Incorporate eboot.c into libstubarch/x86/boot/compressed/Makefile arch/x86/boot/compressed/eboot.h drivers/firmware/efi/libstub/Makefile +2 more+19 -390 replies
8/19efi/libstub: Use consistent type names for file I/O protocolsdrivers/firmware/efi/libstub/efi-stub-helper.c drivers/firmware/efi/libstub/efistub.h include/linux/efi.h+72 -670 replies
9/19efi/libstub: Move stub specific declarations into efistub.hdrivers/firmware/efi/libstub/efistub.h include/linux/efi.h+479 -4840 replies
10/19efi/libstub/x86: Permit bootparams struct to be allocated above 4 GBdrivers/firmware/efi/libstub/x86-stub.c+6 -10 replies
11/19efi/libstub/x86: Permit cmdline data to be allocated above 4 GBarch/x86/include/asm/efi.h drivers/firmware/efi/libstub/arm-stub.c drivers/firmware/efi/libstub/efi-stub-helper.c +2 more+8 -130 replies
12/19efi/libstub: Move efi_random_alloc() into separate source filedrivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/random.c drivers/firmware/efi/libstub/randomalloc.c+125 -1150 replies
13/19efi/libstub: Move get_dram_base() into arm-stub.cdrivers/firmware/efi/libstub/arm-stub.c drivers/firmware/efi/libstub/efi-stub-helper.c drivers/firmware/efi/libstub/efistub.h+33 -376 replies
14/19efi/libstub: Move file I/O support code into separate filedrivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/efi-stub-helper.c drivers/firmware/efi/libstub/efistub.h +1 more+311 -2890 replies
15/19efi/libstub: Rewrite file I/O routinedrivers/firmware/efi/libstub/arm-stub.c drivers/firmware/efi/libstub/efistub.h drivers/firmware/efi/libstub/file.c +1 more+169 -2280 replies
16/19efi/libstub: Take soft and hard memory limits into account for initrd loadingdrivers/firmware/efi/libstub/arm-stub.c drivers/firmware/efi/libstub/efistub.h drivers/firmware/efi/libstub/file.c +1 more+20 -170 replies
17/19efi/libstub: Clean up command line parsing routinedrivers/firmware/efi/libstub/Makefile drivers/firmware/efi/libstub/efi-stub-helper.c drivers/firmware/efi/libstub/string.c+91 -540 replies
18/19efi/libstub: Expose LocateDevicePath boot servicearch/x86/include/asm/efi.h drivers/firmware/efi/libstub/efistub.h+8 -10 replies
19/19efi/libstub: Make the LoadFile EFI protocol accessiblearch/x86/include/asm/efi.h drivers/firmware/efi/libstub/efistub.h include/linux/efi.h+20 -00 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 00/19] EFI stub early spring cleaning part 2

This series is a second pass over the EFI stub code to clean it up and prepare it for some future changes:
- loading the initrd in a different way, which should remove the need for bootloaders to have knowledge about the initrd allocation policies and about how to pass the base and size to the kernel proper,
- support for RISC-V will be arriving soon, which makes this a good time to do some janitorial work to avoid RISC-V from inheriting legacy that only exists for the benefit of other architectures.

First of all, code has been moved into separate source files where appropriate, so that we can benefit from the fact that the EFI stub is a true static library, and so only the objects that are needed to satisfy symbol dependencies are incorporated into the final build. We also move x86's eboot.c into libstub/ so we can use the same cflags and make rules across the entire library. (#5, #7, #9, #12, #13, #14)

Patches #6, #15 and #17 clean up the memory allocation, file I/O and command line parsing routines that are shared by all architectures, to remove open coded logic that is already implemented elsewhere, either in the firmware or in code that we can incorporate from the kernel proper.

Patches #10, #11 and #16 deal with upper limits for memory allocations.

Patches #18 and #19 adds the plumbing to enable us to locate device paths and invoke the EFI LoadFile2 protocol.

The remaining patches are cleanups or minor bug fixes across the board.

Note that this series applies onto Arvind's x86/boot cleanups [0]. Full branch can be found here [1]

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

Ard Biesheuvel (19):
efi/libstub/x86: Remove pointless zeroing of apm_bios_info efi/libstub/x86: Avoid overflowing code32_start on PE entry efi/libstub: Use hidden visiblity for all source files efi/libstub/arm: Relax FDT alignment requirement efi/libstub: Move memory map handling and allocation routines to mem.c efi/libstub: Simplify efi_high_alloc() and rename to
efi_allocate_pages()
efi/libstub/x86: Incorporate eboot.c into libstub efi/libstub: Use consistent type names for file I/O protocols efi/libstub: Move stub specific declarations into efistub.h efi/libstub/x86: Permit bootparams struct to be allocated above 4 GB efi/libstub/x86: Permit cmdline data to be allocated above 4 GB efi/libstub: Move efi_random_alloc() into separate source file efi/libstub: Move get_dram_base() into arm-stub.c efi/libstub: Move file I/O support code into separate file efi/libstub: Rewrite file I/O routine
efi/libstub: Take soft and hard memory limits into account for initrd
loading
efi/libstub: Clean up command line parsing routine efi/libstub: Expose LocateDevicePath boot service efi/libstub: Make the LoadFile EFI protocol accessible

 arch/arm64/include/asm/efi.h                  |  10 -
 arch/x86/boot/compressed/Makefile             |   5 +-
 arch/x86/boot/compressed/eboot.h              |  31 -
 arch/x86/include/asm/efi.h                    |   9 +-
 drivers/firmware/efi/libstub/Makefile         |   6 +-
 drivers/firmware/efi/libstub/arm-stub.c       |  47 +-
 drivers/firmware/efi/libstub/arm64-stub.c     |   8 +-
 .../firmware/efi/libstub/efi-stub-helper.c    | 725 +-----------------
 drivers/firmware/efi/libstub/efistub.h        | 586 +++++++++++++-
 drivers/firmware/efi/libstub/fdt.c            |   7 +-
 drivers/firmware/efi/libstub/file.c           | 258 +++++++
 drivers/firmware/efi/libstub/hidden.h         |   6 +
 drivers/firmware/efi/libstub/mem.c            | 253 ++++++
 drivers/firmware/efi/libstub/random.c         | 114 ---
 drivers/firmware/efi/libstub/randomalloc.c    | 124 +++
 drivers/firmware/efi/libstub/string.c         |  63 ++
 .../firmware/efi/libstub/x86-stub.c           |  79 +-
 include/linux/efi.h                           | 516 +------------
 18 files changed, 1389 insertions(+), 1458 deletions(-)
 delete mode 100644 arch/x86/boot/compressed/eboot.h
 create mode 100644 drivers/firmware/efi/libstub/file.c
 create mode 100644 drivers/firmware/efi/libstub/hidden.h
 create mode 100644 drivers/firmware/efi/libstub/mem.c
 create mode 100644 drivers/firmware/efi/libstub/randomalloc.c
 rename arch/x86/boot/compressed/eboot.c => drivers/firmware/efi/libstub/x86-stub.c (94%)
Signature · 1 line
2.17.1