mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v1 00/54] efi: implement EFI loader support in barebox
Date: Thu, 18 Dec 2025 11:37:20 +0100	[thread overview]
Message-ID: <20251218111242.1527495-1-a.fatoum@pengutronix.de> (raw)

This adds enough support to barebox, so we can boot GRUB and an EFI
stubbed kernel in Debian ARM32 and ARM64 UEFI CDROM installers and
ARM64 nocloud images.

This was mostly tested on Qemu Virt and a RK3568-powered QNAP TS-433eU
and with Debian 13 (Trixie) images.

This builds on lots of great work done on U-Boot. Some of the protocols
differ only little from the U-Boot original, but the parts that are
interfacing with barebox frameworks like memory allocations, file
handling, block devices and so on are understandably different.

I am still debugging an integration test that will boot a Debian kernel
and verify somethings, so that will follow later.

For manual use, here's an example:

  IMG=https://cloud.debian.org/images/cloud/trixie/latest/debian-13-nocloud-arm64.raw
  qemu-system-aarch64 -kernel images/barebox-dt-2nd.img \
  -drive if=virtio,format=raw,snapshot=on,file=$IMG -device virtio-rng -nographic \
  -machine virt,highmem=off -cpu cortex-a57 -m 1024M -serial mon:stdio -trace file=/dev/null

My wishlist for the midterm future:

  - Support for StandaloneMM. Currently only storing the variables in a
    file in the ESP is supported, which is not power-fail safe, doesn't
    allow authenticated variables and doesn't work for setups with
    multiple ESPs (e.g. when installing from USB flash drive).

  - Support for capsules: This would provide us a long missing way
    to expose barebox_update handlers to userspace

  - Making this a sensible default: EFI boot happens with MMU enabled
    and I can see myself using this even with just an EFI-stubbed kernel
    to speed up early kernel boot, but this needs more thorough testing,
    before we enable it in existing defconfigs

  - Implement efibootmgr, so we can boot according to Boot####
    variables. Currently, GRUB or the kernel must either be invoked
    directly or be placed at the removable media path
    (CONFIG_EFI_PAYLOAD_PATH).

  - Turn run time services into a DSO instead of just a section within
    barebox

