[CONNECTOR]: Replace delayed work with usual work queue.
[linux-2.6/verdex.git] / include / linux / kvm.h
blob5bb2c3c585c1fbd3b878ca44da7f7138c8cd5059
1 #ifndef __LINUX_KVM_H
2 #define __LINUX_KVM_H
4 /*
5 * Userspace interface for /dev/kvm - kernel based virtual machine
7 * Note: this interface is considered experimental and may change without
8 * notice.
9 */
11 #include <asm/types.h>
12 #include <linux/ioctl.h>
15 * Architectural interrupt line count, and the size of the bitmap needed
16 * to hold them.
18 #define KVM_NR_INTERRUPTS 256
19 #define KVM_IRQ_BITMAP_SIZE_BYTES ((KVM_NR_INTERRUPTS + 7) / 8)
20 #define KVM_IRQ_BITMAP_SIZE(type) (KVM_IRQ_BITMAP_SIZE_BYTES / sizeof(type))
23 /* for KVM_CREATE_MEMORY_REGION */
24 struct kvm_memory_region {
25 __u32 slot;
26 __u32 flags;
27 __u64 guest_phys_addr;
28 __u64 memory_size; /* bytes */
31 /* for kvm_memory_region::flags */
32 #define KVM_MEM_LOG_DIRTY_PAGES 1UL
35 #define KVM_EXIT_TYPE_FAIL_ENTRY 1
36 #define KVM_EXIT_TYPE_VM_EXIT 2
38 enum kvm_exit_reason {
39 KVM_EXIT_UNKNOWN = 0,
40 KVM_EXIT_EXCEPTION = 1,
41 KVM_EXIT_IO = 2,
42 KVM_EXIT_CPUID = 3,
43 KVM_EXIT_DEBUG = 4,
44 KVM_EXIT_HLT = 5,
45 KVM_EXIT_MMIO = 6,
48 /* for KVM_RUN */
49 struct kvm_run {
50 /* in */
51 __u32 vcpu;
52 __u32 emulated; /* skip current instruction */
53 __u32 mmio_completed; /* mmio request completed */
55 /* out */
56 __u32 exit_type;
57 __u32 exit_reason;
58 __u32 instruction_length;
59 union {
60 /* KVM_EXIT_UNKNOWN */
61 struct {
62 __u32 hardware_exit_reason;
63 } hw;
64 /* KVM_EXIT_EXCEPTION */
65 struct {
66 __u32 exception;
67 __u32 error_code;
68 } ex;
69 /* KVM_EXIT_IO */
70 struct {
71 #define KVM_EXIT_IO_IN 0
72 #define KVM_EXIT_IO_OUT 1
73 __u8 direction;
74 __u8 size; /* bytes */
75 __u8 string;
76 __u8 string_down;
77 __u8 rep;
78 __u8 pad;
79 __u16 port;
80 __u64 count;
81 union {
82 __u64 address;
83 __u32 value;
85 } io;
86 struct {
87 } debug;
88 /* KVM_EXIT_MMIO */
89 struct {
90 __u64 phys_addr;
91 __u8 data[8];
92 __u32 len;
93 __u8 is_write;
94 } mmio;
98 /* for KVM_GET_REGS and KVM_SET_REGS */
99 struct kvm_regs {
100 /* in */
101 __u32 vcpu;
102 __u32 padding;
104 /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
105 __u64 rax, rbx, rcx, rdx;
106 __u64 rsi, rdi, rsp, rbp;
107 __u64 r8, r9, r10, r11;
108 __u64 r12, r13, r14, r15;
109 __u64 rip, rflags;
112 struct kvm_segment {
113 __u64 base;
114 __u32 limit;
115 __u16 selector;
116 __u8 type;
117 __u8 present, dpl, db, s, l, g, avl;
118 __u8 unusable;
119 __u8 padding;
122 struct kvm_dtable {
123 __u64 base;
124 __u16 limit;
125 __u16 padding[3];
128 /* for KVM_GET_SREGS and KVM_SET_SREGS */
129 struct kvm_sregs {
130 /* in */
131 __u32 vcpu;
132 __u32 padding;
134 /* out (KVM_GET_SREGS) / in (KVM_SET_SREGS) */
135 struct kvm_segment cs, ds, es, fs, gs, ss;
136 struct kvm_segment tr, ldt;
137 struct kvm_dtable gdt, idt;
138 __u64 cr0, cr2, cr3, cr4, cr8;
139 __u64 efer;
140 __u64 apic_base;
141 __u64 interrupt_bitmap[KVM_IRQ_BITMAP_SIZE(__u64)];
144 struct kvm_msr_entry {
145 __u32 index;
146 __u32 reserved;
147 __u64 data;
150 /* for KVM_GET_MSRS and KVM_SET_MSRS */
151 struct kvm_msrs {
152 __u32 vcpu;
153 __u32 nmsrs; /* number of msrs in entries */
155 struct kvm_msr_entry entries[0];
158 /* for KVM_GET_MSR_INDEX_LIST */
159 struct kvm_msr_list {
160 __u32 nmsrs; /* number of msrs in entries */
161 __u32 indices[0];
164 /* for KVM_TRANSLATE */
165 struct kvm_translation {
166 /* in */
167 __u64 linear_address;
168 __u32 vcpu;
169 __u32 padding;
171 /* out */
172 __u64 physical_address;
173 __u8 valid;
174 __u8 writeable;
175 __u8 usermode;
178 /* for KVM_INTERRUPT */
179 struct kvm_interrupt {
180 /* in */
181 __u32 vcpu;
182 __u32 irq;
185 struct kvm_breakpoint {
186 __u32 enabled;
187 __u32 padding;
188 __u64 address;
191 /* for KVM_DEBUG_GUEST */
192 struct kvm_debug_guest {
193 /* int */
194 __u32 vcpu;
195 __u32 enabled;
196 struct kvm_breakpoint breakpoints[4];
197 __u32 singlestep;
200 /* for KVM_GET_DIRTY_LOG */
201 struct kvm_dirty_log {
202 __u32 slot;
203 __u32 padding;
204 union {
205 void __user *dirty_bitmap; /* one bit per page */
206 __u64 padding;
210 #define KVMIO 0xAE
212 #define KVM_RUN _IOWR(KVMIO, 2, struct kvm_run)
213 #define KVM_GET_REGS _IOWR(KVMIO, 3, struct kvm_regs)
214 #define KVM_SET_REGS _IOW(KVMIO, 4, struct kvm_regs)
215 #define KVM_GET_SREGS _IOWR(KVMIO, 5, struct kvm_sregs)
216 #define KVM_SET_SREGS _IOW(KVMIO, 6, struct kvm_sregs)
217 #define KVM_TRANSLATE _IOWR(KVMIO, 7, struct kvm_translation)
218 #define KVM_INTERRUPT _IOW(KVMIO, 8, struct kvm_interrupt)
219 #define KVM_DEBUG_GUEST _IOW(KVMIO, 9, struct kvm_debug_guest)
220 #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 10, struct kvm_memory_region)
221 #define KVM_CREATE_VCPU _IOW(KVMIO, 11, int /* vcpu_slot */)
222 #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 12, struct kvm_dirty_log)
223 #define KVM_GET_MSRS _IOWR(KVMIO, 13, struct kvm_msrs)
224 #define KVM_SET_MSRS _IOWR(KVMIO, 14, struct kvm_msrs)
225 #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 15, struct kvm_msr_list)
227 #endif