aboutsummaryrefslogtreecommitdiff
path: root/lib/efi_loader
Commit message (Collapse)AuthorAgeFilesLines
...
| * efi_loader: support booting semihosting fileHeinrich Schuchardt2023-05-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Executing an EFI binary fails for files loaded via semihosting. Construct a dummy device path for EFI binaries loaded via semihosting. A future complete solution may include the creation of a handle with a simple file system protocol. Reported-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
| * efi_loader: print file path w/o boot deviceHeinrich Schuchardt2023-05-131-4/+4
| | | | | | | | | | | | | | Helloworld.efi should print the file path even if the boot device is not set. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* | efi_loader: check lowest supported versionMasahisa Kojima2023-06-081-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | The FMP Payload Header which EDK II capsule generation scripts insert has a firmware version. This commit reads the lowest supported version stored in the device tree, then check if the firmware version in FMP payload header of the ongoing capsule is equal or greater than the lowest supported version. If the firmware version is lower than lowest supported version, capsule update will not be performed. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
* | efi_loader: get lowest supported version from device treeMasahisa Kojima2023-06-081-1/+49
| | | | | | | | | | | | | | | | This commit gets the lowest supported version from device tree, then fills the lowest supported version in FMP->GetImageInfo(). Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | efi_loader: versioning support in GetImageInfoMasahisa Kojima2023-06-081-6/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Current FMP->GetImageInfo() always return 0 for the firmware version, user can not identify which firmware version is currently running through the EFI interface. This commit reads the "FmpStateXXXX" EFI variable, then fills the firmware version in FMP->GetImageInfo(). Now FMP->GetImageInfo() and ESRT have the meaningful version number. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | efi_loader: store firmware version into FmpState variableMasahisa Kojima2023-06-081-19/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Firmware version management is not implemented in the current FMP protocol. EDK II reference implementation capsule generation script inserts the FMP Payload Header right before the payload, FMP Payload Header contains the firmware version and lowest supported version. This commit utilizes the FMP Payload Header, reads the header and stores the firmware version into "FmpStateXXXX" EFI non-volatile variable. XXXX indicates the image index, since FMP protocol handles multiple image indexes. Note that lowest supported version included in the FMP Payload Header is not used. If the platform uses file-based EFI variable storage, it can be tampered. The file-based EFI variable storage is not the right place to store the lowest supported version for anti-rollback protection. This change is compatible with the existing FMP implementation. This change does not mandate the FMP Payload Header. If no FMP Payload Header is found in the capsule file, fw_version, lowest supported version, last attempt version and last attempt status is 0 and this is the same behavior as existing FMP implementation. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
* | efi_loader: add the number of image entries in efi_capsule_update_infoMasahisa Kojima2023-06-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The number of image array entries global variable is required to support EFI capsule update. This information is exposed as a num_image_type_guids variable, but this information should be included in the efi_capsule_update_info structure. This commit adds the num_images member in the efi_capsule_update_info structure. All board files supporting EFI capsule update are updated. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | efi: Correct .efi rulesSimon Glass2023-05-311-0/+3
|/ | | | | | | | | | | | These files should have both 'always' and 'targets' so that dependencies are detected correctly. When only 'always' is used, the target is built every time, although I am not quite sure why. Make sure each has both 'always' and 'targets' to avoid this problem. Signed-off-by: Simon Glass <sjg@chromium.org>
* efi_loader: remove unused efi_capsule_authenticateHeinrich Schuchardt2023-04-211-6/+0
| | | | | | Remove an unused implementation of efi_capsule_authenticate(). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi: loader: Make efi_runtime_mmio staticBin Meng2023-04-081-1/+1
| | | | | | efi_runtime_mmio is only referenced in efi_boottime.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
* efi: loader: Make efi_mem staticBin Meng2023-04-081-1/+1
| | | | | | efi_mem is only referenced in efi_memory.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
* efi: loader: Make efi_event_queue and efi_register_notify_events staticBin Meng2023-04-081-2/+2
| | | | | | | efi_event_queue and efi_register_notify_events are only referenced in efi_boottime.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
* efi_loader: avoid using HandleProtocol in initrddump.efiHeinrich Schuchardt2023-04-081-2/+3
| | | | | | | | HandleProtocol() is deprecated and leaves an OpenedProtocolInformation behind. Use OpenProtocol(GET_PROTOCOL) instead. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi_loader: avoid using HandleProtocol in helloworld.efiHeinrich Schuchardt2023-04-081-5/+8
| | | | | | | | HandleProtocol() is deprecated and leaves an OpenedProtocolInformation behind. Use OpenProtocol(GET_PROTOCOL) instead. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi_loader: device_path: support blkmap devicesTobias Waldekranz2023-04-051-0/+30
| | | | | | | Create a distinct EFI device path for each blkmap device. Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* Merge branch 'next'Tom Rini2023-04-034-52/+41
|\ | | | | | | Signed-off-by: Tom Rini <trini@konsulko.com>
| * efi_loader: simplify efi_str_to_u16()Heinrich Schuchardt2023-03-251-3/+2
| | | | | | | | | | | | | | Use efi_alloc() to allocate memory. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * efi_loader: move dp_alloc() to efi_alloc()Heinrich Schuchardt2023-03-252-48/+38
| | | | | | | | | | | | | | | | | | | | The incumbent function efi_alloc() is unused. Replace dp_alloc() by a new function efi_alloc() that we can use more widely. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * efi_loader: fix device-path for USB devicesHeinrich Schuchardt2023-03-251-12/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | EFI device paths for block devices must be unique. If a non-unique device path is discovered, probing of the block device fails. Currently we use UsbClass() device path nodes. As multiple devices may have the same vendor and product id these are non-unique. Instead we should use Usb() device path nodes. They include the USB port on the parent hub. Hence they are unique. A USB storage device may contain multiple logical units. These can be modeled as Ctrl() nodes. Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * efi_loader: support for Ctrl() device path nodeHeinrich Schuchardt2023-03-251-0/+7
| | | | | | | | | | | | | | | | | | * Add the definitions for Ctrl() device path nodes. * Implement Ctrl() nodes in the device path to text protocol. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * Merge tag 'v2023.04-rc4' into nextTom Rini2023-03-142-6/+33
| |\ | | | | | | | | | | | | | | | Prepare v2023.04-rc4 Signed-off-by: Tom Rini <trini@konsulko.com>
| * | efi_loader: use tpm_auto_start for the tpm deviceIlias Apalodimas2023-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A previous commit is adding a new tpm startup functions which initializes the TPMv2 and performs all the needed selftests. Since the TPM selftests might be needed depending on the requested algorithm or functional module use that instead. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | | efi_loader: remove duplicate assignmentHeinrich Schuchardt2023-04-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Assigning the value of a variable to itself should be avoided. Addresses-Coverity-ID: 451089 ("Evaluation order violation") Fixes: 180b7118bed8 ("efi_loader: fix device-path for USB devices") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* | | efi_loader: correct shortening of device-pathsHeinrich Schuchardt2023-04-011-15/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We use short device-paths in boot options so that a file on a block device can be found independent of the port into which the device is plugged. Usb() device-path nodes only contain port and interface information and therefore cannot identify a block device. UsbWwi() device-path nodes contain the serial number of USB devices. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* | | efi_loader: fix device-path for USB devicesHeinrich Schuchardt2023-03-251-12/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | EFI device paths for block devices must be unique. If a non-unique device path is discovered, probing of the block device fails. Currently we use UsbClass() device path nodes. As multiple devices may have the same vendor and product id these are non-unique. Instead we should use Usb() device path nodes. They include the USB port on the parent hub. Hence they are unique. A USB storage device may contain multiple logical units. These can be modeled as Ctrl() nodes. Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | | efi_loader: support for Ctrl() device path nodeHeinrich Schuchardt2023-03-251-0/+7
| |/ |/| | | | | | | | | | | | | | | * Add the definitions for Ctrl() device path nodes. * Implement Ctrl() nodes in the device path to text protocol. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | efi_loader: describe term_get_char()Heinrich Schuchardt2023-03-131-0/+8
| | | | | | | | | | | | | | Add a function description. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | efi_loader: update SetVariable attribute checkMasahisa Kojima2023-03-131-6/+25
|/ | | | | | | | | | | | | | UEFI specification v2.10 says that EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated and EFI_UNSUPPORTED should be returned in SetVariable variable service. Current implementation returns EFI_INVALID_PARAMETER, let's fix the return value. Together with above change, this commit also updates the SetVariable attribute check to be aligned with the EDK2 reference implementation. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: set CapsuleMax from CONFIG_EFI_CAPSULE_MAXEtienne Carriere2023-02-193-15/+48
| | | | | | | | | Adds CONFIG_EFI_CAPSULE_MAX to configure the max index value used in EFI capsule reports. Prior to this change is the hard coded value was 65535 which would exceed available storage for variables. Now the default value is 15 which should work fine with most systems. Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
* efi_loader: Measure the loaded DTBEtienne Carriere2023-02-192-0/+84
| | | | | | | | | | | | | | Measures the DTB passed to the EFI application upon new boolean config switch CONFIG_EFI_TCG2_PROTOCOL_MEASURE_DTB. For platforms where the content of the DTB passed to the OS can change across reboots, there is not point measuring it hence the config switch to allow platform to not embed this feature. Co-developed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi_loader: fix wrong attribute check for QueryVariableInfoMasahisa Kojima2023-02-191-3/+0
| | | | | | | | | QueryVariableInfo with EFI_VARIABLE_HARDWARE_ERROR_RECORD is accepted, remove wrong attribute check. Fixes: 454a9442fbce ("efi_loader: update attribute check for QueryVariableInfo()") Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: avoid buffer overrun in efi_var_mem_compareHeinrich Schuchardt2023-02-191-1/+3
| | | | | | We should not scan beyond the end of string name. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* Merge tag 'efi-2023-04-rc2' of ↵Tom Rini2023-02-1010-23/+43
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://source.denx.de/u-boot/custodians/u-boot-efi Pull request for efi-2023-04-rc2 Documentation: * Provide page with links to talks on U-Boot UEFI: * Enable CTRL+S to save the boot order in eficonfig command * Run attribute check for QueryVariableInfo() only for the file store * Bug fixes Others: * Improve output formatting of the coninfo command # -----END PGP SIGNATURE----- # gpg: Signature made Fri 10 Feb 2023 12:15:45 PM EST # gpg: using RSA key 6DC4F9C71F29A6FA06B76D33C481DBBC2C051AC4 # gpg: Good signature from "Heinrich Schuchardt <xypron.glpk@gmx.de>" [unknown] # gpg: aka "[jpeg image of size 1389]" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 6DC4 F9C7 1F29 A6FA 06B7 6D33 C481 DBBC 2C05 1AC4
| * efi_loader: static efi_query_variable_info_runtime()Heinrich Schuchardt2023-02-101-1/+1
| | | | | | | | | | | | This function is not used externally and hence should be static. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
| * efi_loader: make gop_blt() staticHeinrich Schuchardt2023-02-101-5/+6
| | | | | | | | | | | | This function is not used externally. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
| * efi_loader: include definition of allow_unaligned()Heinrich Schuchardt2023-02-101-0/+1
| | | | | | | | | | | | Add missing include. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
| * efi_loader: static functions in efi_runtime.cHeinrich Schuchardt2023-02-101-2/+2
| | | | | | | | | | | | Functions that are not used externally should be static. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
| * efi_loader: static functions in efi_console.cHeinrich Schuchardt2023-02-101-1/+1
| | | | | | | | | | | | Define function set_shift_mask() as static as it is not used externally. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
| * efi_loader: static functions in efi_boottime.cHeinrich Schuchardt2023-02-101-2/+4
| | | | | | | | | | | | Make functions that are no used externally static. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
| * efi_loader: static functions in helloworld.cHeinrich Schuchardt2023-02-101-1/+2
| | | | | | | | | | | | Make functions that are not used externally static. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
| * efi_loader: fix efi_ecpt_register()Heinrich Schuchardt2023-02-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | num_entries should be unsigned to avoid warnings. As the target field is u16 we should use this type. lib/efi_loader/efi_conformance.c: In function ‘efi_ecpt_register’: lib/efi_loader/efi_conformance.c:30:33: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion] 30 | ecpt_size = num_entries * sizeof(efi_guid_t) | ^ lib/efi_loader/efi_conformance.c:46:36: warning: conversion from ‘int’ to ‘u16’ {aka ‘short unsigned int’} may change value [-Wconversion] 46 | ecpt->number_of_profiles = num_entries; | ^~~~~~~~~~~ Fixes: 6b92c1735205 ("efi: Create ECPT table") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
| * efi_loader: make get_load_options() staticHeinrich Schuchardt2023-02-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | In program initrddump.efi function get_load_options() can be static. This avoids a warning when building with 'make W=1': lib/efi_loader/initrddump.c:442:6: warning: no previous prototype for ‘get_load_options’ [-Wmissing-prototypes] 442 | u16 *get_load_options(void) | ^~~~~~~~~~~~~~~~ Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
| * efi_loader: update attribute check for QueryVariableInfo()Masahisa Kojima2023-02-102-9/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current U-Boot supports two EFI variable service, U-Boot own implementation and op-tee based StMM variable service. With ACS Security Interface Extension(SIE) v22.10_SIE_REL1.1.0, there are several failure items of QueryVariableInfo(). Current attribute check for QueryVariableInfo() was implemented based on the Self Certification Test (SCT) II Case Specification, June 2017, chapter 4.1.4 QueryVariableInfo(). This test case specification is outdated and don't align at all with the SCT test case code, and UEFI specification v2.10 does not clearly define the priority of the attribute check. For U-Boot standard case that EFI variables are stored in a file in the ESP, this commit modifies the attribute check to get align to the EDK2 implementation. For latter case(op-tee based StMM variable service), parameter check should be delegated to StMM. Now all ACS SIE QueryVariableInfo() test cases passed both EFI variable storage implementations. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Acked-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* | Correct SPL use of EFI_UNICODE_COLLATION_PROTOCOL2Simon Glass2023-02-091-1/+1
| | | | | | | | | | | | | | This converts 1 usage of this option to the non-SPL form, since there is no SPL_EFI_UNICODE_COLLATION_PROTOCOL2 defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
* | Correct SPL use of EFI_TCG2_PROTOCOLSimon Glass2023-02-091-1/+1
| | | | | | | | | | | | | | This converts 1 usage of this option to the non-SPL form, since there is no SPL_EFI_TCG2_PROTOCOL defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
* | Correct SPL use of EFI_LOADER_HIISimon Glass2023-02-091-1/+1
| | | | | | | | | | | | | | This converts 1 usage of this option to the non-SPL form, since there is no SPL_EFI_LOADER_HII defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
* | Correct SPL use of EFI_DEVICE_PATH_UTILSimon Glass2023-02-091-1/+1
|/ | | | | | | This converts 1 usage of this option to the non-SPL form, since there is no SPL_EFI_DEVICE_PATH_UTIL defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
* efi_loader: don't use HandleProtocolHeinrich Schuchardt2023-01-271-2/+3
| | | | | | | | | | | | HandleProtocol() is deprecrated. According to the UEFI specification it should be implemented as a call to OpenProtocolInterface() with a hard coded agent handle. This implies that we would have to call CloseProtocolInterfaces() after usage with the same handle. Getting rid of an EFI_CALL() is also appreciated. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi_loader: fix comment in ESRT codeHeinrich Schuchardt2023-01-271-1/+1
| | | | | | | There is no variable num_pages in function efi_esrt_allocate_install(). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi: Improve logging in efi_diskSimon Glass2023-01-231-9/+21
| | | | | | | | When this fails it can be time-consuming to debug. Add some debugging to help with this. Also try to return error codes instead of just using -1. Signed-off-by: Simon Glass <sjg@chromium.org>