WIP FPC-III support
[linux/fpc-iii.git] / arch / x86 / include / asm / paravirt.h
blobf8dce11d2bc1a175d88276315d65830b3ca62edb
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_PARAVIRT_H
3 #define _ASM_X86_PARAVIRT_H
4 /* Various instructions on x86 need to be replaced for
5 * para-virtualization: those hooks are defined here. */
7 #ifdef CONFIG_PARAVIRT
8 #include <asm/pgtable_types.h>
9 #include <asm/asm.h>
10 #include <asm/nospec-branch.h>
12 #include <asm/paravirt_types.h>
14 #ifndef __ASSEMBLY__
15 #include <linux/bug.h>
16 #include <linux/types.h>
17 #include <linux/cpumask.h>
18 #include <asm/frame.h>
20 static inline unsigned long long paravirt_sched_clock(void)
22 return PVOP_CALL0(unsigned long long, time.sched_clock);
25 struct static_key;
26 extern struct static_key paravirt_steal_enabled;
27 extern struct static_key paravirt_steal_rq_enabled;
29 __visible void __native_queued_spin_unlock(struct qspinlock *lock);
30 bool pv_is_native_spin_unlock(void);
31 __visible bool __native_vcpu_is_preempted(long cpu);
32 bool pv_is_native_vcpu_is_preempted(void);
34 static inline u64 paravirt_steal_clock(int cpu)
36 return PVOP_CALL1(u64, time.steal_clock, cpu);
39 /* The paravirtualized I/O functions */
40 static inline void slow_down_io(void)
42 pv_ops.cpu.io_delay();
43 #ifdef REALLY_SLOW_IO
44 pv_ops.cpu.io_delay();
45 pv_ops.cpu.io_delay();
46 pv_ops.cpu.io_delay();
47 #endif
50 void native_flush_tlb_local(void);
51 void native_flush_tlb_global(void);
52 void native_flush_tlb_one_user(unsigned long addr);
53 void native_flush_tlb_others(const struct cpumask *cpumask,
54 const struct flush_tlb_info *info);
56 static inline void __flush_tlb_local(void)
58 PVOP_VCALL0(mmu.flush_tlb_user);
61 static inline void __flush_tlb_global(void)
63 PVOP_VCALL0(mmu.flush_tlb_kernel);
66 static inline void __flush_tlb_one_user(unsigned long addr)
68 PVOP_VCALL1(mmu.flush_tlb_one_user, addr);
71 static inline void __flush_tlb_others(const struct cpumask *cpumask,
72 const struct flush_tlb_info *info)
74 PVOP_VCALL2(mmu.flush_tlb_others, cpumask, info);
77 static inline void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table)
79 PVOP_VCALL2(mmu.tlb_remove_table, tlb, table);
82 static inline void paravirt_arch_exit_mmap(struct mm_struct *mm)
84 PVOP_VCALL1(mmu.exit_mmap, mm);
87 #ifdef CONFIG_PARAVIRT_XXL
88 static inline void load_sp0(unsigned long sp0)
90 PVOP_VCALL1(cpu.load_sp0, sp0);
93 /* The paravirtualized CPUID instruction. */
94 static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
95 unsigned int *ecx, unsigned int *edx)
97 PVOP_VCALL4(cpu.cpuid, eax, ebx, ecx, edx);
101 * These special macros can be used to get or set a debugging register
103 static inline unsigned long paravirt_get_debugreg(int reg)
105 return PVOP_CALL1(unsigned long, cpu.get_debugreg, reg);
107 #define get_debugreg(var, reg) var = paravirt_get_debugreg(reg)
108 static inline void set_debugreg(unsigned long val, int reg)
110 PVOP_VCALL2(cpu.set_debugreg, reg, val);
113 static inline unsigned long read_cr0(void)
115 return PVOP_CALL0(unsigned long, cpu.read_cr0);
118 static inline void write_cr0(unsigned long x)
120 PVOP_VCALL1(cpu.write_cr0, x);
123 static inline unsigned long read_cr2(void)
125 return PVOP_CALLEE0(unsigned long, mmu.read_cr2);
128 static inline void write_cr2(unsigned long x)
130 PVOP_VCALL1(mmu.write_cr2, x);
133 static inline unsigned long __read_cr3(void)
135 return PVOP_CALL0(unsigned long, mmu.read_cr3);
138 static inline void write_cr3(unsigned long x)
140 PVOP_VCALL1(mmu.write_cr3, x);
143 static inline void __write_cr4(unsigned long x)
145 PVOP_VCALL1(cpu.write_cr4, x);
148 static inline void arch_safe_halt(void)
150 PVOP_VCALL0(irq.safe_halt);
153 static inline void halt(void)
155 PVOP_VCALL0(irq.halt);
158 static inline void wbinvd(void)
160 PVOP_VCALL0(cpu.wbinvd);
163 static inline u64 paravirt_read_msr(unsigned msr)
165 return PVOP_CALL1(u64, cpu.read_msr, msr);
168 static inline void paravirt_write_msr(unsigned msr,
169 unsigned low, unsigned high)
171 PVOP_VCALL3(cpu.write_msr, msr, low, high);
174 static inline u64 paravirt_read_msr_safe(unsigned msr, int *err)
176 return PVOP_CALL2(u64, cpu.read_msr_safe, msr, err);
179 static inline int paravirt_write_msr_safe(unsigned msr,
180 unsigned low, unsigned high)
182 return PVOP_CALL3(int, cpu.write_msr_safe, msr, low, high);
185 #define rdmsr(msr, val1, val2) \
186 do { \
187 u64 _l = paravirt_read_msr(msr); \
188 val1 = (u32)_l; \
189 val2 = _l >> 32; \
190 } while (0)
192 #define wrmsr(msr, val1, val2) \
193 do { \
194 paravirt_write_msr(msr, val1, val2); \
195 } while (0)
197 #define rdmsrl(msr, val) \
198 do { \
199 val = paravirt_read_msr(msr); \
200 } while (0)
202 static inline void wrmsrl(unsigned msr, u64 val)
204 wrmsr(msr, (u32)val, (u32)(val>>32));
207 #define wrmsr_safe(msr, a, b) paravirt_write_msr_safe(msr, a, b)
209 /* rdmsr with exception handling */
210 #define rdmsr_safe(msr, a, b) \
211 ({ \
212 int _err; \
213 u64 _l = paravirt_read_msr_safe(msr, &_err); \
214 (*a) = (u32)_l; \
215 (*b) = _l >> 32; \
216 _err; \
219 static inline int rdmsrl_safe(unsigned msr, unsigned long long *p)
221 int err;
223 *p = paravirt_read_msr_safe(msr, &err);
224 return err;
227 static inline unsigned long long paravirt_read_pmc(int counter)
229 return PVOP_CALL1(u64, cpu.read_pmc, counter);
232 #define rdpmc(counter, low, high) \
233 do { \
234 u64 _l = paravirt_read_pmc(counter); \
235 low = (u32)_l; \
236 high = _l >> 32; \
237 } while (0)
239 #define rdpmcl(counter, val) ((val) = paravirt_read_pmc(counter))
241 static inline void paravirt_alloc_ldt(struct desc_struct *ldt, unsigned entries)
243 PVOP_VCALL2(cpu.alloc_ldt, ldt, entries);
246 static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
248 PVOP_VCALL2(cpu.free_ldt, ldt, entries);
251 static inline void load_TR_desc(void)
253 PVOP_VCALL0(cpu.load_tr_desc);
255 static inline void load_gdt(const struct desc_ptr *dtr)
257 PVOP_VCALL1(cpu.load_gdt, dtr);
259 static inline void load_idt(const struct desc_ptr *dtr)
261 PVOP_VCALL1(cpu.load_idt, dtr);
263 static inline void set_ldt(const void *addr, unsigned entries)
265 PVOP_VCALL2(cpu.set_ldt, addr, entries);
267 static inline unsigned long paravirt_store_tr(void)
269 return PVOP_CALL0(unsigned long, cpu.store_tr);
272 #define store_tr(tr) ((tr) = paravirt_store_tr())
273 static inline void load_TLS(struct thread_struct *t, unsigned cpu)
275 PVOP_VCALL2(cpu.load_tls, t, cpu);
278 static inline void load_gs_index(unsigned int gs)
280 PVOP_VCALL1(cpu.load_gs_index, gs);
283 static inline void write_ldt_entry(struct desc_struct *dt, int entry,
284 const void *desc)
286 PVOP_VCALL3(cpu.write_ldt_entry, dt, entry, desc);
289 static inline void write_gdt_entry(struct desc_struct *dt, int entry,
290 void *desc, int type)
292 PVOP_VCALL4(cpu.write_gdt_entry, dt, entry, desc, type);
295 static inline void write_idt_entry(gate_desc *dt, int entry, const gate_desc *g)
297 PVOP_VCALL3(cpu.write_idt_entry, dt, entry, g);
300 #ifdef CONFIG_X86_IOPL_IOPERM
301 static inline void tss_invalidate_io_bitmap(void)
303 PVOP_VCALL0(cpu.invalidate_io_bitmap);
306 static inline void tss_update_io_bitmap(void)
308 PVOP_VCALL0(cpu.update_io_bitmap);
310 #endif
312 static inline void paravirt_activate_mm(struct mm_struct *prev,
313 struct mm_struct *next)
315 PVOP_VCALL2(mmu.activate_mm, prev, next);
318 static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm,
319 struct mm_struct *mm)
321 PVOP_VCALL2(mmu.dup_mmap, oldmm, mm);
324 static inline int paravirt_pgd_alloc(struct mm_struct *mm)
326 return PVOP_CALL1(int, mmu.pgd_alloc, mm);
329 static inline void paravirt_pgd_free(struct mm_struct *mm, pgd_t *pgd)
331 PVOP_VCALL2(mmu.pgd_free, mm, pgd);
334 static inline void paravirt_alloc_pte(struct mm_struct *mm, unsigned long pfn)
336 PVOP_VCALL2(mmu.alloc_pte, mm, pfn);
338 static inline void paravirt_release_pte(unsigned long pfn)
340 PVOP_VCALL1(mmu.release_pte, pfn);
343 static inline void paravirt_alloc_pmd(struct mm_struct *mm, unsigned long pfn)
345 PVOP_VCALL2(mmu.alloc_pmd, mm, pfn);
348 static inline void paravirt_release_pmd(unsigned long pfn)
350 PVOP_VCALL1(mmu.release_pmd, pfn);
353 static inline void paravirt_alloc_pud(struct mm_struct *mm, unsigned long pfn)
355 PVOP_VCALL2(mmu.alloc_pud, mm, pfn);
357 static inline void paravirt_release_pud(unsigned long pfn)
359 PVOP_VCALL1(mmu.release_pud, pfn);
362 static inline void paravirt_alloc_p4d(struct mm_struct *mm, unsigned long pfn)
364 PVOP_VCALL2(mmu.alloc_p4d, mm, pfn);
367 static inline void paravirt_release_p4d(unsigned long pfn)
369 PVOP_VCALL1(mmu.release_p4d, pfn);
372 static inline pte_t __pte(pteval_t val)
374 return (pte_t) { PVOP_CALLEE1(pteval_t, mmu.make_pte, val) };
377 static inline pteval_t pte_val(pte_t pte)
379 return PVOP_CALLEE1(pteval_t, mmu.pte_val, pte.pte);
382 static inline pgd_t __pgd(pgdval_t val)
384 return (pgd_t) { PVOP_CALLEE1(pgdval_t, mmu.make_pgd, val) };
387 static inline pgdval_t pgd_val(pgd_t pgd)
389 return PVOP_CALLEE1(pgdval_t, mmu.pgd_val, pgd.pgd);
392 #define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION
393 static inline pte_t ptep_modify_prot_start(struct vm_area_struct *vma, unsigned long addr,
394 pte_t *ptep)
396 pteval_t ret;
398 ret = PVOP_CALL3(pteval_t, mmu.ptep_modify_prot_start, vma, addr, ptep);
400 return (pte_t) { .pte = ret };
403 static inline void ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr,
404 pte_t *ptep, pte_t old_pte, pte_t pte)
407 PVOP_VCALL4(mmu.ptep_modify_prot_commit, vma, addr, ptep, pte.pte);
410 static inline void set_pte(pte_t *ptep, pte_t pte)
412 PVOP_VCALL2(mmu.set_pte, ptep, pte.pte);
415 static inline void set_pmd(pmd_t *pmdp, pmd_t pmd)
417 PVOP_VCALL2(mmu.set_pmd, pmdp, native_pmd_val(pmd));
420 static inline pmd_t __pmd(pmdval_t val)
422 return (pmd_t) { PVOP_CALLEE1(pmdval_t, mmu.make_pmd, val) };
425 static inline pmdval_t pmd_val(pmd_t pmd)
427 return PVOP_CALLEE1(pmdval_t, mmu.pmd_val, pmd.pmd);
430 static inline void set_pud(pud_t *pudp, pud_t pud)
432 PVOP_VCALL2(mmu.set_pud, pudp, native_pud_val(pud));
435 static inline pud_t __pud(pudval_t val)
437 pudval_t ret;
439 ret = PVOP_CALLEE1(pudval_t, mmu.make_pud, val);
441 return (pud_t) { ret };
444 static inline pudval_t pud_val(pud_t pud)
446 return PVOP_CALLEE1(pudval_t, mmu.pud_val, pud.pud);
449 static inline void pud_clear(pud_t *pudp)
451 set_pud(pudp, native_make_pud(0));
454 static inline void set_p4d(p4d_t *p4dp, p4d_t p4d)
456 p4dval_t val = native_p4d_val(p4d);
458 PVOP_VCALL2(mmu.set_p4d, p4dp, val);
461 #if CONFIG_PGTABLE_LEVELS >= 5
463 static inline p4d_t __p4d(p4dval_t val)
465 p4dval_t ret = PVOP_CALLEE1(p4dval_t, mmu.make_p4d, val);
467 return (p4d_t) { ret };
470 static inline p4dval_t p4d_val(p4d_t p4d)
472 return PVOP_CALLEE1(p4dval_t, mmu.p4d_val, p4d.p4d);
475 static inline void __set_pgd(pgd_t *pgdp, pgd_t pgd)
477 PVOP_VCALL2(mmu.set_pgd, pgdp, native_pgd_val(pgd));
480 #define set_pgd(pgdp, pgdval) do { \
481 if (pgtable_l5_enabled()) \
482 __set_pgd(pgdp, pgdval); \
483 else \
484 set_p4d((p4d_t *)(pgdp), (p4d_t) { (pgdval).pgd }); \
485 } while (0)
487 #define pgd_clear(pgdp) do { \
488 if (pgtable_l5_enabled()) \
489 set_pgd(pgdp, native_make_pgd(0)); \
490 } while (0)
492 #endif /* CONFIG_PGTABLE_LEVELS == 5 */
494 static inline void p4d_clear(p4d_t *p4dp)
496 set_p4d(p4dp, native_make_p4d(0));
499 static inline void set_pte_atomic(pte_t *ptep, pte_t pte)
501 set_pte(ptep, pte);
504 static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
505 pte_t *ptep)
507 set_pte(ptep, native_make_pte(0));
510 static inline void pmd_clear(pmd_t *pmdp)
512 set_pmd(pmdp, native_make_pmd(0));
515 #define __HAVE_ARCH_START_CONTEXT_SWITCH
516 static inline void arch_start_context_switch(struct task_struct *prev)
518 PVOP_VCALL1(cpu.start_context_switch, prev);
521 static inline void arch_end_context_switch(struct task_struct *next)
523 PVOP_VCALL1(cpu.end_context_switch, next);
526 #define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
527 static inline void arch_enter_lazy_mmu_mode(void)
529 PVOP_VCALL0(mmu.lazy_mode.enter);
532 static inline void arch_leave_lazy_mmu_mode(void)
534 PVOP_VCALL0(mmu.lazy_mode.leave);
537 static inline void arch_flush_lazy_mmu_mode(void)
539 PVOP_VCALL0(mmu.lazy_mode.flush);
542 static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
543 phys_addr_t phys, pgprot_t flags)
545 pv_ops.mmu.set_fixmap(idx, phys, flags);
547 #endif
549 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
551 static __always_inline void pv_queued_spin_lock_slowpath(struct qspinlock *lock,
552 u32 val)
554 PVOP_VCALL2(lock.queued_spin_lock_slowpath, lock, val);
557 static __always_inline void pv_queued_spin_unlock(struct qspinlock *lock)
559 PVOP_VCALLEE1(lock.queued_spin_unlock, lock);
562 static __always_inline void pv_wait(u8 *ptr, u8 val)
564 PVOP_VCALL2(lock.wait, ptr, val);
567 static __always_inline void pv_kick(int cpu)
569 PVOP_VCALL1(lock.kick, cpu);
572 static __always_inline bool pv_vcpu_is_preempted(long cpu)
574 return PVOP_CALLEE1(bool, lock.vcpu_is_preempted, cpu);
577 void __raw_callee_save___native_queued_spin_unlock(struct qspinlock *lock);
578 bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
580 #endif /* SMP && PARAVIRT_SPINLOCKS */
582 #ifdef CONFIG_X86_32
583 /* save and restore all caller-save registers, except return value */
584 #define PV_SAVE_ALL_CALLER_REGS "pushl %ecx;"
585 #define PV_RESTORE_ALL_CALLER_REGS "popl %ecx;"
586 #else
587 /* save and restore all caller-save registers, except return value */
588 #define PV_SAVE_ALL_CALLER_REGS \
589 "push %rcx;" \
590 "push %rdx;" \
591 "push %rsi;" \
592 "push %rdi;" \
593 "push %r8;" \
594 "push %r9;" \
595 "push %r10;" \
596 "push %r11;"
597 #define PV_RESTORE_ALL_CALLER_REGS \
598 "pop %r11;" \
599 "pop %r10;" \
600 "pop %r9;" \
601 "pop %r8;" \
602 "pop %rdi;" \
603 "pop %rsi;" \
604 "pop %rdx;" \
605 "pop %rcx;"
606 #endif
609 * Generate a thunk around a function which saves all caller-save
610 * registers except for the return value. This allows C functions to
611 * be called from assembler code where fewer than normal registers are
612 * available. It may also help code generation around calls from C
613 * code if the common case doesn't use many registers.
615 * When a callee is wrapped in a thunk, the caller can assume that all
616 * arg regs and all scratch registers are preserved across the
617 * call. The return value in rax/eax will not be saved, even for void
618 * functions.
620 #define PV_THUNK_NAME(func) "__raw_callee_save_" #func
621 #define PV_CALLEE_SAVE_REGS_THUNK(func) \
622 extern typeof(func) __raw_callee_save_##func; \
624 asm(".pushsection .text;" \
625 ".globl " PV_THUNK_NAME(func) ";" \
626 ".type " PV_THUNK_NAME(func) ", @function;" \
627 PV_THUNK_NAME(func) ":" \
628 FRAME_BEGIN \
629 PV_SAVE_ALL_CALLER_REGS \
630 "call " #func ";" \
631 PV_RESTORE_ALL_CALLER_REGS \
632 FRAME_END \
633 "ret;" \
634 ".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
635 ".popsection")
637 /* Get a reference to a callee-save function */
638 #define PV_CALLEE_SAVE(func) \
639 ((struct paravirt_callee_save) { __raw_callee_save_##func })
641 /* Promise that "func" already uses the right calling convention */
642 #define __PV_IS_CALLEE_SAVE(func) \
643 ((struct paravirt_callee_save) { func })
645 #ifdef CONFIG_PARAVIRT_XXL
646 static inline notrace unsigned long arch_local_save_flags(void)
648 return PVOP_CALLEE0(unsigned long, irq.save_fl);
651 static inline notrace void arch_local_irq_restore(unsigned long f)
653 PVOP_VCALLEE1(irq.restore_fl, f);
656 static inline notrace void arch_local_irq_disable(void)
658 PVOP_VCALLEE0(irq.irq_disable);
661 static inline notrace void arch_local_irq_enable(void)
663 PVOP_VCALLEE0(irq.irq_enable);
666 static inline notrace unsigned long arch_local_irq_save(void)
668 unsigned long f;
670 f = arch_local_save_flags();
671 arch_local_irq_disable();
672 return f;
674 #endif
677 /* Make sure as little as possible of this mess escapes. */
678 #undef PARAVIRT_CALL
679 #undef __PVOP_CALL
680 #undef __PVOP_VCALL
681 #undef PVOP_VCALL0
682 #undef PVOP_CALL0
683 #undef PVOP_VCALL1
684 #undef PVOP_CALL1
685 #undef PVOP_VCALL2
686 #undef PVOP_CALL2
687 #undef PVOP_VCALL3
688 #undef PVOP_CALL3
689 #undef PVOP_VCALL4
690 #undef PVOP_CALL4
692 extern void default_banner(void);
694 #else /* __ASSEMBLY__ */
696 #define _PVSITE(ptype, ops, word, algn) \
697 771:; \
698 ops; \
699 772:; \
700 .pushsection .parainstructions,"a"; \
701 .align algn; \
702 word 771b; \
703 .byte ptype; \
704 .byte 772b-771b; \
705 .popsection
708 #define COND_PUSH(set, mask, reg) \
709 .if ((~(set)) & mask); push %reg; .endif
710 #define COND_POP(set, mask, reg) \
711 .if ((~(set)) & mask); pop %reg; .endif
713 #ifdef CONFIG_X86_64
715 #define PV_SAVE_REGS(set) \
716 COND_PUSH(set, CLBR_RAX, rax); \
717 COND_PUSH(set, CLBR_RCX, rcx); \
718 COND_PUSH(set, CLBR_RDX, rdx); \
719 COND_PUSH(set, CLBR_RSI, rsi); \
720 COND_PUSH(set, CLBR_RDI, rdi); \
721 COND_PUSH(set, CLBR_R8, r8); \
722 COND_PUSH(set, CLBR_R9, r9); \
723 COND_PUSH(set, CLBR_R10, r10); \
724 COND_PUSH(set, CLBR_R11, r11)
725 #define PV_RESTORE_REGS(set) \
726 COND_POP(set, CLBR_R11, r11); \
727 COND_POP(set, CLBR_R10, r10); \
728 COND_POP(set, CLBR_R9, r9); \
729 COND_POP(set, CLBR_R8, r8); \
730 COND_POP(set, CLBR_RDI, rdi); \
731 COND_POP(set, CLBR_RSI, rsi); \
732 COND_POP(set, CLBR_RDX, rdx); \
733 COND_POP(set, CLBR_RCX, rcx); \
734 COND_POP(set, CLBR_RAX, rax)
736 #define PARA_PATCH(off) ((off) / 8)
737 #define PARA_SITE(ptype, ops) _PVSITE(ptype, ops, .quad, 8)
738 #define PARA_INDIRECT(addr) *addr(%rip)
739 #else
740 #define PV_SAVE_REGS(set) \
741 COND_PUSH(set, CLBR_EAX, eax); \
742 COND_PUSH(set, CLBR_EDI, edi); \
743 COND_PUSH(set, CLBR_ECX, ecx); \
744 COND_PUSH(set, CLBR_EDX, edx)
745 #define PV_RESTORE_REGS(set) \
746 COND_POP(set, CLBR_EDX, edx); \
747 COND_POP(set, CLBR_ECX, ecx); \
748 COND_POP(set, CLBR_EDI, edi); \
749 COND_POP(set, CLBR_EAX, eax)
751 #define PARA_PATCH(off) ((off) / 4)
752 #define PARA_SITE(ptype, ops) _PVSITE(ptype, ops, .long, 4)
753 #define PARA_INDIRECT(addr) *%cs:addr
754 #endif
756 #ifdef CONFIG_PARAVIRT_XXL
757 #define INTERRUPT_RETURN \
758 PARA_SITE(PARA_PATCH(PV_CPU_iret), \
759 ANNOTATE_RETPOLINE_SAFE; \
760 jmp PARA_INDIRECT(pv_ops+PV_CPU_iret);)
762 #define DISABLE_INTERRUPTS(clobbers) \
763 PARA_SITE(PARA_PATCH(PV_IRQ_irq_disable), \
764 PV_SAVE_REGS(clobbers | CLBR_CALLEE_SAVE); \
765 ANNOTATE_RETPOLINE_SAFE; \
766 call PARA_INDIRECT(pv_ops+PV_IRQ_irq_disable); \
767 PV_RESTORE_REGS(clobbers | CLBR_CALLEE_SAVE);)
769 #define ENABLE_INTERRUPTS(clobbers) \
770 PARA_SITE(PARA_PATCH(PV_IRQ_irq_enable), \
771 PV_SAVE_REGS(clobbers | CLBR_CALLEE_SAVE); \
772 ANNOTATE_RETPOLINE_SAFE; \
773 call PARA_INDIRECT(pv_ops+PV_IRQ_irq_enable); \
774 PV_RESTORE_REGS(clobbers | CLBR_CALLEE_SAVE);)
775 #endif
777 #ifdef CONFIG_X86_64
778 #ifdef CONFIG_PARAVIRT_XXL
780 * If swapgs is used while the userspace stack is still current,
781 * there's no way to call a pvop. The PV replacement *must* be
782 * inlined, or the swapgs instruction must be trapped and emulated.
784 #define SWAPGS_UNSAFE_STACK \
785 PARA_SITE(PARA_PATCH(PV_CPU_swapgs), swapgs)
788 * Note: swapgs is very special, and in practise is either going to be
789 * implemented with a single "swapgs" instruction or something very
790 * special. Either way, we don't need to save any registers for
791 * it.
793 #define SWAPGS \
794 PARA_SITE(PARA_PATCH(PV_CPU_swapgs), \
795 ANNOTATE_RETPOLINE_SAFE; \
796 call PARA_INDIRECT(pv_ops+PV_CPU_swapgs); \
799 #define USERGS_SYSRET64 \
800 PARA_SITE(PARA_PATCH(PV_CPU_usergs_sysret64), \
801 ANNOTATE_RETPOLINE_SAFE; \
802 jmp PARA_INDIRECT(pv_ops+PV_CPU_usergs_sysret64);)
804 #ifdef CONFIG_DEBUG_ENTRY
805 #define SAVE_FLAGS(clobbers) \
806 PARA_SITE(PARA_PATCH(PV_IRQ_save_fl), \
807 PV_SAVE_REGS(clobbers | CLBR_CALLEE_SAVE); \
808 ANNOTATE_RETPOLINE_SAFE; \
809 call PARA_INDIRECT(pv_ops+PV_IRQ_save_fl); \
810 PV_RESTORE_REGS(clobbers | CLBR_CALLEE_SAVE);)
811 #endif
812 #endif /* CONFIG_PARAVIRT_XXL */
813 #endif /* CONFIG_X86_64 */
815 #endif /* __ASSEMBLY__ */
816 #else /* CONFIG_PARAVIRT */
817 # define default_banner x86_init_noop
818 #endif /* !CONFIG_PARAVIRT */
820 #ifndef __ASSEMBLY__
821 #ifndef CONFIG_PARAVIRT_XXL
822 static inline void paravirt_arch_dup_mmap(struct mm_struct *oldmm,
823 struct mm_struct *mm)
826 #endif
828 #ifndef CONFIG_PARAVIRT
829 static inline void paravirt_arch_exit_mmap(struct mm_struct *mm)
832 #endif
833 #endif /* __ASSEMBLY__ */
834 #endif /* _ASM_X86_PARAVIRT_H */