aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kvm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kvm.h')
-rw-r--r--include/linux/kvm.h133
1 files changed, 95 insertions, 38 deletions
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 275354ffa1cb..e6edca81ab84 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -11,7 +11,7 @@
11#include <asm/types.h> 11#include <asm/types.h>
12#include <linux/ioctl.h> 12#include <linux/ioctl.h>
13 13
14#define KVM_API_VERSION 4 14#define KVM_API_VERSION 12
15 15
16/* 16/*
17 * Architectural interrupt line count, and the size of the bitmap needed 17 * Architectural interrupt line count, and the size of the bitmap needed
@@ -33,37 +33,39 @@ struct kvm_memory_region {
33/* for kvm_memory_region::flags */ 33/* for kvm_memory_region::flags */
34#define KVM_MEM_LOG_DIRTY_PAGES 1UL 34#define KVM_MEM_LOG_DIRTY_PAGES 1UL
35 35
36 36struct kvm_memory_alias {
37#define KVM_EXIT_TYPE_FAIL_ENTRY 1 37 __u32 slot; /* this has a different namespace than memory slots */
38#define KVM_EXIT_TYPE_VM_EXIT 2 38 __u32 flags;
39 __u64 guest_phys_addr;
40 __u64 memory_size;
41 __u64 target_phys_addr;
42};
39 43
40enum kvm_exit_reason { 44enum kvm_exit_reason {
41 KVM_EXIT_UNKNOWN = 0, 45 KVM_EXIT_UNKNOWN = 0,
42 KVM_EXIT_EXCEPTION = 1, 46 KVM_EXIT_EXCEPTION = 1,
43 KVM_EXIT_IO = 2, 47 KVM_EXIT_IO = 2,
44 KVM_EXIT_CPUID = 3, 48 KVM_EXIT_HYPERCALL = 3,
45 KVM_EXIT_DEBUG = 4, 49 KVM_EXIT_DEBUG = 4,
46 KVM_EXIT_HLT = 5, 50 KVM_EXIT_HLT = 5,
47 KVM_EXIT_MMIO = 6, 51 KVM_EXIT_MMIO = 6,
48 KVM_EXIT_IRQ_WINDOW_OPEN = 7, 52 KVM_EXIT_IRQ_WINDOW_OPEN = 7,
49 KVM_EXIT_SHUTDOWN = 8, 53 KVM_EXIT_SHUTDOWN = 8,
54 KVM_EXIT_FAIL_ENTRY = 9,
55 KVM_EXIT_INTR = 10,
50}; 56};
51 57
52/* for KVM_RUN */ 58/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
53struct kvm_run { 59struct kvm_run {
54 /* in */ 60 /* in */
55 __u32 emulated; /* skip current instruction */
56 __u32 mmio_completed; /* mmio request completed */
57 __u8 request_interrupt_window; 61 __u8 request_interrupt_window;
58 __u8 padding1[7]; 62 __u8 padding1[7];
59 63
60 /* out */ 64 /* out */
61 __u32 exit_type;
62 __u32 exit_reason; 65 __u32 exit_reason;
63 __u32 instruction_length;
64 __u8 ready_for_interrupt_injection; 66 __u8 ready_for_interrupt_injection;
65 __u8 if_flag; 67 __u8 if_flag;
66 __u16 padding2; 68 __u8 padding2[2];
67 69
68 /* in (pre_kvm_run), out (post_kvm_run) */ 70 /* in (pre_kvm_run), out (post_kvm_run) */
69 __u64 cr8; 71 __u64 cr8;
@@ -72,29 +74,26 @@ struct kvm_run {
72 union { 74 union {
73 /* KVM_EXIT_UNKNOWN */ 75 /* KVM_EXIT_UNKNOWN */
74 struct { 76 struct {
75 __u32 hardware_exit_reason; 77 __u64 hardware_exit_reason;
76 } hw; 78 } hw;
79 /* KVM_EXIT_FAIL_ENTRY */
80 struct {
81 __u64 hardware_entry_failure_reason;
82 } fail_entry;
77 /* KVM_EXIT_EXCEPTION */ 83 /* KVM_EXIT_EXCEPTION */
78 struct { 84 struct {
79 __u32 exception; 85 __u32 exception;
80 __u32 error_code; 86 __u32 error_code;
81 } ex; 87 } ex;
82 /* KVM_EXIT_IO */ 88 /* KVM_EXIT_IO */
83 struct { 89 struct kvm_io {
84#define KVM_EXIT_IO_IN 0 90#define KVM_EXIT_IO_IN 0
85#define KVM_EXIT_IO_OUT 1 91#define KVM_EXIT_IO_OUT 1
86 __u8 direction; 92 __u8 direction;
87 __u8 size; /* bytes */ 93 __u8 size; /* bytes */
88 __u8 string;
89 __u8 string_down;
90 __u8 rep;
91 __u8 pad;
92 __u16 port; 94 __u16 port;
93 __u64 count; 95 __u32 count;
94 union { 96 __u64 data_offset; /* relative to kvm_run start */
95 __u64 address;
96 __u32 value;
97 };
98 } io; 97 } io;
99 struct { 98 struct {
100 } debug; 99 } debug;
@@ -105,6 +104,13 @@ struct kvm_run {
105 __u32 len; 104 __u32 len;
106 __u8 is_write; 105 __u8 is_write;
107 } mmio; 106 } mmio;
107 /* KVM_EXIT_HYPERCALL */
108 struct {
109 __u64 args[6];
110 __u64 ret;
111 __u32 longmode;
112 __u32 pad;
113 } hypercall;
108 }; 114 };
109}; 115};
110 116
@@ -118,6 +124,21 @@ struct kvm_regs {
118 __u64 rip, rflags; 124 __u64 rip, rflags;
119}; 125};
120 126
127/* for KVM_GET_FPU and KVM_SET_FPU */
128struct kvm_fpu {
129 __u8 fpr[8][16];
130 __u16 fcw;
131 __u16 fsw;
132 __u8 ftwx; /* in fxsave format */
133 __u8 pad1;
134 __u16 last_opcode;
135 __u64 last_ip;
136 __u64 last_dp;
137 __u8 xmm[16][16];
138 __u32 mxcsr;
139 __u32 pad2;
140};
141
121struct kvm_segment { 142struct kvm_segment {
122 __u64 base; 143 __u64 base;
123 __u32 limit; 144 __u32 limit;
@@ -210,38 +231,74 @@ struct kvm_dirty_log {
210 }; 231 };
211}; 232};
212 233
234struct kvm_cpuid_entry {
235 __u32 function;
236 __u32 eax;
237 __u32 ebx;
238 __u32 ecx;
239 __u32 edx;
240 __u32 padding;
241};
242
243/* for KVM_SET_CPUID */
244struct kvm_cpuid {
245 __u32 nent;
246 __u32 padding;
247 struct kvm_cpuid_entry entries[0];
248};
249
250/* for KVM_SET_SIGNAL_MASK */
251struct kvm_signal_mask {
252 __u32 len;
253 __u8 sigset[0];
254};
255
213#define KVMIO 0xAE 256#define KVMIO 0xAE
214 257
215/* 258/*
216 * ioctls for /dev/kvm fds: 259 * ioctls for /dev/kvm fds:
217 */ 260 */
218#define KVM_GET_API_VERSION _IO(KVMIO, 1) 261#define KVM_GET_API_VERSION _IO(KVMIO, 0x00)
219#define KVM_CREATE_VM _IO(KVMIO, 2) /* returns a VM fd */ 262#define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */
220#define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 15, struct kvm_msr_list) 263#define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list)
264/*
265 * Check if a kvm extension is available. Argument is extension number,
266 * return is 1 (yes) or 0 (no, sorry).
267 */
268#define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03)
269/*
270 * Get size for mmap(vcpu_fd)
271 */
272#define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */
221 273
222/* 274/*
223 * ioctls for VM fds 275 * ioctls for VM fds
224 */ 276 */
225#define KVM_SET_MEMORY_REGION _IOW(KVMIO, 10, struct kvm_memory_region) 277#define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region)
226/* 278/*
227 * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns 279 * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns
228 * a vcpu fd. 280 * a vcpu fd.
229 */ 281 */
230#define KVM_CREATE_VCPU _IOW(KVMIO, 11, int) 282#define KVM_CREATE_VCPU _IO(KVMIO, 0x41)
231#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 12, struct kvm_dirty_log) 283#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log)
284#define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias)
232 285
233/* 286/*
234 * ioctls for vcpu fds 287 * ioctls for vcpu fds
235 */ 288 */
236#define KVM_RUN _IOWR(KVMIO, 2, struct kvm_run) 289#define KVM_RUN _IO(KVMIO, 0x80)
237#define KVM_GET_REGS _IOR(KVMIO, 3, struct kvm_regs) 290#define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs)
238#define KVM_SET_REGS _IOW(KVMIO, 4, struct kvm_regs) 291#define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs)
239#define KVM_GET_SREGS _IOR(KVMIO, 5, struct kvm_sregs) 292#define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs)
240#define KVM_SET_SREGS _IOW(KVMIO, 6, struct kvm_sregs) 293#define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs)
241#define KVM_TRANSLATE _IOWR(KVMIO, 7, struct kvm_translation) 294#define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation)
242#define KVM_INTERRUPT _IOW(KVMIO, 8, struct kvm_interrupt) 295#define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt)
243#define KVM_DEBUG_GUEST _IOW(KVMIO, 9, struct kvm_debug_guest) 296#define KVM_DEBUG_GUEST _IOW(KVMIO, 0x87, struct kvm_debug_guest)
244#define KVM_GET_MSRS _IOWR(KVMIO, 13, struct kvm_msrs) 297#define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs)
245#define KVM_SET_MSRS _IOW(KVMIO, 14, struct kvm_msrs) 298#define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs)
299#define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid)
300#define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask)
301#define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu)
302#define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu)
246 303
247#endif 304#endif