1667 Commits

Author SHA1 Message Date
Ilias Apalodimas
c20372170e lmb: Remove lmb_alloc_base_flags()
lmb_alloc_base() is just calling lmb_alloc_base_flags() with LMB_NONE.
There's not much we gain from this abstraction, so let's remove the
former add the flags argument to lmb_alloc_base() and make the code
a bit easier to follow.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 3075708017)
2025-12-24 05:17:05 -07:00
Ilias Apalodimas
e005799d8f lmb: Remove lmb_alloc_addr_flags()
lmb_alloc_addr() is just calling lmb_alloc_addr_flags() with LMB_NONE
There's not much we gain from this abstraction, so let's remove the
latter, add a flags argument to lmb_alloc_addr() and make the code a
bit easier to follow.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 15e0c5e390)
2025-12-24 05:17:05 -07:00
Simon Glass
ef9b8d95c1 efi: Adjust condition for runtime relocation
Even if CONFIG_ULIB is enabled it may not actually be in use. If not,
we still need the EFI-runtime relocation to happen. Adjust the condition
in efi_runtime_relocate() to fix this.

For static linking with ulib examples, provide weak symbol definitions
for __efi_runtime_rel_start and __efi_runtime_rel_stop. These symbols
are normally defined in linker scripts but need fallback definitions
when linking statically against libu-boot.a.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-12 08:39:49 -07:00
Simon Glass
cf9e4db152 ulib: efi: Disable relocation or runtime-services
This cannot work with the shared library at present, since the symbols
are not defined. Disable it for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 14:23:55 -06:00
Simon Glass
b5fb7fefe8 lib: Rename gen_v5_guid() to indicate it is little-endian
Normally v5 GUIDs are big-endian, so rename this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 07:08:24 -06:00
Simon Glass
8364e9af3e serial: Generalise the code to check the terminal size
The EFI loader has some code to check the size (rows and columns) of an
attached terminal. Move this over to the serial uclass so that it can be
used elsewhere.

Create a new CONFIG_SERIAL_TERM_PRESENT to control whether it should be
used. Enable that for the EFI loader to preserve existing behaviour.

Adjust the implementation so that it returns a useful error code on
failure. Put the ESC and cESC values in the serial.h header.

Series-changes: 3
- Update comment for serial_query_size()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 06:01:53 -06:00
Simon Glass
b0341ef417 efi: Move guid used for variables to common files
Move efi_guid_image_security_database to a common file so that it can be
used by the app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-22 08:23:17 -06:00
Simon Glass
ed609a9439 efi: Use a function to obtain boot services in efi debug
Rather than accessing the EFI loader's structure, create an
efi_get_boot() function to match that used by the app, so that the
call to protocols_per_handle() can operate in the app as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
f06ec4fbcd efi: Move driver-binding guid to a common file
Move efi_guid_driver_binding_protocol to lib/efi so that it can be used
from the app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
fc274ee3d0 efi: Move efi_load_option_dp_join() to a common file
This function is useful in the app so move it to the common helper.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
c43c1681ee efi: Move efi_string utilities to the common directory
This file contains some useful utility functions which are not specific
to the EFI loader. Move them to lib/efi so they can be used by the app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
fe33f0fbfb efi: app: Implement %pD in the app
This printf() extension is useful for the app. Add an implementation of
efi_dp_str() so that it works as expected.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
712bd388ef efi: Move FDT and global-variable GUIDs to common files
The global-variable GUID is already set in the common device_path.c file
but its declaration is only in the efi_loader header.

Move it and also move over the FDT GUIDs.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
4500ade27f efi: Move some load-options handling into the common dir
These functions are useful for the app as well as the loader.

For now, efi_set_load_options() calls efi_search_protocol() which is
still in the loader, but we can provide an 'app' version when needed. It
doesn't seem worth keeping that one function in a separate file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
eeaec57199 efi: Move a few helper functions into the common efi/ dir
Checking if a variable is a load option is useful for the app, so move
efi_varname_is_load_option() and u16_tohex() into a new helper.c file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
9a94bdebbf efi: app: Support efidebug show tables
It is useful to be able to see the available tables in the app, so
enable this subcommand. Provide an implementation of efi_get_sys_table()
that works for the EFI loader.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 09:05:49 -06:00
Simon Glass
a68c0625aa smbios: coreboot: Update smbios_get_header() to use smbios_info
Use the smbios_info struct in this function, so it can deal with any
version of SMBIOS table.

Also update smbios_update_version_full() to work the same way.

Drop find_next_header() which is now unused.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-18 14:00:19 -06:00
Simon Glass
92aad5b59e efi: Move EFI_BINARY_EXEC to lib/efi
The EFI app will eventually execute binaries, but it does not enable
the CONFIG_EFI_LOADER option. So move the option to a common directory.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:11 -06:00
Simon Glass
3d81bf9ac0 efi_loader: Split out efi_binary_run_dp() et all
efi_binary_run_dp() calls efi_init_obj_list() which is specific to the
EFI loader. Move this into a new file within lib/efi_loader

