diff options
40 files changed, 1508 insertions, 622 deletions
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index f3b584be76d7..b0f9c9db9590 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig | |||
| @@ -347,12 +347,18 @@ config CMDLINE_FORCE | |||
| 347 | This is useful if you cannot or don't want to change the | 347 | This is useful if you cannot or don't want to change the |
| 348 | command-line options your boot loader passes to the kernel. | 348 | command-line options your boot loader passes to the kernel. |
| 349 | 349 | ||
| 350 | config EFI_STUB | ||
| 351 | bool | ||
| 352 | |||
| 350 | config EFI | 353 | config EFI |
| 351 | bool "UEFI runtime support" | 354 | bool "UEFI runtime support" |
| 352 | depends on OF && !CPU_BIG_ENDIAN | 355 | depends on OF && !CPU_BIG_ENDIAN |
| 353 | select LIBFDT | 356 | select LIBFDT |
| 354 | select UCS2_STRING | 357 | select UCS2_STRING |
| 355 | select EFI_PARAMS_FROM_FDT | 358 | select EFI_PARAMS_FROM_FDT |
| 359 | select EFI_RUNTIME_WRAPPERS | ||
| 360 | select EFI_STUB | ||
| 361 | select EFI_ARMSTUB | ||
| 356 | default y | 362 | default y |
| 357 | help | 363 | help |
| 358 | This option provides support for runtime services provided | 364 | This option provides support for runtime services provided |
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index e8d025c1459e..57833546bf00 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile | |||
| @@ -52,6 +52,7 @@ core-$(CONFIG_XEN) += arch/arm64/xen/ | |||
| 52 | core-$(CONFIG_CRYPTO) += arch/arm64/crypto/ | 52 | core-$(CONFIG_CRYPTO) += arch/arm64/crypto/ |
| 53 | libs-y := arch/arm64/lib/ $(libs-y) | 53 | libs-y := arch/arm64/lib/ $(libs-y) |
| 54 | libs-y += $(LIBGCC) | 54 | libs-y += $(LIBGCC) |
| 55 | libs-$(CONFIG_EFI_STUB) += drivers/firmware/efi/libstub/ | ||
| 55 | 56 | ||
| 56 | # Default target when executing plain make | 57 | # Default target when executing plain make |
| 57 | KBUILD_IMAGE := Image.gz | 58 | KBUILD_IMAGE := Image.gz |
diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index 5a46c4e7f539..a34fd3b12e2b 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | #define _ASM_EFI_H | 2 | #define _ASM_EFI_H |
| 3 | 3 | ||
| 4 | #include <asm/io.h> | 4 | #include <asm/io.h> |
| 5 | #include <asm/neon.h> | ||
| 5 | 6 | ||
| 6 | #ifdef CONFIG_EFI | 7 | #ifdef CONFIG_EFI |
| 7 | extern void efi_init(void); | 8 | extern void efi_init(void); |
| @@ -11,4 +12,36 @@ extern void efi_idmap_init(void); | |||
| 11 | #define efi_idmap_init() | 12 | #define efi_idmap_init() |
| 12 | #endif | 13 | #endif |
| 13 | 14 | ||
| 15 | #define efi_call_virt(f, ...) \ | ||
| 16 | ({ \ | ||
| 17 | efi_##f##_t *__f = efi.systab->runtime->f; \ | ||
| 18 | efi_status_t __s; \ | ||
| 19 | \ | ||
| 20 | kernel_neon_begin(); \ | ||
| 21 | __s = __f(__VA_ARGS__); \ | ||
| 22 | kernel_neon_end(); \ | ||
| 23 | __s; \ | ||
| 24 | }) | ||
| 25 | |||
| 26 | #define __efi_call_virt(f, ...) \ | ||
| 27 | ({ \ | ||
| 28 | efi_##f##_t *__f = efi.systab->runtime->f; \ | ||
| 29 | \ | ||
| 30 | kernel_neon_begin(); \ | ||
| 31 | __f(__VA_ARGS__); \ | ||
| 32 | kernel_neon_end(); \ | ||
| 33 | }) | ||
| 34 | |||
| 35 | /* arch specific definitions used by the stub code */ | ||
| 36 | |||
| 37 | /* | ||
| 38 | * AArch64 requires the DTB to be 8-byte aligned in the first 512MiB from | ||
| 39 | * start of kernel and may not cross a 2MiB boundary. We set alignment to | ||
| 40 | * 2MiB so we know it won't cross a 2MiB boundary. | ||
| 41 | */ | ||
| 42 | #define EFI_FDT_ALIGN SZ_2M /* used by allocate_new_fdt_and_exit_boot() */ | ||
| 43 | #define MAX_FDT_OFFSET SZ_512M | ||
| 44 | |||
| 45 | #define efi_call_early(f, ...) sys_table_arg->boottime->f(__VA_ARGS__) | ||
| 46 | |||
| 14 | #endif /* _ASM_EFI_H */ | 47 | #endif /* _ASM_EFI_H */ |
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 27c72ef4fd7a..df7ef8768fc2 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile | |||
| @@ -4,8 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | CPPFLAGS_vmlinux.lds := -DTEXT_OFFSET=$(TEXT_OFFSET) | 5 | CPPFLAGS_vmlinux.lds := -DTEXT_OFFSET=$(TEXT_OFFSET) |
| 6 | AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) | 6 | AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) |
| 7 | CFLAGS_efi-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) \ | 7 | CFLAGS_efi-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) |
| 8 | -I$(src)/../../../scripts/dtc/libfdt | ||
| 9 | 8 | ||
| 10 | CFLAGS_REMOVE_ftrace.o = -pg | 9 | CFLAGS_REMOVE_ftrace.o = -pg |
| 11 | CFLAGS_REMOVE_insn.o = -pg | 10 | CFLAGS_REMOVE_insn.o = -pg |
diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c index e786e6cdc400..1317fef8dde9 100644 --- a/arch/arm64/kernel/efi-stub.c +++ b/arch/arm64/kernel/efi-stub.c | |||
| @@ -10,46 +10,16 @@ | |||
| 10 | * | 10 | * |
| 11 | */ | 11 | */ |
| 12 | #include <linux/efi.h> | 12 | #include <linux/efi.h> |
| 13 | #include <linux/libfdt.h> | 13 | #include <asm/efi.h> |
| 14 | #include <asm/sections.h> | 14 | #include <asm/sections.h> |
| 15 | 15 | ||
| 16 | /* | 16 | efi_status_t handle_kernel_image(efi_system_table_t *sys_table, |
| 17 | * AArch64 requires the DTB to be 8-byte aligned in the first 512MiB from | 17 | unsigned long *image_addr, |
| 18 | * start of kernel and may not cross a 2MiB boundary. We set alignment to | 18 | unsigned long *image_size, |
| 19 | * 2MiB so we know it won't cross a 2MiB boundary. | 19 | unsigned long *reserve_addr, |
| 20 | */ | 20 | unsigned long *reserve_size, |
| 21 | #define EFI_FDT_ALIGN SZ_2M /* used by allocate_new_fdt_and_exit_boot() */ | 21 | unsigned long dram_base, |
| 22 | #define MAX_FDT_OFFSET SZ_512M | 22 | efi_loaded_image_t *image) |
| 23 | |||
| 24 | #define efi_call_early(f, ...) sys_table_arg->boottime->f(__VA_ARGS__) | ||
| 25 | |||
| 26 | static void efi_char16_printk(efi_system_table_t *sys_table_arg, | ||
| 27 | efi_char16_t *str); | ||
| 28 | |||
| 29 | static efi_status_t efi_open_volume(efi_system_table_t *sys_table, | ||
| 30 | void *__image, void **__fh); | ||
| 31 | static efi_status_t efi_file_close(void *handle); | ||
| 32 | |||
| 33 | static efi_status_t | ||
| 34 | efi_file_read(void *handle, unsigned long *size, void *addr); | ||
| 35 | |||
| 36 | static efi_status_t | ||
| 37 | efi_file_size(efi_system_table_t *sys_table, void *__fh, | ||
| 38 | efi_char16_t *filename_16, void **handle, u64 *file_sz); | ||
| 39 | |||
| 40 | /* Include shared EFI stub code */ | ||
| 41 | #include "../../../drivers/firmware/efi/efi-stub-helper.c" | ||
| 42 | #include "../../../drivers/firmware/efi/fdt.c" | ||
| 43 | #include "../../../drivers/firmware/efi/arm-stub.c" | ||
| 44 | |||
| 45 | |||
| 46 | static efi_status_t handle_kernel_image(efi_system_table_t *sys_table, | ||
| 47 | unsigned long *image_addr, | ||
| 48 | unsigned long *image_size, | ||
| 49 | unsigned long *res | ||
