efi/arm64: FP/SIMD preserve/restore during UEFI Runtime Services
v3 cover efi/arm64: FP/SIMD preserve/restore during UEFI Runtime Services
Two patches to add FP/SIMD preserve/restore to UEFI Runtime Services:
- patch #1 moves runtime services wrappers to generic code so we can reuse them for arm64
- patch #2 enables the wrappers for arm64 and inserts calls to kernel_neon_begin and kernel_neon_end
@Matt: please queue up for 3.17
v3:
- improve commit message for patch #2 and add Catalin's ack
v2:
- add Kconfig symbol EFI_RUNTIME_WRAPPERS so we don't break ia64 by enabling it unconditionally
Ard Biesheuvel (2):
efi/x86: move UEFI Runtime Services wrappers to generic code efi/arm64: preserve FP/SIMD registers on UEFI runtime services calls
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/efi.h | 21 +++++ arch/arm64/kernel/efi.c | 14 +-- arch/x86/Kconfig | 1 + arch/x86/platform/efi/efi.c | 144 +--------------------------- drivers/firmware/efi/Kconfig | 7 ++ drivers/firmware/efi/Makefile | 1 + drivers/firmware/efi/runtime-wrappers.c | 161 ++++++++++++++++++++++++++++++++ include/linux/efi.h | 2 + 9 files changed, 197 insertions(+), 155 deletions(-) create mode 100644 drivers/firmware/efi/runtime-wrappers.c
Signature · 1 line
1.8.3.2
PATCH v3 1/2 efi/x86: move UEFI Runtime Services wrappers to generic code
In order for other archs (such as arm64) to be able to reuse the virtual mode function call wrappers, move them to drivers/firmware/efi/runtime.c.
--- arch/x86/Kconfig | 1 + arch/x86/platform/efi/efi.c | 144 +--------------------------- drivers/firmware/efi/Kconfig | 7 ++ drivers/firmware/efi/Makefile | 1 + drivers/firmware/efi/runtime-wrappers.c | 161 ++++++++++++++++++++++++++++++++ include/linux/efi.h | 2 + 6 files changed, 174 insertions(+), 142 deletions(-) create mode 100644 drivers/firmware/efi/runtime-wrappers.c
arch/x86/Kconfig +1 -0
@@ -1522,6 +1522,7 @@ config EFI bool "EFI runtime service support" depends on ACPI select UCS2_STRING + select EFI_RUNTIME_WRAPPERS ---help--- This enables the kernel to use EFI runtime services that are available (such as the EFI variable services).
arch/x86/platform/efi/efi.c +2 -142
168 lines not on this page · raw message
drivers/firmware/efi/Kconfig +7 -0
@@ -54,6 +54,13 @@ config EFI_PARAMS_FROM_FDT the EFI runtime support gets system table address, memory map address, and other parameters from the device tree. +config EFI_RUNTIME_WRAPPERS + bool + help + Selected by the arch if it needs to wrap UEFI Runtime Services calls, + in which case it needs to provide #definitions of efi_call_virt and + __efi_call_virt in <asm/efi.h> + endmenu config UEFI_CPER
drivers/firmware/efi/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_EFI_VARS) += efivars.o obj-$(CONFIG_EFI_VARS_PSTORE) += efi-pstore.o obj-$(CONFIG_UEFI_CPER) += cper.o obj-$(CONFIG_EFI_RUNTIME_MAP) += runtime-map.o +obj-$(CONFIG_EFI_RUNTIME_WRAPPERS) += runtime-wrappers.o
drivers/firmware/efi/runtime-wrappers.c new file +161 -0
161 lines not on this page · raw message
include/linux/efi.h +2 -0
@@ -521,6 +521,8 @@ typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **capsules, int *reset_type);typedef efi_status_t efi_query_variable_store_t (u32 attributes,unsigned long size); +void efi_native_runtime_setup (void ); +/* * EFI Configuration Table and GUID definitions */
Signature · 1 line
1.8.3.2
PATCH v3 2/2 efi/arm64: preserve FP/SIMD registers on UEFI runtime services calls
In reply to Ard BiesheuvelAccording to the UEFI spec section 2.3.6.4, the use of FP/SIMD instructions is allowed, and should adhere to the AAPCS64 calling convention, which states that 'only the bottom 64 bits of each value stored in registers v8-v15 need to be preserved' (section 5.1.2).
This applies equally to UEFI Runtime Services called by the kernel, so make sure the FP/SIMD register file is preserved in this case. We do this by enabling the wrappers for UEFI Runtime Services (CONFIG_EFI_RUNTIME_WRAPPERS) and inserting calls to kernel_neon_begin() and kernel_neon_end() into these wrappers.
--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/efi.h | 21 +++++++++++++++++++++ arch/arm64/kernel/efi.c | 14 +------------- 3 files changed, 23 insertions(+), 13 deletions(-)
arch/arm64/Kconfig +1 -0
@@ -299,6 +299,7 @@ config EFI select LIBFDT select UCS2_STRING select EFI_PARAMS_FROM_FDT + select EFI_RUNTIME_WRAPPERS default y help This option provides support for runtime services provided
arch/arm64/include/asm/efi.h +21 -0
@@ -2,6 +2,7 @@#define _ASM_EFI_H#include <asm/io.h> +#include <asm/neon.h> #ifdef CONFIG_EFI extern void efi_init (void );
@@ -11,4 +12,24 @@ extern void efi_idmap_init(void);#define efi_idmap_init ()#endif +#define efi_call_virt (f, ...) \ +({ \ + efi_##f##_t *__f = efi.systab->runtime->f; \ + efi_status_t __s; \ + \ + kernel_neon_begin(); \ + __s = __f(__VA_ARGS__); \ + kernel_neon_end(); \ + __s; \ +}) + +#define __efi_call_virt (f, ...) \ +({ \ + efi_##f##_t *__f = efi.systab->runtime->f; \ + \ + kernel_neon_begin(); \ + __f(__VA_ARGS__); \ + kernel_neon_end(); \ +}) +#endif /* _ASM_EFI_H */
arch/arm64/kernel/efi.c +1 -13
@@ -449,19 +449,7 @@ static int __init arm64_enter_virtual_mode(void)/* Set up runtime services function pointers */ runtime = efi.systab->runtime; - efi.get_time = runtime->get_time; - efi.set_time = runtime->set_time; - efi.get_wakeup_time = runtime->get_wakeup_time; - efi.set_wakeup_time = runtime->set_wakeup_time; - efi.get_variable = runtime->get_variable; - efi.get_next_variable = runtime->get_next_variable; - efi.set_variable = runtime->set_variable; - efi.query_variable_info = runtime->query_variable_info; - efi.update_capsule = runtime->update_capsule; - efi.query_capsule_caps = runtime->query_capsule_caps; - efi.get_next_high_mono_count = runtime->get_next_high_mono_count; - efi.reset_system = runtime->reset_system; - +efi_native_runtime_setup ();set_bit (EFI_RUNTIME_SERVICES , &efi.flags);return 0 ;
Signature · 1 line
1.8.3.2
v3 cover efi/arm64: FP/SIMD preserve/restore during UEFI Runtime Services
In reply to Ard BiesheuvelQuoted 7 lines · Ard Biesheuvel
Two patches to add FP/SIMD preserve/restore to UEFI Runtime Services:
- patch #1 moves runtime services wrappers to generic code so we can reuse them for arm64
- patch #2 enables the wrappers for arm64 and inserts calls tokernel_neon_beginandkernel_neon_end@Matt: please queue up for 3.17
Thanks Ard, applied.
FYI that "please queue up for 3.17" message is super helpful when I'm trying to figure out what branch to apply this to.
Signature · 1 line
Matt Fleming, Intel Open Source Technology Center