summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2023-07-05Merge tag 'v2023.07-rc6' into nextTom Rini4-66/+78
Prepare v2023.07-rc6
2023-06-20mkimage: ecdsa: password for signing from environmentStefano Babic1-1/+15
Use a variable (MKIMAGE_SIGN_PASSWORD) like already done for RSA to allow the signing process to run in batch. Signed-off-by: Stefano Babic <sbabic@denx.de>
2023-06-16efi_selftests: fix protocol repeated selftestingIlias Apalodimas1-0/+2
Running the protocols selftest more than one times fails with => setenv efi_selftest 'manage protocols' && bootefi selftest Testing EFI API implementation Selected test: 'manage protocols' Setting up 'manage protocols' Setting up 'manage protocols' succeeded Executing 'manage protocols' Executing 'manage protocols' succeeded Tearing down 'manage protocols' Tearing down 'manage protocols' succeeded Summary: 0 failures => bootefi selftest Testing EFI API implementation Selected test: 'manage protocols' Setting up 'manage protocols' lib/efi_selftest/efi_selftest_manageprotocols.c(88): ERROR: InstallProtocolInterface failed lib/efi_selftest/efi_selftest.c(89): ERROR: Setting up 'manage protocols' failed Tearing down 'manage protocols' Tearing down 'manage protocols' succeeded Summary: 1 failures The reason is that we don't set the handles to NULL after deleting and freeing them. As a result the subsequent protocol installation will try to use an existing handle which we just removed that from our object list. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-06-16efi_loader: simplify efi_disk_removeIlias Apalodimas1-65/+26
Instead of discovering the ID of the device and call two different functions for a block device or a partition, we can rewrite efi_disk_remove() and handle the minor differences between the two variants internally. As a results we can simplify efi_disk_remove() a lot and get rid of the extra efi_disk_delete_raw/blk calls. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> If a handle is not found, return 0 to let the device be removed. Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-06-16efi_selftests: fix controllers repeated selftestingIlias Apalodimas1-1/+25
Running the controller selftest more than one times fails with => setenv efi_selftest 'controllers' && bootefi selftest Testing EFI API implementation Selected test: 'controllers' Setting up 'controllers' Setting up 'controllers' succeeded Executing 'controllers' Executing 'controllers' succeeded Summary: 0 failures => bootefi selftest Testing EFI API implementation Selected test: 'controllers' Setting up 'controllers' lib/efi_selftest/efi_selftest_controllers.c(280): ERROR: InstallProtocolInterface failed lib/efi_selftest/efi_selftest.c(89): ERROR: Setting up 'controllers' failed Summary: 1 failures There are multiple reason for this. We don't uninstall the binding interface from the controller handle and we don't reset the handle pointers either. So let's uninstall all the protocols properly and reset the handles to NULL on setup(). While at it add a forgotten check when uninstalling protocols from the handle_controller and make sure the number of child controllers is 0 Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-06-16efi_selftest: ReinstallProtocolInterface testHeinrich Schuchardt1-0/+25
Test ReinstallProtocolInterface() more rigorously. Replacing the sole installed protocol interface must not result in deleting the handle and creating a new one. Check which interface is actually installed before and after ReinstallProtocolInterface(). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-06-12Merge tag v2023.07-rc4 into nextTom Rini9-83/+118
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-06-09fwu: provide default fwu_plat_get_bootidxJassi Brar1-0/+18
Just like fwu_plat_get_update_index, provide a default/weak implementation of fwu_plat_get_bootidx. So that most platforms wouldn't have to re-implement the likely case. Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2023-06-09FWU: Add FWU metadata access driver for MTD storage regionsMasami Hiramatsu2-0/+186
In the FWU Multi Bank Update feature, the information about the updatable images is stored as part of the metadata, on a separate region. Add a driver for reading from and writing to the metadata when the updatable images and the metadata are stored on a raw MTD region. The code is divided into core under drivers/fwu-mdata/ and some helper functions clubbed together under lib/fwu_updates/ Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2023-06-09fwu: rename fwu_get_verified_mdata to fwu_get_mdataJassi Brar1-3/+3
fwu_get_mdata() sounds more appropriate than fwu_get_verified_mdata() Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2023-06-09fwu: meta-data: switch to management by common codeJassi Brar1-204/+31
The common code can now read, verify and fix meta-data copies while exposing one consistent structure to users. Only the .read_mdata() and .write_mdata() callbacks of fwu_mdata_ops are needed. Get rid of .get_mdata() .update_mdata() .get_mdata_part_num() .read_mdata_partition() and .write_mdata_partition() and also the corresponding wrapper functions. Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2023-06-09fwu: move meta-data management in coreJassi Brar1-6/+127
Instead of each i/f having to implement their own meta-data verification and storage, move the logic in common code. This simplifies the i/f code much simpler and compact. Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2023-06-08efi_loader: check lowest supported versionMasahisa Kojima1-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>
2023-06-08efi_loader: get lowest supported version from device treeMasahisa Kojima1-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>
2023-06-08efi_loader: versioning support in GetImageInfoMasahisa Kojima1-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>
2023-06-08efi_loader: store firmware version into FmpState variableMasahisa Kojima1-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>
2023-06-08efi_loader: add the number of image entries in efi_capsule_update_infoMasahisa Kojima2-4/+4
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>
2023-06-02efi_selftest: LocateHandleBuffer return codeHeinrich Schuchardt1-5/+11
Check that LocateHandleBuffer() return EFI_NOT_FOUND when called with ByRegisterNotify and all handles already have been retrieved. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-06-02efi_loader: check return value of part_get_info()Heinrich Schuchardt1-1/+6
part_get_info() may return an error code. Check it. Update function description of dp_part_node(). Addresses-Coverity-ID: 184067 ("Unchecked return value") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-06-01efi: Correct .efi rulesSimon Glass1-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>
2023-06-01acpi: Put the version numbers in a central placeSimon Glass1-8/+7
At present two acpi files are built every time since they use a version number from version.h This is not necessary. Make use of the same technique as for the version string, so that they are build only when they change. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-05-13efi_loader: fix efi_dp_from_file()Heinrich Schuchardt2-36/+16
* When called from efi_dp_from_name() we miss to append the filename for non-block devices. * expand_media_path() could be simplified by using efi_dp_from_file to prepend the device path of the boot device. This can be avoided by passing a device path to efi_dp_from_file() instead of a block device descriptor and a partition number. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13efi_loader: simplify efi_dp_from_name()Heinrich Schuchardt1-10/+8
Don't do the same check and assignment in multiple places. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13efi_loader: error code efi_dp_from_name()Heinrich Schuchardt1-1/+1
Use EFI_OUT_OF_RESOURCES if the device path cannot be constructed. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13efi_loader: clean up efi_dp_from_fileHeinrich Schuchardt1-7/+9
* Improve variable name usage: Use pos instead of buf to indicate the current position in a buffer. * Avoid double assignment in a single code line. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13efi_loader: duplicate code in efi_dp_from_nameHeinrich Schuchardt1-13/+1
efi_dp_from_name() has duplicate code to replace slash by backslash. path_to_uefi() called by efi_dp_from_file() already does this. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13efi_loader: avoid #ifdef in efi_dp_from_name()Heinrich Schuchardt1-12/+8
According to our coding style guide #ifdef should be avoided. Use IS_ENABLED() instead. Sort string comparisons alphabetically. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13efi_loader: support booting semihosting fileHeinrich Schuchardt1-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>
2023-05-13efi_loader: print file path w/o boot deviceHeinrich Schuchardt1-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>
2023-05-13fwu: fix config FWU_MULTI_BANK_UPDATEHeinrich Schuchardt1-1/+1
Symbol CONFIG_EFI_SETUP_EARLY does not exist anymore. CONFIG_FWU_MULTI_BANK_UPDATE without CONFIG_FWU_MDATA results in lib/fwu_updates/fwu.c:49: undefined reference to `fwu_get_mdata' Fixes: 86794052418b ("FWU: Add support for the FWU Multi Bank Update feature") Fixes: 023d9c93932c ("efi_loader: remove CONFIG_EFI_SETUP_EARLY") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2023-05-11acpi: Move the table-finding functions into the libarySimon Glass2-0/+47
This is useful for other features. Move the function into library code so it can be used outside just the 'acpi' command. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
2023-05-11acpi: Create a new Kconfig for ACPISimon Glass3-2/+14
We have several Kconfig options for ACPI, but all relate to specific functions, such as generating tables and AML code. Add a new option which controls including basic ACPI library code, including the lib/acpi directory. This will allow us to add functions which are available even if table generation is not supported. Adjust the command to avoid a build error when ACPIGEN is not enabled. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-05-01Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxiTom Rini1-1/+0
Please pull the second part of the sunxi pull request for this cycle. Another bunch of patches that replace old-school U-Boot hacks with proper DM based code, this time for the raw NAND flash driver, and the USB PHY VBUS detection code. Plus two smaller patches that were sitting in my inbox for a while. Gitlab CI passed. In lack of some supported board with NAND flash I couldn't really test this part, but apparently this was tested by the reviewer. I briefly ran the branch on some boards with USB-OTG, and this still worked.
2023-04-28fdt: Indicate that people should use the ofnode APISimon Glass1-0/+3
Add a note to the comment at the top of this file. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-28mtd: nand: sunxi: Convert from fdtdec to ofnodeSamuel Holland1-1/+0
As a first step toward converting this driver to the driver model, use the ofnode abstraction to replace direct references to the FDT blob. Using ofnode_read_u32_index removes an extra pair of loops and makes the allwinner,rb property optional, matching the devicetree binding. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2023-04-21efi_loader: remove unused efi_capsule_authenticateHeinrich Schuchardt1-6/+0
Remove an unused implementation of efi_capsule_authenticate(). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-04-08efi: loader: Make efi_runtime_mmio staticBin Meng1-1/+1
efi_runtime_mmio is only referenced in efi_boottime.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
2023-04-08efi: loader: Make efi_mem staticBin Meng1-1/+1
efi_mem is only referenced in efi_memory.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
2023-04-08efi: loader: Make efi_event_queue and efi_register_notify_events staticBin Meng1-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>
2023-04-08efi: selftest: Make load_file() and load_file2() staticBin Meng1-10/+10
load_file() and load_file2() are only referenced in efi_selftest_load_file.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
2023-04-08efi: selftest: Make record staticBin Meng1-1/+1
record is only referenced in efi_selftest_exitbootservices.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
2023-04-08efi_loader: avoid using HandleProtocol in initrddump.efiHeinrich Schuchardt1-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>
2023-04-08efi_loader: avoid using HandleProtocol in helloworld.efiHeinrich Schuchardt1-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>
2023-04-07lib: missing fallthrough comment in vsnprintf_internal()Heinrich Schuchardt1-0/+3
When a case statement intentionally falls through we should add a comment. Cf. -Wimplicit-fallthrough Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-04-06lmb: add max number of region in lmb_dump_region() outputPatrick Delaunay1-1/+1
Add the max number of region in lmb dump; this patch allows to check the limit for usage of the LMB regions, memory or reserved. Result on STM32MP157C-DK2: STM32MP> bdinfo ..... lmb_dump_all: memory.cnt = 0x1 / max = 0x2 memory[0] [0xc0000000-0xdfffffff], 0x20000000 bytes flags: 0 reserved.cnt = 0x6 / max = 0x10 reserved[0] [0x10000000-0x10045fff], 0x00046000 bytes flags: 4 reserved[1] [0x30000000-0x3003ffff], 0x00040000 bytes flags: 4 reserved[2] [0x38000000-0x3800ffff], 0x00010000 bytes flags: 4 reserved[3] [0xd4000000-0xd7ffffff], 0x04000000 bytes flags: 4 reserved[4] [0xdcae5000-0xdfffffff], 0x0351b000 bytes flags: 0 reserved[5] [0xddafb5b8-0xdfffffff], 0x02504a48 bytes flags: 0 .... Reported-by: Mark Millard <marklmi@yahoo.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-04-06lmb: Fix LMB_MEMORY_REGIONS flag usagePatrick Delaunay2-5/+4
Remove test on CONFIG_LMB_MEMORY_REGIONS introduced by commit 7c1860fce4e3 ("lmb: Fix lmb property's defination under struct lmb"). This code in lmb_init() is strange, because if CONFIG_LMB_USE_MAX_REGIONS and CONFIG_LMB_MEMORY_REGIONS are not defined, the implicit #else is empty and the required initialization is not done: lmb->memory.max = ? lmb->reserved.max = ? But this setting is not possible: - CONFIG_LMB_USE_MAX_REGIONS not defined - CONFIG_LMB_MEMORY_REGIONS not defined because CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS are defined as soon as the CONFIG_LMB_USE_MAX_REGIONS is not defined. This patch removes this impossible case #elif and I add some explanation in lmb.h to explain why in the struct lmb {} the lmb property is defined if CONFIG_LMB_MEMORY_REGIONS is NOT defined. This patch also removes CONFIG_LMB_XXX dependency on CONFIG_LMB as these defines are used in API file lmb.h and not only in library file. Fixes: 5e2548c1d6e03 ("lmb: Fix LMB_MEMORY_REGIONS flag usage") Reported-by: Mark Millard <marklmi@yahoo.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Acked-by: Michal Simek <michal.simek@amd.com>
2023-04-05efi_loader: device_path: support blkmap devicesTobias Waldekranz1-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>
2023-04-03Merge branch 'next'Tom Rini12-57/+136
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-04-01efi_loader: remove duplicate assignmentHeinrich Schuchardt1-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>
2023-04-01efi_loader: correct shortening of device-pathsHeinrich Schuchardt1-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>