aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-02 20:46:37 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-02 20:46:37 -0400
commitbc16d4052f1ae99996f3475b5a73d29c86e7ba81 (patch)
treeeaa34bd9bffbe25af7570e0b7bd148f6c9954f06
parent2fcd2b306aa80771e053275ed74b2dfe7e3d1434 (diff)
parent03781e40890c18bdea40092355b61431d0073c1d (diff)
Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull EFI updates from Ingo Molnar: "The main EFI changes in this cycle were: - Fix the apple-properties code (Andy Shevchenko) - Add WARN() on arm64 if UEFI Runtime Services corrupt the reserved x18 register (Ard Biesheuvel) - Use efi_switch_mm() on x86 instead of manipulating %cr3 directly (Sai Praneeth) - Fix early memremap leak in ESRT code (Ard Biesheuvel) - Switch to L"xxx" notation for wide string literals (Ard Biesheuvel) - ... plus misc other cleanups and bugfixes" * 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/efi: Use efi_switch_mm() rather than manually twiddling with %cr3 x86/efi: Replace efi_pgd with efi_mm.pgd efi: Use string literals for efi_char16_t variable initializers efi/esrt: Fix handling of early ESRT table mapping efi: Use efi_mm in x86 as well as ARM efi: Make const array 'apple' static efi/apple-properties: Use memremap() instead of ioremap() efi: Reorder pr_notice() with add_device_randomness() call x86/efi: Replace GFP_ATOMIC with GFP_KERNEL in efi_query_variable_store() efi/arm64: Check whether x18 is preserved by runtime services calls efi/arm*: Stop printing addresses of virtual mappings efi/apple-properties: Remove redundant attribute initialization from unmarshal_key_value_pairs() efi/arm*: Only register page tables when they exist
-rw-r--r--arch/arm64/include/asm/efi.h4
-rw-r--r--arch/arm64/kernel/Makefile3
-rw-r--r--arch/arm64/kernel/efi-rt-wrapper.S41
-rw-r--r--arch/arm64/kernel/efi.c6
-rw-r--r--arch/x86/boot/compressed/eboot.c3
-rw-r--r--arch/x86/include/asm/efi.h26
-rw-r--r--arch/x86/mm/debug_pagetables.c6
-rw-r--r--arch/x86/platform/efi/efi_64.c60
-rw-r--r--arch/x86/platform/efi/efi_thunk_64.S2
-rw-r--r--arch/x86/platform/efi/quirks.c10
-rw-r--r--drivers/firmware/efi/apple-properties.c20
-rw-r--r--drivers/firmware/efi/arm-runtime.c17
-rw-r--r--drivers/firmware/efi/efi.c11
-rw-r--r--drivers/firmware/efi/esrt.c17
-rw-r--r--drivers/firmware/efi/libstub/Makefile2
-rw-r--r--drivers/firmware/efi/libstub/secureboot.c12
-rw-r--r--drivers/firmware/efi/libstub/tpm.c7
-rw-r--r--include/linux/efi.h2
18 files changed, 141 insertions, 108 deletions
diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h
index 8389050328bb..192d791f1103 100644
--- a/arch/arm64/include/asm/efi.h
+++ b/arch/arm64/include/asm/efi.h
@@ -31,7 +31,7 @@ int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);
31({ \ 31({ \
32 efi_##f##_t *__f; \ 32 efi_##f##_t *__f; \
33 __f = p->f; \ 33 __f = p->f; \
34 __f(args); \ 34 __efi_rt_asm_wrapper(__f, #f, args); \
35}) 35})
36 36
37#define arch_efi_call_virt_teardown() \ 37#define arch_efi_call_virt_teardown() \
@@ -40,6 +40,8 @@ int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);
40 efi_virtmap_unload(); \ 40 efi_virtmap_unload(); \
41}) 41})
42 42
43efi_status_t __efi_rt_asm_wrapper(void *, const char *, ...);
44
43#define ARCH_EFI_IRQ_FLAGS_MASK (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT) 45#define ARCH_EFI_IRQ_FLAGS_MASK (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT)
44 46
45/* arch specific definitions used by the stub code */ 47/* arch specific definitions used by the stub code */
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index b87541360f43..6a4bd80c75bd 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -38,7 +38,8 @@ arm64-obj-$(CONFIG_CPU_PM) += sleep.o suspend.o
38arm64-obj-$(CONFIG_CPU_IDLE) += cpuidle.o 38arm64-obj-$(CONFIG_CPU_IDLE) += cpuidle.o
39arm64-obj-$(CONFIG_JUMP_LABEL) += jump_label.o 39arm64-obj-$(CONFIG_JUMP_LABEL) += jump_label.o
40arm64-obj-$(CONFIG_KGDB) += kgdb.o 40arm64-obj-$(CONFIG_KGDB) += kgdb.o
41arm64-obj-$(CONFIG_EFI) += efi.o efi-entry.stub.o 41arm64-obj-$(CONFIG_EFI) += efi.o efi-entry.stub.o \
42 efi-rt-wrapper.o
42arm64-obj-$(CONFIG_PCI) += pci.o 43arm64-obj-$(CONFIG_PCI) += pci.o
43arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o 44arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o
44arm64-obj-$(CONFIG_ACPI) += acpi.o 45arm64-obj-$(CONFIG_ACPI) += acpi.o
diff --git a/arch/arm64/kernel/efi-rt-wrapper.S b/arch/arm64/kernel/efi-rt-wrapper.S
new file mode 100644
index 000000000000..05235ebb336d
--- /dev/null
+++ b/arch/arm64/kernel/efi-rt-wrapper.S
@@ -0,0 +1,41 @@
1/*
2 * Copyright (C) 2018 Linaro Ltd <ard.biesheuvel@linaro.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/linkage.h>
10
11ENTRY(__efi_rt_asm_wrapper)
12 stp x29, x30, [sp, #-32]!
13 mov x29, sp
14
15 /*
16 * Register x18 is designated as the 'platform' register by the AAPCS,
17 * which means firmware running at the same exception level as the OS
18 * (such as UEFI) should never touch it.
19 */
20 stp x1, x18, [sp, #16]
21
22 /*
23 * We are lucky enough that no EFI runtime services take more than
24 * 5 arguments, so all are passed in registers rather than via the
25 * stack.
26 */
27 mov x8, x0
28 mov x0, x2
29 mov x1, x3
30 mov x2, x4
31 mov x3, x5
32 mov x4, x6
33 blr x8
34
35 ldp x1, x2, [sp, #16]
36 cmp x2, x18
37 ldp x29, x30, [sp], #32
38 b.ne 0f
39 ret
400: b efi_handle_corrupted_x18 // tail call
41ENDPROC(__efi_rt_asm_wrapper)
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index a8bf1c892b90..4f9acb5fbe97 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -126,3 +126,9 @@ bool efi_poweroff_required(void)
126{ 126{
127 return efi_enabled(EFI_RUNTIME_SERVICES); 127 return efi_enabled(EFI_RUNTIME_SERVICES);
128} 128}
129
130asmlinkage efi_status_t efi_handle_corrupted_x18(efi_status_t s, const char *f)
131{
132 pr_err_ratelimited(FW_BUG "register x18 corrupted by EFI %s\n", f);
133 return s;
134}
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 886a9115af62..47d3efff6805 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -421,9 +421,10 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
421 } 421 }
422} 422}
423 423
424static const efi_char16_t apple[] = L"Apple";
425
424static void setup_quirks(struct boot_params *boot_params) 426static void setup_quirks(struct boot_params *boot_params)
425{ 427{
426 efi_char16_t const apple[] = { 'A', 'p', 'p', 'l', 'e', 0 };
427 efi_char16_t *fw_vendor = (efi_char16_t *)(unsigned long) 428 efi_char16_t *fw_vendor = (efi_char16_t *)(unsigned long)
428 efi_table_attr(efi_system_table, fw_vendor, sys_table); 429 efi_table_attr(efi_system_table, fw_vendor, sys_table);
429 430
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index a399c1ebf6f0..cec5fae23eb3 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -7,6 +7,7 @@
7#include <asm/processor-flags.h> 7#include <asm/processor-flags.h>
8#include <asm/tlb.h> 8#include <asm/tlb.h>
9#include <asm/nospec-branch.h> 9#include <asm/nospec-branch.h>
10#include <asm/mmu_context.h>
10 11
11/* 12/*
12 * We map the EFI regions needed for runtime services non-contiguously, 13 * We map the EFI regions needed for runtime services non-contiguously,
@@ -69,14 +70,13 @@ extern asmlinkage u64 efi_call(void *fp, ...);
69#define efi_call_phys(f, args...) efi_call((f), args) 70#define efi_call_phys(f, args...) efi_call((f), args)
70 71
71/* 72/*
72 * Scratch space used for switching the pagetable in the EFI stub 73 * struct efi_scratch - Scratch space used while switching to/from efi_mm
74 * @phys_stack: stack used during EFI Mixed Mode
75 * @prev_mm: store/restore stolen mm_struct while switching to/from efi_mm
73 */ 76 */
74struct efi_scratch { 77struct efi_scratch {
75 u64 r15; 78 u64 phys_stack;
76 u64 prev_cr3; 79 struct mm_struct *prev_mm;
77 pgd_t *efi_pgt;
78 bool use_pgd;
79 u64 phys_stack;
80} __packed; 80} __packed;
81 81
82#define arch_efi_call_virt_setup() \ 82#define arch_efi_call_virt_setup() \
@@ -86,11 +86,8 @@ struct efi_scratch {
86 __kernel_fpu_begin(); \ 86 __kernel_fpu_begin(); \
87 firmware_restrict_branch_speculation_start(); \ 87 firmware_restrict_branch_speculation_start(); \
88 \ 88 \
89 if (efi_scratch.use_pgd) { \ 89 if (!efi_enabled(EFI_OLD_MEMMAP)) \
90 efi_scratch.prev_cr3 = __read_cr3(); \ 90 efi_switch_mm(&efi_mm); \
91 write_cr3((unsigned long)efi_scratch.efi_pgt); \
92 __flush_tlb_all(); \
93 } \
94}) 91})
95 92
96#define arch_efi_call_virt(p, f, args...) \ 93#define arch_efi_call_virt(p, f, args...) \
@@ -98,10 +95,8 @@ struct efi_scratch {
98 95
99#define arch_efi_call_virt_teardown() \ 96#define arch_efi_call_virt_teardown() \
100({ \ 97({ \
101 if (efi_scratch.use_pgd) { \ 98 if (!efi_enabled(EFI_OLD_MEMMAP)) \
102 write_cr3(efi_scratch.prev_cr3); \ 99 efi_switch_mm(efi_scratch.pre