Merge tag 'devicetree-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/robh...
[linux-2.6-block.git] / arch / x86 / include / asm / kvm_para.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1965aae3
PA
2#ifndef _ASM_X86_KVM_PARA_H
3#define _ASM_X86_KVM_PARA_H
5f43238d 4
5f43238d 5#include <asm/processor.h>
c1118b36 6#include <asm/alternative.h>
af170c50 7#include <uapi/asm/kvm_para.h>
5f43238d 8
18068523
GOC
9extern void kvmclock_init(void);
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#define KVM_HYPERCALL \
21 ALTERNATIVE(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9", X86_FEATURE_VMMCALL)
5f43238d 22
e423ca15 23/* For KVM hypercalls, a three-byte sequence of either the vmcall or the vmmcall
5f43238d
CB
24 * instruction. The hypervisor may replace it with something else but only the
25 * instructions are guaranteed to be supported.
26 *
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
11393a07 29 * placed in rax. No other registers will be clobbered unless explicitly
5f43238d
CB
30 * noted by the particular hypercall.
31 */
32
33static inline long kvm_hypercall0(unsigned int nr)
34{
35 long ret;
36 asm volatile(KVM_HYPERCALL
37 : "=a"(ret)
ca373932
AL
38 : "a"(nr)
39 : "memory");
5f43238d
CB
40 return ret;
41}
42
43static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
44{
45 long ret;
46 asm volatile(KVM_HYPERCALL
47 : "=a"(ret)
ca373932
AL
48 : "a"(nr), "b"(p1)
49 : "memory");
5f43238d
CB
50 return ret;
51}
52
53static inline long kvm_hypercall2(unsigned int nr, unsigned long p1,
54 unsigned long p2)
55{
56 long ret;
57 asm volatile(KVM_HYPERCALL
58 : "=a"(ret)
ca373932
AL
59 : "a"(nr), "b"(p1), "c"(p2)
60 : "memory");
5f43238d
CB
61 return ret;
62}
63
64static inline long kvm_hypercall3(unsigned int nr, unsigned long p1,
65 unsigned long p2, unsigned long p3)
66{
67 long ret;
68 asm volatile(KVM_HYPERCALL
69 : "=a"(ret)
ca373932
AL
70 : "a"(nr), "b"(p1), "c"(p2), "d"(p3)
71 : "memory");
5f43238d
CB
72 return ret;
73}
74
75static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
76 unsigned long p2, unsigned long p3,
77 unsigned long p4)
78{
79 long ret;
80 asm volatile(KVM_HYPERCALL
81 : "=a"(ret)
ca373932
AL
82 : "a"(nr), "b"(p1), "c"(p2), "d"(p3), "S"(p4)
83 : "memory");
5f43238d
CB
84 return ret;
85}
86
ba492962 87#ifdef CONFIG_KVM_GUEST
1c300a40 88bool kvm_para_available(void);
77f01bdf 89unsigned int kvm_arch_para_features(void);
a4429e53 90unsigned int kvm_arch_para_hints(void);
a2b7861b 91void kvm_async_pf_task_wait(u32 token, int interrupt_kernel);
631bc487
GN
92void kvm_async_pf_task_wake(u32 token);
93u32 kvm_read_and_reset_pf_reason(void);
d910f5c1 94extern void kvm_disable_steal_time(void);
89f579ce 95void do_async_page_fault(struct pt_regs *regs, unsigned long error_code);
92b75202
SV
96
97#ifdef CONFIG_PARAVIRT_SPINLOCKS
98void __init kvm_spinlock_init(void);
99#else /* !CONFIG_PARAVIRT_SPINLOCKS */
100static inline void kvm_spinlock_init(void)
101{
102}
103#endif /* CONFIG_PARAVIRT_SPINLOCKS */
104
105#else /* CONFIG_KVM_GUEST */
a2b7861b 106#define kvm_async_pf_task_wait(T, I) do {} while(0)
631bc487 107#define kvm_async_pf_task_wake(T) do {} while(0)
92b75202 108
1c300a40
PB
109static inline bool kvm_para_available(void)
110{
1d804d07 111 return false;
1c300a40
PB
112}
113
77f01bdf
PB
114static inline unsigned int kvm_arch_para_features(void)
115{
116 return 0;
117}
118
a4429e53
WL
119static inline unsigned int kvm_arch_para_hints(void)
120{
121 return 0;
122}
123
d4c90b00 124static inline u32 kvm_read_and_reset_pf_reason(void)
631bc487
GN
125{
126 return 0;
127}
d910f5c1
GC
128
129static inline void kvm_disable_steal_time(void)
130{
131 return;
132}
5f43238d
CB
133#endif
134
1965aae3 135#endif /* _ASM_X86_KVM_PARA_H */