From cc65faf2a38c6241eefcabf0c68dbde2f04d7cf2 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 21 Dec 2021 09:09:48 +0100 Subject: efi: fix typo in description of struct efi_entry_hdr Add missing colon. Signed-off-by: Heinrich Schuchardt --- include/efi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/efi.h b/include/efi.h index 0ec5913ddd..1432038838 100644 --- a/include/efi.h +++ b/include/efi.h @@ -321,7 +321,7 @@ struct efi_info_hdr { * struct efi_entry_hdr - Header for a table entry * * @type: enum eft_entry_t - * @size size of entry bytes excluding header and padding + * @size: size of entry bytes excluding header and padding * @addr: address of this entry (0 if it follows the header ) * @link: size of entry including header and padding * @spare1: Spare space for expansion -- cgit v1.2.3 From 2b18d95d91c8d52a1971f93202c6b8212fa4f27e Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Fri, 24 Dec 2021 10:08:41 +0200 Subject: efi_loader: Don't limit the StMM buffer size explicitly Currently we allow and explicitly check a single shared page with StandAloneMM. This is dictated by OP-TEE which runs the application. However there's no way for us dynamically discover the number of pages we are allowed to use. Since writing big EFI signature list variable requires more than a page, OP-TEE has bumped the number of shared pages to four. Let's remove our explicit check and allow the request to reach OP-TEE even if it's bigger than what it supports. There's no need to sanitize the number of pages internally. OP-TEE will fail if we try to write more than it's allowed. The error will just trigger later on, during the StMM access. While at it add an error message to help users figure out what failed. Signed-off-by: Ilias Apalodimas Tested-by: Ying-Chun Liu (PaulLiu) Signed-off-by: Ilias Apalodimas --- include/tee.h | 1 + lib/efi_loader/efi_variable_tee.c | 16 +++++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/include/tee.h b/include/tee.h index 44e9cd4321..087810bd12 100644 --- a/include/tee.h +++ b/include/tee.h @@ -39,6 +39,7 @@ #define TEE_SUCCESS 0x00000000 #define TEE_ERROR_STORAGE_NOT_AVAILABLE 0xf0100003 #define TEE_ERROR_GENERIC 0xffff0000 +#define TEE_ERROR_EXCESS_DATA 0xffff0004 #define TEE_ERROR_BAD_PARAMETERS 0xffff0006 #define TEE_ERROR_ITEM_NOT_FOUND 0xffff0008 #define TEE_ERROR_NOT_IMPLEMENTED 0xffff0009 diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c index 281f886124..a2c65e3694 100644 --- a/lib/efi_loader/efi_variable_tee.c +++ b/lib/efi_loader/efi_variable_tee.c @@ -15,7 +15,6 @@ #include #include -#define OPTEE_PAGE_SIZE BIT(12) extern struct efi_var_file __efi_runtime_data *efi_var_buf; static efi_uintn_t max_buffer_size; /* comm + var + func + data */ static efi_uintn_t max_payload_size; /* func + data */ @@ -114,7 +113,11 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize) rc = tee_invoke_func(conn.tee, &arg, 2, param); tee_shm_free(shm); tee_close_session(conn.tee, conn.session); - if (rc || arg.ret != TEE_SUCCESS) + if (rc) + return EFI_DEVICE_ERROR; + if (arg.ret == TEE_ERROR_EXCESS_DATA) + log_err("Variable payload too large\n"); + if (arg.ret != TEE_SUCCESS) return EFI_DEVICE_ERROR; switch (param[1].u.value.a) { @@ -255,15 +258,6 @@ efi_status_t EFIAPI get_max_payload(efi_uintn_t *size) goto out; } *size = var_payload->size; - /* - * Although the max payload is configurable on StMM, we only share a - * single page from OP-TEE for the non-secure buffer used to communicate - * with StMM. Since OP-TEE will reject to map anything bigger than that, - * make sure we are in bounds. - */ - if (*size > OPTEE_PAGE_SIZE) - *size = OPTEE_PAGE_SIZE - MM_COMMUNICATE_HEADER_SIZE - - MM_VARIABLE_COMMUNICATE_SIZE; /* * There seems to be a bug in EDK2 miscalculating the boundaries and * size checks, so deduct 2 more bytes to fulfill this requirement. Fix -- cgit v1.2.3 From 88c4cbedfb2f0a41830b662fe2e5797a95af508f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 4 Nov 2021 10:31:17 +0100 Subject: sysreset: watchdog: watchdog cannot power off The watchdog system reset driver can reboot the device but it cannot power it off. If power off is requested, the driver should not reset the system but leave powering off to one of the other system reset drivers. As power cycling is typically not a feature of a watchdog driver the reset types SYSRESET_POWER and SYSRESET_POWER_OFF shall both be excluded. Fixes: 17a0c14164dc ("dm: sysreset: add watchdog-reboot driver") Signed-off-by: Heinrich Schuchardt Reviewed-by: Stefan Roese --- drivers/sysreset/sysreset_watchdog.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/sysreset/sysreset_watchdog.c b/drivers/sysreset/sysreset_watchdog.c index 35efcac59d..8a659ee9b9 100644 --- a/drivers/sysreset/sysreset_watchdog.c +++ b/drivers/sysreset/sysreset_watchdog.c @@ -20,9 +20,16 @@ static int wdt_reboot_request(struct udevice *dev, enum sysreset_t type) struct wdt_reboot_plat *plat = dev_get_plat(dev); int ret; - ret = wdt_expire_now(plat->wdt, 0); - if (ret) - return ret; + switch (type) { + case SYSRESET_COLD: + case SYSRESET_WARM: + ret = wdt_expire_now(plat->wdt, 0); + if (ret) + return ret; + break; + default: + return -ENOSYS; + } return -EINPROGRESS; } -- cgit v1.2.3 From 3a8b919932fdf07b6fefc1e76abb086984909be9 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 18 Dec 2021 11:25:12 +0100 Subject: tools: avoid OpenSSL deprecation warnings Our Gitlab CI buildsystem is set up to treat warnings as errors. With OpenSSL 3.0 a lot of deprecation warnings occur. With the patch compatibility with OpenSSL 1.1.1 is declared. In the long run we should upgrade our code to use the current API. A -Wdiscarded-qualifiers warning is muted by casting. Signed-off-by: Heinrich Schuchardt --- lib/aes/aes-encrypt.c | 3 +++ lib/ecdsa/ecdsa-libcrypto.c | 2 ++ lib/rsa/rsa-sign.c | 2 ++ tools/kwbimage.c | 2 ++ 4 files changed, 9 insertions(+) diff --git a/lib/aes/aes-encrypt.c b/lib/aes/aes-encrypt.c index a6d1720f30..e74e35eaa2 100644 --- a/lib/aes/aes-encrypt.c +++ b/lib/aes/aes-encrypt.c @@ -2,6 +2,9 @@ /* * Copyright (c) 2019,Softathome */ + +#define OPENSSL_API_COMPAT 0x10101000L + #include "mkimage.h" #include #include diff --git a/lib/ecdsa/ecdsa-libcrypto.c b/lib/ecdsa/ecdsa-libcrypto.c index 1757a14562..ae6dfa0ba9 100644 --- a/lib/ecdsa/ecdsa-libcrypto.c +++ b/lib/ecdsa/ecdsa-libcrypto.c @@ -18,6 +18,8 @@ * Copyright (c) 2020,2021, Alexandru Gagniuc */ +#define OPENSSL_API_COMPAT 0x10101000L + #include #include #include diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c index 0579e5294e..44f21416ce 100644 --- a/lib/rsa/rsa-sign.c +++ b/lib/rsa/rsa-sign.c @@ -3,6 +3,8 @@ * Copyright (c) 2013, Google Inc. */ +#define OPENSSL_API_COMPAT 0x10101000L + #include "mkimage.h" #include #include diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 875f636c7a..da8bfe0518 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -8,6 +8,8 @@ * */ +#define OPENSSL_API_COMPAT 0x10101000L + #include "imagetool.h" #include #include -- cgit v1.2.3 From d241d2c879ec2754ca93f4c5d623b82f75f7d1ce Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Mon, 27 Dec 2021 10:08:15 +0200 Subject: doc: Fix usage of CFG_RPMB_WRITE_KEY This is a 'y/n' selection, so fix it. While at it remove the duplicate usage of CFG_CORE_HEAP_SIZE Signed-off-by: Ilias Apalodimas Acked-by: Heinrich Schuchardt --- doc/develop/uefi/uefi.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index a3e2656ab8..43fb10f797 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -248,9 +248,9 @@ OP-TEE Build instructions $ export ARCH=arm $ CROSS_COMPILE32=arm-linux-gnueabihf- make -j32 CFG_ARM64_core=y \ PLATFORM= CFG_STMM_PATH=BL32_AP_MM.fd CFG_RPMB_FS=y \ - CFG_RPMB_FS_DEV_ID=0 CFG_CORE_HEAP_SIZE=524288 CFG_RPMB_WRITE_KEY=1 \ - CFG_CORE_HEAP_SIZE=524288 CFG_CORE_DYN_SHM=y CFG_RPMB_TESTKEY=y \ - CFG_REE_FS=n CFG_CORE_ARM64_PA_BITS=48 CFG_TEE_CORE_LOG_LEVEL=1 \ + CFG_RPMB_FS_DEV_ID=0 CFG_CORE_HEAP_SIZE=524288 CFG_RPMB_WRITE_KEY=y \ + CFG_CORE_DYN_SHM=y CFG_RPMB_TESTKEY=y CFG_REE_FS=n \ + CFG_CORE_ARM64_PA_BITS=48 CFG_TEE_CORE_LOG_LEVEL=1 \ CFG_TEE_TA_LOG_LEVEL=1 CFG_SCTLR_ALIGNMENT_CHECK=n U-Boot Build instructions -- cgit v1.2.3