Skip to content

Commit a1439d8

Browse files
committed
efi/arm: Disable LPAE PAN when calling EFI runtime services
EFI runtime services are remapped into the lower 1 GiB of virtual address space at boot, so they are guaranteed to be able to co-exist with the kernel virtual mappings without the need to allocate space for them in the kernel's vmalloc region, which is rather small. This means those mappings are covered by TTBR0 when LPAE PAN is enabled, and so 'user' access must be enabled while such calls are in progress. Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 9928041 commit a1439d8

File tree

1 file changed

+13
-0
lines changed
  • arch/arm/include/asm

1 file changed

+13
-0
lines changed

arch/arm/include/asm/efi.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <asm/mach/map.h>
1515
#include <asm/mmu_context.h>
1616
#include <asm/ptrace.h>
17+
#include <asm/uaccess.h>
1718

1819
#ifdef CONFIG_EFI
1920
void efi_init(void);
@@ -25,6 +26,18 @@ int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md, boo
2526
#define arch_efi_call_virt_setup() efi_virtmap_load()
2627
#define arch_efi_call_virt_teardown() efi_virtmap_unload()
2728

29+
#ifdef CONFIG_CPU_TTBR0_PAN
30+
#undef arch_efi_call_virt
31+
#define arch_efi_call_virt(p, f, args...) ({ \
32+
unsigned int flags = uaccess_save_and_enable(); \
33+
efi_status_t res = _Generic((p)->f(args), \
34+
efi_status_t: (p)->f(args), \
35+
default: ((p)->f(args), EFI_ABORTED)); \
36+
uaccess_restore(flags); \
37+
res; \
38+
})
39+
#endif
40+
2841
#define ARCH_EFI_IRQ_FLAGS_MASK \
2942
(PSR_J_BIT | PSR_E_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT | \
3043
PSR_T_BIT | MODE_MASK)

0 commit comments

Comments
 (0)