aboutsummaryrefslogtreecommitdiff
path: root/lib/efi_selftest
AgeCommit message (Collapse)AuthorFilesLines
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>
2021-01-29efi_selftest: test EFI_BLOCK_IO_PROTOCOL.Media->LastBlockHeinrich Schuchardt1-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>
2021-01-20efi_selftest: use CRLF as line endings in dtbdumpHeinrich Schuchardt1-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>
2021-01-20efi_selftest: provide initrddump test toolHeinrich Schuchardt3-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>
2021-01-20efi_selftest: don't compile dtbdump if GENERATE_ACPI_TABLEHeinrich Schuchardt1-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>
2021-01-20efi_selftest: ask before overwriting in dtbdump.efiHeinrich Schuchardt1-1/+59
Before overwriting an existing file ask the user. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-13efi_selftest: dtbdump support EFI_DT_FIXUP_PROTOCOLHeinrich Schuchardt1-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>
2020-12-13efi_selftest: implement exception test for sandboxHeinrich Schuchardt1-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>
2020-12-10efi_selftest: test EFI_LOAD_FILE_PROTOCOLHeinrich Schuchardt2-0/+478
A unit test is supplied to test the support for the EFI_LOAD_FILE_PROTOCOL and the EFI_LOAD_FILE2_PROTOCOL by the LoadImage() boot service. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-10efi_selftest: clean up MakefileHeinrich Schuchardt1-8/+6
Bring all obj-y entries together. Sort *.o targets. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-12-10efi_loader: move EFI_LOAD_FILE2_PROTOCOL_GUIDHeinrich Schuchardt1-3/+4
The EFI_LOAD_FILE_PROTOCOL_GUID and EFI_LOAD_FILE2_PROTOCOL_GUID are needed to complement the implementation of the LoadFile() boot service. Remove a duplicate declaration of a variable for the EFI_LOAD_FILE2_PROTOCOL_GUID. Move the remaining declaration to efi_boottime.c. Add a variable for the EFI_LOAD_FILE_PROTOCOL_GUID. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-11-14efi_selftest: provide unit test for the EFI_TCG2_PROTOCOLHeinrich Schuchardt2-0/+76
Provide a minimal test for the EFI_TCG2_PROTOCOL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-11-14efi_selftest: keep devices in ExitBootServices()Heinrich Schuchardt1-0/+3
When calling ExitBootServices during out unit tests we should not detach devices as we need console output for runtime tests. Fixes: 529441ca89b1 ("efi_loader: Disable devices before handing over control") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-11-09efi_selftest: add tool to download dtbHeinrich Schuchardt2-0/+220
For validating the fixed up device tree we need a tool to need to save it to a file. dtbdump.efi copies the configuration table with the device tree to a file on the same partition from which dtbdump.efi was invoked. The file name can be entered on the console. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-10-06efi: Fix typo in documentationSean Anderson1-1/+1
There is an extra space. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-10-06efi_selftest: avoid unnecessary resetHeinrich Schuchardt1-0/+31
When we do not execute a test requiring ExitBootServices do not reset the system after testing. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-10-06efi_selftest: print CRC32 of initrd as hexadecimalHeinrich Schuchardt1-1/+1
Print the CRC32 loaded via the EFI_LOAD_FILE2_PROTOCOL as a hexadecimal number. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2020-10-06efi_selftest: enable printing hexadecimal numbersHeinrich Schuchardt1-13/+22
Add code to use %x in efi_st_print(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-18efi_selftest: check for RISC-V boot-hartid in FDTHeinrich Schuchardt1-0/+15
On RISC-V check that the /chosen node has a boot-hartid property. To run the test configure with CONFIG_CMD_BOOTEFI_SELFTEST=y and issue setenv efi_selftest device tree setenv serial# myserial bootefi selftest If the test succeeds, it reports the boot-hartid, e.g. boot-hartid: 1 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-18efi_selftest: rework device tree testHeinrich Schuchardt1-14/+39
Allow specifying the node on which a property is searched. Test the device tree consistency more rigorously. Some efi_st_printf() calls have been converted to efi_st_error(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-14efi_selftest: restore gd before do_reset()Heinrich Schuchardt1-2/+4
Before calling do_reset() in the EFI selftest we must restore the global data pointer. Fixes: fa63753f86cc ("efi_selftest: substitute ResetSystem() by do_reset()") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-09-06efi_selftest: simplify MakefileHeinrich Schuchardt1-6/+0
CONFIG_EFI_LOADER cannot be selected for ARMv7-M CPUs. So don't check it in the Makefile. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-24efi_selftest: substitute ResetSystem() by do_reset()Heinrich Schuchardt1-2/+8
If ResetSystem() is not implemented at runtime, call do_reset() after test completion. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-24efi_selftest: add a test for ResetSystem()Heinrich Schuchardt2-0/+59
The unit test will reset the system by calling the ResetSystem() runtime service before or after ExitBootServices() according to the users choice by setting environment variable efi_selftest to: * 'reset system' or * 'reset system runtime'. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-01efi_selftest: block device test requires CONFIG_DOS_PARTITIONHeinrich Schuchardt2-1/+3
Do not execute the block device test if CONFIG_DOS_PARTITION=n. Imply CONFIG_DOS_PARTITION in Kconfig. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-08-01efi_selftest: SNP test depends on networkHeinrich Schuchardt1-1/+2
If CONFIG_NET=n, testing the simple network protocol makes no sense. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-07-11efi_selftest: adjust runtime test for variablesHeinrich Schuchardt1-7/+6
As variable services are available at runtime we have to expect EFI_SUCCESS when calling the services. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-05-18common: Drop net.h from common headerSimon Glass3-0/+3
Move this header out of the common header. Network support is used in quite a few places but it still does not warrant blanket inclusion. Note that this net.h header itself has quite a lot in it. It could be split into the driver-mode support, functions, structures, checksumming, etc. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-07efi_loader: put device tree into EfiACPIReclaimMemoryHeinrich Schuchardt1-2/+2
According to the UEFI spec ACPI tables should be placed in EfiACPIReclaimMemory. Let's do the same with the device tree. Suggested-by: Ard Biesheuvel <ardb@kernel.org> Cc: Grant Likely <grant.likely@arm.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>