diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ecdsa/ecdsa-verify.c | 5 | ||||
-rw-r--r-- | lib/efi_driver/Makefile | 1 | ||||
-rw-r--r-- | lib/efi_driver/efi_reset_riscv.c | 29 | ||||
-rw-r--r-- | lib/efi_loader/Kconfig | 2 | ||||
-rw-r--r-- | lib/initcall.c | 4 |
5 files changed, 39 insertions, 2 deletions
diff --git a/lib/ecdsa/ecdsa-verify.c b/lib/ecdsa/ecdsa-verify.c index 0601700c4fc..4d1835b598a 100644 --- a/lib/ecdsa/ecdsa-verify.c +++ b/lib/ecdsa/ecdsa-verify.c @@ -31,6 +31,11 @@ static int fdt_get_key(struct ecdsa_public_key *key, const void *fdt, int node) int x_len, y_len; key->curve_name = fdt_getprop(fdt, node, "ecdsa,curve", NULL); + if (!key->curve_name) { + debug("Error: ecdsa cannot get 'ecdsa,curve' property from key. Likely not an ecdsa key.\n"); + return -ENOMSG; + } + key->size_bits = ecdsa_key_size(key->curve_name); if (key->size_bits == 0) { debug("Unknown ECDSA curve '%s'", key->curve_name); diff --git a/lib/efi_driver/Makefile b/lib/efi_driver/Makefile index f2b6c05cc24..0da20fe91d3 100644 --- a/lib/efi_driver/Makefile +++ b/lib/efi_driver/Makefile @@ -9,3 +9,4 @@ obj-y += efi_uclass.o ifeq ($(CONFIG_PARTITIONS),y) obj-y += efi_block_device.o endif +obj-$(CONFIG_SYSRESET_SBI) += efi_reset_riscv.o diff --git a/lib/efi_driver/efi_reset_riscv.c b/lib/efi_driver/efi_reset_riscv.c new file mode 100644 index 00000000000..89b23522e95 --- /dev/null +++ b/lib/efi_driver/efi_reset_riscv.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include <efi_loader.h> +#include <asm/sbi.h> + +void __efi_runtime EFIAPI efi_reset_system(enum efi_reset_type reset_type, + efi_status_t reset_status, + unsigned long data_size, + void *reset_data) +{ + register unsigned long eid asm("a7") = SBI_EXT_SRST; + register unsigned long fid asm("a6") = SBI_EXT_SRST_RESET; + register unsigned long type asm("a0"); + register unsigned long reason asm("a1") = SBI_SRST_RESET_REASON_NONE; + + switch (reset_type) { + case EFI_RESET_WARM: + type = SBI_SRST_RESET_TYPE_WARM_REBOOT; + break; + case EFI_RESET_SHUTDOWN: + type = SBI_SRST_RESET_TYPE_SHUTDOWN; + break; + default: + type = SBI_SRST_RESET_TYPE_COLD_REBOOT; + break; + } + asm volatile ("ecall\n" + : : "r" (eid), "r" (fid), "r" (type), "r" (reason)); +} diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index db5571de1d9..a7c3e05c13a 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -366,7 +366,7 @@ config EFI_HAVE_RUNTIME_RESET bool default y depends on ARCH_BCM283X || FSL_LAYERSCAPE || PSCI_RESET || \ - SANDBOX || SYSRESET_X86 + SANDBOX || SYSRESET_SBI || SYSRESET_X86 config EFI_GRUB_ARM32_WORKAROUND bool "Workaround for GRUB on 32bit ARM" diff --git a/lib/initcall.c b/lib/initcall.c index ce317af213a..c8e2b0f6a38 100644 --- a/lib/initcall.c +++ b/lib/initcall.c @@ -55,7 +55,7 @@ int initcall_run_list(const init_fnc_t init_sequence[]) init_fnc_t func; int ret = 0; - for (ptr = init_sequence; func = *ptr, !ret && func; ptr++) { + for (ptr = init_sequence; func = *ptr, func; ptr++) { type = initcall_is_event(func); if (type) { @@ -71,6 +71,8 @@ int initcall_run_list(const init_fnc_t init_sequence[]) } ret = type ? event_notify_null(type) : func(); + if (ret) + break; } if (ret) { |