aboutsummaryrefslogtreecommitdiff
path: root/lib/efi_loader
AgeCommit message (Collapse)AuthorFilesLines
2024-03-25Merge tag 'v2024.04-rc5' into nextWIP/25Mar2024-nextTom Rini1-5/+11
Prepare v2024.04-rc5
2024-03-21efi_loader: correct handling of EFI binary return codeHeinrich Schuchardt1-5/+11
We should not try to remove protocol interfaces from a NULL handle. efi_run_image() should always return the return code of the executed EFI binary. Fixes: 6422820ac3e5 ("efi_loader: split unrelated code from efi_bootmgr.c") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-03-21lib/charset: Map Unicode code points to CP437 code points 1-31Janne Grunau1-1/+1
Code page 437 uses code points 1-31 for glyphs instead of control characters. Map the appropriate Unicode code points to this code points. Fixes rendering of grub2's menu as EFI application using the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on a console with bitmap fonts. Signed-off-by: Janne Grunau <j@jannau.net>
2024-03-19Merge tag 'u-boot-socfpga-next-20240319' of ↵WIP/19Mar2024-nextTom Rini1-4/+7
https://source.denx.de/u-boot/custodians/u-boot-socfpga into next - A new driver in the misc to register setting from device tree. This also provides user a clean interface and all register settings are centralized in one place, device tree. - Enable Agilex5 platform for Intel product. Changes, modification and new files are created for board, dts, configs and makefile to create the base for Agilex5. Build-tested on SoC64 boards, boot tested on some of them.
2024-03-13efi_loader: Don't carve out memory reservations too earlyMark Kettenis1-4/+7
Moving the efi_carve_out_dt_rsv() call in commit 1be415b21b2d ("efi_loader: create memory reservations in ACPI case") broke boards that create additional memory reservations in ft_board_setup() since it is now called before those additional memory reservations are made. This is the case for the rk3588 boards and breaks booting OpenBSD on those boards. Move the call back to its original location and add a call in the code path used for ACPI. Fixes: 1be415b21b2d ("efi_loader: create memory reservations in ACPI case") Signed-off-by: Mark Kettenis <kettenis@openbsd.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-28efi_driver: provide SBI based runtime system resetHeinrich Schuchardt1-1/+1
On RISC-V systems system the Supervisory Binary Interface provides system reset and poweroff. Use it at EFI runtime. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-12efi_loader: simplify error message in efi_disk_create_raw()Heinrich Schuchardt1-1/+2
The error message Adding disk for usb_mass_storage.lun0 failed (err=-9223372036854775788/0x8000000000000014) provides a decimal and a hexadecimal notation of the EFI status code EFI_ALREADY_STARTED which is defined as (EFI_ERROR_MASK | 20). The decimal output does not convey the value 20 clearly. With the patch we write Adding block device usb_mass_storage.lun0 failed, r = 20 similar to other EFI error messages. Fixes: 952018117ab4 ("dm: sandbox: Switch over to using the new host uclass") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-02smbios: correctly name Structure Table Maximum Size fieldHeinrich Schuchardt2-5/+5
In the SMBIOS 3 entry point the Structure Table Maximum Size field was incorrectly named max_struct_size. A Maximum Structure Size field only exists in the SMBIOS 2.1 entry point and has a different meaning. Call the Structure Table Length field table_maximum_size. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-29efi_loader: check efi_get_variable_int return valueMasahisa Kojima1-5/+5
efi_get_variable_int() may fail, the buffer should be cleared before using it. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Addresses-Coverity-ID: 478333 ("Error handling issues")
2024-01-29efi_loader: replace find_smbios_table by library functionHeinrich Schuchardt1-18/+1
The code in find_smbios_table() is redundant to efi_get_configuration_table(). Replace it. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-29efi_loader: export efi_get_configuration_tableHeinrich Schuchardt1-3/+3
In multiple places we need a function to find an EFI configuration table. Rename get_config_table() to efi_get_configuration_table() and export it. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-26efi_loader: migrate SMBIOS 3.0 entry point structure for measurementMasahisa Kojima1-7/+12
Current U-Boot only supports the SMBIOS 3.0 entry point structure. TCG2 measurement code should migrate to SMBIOS 3.0 entry point structure. efi_selftest tcg2 test also needs to be updated, and expected PCR[1] result is changed since guid for SMBIOS EFI system table uses different guid SMBIOS3_TABLE_GUID instead of SMBIOS_TABLE_GUID. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-21efi_loader: return immediately in UCLASS_EFI_LOADER removalMasahisa Kojima1-6/+10
In case of UCLASS_EFI_LOADER, EFI handles are managed by EFI application/driver, we must not delete EFI handles. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-21efi_loader: create common function to free struct efi_disk_objMasahisa Kojima1-7/+19
Current error handling of creating raw disk/partition has following issues. - duplicate free for EFI handle, EFI handle is already freed in efi_delete_handle() - missing free for struct efi_device_path and struct efi_simple_file_system_protocol in some error paths To address those issues, this commit creates the common function to free the struct efi_disk_obj resources and calls it in case of error. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-21efi_loader: avoid pointer access after calling efi_delete_handleMasahisa Kojima1-6/+14
efi_delete_handle() calls efi_purge_handle(), then it finally frees the EFI handle. Both diskobj and handle variables in efi_disk_remove() have the same pointer, we can not access diskobj->dp after calling efi_delete_handle(). This commit saves the struct efi_device_path pointer before calling efi_delete_handle(). This commit also fixes the missing free for volume member in struct efi_disk_obj. This commit also removes the container_of() calls, and adds the TODO comment of missing efi_close_protocol() call for the parent EFI_BLOCK_IO_PROTOCOL. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-21efi_loader: auto-generate removable media boot option firstMasahisa Kojima1-7/+26
This commit auto-generates the boot option for removable block io devices followed by fixed block io devices. This is what EDK II reference implementation does. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-21efi_loader: auto-generate boot option for each blkio deviceMasahisa Kojima1-26/+75
Current efibootmgr auto-generates the boot option for all disks and partitions installing EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, while EDK II reference implementation auto-generates the boot option for all devices installing EFI_BLOCK_IO_PROTOCOL with eliminating logical partitions. This commit modifies the efibootmgr to get aligned to EDK II. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-21efi_loader: rename check_disk_has_default_file functionMasahisa Kojima1-5/+8
check_disk_has_default_file() function checks if the architecture-specific default file exists on the block device, and fills the default file device path if it exists. Rename the function name to fill_default_file_path(). Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-01-17Merge tag 'efi-2024-04-rc1-2' of ↵Tom Rini6-491/+511
https://source.denx.de/u-boot/custodians/u-boot-efi Documentation: * add generated index to table of contents * create index entries for commands * update Python packages used to build the documentation * fix typos in dfu documentation UEFI: * split unrelated code from efi_bootmgr.c * rename CONFIG_BOOTEFI_BOOTMGR to CONFIG_EFI_BOOTMGR * net: tftp: remove explicit EFI configuration dependency * fs: remove explicit EFI configuration dependency Other: * Add Goldfish RTC driver and make it available on RISC-V QEMU
2024-01-17efi_loader: rename BOOTEFI_BOOTMGR to EFI_BOOTMGRAKASHI Takahiro2-2/+2
At this point, EFI boot manager interfaces is fully independent from bootefi command. So just rename the configuration parameter. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-17efi_loader: split unrelated code from efi_bootmgr.cAKASHI Takahiro6-489/+509
Some code moved from cmd/bootefi.c is actually necessary only for "bootefi <addr>" command (starting an image manually loaded by a user using U-Boot load commands or other methods (like JTAG debugger). The code will never been opted out as unused code by a compiler which doesn't know how EFI boot manager is implemented. So introduce a new configuration, CONFIG_EFI_BINARY_EXEC, to enforce them opted out explicitly. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2024-01-16smbios: copy QEMU tablesHeinrich Schuchardt1-1/+3
QEMU provides SMBIOS tables with detailed information. We should not try to replicate them in U-Boot. If we want to inform about U-Boot, we can add a Firmware Inventory Information (type 45) table in future. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-13efi_loader: support fmp versioning for multi bank updateMasahisa Kojima1-15/+60
This commit stores the firmware version into the array of fmp_state structure to support the fmp versioning for multi bank update. The index of the array is identified by the bank index. This modification keeps the backward compatibility with the existing versioning feature. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-13fwu: fix fwu_get_image_index interfaceMasahisa Kojima1-2/+9
The capsule update uses the DFU framework for updating storage. fwu_get_image_index() currently returns the image_index calculated by (dfu_alt_num + 1), but this is different from the image_index in UEFI terminology. Since capsule update implementation calls dfu_write_by_alt function, it is better that FWU returns the dfu_alt_num. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-13efi_loader: Clean up efi_dp_append and efi_dp_concatIlias Apalodimas4-54/+26
Looking back at the initrd storing functionality, we introduced three functions, efi_dp_append_or_concatenate(), efi_dp_append/concat(). In hindsight we could have simplified that by a lot. First of all none of the functions append anything. They all allocate a new device path and concatenate the contents of two device paths in one. A boolean parameter controls the final device path -- if that's true an end node is injected between the two device paths. So let's rewrite this and make it a bit easier to read. Get rid of efi_dp_append(), efi_dp_concat() and rename efi_dp_append_or_concatenate() to efi_dp_concat(). This is far more intuitive and the only adjustment that is needed is an extra boolean argument on all callsites. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-13efi_loader: remove unused members from struct efi_disk_objMasahisa Kojima1-12/+3
part and dev_index in struct efi_disk_obj are not used, let's remove it. This commit also removes the invalid structure comment for @dev, it does not exist. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-01-13efi_loader: fix iteration of FMP protocolsMasahisa Kojima1-6/+12
If one of the FMP protocols fails when calling GetImageInfo(), populating the ESRT ends up with failure and other FMP protocols are not added to the ESRT. We should still add all other FMP protocols to the ESRT. With this commit, iteration of all FMP protocols continues even though one of the FMP protocols fails. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-09efi_loader: provide tool to dump SMBIOS tableHeinrich Schuchardt2-0/+629
An EFI binary smbiosdump.efi is provided that can be used to check the SMBIOS table for consistency and to dump it as a file. The tool provides the following commands: check Check the SMBIOS table for consistency. exit Leave the tool. help Show available commands. save Save the SMBIOS table to a file on the EFI system partition. The file can be further analyzed with the dmidecode command line tool:: dmidecode --from-dump <filename> Specifying 'nocolor' as load option data suppresses colored output and clearing of the screen. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-09smbios: smbios.h should not import ofnode.hHeinrich Schuchardt1-0/+3
The smbios.h include does not use any definitions from ofnode.h. So don't include it. As DECLARE_GLOBAL_DATA_PTR is no longer defined via dm/of.h we need to add it to efi_smbios.c. Add now missing includes to smbios-parser.c. Remove a superfluous check comparing the sizes of the SMBIOS 2.1 and SMBIOS 3.0 anchors. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-07efi: Correct smbios-table installationSimon Glass1-9/+7
At present this code allocates memory when writing the tables and then unnecessarily adds another memory map when installing it. Adjust the code to allocate the tables using the normal U-Boot mechanism. This avoids doing an EFI memory allocation early in U-Boot, which may use memory that would be overwritten by a 'load' command, for example. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-01-07efi: smbios: Drop support for SMBIOS2 tablesSimon Glass1-3/+1
Only the v3 table is supported now, so always use this when installing the EFI table. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-01-07efi: Use the correct GUID for the SMBIOS tableSimon Glass1-2/+10
EFI does not use the 'anchor string' to determine the SMBIOS table version, instead preferring to have two separate GUIDs. Use the correct one, depending on the table version. Call unmap_system() to balance to the use of map_sysmem() Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-07smbios: Correct gd_smbios_start()Simon Glass1-1/+1
This should access arch-specific properties. Fix it and update the existing usage. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-12-21efi_loader: Remove <common.h>Tom Rini42-42/+1
We largely do not need <common.h> in these files, so drop it. The only exception here is that efi_freestanding.c needs <linux/types.h> and had been getting that via <common.h>. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2023-12-18Merge tag 'v2024.01-rc5' into nextTom Rini3-34/+20
Prepare v2024.01-rc5
2023-12-17cmd: bootefi: move library interfaces under lib/efi_loaderAKASHI Takahiro1-0/+530
In the prior commits, interfaces for executing EFI binary and boot manager were carved out. Move them under efi_loader directory so that they can be called from other places without depending on bootefi command. Only efi_selftest-related code will be left in bootefi.c. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2023-12-13boot: Drop size parameter from image_setup_libfdt()Simon Glass1-1/+1
The of_size parameter is not used, so remove it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-04Merge tag 'v2024.01-rc4' into nextTom Rini1-7/+9
Prepare v2024.01-rc4 # -----BEGIN PGP SIGNATURE----- # # iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmVuHrwACgkQFHw5/5Y0 # tyy3Tgv+LB/X0ZR3IHnu1mvQ7kpOFvAjjKr0BUpcEEzsrDZeJnS6sy06m+REez2E # UmuLeKFj5NUCYXNKtxn2+gVnJt8Tk6ftxhMTiZHmR4Y4NVc5aPtqYmVsv6Q29j0U # mcg7AGcZTniu9/naNM+ZcDeHzLDAB0whmE9eVfixXVgyitILoLHNdFiQ7W4oR7Kh # /mBgdMDBS3rqiRi6CuqKUnl4ADX8T3AXaSfi3hqOC5Pj+HPkZSUfyWx31mu9mN1D # wXTHASZX06Dop25fm/ZSdWk1blBw29WqRiJBdwNatvyC5pqMsotTvAfH2AcHBEYg # tpoper+WDOBAipt6b6Y1B7q4VPvJ97L9dFCAYqN0nGCe+rkdi+k+cly7M6Ye9xLt # e7rVUfnKgIMP8jkLcVBYoWkFY5FiJ82O5qjoF5N3dAuHeWacDFsB5TugDTOQvblH # LWCmcIyU1N9Ma/Ib0rTvNduvpBUYBKXYlD1+rjPZUbTUnfc79mf+ReFpcoW6Kxh+ # bkz81p8P # =ebIZ # -----END PGP SIGNATURE----- # gpg: Signature made Mon 04 Dec 2023 01:47:24 PM EST # gpg: using RSA key 1A3C7F70E08FAB1707809BBF147C39FF9634B72C # gpg: Good signature from "Thomas Rini <trini@konsulko.com>" [ultimate]
2023-12-05efi_loader: Make DisconnectController follow the EFI specIlias Apalodimas1-17/+10
commit 239d59a65e20 ("efi_loader: reconnect drivers on failure") tried to fix the UninstallProtocol interface which must reconnect any controllers it disconnected by calling ConnectController() in case of failure. However, the reconnect functionality was wired in efi_disconnect_all_drivers() instead of efi_uninstall_protocol(). As a result some SCT tests started failing. Specifically, BBTestOpenProtocolInterfaceTest333CheckPoint3() test - Calls ConnectController for DriverImageHandle1 - Calls DisconnectController for DriverImageHandle1 which will disconnect everything apart from TestProtocol4. That will remain open on purpose. - Calls ConnectController for DriverImageHandle2. TestProtocol4 which was explicitly preserved was installed wth BY_DRIVER attributes. The new protocol will call DisconnectController since its attributes are BY_DRIVER|EXCLUSIVE, but TestProtocol4 will not be removed. The test expects EFI_ACCESS_DENIED which works fine. The problem is that DisconnectController, will eventually call EFI_DRIVER_BINDING_PROTOCOL.Stop(). But on the aforementioned test this will call CloseProtocol -- the binding protocol is defined in 'DBindingDriver3.c' and the .Stop function uses CloseProtocol. If that close protocol call fails with EFI_NOT_FOUND, the current code will try to mistakenly reconnect all drivers and the subsequent tests that rely on the device being disconnected will fail. Move the reconnection in efi_uninstall_protocol() were it belongs. Fixes: commit 239d59a65e20 ("efi_loader: reconnect drivers on failure") Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-12-05efi_loader: create memory reservations in ACPI caseHeinrich Schuchardt1-2/+0
ACPI tables cannot convey memory reservations for ARM and RISC-V. x86 uses the BIOS E820 table for this purpose. We cannot simply ignore the device-tree when booting via ACPI. We have to assign EfiReservedMemory according to the prior stage device-tree ($fdtaddr) or as fallback the control device-tree ($fdtcontroladdr). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-12-04efi_loader: generated SMBIOS table below 4 GiBHeinrich Schuchardt1-7/+9
We currently use an outdated format 32-bit format for SMBIOS tables. So we must allocate SMBIOS tables below 4 GiB. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-11-30Merge branch 'staging' of ↵Tom Rini3-9/+17
https://source.denx.de/u-boot/custodians/u-boot-tegra into next Device tree improvents for Paz00 and DM PMIC convertion of recently merged Tegra boards.
2023-11-20efi_loader: improve efi_var_from_file() descriptionHeinrich Schuchardt1-2/+5
It is unclear to developers why efi_var_from_file() returns EFI_SUCCESS if file ubootefi.var is missing or corrupted. Improve the description. Reported-by: Weizhao Ouyang <o451686892@gmail.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Weizhao Ouyang <o451686892@gmail.com>
2023-11-20efi_loader: Correctly account the SCRTM event creationIlias Apalodimas1-1/+4
The result of efi_append_scrtm_version() is overwritten before anyone checks its result. Check it and exit the function on failures Addresses-Coverity-ID: 467399 Code maintainability issues (UNUSED_VALUE) Fixes: commit 97707f12fdab ("tpm: Support boot measurements") Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-11-20efi_loader: Increase default variable store size to 128KIlias Apalodimas1-6/+8
In commit 9fd3f881c6ed ("efi_loader: Increase default variable store size to 64KiB") Alper has a detailed explanation of why the size needs to be bumped to at least 64K. However enabling Secure boot, writing db, KEK, PK etc keys will further increase the size so bump it to 128K. It's worth noting that when U-Boot stores the EFI variables in an RPMB the available storage is defined statically in StandAloneMM at build time. The U-Boot code is detecting the available true size on the fly during writes. When StandAloneMM is present this size defines the reserved memory U-Boot can use to copy any runtime variables, before booting an OS. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-11-20Merge tag 'v2024.01-rc3' into nextTom Rini1-5/+7
Prepare v2024.01-rc3
2023-11-18efi_loader: support boot from URI device pathMasahisa Kojima2-0/+395
This supports to boot from the URI device path. When user selects the URI device path, bootmgr downloads the file using wget into the address specified by loadaddr env variable. If the file is .iso or .img file, mount the image with blkmap then try to boot with the default file(e.g. EFI/BOOT/BOOTAA64.EFI). Since boot option indicating the default file is automatically created when new disk is detected, system can boot by selecting the automatically created blkmap boot option. If the file is PE-COFF file, load and start the downloaded file. The buffer used to download the ISO image file must be reserved to avoid the unintended access to the image and expose the ramdisk to the OS. For PE-COFF file case, this memory reservation is done in LoadImage Boot Service. [Ilias fix a few memory leaks by replacing returns with gotos] Lore: https://lore.kernel.org/u-boot/20231110042542.3797301-1-masahisa.kojima@linaro.org/T/#mbac31da301ff465b60894b38f3a587b2868cf817 Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-11-18efi_loader: add return to efibootmgr event groupMasahisa Kojima1-0/+3
When the image loaded by efibootmgr returns, efibootmgr needs to clean the resources. Adding the event of returning to efibootmgr is useful to simplify the implementation. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-11-18efi_loader: add missing const classifier for event serviceMasahisa Kojima1-2/+2
const classifier is missing in EventGroup parameter of CreateEventEx(). Fix it to remove the compiler warning. NotifyContext parameter of CreateEventEx() is also defined with const in UEFI specification, but NotifyContext parameter of CreateEvent() is defined without const. Since current implementation calls the common efi_create_event() function from both CreateEventEx() and CreateEvent() services, NotifyContext parameter leaves as is. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-11-18efi_loader: Boot var automatic managementRaymond Mao2-0/+25
Changes for complying to EFI spec §3.5.1.1 'Removable Media Boot Behavior'. Boot variables can be automatically generated during a removable media is probed. At the same time, unused boot variables will be detected and removed. Please note that currently the function 'efi_disk_remove' has no ability to distinguish below two scenarios a) Unplugging of a removable media under U-Boot b) U-Boot exiting and booting an OS Thus currently the boot variables management is not added into 'efi_disk_remove' to avoid boot options being added/erased repeatedly under scenario b) during power cycles See TODO comments under function 'efi_disk_remove' for more details The original efi_secboot tests expect that BootOrder EFI variable is not defined. With this commit, the BootOrder EFI variable is automatically added when the disk is detected. The original efi_secboot tests end up with unexpected failure. The efi_secboot tests need to be modified to explicitly set the BootOrder EFI variable. squashfs and erofs ls tests are also affected by this modification, need to clear the previous state before squashfs ls test starts. Co-developed-by: Masahisa Kojima <masahisa.kojima@linaro.org> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>