]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0030-x86-paravirt-Remove-no-longer-used-paravirt-function.patch
KPTI: add follow-up fixes
[pve-kernel.git] / patches / kernel / 0030-x86-paravirt-Remove-no-longer-used-paravirt-function.patch
CommitLineData
321d628a
FG
1From bbb647f65a627420f8c3351b34d14490a9878509 Mon Sep 17 00:00:00 2001
2From: Juergen Gross <jgross@suse.com>
3Date: Mon, 4 Sep 2017 12:25:27 +0200
e4cdf2a5 4Subject: [PATCH 030/241] x86/paravirt: Remove no longer used paravirt
321d628a
FG
5 functions
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10CVE-2017-5754
11
12With removal of lguest some of the paravirt functions are no longer
13needed:
14
15 ->read_cr4()
16 ->store_idt()
17 ->set_pmd_at()
18 ->set_pud_at()
19 ->pte_update()
20
21Remove them.
22
23Signed-off-by: Juergen Gross <jgross@suse.com>
24Cc: Linus Torvalds <torvalds@linux-foundation.org>
25Cc: Peter Zijlstra <peterz@infradead.org>
26Cc: Thomas Gleixner <tglx@linutronix.de>
27Cc: akataria@vmware.com
28Cc: boris.ostrovsky@oracle.com
29Cc: chrisw@sous-sol.org
30Cc: jeremy@goop.org
31Cc: rusty@rustcorp.com.au
32Cc: virtualization@lists.linux-foundation.org
33Cc: xen-devel@lists.xenproject.org
34Link: http://lkml.kernel.org/r/20170904102527.25409-1-jgross@suse.com
35Signed-off-by: Ingo Molnar <mingo@kernel.org>
36(cherry picked from commit 87930019c713873a1c3b9bd55dde46e81f70c8f1)
37Signed-off-by: Andy Whitcroft <apw@canonical.com>
38Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
39(cherry picked from commit edf3ab0080a6e79a300753e66929b0b7499eaec5)
40Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
41---
42 arch/x86/include/asm/desc.h | 3 +--
43 arch/x86/include/asm/paravirt.h | 37 -----------------------------------
44 arch/x86/include/asm/paravirt_types.h | 9 ---------
45 arch/x86/include/asm/pgtable.h | 27 ++++---------------------
46 arch/x86/include/asm/special_insns.h | 10 +++++-----
47 arch/x86/kernel/paravirt.c | 5 -----
48 arch/x86/kvm/vmx.c | 2 +-
49 arch/x86/mm/pgtable.c | 7 +------
50 arch/x86/xen/enlighten_pv.c | 2 --
51 arch/x86/xen/mmu_pv.c | 2 --
52 10 files changed, 12 insertions(+), 92 deletions(-)
53
54diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
55index 57e502a4e92f..f995e5a09136 100644
56--- a/arch/x86/include/asm/desc.h
57+++ b/arch/x86/include/asm/desc.h
58@@ -120,7 +120,6 @@ static inline int desc_empty(const void *ptr)
59 #define load_ldt(ldt) asm volatile("lldt %0"::"m" (ldt))
60
61 #define store_gdt(dtr) native_store_gdt(dtr)
62-#define store_idt(dtr) native_store_idt(dtr)
63 #define store_tr(tr) (tr = native_store_tr())
64
65 #define load_TLS(t, cpu) native_load_tls(t, cpu)
66@@ -241,7 +240,7 @@ static inline void native_store_gdt(struct desc_ptr *dtr)
67 asm volatile("sgdt %0":"=m" (*dtr));
68 }
69
70-static inline void native_store_idt(struct desc_ptr *dtr)
71+static inline void store_idt(struct desc_ptr *dtr)
72 {
73 asm volatile("sidt %0":"=m" (*dtr));
74 }
75diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
76index c25dd22f7c70..12deec722cf0 100644
77--- a/arch/x86/include/asm/paravirt.h
78+++ b/arch/x86/include/asm/paravirt.h
79@@ -71,11 +71,6 @@ static inline void write_cr3(unsigned long x)
80 PVOP_VCALL1(pv_mmu_ops.write_cr3, x);
81 }
82
83-static inline unsigned long __read_cr4(void)
84-{
85- return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr4);
86-}
87-
88 static inline void __write_cr4(unsigned long x)
89 {
90 PVOP_VCALL1(pv_cpu_ops.write_cr4, x);
91@@ -228,10 +223,6 @@ static inline void set_ldt(const void *addr, unsigned entries)
92 {
93 PVOP_VCALL2(pv_cpu_ops.set_ldt, addr, entries);
94 }
95-static inline void store_idt(struct desc_ptr *dtr)
96-{
97- PVOP_VCALL1(pv_cpu_ops.store_idt, dtr);
98-}
99 static inline unsigned long paravirt_store_tr(void)
100 {
101 return PVOP_CALL0(unsigned long, pv_cpu_ops.store_tr);
102@@ -365,12 +356,6 @@ static inline void paravirt_release_p4d(unsigned long pfn)
103 PVOP_VCALL1(pv_mmu_ops.release_p4d, pfn);
104 }
105
106-static inline void pte_update(struct mm_struct *mm, unsigned long addr,
107- pte_t *ptep)
108-{
109- PVOP_VCALL3(pv_mmu_ops.pte_update, mm, addr, ptep);
110-}
111-
112 static inline pte_t __pte(pteval_t val)
113 {
114 pteval_t ret;
115@@ -472,28 +457,6 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
116 PVOP_VCALL4(pv_mmu_ops.set_pte_at, mm, addr, ptep, pte.pte);
117 }
118
119-static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
120- pmd_t *pmdp, pmd_t pmd)
121-{
122- if (sizeof(pmdval_t) > sizeof(long))
123- /* 5 arg words */
124- pv_mmu_ops.set_pmd_at(mm, addr, pmdp, pmd);
125- else
126- PVOP_VCALL4(pv_mmu_ops.set_pmd_at, mm, addr, pmdp,
127- native_pmd_val(pmd));
128-}
129-
130-static inline void set_pud_at(struct mm_struct *mm, unsigned long addr,
131- pud_t *pudp, pud_t pud)
132-{
133- if (sizeof(pudval_t) > sizeof(long))
134- /* 5 arg words */
135- pv_mmu_ops.set_pud_at(mm, addr, pudp, pud);
136- else
137- PVOP_VCALL4(pv_mmu_ops.set_pud_at, mm, addr, pudp,
138- native_pud_val(pud));
139-}
140-
141 static inline void set_pmd(pmd_t *pmdp, pmd_t pmd)
142 {
143 pmdval_t val = native_pmd_val(pmd);
144diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
145index 6b64fc6367f2..42873edd9f9d 100644
146--- a/arch/x86/include/asm/paravirt_types.h
147+++ b/arch/x86/include/asm/paravirt_types.h
148@@ -107,7 +107,6 @@ struct pv_cpu_ops {
149 unsigned long (*read_cr0)(void);
150 void (*write_cr0)(unsigned long);
151
152- unsigned long (*read_cr4)(void);
153 void (*write_cr4)(unsigned long);
154
155 #ifdef CONFIG_X86_64
156@@ -119,8 +118,6 @@ struct pv_cpu_ops {
157 void (*load_tr_desc)(void);
158 void (*load_gdt)(const struct desc_ptr *);
159 void (*load_idt)(const struct desc_ptr *);
160- /* store_gdt has been removed. */
161- void (*store_idt)(struct desc_ptr *);
162 void (*set_ldt)(const void *desc, unsigned entries);
163 unsigned long (*store_tr)(void);
164 void (*load_tls)(struct thread_struct *t, unsigned int cpu);
165@@ -245,12 +242,6 @@ struct pv_mmu_ops {
166 void (*set_pte_at)(struct mm_struct *mm, unsigned long addr,
167 pte_t *ptep, pte_t pteval);
168 void (*set_pmd)(pmd_t *pmdp, pmd_t pmdval);
169- void (*set_pmd_at)(struct mm_struct *mm, unsigned long addr,
170- pmd_t *pmdp, pmd_t pmdval);
171- void (*set_pud_at)(struct mm_struct *mm, unsigned long addr,
172- pud_t *pudp, pud_t pudval);
173- void (*pte_update)(struct mm_struct *mm, unsigned long addr,
174- pte_t *ptep);
175
176 pte_t (*ptep_modify_prot_start)(struct mm_struct *mm, unsigned long addr,
177 pte_t *ptep);
178diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
179index 77037b6f1caa..bb8e9ea7deb4 100644
180--- a/arch/x86/include/asm/pgtable.h
181+++ b/arch/x86/include/asm/pgtable.h
182@@ -43,8 +43,6 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
183 #else /* !CONFIG_PARAVIRT */
184 #define set_pte(ptep, pte) native_set_pte(ptep, pte)
185 #define set_pte_at(mm, addr, ptep, pte) native_set_pte_at(mm, addr, ptep, pte)
186-#define set_pmd_at(mm, addr, pmdp, pmd) native_set_pmd_at(mm, addr, pmdp, pmd)
187-#define set_pud_at(mm, addr, pudp, pud) native_set_pud_at(mm, addr, pudp, pud)
188
189 #define set_pte_atomic(ptep, pte) \
190 native_set_pte_atomic(ptep, pte)
191@@ -75,8 +73,6 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
192 #define pte_clear(mm, addr, ptep) native_pte_clear(mm, addr, ptep)
193 #define pmd_clear(pmd) native_pmd_clear(pmd)
194
195-#define pte_update(mm, addr, ptep) do { } while (0)
196-
197 #define pgd_val(x) native_pgd_val(x)
198 #define __pgd(x) native_make_pgd(x)
199
200@@ -965,31 +961,18 @@ static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr,
201 native_set_pte(ptep, pte);
202 }
203
204-static inline void native_set_pmd_at(struct mm_struct *mm, unsigned long addr,
205- pmd_t *pmdp , pmd_t pmd)
206+static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
207+ pmd_t *pmdp, pmd_t pmd)
208 {
209 native_set_pmd(pmdp, pmd);
210 }
211
212-static inline void native_set_pud_at(struct mm_struct *mm, unsigned long addr,
213- pud_t *pudp, pud_t pud)
214+static inline void set_pud_at(struct mm_struct *mm, unsigned long addr,
215+ pud_t *pudp, pud_t pud)
216 {
217 native_set_pud(pudp, pud);
218 }
219
220-#ifndef CONFIG_PARAVIRT
221-/*
222- * Rules for using pte_update - it must be called after any PTE update which
223- * has not been done using the set_pte / clear_pte interfaces. It is used by
224- * shadow mode hypervisors to resynchronize the shadow page tables. Kernel PTE
225- * updates should either be sets, clears, or set_pte_atomic for P->P
226- * transitions, which means this hook should only be called for user PTEs.
227- * This hook implies a P->P protection or access change has taken place, which
228- * requires a subsequent TLB flush.
229- */
230-#define pte_update(mm, addr, ptep) do { } while (0)
231-#endif
232-
233 /*
234 * We only update the dirty/accessed state if we set
235 * the dirty bit by hand in the kernel, since the hardware
236@@ -1017,7 +1000,6 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
237 pte_t *ptep)
238 {
239 pte_t pte = native_ptep_get_and_clear(ptep);
240- pte_update(mm, addr, ptep);
241 return pte;
242 }
243
244@@ -1044,7 +1026,6 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm,
245 unsigned long addr, pte_t *ptep)
246 {
247 clear_bit(_PAGE_BIT_RW, (unsigned long *)&ptep->pte);
248- pte_update(mm, addr, ptep);
249 }
250
251 #define flush_tlb_fix_spurious_fault(vma, address) do { } while (0)
252diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
253index 9efaabf5b54b..a24dfcf79f4a 100644
254--- a/arch/x86/include/asm/special_insns.h
255+++ b/arch/x86/include/asm/special_insns.h
256@@ -135,6 +135,11 @@ static inline void native_wbinvd(void)
257
258 extern asmlinkage void native_load_gs_index(unsigned);
259
260+static inline unsigned long __read_cr4(void)
261+{
262+ return native_read_cr4();
263+}
264+
265 #ifdef CONFIG_PARAVIRT
266 #include <asm/paravirt.h>
267 #else
268@@ -173,11 +178,6 @@ static inline void write_cr3(unsigned long x)
269 native_write_cr3(x);
270 }
271
272-static inline unsigned long __read_cr4(void)
273-{
274- return native_read_cr4();
275-}
276-
277 static inline void __write_cr4(unsigned long x)
278 {
279 native_write_cr4(x);
280diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
281index a14df9eecfed..19a3e8f961c7 100644
282--- a/arch/x86/kernel/paravirt.c
283+++ b/arch/x86/kernel/paravirt.c
284@@ -327,7 +327,6 @@ __visible struct pv_cpu_ops pv_cpu_ops = {
285 .set_debugreg = native_set_debugreg,
286 .read_cr0 = native_read_cr0,
287 .write_cr0 = native_write_cr0,
288- .read_cr4 = native_read_cr4,
289 .write_cr4 = native_write_cr4,
290 #ifdef CONFIG_X86_64
291 .read_cr8 = native_read_cr8,
292@@ -343,7 +342,6 @@ __visible struct pv_cpu_ops pv_cpu_ops = {
293 .set_ldt = native_set_ldt,
294 .load_gdt = native_load_gdt,
295 .load_idt = native_load_idt,
296- .store_idt = native_store_idt,
297 .store_tr = native_store_tr,
298 .load_tls = native_load_tls,
299 #ifdef CONFIG_X86_64
300@@ -411,8 +409,6 @@ struct pv_mmu_ops pv_mmu_ops __ro_after_init = {
301 .set_pte = native_set_pte,
302 .set_pte_at = native_set_pte_at,
303 .set_pmd = native_set_pmd,
304- .set_pmd_at = native_set_pmd_at,
305- .pte_update = paravirt_nop,
306
307 .ptep_modify_prot_start = __ptep_modify_prot_start,
308 .ptep_modify_prot_commit = __ptep_modify_prot_commit,
309@@ -424,7 +420,6 @@ struct pv_mmu_ops pv_mmu_ops __ro_after_init = {
310 .pmd_clear = native_pmd_clear,
311 #endif
312 .set_pud = native_set_pud,
313- .set_pud_at = native_set_pud_at,
314
315 .pmd_val = PTE_IDENT,
316 .make_pmd = PTE_IDENT,
317diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
318index 7b447d126d17..dd4996a96c71 100644
319--- a/arch/x86/kvm/vmx.c
320+++ b/arch/x86/kvm/vmx.c
321@@ -5174,7 +5174,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
322 vmcs_write16(HOST_SS_SELECTOR, __KERNEL_DS); /* 22.2.4 */
323 vmcs_write16(HOST_TR_SELECTOR, GDT_ENTRY_TSS*8); /* 22.2.4 */
324
325- native_store_idt(&dt);
326+ store_idt(&dt);
327 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
328 vmx->host_idt_base = dt.address;
329
330diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
331index 508a708eb9a6..942391b5b639 100644
332--- a/arch/x86/mm/pgtable.c
333+++ b/arch/x86/mm/pgtable.c
334@@ -426,10 +426,8 @@ int ptep_set_access_flags(struct vm_area_struct *vma,
335 {
336 int changed = !pte_same(*ptep, entry);
337
338- if (changed && dirty) {
339+ if (changed && dirty)
340 *ptep = entry;
341- pte_update(vma->vm_mm, address, ptep);
342- }
343
344 return changed;
345 }
346@@ -486,9 +484,6 @@ int ptep_test_and_clear_young(struct vm_area_struct *vma,
347 ret = test_and_clear_bit(_PAGE_BIT_ACCESSED,
348 (unsigned long *) &ptep->pte);
349
350- if (ret)
351- pte_update(vma->vm_mm, addr, ptep);
352-
353 return ret;
354 }
355
356diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
357index ae2a2e2d6362..69b9deff7e5c 100644
358--- a/arch/x86/xen/enlighten_pv.c
359+++ b/arch/x86/xen/enlighten_pv.c
360@@ -1038,7 +1038,6 @@ static const struct pv_cpu_ops xen_cpu_ops __initconst = {
361 .read_cr0 = xen_read_cr0,
362 .write_cr0 = xen_write_cr0,
363
364- .read_cr4 = native_read_cr4,
365 .write_cr4 = xen_write_cr4,
366
367 #ifdef CONFIG_X86_64
368@@ -1073,7 +1072,6 @@ static const struct pv_cpu_ops xen_cpu_ops __initconst = {
369 .alloc_ldt = xen_alloc_ldt,
370 .free_ldt = xen_free_ldt,
371
372- .store_idt = native_store_idt,
373 .store_tr = xen_store_tr,
374
375 .write_ldt_entry = xen_write_ldt_entry,
376diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
377index cab28cf2cffb..5f61b7e2e6b2 100644
378--- a/arch/x86/xen/mmu_pv.c
379+++ b/arch/x86/xen/mmu_pv.c
380@@ -2430,8 +2430,6 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
381 .flush_tlb_single = xen_flush_tlb_single,
382 .flush_tlb_others = xen_flush_tlb_others,
383
384- .pte_update = paravirt_nop,
385-
386 .pgd_alloc = xen_pgd_alloc,
387 .pgd_free = xen_pgd_free,
388
389--
3902.14.2
391