ACPI / PCI: Remove duplicated penalty on SCI IRQ
[linux-2.6-block.git] / arch / x86 / include / asm / kvm_para.h
CommitLineData
1965aae3
PA
1#ifndef _ASM_X86_KVM_PARA_H
2#define _ASM_X86_KVM_PARA_H
5f43238d 3
5f43238d 4#include <asm/processor.h>
c1118b36 5#include <asm/alternative.h>
af170c50 6#include <uapi/asm/kvm_para.h>
5f43238d 7
18068523 8extern void kvmclock_init(void);
ca3f1017 9extern int kvm_register_clock(char *txt);
18068523 10
90993cdd 11#ifdef CONFIG_KVM_GUEST
3b5d56b9
EM
12bool kvm_check_and_clear_guest_paused(void);
13#else
14static inline bool kvm_check_and_clear_guest_paused(void)
15{
16 return false;
17}
90993cdd 18#endif /* CONFIG_KVM_GUEST */
18068523 19
c1118b36
PB
20#ifdef CONFIG_DEBUG_RODATA
21#define KVM_HYPERCALL \
22 ALTERNATIVE(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9", X86_FEATURE_VMMCALL)
23#else
24/* On AMD processors, vmcall will generate a trap that we will
25 * then rewrite to the appropriate instruction.
5f43238d
CB
26 */
27#define KVM_HYPERCALL ".byte 0x0f,0x01,0xc1"
c1118b36 28#endif
5f43238d 29
e423ca15 30/* For KVM hypercalls, a three-byte sequence of either the vmcall or the vmmcall
5f43238d
CB
31 * instruction. The hypervisor may replace it with something else but only the
32 * instructions are guaranteed to be supported.
33 *
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
11393a07 36 * placed in rax. No other registers will be clobbered unless explicitly
5f43238d
CB
37 * noted by the particular hypercall.
38 */
39
40static inline long kvm_hypercall0(unsigned int nr)
41{
42 long ret;
43 asm volatile(KVM_HYPERCALL
44 : "=a"(ret)
ca373932
AL
45 : "a"(nr)
46 : "memory");
5f43238d
CB
47 return ret;
48}
49
50static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
51{
52 long ret;
53 asm volatile(KVM_HYPERCALL
54 : "=a"(ret)
ca373932
AL
55 : "a"(nr), "b"(p1)
56 : "memory");
5f43238d
CB
57 return ret;
58}
59
60static inline long kvm_hypercall2(unsigned int nr, unsigned long p1,
61 unsigned long p2)
62{
63 long ret;
64 asm volatile(KVM_HYPERCALL
65 : "=a"(ret)
ca373932
AL
66 : "a"(nr), "b"(p1), "c"(p2)
67 : "memory");
5f43238d
CB
68 return ret;
69}
70
71static inline long kvm_hypercall3(unsigned int nr, unsigned long p1,
72 unsigned long p2, unsigned long p3)
73{
74 long ret;
75 asm volatile(KVM_HYPERCALL
76 : "=a"(ret)
ca373932
AL
77 : "a"(nr), "b"(p1), "c"(p2), "d"(p3)
78 : "memory");
5f43238d
CB
79 return ret;
80}
81
82static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
83 unsigned long p2, unsigned long p3,
84 unsigned long p4)
85{
86 long ret;
87 asm volatile(KVM_HYPERCALL
88 : "=a"(ret)
ca373932
AL
89 : "a"(nr), "b"(p1), "c"(p2), "d"(p3), "S"(p4)
90 : "memory");
5f43238d
CB
91 return ret;
92}
93
ba492962 94#ifdef CONFIG_KVM_GUEST
1c300a40 95bool kvm_para_available(void);
77f01bdf 96unsigned int kvm_arch_para_features(void);
ba492962 97void __init kvm_guest_init(void);
631bc487
GN
98void kvm_async_pf_task_wait(u32 token);
99void kvm_async_pf_task_wake(u32 token);
100u32 kvm_read_and_reset_pf_reason(void);
d910f5c1 101extern void kvm_disable_steal_time(void);
92b75202
SV
102
103#ifdef CONFIG_PARAVIRT_SPINLOCKS
104void __init kvm_spinlock_init(void);
105#else /* !CONFIG_PARAVIRT_SPINLOCKS */
106static inline void kvm_spinlock_init(void)
107{
108}
109#endif /* CONFIG_PARAVIRT_SPINLOCKS */
110
111#else /* CONFIG_KVM_GUEST */
112#define kvm_guest_init() do {} while (0)
631bc487
GN
113#define kvm_async_pf_task_wait(T) do {} while(0)
114#define kvm_async_pf_task_wake(T) do {} while(0)
92b75202 115
1c300a40
PB
116static inline bool kvm_para_available(void)
117{
1d804d07 118 return false;
1c300a40
PB
119}
120
77f01bdf
PB
121static inline unsigned int kvm_arch_para_features(void)
122{
123 return 0;
124}
125
d4c90b00 126static inline u32 kvm_read_and_reset_pf_reason(void)
631bc487
GN
127{
128 return 0;
129}
d910f5c1
GC
130
131static inline void kvm_disable_steal_time(void)
132{
133 return;
134}
5f43238d
CB
135#endif
136
1965aae3 137#endif /* _ASM_X86_KVM_PARA_H */