]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/x86/include/asm/kvm_para.h
x86/msr-index: Cleanup bit defines
[mirror_ubuntu-bionic-kernel.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 9extern void kvmclock_init(void);
ca3f1017 10extern int kvm_register_clock(char *txt);
18068523 11
90993cdd 12#ifdef CONFIG_KVM_GUEST
3b5d56b9
EM
13bool kvm_check_and_clear_guest_paused(void);
14#else
15static inline bool kvm_check_and_clear_guest_paused(void)
16{
17 return false;
18}
90993cdd 19#endif /* CONFIG_KVM_GUEST */
18068523 20
c1118b36
PB
21#define KVM_HYPERCALL \
22 ALTERNATIVE(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9", X86_FEATURE_VMMCALL)
5f43238d 23
e423ca15 24/* For KVM hypercalls, a three-byte sequence of either the vmcall or the vmmcall
5f43238d
CB
25 * instruction. The hypervisor may replace it with something else but only the
26 * instructions are guaranteed to be supported.
27 *
28 * Up to four arguments may be passed in rbx, rcx, rdx, and rsi respectively.
29 * The hypercall number should be placed in rax and the return value will be
11393a07 30 * placed in rax. No other registers will be clobbered unless explicitly
5f43238d
CB
31 * noted by the particular hypercall.
32 */
33
34static inline long kvm_hypercall0(unsigned int nr)
35{
36 long ret;
37 asm volatile(KVM_HYPERCALL
38 : "=a"(ret)
ca373932
AL
39 : "a"(nr)
40 : "memory");
5f43238d
CB
41 return ret;
42}
43
44static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
45{
46 long ret;
47 asm volatile(KVM_HYPERCALL
48 : "=a"(ret)
ca373932
AL
49 : "a"(nr), "b"(p1)
50 : "memory");
5f43238d
CB
51 return ret;
52}
53
54static inline long kvm_hypercall2(unsigned int nr, unsigned long p1,
55 unsigned long p2)
56{
57 long ret;
58 asm volatile(KVM_HYPERCALL
59 : "=a"(ret)
ca373932
AL
60 : "a"(nr), "b"(p1), "c"(p2)
61 : "memory");
5f43238d
CB
62 return ret;
63}
64
65static inline long kvm_hypercall3(unsigned int nr, unsigned long p1,
66 unsigned long p2, unsigned long p3)
67{
68 long ret;
69 asm volatile(KVM_HYPERCALL
70 : "=a"(ret)
ca373932
AL
71 : "a"(nr), "b"(p1), "c"(p2), "d"(p3)
72 : "memory");
5f43238d
CB
73 return ret;
74}
75
76static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
77 unsigned long p2, unsigned long p3,
78 unsigned long p4)
79{
80 long ret;
81 asm volatile(KVM_HYPERCALL
82 : "=a"(ret)
ca373932
AL
83 : "a"(nr), "b"(p1), "c"(p2), "d"(p3), "S"(p4)
84 : "memory");
5f43238d
CB
85 return ret;
86}
87
ba492962 88#ifdef CONFIG_KVM_GUEST
1c300a40 89bool kvm_para_available(void);
77f01bdf 90unsigned int kvm_arch_para_features(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);
92b75202
SV
95
96#ifdef CONFIG_PARAVIRT_SPINLOCKS
97void __init kvm_spinlock_init(void);
98#else /* !CONFIG_PARAVIRT_SPINLOCKS */
99static inline void kvm_spinlock_init(void)
100{
101}
102#endif /* CONFIG_PARAVIRT_SPINLOCKS */
103
104#else /* CONFIG_KVM_GUEST */
a2b7861b 105#define kvm_async_pf_task_wait(T, I) do {} while(0)
631bc487 106#define kvm_async_pf_task_wake(T) do {} while(0)
92b75202 107
1c300a40
PB
108static inline bool kvm_para_available(void)
109{
1d804d07 110 return false;
1c300a40
PB
111}
112
77f01bdf
PB
113static inline unsigned int kvm_arch_para_features(void)
114{
115 return 0;
116}
117
d4c90b00 118static inline u32 kvm_read_and_reset_pf_reason(void)
631bc487
GN
119{
120 return 0;
121}
d910f5c1
GC
122
123static inline void kvm_disable_steal_time(void)
124{
125 return;
126}
5f43238d
CB
127#endif
128
1965aae3 129#endif /* _ASM_X86_KVM_PARA_H */