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 #define KVM_HYPERCALL \
21 ALTERNATIVE(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9", X86_FEATURE_VMMCALL)
23 /* For KVM hypercalls, a three-byte sequence of either the vmcall or the vmmcall
24 * instruction. The hypervisor may replace it with something else but only the
25 * instructions are guaranteed to be supported.
27 * Up to four arguments may be passed in rbx, rcx, rdx, and rsi respectively.
28 * The hypercall number should be placed in rax and the return value will be
29 * placed in rax. No other registers will be clobbered unless explicitly
30 * noted by the particular hypercall.
33 static inline long kvm_hypercall0(unsigned int nr
)
36 asm volatile(KVM_HYPERCALL
43 static inline long kvm_hypercall1(unsigned int nr
, unsigned long p1
)
46 asm volatile(KVM_HYPERCALL
53 static inline long kvm_hypercall2(unsigned int nr
, unsigned long p1
,
57 asm volatile(KVM_HYPERCALL
59 : "a"(nr
), "b"(p1
), "c"(p2
)
64 static inline long kvm_hypercall3(unsigned int nr
, unsigned long p1
,
65 unsigned long p2
, unsigned long p3
)
68 asm volatile(KVM_HYPERCALL
70 : "a"(nr
), "b"(p1
), "c"(p2
), "d"(p3
)
75 static inline long kvm_hypercall4(unsigned int nr
, unsigned long p1
,
76 unsigned long p2
, unsigned long p3
,
80 asm volatile(KVM_HYPERCALL
82 : "a"(nr
), "b"(p1
), "c"(p2
), "d"(p3
), "S"(p4
)
87 #ifdef CONFIG_KVM_GUEST
88 bool kvm_para_available(void);
89 unsigned int kvm_arch_para_features(void);
90 void __init
kvm_guest_init(void);
91 void kvm_async_pf_task_wait(u32 token
);
92 void kvm_async_pf_task_wake(u32 token
);
93 u32
kvm_read_and_reset_pf_reason(void);
94 extern void kvm_disable_steal_time(void);
96 #ifdef CONFIG_PARAVIRT_SPINLOCKS
97 void __init
kvm_spinlock_init(void);
98 #else /* !CONFIG_PARAVIRT_SPINLOCKS */
99 static inline void kvm_spinlock_init(void)
102 #endif /* CONFIG_PARAVIRT_SPINLOCKS */
104 #else /* CONFIG_KVM_GUEST */
105 #define kvm_guest_init() do {} while (0)
106 #define kvm_async_pf_task_wait(T) do {} while(0)
107 #define kvm_async_pf_task_wake(T) do {} while(0)
109 static inline bool kvm_para_available(void)
114 static inline unsigned int kvm_arch_para_features(void)
119 static inline u32
kvm_read_and_reset_pf_reason(void)
124 static inline void kvm_disable_steal_time(void)
130 #endif /* _ASM_X86_KVM_PARA_H */