]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0185-init-Invoke-init_espfix_bsp-from-mm_init.patch
build: reformat existing patches
[pve-kernel.git] / patches / kernel / 0185-init-Invoke-init_espfix_bsp-from-mm_init.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Thomas Gleixner <tglx@linutronix.de>
3 Date: Sun, 17 Dec 2017 10:56:29 +0100
4 Subject: [PATCH] init: Invoke init_espfix_bsp() from mm_init()
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 CVE-2017-5754
10
11 init_espfix_bsp() needs to be invoked before the page table isolation
12 initialization. Move it into mm_init() which is the place where pti_init()
13 will be added.
14
15 While at it get rid of the #ifdeffery and provide proper stub functions.
16
17 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
18 Cc: Andy Lutomirski <luto@kernel.org>
19 Cc: Borislav Petkov <bp@alien8.de>
20 Cc: Dave Hansen <dave.hansen@linux.intel.com>
21 Cc: H. Peter Anvin <hpa@zytor.com>
22 Cc: Josh Poimboeuf <jpoimboe@redhat.com>
23 Cc: Juergen Gross <jgross@suse.com>
24 Cc: Linus Torvalds <torvalds@linux-foundation.org>
25 Cc: Peter Zijlstra <peterz@infradead.org>
26 Signed-off-by: Ingo Molnar <mingo@kernel.org>
27 (cherry picked from commit 613e396bc0d4c7604fba23256644e78454c68cf6)
28 Signed-off-by: Andy Whitcroft <apw@canonical.com>
29 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
30 (cherry picked from commit a187e1a3cd87c860a8db188991d2d43fedd7225f)
31 Signed-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
39 diff --git a/arch/x86/include/asm/espfix.h b/arch/x86/include/asm/espfix.h
40 index 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 */
63 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
64 index 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
79 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
80 index 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);
97 diff --git a/init/main.c b/init/main.c
98 index 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 --
122 2.14.2
123