Ahmad Fatoum (54):
  efi: payload: initrd: fix type mismatch on 32-bit
  efi: loader: switch over event/memory key type to efi_uintn_t
  lib: vsprintf: print human-readable EFI GUIDs with %pUs
  fs: fat: don't duplicate dentries when resolving differently cased
    paths
  efi: loader: add memory accounting
  efi: loader: add pool allocator
  efi: types: add EFI_RUNTIME_SECTION
  resource: assign memory banks a default type and attr
  ARM: lds: add EFI runtime service section
  ARM: move needed assembly routines into EFI runtime section
  crypto: crc32: implement position independent CRC32
  efi: loader: add support for tracing calls back into UEFI
  efi: loader: add table utility functions
  lib: add charset helpers
  efi: loader: add object handling API
  efi: loader: add devicepath support
  efi: loader: add debug support
  efi: loader: add boot services support
  efi: loader: add support for runtime services before ExitBootServices
  efi: loader: setup root node
  efi: loader: add watchdog support
  efi: loader: move PE implementation out of common code
  efi: loader: protocol: add file protocol support
  efi: loader: protocol: add Block IO support
  efi: loader: protocol: implement efi_file_from_path
  efi: loader: boot: implement LoadImage BootService
  efi: loader: add EFI load option handling
  efi: loader: protocol: add graphical output protocol support
  efi: loader: protocol: add console support
  efi: loader: protocol: add HII support
  efi: loader: protocol: add unicode collation support
  efi: loader: protocol: add random number generator protocol
  efi: loader: protocol: add device_path_utilities
  efi: loader: support formatting only first device path node to text
  efi: loader: protocol: add efi_device_path_to_text support
  restart: allow drivers to register runtime restart handler
  poweroff: allow drivers to register runtime poweroff handler
  ARM: psci: client: register runtime service poweroff handler
  ARM: psci: client: register runtime service restart handler
  hardening: disable some features when EFI runtime support is enabled
  filetype: add new filetype for efi-stubbed ARM zImages
  bootm: add global.bootm.efi toggle
  efi: loader: add ESP boot entry provider
  efi: loader: add rudimentary EFI boot manager
  efi: loader: implement bootm handler
  efi: runtime: add EFI variable support
  efi: loader: populate OsIndicationsSupported/PlatformLang variables
  ARM: don't disable MMU when EFI booting
  efi: runtime: add runtime service support after ExitBootServices
  efi: runtime: add relocation check
  efi: loader: CONFIG_EFI_RT_VOLATILE_STORE
  efi: loader: support ExitBootServices
  efi: loader: pass along SMBIOS table
  ARM: configs: add multi_v7/8_efiloader_defconfig

 Makefile                                     |    3 +
 arch/Kconfig                                 |    3 +
 arch/arm/Kconfig                             |    3 +
 arch/arm/Makefile                            |    4 +
 arch/arm/cpu/cpu.c                           |    3 +
 arch/arm/cpu/psci-client.c                   |   27 +-
 arch/arm/cpu/smccc-call_32.S                 |    4 +-
 arch/arm/cpu/smccc-call_64.S                 |    5 +-
 arch/arm/lib32/barebox.lds.S                 |    5 +
 arch/arm/lib32/memcpy.S                      |    3 +-
 arch/arm/lib32/memmove.S                     |    3 +-
 arch/arm/lib32/memset.S                      |    3 +-
 arch/arm/lib64/armlinux.c                    |   14 +-
 arch/arm/lib64/barebox.lds.S                 |    4 +
 arch/arm/lib64/memcpy.S                      |    3 +
 arch/arm/lib64/memset.S                      |    3 +
 arch/riscv/lib/bootm.c                       |   14 +-
 commands/efi_handle_dump.c                   |    4 +-
 common/Kconfig                               |   16 +-
 common/Kconfig.debug                         |   23 +
 common/Makefile                              |    1 -
 common/boards/configs/efi-loader.config      |    2 +
 common/boot.c                                |    7 +-
 common/bootm.c                               |   43 +
 common/filetype.c                            |   20 +-
 common/memory.c                              |   40 +-
 common/pe.c                                  |  382 --
 common/poweroff.c                            |   36 +
 common/restart.c                             |   46 +
 crypto/crc32.c                               |   24 +
 drivers/efi/efi-device.c                     |    4 +-
 efi/Kconfig                                  |   31 +
 efi/Makefile                                 |    2 +
 efi/devicepath.c                             |   17 +-
 efi/guid.c                                   |    4 +-
 efi/initrd.c                                 |    4 +-
 efi/loader/Kconfig                           |   91 +
 efi/loader/Makefile                          |   23 +
 efi/loader/boot.c                            | 3920 ++++++++++++++++++
 efi/loader/bootesp.c                         |  260 ++
 efi/loader/bootm.c                           |  358 ++
 efi/loader/debug_support.c                   |  192 +
 efi/loader/defaultvars.c                     |  122 +
 efi/loader/devicepath.c                      | 1073 +++++
 efi/loader/efi_var_common.c                  |  475 +++
 efi/loader/efi_var_file.c                    |  254 ++
 efi/loader/efi_var_mem.c                     |   80 +
 efi/loader/efi_variable.c                    |  214 +
 efi/loader/efibootmgr.c                      |   79 +
 efi/loader/loadopts.c                        |  181 +
 efi/loader/memory.c                          |  415 ++
 efi/loader/pe.c                              |  727 ++++
 efi/loader/pool_alloc.c                      |  205 +
 efi/loader/protocols/Kconfig                 |   56 +
 efi/loader/protocols/Makefile                |   11 +
 efi/loader/protocols/console.c               | 1327 ++++++
 efi/loader/protocols/device_path_to_text.c   |  130 +
 efi/loader/protocols/device_path_utilities.c |  210 +
 efi/loader/protocols/disk.c                  |  412 ++
 efi/loader/protocols/file.c                  | 1044 +++++
 efi/loader/protocols/gop.c                   |  572 +++
 efi/loader/protocols/hii.c                   | 1100 +++++
 efi/loader/protocols/hii_config.c            |  157 +
 efi/loader/protocols/rng.c                   |  165 +
 efi/loader/protocols/unicode_collation.c     |  329 ++
 efi/loader/runtime.c                         |  314 ++
 efi/loader/setup.c                           |  233 ++
 efi/loader/smbios.c                          |   55 +
 efi/loader/table.c                           |   31 +
 efi/loader/trace.c                           |   44 +
 efi/loader/variable.h                        |   35 +
 efi/loader/watchdog.c                        |   94 +
 efi/payload/bootm.c                          |    1 +
 efi/payload/init.c                           |    2 +-
 efi/runtime/Kconfig                          |   44 +
 efi/runtime/Makefile                         |   53 +
 efi/runtime/common.h                         |   35 +
 efi/runtime/efi_var_mem.c                    |  380 ++
 efi/runtime/efi_variable.c                   |  211 +
 efi/runtime/services.c                       |  303 ++
 fs/fat/fat.c                                 |    1 +
 fs/fs.c                                      |   10 +
 include/asm-generic/barebox.lds.h            |   40 +
 include/asm-generic/sections.h               |   10 +
 include/bootm.h                              |   12 +
 include/capitalization.h                     | 2029 +++++++++
 include/charset.h                            |  346 ++
 include/crc.h                                |    2 +
 include/efi/attributes.h                     |   84 +
 include/efi/devicepath.h                     |    5 +-
 include/efi/guid.h                           |    2 +-
 include/efi/loader.h                         |   86 +
 include/efi/loader/debug.h                   |   73 +
 include/efi/loader/devicepath.h              |   66 +
 include/efi/loader/event.h                   |   93 +
 include/efi/loader/file.h                    |   33 +
 include/efi/loader/image.h                   |   18 +
 include/efi/loader/object.h                  |  137 +
 include/efi/loader/option.h                  |   36 +
 include/efi/loader/pe.h                      |   83 +
 include/efi/loader/table.h                   |   11 +
 include/efi/loader/trace.h                   |  111 +
 include/efi/loader/variable.h                |  153 +
 include/efi/mode.h                           |   23 +-
 include/efi/protocol/devicepath.h            |   42 +
 include/efi/protocol/gop.h                   |    9 +
 include/efi/protocol/hii.h                   |  428 ++
 include/efi/protocol/text.h                  |   32 +-
 include/efi/protocol/unicode_collation.h     |   24 +
 include/efi/runtime.h                        |  164 +
 include/efi/services.h                       |   28 +-
 include/efi/table/rt_properties.h            |   30 +
 include/efi/types.h                          |   14 +
 include/efi/variable.h                       |    7 +-
 include/filetype.h                           |    2 +
 include/libfile.h                            |    2 +
 include/linux/fs.h                           |    1 +
 include/linux/ioport.h                       |    2 +
 include/memory.h                             |    2 +
 include/pe.h                                 |   47 +-
 include/poweroff.h                           |    2 +
 include/restart.h                            |    3 +
 lib/Kconfig                                  |   16 +
 lib/Kconfig.hardening                        |    2 +
 lib/Makefile                                 |    2 +
 lib/charset.c                                |  583 +++
 lib/cp437.h                                  |   48 +
 lib/libfile.c                                |   56 +
 lib/vsprintf.c                               |   25 +-
 scripts/check-efi-runtime.sh                 |   13 +
 test/self/printf.c                           |    4 +
 131 files changed, 21392 insertions(+), 487 deletions(-)
 create mode 100644 common/boards/configs/efi-loader.config
 delete mode 100644 common/pe.c
 create mode 100644 efi/loader/Kconfig
 create mode 100644 efi/loader/Makefile
 create mode 100644 efi/loader/boot.c
 create mode 100644 efi/loader/bootesp.c
 create mode 100644 efi/loader/bootm.c
 create mode 100644 efi/loader/debug_support.c
 create mode 100644 efi/loader/defaultvars.c
 create mode 100644 efi/loader/devicepath.c
 create mode 100644 efi/loader/efi_var_common.c
 create mode 100644 efi/loader/efi_var_file.c
 create mode 100644 efi/loader/efi_var_mem.c
 create mode 100644 efi/loader/efi_variable.c
 create mode 100644 efi/loader/efibootmgr.c
 create mode 100644 efi/loader/loadopts.c
 create mode 100644 efi/loader/memory.c
 create mode 100644 efi/loader/pe.c
 create mode 100644 efi/loader/pool_alloc.c
 create mode 100644 efi/loader/protocols/Kconfig
 create mode 100644 efi/loader/protocols/Makefile
 create mode 100644 efi/loader/protocols/console.c
 create mode 100644 efi/loader/protocols/device_path_to_text.c
 create mode 100644 efi/loader/protocols/device_path_utilities.c
 create mode 100644 efi/loader/protocols/disk.c
 create mode 100644 efi/loader/protocols/file.c
 create mode 100644 efi/loader/protocols/gop.c
 create mode 100644 efi/loader/protocols/hii.c
 create mode 100644 efi/loader/protocols/hii_config.c
 create mode 100644 efi/loader/protocols/rng.c
 create mode 100644 efi/loader/protocols/unicode_collation.c
 create mode 100644 efi/loader/runtime.c
 create mode 100644 efi/loader/setup.c
 create mode 100644 efi/loader/smbios.c
 create mode 100644 efi/loader/table.c
 create mode 100644 efi/loader/trace.c
 create mode 100644 efi/loader/variable.h
 create mode 100644 efi/loader/watchdog.c
 create mode 100644 efi/runtime/Kconfig
 create mode 100644 efi/runtime/Makefile
 create mode 100644 efi/runtime/common.h
 create mode 100644 efi/runtime/efi_var_mem.c
 create mode 100644 efi/runtime/efi_variable.c
 create mode 100644 efi/runtime/services.c
 create mode 100644 include/capitalization.h
 create mode 100644 include/charset.h
 create mode 100644 include/efi/loader.h
 create mode 100644 include/efi/loader/debug.h
 create mode 100644 include/efi/loader/devicepath.h
 create mode 100644 include/efi/loader/event.h
 create mode 100644 include/efi/loader/file.h
 create mode 100644 include/efi/loader/image.h
 create mode 100644 include/efi/loader/object.h
 create mode 100644 include/efi/loader/option.h
 create mode 100644 include/efi/loader/pe.h
 create mode 100644 include/efi/loader/table.h
 create mode 100644 include/efi/loader/trace.h
 create mode 100644 include/efi/loader/variable.h
 create mode 100644 include/efi/protocol/devicepath.h
 create mode 100644 include/efi/protocol/hii.h
 create mode 100644 include/efi/protocol/unicode_collation.h
 create mode 100644 include/efi/runtime.h
 create mode 100644 include/efi/table/rt_properties.h
 create mode 100644 lib/charset.c
 create mode 100644 lib/cp437.h
 create mode 100755 scripts/check-efi-runtime.sh

