1 #ifndef _ASM_X86_KVM_PARA_H
2 #define _ASM_X86_KVM_PARA_H
4 #include <linux/types.h>
10 #define KVM_CPUID_SIGNATURE 0x40000000
15 #define KVM_CPUID_FEATURES 0x40000001
16 #define KVM_FEATURE_CLOCKSOURCE 0
17 #define KVM_FEATURE_NOP_IO_DELAY 1
18 #define KVM_FEATURE_MMU_OP 2
22 #define KVM_FEATURE_CLOCKSOURCE2 3
23 #define KVM_FEATURE_ASYNC_PF 4
24 #define KVM_FEATURE_STEAL_TIME 5
25 #define KVM_FEATURE_PV_EOI 6
30 #define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 24
32 #define MSR_KVM_WALL_CLOCK 0x11
33 #define MSR_KVM_SYSTEM_TIME 0x12
35 #define KVM_MSR_ENABLED 1
37 #define MSR_KVM_WALL_CLOCK_NEW 0x4b564d00
38 #define MSR_KVM_SYSTEM_TIME_NEW 0x4b564d01
39 #define MSR_KVM_ASYNC_PF_EN 0x4b564d02
40 #define MSR_KVM_STEAL_TIME 0x4b564d03
41 #define MSR_KVM_PV_EOI_EN 0x4b564d04
50 #define KVM_STEAL_ALIGNMENT_BITS 5
51 #define KVM_STEAL_VALID_BITS ((-1ULL << (KVM_STEAL_ALIGNMENT_BITS + 1)))
52 #define KVM_STEAL_RESERVED_MASK (((1 << KVM_STEAL_ALIGNMENT_BITS) - 1 ) << 1)
54 #define KVM_MAX_MMU_OP_BATCH 32
56 #define KVM_ASYNC_PF_ENABLED (1 << 0)
57 #define KVM_ASYNC_PF_SEND_ALWAYS (1 << 1)
60 #define KVM_MMU_OP_WRITE_PTE 1
61 #define KVM_MMU_OP_FLUSH_TLB 2
62 #define KVM_MMU_OP_RELEASE_PT 3
85 #define KVM_PV_REASON_PAGE_NOT_PRESENT 1
86 #define KVM_PV_REASON_PAGE_READY 2
94 #define KVM_PV_EOI_BIT 0
95 #define KVM_PV_EOI_MASK (0x1 << KVM_PV_EOI_BIT)
96 #define KVM_PV_EOI_ENABLED KVM_PV_EOI_MASK
97 #define KVM_PV_EOI_DISABLED 0x0
100 #include <asm/processor.h>
105 #ifdef CONFIG_KVM_GUEST
117 #define KVM_HYPERCALL ".byte 0x0f,0x01,0xc1"
129 static inline long kvm_hypercall0(
unsigned int nr)
132 asm volatile(KVM_HYPERCALL
139 static inline long kvm_hypercall1(
unsigned int nr,
unsigned long p1)
142 asm volatile(KVM_HYPERCALL
149 static inline long kvm_hypercall2(
unsigned int nr,
unsigned long p1,
153 asm volatile(KVM_HYPERCALL
155 :
"a"(nr),
"b"(
p1),
"c"(p2)
160 static inline long kvm_hypercall3(
unsigned int nr,
unsigned long p1,
161 unsigned long p2,
unsigned long p3)
164 asm volatile(KVM_HYPERCALL
166 :
"a"(nr),
"b"(
p1),
"c"(p2),
"d"(p3)
171 static inline long kvm_hypercall4(
unsigned int nr,
unsigned long p1,
172 unsigned long p2,
unsigned long p3,
176 asm volatile(KVM_HYPERCALL
178 :
"a"(nr),
"b"(
p1),
"c"(p2),
"d"(p3),
"S"(p4)
185 unsigned int eax,
ebx,
ecx, edx;
191 if (cpu_has_hypervisor) {
193 memcpy(signature + 0, &ebx, 4);
194 memcpy(signature + 4, &ecx, 4);
195 memcpy(signature + 8, &edx, 4);
198 if (
strcmp(signature,
"KVMKVMKVM") == 0)
205 static inline unsigned int kvm_arch_para_features(
void)
210 #ifdef CONFIG_KVM_GUEST
217 #define kvm_guest_init() do { } while (0)
218 #define kvm_async_pf_task_wait(T) do {} while(0)
219 #define kvm_async_pf_task_wake(T) do {} while(0)