summaryrefslogtreecommitdiff
path: root/lib/efi_selftest
AgeCommit message (Collapse)AuthorFilesLines
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-15efi_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-12efi_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-19common: 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>
2020-03-22efi_selftest: test CalculateCrc32, CopyMem, SetMemHeinrich Schuchardt2-0/+78
Provide unit tests for CalculateCrc32(), CopyMem(), SetMem(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-03-22efi_selftest: check length reported by GetNextVariableName()Heinrich Schuchardt1-2/+8
GetNextVariableName should report the length of the variable including the final 0x0000 in bytes. Check this in the unit test. Increase the buffer size for variable names. 40 bytes is too short. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-28efi_selftest: add selftests for loadfile2 used to load initramfsIlias Apalodimas2-0/+221
Provide a unit test loading an initial ramdisk using the EFI_LOAD_FILE2_PROTOCOL. The test is only executed on request. An example usage - given a file image with a file system in partition 1 holding file initrd - is: * Configure the sandbox with CONFIG_EFI_SELFTEST=y CONFIG_EFI_LOAD_FILE2_INITRD=y CONFIG_EFI_INITRD_FILESPEC="host 0:1 initrd" * Run ./u-boot and execute host bind 0 image setenv efi_selftest load initrd bootefi selftest This would provide a test output like: Testing EFI API implementation Selected test: 'load initrd' Setting up 'load initrd' Setting up 'load initrd' succeeded Executing 'load initrd' Loaded 12378613 bytes CRC32 2997478465 Executing 'load initrd' succeeded Now the size and CRC32 can be compared to the provided file. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-15efi_driver: fix efi_uc_stop()Heinrich Schuchardt1-2/+2
Use the correct protocol in efi_uc_stop() when detaching the driver from the controller. Change the block IO unit test for the block device driver to throw an error instead of a todo if teardown fails. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-15efi_selftest: enable CONFIG_CMD_POWEROFFHeinrich Schuchardt1-0/+1
For automating testing we should be able to power off the test system. The implementation of EFI_RESET_SHUTDOWN requires the do_poweroff() function which is only available if CONFIG_CMD_POWEROFF=y. Enable CONFIG_CMD_POWEROFF if PSCI reset is available. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_selftest: unit test for EFI_RNG_PROTOCOLHeinrich Schuchardt2-0/+118
Provide a unit test for the EFI_RNG_PROTOCOL. The list of algorithms is read. Two random numbers are generated. The test checks that the two numbers differ. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-01-07efi_selftest: Update .gitignoreSughosh Ganu1-2/+1
Add the following file to .gitignore efi_miniapp_file_image_exception.h Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Use efi_miniapp_*.h instead of file enumeration. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-12-03crc32: Use the crc.h header for crc functionsSimon Glass2-0/+2
Drop inclusion of crc.h in common.h and use the correct header directly instead. With this we can drop the conflicting definition in fw_env.h and rely on the crc.h header, which is already included. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-11-13efi_selftest: enable all UEFI unit tests on the sandboxHeinrich Schuchardt1-2/+5
As we can build relocation code for the sandbox now we should enable the unit tests that had to be disabled up to now. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-06efi_selftest: testing read-only variablesHeinrich Schuchardt1-11/+0
The UEFI spec has this sentence: "Variables that have runtime access but that are not nonvolatile are read-only data variables once ExitBootServices() is performed." At least EDK2 therefore treats variable PlatformLangCodes only as read-only at runtime. Nowhere do we make this variable read-only in U-Boot. Do not use variable PlatformLangCodes for testing if the read only attribute of variables is observed before ExitBootServices(). Fixes: 5a24239c951e ("efi_loader: selftest: enable APPEND_WRITE tests") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-10-06efi_selftest: correct SetVariable() testHeinrich Schuchardt1-14/+16
Errors should not only be announced as text but should also result in EFI_ST_FAILURE being returned. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-20efi_loader: selftest: enable APPEND_WRITE testsAKASHI Takahiro1-1/+19
Now that APPEND_WRITE is supported, the result check for the only existing test case should be changed to 'todo' to 'error', while two more test cases are added. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_loader: fix status management in network stackHeinrich Schuchardt1-6/+42
The network should start in status EfiSimpleNetworkStopped. Add and correct status checks in the simple network protocol. Correct the unit test: * Shutdown() and Stop() during setup if needed * invoke Shutdown() before Stop() when tearing down Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-09-06efi_selftest: check EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPTHeinrich Schuchardt1-2/+14
Check that when the WaitForPacket event occurs EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT is set. Check the return value of Receive(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-29efi_selftest: use standalone UEFI program for exceptionHeinrich Schuchardt3-23/+169
To fully demonstrate crash outputs for UEFI images provide a standalone UEFI application that tries to invoke an illegal opcode. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-08-29efi_selftest: enable Exit() unit test on x86_64Heinrich Schuchardt1-3/+3
Enable unit tests for StartImage() and Exit() unit tests on x86_64. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-30efi_selftest: sharpen ConvertPointer() testHeinrich Schuchardt1-8/+22
Now that ConvertPointer() is implemented throw an error if the result is incorrect. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-30efi_selftest: fix SetVirtualAddressMap unit testHeinrich Schuchardt1-0/+1
We read the address map before assigning the memory for the pages that will be mapped to virtual addresses. So these pages will overlap with the entry for EFI_CONVENTIONAL_MEMORY. We have to ensure that every page is described at most once in the map. Remove EFI_CONVENTIONAL_MEMORY from the map that we pass to SetVirtualAddressMap(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-17efi_selftest: EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGEHeinrich Schuchardt2-0/+193
Provide a unit test for SetVirtualAddressMap() and ConvertPointer(). As ConvertPointer() is not implemented yet this will spit out some warnings. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-17efi_selftest: do not call CloseEvent() after ExitBootServices()Heinrich Schuchardt1-23/+0
Boot services are not available after calling ExitBootServices(). So we should not try to close an event here. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
2019-07-06efi_selftest: test variable services at runtimeHeinrich Schuchardt2-0/+95
Provide a unit test for the variable services at runtime. Currently we expect EFI_UNSUPPORTED to be returned as the runtime implementation is still missing. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-06efi_selftest: description of CMD_BOOTEFI_SELFTESTHeinrich Schuchardt1-4/+4
The current short description has a typo. Let it stand out clear that we provide unit tests. Improve the description of the CMD_BOOTEFI_SELFTEST configuration option. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Alexander Graf <agraf@csgraf.de>