u-boot/lib/efi_selftest
Ilias Apalodimas c28d32f946 efi_loader: conditionally enable SetvariableRT
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 <heinrich.schuchardt@canonical.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-04-20 08:22:24 +02:00
..
.gitignore efi_selftest: Update .gitignore 2020-01-07 18:08:20 +01:00
efi_freestanding.c
efi_miniapp_tcg2_arm.h efi_selftest: add selftest for EFI_TCG2_PROTOCOL and Measured Boot 2021-11-07 18:36:55 +01:00
efi_miniapp_tcg2_arm64.h efi_selftest: add selftest for EFI_TCG2_PROTOCOL and Measured Boot 2021-11-07 18:36:55 +01:00
efi_miniapp_tcg2_ia32.h efi_selftest: add selftest for EFI_TCG2_PROTOCOL and Measured Boot 2021-11-07 18:36:55 +01:00
efi_miniapp_tcg2_riscv32.h efi_selftest: add selftest for EFI_TCG2_PROTOCOL and Measured Boot 2021-11-07 18:36:55 +01:00
efi_miniapp_tcg2_riscv64.h efi_selftest: add selftest for EFI_TCG2_PROTOCOL and Measured Boot 2021-11-07 18:36:55 +01:00
efi_miniapp_tcg2_x86_64.h efi_selftest: add selftest for EFI_TCG2_PROTOCOL and Measured Boot 2021-11-07 18:36:55 +01:00
efi_selftest.c efi_selftest: export efi_st_get_config_table() 2022-09-09 16:07:54 +02:00
efi_selftest_bitblt.c efi_selftest: BitBlt test 2023-10-12 08:32:27 +02:00
efi_selftest_block_device.c EFI: Fix ReadBlocks API reading incorrect sector for UCLASS_PARTITION devices 2022-07-02 14:19:12 +02:00
efi_selftest_config_table.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_console.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_controllers.c efi_selftests: add extra testcases on controller handling 2023-07-15 11:20:41 +02:00
efi_selftest_crc32.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_devicepath.c efi: Use 16-bit unicode strings 2022-02-03 12:16:01 -05:00
efi_selftest_devicepath_util.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_disk_image.h
efi_selftest_ecpt.c efi: adjust ebbr to v2.1 in conformance profile 2022-12-17 13:37:33 +00:00
efi_selftest_esrt.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
efi_selftest_event_groups.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_events.c efi_selftest: rename event_notify 2022-10-06 22:54:58 +02:00
efi_selftest_exception.c efi: Use 16-bit unicode strings 2022-02-03 12:16:01 -05:00
efi_selftest_exitbootservices.c efi: selftest: Make record static 2023-04-08 07:46:44 +02:00
efi_selftest_fdt.c efi_selftest: export efi_st_get_config_table() 2022-09-09 16:07:54 +02:00
efi_selftest_gop.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_hii.c efi_selftest: remove superfluous assignments 2023-08-03 09:21:02 +02:00
efi_selftest_hii_data.c
efi_selftest_load_file.c efi: selftest: Make load_file() and load_file2() static 2023-04-08 07:46:44 +02:00
efi_selftest_loaded_image.c efi_selftest: remove redundant function efi_st_memcmp() 2019-05-07 21:10:04 +02:00
efi_selftest_loadimage.c efi_selftest: prefix test functions with efi_st_ 2022-09-30 02:03:23 +02:00
efi_selftest_manageprotocols.c efi_selftests: fix protocol repeated selftesting 2023-06-16 06:48:46 +02:00
efi_selftest_mem.c efi_selftest: test CalculateCrc32, CopyMem, SetMem 2020-03-22 11:06:23 +01:00
efi_selftest_memory.c efi_loader: put device tree into EfiACPIReclaimMemory 2020-05-07 18:23:16 +02:00
efi_selftest_miniapp_exception.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
efi_selftest_miniapp_exit.c efi_selftest: add missing line feed in efi_selftest_miniapp_exit 2024-01-29 11:29:19 +01:00
efi_selftest_miniapp_return.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
efi_selftest_open_protocol.c efi_selftest: unit test for OpenProtocolInformation() 2019-06-01 22:40:24 +02:00
efi_selftest_register_notify.c efi_selftest: ReinstallProtocolInterface test 2023-06-16 06:45:19 +02:00
efi_selftest_reset.c efi: Use 16-bit unicode strings 2022-02-03 12:16:01 -05:00
efi_selftest_rng.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_rtc.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_set_virtual_address_map.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_snp.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_startimage_exit.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_startimage_return.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_tcg2.c efi_loader: migrate SMBIOS 3.0 entry point structure for measurement 2024-01-26 14:16:17 +01:00
efi_selftest_textinput.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_textinputex.c efi_loader: correct function comment style 2022-01-29 10:23:40 +01:00
efi_selftest_textoutput.c efi_selftest: Add geometric shapes character selftest 2024-03-21 06:56:13 +01:00
efi_selftest_tpl.c efi_selftest: rename event_notify 2022-10-06 22:54:58 +02:00
efi_selftest_unaligned.c efi_selftest: clean up unaligned unit test 2022-05-03 21:39:22 +02:00
efi_selftest_unicode_collation.c efi_selftest: Update StrToFat() unit test after CP473 map extension 2024-03-21 06:56:14 +01:00
efi_selftest_util.c efi_selftest: unsigned char parameter for efi_st_strcmp_16_8() 2022-11-22 11:54:30 +01:00
efi_selftest_variables.c efi_loader: fix append write behavior to non-existent variable 2024-04-08 13:01:13 +02:00
efi_selftest_variables_runtime.c efi_loader: conditionally enable SetvariableRT 2024-04-20 08:22:24 +02:00
efi_selftest_watchdog.c efi_selftest: rename event_notify 2022-10-06 22:54:58 +02:00
Kconfig efi_selftest: block device test requires CONFIG_DOS_PARTITION 2020-08-01 11:58:39 +02:00
Makefile efi_loader: Let networking support depend on NETDEVICES 2022-11-06 10:50:04 +01:00