aboutsummaryrefslogtreecommitdiff
path: root/lib/efi_selftest
AgeCommit message (Collapse)AuthorFilesLines
2023-10-12efi_selftest: BitBlt testHeinrich Schuchardt1-20/+63
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 <heinrich.schuchardt@canonical.com> Acked-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-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-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_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-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-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-01-13efi_selftest: add hii set keyboard layout test caseVincent Stehlé1-0/+12
Add a test for the case when the HII database protocol set_keyboard_layout() function is called with a NULL key_guid argument. Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-12-20efi_selftest: conformance test for GetNextVariableNameHeinrich Schuchardt1-0/+35
Test that GetNextVariableName() checks the parameters. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-12-17efi: adjust ebbr to v2.1 in conformance profileVincent Stehlé1-3/+3
The EFI Conformance Profile Table entry for EBBR appears in v2.1.0 of the EBBR specification[1]. Update naming accordingly. While at it, update the EBBR version referenced in the documentation. [1]: https://github.com/ARM-software/ebbr/releases/tag/v2.1.0 Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-12-02efi_selftest: test FatToStr() truncationHeinrich Schuchardt1-1/+1
Let the FatToStr test check that the FatSize parameter is considered. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-11-22efi_selftest: Improve the FatToStr() unit testHeinrich Schuchardt1-0/+12
Add a test with a character >= 0x80. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-11-22efi_selftest: unsigned char parameter for efi_st_strcmp_16_8()Heinrich Schuchardt1-1/+1
Use unsigned char for the parameter of efi_st_strcmp_16_8. This allows comparing characters 0x80 - 0xff. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-11-06efi_loader: Let networking support depend on NETDEVICESJan Kiszka1-1/+1
CONFIG_NET does not imply that there are actually network devices available, only CONFIG_NETDEVICES does. Changing to this dependency obsoletes the check in Kconfig because NETDEVICES means DM_ETH. Fixes: 0efe1bcf5c2c ("efi_loader: Add network access support") Suggested-by: Tom Rini <trini@konsulko.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-10-06efi_selftest: rename event_notifyHeinrich Schuchardt4-46/+55
A function event_notify() exists. We should not use the same name for and EFI event. Rename events in unit tests. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-09-30efi_selftest: prefix test functions with efi_st_Heinrich Schuchardt1-43/+44
An upcoming patch set creates a global function flush(). To make debugging easier we should not use the same name for a static function. Rename static functions in the LoadImage() unit test adding an efi_st_ prefix. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-09-09efi_selftest: unit test for EFI Conformance Profile TableHeinrich Schuchardt2-0/+77
Add a new unit test to test the integrity of the EFI Conformance Profile Table. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-09-09efi_selftest: export efi_st_get_config_table()Heinrich Schuchardt3-36/+30
We can use efi_st_get_config_table() in multiple unit tests. Export the function. Export system-table and boot-services. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-09-03efi_selftest: on sandbox use host specific assemblyHeinrich Schuchardt1-1/+8
The selftest checking the handling of exceptions in UEFI binaries is using assembly to provide an undefined instruction. On the sandbox the correct form of the instruction depends on the host architecture. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-07-02EFI: Fix ReadBlocks API reading incorrect sector for UCLASS_PARTITION devicesPaul Barbieri1-0/+27
The requsted partition disk sector incorrectly has the parition start sector added in twice for UCLASS_PARTITION devices. The efi_disk_rw_blocks() routine adds the diskobj->offset to the requested lba. When the device is a UCLASS_PARTITION, the dev_read() or dev_write() routine is called which adds part-gpt_part_info.start. This causes I/O to the wrong sector. Takahiro Akashi suggested removing the offset field from the efi_disk_obj structure since disk-uclass.c handles the partition start biasing. Device types other than UCLASS_PARTITION set the diskobj->offset field to zero which makes the field unnecessary. This change removes the offset field from the structure and removes all references from the code which is isolated to the lib/efi_loader/efi_disk.c module. This change also adds a test for the EFI ReadBlocks() API in the EFI selftest code. There is already a test for reading a FAT file. The new test uses ReadBlocks() to read the same "disk" block and compare it to the data read from the file system API. Signed-Off-by: Paul Barbieri <plb365@gmail.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-05-03efi_selftest: error handling in efi_selftest_tcg2Heinrich Schuchardt1-2/+6
If memory allocation fails, write an error message. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-05-03efi_selftest: clean up unaligned unit testHeinrich Schuchardt1-5/+4
* fix typo %s/give/given/ * don't use void * in pointer arithmetic Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-05-03efi_selftest: buildefi_selftest_unaligned.cHeinrich Schuchardt1-1/+3
The unit test has not been built since CPU_V7 was rename CPU_V7A. Fixes: acf1500138bb ("arm: v7: Kconfig: Rename CPU_V7 as CPU_V7A") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-03-20efi_loader: move dtbdump.c, initrddump.c to lib/efi_loaderHeinrich Schuchardt3-1000/+0
The tools dtbdump.efi and initrddump.efi are useful for Python testing even if CONFIG_EFI_SELFTEST=n. Don't clear the screen as it is incompatible with Python testing. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-02-05efi_selftest: merge FDT and RISC-V testsHeinrich Schuchardt3-135/+57
The test for the RISCV_EFI_BOOT_PROTOCOL retrieves the boot hart id via the protocol and compares it to the value of the boot hart id in the device tree. The boot hart id is already retrieved from the device tree in the FDT test. Merge the two tests to avoid code duplication. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-02-05efi_selftest: unit test for RISCV_EFI_BOOT_PROTOCOLSunil V L2-0/+120
Add a test for the RISCV_EFI_BOOT_PROTOCOL. Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
2022-02-03efi: Use 16-bit unicode stringsSimon Glass19-187/+187
At present we use wide characters for unicode but this is not necessary. Change the code to use the 'u' literal instead. This helps to fix build warnings for sandbox on rpi. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-01-29efi_loader: correct function comment styleHeinrich Schuchardt34-79/+79
Replace @return and @param. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-01-22Merge tag 'efi-2022-04-rc1-2' of ↵WIP/22Jan2022Tom Rini2-4/+29
https://source.denx.de/u-boot/custodians/u-boot-efi Pull request for efi-2022-04-rc1-2 Documentation: * describe printf() format codes UEFI * enable more algorithms for UEFI image verification, e.g. SHA256-RSA2048 General * simplify printing short texts for GUIDs * provide a unit test for printing GUIDs
2022-01-19doc: replace @return by Return:Heinrich Schuchardt13-32/+32
Sphinx expects Return: and not @return to indicate a return value. find . -name '*.c' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; find . -name '*.h' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-01-19efi_selftest: implement printing GUIDsHeinrich Schuchardt2-4/+29
The ESRT test may try to print a GUID if an error occurs. Implement the %pU print code. Correct the ESRT test to use %pU instead of %pUl to avoid the output of character 'l'. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-11-26efi_selftest: simplify endian conversion for FDT testHeinrich Schuchardt1-7/+8
UEFI code is always little-endian. Remove a superfluous test. Remove a superfluous type conversion. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-11-20efi_selftest: unit test for EFI_GROUP_BEFORE_EXIT_BOOT_SERVICEHeinrich Schuchardt1-11/+56
Add a test for the EFI_GROUP_BEFORE_EXIT_BOOT_SERVICE event group. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-11-07efi_selftest: add selftest for EFI_TCG2_PROTOCOL and Measured BootMasahisa Kojima7-1/+2023
This commit adds the missing EFI_TCG2_PROTOCOL selftest and Measured Boot selftest in lib/efi_selftest. This selftest includes PE/COFF image measurement test, some PCR values are different in each architecture. With that, this commit also adds pre-built versions of lib/efi_selftest/efi_miniapp_file_image_exit.c for PE/COFF image measurement test for 32-bit arm, arm64, ia32, x86_64, riscv32 and riscv64. Prebuilding avoids the problem of reproducible builds. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Make the test 'onrequest'. Add code comments to the includes with the binaries. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-10-21efi_selftest: Receive the packets until the receive buffer is emptyMasami Hiramatsu1-30/+37
Repeatedly receive the packets until the receive buffer is empty. If the buffer is empty, EFI_SIMPLE_NETWORK_PROTOCOL::Receive() returns EFI_NOT_READY. We don't need to use the wait_for_event() every time. Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-10-21efi_selftest: Do not check EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPTMasami Hiramatsu1-11/+0
Do not check EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT in packet receiving loop. This depends on the implementation and not related to whether the packet can be received or not. Whether the received packets are available or not is ensured by wait_for_packet, and that is already done in the loop. Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-10-21efi_selftest: Use EFI_SIMPLE_NETWORK_PROTOCOL::GetStatus() for media checkMasami Hiramatsu1-0/+12
According to the UEF specification v2.9, the main purpose of the EFI_SIMPLE_NETWORK_PROTOCOL::GetStatus() is for checking the link status via EFI_SIMPLE_NETWORK_MODE::MediaPresent. So this uses net->get_status() for checking the link status before running network test. Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-28efi_loader: TPL_HIGH_LEVEL not allowed for CreateEventHeinrich Schuchardt1-1/+1
According to chapter 7.1 "Event, Timer, and Task Priority Services" TPL_HIGH_LEVEL should not be exposed to applications and drivers. According to the discussion with EDK II contributors this implies that CreateEvent() shall not allow to create events with TPL_HIGH_LEVEL. Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
2021-05-24efi_selftest: compiler flags for efi_selftest_miniapp_exception.oMarek Behún1-0/+2
Add $(CFLAGS_EFI) and remove $(CFLAGS_NON_EFI) for efi_selftest_miniapp_exception.o. The removal is needed when compiling with LTO - this object file needs to be compiled without -flto. The adding is for consistency with other miniapps. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-25efi_selfest: redefine enum efi_test_phaseHeinrich Schuchardt2-6/+7
Setup will always occur before ExitBootServices(). So eliminate EFI_SETUP_AFTER_BOOTTIME_EXIT. Put the SetVirtualAddressMap() test into a separate class so that we can execute it last. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-25efi: ESRT creation testsJose Marinho2-0/+293
This commmit exercises the ESRT creation in a EFI selftest. A fake FMP, with TEST_ESRT_NUM_ENTRIES FW images, is installed in the system leading to the corresponding ESRT entries being populated. The ESRT entries are checked against the datastructure used to initialize the FMP. Invocation from the sandbox platform: add to sandbox_defconfig: +CONFIG_CMD_BOOTEFI_SELFTEST=y make sandbox_capsule_defconfig all ./u-boot -d arch/sandbox/dts/test.dtb bootefi selftest CC: Heinrich Schuchardt <xypron.glpk@gmx.de> CC: Sughosh Ganu <sughosh.ganu@linaro.org> CC: AKASHI Takahiro <takahiro.akashi@linaro.org> CC: Ilias Apalodimas <ilias.apalodimas@linaro.org> CC: Andre Przywara <andre.przywara@arm.com> CC: Alexander Graf <agraf@csgraf.de> CC: nd@arm.com Signed-off-by: Jose Marinho <jose.marinho@arm.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-25efi_selftest: Remove loadfile2 for initrd selftestsIlias Apalodimas2-222/+0
We are redefining how u-boot locates the initrd to load via the kernel LoadFile2 protocol. This selftest is not relevant any more, so remove it. A new one will be added later Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-25efi_selftest: illegal cast to pointer in initrddumpHeinrich Schuchardt1-1/+1
On 32bit systems u64 cannot directly be cast to void *. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-02-21efi_selftest: multi part device path to textHeinrich Schuchardt1-0/+65
Test EFI_DEVICE_PATH_TO_TEXT_PROTOCOL.ConvertDevicePathToText() for a multi part device path. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-02-21efi_selftest: compiler flags for dtbdump.oHeinrich Schuchardt1-1/+1
Fix a typo. Apply the correct compiler flags to dtbdump.o. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-02-15Merge branch '2021-02-02-drop-asm_global_data-when-unused'Tom Rini1-0/+1
- Merge the patch to take <asm/global_data.h> out of <common.h>
2021-02-04efi_selftest: use GUID to find ESP in dtbdumpHeinrich Schuchardt1-33/+52
If dtbdump.efi is loaded from memory when calling LoadImage the loaded image protocol will not indicate the partition from where it was loaded. In this case use the EFI system partition for the 'load' and 'save' commands. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-02-02common: Drop asm/global_data.h from common headerSimon Glass1-0/+1
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>