u-boot/lib
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
..
acpi acpi: rename aslc_id, aslc_revision 2024-03-27 09:15:39 +01:00
aes lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
at91 lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
blake2 lib: add BLAKE2 hash support 2022-01-18 08:31:02 -05:00
bzip2 lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
crypt lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
crypto lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
dhry lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
ecdsa Check curve_name for null to avoid crash 2024-03-07 07:41:41 -05:00
efi efi: Avoid using dm_scan_other() 2024-01-13 18:17:46 +01:00
efi_driver efi_driver: provide SBI based runtime system reset 2024-02-28 14:38:47 +01:00
efi_loader efi_loader: conditionally enable SetvariableRT 2024-04-20 08:22:24 +02:00
efi_selftest efi_loader: conditionally enable SetvariableRT 2024-04-20 08:22:24 +02:00
fwu_updates fwu: fix fwu_get_image_index interface 2024-01-13 18:17:47 +01:00
libavb global: Drop common.h inclusion 2023-12-21 08:54:37 -05:00
libfdt
lzma lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
lzo lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
optee lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
rsa lib: add missing line breaks in debug messages 2024-04-10 09:34:53 -06:00
zlib zlib: Remove incorrect ZLIB_VERSION 2024-04-12 12:57:07 -06:00
zstd lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
.gitignore
abuf.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
addr_map.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
aes.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
asm-offsets.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
asn1_decoder.c common: Drop linux/printk.h from common header 2023-09-24 09:54:57 -04:00
bch.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
binman.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
bitrev.c
charset.c lib/charset: Map Unicode code points to CP437 code points 1-31 2024-03-21 06:56:13 +01:00
circbuf.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
crc7.c
crc8.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
crc16-ccitt.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
crc16.c crc16: Move standard CRC-16 implementation from ubifs to lib 2022-04-21 14:32:40 -04:00
crc32.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
crc32c.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
ctype.c
date.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
display_options.c display_options: Clean up headers 2023-12-21 08:54:37 -05:00
div64.c
elf.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
errno.c sandbox: errno: avoid conflict with libc's errno 2021-05-24 14:21:30 -04:00
errno_str.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
fdt-libcrypto.c lib/rsa: Make fdt_add_bignum() available outside of RSA code 2021-04-14 15:06:08 -04:00
fdtdec.c fdt: Allow the devicetree to come from a bloblist 2024-01-07 13:45:07 -07:00
fdtdec_common.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
fdtdec_test.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
getopt.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
gunzip.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
gzip.c zlib: Remove incorrect ZLIB_VERSION 2024-04-12 12:57:07 -06:00
hang.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
hash-checksum.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
hashtable.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
hexdump.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
image-sparse.c lib: sparse: Fix error checking for write_sparse_chunk_raw 2024-02-09 09:42:04 +01:00
initcall.c initcall: break loop immediately on failure 2024-03-13 18:47:11 -04:00
Kconfig Fix references to trace doc 2024-04-13 11:14:29 +02:00
ldiv.c
linux_compat.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
linux_string.c
list_sort.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
lmb.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
lz4.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
lz4_wrapper.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
Makefile fs: ext4: Fix building ext4 in SPL if write is enabled 2023-10-17 20:50:52 -04:00
md5.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
membuff.c lib: membuff: fix readline not returning line in case of overflow 2024-01-09 14:58:33 +01:00
net_utils.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
of_live.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
oid_registry.c
panic.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
physmem.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
qsort.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
rand.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
rational.c lib: rational: copy the rational fraction lib routines from Linux 2021-06-11 16:34:52 +05:30
rbtree.c
rc4.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
rtc-lib.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
semihosting.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
sha1.c lib/sha*.c: Update header list 2023-12-21 08:54:37 -05:00
sha256.c lib/sha*.c: Update header list 2023-12-21 08:54:37 -05:00
sha512.c lib/sha*.c: Update header list 2023-12-21 08:54:37 -05:00
slre.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
smbios-parser.c smbios: correctly name Structure Table Maximum Size field 2024-02-02 19:57:45 +01:00
smbios.c smbios: fill wake-up type 2024-03-27 09:23:30 +01:00
sscanf.c xen: Code style conformity 2020-08-24 14:11:31 -04:00
string.c Revert "lib: string: Fix strlcpy return value", fix callers 2023-08-08 17:05:43 -04:00
strto.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
tables_csum.c lib: make table_compute_checksum() arguments const 2024-01-09 10:08:52 +01:00
time.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
tiny-printf.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
tpm-common.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
tpm-utils.h doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
tpm-v1.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
tpm-v2.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
tpm_api.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
trace.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
uuid.c lib: support SMBIOS3 table in uuid_guid_get_str() 2024-01-26 14:17:55 +01:00
vsprintf.c lib: Remove <common.h> inclusion from these files 2023-12-21 08:54:37 -05:00
xxhash.c