Similarly, move efi_run_image() since the app will need a different
implementation.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:10 -06:00
Simon Glass
73ad2d9909 efi: Move efi_bootflow_run() to a common file
Move this function and some dependencies into the lib/efi directory so
that it can be used by the app, which does not enable CONFIG_EFI_LOADER

Since the networking has an #ifdef add CONFIG_EFI_LOADER to it, since
the definitions are in efi_loader.h for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:10 -06:00
Simon Glass
a48a8929de efi: Move most of efi_device_path into lib/efi
Most of these utility functions are useful for the app, so move them
into the common directory.

Move the GUIDs used by this file from their various other location, so
they are available to the app, even if it doesn't enabled EFI_LOADER

Fix the rather large number of checkpath warnings in this file, except
for the lwip one, best left to the maintainer to sort out.

One noteable change is adding a return value to dp_fill() for the case
where an option is not enabled but its uclass is referenced. This
presuambly never happens during execution, since if the uclass is not
supported there can be no device in that uclass and therefore nothing
will ever request its path. So just handle this like an invalid device.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:59:10 -06:00
Simon Glass
ffde1a3922 efi: Use variables in dp_size()
This function calculates the parent size in many places and does the
same addition in most cases. Create a variable for the parent_size and
another for the size, so we can do the addition once at the end.

The uclass array is too sparse to consider an array.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-08 16:56:46 -06:00
Simon Glass
6da757f538 bootm: Move bootm_disable_interrupts() to bootm_final()
Move disabling of interrupts to bootm_final() so it is done for bootm
and EFI boot paths. Drop the now-duplicate calls.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 16:22:33 -06:00
Simon Glass
ec4efd7f0f bootm: Move board_quiesce_devices(void) to bootm_final()
This function is called just before boot, so move it from EFI into the
common bootm_final() function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 16:18:52 -06:00
Simon Glass
490dbf1968 bootm: Call cleanup_before_linux() from bootm_final()
Add this call to the bootm_final() function, dropping it from RISC-V

Add a flag to ensure that cleanup_before_linux() is not called when
booting an EFI app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 16:18:52 -06:00
Simon Glass
898b951842 efi: Drop EFI_GRUB_ARM32_WORKAROUND
This work-around dates from 2019 and grub 2.04 which is quite old. New
builds of grub don't have the problem and old boards presumably use an
older U-Boot, so don't need this.

Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 16:16:50 -06:00
Simon Glass
a1ae8de12c riscv: Call bootm_final()
Make use of this function, adding some pieces needed by RISC-V

Drop the udc_disconnect() from EFI_LOADER since it is now done in
bootm_final()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 16:14:47 -06:00
Simon Glass
148240871e efi: Make use of bootm_final()
Call this function from the EFI code. Add the required call to
dm_remove_devices_active() there.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 15:59:38 +02:00
Simon Glass
37e7aec2d2 efi_loader: Use the first random-number-generator device
There is no guarantee that the RNG device has a sequence number of zero.
Use the first available device instead, by default.

This resolved a failure to find the device with qemu-x86_64 when the
virtio device is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:10 +02:00
Simon Glass
50d0aeeeff emulation: efi_loader: Set MACH_QEMU with ARCH_QEMU_ARM
Define MACH_QEMU whenever ARCH_QEMU_ARM is used.

Some of the uses of ARCH_QEMU_ARM with efi_loader should clearly apply
to all QEMU variables, so update these.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-05 05:48:28 -06:00
Simon Glass
ab3b9d1d88 emulation: Rename ARCH_QEMU to ARCH_QEMU_ARM
This option looks generic but in fact is specific to ARM. Rename it to
reflect this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-05 05:48:28 -06:00
Simon Glass
8630e568b2 fs: Rename fs_read() to fs_legacy_read()
This existing function does not have any context associated with it.
Rename it so that fs_read() can be used for the new FS uclass.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 12:30:56 -06:00
Simon Glass
8a698cf850 fs: Rename fs.h to fs_legacy.h
A new filesystem interface is coming, so rename the current header to
indicate that it is the old one.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-28 07:53:25 -06:00
Ilias Apalodimas
23c09e4950 efi_loader: Run dhcp if an http boot option is selected
The EFI boot manager relies on having an IP address before trying to
boot an EFI HTTP(s) boot entry. However, defining it as a boot or
pre-boot command is not always the right answer since it will
unconditionally add delay to the board boot, even if we don't boot
over the network.

So let's do a DHCP request from the boot manager, if 'ipaddr' is
empty and fail early if we don't have an address.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Michal Simek <michal.simek@amd.com>
2025-05-28 08:04:23 +01:00
Simon Glass
ed4bb8d982 efi: Move FDT-filename discovery into lib/efi
Move efi_get_distro_fdt_name() into lib/efi so it can be used from the
app.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-28 08:02:11 +01:00
Simon Glass
624cdc9228 efi: Move the base name and PXE info into lib/efi
Move efi_get_basename() and efi_get_pxe_arch() into lib/efi so they can
be used from the app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-28 08:02:11 +01:00
Simon Glass
a07abd67da efi: Create a new CONFIG_EFI
Create a Kconfig which indicates that EFI functionality is in use,
either as a client (EFI app / stub) or provider (EFI loader). This will
make it easier to share code between these two parts of U-Boot

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-28 08:02:11 +01:00
Simon Glass
5f4327ec9f efi: Rename the lib/efi directory
This directory was created when U-Boot gained the ability to run as an
EFI app in 2015. Since then the EFI-loader feature has been added.

