summaryrefslogtreecommitdiff
path: root/lib/efi_loader
AgeCommit message (Collapse)Author
2026-03-14efi_vars: Implement SPI Flash storeShantur Rathore
Currently U-Boot uses ESP as storage for EFI variables. Devices with SPI Flash are used for storing environment with this commit we allow EFI variables to be stored on SPI Flash. Signed-off-by: Shantur Rathore <[email protected]> Signed-off-by: Michal Simek <[email protected]> Tested-by: Neil Armstrong <[email protected]> # on AML-S905D3-CC Acked-by: Ilias Apalodimas <[email protected]>
2026-03-14efi_loader: avoid superfluous variable store writes on unchanged dataMichal Simek
Every SetVariable() call triggers efi_var_mem_ins() followed by efi_var_to_storage(), even when the variable value is not actually changing. This is unfriendly to flash-backed stores that suffer wear from unnecessary erase/write cycles. Add a change-detection path to efi_var_mem_ins(): when size2 == 0 (i.e. not an append) and the caller passes a non-NULL changep flag, look up the existing variable and compare attributes, length, time and data byte-by-byte. If everything matches, set *changep = false and return EFI_SUCCESS without touching the variable buffer. Both efi_set_variable_int() and efi_set_variable_runtime() now check the flag and skip efi_var_mem_del() / efi_var_to_storage() when nothing changed. Introduce efi_memcmp_runtime() - a runtime-safe byte-by-byte memory comparison helper, following the same pattern as the existing efi_memcpy_runtime(). The standard memcmp() is not available after ExitBootServices() and calling it from Linux will crash. Tested-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Michal Simek <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2026-03-14efi_loader: avoid buffer overrun in efi_var_restore()Heinrich Schuchardt
The value of buf->length comes from outside U-Boot and may be incorrect. We must avoid to overrun our internal buffer for excessive values. If buf->length is shorter than the variable file header, the variable file is invalid. Reviewed-by: Ilias Apalodimas <[email protected]> Tested-by: Michal Simek <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2026-03-14efi_loader: export efi_ecpt_guidVincent Stehlé
Export the ECPT GUID, to prepare accessing it from more than one location. The C file containing the GUID is compiled only when CONFIG_EFI_ECPT is set; gate the export accordingly. Signed-off-by: Vincent Stehlé <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Tom Rini <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2026-03-14efi_loader: require at least 128 KiB of stack spaceHeinrich Schuchardt
The UEFI specification requires at least 128 KiB stack space. Consider this value as a prerequisite for CONFIG_EFI_LOADER. Mention the requirement in the CONFIG_STACK_SPACE description and decribe that the UEFI sub-system uses CONFIG_STACK_SPACE when defining the memory map. Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2026-03-09Merge tag 'v2026.04-rc4' into nextTom Rini
Prepare v2026.04-rc4
2026-02-27efi_loader: fix specific LoadImage() return codeVincent Stehlé
When the LoadImage() UEFI function is called with both its SourceBuffer and DevicePath input arguments equal to NULL, it must return EFI_NOT_FOUND [1]. However, it does return EFI_INVALID_PARAMETER instead; fix it. Link: https://uefi.org/specs/UEFI/2.11/07_Services_Boot_Services.html#efi-boot-services-loadimage [1] Reported-by: Sathisha Shivaramappa <[email protected]> Signed-off-by: Vincent Stehlé <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Tom Rini <[email protected]>
2026-02-23Merge tag 'v2026.04-rc3' into nextTom Rini
Prepare v2026.04-rc3
2026-02-17Merge patch series "treewide: Clean up usage of DECLARE_GLOBAL_DATA_PTR"Tom Rini
Peng Fan (OSS) <[email protected]> says: This patch set primarily removes unused DECLARE_GLOBAL_DATA_PTR instances. Many files declare DECLARE_GLOBAL_DATA_PTR and include asm/global_data.h even though gd is never used. In these cases, asm/global_data.h is effectively treated as a proxy header, which is not a good practice. Following the Include What You Use principle, files should include only the headers they actually depend on, rather than relying on global_data.h indirectly. This approach is also adopted in Linux kernel [1]. The first few patches are prepartion to avoid building break after remove the including of global_data.h. A script is for filtering the files: list=`find . -name "*.[ch]"` for source in ${list} do result=`sed -n '/DECLARE_GLOBAL_DATA_PTR/p' ${source}` if [ "${result}" == "DECLARE_GLOBAL_DATA_PTR;" ]; then echo "Found in ${source}" result=`sed -n '/\<gd\>/p' ${source}` result2=`sed -n '/\<gd_/p' ${source}` result3=`sed -n '/\<gd->/p' ${source}` if [ "${result}" == "" ] && [ "${result2}" == "" ] && [ "${result3}" == "" ];then echo "Cleanup ${source}" sed -i '/DECLARE_GLOBAL_DATA_PTR/{N;/\n[[:space:]]*$/d;s/.*\n//;}' ${source} sed -i '/DECLARE_GLOBAL_DATA_PTR/d' ${source} sed -i '/global_data.h/d' ${source} git add ${source} fi fi done [1] https://lpc.events/event/17/contributions/1620/attachments/1228/2520/Linux%20Kernel%20Header%20Optimization.pdf CI: https://github.com/u-boot/u-boot/pull/865 Link: https://lore.kernel.org/r/[email protected]
2026-02-17treewide: Clean up DECLARE_GLOBAL_DATA_PTR usagePeng Fan
Remove DECLARE_GLOBAL_DATA_PTR from files where gd is not used, and drop the unnecessary inclusion of asm/global_data.h. Headers should be included directly by the files that need them, rather than indirectly via global_data.h. Reviewed-by: Patrice Chotard <[email protected]> #STMicroelectronics boards and STM32MP1 ram test driver Tested-by: Anshul Dalal <[email protected]> #TI boards Acked-by: Yao Zi <[email protected]> #TH1520 Signed-off-by: Peng Fan <[email protected]>
2026-02-15efi_loader: Setup default location for UEFI Variables storingMichal Simek
EFI_VARIABLE_FILE_STORE is only available when FAT_WRITE is enabled but that's not valid for all platforms and dependency should be covered. Also Kconfig behavior is that if default option is not valid then Kconfig selects the first presented valid option instead hence it is better to record EFI_VARIABLE_NO_STORE as safe default option. Suggested-by: Tom Rini <[email protected]> Signed-off-by: Michal Simek <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2026-02-15efi_var: Unify read/write access helper functionMichal Simek
efi_var_to/from_file() suggest method where variables are placed. But there is no reason for it and generic name can be used to wire also different locations for variables. Signed-off-by: Michal Simek <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Tested-by: Neil Armstrong <[email protected]> # on AML-S905D3-CC Reviewed-by: Heinrich Schuchardt <[email protected]>
2026-02-15efi_var_file: refactor to move buffer functionsShantur Rathore
Currently efi_var_file.c has functions to store/read EFI variables to/from memory buffer. These functions can be used with other EFI variable stores so move them out to efi_var_common.c Signed-off-by: Shantur Rathore <[email protected]> Signed-off-by: Michal Simek <[email protected]> Tested-by: Neil Armstrong <[email protected]> # on AML-S905D3-CC Reviewed-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2026-02-15efi_loader: disk: Extend EFI_PARTITION_INFO_PROTOCOL to support MBRJavier Martinez Canillas
The EFI_PARTITION_INFO_PROTOCOL provides detailed information about partitions. The UEFI specification mentions that both GPT and MBR partition schemes are supported, but the U-Boot implementation only supports the former. This can cause compatibility issues for platforms whose boot ROM only supports MBR. This change adds support for MBR partition tables to the protocol, making U-Boot compatible with systems that require a legacy MBR table. Signed-off-by: Javier Martinez Canillas <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2026-02-15efi_loader: fix ecpt size computationVincent Stehlé
The size of the memory allocated for the EFI Conformance Profiles Table is computed with `num_entries' always equal to zero, which is incorrect when CONFIG_EFI_EBBR_2_1_CONFORMANCE is enabled. This can be verified by allocating the ECPT memory with malloc() instead of efi_allocate_pool(), building u-boot with sandbox_defconfig and CONFIG_VALGRIND=y, and by finally running the following command: valgrind --suppressions=scripts/u-boot.supp \ ./u-boot -T -c 'efidebug tables' Fix this by using an array of the supported profiles GUIDs instead, which should also be easier to extend in the future as U-Boot should publish the GUIDs for all supported EBBR revisions. Fixes: 6b92c1735205 ("efi: Create ECPT table") Suggested-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Vincent Stehlé <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Tom Rini <[email protected]> Cc: Jose Marinho <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2026-02-15efi_loader: add missing EFI_CALL around tcg2 read_blocks callsVincent Stehlé
The read_blocks() function from the Block IO protocol is a UEFI function; make sure to call it from within U-Boot using the EFI_CALL() macro. To demonstrate the issue on an AArch64 machine, define the DEBUG macro in include/efi_loader.h and build u-boot with sandbox_defconfig, then download and uncompress the ACS-DT image [1], and finally execute the following command: $ ./u-boot -T -c " \ host bind 0 systemready-dt_acs_live_image.wic; \ setenv loadaddr 0x10000; \ load host 0 \${loadaddr} EFI/BOOT/Shell.efi; \ bootefi \${loadaddr} \${fdtcontroladdr}" The following assertion should fail: lib/efi_loader/efi_net.c:858: efi_network_timer_notify: Assertion `__efi_entry_check()' failed. This happens due to the following EFIAPI functions call chain: efi_start_image() efi_disk_read_blocks() (due to the missing EFI_CALL, entry_count == 2) efi_network_timer_notify() Link: https://github.com/ARM-software/arm-systemready/releases/download/v25.12_DT_3.1.1/systemready-dt_acs_live_image.wic.xz [1] Fixes: ce3dbc5d080d ("efi_loader: add UEFI GPT measurement") Signed-off-by: Vincent Stehlé <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Tom Rini <[email protected]> Cc: Masahisa Kojima <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Acked-by: Masahisa Kojima <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2026-02-11fwu: Pass bank state enum to fwu_state_machine_updates()Kory Maincent
Change fwu_state_machine_updates() to accept an enum fwu_bank_states parameter instead of a boolean. This makes the function interface more explicit and prepares for adding FWU_BANK_INVALID support to handle boot failures on the active bank. Convert the FWU_BANK_* defines to an enum and update all call sites accordingly. Signed-off-by: Kory Maincent <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2026-02-06efi_net: add missing EFI_CALL in efi_netVincent Stehlé
The efi_reinstall_protocol_interface() function is a UEFI function; make sure to call it from within U-Boot using the EFI_CALL() macro. This fixes the following assertion: lib/efi_loader/efi_boottime.c:3752: efi_reinstall_protocol_interface: Assertion `__efi_entry_check()' failed. To reproduce the issue, define LOG_DEBUG in lib/efi_loader/efi_boottime.c and build u-boot for your platform. Then, boot the U-Boot helloworld.efi application over the network. Example commands (adjust the URL and boot entry number): => efidebug boot add -u 0 net http://10.0.2.2:8000/helloworld.efi => efidebug boot order 0 => bootefi bootmgr Fixes: dd5d82a59995 ("efi_loader: efi_net: Add device path cache") Signed-off-by: Vincent Stehlé <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Tom Rini <[email protected]> Cc: Adriano Cordova <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2026-02-06efi_loader: fix efi_debug_image_info_normal allocationVincent Stehlé
When adding a new EFI Debug Image Info entry, we allocate memory for a new EFI Debug Image Info Normal structure and we add a new entry into the EFI Debug Image Info Table, which is in fact just a pointer to the allocated structure. However, when allocating memory for the new structure we allocate memory for the wrong type, leading to allocating memory for just a pointer instead of the desired structure. Fix the type used during allocation. Fixes: 146546138af5 ("efi: add EFI_DEBUG_IMAGE_INFO for debug") Signed-off-by: Vincent Stehlé <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Tom Rini <[email protected]> Cc: Ying-Chun Liu (PaulLiu) <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2026-02-06efi_loader: Improve EFI variable load messagePranav Tilak
Change the EFI variable load message from log_err() to log_info() with neutral wording. The previous "Failed to load" message caused customer confusion as it appeared to indicate an error condition. The efi_var_from_file() function deliberately returns EFI_SUCCESS in this case to allow the boot process to continue normally. This is documented in the function's comment block but was not reflected in the log message level or content. The message now uses informational wording to reflect that this is normal behavior when the ubootefi.var file does not yet exist. Signed-off-by: Pranav Tilak <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2026-02-06efi_loader: fix use after free in efi_exit() with tcg2Vincent Stehlé
The efi_exit() function frees the loaded image memory by calling efi_delete_image(). However, when CONFIG_EFI_TCG2_PROTOCOL is enabled, the image_obj->image_type structure member is accessed after the memory has been freed. Fix this by performing the tcg2 measurement before the image deletion. Fixes: 8fc4e0b4273a ("efi_loader: add boot variable measurement") Suggested-by: Ilias Apalodimas <[email protected]> Signed-off-by: Vincent Stehlé <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Tom Rini <[email protected]> Cc: Masahisa Kojima <[email protected]> Acked-by: Masahisa Kojima <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2026-01-02kbuild: Bump the build system to 6.1Sughosh Ganu
Our last sync with the kernel was 5.1. We are so out of sync now, that tracking the patches and backporting them one by one makes little sense and it's going to take ages. This is an attempt to sync up Makefiles to 6.1. Unfortunately due to sheer amount of patches this is not easy to review, but that's what we decided during a community call for the bump to 5.1, so we are following the same guidelines here. Signed-off-by: Sughosh Ganu <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>a #rebased on -next
2025-12-24efi_loader: Trigger capsule updates with automatically generated boot optionsIlias Apalodimas
The EFI spec in §8.5.5 says "The directory \EFI\UpdateCapsule is checked for capsules only within the EFI system partition on the device specified in the active boot option determine by reference to BootNext variable or BootOrder variable processing." Automatically generated boot options don't point to the ESP, they point to the disk itself and find_handle() won't match when searching for an ESP during a capsule update. This happens because find_handle() only matches device paths that are shorter or equal to the device path passed as an argument. Since the EFI spec allows it we want to allow capsule updates, when the boot option points to a disk, but that disk contains an ESP with a \EFI\UpdateCapsule directory. So, let's change device_is_present_and_system_part() and check if the supplied device path contains an ESP. If it does return the handle of the device. Otherwise, iterate over child devices and return the handle of the first child that contains an ESP. The returned handle can then be reused later. Rather than calling efi_fs_from_path(), we can simply look up the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on the discovered handle, avoiding the need to re-parse device paths. Reported-by: Balaji Selvanathan <[email protected]> Reported-by: John Toomey <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2025-12-08Merge tag 'v2026.01-rc4' into nextTom Rini
Prepare v2026.01-rc4
2025-12-06efi_loader: Fix a memory leak when retrieving device paths from boot varsIlias Apalodimas
get_dp_device() is used to derive the device path from a boot variable. However, if the last efi_get_variable_int() call fails, we return an error without freeing 'buf'. There's no need to call efi_get_variable_int() for variables we don't know the size since we have the efi_get_var() wrapper. Replace that in the two instances we use it. The first one will also fix the memory leak. A nice sideeffect is that the code size is also reduced, since we are re-using functions instead of open coding them $~ bloat-o-meter u-boot u-boot.new add/remove: 0/0 grow/shrink: 1/2 up/down: 6/-196 (-190) Function old new delta version_string 70 76 +6 efi_launch_capsules 2288 2196 -92 get_dp_device 244 140 -104 Total: Before=1222331, After=1222141, chg -0.02% Fixes: c74cd8bd08d1 ("efi_loader: capsule: add capsule_on_disk support") Signed-off-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2025-12-04tpm2: add sm3 256 hash supportHeiko Schocher
add sm3 256 hash support, so TPM2 chips which report 5 pcrs with sm3 hash do not fail with: u-boot=> tpm2 autostart tpm2_get_pcr_info: too many pcrs: 5 Error: -90 Signed-off-by: Heiko Schocher <[email protected]>
2025-11-15efi_loader: Assure fitImage from capsule is used from 8-byte aligned addressMarek Vasut
The fitImage may be stored in EFI update capsule at address that is not aligned to 8 bytes. Since fitImage is a DT, new version of libfdt 1.7.2 rejects such an unaligned DT. Patch the code and copy the fitImage into aligned buffer in case it is not aligned. This does increase overhead for unaligned fitImages in EFI capsules, but tries to keep the overhead low for aligned ones. Signed-off-by: Marek Vasut <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2025-11-15efi_loader: typo 'eventfor' in efi_ipconfig.cHeinrich Schuchardt
%s/eventfor/event for/ Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-11-06efi_loader: typo 'mange' in efi_net.cHeinrich Schuchardt
%s/mange/manage/ Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-10-26efi_loader: efi_console: support editable input fieldsCasey Connolly
When editing eficonfig "optional data" (typically cmdline arguments) it's useful to be able to edit the string rather than having to re-type the entire thing. Implement support for editing buffers to make this a whole lot nicer. Specifically, add support for moving the cursor with the arrow keys and End key as well as deleting backwards with the delete key. Signed-off-by: Casey Connolly <[email protected]> Acked-by: Ilias Apalodimas <[email protected]> Tested-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-10-18efi_loader: dbginfodump: use guid definitionVincent Stehlé
Use the Debug Image Info Table GUID definition from efi_api.h instead or redefining it locally. Signed-off-by: Vincent Stehlé <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Tom Rini <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2025-10-18efi_loader: Use ESRT_FW_TYPE_SYSTEMFIRMWARE instead of ESRT_FW_TYPE_UNKNOWNIlias Apalodimas
We currently set the firmware image type to ESRT_FW_TYPE_UNKNOWN. The spec defines the following: ESRT_FW_TYPE_UNKNOWN 0x00000000 ESRT_FW_TYPE_SYSTEMFIRMWARE 0x00000001 ESRT_FW_TYPE_DEVICEFIRMWARE 0x00000002 ESRT_FW_TYPE_UEFIDRIVER 0x00000003 Since we don't support updating DEVICEFIRMWARE or UEFIDRIVER types, let's switch over to SYSTEMFIRMWARE which seems more appropriate. Suggested-by: Michal Simek <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2025-10-18efi_loader: correctly check if the HTTP protocol is foundHeinrich Schuchardt
In function efi_http_service_binding_destroy_child() phandler is created as as a local variable. If efi_search_protocol() fails, phandler will hold a random value from the stack. Even it is not zero, we must not use it. If efi_search_protocol() succeeds, the pointer has already be dereferenced, so checking against NULL makes not sense here. If ChildHandle is not a valid UEFI handle, we must return EFI_INVALID_PARAMETER. Use a single location for EFI_EXIT(). Addresses-Coverity-ID: CID 531974 (Unchecked return value) Fixes: 5753dc3f6572 ("efi_loader: Prevent dereference of uninitialised variable") Reviewed-by: Ilias Apalodimas <[email protected]> Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-10-18efi_loader: Prevent leak of memory from tmp_filesAndrew Goodbody
After the malloc of tmp_files and before its value is recorded an early exit will need to free tmp_files to prevent leaking that memory. This issue was found by Smatch. Signed-off-by: Andrew Goodbody <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2025-10-14efi_loader: Improve disk image detection in efi_bootmgrJavier Tia
Enhances the process for identifying disk images within the EFI boot manager. Utilize part_driver_lookup_type() to verify the validity of a downloaded file as a disk image, rather than depending on file extensions. part_driver_lookup_type() is now used in the prepare_loaded_image() function in the EFI boot manager to detect partitions on a block device created from a downloaded image. This allows the boot manager to boot from any disk image that can be recognized by a partition driver, not just ISO and IMG images. Update prepare_loaded_image() to create the ramdisk block device internally, obtain the blk_desc and use part_driver_lookup_type() to detect a valid partition table. In try_load_from_uri_path(), try prepare_loaded_image() first to detect disk images, and fall back to PE-COFF detection only if that fails. Signed-off-by: Javier Tia <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2025-09-27efi_loader: Cleanup UEFI Variables menu selectionMichal Simek
There are 3 options listed between choice/endchoice FILE/TEE/NO_STORE. There is no reason to add other config with dependencies between choice/endchoice because they can never be selected because they depends on only that 3 options which can be selected. That's why move additional configuration with dependency below choice section. Signed-off-by: Michal Simek <[email protected]>
2025-08-30efi: Select also CMD_DHCP from EFI_HTTP_BOOTJan Kiszka
This is needed because distro_efi_read_bootflow_net will then need dhcp_run which is not already enabled by CMD_NET. Signed-off-by: Jan Kiszka <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2025-08-30efi_loader: Make EFI_VARIABLES_PRESEED depend on !COMPILE_TESTTom Rini
When doing compile testing build we cannot rely on having a valid file for EFI_VAR_SEED_FILE to exist, so disable this option when doing compile tests. Signed-off-by: Tom Rini <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Acked-by: Heinrich Schuchardt <[email protected]>
2025-07-26efi_loader: add missing check in FMP.GetImageInfo()Heinrich Schuchardt
The UEFI 2.11 specification, chapter 23.1.3 requires EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetImageInfo() to return EFI_INVALID_PARAMETER if *ImageInfoSize is not too small and ImageInfo is NULL. Fixes: f27c20148511 ("efi_loader: add firmware management protocol for FIT image") Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-07-26efi_loader: correct EFI_DEBUG_TABLE_ENTRY_SIZEHeinrich Schuchardt
With the current code we allocate to little memory when adding entries to the EFI_DEBUG_INFO_TABLE and we fail to correctly move entries when an entry is removed. EFI_DEBUG_TABLE_ENTRY_SIZE must be the size of an entry in the EFI_DEBUG_INFO_TABLE, not the size of a pointer. Fixes: 146546138af5 ("efi: add EFI_DEBUG_IMAGE_INFO for debug") Addresses-Coverity-ID: CID 569498: Code maintainability issues (SIZEOF_MISMATCH) Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-07-26efi_loader: efi_realloc() must check efi_alloc() return valueHeinrich Schuchardt
Avoid copying to NULL if out of memory. Fixes: 3c08df58cc43 ("lib: efi_loader: efi_memory.c: add efi_realloc() for realloc memory") Addresses-Coverity-ID: 569499: Null pointer dereferences (NULL_RETURNS) Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-07-26efi: Create a new CONFIG_EFISimon Glass
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 <[email protected]>
2025-07-26efi: Rename the lib/efi directorySimon Glass
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 <[email protected]>
2025-07-07Merge branch 'next'Tom Rini
2025-07-03efi_loader: add dbginfodump.efiHeinrich Schuchardt
Provide a test application to dump the EFI_DEBUG_IMAGE_INFO_TABLE as implemented in EDK II. EFI_DEBUG_IMAGE_INFO is not packed in contrast to many other EFI structures. As of today EDK II when removing an entry in the EfiDebugImageInfoTable just sets NormalImage = NULL but does not compact the array. So TableSize reflects the number of non-NULL entries and not the array size as reported independently in https://github.com/tianocore/edk2/pull/11013 and https://github.com/tianocore/edk2/pull/11019. The current implementation tolerates this deviation from the UEFI specification. This is what the output may look like: Debug Info Table Dump ===================== => dump Modified Number of entries: 0x0000004a Info type 0x00000001 Address: [0x000000008315a000, 0x00000000831bafff] File: FvFile(D6A2CB7F-6A18-4E2F-B43B-9920A733700A) Handle: 0x000000017fe3cb18 ... Info type 0x00000001 Address: [0x000000017e8db000, 0x000000017ea00f3f] File: FvFile(7C04A583-9E3E-4F1C-AD65-E05268D0B4D1) Handle: 0x000000017f358e98 Info type 0x00000001 Address: [0x000000017eae5000, 0x000000017eae81ff] File: \dbginfodump.efi Handle: 0x000000017eaf0298 => Signed-off-by: Heinrich Schuchardt <[email protected]> Acked-by: Ilias Apalodimas <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2025-07-03efi: add EFI_DEBUG_IMAGE_INFO for debugYing-Chun Liu (PaulLiu)
This commit adds the functionality of generate EFI_DEBUG_IMAGE_INFO while loading the image. This feature is described in UEFI Spec 2.10. Section 18.4.3. The implementation ensures support for hardware-assisted debugging and provides a standardized mechanism for debuggers to discover the load address of an EFI application. Cc: Ilias Apalodimas <[email protected]> Cc: Peter Robinson <[email protected]> Cc: Simon Glass <[email protected]> Signed-off-by: Ying-Chun Liu (PaulLiu) <[email protected]> Tested-by: Heinrich Schuchardt <[email protected]> Acked-by: Ilias Apalodimas <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2025-07-03lib: efi_loader: efi_memory.c: add efi_realloc() for realloc memoryYing-Chun Liu (PaulLiu)
Add efi_realloc() for realloc memory that previously alloc by efi_alloc(). Note that if realloced memory is explicitly allocated as BootServicesData. Cc: Heinrich Schuchardt <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Peter Robinson <[email protected]> Cc: Simon Glass <[email protected]> Signed-off-by: Ying-Chun Liu (PaulLiu) <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2025-07-03efi: add EFI_DEBUG_IMAGE_INFO_TABLE for debugYing-Chun Liu (PaulLiu)
EFI_DEBUG_IMAGE_INFO_TABLE is used to store EFI_LOADED_IMAGE for debug purpose. This commit adds the table to the EFI_CONFIGURATION_TABLE. This feature is described in UEFI Spec version 2.10. Section 18.4. The implementation ensures support for hardware-assisted debugging and provides a standardized mechanism for debuggers to discover and interact with system-level debug resources. Cc: Heinrich Schuchardt <[email protected]> Cc: Peter Robinson <[email protected]> Cc: Simon Glass <[email protected]> Signed-off-by: Ying-Chun Liu (PaulLiu) <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2025-07-03efi: add EFI_SYSTEM_TABLE_POINTER for debugYing-Chun Liu (PaulLiu)
Add EFI_SYSTEM_TABLE_POINTER structure for remote debugger to locate the address of EFI_SYSTEM_TABLE. This feature is described in UEFI SPEC version 2.10. Section 18.4.2. The implementation ensures support for hardware-assisted debugging and provides a standardized mechanism for debuggers to discover the EFI system table. Cc: Peter Robinson <[email protected]> Cc: Simon Glass <[email protected]> Signed-off-by: Ying-Chun Liu (PaulLiu) <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Tested-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]> # change memset(systab_pointer, 0 ...) -> systab_pointer->crc32 = 0; Signed-off-by: Ilias Apalodimas <[email protected]>
2025-07-03efi_loader: Prevent free of uninitialised pointerAndrew Goodbody
Taking a goto to out_of_resources before receive_lengths is assigned will result in an attempt to free an unitialised pointer. Instead initialise receive_lengths to NULL on declaration to prevent this from occurring. This issue was found by Smatch. Reviewed-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Andrew Goodbody <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>