.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* Paravirtualization interfaces |
---|
2 | 3 | Copyright (C) 2006 Rusty Russell IBM Corporation |
---|
3 | 4 | |
---|
4 | | - This program is free software; you can redistribute it and/or modify |
---|
5 | | - it under the terms of the GNU General Public License as published by |
---|
6 | | - the Free Software Foundation; either version 2 of the License, or |
---|
7 | | - (at your option) any later version. |
---|
8 | | - |
---|
9 | | - This program is distributed in the hope that it will be useful, |
---|
10 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | | - GNU General Public License for more details. |
---|
13 | | - |
---|
14 | | - You should have received a copy of the GNU General Public License |
---|
15 | | - along with this program; if not, write to the Free Software |
---|
16 | | - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
17 | 5 | |
---|
18 | 6 | 2007 - x86_64 support added by Glauber de Oliveira Costa, Red Hat Inc |
---|
19 | 7 | */ |
---|
.. | .. |
---|
25 | 13 | #include <linux/bcd.h> |
---|
26 | 14 | #include <linux/highmem.h> |
---|
27 | 15 | #include <linux/kprobes.h> |
---|
| 16 | +#include <linux/pgtable.h> |
---|
28 | 17 | |
---|
29 | 18 | #include <asm/bug.h> |
---|
30 | 19 | #include <asm/paravirt.h> |
---|
31 | 20 | #include <asm/debugreg.h> |
---|
32 | 21 | #include <asm/desc.h> |
---|
33 | 22 | #include <asm/setup.h> |
---|
34 | | -#include <asm/pgtable.h> |
---|
35 | 23 | #include <asm/time.h> |
---|
36 | 24 | #include <asm/pgalloc.h> |
---|
37 | 25 | #include <asm/irq.h> |
---|
.. | .. |
---|
42 | 30 | #include <asm/timer.h> |
---|
43 | 31 | #include <asm/special_insns.h> |
---|
44 | 32 | #include <asm/tlb.h> |
---|
| 33 | +#include <asm/io_bitmap.h> |
---|
45 | 34 | |
---|
46 | 35 | /* |
---|
47 | 36 | * nop stub, which must not clobber anything *including the stack* to |
---|
.. | .. |
---|
51 | 40 | asm (".pushsection .entry.text, \"ax\"\n" |
---|
52 | 41 | ".global _paravirt_nop\n" |
---|
53 | 42 | "_paravirt_nop:\n\t" |
---|
54 | | - "ret\n\t" |
---|
| 43 | + ASM_RET |
---|
55 | 44 | ".size _paravirt_nop, . - _paravirt_nop\n\t" |
---|
56 | 45 | ".type _paravirt_nop, @function\n\t" |
---|
57 | 46 | ".popsection"); |
---|
58 | | - |
---|
59 | | -/* identity function, which can be inlined */ |
---|
60 | | -u32 notrace _paravirt_ident_32(u32 x) |
---|
61 | | -{ |
---|
62 | | - return x; |
---|
63 | | -} |
---|
64 | | - |
---|
65 | | -u64 notrace _paravirt_ident_64(u64 x) |
---|
66 | | -{ |
---|
67 | | - return x; |
---|
68 | | -} |
---|
69 | 47 | |
---|
70 | 48 | void __init default_banner(void) |
---|
71 | 49 | { |
---|
.. | .. |
---|
81 | 59 | u32 delta; |
---|
82 | 60 | } __attribute__((packed)); |
---|
83 | 61 | |
---|
84 | | -unsigned paravirt_patch_call(void *insnbuf, |
---|
85 | | - const void *target, u16 tgt_clobbers, |
---|
86 | | - unsigned long addr, u16 site_clobbers, |
---|
87 | | - unsigned len) |
---|
| 62 | +static unsigned paravirt_patch_call(void *insn_buff, const void *target, |
---|
| 63 | + unsigned long addr, unsigned len) |
---|
88 | 64 | { |
---|
89 | | - struct branch *b = insnbuf; |
---|
90 | | - unsigned long delta = (unsigned long)target - (addr+5); |
---|
| 65 | + const int call_len = 5; |
---|
| 66 | + struct branch *b = insn_buff; |
---|
| 67 | + unsigned long delta = (unsigned long)target - (addr+call_len); |
---|
91 | 68 | |
---|
92 | | - if (len < 5) { |
---|
93 | | -#ifdef CONFIG_RETPOLINE |
---|
94 | | - WARN_ONCE(1, "Failing to patch indirect CALL in %ps\n", (void *)addr); |
---|
95 | | -#endif |
---|
96 | | - return len; /* call too long for patch site */ |
---|
| 69 | + if (len < call_len) { |
---|
| 70 | + pr_warn("paravirt: Failed to patch indirect CALL at %ps\n", (void *)addr); |
---|
| 71 | + /* Kernel might not be viable if patching fails, bail out: */ |
---|
| 72 | + BUG_ON(1); |
---|
97 | 73 | } |
---|
98 | 74 | |
---|
99 | 75 | b->opcode = 0xe8; /* call */ |
---|
100 | 76 | b->delta = delta; |
---|
101 | | - BUILD_BUG_ON(sizeof(*b) != 5); |
---|
| 77 | + BUILD_BUG_ON(sizeof(*b) != call_len); |
---|
102 | 78 | |
---|
103 | | - return 5; |
---|
| 79 | + return call_len; |
---|
104 | 80 | } |
---|
105 | 81 | |
---|
106 | | -unsigned paravirt_patch_jmp(void *insnbuf, const void *target, |
---|
107 | | - unsigned long addr, unsigned len) |
---|
| 82 | +#ifdef CONFIG_PARAVIRT_XXL |
---|
| 83 | +/* identity function, which can be inlined */ |
---|
| 84 | +u64 notrace _paravirt_ident_64(u64 x) |
---|
108 | 85 | { |
---|
109 | | - struct branch *b = insnbuf; |
---|
| 86 | + return x; |
---|
| 87 | +} |
---|
| 88 | + |
---|
| 89 | +static unsigned paravirt_patch_jmp(void *insn_buff, const void *target, |
---|
| 90 | + unsigned long addr, unsigned len) |
---|
| 91 | +{ |
---|
| 92 | + struct branch *b = insn_buff; |
---|
110 | 93 | unsigned long delta = (unsigned long)target - (addr+5); |
---|
111 | 94 | |
---|
112 | 95 | if (len < 5) { |
---|
.. | .. |
---|
121 | 104 | |
---|
122 | 105 | return 5; |
---|
123 | 106 | } |
---|
| 107 | +#endif |
---|
124 | 108 | |
---|
125 | 109 | DEFINE_STATIC_KEY_TRUE(virt_spin_lock_key); |
---|
126 | 110 | |
---|
127 | 111 | void __init native_pv_lock_init(void) |
---|
128 | 112 | { |
---|
129 | | - if (!static_cpu_has(X86_FEATURE_HYPERVISOR)) |
---|
| 113 | + if (!boot_cpu_has(X86_FEATURE_HYPERVISOR)) |
---|
130 | 114 | static_branch_disable(&virt_spin_lock_key); |
---|
131 | 115 | } |
---|
132 | 116 | |
---|
133 | | -/* |
---|
134 | | - * Neat trick to map patch type back to the call within the |
---|
135 | | - * corresponding structure. |
---|
136 | | - */ |
---|
137 | | -static void *get_call_destination(u8 type) |
---|
138 | | -{ |
---|
139 | | - struct paravirt_patch_template tmpl = { |
---|
140 | | - .pv_init_ops = pv_init_ops, |
---|
141 | | - .pv_time_ops = pv_time_ops, |
---|
142 | | - .pv_cpu_ops = pv_cpu_ops, |
---|
143 | | - .pv_irq_ops = pv_irq_ops, |
---|
144 | | - .pv_mmu_ops = pv_mmu_ops, |
---|
145 | | -#ifdef CONFIG_PARAVIRT_SPINLOCKS |
---|
146 | | - .pv_lock_ops = pv_lock_ops, |
---|
147 | | -#endif |
---|
148 | | - }; |
---|
149 | | - return *((void **)&tmpl + type); |
---|
150 | | -} |
---|
151 | | - |
---|
152 | | -unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf, |
---|
| 117 | +unsigned paravirt_patch_default(u8 type, void *insn_buff, |
---|
153 | 118 | unsigned long addr, unsigned len) |
---|
154 | 119 | { |
---|
155 | | - void *opfunc = get_call_destination(type); |
---|
| 120 | + /* |
---|
| 121 | + * Neat trick to map patch type back to the call within the |
---|
| 122 | + * corresponding structure. |
---|
| 123 | + */ |
---|
| 124 | + void *opfunc = *((void **)&pv_ops + type); |
---|
156 | 125 | unsigned ret; |
---|
157 | 126 | |
---|
158 | 127 | if (opfunc == NULL) |
---|
159 | 128 | /* If there's no function, patch it with a ud2a (BUG) */ |
---|
160 | | - ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a)); |
---|
| 129 | + ret = paravirt_patch_insns(insn_buff, len, ud2a, ud2a+sizeof(ud2a)); |
---|
161 | 130 | else if (opfunc == _paravirt_nop) |
---|
162 | 131 | ret = 0; |
---|
163 | 132 | |
---|
| 133 | +#ifdef CONFIG_PARAVIRT_XXL |
---|
164 | 134 | /* identity functions just return their single argument */ |
---|
165 | | - else if (opfunc == _paravirt_ident_32) |
---|
166 | | - ret = paravirt_patch_ident_32(insnbuf, len); |
---|
167 | 135 | else if (opfunc == _paravirt_ident_64) |
---|
168 | | - ret = paravirt_patch_ident_64(insnbuf, len); |
---|
| 136 | + ret = paravirt_patch_ident_64(insn_buff, len); |
---|
169 | 137 | |
---|
170 | | - else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) || |
---|
171 | | - type == PARAVIRT_PATCH(pv_cpu_ops.usergs_sysret64)) |
---|
| 138 | + else if (type == PARAVIRT_PATCH(cpu.iret) || |
---|
| 139 | + type == PARAVIRT_PATCH(cpu.usergs_sysret64)) |
---|
172 | 140 | /* If operation requires a jmp, then jmp */ |
---|
173 | | - ret = paravirt_patch_jmp(insnbuf, opfunc, addr, len); |
---|
| 141 | + ret = paravirt_patch_jmp(insn_buff, opfunc, addr, len); |
---|
| 142 | +#endif |
---|
174 | 143 | else |
---|
175 | | - /* Otherwise call the function; assume target could |
---|
176 | | - clobber any caller-save reg */ |
---|
177 | | - ret = paravirt_patch_call(insnbuf, opfunc, CLBR_ANY, |
---|
178 | | - addr, clobbers, len); |
---|
| 144 | + /* Otherwise call the function. */ |
---|
| 145 | + ret = paravirt_patch_call(insn_buff, opfunc, addr, len); |
---|
179 | 146 | |
---|
180 | 147 | return ret; |
---|
181 | 148 | } |
---|
182 | 149 | |
---|
183 | | -unsigned paravirt_patch_insns(void *insnbuf, unsigned len, |
---|
| 150 | +unsigned paravirt_patch_insns(void *insn_buff, unsigned len, |
---|
184 | 151 | const char *start, const char *end) |
---|
185 | 152 | { |
---|
186 | 153 | unsigned insn_len = end - start; |
---|
187 | 154 | |
---|
188 | | - if (insn_len > len || start == NULL) |
---|
189 | | - insn_len = len; |
---|
190 | | - else |
---|
191 | | - memcpy(insnbuf, start, insn_len); |
---|
| 155 | + /* Alternative instruction is too large for the patch site and we cannot continue: */ |
---|
| 156 | + BUG_ON(insn_len > len || start == NULL); |
---|
| 157 | + |
---|
| 158 | + memcpy(insn_buff, start, insn_len); |
---|
192 | 159 | |
---|
193 | 160 | return insn_len; |
---|
194 | | -} |
---|
195 | | - |
---|
196 | | -static void native_flush_tlb(void) |
---|
197 | | -{ |
---|
198 | | - __native_flush_tlb(); |
---|
199 | | -} |
---|
200 | | - |
---|
201 | | -/* |
---|
202 | | - * Global pages have to be flushed a bit differently. Not a real |
---|
203 | | - * performance problem because this does not happen often. |
---|
204 | | - */ |
---|
205 | | -static void native_flush_tlb_global(void) |
---|
206 | | -{ |
---|
207 | | - __native_flush_tlb_global(); |
---|
208 | | -} |
---|
209 | | - |
---|
210 | | -static void native_flush_tlb_one_user(unsigned long addr) |
---|
211 | | -{ |
---|
212 | | - __native_flush_tlb_one_user(addr); |
---|
213 | 161 | } |
---|
214 | 162 | |
---|
215 | 163 | struct static_key paravirt_steal_enabled; |
---|
.. | .. |
---|
281 | 229 | preempt_enable(); |
---|
282 | 230 | } |
---|
283 | 231 | |
---|
| 232 | +#ifdef CONFIG_PARAVIRT_XXL |
---|
284 | 233 | void paravirt_start_context_switch(struct task_struct *prev) |
---|
285 | 234 | { |
---|
286 | 235 | BUG_ON(preemptible()); |
---|
.. | .. |
---|
301 | 250 | if (test_and_clear_ti_thread_flag(task_thread_info(next), TIF_LAZY_MMU_UPDATES)) |
---|
302 | 251 | arch_enter_lazy_mmu_mode(); |
---|
303 | 252 | } |
---|
| 253 | +#endif |
---|
304 | 254 | |
---|
305 | 255 | enum paravirt_lazy_mode paravirt_get_lazy_mode(void) |
---|
306 | 256 | { |
---|
.. | .. |
---|
312 | 262 | |
---|
313 | 263 | struct pv_info pv_info = { |
---|
314 | 264 | .name = "bare hardware", |
---|
315 | | - .kernel_rpl = 0, |
---|
316 | | - .shared_kernel_pmd = 1, /* Only used when CONFIG_X86_PAE is set */ |
---|
317 | | - |
---|
318 | | -#ifdef CONFIG_X86_64 |
---|
| 265 | +#ifdef CONFIG_PARAVIRT_XXL |
---|
319 | 266 | .extra_user_64bit_cs = __USER_CS, |
---|
320 | 267 | #endif |
---|
321 | 268 | }; |
---|
322 | 269 | |
---|
323 | | -struct pv_init_ops pv_init_ops = { |
---|
324 | | - .patch = native_patch, |
---|
325 | | -}; |
---|
| 270 | +/* 64-bit pagetable entries */ |
---|
| 271 | +#define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64) |
---|
326 | 272 | |
---|
327 | | -struct pv_time_ops pv_time_ops = { |
---|
328 | | - .sched_clock = native_sched_clock, |
---|
329 | | - .steal_clock = native_steal_clock, |
---|
330 | | -}; |
---|
| 273 | +struct paravirt_patch_template pv_ops = { |
---|
| 274 | + /* Init ops. */ |
---|
| 275 | + .init.patch = native_patch, |
---|
331 | 276 | |
---|
332 | | -__visible struct pv_irq_ops pv_irq_ops = { |
---|
333 | | - .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl), |
---|
334 | | - .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl), |
---|
335 | | - .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable), |
---|
336 | | - .irq_enable = __PV_IS_CALLEE_SAVE(native_irq_enable), |
---|
337 | | - .safe_halt = native_safe_halt, |
---|
338 | | - .halt = native_halt, |
---|
339 | | -}; |
---|
| 277 | + /* Time ops. */ |
---|
| 278 | + .time.sched_clock = native_sched_clock, |
---|
| 279 | + .time.steal_clock = native_steal_clock, |
---|
340 | 280 | |
---|
341 | | -__visible struct pv_cpu_ops pv_cpu_ops = { |
---|
342 | | - .cpuid = native_cpuid, |
---|
343 | | - .get_debugreg = native_get_debugreg, |
---|
344 | | - .set_debugreg = native_set_debugreg, |
---|
345 | | - .read_cr0 = native_read_cr0, |
---|
346 | | - .write_cr0 = native_write_cr0, |
---|
347 | | - .write_cr4 = native_write_cr4, |
---|
348 | | -#ifdef CONFIG_X86_64 |
---|
349 | | - .read_cr8 = native_read_cr8, |
---|
350 | | - .write_cr8 = native_write_cr8, |
---|
| 281 | + /* Cpu ops. */ |
---|
| 282 | + .cpu.io_delay = native_io_delay, |
---|
| 283 | + |
---|
| 284 | +#ifdef CONFIG_PARAVIRT_XXL |
---|
| 285 | + .cpu.cpuid = native_cpuid, |
---|
| 286 | + .cpu.get_debugreg = native_get_debugreg, |
---|
| 287 | + .cpu.set_debugreg = native_set_debugreg, |
---|
| 288 | + .cpu.read_cr0 = native_read_cr0, |
---|
| 289 | + .cpu.write_cr0 = native_write_cr0, |
---|
| 290 | + .cpu.write_cr4 = native_write_cr4, |
---|
| 291 | + .cpu.wbinvd = native_wbinvd, |
---|
| 292 | + .cpu.read_msr = native_read_msr, |
---|
| 293 | + .cpu.write_msr = native_write_msr, |
---|
| 294 | + .cpu.read_msr_safe = native_read_msr_safe, |
---|
| 295 | + .cpu.write_msr_safe = native_write_msr_safe, |
---|
| 296 | + .cpu.read_pmc = native_read_pmc, |
---|
| 297 | + .cpu.load_tr_desc = native_load_tr_desc, |
---|
| 298 | + .cpu.set_ldt = native_set_ldt, |
---|
| 299 | + .cpu.load_gdt = native_load_gdt, |
---|
| 300 | + .cpu.load_idt = native_load_idt, |
---|
| 301 | + .cpu.store_tr = native_store_tr, |
---|
| 302 | + .cpu.load_tls = native_load_tls, |
---|
| 303 | + .cpu.load_gs_index = native_load_gs_index, |
---|
| 304 | + .cpu.write_ldt_entry = native_write_ldt_entry, |
---|
| 305 | + .cpu.write_gdt_entry = native_write_gdt_entry, |
---|
| 306 | + .cpu.write_idt_entry = native_write_idt_entry, |
---|
| 307 | + |
---|
| 308 | + .cpu.alloc_ldt = paravirt_nop, |
---|
| 309 | + .cpu.free_ldt = paravirt_nop, |
---|
| 310 | + |
---|
| 311 | + .cpu.load_sp0 = native_load_sp0, |
---|
| 312 | + |
---|
| 313 | + .cpu.usergs_sysret64 = native_usergs_sysret64, |
---|
| 314 | + .cpu.iret = native_iret, |
---|
| 315 | + |
---|
| 316 | +#ifdef CONFIG_X86_IOPL_IOPERM |
---|
| 317 | + .cpu.invalidate_io_bitmap = native_tss_invalidate_io_bitmap, |
---|
| 318 | + .cpu.update_io_bitmap = native_tss_update_io_bitmap, |
---|
351 | 319 | #endif |
---|
352 | | - .wbinvd = native_wbinvd, |
---|
353 | | - .read_msr = native_read_msr, |
---|
354 | | - .write_msr = native_write_msr, |
---|
355 | | - .read_msr_safe = native_read_msr_safe, |
---|
356 | | - .write_msr_safe = native_write_msr_safe, |
---|
357 | | - .read_pmc = native_read_pmc, |
---|
358 | | - .load_tr_desc = native_load_tr_desc, |
---|
359 | | - .set_ldt = native_set_ldt, |
---|
360 | | - .load_gdt = native_load_gdt, |
---|
361 | | - .load_idt = native_load_idt, |
---|
362 | | - .store_tr = native_store_tr, |
---|
363 | | - .load_tls = native_load_tls, |
---|
364 | | -#ifdef CONFIG_X86_64 |
---|
365 | | - .load_gs_index = native_load_gs_index, |
---|
| 320 | + |
---|
| 321 | + .cpu.start_context_switch = paravirt_nop, |
---|
| 322 | + .cpu.end_context_switch = paravirt_nop, |
---|
| 323 | + |
---|
| 324 | + /* Irq ops. */ |
---|
| 325 | + .irq.save_fl = __PV_IS_CALLEE_SAVE(native_save_fl), |
---|
| 326 | + .irq.restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl), |
---|
| 327 | + .irq.irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable), |
---|
| 328 | + .irq.irq_enable = __PV_IS_CALLEE_SAVE(native_irq_enable), |
---|
| 329 | + .irq.safe_halt = native_safe_halt, |
---|
| 330 | + .irq.halt = native_halt, |
---|
| 331 | +#endif /* CONFIG_PARAVIRT_XXL */ |
---|
| 332 | + |
---|
| 333 | + /* Mmu ops. */ |
---|
| 334 | + .mmu.flush_tlb_user = native_flush_tlb_local, |
---|
| 335 | + .mmu.flush_tlb_kernel = native_flush_tlb_global, |
---|
| 336 | + .mmu.flush_tlb_one_user = native_flush_tlb_one_user, |
---|
| 337 | + .mmu.flush_tlb_others = native_flush_tlb_others, |
---|
| 338 | + .mmu.tlb_remove_table = |
---|
| 339 | + (void (*)(struct mmu_gather *, void *))tlb_remove_page, |
---|
| 340 | + |
---|
| 341 | + .mmu.exit_mmap = paravirt_nop, |
---|
| 342 | + |
---|
| 343 | +#ifdef CONFIG_PARAVIRT_XXL |
---|
| 344 | + .mmu.read_cr2 = __PV_IS_CALLEE_SAVE(native_read_cr2), |
---|
| 345 | + .mmu.write_cr2 = native_write_cr2, |
---|
| 346 | + .mmu.read_cr3 = __native_read_cr3, |
---|
| 347 | + .mmu.write_cr3 = native_write_cr3, |
---|
| 348 | + |
---|
| 349 | + .mmu.pgd_alloc = __paravirt_pgd_alloc, |
---|
| 350 | + .mmu.pgd_free = paravirt_nop, |
---|
| 351 | + |
---|
| 352 | + .mmu.alloc_pte = paravirt_nop, |
---|
| 353 | + .mmu.alloc_pmd = paravirt_nop, |
---|
| 354 | + .mmu.alloc_pud = paravirt_nop, |
---|
| 355 | + .mmu.alloc_p4d = paravirt_nop, |
---|
| 356 | + .mmu.release_pte = paravirt_nop, |
---|
| 357 | + .mmu.release_pmd = paravirt_nop, |
---|
| 358 | + .mmu.release_pud = paravirt_nop, |
---|
| 359 | + .mmu.release_p4d = paravirt_nop, |
---|
| 360 | + |
---|
| 361 | + .mmu.set_pte = native_set_pte, |
---|
| 362 | + .mmu.set_pmd = native_set_pmd, |
---|
| 363 | + |
---|
| 364 | + .mmu.ptep_modify_prot_start = __ptep_modify_prot_start, |
---|
| 365 | + .mmu.ptep_modify_prot_commit = __ptep_modify_prot_commit, |
---|
| 366 | + |
---|
| 367 | + .mmu.set_pud = native_set_pud, |
---|
| 368 | + |
---|
| 369 | + .mmu.pmd_val = PTE_IDENT, |
---|
| 370 | + .mmu.make_pmd = PTE_IDENT, |
---|
| 371 | + |
---|
| 372 | + .mmu.pud_val = PTE_IDENT, |
---|
| 373 | + .mmu.make_pud = PTE_IDENT, |
---|
| 374 | + |
---|
| 375 | + .mmu.set_p4d = native_set_p4d, |
---|
| 376 | + |
---|
| 377 | +#if CONFIG_PGTABLE_LEVELS >= 5 |
---|
| 378 | + .mmu.p4d_val = PTE_IDENT, |
---|
| 379 | + .mmu.make_p4d = PTE_IDENT, |
---|
| 380 | + |
---|
| 381 | + .mmu.set_pgd = native_set_pgd, |
---|
| 382 | +#endif /* CONFIG_PGTABLE_LEVELS >= 5 */ |
---|
| 383 | + |
---|
| 384 | + .mmu.pte_val = PTE_IDENT, |
---|
| 385 | + .mmu.pgd_val = PTE_IDENT, |
---|
| 386 | + |
---|
| 387 | + .mmu.make_pte = PTE_IDENT, |
---|
| 388 | + .mmu.make_pgd = PTE_IDENT, |
---|
| 389 | + |
---|
| 390 | + .mmu.dup_mmap = paravirt_nop, |
---|
| 391 | + .mmu.activate_mm = paravirt_nop, |
---|
| 392 | + |
---|
| 393 | + .mmu.lazy_mode = { |
---|
| 394 | + .enter = paravirt_nop, |
---|
| 395 | + .leave = paravirt_nop, |
---|
| 396 | + .flush = paravirt_nop, |
---|
| 397 | + }, |
---|
| 398 | + |
---|
| 399 | + .mmu.set_fixmap = native_set_fixmap, |
---|
| 400 | +#endif /* CONFIG_PARAVIRT_XXL */ |
---|
| 401 | + |
---|
| 402 | +#if defined(CONFIG_PARAVIRT_SPINLOCKS) |
---|
| 403 | + /* Lock ops. */ |
---|
| 404 | +#ifdef CONFIG_SMP |
---|
| 405 | + .lock.queued_spin_lock_slowpath = native_queued_spin_lock_slowpath, |
---|
| 406 | + .lock.queued_spin_unlock = |
---|
| 407 | + PV_CALLEE_SAVE(__native_queued_spin_unlock), |
---|
| 408 | + .lock.wait = paravirt_nop, |
---|
| 409 | + .lock.kick = paravirt_nop, |
---|
| 410 | + .lock.vcpu_is_preempted = |
---|
| 411 | + PV_CALLEE_SAVE(__native_vcpu_is_preempted), |
---|
| 412 | +#endif /* SMP */ |
---|
366 | 413 | #endif |
---|
367 | | - .write_ldt_entry = native_write_ldt_entry, |
---|
368 | | - .write_gdt_entry = native_write_gdt_entry, |
---|
369 | | - .write_idt_entry = native_write_idt_entry, |
---|
370 | | - |
---|
371 | | - .alloc_ldt = paravirt_nop, |
---|
372 | | - .free_ldt = paravirt_nop, |
---|
373 | | - |
---|
374 | | - .load_sp0 = native_load_sp0, |
---|
375 | | - |
---|
376 | | -#ifdef CONFIG_X86_64 |
---|
377 | | - .usergs_sysret64 = native_usergs_sysret64, |
---|
378 | | -#endif |
---|
379 | | - .iret = native_iret, |
---|
380 | | - .swapgs = native_swapgs, |
---|
381 | | - |
---|
382 | | - .set_iopl_mask = native_set_iopl_mask, |
---|
383 | | - .io_delay = native_io_delay, |
---|
384 | | - |
---|
385 | | - .start_context_switch = paravirt_nop, |
---|
386 | | - .end_context_switch = paravirt_nop, |
---|
387 | 414 | }; |
---|
388 | 415 | |
---|
| 416 | +#ifdef CONFIG_PARAVIRT_XXL |
---|
389 | 417 | /* At this point, native_get/set_debugreg has real function entries */ |
---|
390 | 418 | NOKPROBE_SYMBOL(native_get_debugreg); |
---|
391 | 419 | NOKPROBE_SYMBOL(native_set_debugreg); |
---|
392 | 420 | NOKPROBE_SYMBOL(native_load_idt); |
---|
393 | | - |
---|
394 | | -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE) |
---|
395 | | -/* 32-bit pagetable entries */ |
---|
396 | | -#define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32) |
---|
397 | | -#else |
---|
398 | | -/* 64-bit pagetable entries */ |
---|
399 | | -#define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64) |
---|
400 | 421 | #endif |
---|
401 | 422 | |
---|
402 | | -struct pv_mmu_ops pv_mmu_ops __ro_after_init = { |
---|
403 | | - |
---|
404 | | - .read_cr2 = native_read_cr2, |
---|
405 | | - .write_cr2 = native_write_cr2, |
---|
406 | | - .read_cr3 = __native_read_cr3, |
---|
407 | | - .write_cr3 = native_write_cr3, |
---|
408 | | - |
---|
409 | | - .flush_tlb_user = native_flush_tlb, |
---|
410 | | - .flush_tlb_kernel = native_flush_tlb_global, |
---|
411 | | - .flush_tlb_one_user = native_flush_tlb_one_user, |
---|
412 | | - .flush_tlb_others = native_flush_tlb_others, |
---|
413 | | - .tlb_remove_table = (void (*)(struct mmu_gather *, void *))tlb_remove_page, |
---|
414 | | - |
---|
415 | | - .pgd_alloc = __paravirt_pgd_alloc, |
---|
416 | | - .pgd_free = paravirt_nop, |
---|
417 | | - |
---|
418 | | - .alloc_pte = paravirt_nop, |
---|
419 | | - .alloc_pmd = paravirt_nop, |
---|
420 | | - .alloc_pud = paravirt_nop, |
---|
421 | | - .alloc_p4d = paravirt_nop, |
---|
422 | | - .release_pte = paravirt_nop, |
---|
423 | | - .release_pmd = paravirt_nop, |
---|
424 | | - .release_pud = paravirt_nop, |
---|
425 | | - .release_p4d = paravirt_nop, |
---|
426 | | - |
---|
427 | | - .set_pte = native_set_pte, |
---|
428 | | - .set_pte_at = native_set_pte_at, |
---|
429 | | - .set_pmd = native_set_pmd, |
---|
430 | | - |
---|
431 | | - .ptep_modify_prot_start = __ptep_modify_prot_start, |
---|
432 | | - .ptep_modify_prot_commit = __ptep_modify_prot_commit, |
---|
433 | | - |
---|
434 | | -#if CONFIG_PGTABLE_LEVELS >= 3 |
---|
435 | | -#ifdef CONFIG_X86_PAE |
---|
436 | | - .set_pte_atomic = native_set_pte_atomic, |
---|
437 | | - .pte_clear = native_pte_clear, |
---|
438 | | - .pmd_clear = native_pmd_clear, |
---|
439 | | -#endif |
---|
440 | | - .set_pud = native_set_pud, |
---|
441 | | - |
---|
442 | | - .pmd_val = PTE_IDENT, |
---|
443 | | - .make_pmd = PTE_IDENT, |
---|
444 | | - |
---|
445 | | -#if CONFIG_PGTABLE_LEVELS >= 4 |
---|
446 | | - .pud_val = PTE_IDENT, |
---|
447 | | - .make_pud = PTE_IDENT, |
---|
448 | | - |
---|
449 | | - .set_p4d = native_set_p4d, |
---|
450 | | - |
---|
451 | | -#if CONFIG_PGTABLE_LEVELS >= 5 |
---|
452 | | - .p4d_val = PTE_IDENT, |
---|
453 | | - .make_p4d = PTE_IDENT, |
---|
454 | | - |
---|
455 | | - .set_pgd = native_set_pgd, |
---|
456 | | -#endif /* CONFIG_PGTABLE_LEVELS >= 5 */ |
---|
457 | | -#endif /* CONFIG_PGTABLE_LEVELS >= 4 */ |
---|
458 | | -#endif /* CONFIG_PGTABLE_LEVELS >= 3 */ |
---|
459 | | - |
---|
460 | | - .pte_val = PTE_IDENT, |
---|
461 | | - .pgd_val = PTE_IDENT, |
---|
462 | | - |
---|
463 | | - .make_pte = PTE_IDENT, |
---|
464 | | - .make_pgd = PTE_IDENT, |
---|
465 | | - |
---|
466 | | - .dup_mmap = paravirt_nop, |
---|
467 | | - .exit_mmap = paravirt_nop, |
---|
468 | | - .activate_mm = paravirt_nop, |
---|
469 | | - |
---|
470 | | - .lazy_mode = { |
---|
471 | | - .enter = paravirt_nop, |
---|
472 | | - .leave = paravirt_nop, |
---|
473 | | - .flush = paravirt_nop, |
---|
474 | | - }, |
---|
475 | | - |
---|
476 | | - .set_fixmap = native_set_fixmap, |
---|
477 | | -}; |
---|
478 | | - |
---|
479 | | -EXPORT_SYMBOL_GPL(pv_time_ops); |
---|
480 | | -EXPORT_SYMBOL (pv_cpu_ops); |
---|
481 | | -EXPORT_SYMBOL (pv_mmu_ops); |
---|
| 423 | +EXPORT_SYMBOL(pv_ops); |
---|
482 | 424 | EXPORT_SYMBOL_GPL(pv_info); |
---|
483 | | -EXPORT_SYMBOL (pv_irq_ops); |
---|