summaryrefslogtreecommitdiff
path: root/lib/efi_selftest
AgeCommit message (Collapse)Author
2026-03-09Merge tag 'v2026.04-rc4' into nextTom Rini
Prepare v2026.04-rc4
2026-02-27efi_selftest: cosmetic: fix spelling in commentsVincent Stehlé
Fix a few UEFI function names, as well as a typo. Signed-off-by: Vincent Stehlé <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Tom Rini <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2026-02-27efi_selftest: test specific LoadImage() caseVincent Stehlé
Add a test calling the LoadImage() UEFI function with both its SourceBuffer and DevicePath input arguments equal to NULL. This test can be run on the sandbox with the following command: ./u-boot -T -c "setenv efi_selftest load image from file; \ bootefi selftest" Signed-off-by: Vincent Stehlé <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Ilias Apalodimas <[email protected]> Cc: Tom Rini <[email protected]>
2026-02-15efi_selftest: Enhance MBR test for PARTITION_INFO_PROTOCOLJavier Martinez Canillas
The EFI_PARTITION_INFO_PROTOCOL test was added before the protocol fully supported MBR partitions. As a result, it lacked specific checks for the content of the raw MBR partition record. Now that MBR support has been implemented, enhance the selftest to provide coverage for the MBR entries too. This verifies that the protocol correctly reads and exposes MBR partition records and prevents this functionality to regress due future changes. Signed-off-by: Javier Martinez Canillas <[email protected]> Acked-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2025-12-24efi_selftest: remove unnecessary __efi_runtime_data attributeHeinrich Schuchardt
Assigning a single variable to section __efi_runtime_date while the rest of the test is in the boottime section does not make much sense. As we do not set a virtual address map here, we don't need a runtime section. Update the variables at runtime test. Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-12-24efi_selftest: Enhance LoadImage testHeinrich Schuchardt
Check that only a file system installed on a handle for the device-path node immediately preceding the file path node is used for LoadImage(). LoadImage() ends up invoking efi_dp_find_obj(). This test helped to demonstrate an issue in a suggested patch to change that function. The test can be run with: setenv efi_selftest load image from file bootefi selftest Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-11-24Merge tag 'v2026.01-rc3' into nextTom Rini
Prepare v2026.01-rc3
2025-11-21efi_selftest: simplify efi_selftest_variables_runtimeHeinrich Schuchardt
Use global st_boottime and st_runtime. Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-11-21efi_selftest: simplify efi_selftest_variablesHeinrich Schuchardt
Use global st_boottime and st_runtime. Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-11-21efi_selftest: simplify efi_st_query_variable_commonHeinrich Schuchardt
Use global st_runtime. Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-11-21efi_selftest: simplify efi_selftest_set_virtual_address_mapHeinrich Schuchardt
Use global st_boottime and st_runtime. Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-11-21efi_selftest: simplify efi_selftest_rtcHeinrich Schuchardt
Use global st_runtime. Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-11-21efi_selftest: simplify efi_selftest_resetHeinrich Schuchardt
Use global st_runtime. Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-11-21efi_selftest: expose runtime table addressHeinrich Schuchardt
Save the address of the EFI runtime as a global variable. This allows to simplify the setup of tests. Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-11-15efi_selftest: efi_selftest_snp: Fix warning when building with clangTom Rini
When building with clang, we see a warning: lib/efi_selftest/efi_selftest_snp.c:63:18: error: field dhcp_hdr within 'struct dhcp' is less aligned than 'struct dhcp_hdr' and is usually due to 'struct dhcp' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access] when building lib/efi_selftest/efi_selftest_snp.c. Resolve this error by packing struct dhcp_hdr as well, as the only place it is used also is packed. Signed-off-by: Tom Rini <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2025-11-15efi_selftest: use Sphinx style comments in efi_console.cHeinrich Schuchardt
Convert function comments in efi_selftest_console.c to match Sphinx style. Correct function name in print_uuid() comment. Acked-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-07-26efi_selftest: fix ESRT creation testsHeinrich Schuchardt
The code foresees that parameters descriptor_size and descriptor_count might be NULL and then dereferences them without further check. The size check must take into account the descriptor count. ImageInfo might be NULL. In this case we must not dereference it. Fixes: 4ac6041c3cbf ("efi: ESRT creation tests") Addresses-Coverity-ID: CID 569497: Null pointer dereferences (FORWARD_NULL) Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-07-26efi_selftest: check system table pointerHeinrich Schuchardt
Enhance the debug support unit test. Acked-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-07-03efi: selftest: add selftest for EFI_DEBUG_SUPPORTYing-Chun Liu (PaulLiu)
Add selftest to check the installed configuration table that has the correct GUID. Cc: Heinrich Schuchardt <[email protected]> Cc: Ilias Apalodimas <[email protected]> Signed-off-by: Ying-Chun Liu (PaulLiu) <[email protected]> Acked-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2025-07-03efi_selftest: Add basic partition info check to block io testJavier Martinez Canillas
Test the EFI_PARTITION_INFO_PROTOCOL in the existing EFI_BLOCK_IO_PROTOCOL unit test. It is fairly basic, since it only checks that the values of the struct efi_partition_info .revision, .type and .system fields are correct. It doesn't check the MBR partition record information, because that's not supported by the EFI_PARTITION_INFO_PROTOCOL implementation yet. The test can be extended once the support is implemented, or if the in-memory disk image used for the test is modified to have a GPT partition type instead. Suggested-by: Tom Rini <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2025-04-19efi_selftest: check executing in EL2Heinrich Schuchardt
UEFI binaries should be executed in EL2 or EL1 even if U-Boot is started in EL3. Provide a unit test. Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2025-04-11efi_selftest: remove un-needed NULL checksBryan Brattlof
Because we've already returned early in the event 'handle' is NULL we don't need these extra not NULL checks. Remove them Signed-off-by: Bryan Brattlof <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2025-03-10efi_loader: expose symbols to be used by the EFI network stackAdriano Cordova
The following symbols are exposed: - efi_reinstall_protocol_interface This is done so that the device path protocol interface of the network device can be changed internally by u-boot when a new bootfile gets downloaded. - eth_set_dev To support multiple network udevices - efi_close_event This comes in preparation to support unregistering an EFI network device from the EFI network stack when the underlying U-boot device gets removed - efi_[dis]connect_controller The EFI network driver uses ConnectController to add a NIC to the EFI network stack. - efi_uninstall_protocol_interface connect_controler for the efi network driver can install protocols, which need to be uninstalled in disconnect_controller - EFI_SIMPLE_NETWORK_PROTOCOL_GUID Signed-off-by: Adriano Cordova <[email protected]>
2025-01-05efi_loader: Update startimage_exit self-test to check errorSimon Glass
Check for an error returned from the decompress() function, just in case. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2024-12-04efi_selftest: add test for IPv4 Config2 protocolAdriano Cordova
Add a test for the EFI_IP4_CONFIG2_PROTOCOL. The test sets the ip policy to static, adds an ip address, and then reads the current ip address and checks for it to be the same as the one that was set. Signed-off-by: Adriano Cordova <[email protected]>
2024-12-04efi_selftest: add test for HTTP protocolAdriano Cordova
Add a test for the EFI_HTTP_PROTOCOL and EFI_SEVICE_BINDING_PROTOCOL. Signed-off-by: Adriano Cordova <[email protected]>
2024-10-30efi_selftest: make HII test data staticHeinrich Schuchardt
Variables that are only used locally in a module should not be exported. * Make the HII test data variables static. * Remove unused GUIDs. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2024-10-30efi_selftest: fix typo 'got languages' in HII testHeinrich Schuchardt
%s/got languages are/Available languages:/ Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Simon Glass <[email protected]> Acked-by: Ilias Apalodimas <[email protected]>
2024-07-15lib: Remove duplicate newlinesMarek Vasut
Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <[email protected]>
2024-06-30efi_selftest: can't have measured device-tree with kaslr-seedHeinrich Schuchardt
Test that we don't have a /chosen/kaslr-seed property if we measure the device-tree. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2024-05-01efi_selftest: add tests for QueryVariableInfo at boottimeIlias Apalodimas
Previous patches added QueryVariableInfo at runtime tests and split a common function that can be used at boottime. Weire it up and run a similar set of tets. While at it move a test which is checiking for 0 available storage in the common code Add tests for - Test QueryVariableInfo returns EFI_SUCCESS - Test null pointers for the function arguments - Test invalid combination of attributes Signed-off-by: Ilias Apalodimas <[email protected]>
2024-05-01efi_selftest: add tests for QueryVariableInfo at runtimeIlias Apalodimas
Since we support QueryVariableInfo at runtime now add the relevant tests. Since we want those to be reusable at bootime, add them in a separate file Add tests for - Test QueryVariableInfo returns EFI_SUCCESS - Test null pointers for the function arguments - Test invalid combination of attributes Signed-off-by: Ilias Apalodimas <[email protected]>
2024-05-01efi_loader: enable QueryVariableInfo at runtime for file backed variablesIlias Apalodimas
Since commit c28d32f946f0 ("efi_loader: conditionally enable SetvariableRT") we are enabling the last bits of missing runtime services. Add support for QueryVariableInfo which we already support at boottime and we just need to mark some fucntions available at runtime and move some checks around. It's worth noting that pointer checks for maxmimum and remaining variable storage aren't when we store variables on the RPMB, since the Secure World backend is already performing them. Signed-off-by: Ilias Apalodimas <[email protected]>
2024-04-20efi_selftest: add tests for setvariableRTIlias Apalodimas
Since we support SetVariableRT now add the relevant tests - Search for the RTStorageVolatile and VarToFile variables after EBS - Try to update with invalid variales (BS, RT only) - Try to write a variable bigger than our backend storage - Write a variable that fits and check VarToFile has been updated correclty - Append to the variable and check VarToFile changes - Try to delete VarToFile which is write protected - Try to add/delete runtime variables - Verify VarToFile contains a valid file format Signed-off-by: Ilias Apalodimas <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-04-20efi_loader: conditionally enable SetvariableRTIlias Apalodimas
When we store EFI variables on file we don't allow SetVariable at runtime, since the OS doesn't know how to access or write that file. At the same time keeping the U-Boot drivers alive in runtime sections and performing writes from the firmware is dangerous -- if at all possible. For GetVariable at runtime we copy runtime variables in RAM and expose them to the OS. Add a Kconfig option and provide SetVariable at runtime using the same memory backend. The OS will be responsible for syncing the RAM contents to the file, otherwise any changes made during runtime won't persist reboots. It's worth noting that the variable store format is defined in EBBR [0] and authenticated variables are explicitly prohibited, since they have to be stored on a medium that's tamper and rollback protected. - pre-patch $~ mount | grep efiva efivarfs on /sys/firmware/efi/efivars type efivarfs (ro,nosuid,nodev,noexec,relatime) $~ efibootmgr -n 0001 Could not set BootNext: Read-only file system - post-patch $~ mount | grep efiva efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime) $~ efibootmgr -n 0001 BootNext: 0001 BootCurrent: 0000 BootOrder: 0000,0001 Boot0000* debian HD(1,GPT,bdae5610-3331-4e4d-9466-acb5caf0b4a6,0x800,0x100000)/File(EFI\debian\grubaa64.efi) Boot0001* virtio 0 VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b,0000000000000000)/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b,850000001f000000)/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b,1600850000000000){auto_created_boot_option} $~ efivar -p -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-BootNext GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c Name: "BootNext" Attributes: Non-Volatile Boot Service Access Runtime Service Access Value: 00000000 01 00 FWTS runtime results Skipped tests are for SetVariable which is now supported 'Passed' test is for QueryVariableInfo which is not yet supported Test: UEFI miscellaneous runtime service interface tests. Test for UEFI miscellaneous runtime service interfaces 6 skipped Stress test for UEFI miscellaneous runtime service i.. 1 skipped Test GetNextHighMonotonicCount with invalid NULL par.. 1 skipped Test UEFI miscellaneous runtime services unsupported.. 1 passed Test: UEFI Runtime service variable interface tests. Test UEFI RT service get variable interface. 1 passed Test UEFI RT service get next variable name interface. 4 passed Test UEFI RT service set variable interface. 8 passed Test UEFI RT service query variable info interface. 1 skipped Test UEFI RT service variable interface stress test. 2 passed Test UEFI RT service set variable interface stress t.. 4 passed Test UEFI RT service query variable info interface s.. 1 skipped Test UEFI RT service get variable interface, invalid.. 5 passed Test UEFI RT variable services unsupported status. 1 passed, 3 skipped [0] https://arm-software.github.io/ebbr/index.html#document-chapter5-variable-storage Reviewed-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2024-04-08efi_loader: fix append write behavior to non-existent variableMasahisa Kojima
Current "variables" efi_selftest result is inconsistent between the U-Boot file storage and the tee-based StandaloneMM RPMB secure storage. U-Boot file storage implementation does not accept SetVariale call to non-existent variable with EFI_VARIABLE_APPEND_WRITE, it return EFI_NOT_FOUND. However it is accepted and new variable is created in EDK II StandaloneMM implementation if valid data and size are specified. If data size is 0, EFI_SUCCESS is returned. Since UEFI specification does not clearly describe the behavior of the append write to non-existent variable, let's update the U-Boot file storage implementation to get aligned with the EDK II reference implementation. Signed-off-by: Masahisa Kojima <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Tested-by: Ilias Apalodimas <[email protected]>
2024-03-21efi_selftest: Update StrToFat() unit test after CP473 map extensionJanne Grunau
Test that Unicode code points which map to CP437 code points 1-31 are converted to '_'. This ensures no FAT file names do not contain chars which are control characters in other code pages (CP 1250 for example). Signed-off-by: Janne Grunau <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-03-21efi_selftest: Add geometric shapes character selftestJanne Grunau
Draw symbols from Unicode's "Geometric shapes" page which translate to code page 437 code points 1-31. These are used by UEFI applications to draw user interfaces using EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. The output has to be checked manually on the screen for correctness. Signed-off-by: Janne Grunau <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-03-21efi_selftest: Add box drawing character selftestAndre Przywara
UEFI applications rely on Unicode output capability, and might use that for drawing pseudo-graphical interfaces using Unicode defined box drawing characters. Add a simple test to display the most basic box characters, which would need to be checked manually on the screen for correctness. Signed-off-by: Andre Przywara <[email protected]> Suggested-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Janne Grunau <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-03-21efi_selftest: Add international characters testAndre Przywara
UEFI relies entirely on unicode output, which actual fonts displayed on the screen might not be ready for. Add a test displaying some international characters, to reveal missing glyphs, especially in our builtin fonts. This would be needed to be manually checked on the screen for correctness. Signed-off-by: Andre Przywara <[email protected]> Suggested-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Janne Grunau <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2024-01-29efi_selftest: add missing line feed in efi_selftest_miniapp_exitHeinrich Schuchardt
If an error occurs we may see an output like: EFI application calling Exit Could not open loaded image protocolLoaded image protocol missing Add the missing line feed. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2024-01-26efi_loader: migrate SMBIOS 3.0 entry point structure for measurementMasahisa Kojima
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 <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2023-12-21lib: Remove <common.h> inclusion from these filesTom Rini
After some header file cleanups to add missing include files, remove common.h from all files in the lib directory. This primarily means just dropping the line but in a few cases we need to add in other header files now. Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2023-10-12efi_selftest: BitBlt testHeinrich Schuchardt
The BitBlt test leaves the serial console output in disarray. * Call ClearScreen() where needed. * Test CheckEvent() for EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey via adding navigation keys * Correct timer comment For testing on the sandbox: CONFIG_CMD_BOOTEFI_SELFTEST=y CONFIG_CONSOLE_TRUETYPE=n $ ./u-boot -T -l => setenv efi_selftest block image transfer => bootefi selftest Signed-off-by: Heinrich Schuchardt <[email protected]> Acked-by: Ilias Apalodimas <[email protected]>
2023-08-03efi_selftest: remove superfluous assignmentsHeinrich Schuchardt
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 <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2023-07-15efi_selftests: add extra testcases on controller handlingIlias Apalodimas
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 <[email protected]>
2023-06-16efi_selftests: fix protocol repeated selftestingIlias Apalodimas
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 <[email protected]>
2023-06-16efi_selftests: fix controllers repeated selftestingIlias Apalodimas
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 <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2023-06-16efi_selftest: ReinstallProtocolInterface testHeinrich Schuchardt
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 <[email protected]>
2023-06-02efi_selftest: LocateHandleBuffer return codeHeinrich Schuchardt
Check that LocateHandleBuffer() return EFI_NOT_FOUND when called with ByRegisterNotify and all handles already have been retrieved. Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>