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