diff options
author | Tom Rini <trini@konsulko.com> | 2023-03-13 11:39:21 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-03-13 11:39:21 -0400 |
commit | 218cf0e09672ac7c2f650ff0d9ab87669224bf50 (patch) | |
tree | f891991d65ce74cbf1b0c790e5cbf6a01b8f3576 | |
parent | 1247fc7de81d8106cdfa64ecf18aba47a6e587f3 (diff) | |
parent | d3970e04e7125e37ea8c4f3f056b6f5ba868e5f7 (diff) | |
download | u-boot-WIP/13Mar2023.zip u-boot-WIP/13Mar2023.tar.gz u-boot-WIP/13Mar2023.tar.bz2 |
Merge tag 'efi-2023-04-rc4' of https://source.denx.de/u-boot/custodians/u-boot-efiWIP/13Mar2023
Pull request for efi-2023-04-rc4
Documentation:
* man-page for panic command
UEFI:
* Correct parameter check for SetVariable()
Other:
* Provide unit test for crc8
-rw-r--r-- | doc/develop/uefi/fwu_updates.rst | 3 | ||||
-rw-r--r-- | doc/develop/uefi/uefi.rst | 4 | ||||
-rw-r--r-- | doc/usage/cmd/panic.rst | 33 | ||||
-rw-r--r-- | doc/usage/index.rst | 1 | ||||
-rw-r--r-- | lib/efi_loader/efi_console.c | 8 | ||||
-rw-r--r-- | lib/efi_loader/efi_variable.c | 31 | ||||
-rw-r--r-- | test/lib/Makefile | 1 | ||||
-rw-r--r-- | test/lib/test_crc8.c | 29 |
8 files changed, 101 insertions, 9 deletions
diff --git a/doc/develop/uefi/fwu_updates.rst b/doc/develop/uefi/fwu_updates.rst index 72c850a..e4709d8 100644 --- a/doc/develop/uefi/fwu_updates.rst +++ b/doc/develop/uefi/fwu_updates.rst @@ -27,7 +27,8 @@ metadata. Individual drivers can be added based on the type of storage media, and its partitioning method. Details of the storage device containing the FWU metadata partitions are specified through a U-Boot specific device tree property `fwu-mdata-store`. Please refer to -U-Boot `doc <doc/device-tree-bindings/firmware/fwu-mdata-gpt.yaml>`__ +U-Boot :download:`fwu-mdata-gpt.yaml +</device-tree-bindings/firmware/fwu-mdata-gpt.yaml>` for the device tree bindings. Enabling the FWU Multi Bank Update feature diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index a944c0f..ffe25ca 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -386,8 +386,8 @@ is because the FWU feature supports multiple partitions(banks) of updatable images, and the actual dfu alt number to which the image is to be written to is determined at runtime, based on the value of the update bank to which the image is to be written. For more information -on the FWU Multi Bank Update feature, please refer `doc -<doc/develop/uefi/fwu_updates.rst>`__. +on the FWU Multi Bank Update feature, please refer to +:doc:`/develop/uefi/fwu_updates`. When using the FMP for FIT images, the image index value needs to be set to 1. diff --git a/doc/usage/cmd/panic.rst b/doc/usage/cmd/panic.rst new file mode 100644 index 0000000..115eba5 --- /dev/null +++ b/doc/usage/cmd/panic.rst @@ -0,0 +1,33 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +panic command +============= + +Synopis +------- + +:: + + panic [message] + +Description +----------- + +Display a message and reset the board. + +message + text to be displayed + +Examples +-------- + +:: + + => panic 'Unrecoverable error' + Unrecoverable error + resetting ... + +Configuration +------------- + +If CONFIG_PANIC_HANG=y, the user has to reset the board manually. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 840c20c..ebf5eea 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -65,6 +65,7 @@ Shell commands cmd/md cmd/mmc cmd/mtest + cmd/panic cmd/part cmd/pause cmd/pinmux diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 4317630..a2d137d 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -77,6 +77,14 @@ static struct simple_text_output_mode efi_con_mode = { .cursor_visible = 1, }; +/** + * term_get_char() - read a character from the console + * + * Wait for up to 100 ms to read a character from the console. + * + * @c: pointer to the buffer to receive the character + * Return: 0 on success, 1 otherwise + */ static int term_get_char(s32 *c) { u64 timeout; diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 5804f69..be95ed4 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -230,8 +230,30 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, u64 time = 0; enum efi_auth_var_type var_type; - if (!variable_name || !*variable_name || !vendor || - ((attributes & EFI_VARIABLE_RUNTIME_ACCESS) && + if (!variable_name || !*variable_name || !vendor) + return EFI_INVALID_PARAMETER; + + if (data_size && !data) + return EFI_INVALID_PARAMETER; + + /* EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated */ + if (attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) + return EFI_UNSUPPORTED; + + /* Make sure if runtime bit is set, boot service bit is set also */ + if ((attributes & + (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == + EFI_VARIABLE_RUNTIME_ACCESS) + return EFI_INVALID_PARAMETER; + + /* only EFI_VARIABLE_NON_VOLATILE attribute is invalid */ + if ((attributes & EFI_VARIABLE_MASK) == EFI_VARIABLE_NON_VOLATILE) + return EFI_INVALID_PARAMETER; + + /* Make sure HR is set with NV, BS and RT */ + if (attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD && + (!(attributes & EFI_VARIABLE_NON_VOLATILE) || + !(attributes & EFI_VARIABLE_RUNTIME_ACCESS) || !(attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS))) return EFI_INVALID_PARAMETER; @@ -281,8 +303,6 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, /* authenticate a variable */ if (IS_ENABLED(CONFIG_EFI_SECURE_BOOT)) { - if (attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) - return EFI_INVALID_PARAMETER; if (attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) { u32 env_attr; @@ -300,8 +320,7 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, } } else { if (attributes & - (EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | - EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)) { + EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) { EFI_PRINT("Secure boot is not configured\n"); return EFI_INVALID_PARAMETER; } diff --git a/test/lib/Makefile b/test/lib/Makefile index 7e7922f..e0bd9e0 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_UT_LIB_ASN1) += asn1.o obj-$(CONFIG_UT_LIB_RSA) += rsa.o obj-$(CONFIG_AES) += test_aes.o obj-$(CONFIG_GETOPT) += getopt.o +obj-$(CONFIG_CRC8) += test_crc8.o obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o else obj-$(CONFIG_SANDBOX) += kconfig_spl.o diff --git a/test/lib/test_crc8.c b/test/lib/test_crc8.c new file mode 100644 index 0000000..0dac97b --- /dev/null +++ b/test/lib/test_crc8.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2023, Heinrich Schuchardt <heinrich.schuchardt@canonical.com> + * + * Unit test for crc8 + */ + +#include <test/lib.h> +#include <test/ut.h> +#include <u-boot/crc.h> + +static int lib_crc8(struct unit_test_state *uts) { + const char str[] = {0x20, 0xf4, 0xd8, 0x24, 0x6f, 0x41, 0x91, 0xae, + 0x46, 0x61, 0xf6, 0x55, 0xeb, 0x38, 0x47, 0x0f, + 0xec, 0xd8}; + int actual1, actual2, actual3; + int expected1 = 0x47, expected2 = 0xea, expected3 = expected1; + + actual1 = crc8(0, str, sizeof(str)); + ut_asserteq(expected1, actual1); + actual2 = crc8(0, str, 7); + ut_asserteq(expected2, actual2); + actual3 = crc8(actual2, str + 7, sizeof(str) - 7); + ut_asserteq(expected3, actual3); + + return 0; +} + +LIB_TEST(lib_crc8, 0); |