aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/paravirt.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/paravirt.c')
-rw-r--r--arch/x86/kernel/paravirt.c81
1 files changed, 67 insertions, 14 deletions
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index e4c8fb608873..6dc4dca255e4 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -44,6 +44,17 @@ void _paravirt_nop(void)
44{ 44{
45} 45}
46 46
47/* identity function, which can be inlined */
48u32 _paravirt_ident_32(u32 x)
49{
50 return x;
51}
52
53u64 _paravirt_ident_64(u64 x)
54{
55 return x;
56}
57
47static void __init default_banner(void) 58static void __init default_banner(void)
48{ 59{
49 printk(KERN_INFO "Booting paravirtualized kernel on %s\n", 60 printk(KERN_INFO "Booting paravirtualized kernel on %s\n",
@@ -138,9 +149,16 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
138 if (opfunc == NULL) 149 if (opfunc == NULL)
139 /* If there's no function, patch it with a ud2a (BUG) */ 150 /* If there's no function, patch it with a ud2a (BUG) */
140 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a)); 151 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
141 else if (opfunc == paravirt_nop) 152 else if (opfunc == _paravirt_nop)
142 /* If the operation is a nop, then nop the callsite */ 153 /* If the operation is a nop, then nop the callsite */
143 ret = paravirt_patch_nop(); 154 ret = paravirt_patch_nop();
155
156 /* identity functions just return their single argument */
157 else if (opfunc == _paravirt_ident_32)
158 ret = paravirt_patch_ident_32(insnbuf, len);
159 else if (opfunc == _paravirt_ident_64)
160 ret = paravirt_patch_ident_64(insnbuf, len);
161
144 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) || 162 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
145 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) || 163 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
146 type == PARAVIRT_PATCH(pv_cpu_ops.usergs_sysret32) || 164 type == PARAVIRT_PATCH(pv_cpu_ops.usergs_sysret32) ||
@@ -268,6 +286,32 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
268 return __get_cpu_var(paravirt_lazy_mode); 286 return __get_cpu_var(paravirt_lazy_mode);
269} 287}
270 288
289void arch_flush_lazy_mmu_mode(void)
290{
291 preempt_disable();
292
293 if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU) {
294 WARN_ON(preempt_count() == 1);
295 arch_leave_lazy_mmu_mode();
296 arch_enter_lazy_mmu_mode();
297 }
298
299 preempt_enable();
300}
301
302void arch_flush_lazy_cpu_mode(void)
303{
304 preempt_disable();
305
306 if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_CPU) {
307 WARN_ON(preempt_count() == 1);
308 arch_leave_lazy_cpu_mode();
309 arch_enter_lazy_cpu_mode();
310 }
311
312 preempt_enable();
313}
314
271struct pv_info pv_info = { 315struct pv_info pv_info = {
272 .name = "bare hardware", 316 .name = "bare hardware",
273 .paravirt_enabled = 0, 317 .paravirt_enabled = 0,
@@ -292,10 +336,10 @@ struct pv_time_ops pv_time_ops = {
292 336
293struct pv_irq_ops pv_irq_ops = { 337struct pv_irq_ops pv_irq_ops = {
294 .init_IRQ = native_init_IRQ, 338 .init_IRQ = native_init_IRQ,
295 .save_fl = native_save_fl, 339 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
296 .restore_fl = native_restore_fl, 340 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
297 .irq_disable = native_irq_disable, 341 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
298 .irq_enable = native_irq_enable, 342 .irq_enable = __PV_IS_CALLEE_SAVE(native_irq_enable),
299 .safe_halt = native_safe_halt, 343 .safe_halt = native_safe_halt,
300 .halt = native_halt, 344 .halt = native_halt,
301#ifdef CONFIG_X86_64 345#ifdef CONFIG_X86_64
@@ -373,6 +417,14 @@ struct pv_apic_ops pv_apic_ops = {
373#endif 417#endif
374}; 418};
375 419
420#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
421/* 32-bit pagetable entries */
422#define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
423#else
424/* 64-bit pagetable entries */
425#define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
426#endif
427
376struct pv_mmu_ops pv_mmu_ops = { 428struct pv_mmu_ops pv_mmu_ops = {
377#ifndef CONFIG_X86_64 429#ifndef CONFIG_X86_64
378 .pagetable_setup_start = native_pagetable_setup_start, 430 .pagetable_setup_start = native_pagetable_setup_start,
@@ -424,22 +476,23 @@ struct pv_mmu_ops pv_mmu_ops = {
424 .pmd_clear = native_pmd_clear, 476 .pmd_clear = native_pmd_clear,
425#endif 477#endif
426 .set_pud = native_set_pud, 478 .set_pud = native_set_pud,
427 .pmd_val = native_pmd_val, 479
428 .make_pmd = native_make_pmd, 480 .pmd_val = PTE_IDENT,
481 .make_pmd = PTE_IDENT,
429 482
430#if PAGETABLE_LEVELS == 4 483#if PAGETABLE_LEVELS == 4
431 .pud_val = native_pud_val, 484 .pud_val = PTE_IDENT,
432 .make_pud = native_make_pud, 485 .make_pud = PTE_IDENT,
486
433 .set_pgd = native_set_pgd, 487 .set_pgd = native_set_pgd,
434#endif 488#endif
435#endif /* PAGETABLE_LEVELS >= 3 */ 489#endif /* PAGETABLE_LEVELS >= 3 */
436 490
437 .pte_val = native_pte_val, 491 .pte_val = PTE_IDENT,
438 .pte_flags = native_pte_flags, 492 .pgd_val = PTE_IDENT,
439 .pgd_val = native_pgd_val,
440 493
441 .make_pte = native_make_pte, 494 .make_pte = PTE_IDENT,
442 .make_pgd = native_make_pgd, 495 .make_pgd = PTE_IDENT,
443 496
444 .dup_mmap = paravirt_nop, 497 .dup_mmap = paravirt_nop,
445 .exit_mmap = paravirt_nop, 498 .exit_mmap = paravirt_nop,