1 #ifndef _ASM_X86_KVM_PARA_H
2 #define _ASM_X86_KVM_PARA_H
4 #include <asm/processor.h>
5 #include <asm/alternative.h>
6 #include <uapi/asm/kvm_para.h>
8 extern void kvmclock_init(void);
9 extern int kvm_register_clock(char *txt);
11 #ifdef CONFIG_KVM_GUEST
12 bool kvm_check_and_clear_guest_paused(void);
14 static inline bool kvm_check_and_clear_guest_paused(void)
18 #endif /* CONFIG_KVM_GUEST */
20 #ifdef CONFIG_DEBUG_RODATA
21 #define KVM_HYPERCALL \
22 ALTERNATIVE(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9", X86_FEATURE_VMMCALL)
24 /* On AMD processors, vmcall will generate a trap that we will
25 * then rewrite to the appropriate instruction.
27 #define KVM_HYPERCALL ".byte 0x0f,0x01,0xc1"
30 /* For KVM hypercalls, a three-byte sequence of either the vmcall or the vmmcall
31 * instruction. The hypervisor may replace it with something else but only the
32 * instructions are guaranteed to be supported.
34 * Up to four arguments may be passed in rbx, rcx, rdx, and rsi respectively.
35 * The hypercall number should be placed in rax and the return value will be
36 * placed in rax. No other registers will be clobbered unless explicitly
37 * noted by the particular hypercall.
40 static inline long kvm_hypercall0(unsigned int nr)
43 asm volatile(KVM_HYPERCALL
50 static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
53 asm volatile(KVM_HYPERCALL
60 static inline long kvm_hypercall2(unsigned int nr, unsigned long p1,
64 asm volatile(KVM_HYPERCALL
66 : "a"(nr), "b"(p1), "c"(p2)
71 static inline long kvm_hypercall3(unsigned int nr, unsigned long p1,
72 unsigned long p2, unsigned long p3)
75 asm volatile(KVM_HYPERCALL
77 : "a"(nr), "b"(p1), "c"(p2), "d"(p3)
82 static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
83 unsigned long p2, unsigned long p3,
87 asm volatile(KVM_HYPERCALL
89 : "a"(nr), "b"(p1), "c"(p2), "d"(p3), "S"(p4)
94 #ifdef CONFIG_KVM_GUEST
95 bool kvm_para_available(void);
96 unsigned int kvm_arch_para_features(void);
97 void __init kvm_guest_init(void);
98 void kvm_async_pf_task_wait(u32 token);
99 void kvm_async_pf_task_wake(u32 token);
100 u32 kvm_read_and_reset_pf_reason(void);
101 extern void kvm_disable_steal_time(void);
103 #ifdef CONFIG_PARAVIRT_SPINLOCKS
104 void __init kvm_spinlock_init(void);
105 #else /* !CONFIG_PARAVIRT_SPINLOCKS */
106 static inline void kvm_spinlock_init(void)
109 #endif /* CONFIG_PARAVIRT_SPINLOCKS */
111 #else /* CONFIG_KVM_GUEST */
112 #define kvm_guest_init() do {} while (0)
113 #define kvm_async_pf_task_wait(T) do {} while(0)
114 #define kvm_async_pf_task_wake(T) do {} while(0)
116 static inline bool kvm_para_available(void)
121 static inline unsigned int kvm_arch_para_features(void)
126 static inline u32 kvm_read_and_reset_pf_reason(void)
131 static inline void kvm_disable_steal_time(void)
137 #endif /* _ASM_X86_KVM_PARA_H */