]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0185-init-Invoke-init_espfix_bsp-from-mm_init.patch
KPTI: add follow-up fixes
[pve-kernel.git] / patches / kernel / 0185-init-Invoke-init_espfix_bsp-from-mm_init.patch
CommitLineData
321d628a
FG
1From a6bd428da9f8bbc467b119ef5dc9ad4a1fb58acc Mon Sep 17 00:00:00 2001
2From: Thomas Gleixner <tglx@linutronix.de>
3Date: Sun, 17 Dec 2017 10:56:29 +0100
e4cdf2a5 4Subject: [PATCH 185/241] init: Invoke init_espfix_bsp() from mm_init()
321d628a
FG
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9CVE-2017-5754
10
11init_espfix_bsp() needs to be invoked before the page table isolation
12initialization. Move it into mm_init() which is the place where pti_init()
13will be added.
14
15While at it get rid of the #ifdeffery and provide proper stub functions.
16
17Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
18Cc: Andy Lutomirski <luto@kernel.org>
19Cc: Borislav Petkov <bp@alien8.de>
20Cc: Dave Hansen <dave.hansen@linux.intel.com>
21Cc: H. Peter Anvin <hpa@zytor.com>
22Cc: Josh Poimboeuf <jpoimboe@redhat.com>
23Cc: Juergen Gross <jgross@suse.com>
24Cc: Linus Torvalds <torvalds@linux-foundation.org>
25Cc: Peter Zijlstra <peterz@infradead.org>
26Signed-off-by: Ingo Molnar <mingo@kernel.org>
27(cherry picked from commit 613e396bc0d4c7604fba23256644e78454c68cf6)
28Signed-off-by: Andy Whitcroft <apw@canonical.com>
29Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
30(cherry picked from commit a187e1a3cd87c860a8db188991d2d43fedd7225f)
31Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
32---
33 arch/x86/include/asm/espfix.h | 7 ++++---
34 include/asm-generic/pgtable.h | 5 +++++
35 arch/x86/kernel/smpboot.c | 6 +-----
36 init/main.c | 6 ++----
37 4 files changed, 12 insertions(+), 12 deletions(-)
38
39diff --git a/arch/x86/include/asm/espfix.h b/arch/x86/include/asm/espfix.h
40index ca3ce9ab9385..e7009ac975af 100644
41--- a/arch/x86/include/asm/espfix.h
42+++ b/arch/x86/include/asm/espfix.h
43@@ -1,7 +1,7 @@
44 #ifndef _ASM_X86_ESPFIX_H
45 #define _ASM_X86_ESPFIX_H
46
47-#ifdef CONFIG_X86_64
48+#ifdef CONFIG_X86_ESPFIX64
49
50 #include <asm/percpu.h>
51
52@@ -10,7 +10,8 @@ DECLARE_PER_CPU_READ_MOSTLY(unsigned long, espfix_waddr);
53
54 extern void init_espfix_bsp(void);
55 extern void init_espfix_ap(int cpu);
56-
57-#endif /* CONFIG_X86_64 */
58+#else
59+static inline void init_espfix_ap(int cpu) { }
60+#endif
61
62 #endif /* _ASM_X86_ESPFIX_H */
63diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
64index 7dfa767dc680..1bab3cfc0601 100644
65--- a/include/asm-generic/pgtable.h
66+++ b/include/asm-generic/pgtable.h
67@@ -956,6 +956,11 @@ static inline int pmd_clear_huge(pmd_t *pmd)
68 struct file;
69 int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
70 unsigned long size, pgprot_t *vma_prot);
71+
72+#ifndef CONFIG_X86_ESPFIX64
73+static inline void init_espfix_bsp(void) { }
74+#endif
75+
76 #endif /* !__ASSEMBLY__ */
77
78 #ifndef io_remap_pfn_range
79diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
80index 8ea3b18cbdc1..03d2ba2da3b0 100644
81--- a/arch/x86/kernel/smpboot.c
82+++ b/arch/x86/kernel/smpboot.c
83@@ -989,12 +989,8 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle,
84 initial_code = (unsigned long)start_secondary;
85 initial_stack = idle->thread.sp;
86
87- /*
88- * Enable the espfix hack for this CPU
89- */
90-#ifdef CONFIG_X86_ESPFIX64
91+ /* Enable the espfix hack for this CPU */
92 init_espfix_ap(cpu);
93-#endif
94
95 /* So we see what's up */
96 announce_cpu(cpu, apicid);
97diff --git a/init/main.c b/init/main.c
98index 83d1004e3b97..de1c495da782 100644
99--- a/init/main.c
100+++ b/init/main.c
101@@ -504,6 +504,8 @@ static void __init mm_init(void)
102 pgtable_init();
103 vmalloc_init();
104 ioremap_huge_init();
105+ /* Should be run before the first non-init thread is created */
106+ init_espfix_bsp();
107 }
108
109 asmlinkage __visible void __init start_kernel(void)
110@@ -664,10 +666,6 @@ asmlinkage __visible void __init start_kernel(void)
111 #ifdef CONFIG_X86
112 if (efi_enabled(EFI_RUNTIME_SERVICES))
113 efi_enter_virtual_mode();
114-#endif
115-#ifdef CONFIG_X86_ESPFIX64
116- /* Should be run before the first non-init thread is created */
117- init_espfix_bsp();
118 #endif
119 thread_stack_cache_init();
120 cred_init();
121--
1222.14.2
123