-- 
2.47.3




             reply	other threads:[~2025-12-18 11:13 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18 10:37 Ahmad Fatoum [this message]
2025-12-18 10:37 ` [PATCH v1 01/54] efi: payload: initrd: fix type mismatch on 32-bit Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 02/54] efi: loader: switch over event/memory key type to efi_uintn_t Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 03/54] lib: vsprintf: print human-readable EFI GUIDs with %pUs Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 04/54] fs: fat: don't duplicate dentries when resolving differently cased paths Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 05/54] efi: loader: add memory accounting Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 06/54] efi: loader: add pool allocator Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 07/54] efi: types: add EFI_RUNTIME_SECTION Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 08/54] resource: assign memory banks a default type and attr Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 09/54] ARM: lds: add EFI runtime service section Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 10/54] ARM: move needed assembly routines into EFI runtime section Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 11/54] crypto: crc32: implement position independent CRC32 Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 12/54] efi: loader: add support for tracing calls back into UEFI Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 13/54] efi: loader: add table utility functions Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 14/54] lib: add charset helpers Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 15/54] efi: loader: add object handling API Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 16/54] efi: loader: add devicepath support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 17/54] efi: loader: add debug support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 18/54] efi: loader: add boot services support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 19/54] efi: loader: add support for runtime services before ExitBootServices Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 20/54] efi: loader: setup root node Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 21/54] efi: loader: add watchdog support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 22/54] efi: loader: move PE implementation out of common code Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 23/54] efi: loader: protocol: add file protocol support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 24/54] efi: loader: protocol: add Block IO support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 25/54] efi: loader: protocol: implement efi_file_from_path Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 26/54] efi: loader: boot: implement LoadImage BootService Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 27/54] efi: loader: add EFI load option handling Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 28/54] efi: loader: protocol: add graphical output protocol support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 29/54] efi: loader: protocol: add console support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 30/54] efi: loader: protocol: add HII support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 31/54] efi: loader: protocol: add unicode collation support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 32/54] efi: loader: protocol: add random number generator protocol Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 33/54] efi: loader: protocol: add device_path_utilities Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 34/54] efi: loader: support formatting only first device path node to text Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 35/54] efi: loader: protocol: add efi_device_path_to_text support Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 36/54] restart: allow drivers to register runtime restart handler Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 37/54] poweroff: allow drivers to register runtime poweroff handler Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 38/54] ARM: psci: client: register runtime service " Ahmad Fatoum
2025-12-18 10:37 ` [PATCH v1 39/54] ARM: psci: client: register runtime service restart handler Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 40/54] hardening: disable some features when EFI runtime support is enabled Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 41/54] filetype: add new filetype for efi-stubbed ARM zImages Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 42/54] bootm: add global.bootm.efi toggle Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 43/54] efi: loader: add ESP boot entry provider Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 44/54] efi: loader: add rudimentary EFI boot manager Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 45/54] efi: loader: implement bootm handler Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 46/54] efi: runtime: add EFI variable support Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 47/54] efi: loader: populate OsIndicationsSupported/PlatformLang variables Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 48/54] ARM: don't disable MMU when EFI booting Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 49/54] efi: runtime: add runtime service support after ExitBootServices Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 50/54] efi: runtime: add relocation check Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 51/54] efi: loader: CONFIG_EFI_RT_VOLATILE_STORE Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 52/54] efi: loader: support ExitBootServices Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 53/54] efi: loader: pass along SMBIOS table Ahmad Fatoum
2025-12-18 10:38 ` [PATCH v1 54/54] ARM: configs: add multi_v7/8_efiloader_defconfig Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251218111242.1527495-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox