summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2023-08-28Revert "arm: imx: mx7: Move CONFIG_OPTEE_TZDRAM_SIZE from lib/optee"Ricardo Salveti1-0/+8
This reverts commit c5b68ef8af3c2f515c1f5b8d63a69359a85d753b. CONFIG_OPTEE_TZDRAM_SIZE is used by imx6-based SoCs as well. Move the option back. Signed-off-by: Ricardo Salveti <ricardo@foundries.io> Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
2023-08-28spl: crypto: fix including SHA* object files in SPLOleksandr Suvorov1-3/+3
If one of SHA* algorithms is disabled in u-boot, its code is not included in SPL even if a given SHA* option is enabled in SPL. Fix this. Fixes: 603d15a572d ("spl: cypto: Bring back SPL_ versions of SHA") Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-08-27efi_loader: delete handle from events when a protocol is uninstalledIlias Apalodimas1-24/+65
When a notification event is registered for a protocol the handle of the protocol is added in our event notification list. When all the protocols of the handle are uninstalled we delete the handle but we do not remove it from the event notification list. Clean up the protocol removal functions and add a wrapper which - Removes the to-be deleted handle from any lists it participates - Remove the handle if no more protocols are present Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-08-27lib: parameter check in hash_calculateHeinrich Schuchardt1-2/+4
If hash_calculate is invoked with region_count = 0, it will try to hash INT_MAX regions. We should check this parameter. * Avoid a comparison with different signedness. * Check that region_count is at least 1. * Avoid a superfluous assignment. Fixes: b37b46f042cc ("rsa: Use checksum algorithms from struct hash_algo") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-15efi_loader: fix efi_add_known_memory()Heinrich Schuchardt1-1/+1
In efi_add_known_memory() we currently call board_get_usable_ram_top() with an incorrect value 0 of parameter total_size. This leads to an incorrect value for ram_top depending on the code in board_get_usable_ram_top(). Use the value of gd->ram_top instead which is set before relocation by calling board_get_usable_ram_top(). Fixes: 7b78d6438a2b ("efi_loader: Reserve unaccessible memory") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-08-09lib: Suppress E when writing error-string outputSimon Glass1-2/+3
When CONFIG_ERRNO_STR is not enabled this shows a spurious 'E' from the format string. Fix this. Fixes: 7f331941321 ("lib: Support printing an error string") Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-08-08arm_ffa: efi: introduce FF-A MM communicationAbdellatif El Khlifi2-6/+303
Add MM communication support using FF-A transport This feature allows accessing MM partitions services through EFI MM communication protocol. MM partitions such as StandAlonneMM or smm-gateway secure partitions which reside in secure world. An MM shared buffer and a door bell event are used to exchange the data. The data is used by EFI services such as GetVariable()/SetVariable() and copied from the communication buffer to the MM shared buffer. The secure partition is notified about availability of data in the MM shared buffer by an FF-A message (door bell). On such event, MM SP can read the data and updates the MM shared buffer with the response data. The response data is copied back to the communication buffer and consumed by the EFI subsystem. MM communication protocol supports FF-A 64-bit direct messaging. We tested the FF-A MM communication on the Corstone-1000 platform. We ran the UEFI SCT test suite containing EFI setVariable, getVariable and getNextVariable tests which involve FF-A MM communication and all tests are passing with the current changes. We made the SCT test reports (part of the ACS results) public following the latest Corstone-1000 platform software release. Please find the test reports at [1]. [1]: https://gitlab.arm.com/arm-reference-solutions/arm-reference-solutions-test-report/-/tree/master/embedded-a/corstone1000/CORSTONE1000-2023.06/acs_results_fpga.zip Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Tested-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2023-08-08lib: uuid: introduce uuid_str_to_le_bin functionAbdellatif El Khlifi1-0/+48
convert UUID string to little endian binary data Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jens Wiklander <jens.wiklander@linaro.org>
2023-08-07spl: move SPL_CRC32 option to lib/KconfigOleksandr Suvorov1-0/+11
All SPL hash algorithm options are collected in lib/Kconfig. Move SPL_CRC32 there as well. Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-03efi_loader: check uuid_str_to_bin return valueMasahisa Kojima1-2/+6
Check the uuid_str_to_bin return value, skip the node if the image-type-id property is wrong format. Addresses-Coverity-ID: 463145 ("Error handling issues") Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-08-03efi_loader: catch out of memory in file_openHeinrich Schuchardt1-0/+2
If calloc() return NULL, don't dereference it. Fixes: 2a92080d8c44 ("efi_loader: add file/filesys support") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: error handling in efi_disk_add_devHeinrich Schuchardt2-10/+17
* If an error occurs in efi_disk_add_dev(), don't leak resources. * If calloc() fails while creating the file system protocol interface, signal an error. * Rename efi_simple_file_system() to efi_create_simple_file_system(). * Drop a little helpful debug message. Fixes: 2a92080d8c44 ("efi_loader: add file/filesys support") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: memory leak efi_add_memory_map_pgHeinrich Schuchardt1-0/+2
Don't leak newlist if we error out. Fixes: 74c16acce30b ("efi_loader: Don't allocate from memory holes") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: out of memory in efi_mem_carve_outHeinrich Schuchardt1-0/+6
Handle out of memory situation in efi_mem_carve_out(). Fixes: 5d00995c361c ("efi_loader: Implement memory allocation and map") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: overflow in efi_allocate_pagesHeinrich Schuchardt1-1/+6
On 32bit systems (pages << EFI_PAGE_SHIFT) may lead to an overflow which does not occur in 64bit arithmetics. An overflow of (pages << EFI_PAGE_SHIFT) on 64bit systems should be treated as an error. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-08-03efi_loader: error handling in tcg2_hash_pe_image()Heinrich Schuchardt1-4/+2
If the hard coded array hash_algo_list[] contains an entry for an unsupported algorithm, we should not leak resources new_efi and regs. We should still extend the log with the digests for the supported algorithms and not write any message. The same holds true of tcg2_create_digest(): just continue in case hash_algo_list[] contains an unsupported entry. Fixes: 163a0d7e2cbd ("efi_loader: add PE/COFF image measurement") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: out of memory in efi_add_memory_map_pgHeinrich Schuchardt1-0/+2
Handle out of memory situation in efi_add_memory_map_pg(). Fixes: 5d00995c361c ("efi_loader: Implement memory allocation and map") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_selftest: remove superfluous assignmentsHeinrich Schuchardt1-11/+0
In test_hii_database_list_package_lists() 'ret' is used for the return code of EFI API calls and 'result' for the return value of the function. Writing EFI_ST_FAILURE to ret is superfluous. Fixes: 4c4fb10da294 ("efi_selftest: add HII database protocols test") Fixes: ee3c8ba85525 ("efi_selftest: fix memory allocation in HII tests") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: fix an IS_ERR() vs NULL checkDan Carpenter1-2/+1
The efi_parse_pkcs7_header() function returns NULL on error so the check for IS_ERR() should be changed to a NULL check. Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-08-03efi_loader: capsule: enforce guid check in api and capsule_on_diskAKASHI Takahiro1-9/+8
While UPDATE_CAPSULE api is not fully implemented, this interface and capsule-on-disk feature should behave in the same way, especially in handling an empty capsule for fwu multibank, for future enhancement. So move the guid check into efi_capsule_update_firmware(). Fixed: commit a6aafce494ab ("efi_loader: use efi_update_capsule_firmware() for capsule on disk") Reported-by: Michal Simek <michal.simek@amd.com> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reported-by: Michal Simek <michal.simek@amd.com> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Tested-by: Michal Simek <michal.simek@amd.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-08-03efi_loader: Fix memory corruption on 32bit systemsDan Carpenter1-2/+3
It's pretty unlikely that anyone is going to be using EFI authentication on a 32bit system. However, if you did, the efi_prepare_aligned_image() function would write 8 bytes of data to the &efi_size variable and it can only hold 4 bytes so that corrupts memory. Fixes: 163a0d7e2cbd ("efi_loader: add PE/COFF image measurement") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-07-28efi_loader: fix uninitialized variable bug in efi_set_load_options()Dan Carpenter1-1/+1
Check for efi_search_protocol() failure before dereferencing "handler" to avoid a crash. Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
2023-07-28efi_loader: make efi_delete_handle() follow the EFI specIlias Apalodimas3-14/+25
The EFI doesn't allow removal of handles, unless all hosted protocols are cleanly removed. Our efi_delete_handle() is a bit intrusive. Although it does try to delete protocols before removing a handle, it doesn't care if that fails. Instead it only returns an error if the handle is invalid. On top of that none of the callers of that function check the return code. So let's rewrite this in a way that fits the EFI spec better. Instead of forcing the handle removal, gracefully uninstall all the handle protocols. According to the EFI spec when the last protocol is removed the handle will be deleted. Also switch all the callers and check the return code. Some callers can't do anything useful apart from reporting an error. The disk related functions on the other hand, can prevent a medium that is being used by EFI from removal. The only function that doesn't check the result is efi_delete_image(). But that function needs a bigger rework anyway, so we can clean it up in the future Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-07-28efi_loader: simplify dp_fill()Heinrich Schuchardt1-27/+18
Move the recursive dp_fill(dev->parent) call to a single location. Determine uclass_id only once. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-28efi_loader: device paths for special block devicesHeinrich Schuchardt1-93/+21
The UEFI specification does not provide node types matching UCLASS_BLKMAP, UCLASS_HOST, UCLASS_VIRTIO block devices. The current implementation uses VenHw() nodes with uclass specific GUIDs and a single byte for the device number appended. This leads to unaligned integers in succeeding device path nodes. The current implementation fails to create unique device paths for block devices based on other uclasses like UCLASS_PVBLOCK. Let's use a VenHw() node with the U-Boot GUID with a length dividable by four and encoding blkdesc->uclass_id as well as blkdesc->devnum. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-25fwu: Show number of attempts in Trial StateMichal Simek1-0/+2
It is not visible anywhere in Trial State if this is the first, second, etc attempt that's why show a message to be aware about status. Signed-off-by: Michal Simek <michal.simek@amd.com> Acked-by: Jassi Brar <jaswinder.singh@linaro.org>
2023-07-25fwu: mtd: Fix dfu_alt_info generation for 2 images per bankMichal Simek1-2/+4
Code rewrites the last char of size with adding &. It is visible from dfu_alt_info print before this patch: Make dfu_alt_info: 'mtd nor0=bank0 raw 2320000 80000;bank1 raw 27a0000 8000&mtd nor0=bank0 raw 23a0000 4000000;bank1 raw 2820000 4000000' And after it: Make dfu_alt_info: 'mtd nor0=bank0 raw 2320000 80000;bank1 raw 27a0000 80000&mtd nor0=bank0 raw 23a0000 4000000;bank1 raw 2820000 4000000' Size for bank0 and bank1 must be the same because it is the same image. Signed-off-by: Michal Simek <michal.simek@amd.com> Acked-by: Jassi Brar <jaswinder.singh@linaro.org>
2023-07-25fwu: Allow code to properly decode trial stateMichal Simek1-2/+0
Current code after capsule update (mtd write) is not changing active_index in mdata to previous_active_index. On the reboot this is shown but showing message "Boot idx 1 is not matching active idx 0, changing active_idx" which is changing active_idx and writing mdata to flash. But when this message is visible it is not checking which state that images are. If they have acceptance bit setup to yes everything is fine and valid images are booted (doesn't mean the latest one). But if acceptance bit is no and images are in trial state in_trial variable is never setup. Which means that from new flashed image stable image can be rewritten because in_trial is not setup properly. Signed-off-by: Michal Simek <michal.simek@amd.com> Acked-by: Jassi Brar <jaswinder.singh@linaro.org>
2023-07-25lib: sparse: allocate FASTBOOT_MAX_BLK_WRITE instead of small numberMattijs Korpershoek1-1/+2
Commit 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned") fixed cache alignment for systems with a D-CACHE. However it introduced some performance regressions [1] on system flashing huge images, such as Android. On AM62x SK EVM, we also observe such performance penalty: Sending sparse 'super' 1/2 (768793 KB) OKAY [ 23.954s] Writing 'super' OKAY [ 75.926s] Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.641s] Writing 'super' OKAY [ 62.849s] Finished. Total time: 182.474s The reason for this is that we use an arbitrary small buffer (info->blksz * 100) for transferring. Fix it by using a bigger buffer (info->blksz * FASTBOOT_MAX_BLK_WRITE) as suggested in the original's patch review [2]. With this patch, performance impact is mitigated: Sending sparse 'super' 1/2 (768793 KB) OKAY [ 23.912s] Writing 'super' OKAY [ 15.780s] Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.581s] Writing 'super' OKAY [ 17.192s] Finished. Total time: 76.569s [1] https://lore.kernel.org/r/20221118121323.4009193-1-gary.bisson@boundarydevices.com [2] https://lore.kernel.org/r/all/43e4c17c-4483-ec8e-f843-9b4c5569bd18@seco.com/ Fixes: 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned") Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-07-25Revert "Merge branch '2023-07-24-introduce-FF-A-suppport'"Tom Rini3-344/+7
This reverts commit d927d1a80843e1c3e2a3f0b8f6150790bef83da1, reversing changes made to c07ad9520c6190070513016fdb495d4703a4a853. These changes do not pass CI currently. Signed-off-by: Tom Rini <trini@konsulko.com>
2023-07-24arm_ffa: efi: introduce FF-A MM communicationAbdellatif El Khlifi2-7/+296
Add MM communication support using FF-A transport This feature allows accessing MM partitions services through EFI MM communication protocol. MM partitions such as StandAlonneMM or smm-gateway secure partitions which reside in secure world. An MM shared buffer and a door bell event are used to exchange the data. The data is used by EFI services such as GetVariable()/SetVariable() and copied from the communication buffer to the MM shared buffer. The secure partition is notified about availability of data in the MM shared buffer by an FF-A message (door bell). On such event, MM SP can read the data and updates the MM shared buffer with the response data. The response data is copied back to the communication buffer and consumed by the EFI subsystem. MM communication protocol supports FF-A 64-bit direct messaging. Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Tested-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jens Wiklander <jens.wiklander@linaro.org>
2023-07-24lib: uuid: introduce uuid_str_to_le_bin functionAbdellatif El Khlifi1-0/+48
convert UUID string to little endian binary data Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jens Wiklander <jens.wiklander@linaro.org>
2023-07-22lib: Kconfig: k3: Enable SHA512 for fit signatureManorit Chawdhry1-0/+1
We are using our custMpk for signing that is a 4096 bit key, 4096 bit rsa key requires a SHA512 hashing algorithm to be enabled as per the source. Even though it is not mandated but this is how it works and is tested. Enables SHA512 if fit signature is enabled on K3 platforms. Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2023-07-20efi_loader: support all uclasses in device pathHeinrich Schuchardt1-31/+25
On devices with multiple USB mass storage devices errors like Path /../USB(0x0,0x0)/USB(0x1,0x0)/Ctrl(0x0) already installed. are seen. This is due to creating non-unique device paths. To uniquely identify devices we must provide path nodes for all devices on the path from the root device. Add support for generating device path nodes for all uclasses. Reported-by: Suniel Mahesh <sunil@amarulasolutions.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-07-20efi_loader: fix dp_fill() for BLKMAP, HOST, VIRTIOHeinrich Schuchardt1-9/+3
Do not assume that the preceding device path contains a single VenHW node. Instead use the return value of dp_fill() which provides the address of the next node. Fixes: 23ad52fff4da ("efi_loader: device_path: support Sandbox's "host" devices") Fixes: 19ecced71cfb ("efi_loader: device path for virtio block devices") Fixes: 272ec6b45304 ("efi_loader: device_path: support blkmap devices") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-07-20efi_driver: fix duplicate efiblk#0 issueMasahisa Kojima1-4/+2
The devnum value of the blk_desc structure starts from 0, current efi_bl_create_block_device() function creates two "efiblk#0" devices for the cases that blk_find_max_devnum() returns -ENODEV and blk_find_max_devnum() returns 0(one device found in this case). This commit uses blk_next_free_devnum() instead of blk_find_max_devnum(). Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2023-07-20efi_loader: make efi_remove_protocol() staticIlias Apalodimas1-3/+3
A previous patch is removing the last consumer of efi_remove_protocol(). Switch that to static and treat it as an internal API in order to force users install and remove protocols with the appropriate EFI functions. It's worth noting that we still have files using efi_add_protocol(). We should convert all these to efi_install_multiple_protocol_interfaces() and treat efi_add_protocol() in a similar manner Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-20efi_loader: use efi_install_multiple_protocol_interfaces()Ilias Apalodimas1-4/+4
The TCG2 protocol currently adds and removes protocols with efi_(add/remove)_protocol(). Removing protocols with efi_remove_protocol() might prove problematic since it doesn't call DisconnectController() when uninstalling the protocol and does not comply with the UEFI specification. It's also beneficial for readability to have protocol installations and removals in pairs -- IOW when efi_install_multiple_protocol_interfaces() is called, efi_uninstall_multiple_protocol_interfaces() should be used to remove it. So let's swap the efi_add_protocol() as well. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-20efi_loader: simplify efi_uninstall_protocol()Heinrich Schuchardt1-8/+1
The call to efi_search_obj() is redundant as the function is called in efi_search_protocol() too. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-17Merge https://source.denx.de/u-boot/custodians/u-boot-x86Tom Rini2-15/+20
- bootstd: Add a bootmeth for ChromiumOS on x86 - x86: Use qemu-x86_64 to boot EFI installers
2023-07-17efi: Use the installed ACPI tablesSimon Glass1-14/+19
U-Boot sets up the ACPI tables during startup. Rather than creating a new set, install the existing ones. Create a memory-map record to cover the tables. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-07-17efi: Show all known UUIDs with CONFIG_CMD_EFIDEBUGSimon Glass1-1/+1
The CMD_EFIDEBUG option enables debugging so it is reasonable to assume that all effects should be made to decode the dreaded UUIDs favoured by UEFI. Update the table to show them all when CONFIG_CMD_EFIDEBUG is enabled. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-07-15Merge tag 'efi-2023-10-rc1' of ↵Tom Rini4-10/+487
https://source.denx.de/u-boot/custodians/u-boot-efi Pull request efi-2023-10-rc1 Documentation: * enhance UEFI anti-rollback documentation EFI: * Reconnect drivers if UninstallProtocol fails * Prefer short device paths for boot options * Fix error handling when updating boot options for block devices
2023-07-15efi_selftests: add extra testcases on controller handlingIlias Apalodimas1-3/+41
We recently fixed a few issues wrt to controller handling. Add a few test cases to cover the new code. - return EFI_DEVICE_ERROR the first time the protocol interface of the controller is uninstalled, after all the children have been disconnected. This should make the drivers reconnect - add tests to verify controllers are reconnected when uninstalling a protocol fails - add tests to make sure EFI_NOT_FOUND is returned if a non existent interface is being removed Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-15efi_loader: fix the return codes of UninstallProtocolIlias Apalodimas1-0/+2
Up to now we did not check the return value of DisconnectController. A previous patch is fixing that taking into account what happened during the controller disconnect. But that check takes place before our code is trying to figure out if the interface exists to begin with. In case a driver is not allowed to unbind -- e.g returning EFI_DEVICE_ERROR, we will end up returning that error instead of EFI_NOT_FOUND. Add an extra check on the top of the function to make sure the protocol interface exists before trying to disconnect any drivers Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-15efi_loader: check the status of disconnected driversIlias Apalodimas1-2/+8
efi_uninstall_protocol() calls efi_disconnect_all_drivers() but never checks the return value. Instead it tries to identify protocols that are still open after closing the ones that were opened with EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL, EFI_OPEN_PROTOCOL_GET_PROTOCOL and EFI_OPEN_PROTOCOL_TEST_PROTOCOL. Instead of doing that, check the return value early and exit if disconnecting the drivers failed. Also reconnect all the drivers of a handle if protocols are still found on the handle after disconnecting controllers and closing the remaining protocols. While at it fix a memory leak and properly free the opened protocol information when closing a protocol. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2023-07-15efi_loader: reconnect drivers on failureIlias Apalodimas1-5/+26
efi_disconnect_controller() doesn't reconnect drivers in case of failure. Reconnect the disconnected drivers properly Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2023-07-15Load option with short device path for boot varsRaymond Mao1-0/+6
The boot variables automatically generated for removable medias should be with short form of device path without device nodes. This is a requirement for the case that a removable media is plugged into a different port but is still able to work with the existing boot variables. 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>
2023-07-15Fix incorrect return code of boot option updateRaymond Mao1-2/+6
Correct the return code for out-of-memory and no boot option found Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-15Move bootorder and bootoption apis to libRaymond Mao2-0/+400
Rename and move bootorder and bootoption apis from cmd to lib for re-use between eficonfig and bootmgr Fix 'unexpected indentation' when 'make htmldocs' after functions are moved Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>