diff options
Diffstat (limited to 'cmd/bootefi.c')
-rw-r--r-- | cmd/bootefi.c | 152 |
1 files changed, 6 insertions, 146 deletions
diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 38679ffc56..ee685d8644 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -5,8 +5,9 @@ * Copyright (c) 2016 Alexander Graf */ -#include <charset.h> #include <common.h> +#include <bootm.h> +#include <charset.h> #include <command.h> #include <dm.h> #include <efi_loader.h> @@ -21,93 +22,11 @@ #include <asm-generic/unaligned.h> #include <linux/linkage.h> -#ifdef CONFIG_ARMV7_NONSEC -#include <asm/armv7.h> -#include <asm/secure.h> -#endif - DECLARE_GLOBAL_DATA_PTR; -#define OBJ_LIST_NOT_INITIALIZED 1 - -static efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED; - static struct efi_device_path *bootefi_image_path; static struct efi_device_path *bootefi_device_path; -/* Initialize and populate EFI object list */ -efi_status_t efi_init_obj_list(void) -{ - efi_status_t ret = EFI_SUCCESS; - - /* - * On the ARM architecture gd is mapped to a fixed register (r9 or x18). - * As this register may be overwritten by an EFI payload we save it here - * and restore it on every callback entered. - */ - efi_save_gd(); - - /* Initialize once only */ - if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) - return efi_obj_list_initialized; - - /* Initialize system table */ - ret = efi_initialize_system_table(); - if (ret != EFI_SUCCESS) - goto out; - - /* Initialize root node */ - ret = efi_root_node_register(); - if (ret != EFI_SUCCESS) - goto out; - - /* Initialize EFI driver uclass */ - ret = efi_driver_init(); - if (ret != EFI_SUCCESS) - goto out; - - ret = efi_console_register(); - if (ret != EFI_SUCCESS) - goto out; -#ifdef CONFIG_PARTITIONS - ret = efi_disk_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif -#if defined(CONFIG_LCD) || defined(CONFIG_DM_VIDEO) - ret = efi_gop_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif -#ifdef CONFIG_NET - ret = efi_net_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif -#ifdef CONFIG_GENERATE_ACPI_TABLE - ret = efi_acpi_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif -#ifdef CONFIG_GENERATE_SMBIOS_TABLE - ret = efi_smbios_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif - ret = efi_watchdog_register(); - if (ret != EFI_SUCCESS) - goto out; - - /* Initialize EFI runtime services */ - ret = efi_reset_system_init(); - if (ret != EFI_SUCCESS) - goto out; - -out: - efi_obj_list_initialized = ret; - return ret; -} - /* * Allow unaligned memory access. * @@ -228,34 +147,6 @@ static efi_status_t efi_do_enter( return ret; } -#ifdef CONFIG_ARM64 -static efi_status_t efi_run_in_el2(EFIAPI efi_status_t (*entry)( - efi_handle_t image_handle, struct efi_system_table *st), - efi_handle_t image_handle, struct efi_system_table *st) -{ - /* Enable caches again */ - dcache_enable(); - - return efi_do_enter(image_handle, st, entry); -} -#endif - -#ifdef CONFIG_ARMV7_NONSEC -static bool is_nonsec; - -static efi_status_t efi_run_in_hyp(EFIAPI efi_status_t (*entry)( - efi_handle_t image_handle, struct efi_system_table *st), - efi_handle_t image_handle, struct efi_system_table *st) -{ - /* Enable caches again */ - dcache_enable(); - - is_nonsec = true; - - return efi_do_enter(image_handle, st, entry); -} -#endif - /* * efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges * @@ -386,7 +277,7 @@ static efi_status_t do_bootefi_exec(void *efi, if (!device_path && !image_path) { printf("WARNING: using memory device/image path, this may confuse some payloads!\n"); /* actual addresses filled in after efi_load_pe() */ - memdp = efi_dp_from_mem(0, 0, 0); + memdp = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, 0, 0); device_path = image_path = memdp; /* * Grub expects that the device path of the loaded image is @@ -428,46 +319,13 @@ static efi_status_t do_bootefi_exec(void *efi, "{ro,boot}(blob)0000000000000000"); /* Call our payload! */ - debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry); + debug("%s: Jumping to 0x%p\n", __func__, entry); if (setjmp(&image_obj->exit_jmp)) { ret = image_obj->exit_status; goto err_prepare; } -#ifdef CONFIG_ARM64 - /* On AArch64 we need to make sure we call our payload in < EL3 */ - if (current_el() == 3) { - smp_kick_all_cpus(); - dcache_disable(); /* flush cache before switch to EL2 */ - - /* Move into EL2 and keep running there */ - armv8_switch_to_el2((ulong)entry, - (ulong)&image_obj->header, - (ulong)&systab, 0, (ulong)efi_run_in_el2, - ES_TO_AARCH64); - - /* Should never reach here, efi exits with longjmp */ - while (1) { } - } -#endif - -#ifdef CONFIG_ARMV7_NONSEC - if (armv7_boot_nonsec() && !is_nonsec) { - dcache_disable(); /* flush cache before switch to HYP */ - - armv7_init_nonsec(); - secure_ram_addr(_do_nonsec_entry)( - efi_run_in_hyp, - (uintptr_t)entry, - (uintptr_t)&image_obj->header, - (uintptr_t)&systab); - - /* Should never reach here, efi exits with longjmp */ - while (1) { } - } -#endif - ret = efi_do_enter(&image_obj->header, &systab, entry); err_prepare: @@ -553,6 +411,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* Allow unaligned memory access */ allow_unaligned(); + switch_to_non_secure_mode(); + /* Initialize EFI drivers */ r = efi_init_obj_list(); if (r != EFI_SUCCESS) { |