summaryrefslogtreecommitdiff
path: root/lib/efi_selftest
Commit message (Collapse)AuthorAgeFilesLines
* efi: selftest: Make load_file() and load_file2() staticBin Meng2023-04-081-10/+10
| | | | | | | load_file() and load_file2() are only referenced in efi_selftest_load_file.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
* efi: selftest: Make record staticBin Meng2023-04-081-1/+1
| | | | | | record is only referenced in efi_selftest_exitbootservices.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
* efi_selftest: add hii set keyboard layout test caseVincent Stehlé2023-01-131-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>
* efi_selftest: conformance test for GetNextVariableNameHeinrich Schuchardt2022-12-201-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>
* efi: adjust ebbr to v2.1 in conformance profileVincent Stehlé2022-12-171-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>
* efi_selftest: test FatToStr() truncationHeinrich Schuchardt2022-12-021-1/+1
| | | | | | Let the FatToStr test check that the FatSize parameter is considered. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_selftest: Improve the FatToStr() unit testHeinrich Schuchardt2022-11-221-0/+12
| | | | | | Add a test with a character >= 0x80. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_selftest: unsigned char parameter for efi_st_strcmp_16_8()Heinrich Schuchardt2022-11-221-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>
* efi_loader: Let networking support depend on NETDEVICESJan Kiszka2022-11-061-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>
* efi_selftest: rename event_notifyHeinrich Schuchardt2022-10-064-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>
* efi_selftest: prefix test functions with efi_st_Heinrich Schuchardt2022-09-301-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>
* efi_selftest: unit test for EFI Conformance Profile TableHeinrich Schuchardt2022-09-092-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>
* efi_selftest: export efi_st_get_config_table()Heinrich Schuchardt2022-09-093-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>
* efi_selftest: on sandbox use host specific assemblyHeinrich Schuchardt2022-09-031-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>
* EFI: Fix ReadBlocks API reading incorrect sector for UCLASS_PARTITION devicesPaul Barbieri2022-07-021-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>
* efi_selftest: error handling in efi_selftest_tcg2Heinrich Schuchardt2022-05-031-2/+6
| | | | | | If memory allocation fails, write an error message. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_selftest: clean up unaligned unit testHeinrich Schuchardt2022-05-031-5/+4
| | | | | | | * fix typo %s/give/given/ * don't use void * in pointer arithmetic Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_selftest: buildefi_selftest_unaligned.cHeinrich Schuchardt2022-05-031-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>
* efi_loader: move dtbdump.c, initrddump.c to lib/efi_loaderHeinrich Schuchardt2022-03-203-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>
* efi_selftest: merge FDT and RISC-V testsHeinrich Schuchardt2022-02-053-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>
* efi_selftest: unit test for RISCV_EFI_BOOT_PROTOCOLSunil V L2022-02-052-0/+120
| | | | | | Add a test for the RISCV_EFI_BOOT_PROTOCOL. Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
* efi: Use 16-bit unicode stringsSimon Glass2022-02-0319-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>
* efi_loader: correct function comment styleHeinrich Schuchardt2022-01-2934-79/+79
| | | | | | Replace @return and @param. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* Merge tag 'efi-2022-04-rc1-2' of ↵Tom Rini2022-01-222-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
| * efi_selftest: implement printing GUIDsHeinrich Schuchardt2022-01-192-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>
* | doc: replace @return by Return:Heinrich Schuchardt2022-01-1913-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>
* efi_selftest: simplify endian conversion for FDT testHeinrich Schuchardt2021-11-261-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>
* efi_selftest: unit test for EFI_GROUP_BEFORE_EXIT_BOOT_SERVICEHeinrich Schuchardt2021-11-201-11/+56
| | | | | | Add a test for the EFI_GROUP_BEFORE_EXIT_BOOT_SERVICE event group. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_selftest: add selftest for EFI_TCG2_PROTOCOL and Measured BootMasahisa Kojima2021-11-077-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>
* efi_selftest: Receive the packets until the receive buffer is emptyMasami Hiramatsu2021-10-211-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>
* efi_selftest: Do not check EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPTMasami Hiramatsu2021-10-211-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>
* efi_selftest: Use EFI_SIMPLE_NETWORK_PROTOCOL::GetStatus() for media checkMasami Hiramatsu2021-10-211-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>
* efi_loader: TPL_HIGH_LEVEL not allowed for CreateEventHeinrich Schuchardt2021-06-281-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>
* efi_selftest: compiler flags for efi_selftest_miniapp_exception.oMarek Behún2021-05-241-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>
* efi_selfest: redefine enum efi_test_phaseHeinrich Schuchardt2021-03-252-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>
* efi: ESRT creation testsJose Marinho2021-03-252-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>
* efi_selftest: Remove loadfile2 for initrd selftestsIlias Apalodimas2021-03-252-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>
* efi_selftest: illegal cast to pointer in initrddumpHeinrich Schuchardt2021-03-251-1/+1
| | | | | | On 32bit systems u64 cannot directly be cast to void *. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_selftest: multi part device path to textHeinrich Schuchardt2021-02-211-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>
* efi_selftest: compiler flags for dtbdump.oHeinrich Schuchardt2021-02-211-1/+1
| | | | | | Fix a typo. Apply the correct compiler flags to dtbdump.o. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* Merge branch '2021-02-02-drop-asm_global_data-when-unused'Tom Rini2021-02-151-0/+1
|\ | | | | | | - Merge the patch to take <asm/global_data.h> out of <common.h>
| * common: Drop asm/global_data.h from common headerWIP/2021-02-02-drop-asm_global_data-when-unusedSimon Glass2021-02-021-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>
* | efi_selftest: use GUID to find ESP in dtbdumpHeinrich Schuchardt2021-02-041-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>
* efi_selftest: test EFI_BLOCK_IO_PROTOCOL.Media->LastBlockHeinrich Schuchardt2021-01-291-1/+20
| | | | | | | | | | | | The field Media->LastBlock of the EFI_BLOCK_IO_PROTOCOL must be filled with the index of the last logical block (LBA) for the block device that our test driver provides. After calling ConnectController() U-Boot exposes the block IO protocol for the partition check that the value of Media->LastBlock equals the partition size minus one. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_selftest: use CRLF as line endings in dtbdumpHeinrich Schuchardt2021-01-201-42/+52
| | | | | | | | EFI applications must use CR LF as line endings. Provide a print() function to reduce code size. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_selftest: provide initrddump test toolHeinrich Schuchardt2021-01-203-2/+456
| | | | | | | | Provide an UEFI application to save the initial RAM disk provided by U-Boot via the Load File2 protocol. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi_selftest: don't compile dtbdump if GENERATE_ACPI_TABLEHeinrich Schuchardt2021-01-201-2/+3
| | | | | | | If we are using ACPI tables instead of a device tree, we don't need the dtbdump.efi test tool. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_selftest: ask before overwriting in dtbdump.efiHeinrich Schuchardt2021-01-201-1/+59
| | | | | | Before overwriting an existing file ask the user. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_selftest: dtbdump support EFI_DT_FIXUP_PROTOCOLHeinrich Schuchardt2021-01-131-37/+273
| | | | | | | | | | | | | | | | | | | | | | | | | | | The dtbdump.efi binary can already be used to dump the configuration table with the device-tree to a file. With this patch a device-tree file can be loaded. The EFI_DT_FIXUP_PROTOCOL is called to * apply U-Boot's fix-ups * let U-Boot make memory reservations as required by the device-tree * install the new device-tree as configuration table In a next step this configuration table can be dumped. A dtbdump.efi session would look like: DTB Dump ======== => load test.dtb device-tree installed => save fixed-up.dtb fixed-up.dtb written => exit Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* efi_selftest: implement exception test for sandboxHeinrich Schuchardt2020-12-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Provide a unit test that causes an illegal instruction to occur. The test can be run with the following commands: => setenv efi_selftest exception => bootefi selftest This might be the output: Executing 'exception' EFI application triggers exception. Illegal instruction pc = 0x1444d016, pc_reloc = 0xffffaa078e8dd016 UEFI image [0x0000000000000000:0xffffffffffffffff] '/\selftest' UEFI image [0x000000001444b000:0x0000000014451fff] pc=0x2016 '/bug.efi' Resetting ... It would tell us that the exception was triggered by an instruction 0x2016 bytes after the load address of the binary with filename /bug.efi. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>