The code in lib/efi is not actually used by the loader, so the name is
confusing.

Rename the directory to efi_client to indicate that it includes files
just for U-Boot being a client of EFI, i.e. the EFI app and stub.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-28 08:02:11 +01:00
Simon Glass
fe719aa8e8 efi: Rename END to EFI_DP_END
This exported symbol has a very generic name. Rename it to indicate that
it relates to EFI and device-paths.

Fix checkpatch warnings related to use of multiple assignments.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-28 08:01:43 +01:00
Simon Glass
411847f2a9 efi_loader: Separate device path into its own header
These functions are useful for the EFI app. As a first step towards
making these available outside lib/efi_loader, create a separate header
file and include it where needed. Add proper comments to the functions,
since many are missing at present.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-28 07:59:26 +01:00
Simon Glass
3693046cc4 Revert "efi_loader: Move public cert for capsules to .rodata"
The dtb part of this patch was rejected a few years ago[1][2]

It seems to have crept in under another name.

With signatures in U-Boot itself it is difficult to insert signatures
after U-Boot itself is built. The devicetree approach is more flexible,
since it can be updates by Binman or other build processes.

This reverts commit 261b422aed.

[1] https://patchwork.ozlabs.org/project/uboot/patch/20210802014621.2280899-1-sjg@chromium.org/
[2] https://lore.kernel.org/u-boot/CAPnjgZ1UiJVHxe2qD3GrYO2LBrXWazXsqP_HYUabOXjKRiPZDA@mail.gmail.com/

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27 08:54:57 +01:00
Simon Glass
4cec711b05 Revert "efi_loader: Moved the generated ESL file to objtree"
This reverts commit 31f66cd757.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27 08:54:57 +01:00
Ilias Apalodimas
cc23cb1894 efi_loader: Moved the generated ESL file to objtree
Tom reports that generating the ESL file we need for authenticated
capsule updates fails to work on azure which expects a RO git tree.

Move it to $(objtree)

Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-05-27 08:54:53 +01:00
Vincent Stehlé
60acd3ad87 efi_loader: fix ipv4 device path node conversion
When converting an IPv4 device path node to text, the
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL will produce the following string:

  IPv4(5.6.7.8,TCP,UDP,0x6,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)

This string erroneously contains multiple protocols: TCP, UDP and 0x6.

Add the missing `break' statements in the dp_msging() function to fix this
and obtain the following expected string instead:

  IPv4(5.6.7.8,TCP,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)

Fixes: aaf63429a1 ("efi_loader: add IPv4() to device path to text protocol")
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Adriano Cordova <adrianox@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-05-16 17:03:18 +02:00
Adriano Cordova
67e474cce0 efi_loader: fix typo initd_sz to initrd_sz
Signed-off-by: Adriano Cordova <adriano.cordova@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-05-16 17:03:17 +02:00
Adriano Cordova
70a692335b efi_loader: bootbin: do not load an initrd if none is provided
Do not try to create an initrd device path nor try to register
an initrd with the EFI_LOAD_FILE2_PROTOCOL if none is provided.

Handle initrd installation in efi_binary_run_dp with
efi_install_initrd, imitating what is done for the fdt.

Fixes: 36835a9105 ("efi_loader: binary_run: register an initrd")
Reported-by: Weizhao Ouyang <o451686892@gmail.com>
Signed-off-by: Adriano Cordova <adriano.cordova@canonical.com>
Tested-by: Weizhao Ouyang <o451686892@gmail.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-05-16 17:03:17 +02:00
Adriano Cordova
822fe503fd efi_loader: binary_run: register an initrd
Add support to install an initrd when running an EFI binary
with efi_binary_run

Signed-off-by: Adriano Cordova <adriano.cordova@canonical.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-05-16 17:03:17 +02:00
Simon Glass
6ce4b85cbb efi_loader: Make calculate_paths() static
Update this function and adjust arguments to match us/next

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-16 17:03:17 +02:00
Adriano Cordova
f21461f6b3 efi_loader: fix dtbdump output color and format
Imitate in dtbdump what initrddump does for color,
newlines and input handling. The output parsing in
the CI is strict and with the current output the CI
is not recongnizing the prompt '=>'.

Signed-off-by: Adriano Cordova <adriano.cordova@canonical.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-16 17:03:17 +02:00
Heinrich Schuchardt
d7d334ab7b efi_loader: print image load address in StartImage
When starting image add the image load address to the debug output.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-05-16 14:45:26 +02:00