[PATCH 000/112] efi: prepare for ARM64 EFI loader support
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Jan 3 10:11:20 PST 2024
I've been working on enabling use of barebox as EFI loader for a while.
It's already functional enough to boot efi-stubbed Linux directly or via
Grub, but some key parts like proper runtime services and the EFI boot
manager are still missing.
Nevertheless, A lot of commits are already in a good enough shape to be
upstreamed, which I collected in this series. A second WIP series with
the EFI loader support will follow afterwards.
This series lays the ground work for using barebox as EFI loader (i.e.
EFI firmware) on - at first - ARM64 systems:
- Generalize existing x86 EFI payload support, so it's usable on other
architectures and for barebox as EFI loader
- Rework virtual file system support, so we can easily map EFI file
system protocol onto barebox VFS
- Add barebox payload on ARM64 support to allow further
experimentation and to have an in-tree payload to test barebox
as EFI loader against
The payload has been tested with Qemu Virt64 against Tianocore, U-Boot and
my upcoming barebox EFI loader patches. It's not fully usable as Grub
replacement yet, because a boot handler isn't registered, but it was
very useful to develop the loader, which is why I am including it here,
even if not yet fully featured.
Ahmad Fatoum (112):
string: implement strcmp_ptr and streq_ptr helpers
commands: efiexit: flush console and shutdown barebox
treewide: add errno_set helper for returning positive error code in
errno
vsprintf: guard against NULL in UUID %pU
common: add option to poweroff system on failure
boot: print error code when booting fails
common: efi: move directory to top-level
efi: payload: rename CONFIG_EFI_BOOTUP to CONFIG_EFI_PAYLOAD
efi: payload: image: return actual read_file() error
of: don't report failure to of_read_file twice
efi: payload: make missing state reporting less verbose
libfile: factor out read_file_into_buf helper
efi: payload: image: allocate image via loader if it exceeds malloc
area
efi: payload: image: use assigned barebox loader type on x86
efi: payload: iomem: adjust types to avoid casting
commands: kallsyms: add command-line interface
block: define BLOCKSIZE globally in block.h
cdev: implement setter/getter for cdev device node
block: virtio: assign virtio-mmio device tree node to cdevs
commands: stat: print DT node for cdevs if available
partitions: have parsers record bootable bits
commands: stat: display bootable partition table bit info
block: record block device type
include: add definitions for UAPI discoverable partitions spec
efi: payload: restrict 8250 UART at I/O port 0x3f8 registration to x86
fs: fix unreaddir, so readdir returns unread dirent first
fs: turn creat into static inline helper
fs: drop unused LOOKUP_ flags
fs: opendir: reference mount point until closedir is called
fs: factor out opendir iteration
fs: implement fdopendir and rewinddir
fs: remove unused member from struct nameidata
fs: always check path_init for errors
fs: set current working dir directly when mounting root
fs: implement openat and friends
fs: implement O_PATH
fs: support different root directories
fs: implement O_CHROOT
commands: introduce new findmnt command
fs: initialize struct nameidata::last
fs: support opening /
test: self: add dirfd tests
commands: stat: add option for statat
efi: payload: lower command line options print from error to info
efi: payload: init: warn if /boot FS is unknown
commands: time: refactor into new strjoin
string: reduce strjoin runtime, drop trailing separator
test: self: add strjoin tests
filetype: have cdev_detect_type take a cdev
ARM: mmu-early: gracefully handle already enabled MMU
efi: don't hide structs, enums or unions behind _t
efi: make headers self-contained
efi: unify whitespace for GUIDs
efi: efi-guid: add more GUIDs
ARM64: cpu: setupc: rewrite to be fully PIC
ARM64: runtime-offset: make get_runtime_offset fully PIC
pbl: introduce CONFIG_PBL_FULLY_PIC
efi: payload: fix ARM build
efi: payload: init: restrict barebox mem to first 1G only on x86
ARM: pbl: add 64K segment alignment for PE/COFF
efi: add efi_is_loader/efi_is_payload helpers
efi: payload: suppress EFI payload initcalls when not EFI-loaded
ARM: make board data definitions accessible to other architectures
boarddata: add barebox_boarddata_is_machine helper
common: add PE/COFF loader
efi: use efi_handle_t where appropriate
efi: block: move definitions into header file
efi: define efi_handle_t as opaque pointer
efi: constify guid_t in API
efi: rename efi_simple_input_interface to
efi_simple_text_input_protocol
efi: add EFI_WARN constants
efi-stdio: fix wait_for_event argument
efi-stdio: wait for extended input key event when using extended input
efi: flesh out EFI definitions in header
efi: add efi_driver_binding_protocol
efi: improve usability of EFI_PAGE_* macros
fs: efi: move definitions into header
efi: fs: flesh out file system definitions
efi: stdio: fix efi_register_keystroke_notify prototype
video: mark EFI_GOP driver x86-only for now
filetype: add new file types for EFI-enabled Linux images
efi: payload: register handler for EFI-stubbed ARM64 kernel
efi: payload: factor C efi_main into dedicated file
efi: payload: early-mem: simplify error message reporting
efi: payload: early-mem: use EFI_PAGE_SIZE instead of PAGE_SIZE
ARM64: add optional EFI stub
efi: devicepath: improve const safety
efi: refactor device_path_to_partuuid for code reuse
efi: devicepath: implement device_path_to_str_buf variant
vsprintf: add %pD for printing EFI device path
lib: string: import Linux strreplace helper
efi: payload: dynamically determine bootloader file name
efi: payload: iomem: register later
efi: payload: protect against buggy EFI implementations
efi: payload: don't require efi_loaded_image->parent_handle for
bootsource detection
commands: add cpuinfo -s option for stacktrace
efi: devicepath: align MemoryMapped name with spec
efi: devicepath: pretty print BBS BEV DeviceType
efi: devicepath: format GUIDs as little endian
efi: devicepath: move END device node definitions into header
efi: devicepath: drop underscores in hex constants
efi: devicepath: namespace definitions
efi: devicepath: use flexible array members for trailing strings
efi: devicepath: drop unused macro
efi: devicepath: let compiler worry about unaligned unpacking
efi: devicepath: correct formatting of BBS
commands: provide efi_handle_dump in both payload and loader
lib: uuid: implement uuid/guid_parse
commands: efi_handle_dump: prepare for supporting EFI loader
commands: efi_handle_dump: print loaded image devpath
commands: efi_handle_dump: use guid_parse instead of open-coding
commands: efi_handle_dump: don't ignore failure to parse GUID
Kconfig | 1 +
Makefile | 7 +-
arch/arm/Kconfig | 1 +
arch/arm/cpu/Kconfig | 1 +
arch/arm/cpu/board-dt-2nd-aarch64.S | 8 +-
arch/arm/cpu/cpu.c | 6 +
arch/arm/cpu/cpuinfo.c | 25 +-
arch/arm/cpu/efi-header-aarch64.S | 122 ++++
arch/arm/cpu/entry.c | 3 +
arch/arm/cpu/interrupts_64.c | 6 +-
arch/arm/cpu/mmu-common.c | 4 +
arch/arm/cpu/mmu_32.c | 3 +
arch/arm/cpu/mmu_64.c | 3 +
arch/arm/cpu/setupc_64.S | 22 +-
arch/arm/cpu/start.c | 16 +-
arch/arm/include/asm/barebox-arm.h | 30 +-
arch/arm/include/asm/memory.h | 20 +
arch/arm/include/asm/pci.h | 4 +-
arch/arm/lib/pbl.lds.S | 31 +
arch/arm/lib64/armlinux.c | 11 +
arch/arm/lib64/runtime-offset.S | 5 +-
arch/riscv/lib/bootm.c | 7 +
arch/sandbox/board/hostfile.c | 3 +-
arch/x86/Kconfig | 3 +-
arch/x86/mach-efi/clocksource.c | 4 +-
arch/x86/mach-efi/reloc_ia32.c | 2 +-
commands/Kconfig | 38 +-
commands/Makefile | 3 +
commands/efi_handle_dump.c | 144 ++++
commands/findmnt.c | 108 +++
commands/kallsyms.c | 50 ++
commands/of_diff.c | 5 +-
commands/of_display_timings.c | 4 +-
commands/of_overlay.c | 4 +-
commands/oftree.c | 4 +-
commands/readlink.c | 2 +-
commands/stat.c | 26 +-
commands/time.c | 11 +-
common/Kconfig | 49 +-
common/Makefile | 2 +-
common/block.c | 26 +-
common/boot.c | 2 +-
common/efi/Kconfig | 27 -
common/efi/payload/Makefile | 7 -
common/filetype.c | 25 +-
common/misc.c | 12 +-
common/partitions.c | 4 +-
common/partitions/dos.c | 10 +
common/partitions/efi.c | 18 +
common/partitions/parser.h | 3 +
common/pe.c | 377 +++++++++++
common/startup.c | 3 +-
drivers/Makefile | 2 +-
drivers/ata/ahci.c | 1 +
drivers/ata/disk_ata_drive.c | 1 +
drivers/block/Kconfig | 2 +-
drivers/block/efi-block-io.c | 28 +-
drivers/block/virtio_blk.c | 2 +
drivers/bus/Kconfig | 2 +-
drivers/bus/acpi.c | 6 +-
drivers/clocksource/Kconfig | 4 +-
drivers/clocksource/efi.c | 4 +-
drivers/efi/Makefile | 3 +-
drivers/efi/efi-device.c | 220 +------
drivers/efi/efi-handle.c | 43 ++
drivers/hw_random/efi-rng.c | 2 +-
drivers/mci/mci-core.c | 3 +-
drivers/net/Kconfig | 2 +-
drivers/net/efi-snp.c | 20 +-
drivers/nvme/host/core.c | 1 +
drivers/nvmem/core.c | 2 +-
drivers/of/Kconfig | 2 +-
drivers/of/of_path.c | 4 +-
drivers/of/overlay.c | 4 +-
drivers/of/partition.c | 12 +-
drivers/pci/Kconfig | 2 +-
drivers/serial/Kconfig | 4 +-
drivers/serial/efi-stdio.c | 23 +-
drivers/usb/storage/usb.c | 1 +
drivers/video/Kconfig | 3 +-
drivers/virtio/virtio.c | 1 +
drivers/watchdog/Kconfig | 2 +-
efi/Kconfig | 48 ++
{common/efi => efi}/Makefile | 2 +-
{common/efi => efi}/devicepath.c | 458 ++++++-------
{common/efi => efi}/efivar-filename.c | 0
{common/efi => efi}/errno.c | 1 +
{common/efi => efi}/guid.c | 36 +-
efi/payload/Makefile | 11 +
efi/payload/boarddata.c | 45 ++
efi/payload/early-mem.c | 28 +
efi/payload/entry-multi.c | 45 ++
efi/payload/entry-single.c | 45 ++
.../payload/env-efi/network/eth0-discover | 0
{common/efi => efi}/payload/fdt.c | 5 +-
{common/efi => efi}/payload/image.c | 104 ++-
{common/efi => efi}/payload/init.c | 144 ++--
{common/efi => efi}/payload/iomem.c | 8 +-
fs/Kconfig | 4 +-
fs/devfs-core.c | 2 +-
fs/efi.c | 59 --
fs/efivarfs.c | 2 +-
fs/fs.c | 531 ++++++++-------
include/acpi.h | 3 +-
include/asm-generic/pe.h | 56 ++
include/ata_drive.h | 5 +-
include/block.h | 18 +-
include/boarddata.h | 49 ++
include/dirent.h | 5 +
include/driver.h | 21 +
include/efi.h | 617 +++++++++++-------
include/efi/device-path.h | 258 ++++----
include/efi/efi-device.h | 19 +-
include/efi/efi-init.h | 51 ++
include/efi/efi-mode.h | 30 +
include/efi/efi-payload.h | 13 +-
include/efi/efi-stdio.h | 11 +-
include/efi/efi-util.h | 8 +-
include/efi/partition.h | 6 +-
include/efi/types.h | 68 ++
include/errno.h | 7 +
include/fcntl.h | 22 +-
include/filetype.h | 6 +-
include/fs.h | 6 +-
include/libfile.h | 4 +
include/linux/export.h | 2 +-
include/linux/hidden.h | 19 +
include/linux/namei.h | 13 -
include/linux/pagemap.h | 1 +
include/linux/pe.h | 468 +++++++++++++
include/linux/string.h | 1 +
include/pbl.h | 4 +
include/pe.h | 316 +++++++++
include/string.h | 13 +
include/sys/stat.h | 8 +-
include/uapi/spec/dps.h | 370 +++++++++++
include/unistd.h | 35 +-
lib/libfile.c | 59 +-
lib/parameter.c | 22 +-
lib/string.c | 49 ++
lib/uuid.c | 63 ++
lib/vsprintf.c | 18 +
pbl/Kconfig | 7 +
scripts/Makefile.lib | 5 +
scripts/Makefile.pic | 22 +
test/self/Kconfig | 5 +
test/self/Makefile | 1 +
test/self/dirfd.c | 129 ++++
test/self/mmu.c | 7 +
test/self/string.c | 28 +
150 files changed, 4742 insertions(+), 1502 deletions(-)
create mode 100644 arch/arm/cpu/efi-header-aarch64.S
create mode 100644 commands/efi_handle_dump.c
create mode 100644 commands/findmnt.c
create mode 100644 commands/kallsyms.c
delete mode 100644 common/efi/Kconfig
delete mode 100644 common/efi/payload/Makefile
create mode 100644 common/pe.c
create mode 100644 drivers/efi/efi-handle.c
create mode 100644 efi/Kconfig
rename {common/efi => efi}/Makefile (80%)
rename {common/efi => efi}/devicepath.c (50%)
rename {common/efi => efi}/efivar-filename.c (100%)
rename {common/efi => efi}/errno.c (99%)
rename {common/efi => efi}/guid.c (77%)
create mode 100644 efi/payload/Makefile
create mode 100644 efi/payload/boarddata.c
create mode 100644 efi/payload/early-mem.c
create mode 100644 efi/payload/entry-multi.c
create mode 100644 efi/payload/entry-single.c
rename {common/efi => efi}/payload/env-efi/network/eth0-discover (100%)
rename {common/efi => efi}/payload/fdt.c (90%)
rename {common/efi => efi}/payload/image.c (76%)
rename {common/efi => efi}/payload/init.c (77%)
rename {common/efi => efi}/payload/iomem.c (95%)
create mode 100644 include/asm-generic/pe.h
create mode 100644 include/boarddata.h
create mode 100644 include/efi/efi-init.h
create mode 100644 include/efi/efi-mode.h
create mode 100644 include/efi/types.h
create mode 100644 include/linux/hidden.h
create mode 100644 include/linux/pe.h
create mode 100644 include/pe.h
create mode 100644 include/uapi/spec/dps.h
create mode 100644 scripts/Makefile.pic
create mode 100644 test/self/dirfd.c
--
2.39.2
More information about the barebox
mailing list