diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-30 17:30:10 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-30 17:30:10 -0500 |
commit | 2c57ee6f924c95e4dce61ed4776fb3f62e1b9f92 (patch) | |
tree | b9d92e52e8c0ee68a0f5012b470c6146a9f0b65a /include/linux/kvm.h | |
parent | f389e9fcecdec4c4cb890ad28ea30a87a579ec3e (diff) | |
parent | 2f52d58c92d971bf421f461ad06eb93fb4f34981 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm: (249 commits)
KVM: Move apic timer migration away from critical section
KVM: Put kvm_para.h include outside __KERNEL__
KVM: Fix unbounded preemption latency
KVM: Initialize the mmu caches only after verifying cpu support
KVM: MMU: Fix dirty page setting for pages removed from rmap
KVM: Portability: Move kvm_fpu to asm-x86/kvm.h
KVM: x86 emulator: Only allow VMCALL/VMMCALL trapped by #UD
KVM: MMU: Merge shadow level check in FNAME(fetch)
KVM: MMU: Move kvm_free_some_pages() into critical section
KVM: MMU: Switch to mmu spinlock
KVM: MMU: Avoid calling gfn_to_page() in mmu_set_spte()
KVM: Add kvm_read_guest_atomic()
KVM: MMU: Concurrent guest walkers
KVM: Disable vapic support on Intel machines with FlexPriority
KVM: Accelerated apic support
KVM: local APIC TPR access reporting facility
KVM: Print data for unimplemented wrmsr
KVM: MMU: Add cache miss statistic
KVM: MMU: Coalesce remote tlb flushes
KVM: Expose ioapic to ia64 save/restore APIs
...
Diffstat (limited to 'include/linux/kvm.h')
-rw-r--r-- | include/linux/kvm.h | 203 |
1 files changed, 50 insertions, 153 deletions
diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 057a7f34ee36..4de4fd2d8607 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h | |||
@@ -9,12 +9,10 @@ | |||
9 | 9 | ||
10 | #include <asm/types.h> | 10 | #include <asm/types.h> |
11 | #include <linux/ioctl.h> | 11 | #include <linux/ioctl.h> |
12 | #include <asm/kvm.h> | ||
12 | 13 | ||
13 | #define KVM_API_VERSION 12 | 14 | #define KVM_API_VERSION 12 |
14 | 15 | ||
15 | /* Architectural interrupt line count. */ | ||
16 | #define KVM_NR_INTERRUPTS 256 | ||
17 | |||
18 | /* for KVM_CREATE_MEMORY_REGION */ | 16 | /* for KVM_CREATE_MEMORY_REGION */ |
19 | struct kvm_memory_region { | 17 | struct kvm_memory_region { |
20 | __u32 slot; | 18 | __u32 slot; |
@@ -23,17 +21,19 @@ struct kvm_memory_region { | |||
23 | __u64 memory_size; /* bytes */ | 21 | __u64 memory_size; /* bytes */ |
24 | }; | 22 | }; |
25 | 23 | ||
26 | /* for kvm_memory_region::flags */ | 24 | /* for KVM_SET_USER_MEMORY_REGION */ |
27 | #define KVM_MEM_LOG_DIRTY_PAGES 1UL | 25 | struct kvm_userspace_memory_region { |
28 | 26 | __u32 slot; | |
29 | struct kvm_memory_alias { | ||
30 | __u32 slot; /* this has a different namespace than memory slots */ | ||
31 | __u32 flags; | 27 | __u32 flags; |
32 | __u64 guest_phys_addr; | 28 | __u64 guest_phys_addr; |
33 | __u64 memory_size; | 29 | __u64 memory_size; /* bytes */ |
34 | __u64 target_phys_addr; | 30 | __u64 userspace_addr; /* start of the userspace allocated memory */ |
35 | }; | 31 | }; |
36 | 32 | ||
33 | /* for kvm_memory_region::flags */ | ||
34 | #define KVM_MEM_LOG_DIRTY_PAGES 1UL | ||
35 | |||
36 | |||
37 | /* for KVM_IRQ_LINE */ | 37 | /* for KVM_IRQ_LINE */ |
38 | struct kvm_irq_level { | 38 | struct kvm_irq_level { |
39 | /* | 39 | /* |
@@ -45,62 +45,18 @@ struct kvm_irq_level { | |||
45 | __u32 level; | 45 | __u32 level; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | /* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */ | ||
49 | struct kvm_pic_state { | ||
50 | __u8 last_irr; /* edge detection */ | ||
51 | __u8 irr; /* interrupt request register */ | ||
52 | __u8 imr; /* interrupt mask register */ | ||
53 | __u8 isr; /* interrupt service register */ | ||
54 | __u8 priority_add; /* highest irq priority */ | ||
55 | __u8 irq_base; | ||
56 | __u8 read_reg_select; | ||
57 | __u8 poll; | ||
58 | __u8 special_mask; | ||
59 | __u8 init_state; | ||
60 | __u8 auto_eoi; | ||
61 | __u8 rotate_on_auto_eoi; | ||
62 | __u8 special_fully_nested_mode; | ||
63 | __u8 init4; /* true if 4 byte init */ | ||
64 | __u8 elcr; /* PIIX edge/trigger selection */ | ||
65 | __u8 elcr_mask; | ||
66 | }; | ||
67 | |||
68 | #define KVM_IOAPIC_NUM_PINS 24 | ||
69 | struct kvm_ioapic_state { | ||
70 | __u64 base_address; | ||
71 | __u32 ioregsel; | ||
72 | __u32 id; | ||
73 | __u32 irr; | ||
74 | __u32 pad; | ||
75 | union { | ||
76 | __u64 bits; | ||
77 | struct { | ||
78 | __u8 vector; | ||
79 | __u8 delivery_mode:3; | ||
80 | __u8 dest_mode:1; | ||
81 | __u8 delivery_status:1; | ||
82 | __u8 polarity:1; | ||
83 | __u8 remote_irr:1; | ||
84 | __u8 trig_mode:1; | ||
85 | __u8 mask:1; | ||
86 | __u8 reserve:7; | ||
87 | __u8 reserved[4]; | ||
88 | __u8 dest_id; | ||
89 | } fields; | ||
90 | } redirtbl[KVM_IOAPIC_NUM_PINS]; | ||
91 | }; | ||
92 | |||
93 | #define KVM_IRQCHIP_PIC_MASTER 0 | ||
94 | #define KVM_IRQCHIP_PIC_SLAVE 1 | ||
95 | #define KVM_IRQCHIP_IOAPIC 2 | ||
96 | 48 | ||
97 | struct kvm_irqchip { | 49 | struct kvm_irqchip { |
98 | __u32 chip_id; | 50 | __u32 chip_id; |
99 | __u32 pad; | 51 | __u32 pad; |
100 | union { | 52 | union { |
101 | char dummy[512]; /* reserving space */ | 53 | char dummy[512]; /* reserving space */ |
54 | #ifdef CONFIG_X86 | ||
102 | struct kvm_pic_state pic; | 55 | struct kvm_pic_state pic; |
56 | #endif | ||
57 | #if defined(CONFIG_X86) || defined(CONFIG_IA64) | ||
103 | struct kvm_ioapic_state ioapic; | 58 | struct kvm_ioapic_state ioapic; |
59 | #endif | ||
104 | } chip; | 60 | } chip; |
105 | }; | 61 | }; |
106 | 62 | ||
@@ -116,6 +72,7 @@ struct kvm_irqchip { | |||
116 | #define KVM_EXIT_FAIL_ENTRY 9 | 72 | #define KVM_EXIT_FAIL_ENTRY 9 |
117 | #define KVM_EXIT_INTR 10 | 73 | #define KVM_EXIT_INTR 10 |
118 | #define KVM_EXIT_SET_TPR 11 | 74 | #define KVM_EXIT_SET_TPR 11 |
75 | #define KVM_EXIT_TPR_ACCESS 12 | ||
119 | 76 | ||
120 | /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ | 77 | /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ |
121 | struct kvm_run { | 78 | struct kvm_run { |
@@ -174,90 +131,17 @@ struct kvm_run { | |||
174 | __u32 longmode; | 131 | __u32 longmode; |
175 | __u32 pad; | 132 | __u32 pad; |
176 | } hypercall; | 133 | } hypercall; |
134 | /* KVM_EXIT_TPR_ACCESS */ | ||
135 | struct { | ||
136 | __u64 rip; | ||
137 | __u32 is_write; | ||
138 | __u32 pad; | ||
139 | } tpr_access; | ||
177 | /* Fix the size of the union. */ | 140 | /* Fix the size of the union. */ |
178 | char padding[256]; | 141 | char padding[256]; |
179 | }; | 142 | }; |
180 | }; | 143 | }; |
181 | 144 | ||
182 | /* for KVM_GET_REGS and KVM_SET_REGS */ | ||
183 | struct kvm_regs { | ||
184 | /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ | ||
185 | __u64 rax, rbx, rcx, rdx; | ||
186 | __u64 rsi, rdi, rsp, rbp; | ||
187 | __u64 r8, r9, r10, r11; | ||
188 | __u64 r12, r13, r14, r15; | ||
189 | __u64 rip, rflags; | ||
190 | }; | ||
191 | |||
192 | /* for KVM_GET_FPU and KVM_SET_FPU */ | ||
193 | struct kvm_fpu { | ||
194 | __u8 fpr[8][16]; | ||
195 | __u16 fcw; | ||
196 | __u16 fsw; | ||
197 | __u8 ftwx; /* in fxsave format */ | ||
198 | __u8 pad1; | ||
199 | __u16 last_opcode; | ||
200 | __u64 last_ip; | ||
201 | __u64 last_dp; | ||
202 | __u8 xmm[16][16]; | ||
203 | __u32 mxcsr; | ||
204 | __u32 pad2; | ||
205 | }; | ||
206 | |||
207 | /* for KVM_GET_LAPIC and KVM_SET_LAPIC */ | ||
208 | #define KVM_APIC_REG_SIZE 0x400 | ||
209 | struct kvm_lapic_state { | ||
210 | char regs[KVM_APIC_REG_SIZE]; | ||
211 | }; | ||
212 | |||
213 | struct kvm_segment { | ||
214 | __u64 base; | ||
215 | __u32 limit; | ||
216 | __u16 selector; | ||
217 | __u8 type; | ||
218 | __u8 present, dpl, db, s, l, g, avl; | ||
219 | __u8 unusable; | ||
220 | __u8 padding; | ||
221 | }; | ||
222 | |||
223 | struct kvm_dtable { | ||
224 | __u64 base; | ||
225 | __u16 limit; | ||
226 | __u16 padding[3]; | ||
227 | }; | ||
228 | |||
229 | /* for KVM_GET_SREGS and KVM_SET_SREGS */ | ||
230 | struct kvm_sregs { | ||
231 | /* out (KVM_GET_SREGS) / in (KVM_SET_SREGS) */ | ||
232 | struct kvm_segment cs, ds, es, fs, gs, ss; | ||
233 | struct kvm_segment tr, ldt; | ||
234 | struct kvm_dtable gdt, idt; | ||
235 | __u64 cr0, cr2, cr3, cr4, cr8; | ||
236 | __u64 efer; | ||
237 | __u64 apic_base; | ||
238 | __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64]; | ||
239 | }; | ||
240 | |||
241 | struct kvm_msr_entry { | ||
242 | __u32 index; | ||
243 | __u32 reserved; | ||
244 | __u64 data; | ||
245 | }; | ||
246 | |||
247 | /* for KVM_GET_MSRS and KVM_SET_MSRS */ | ||
248 | struct kvm_msrs { | ||
249 | __u32 nmsrs; /* number of msrs in entries */ | ||
250 | __u32 pad; | ||
251 | |||
252 | struct kvm_msr_entry entries[0]; | ||
253 | }; | ||
254 | |||
255 | /* for KVM_GET_MSR_INDEX_LIST */ | ||
256 | struct kvm_msr_list { | ||
257 | __u32 nmsrs; /* number of msrs in entries */ | ||
258 | __u32 indices[0]; | ||
259 | }; | ||
260 | |||
261 | /* for KVM_TRANSLATE */ | 145 | /* for KVM_TRANSLATE */ |
262 | struct kvm_translation { | 146 | struct kvm_translation { |
263 | /* in */ | 147 | /* in */ |
@@ -302,28 +186,24 @@ struct kvm_dirty_log { | |||
302 | }; | 186 | }; |
303 | }; | 187 | }; |
304 | 188 | ||
305 | struct kvm_cpuid_entry { | ||
306 | __u32 function; | ||
307 | __u32 eax; | ||
308 | __u32 ebx; | ||
309 | __u32 ecx; | ||
310 | __u32 edx; | ||
311 | __u32 padding; | ||
312 | }; | ||
313 | |||
314 | /* for KVM_SET_CPUID */ | ||
315 | struct kvm_cpuid { | ||
316 | __u32 nent; | ||
317 | __u32 padding; | ||
318 | struct kvm_cpuid_entry entries[0]; | ||
319 | }; | ||
320 | |||
321 | /* for KVM_SET_SIGNAL_MASK */ | 189 | /* for KVM_SET_SIGNAL_MASK */ |
322 | struct kvm_signal_mask { | 190 | struct kvm_signal_mask { |
323 | __u32 len; | 191 | __u32 len; |
324 | __u8 sigset[0]; | 192 | __u8 sigset[0]; |
325 | }; | 193 | }; |
326 | 194 | ||
195 | /* for KVM_TPR_ACCESS_REPORTING */ | ||
196 | struct kvm_tpr_access_ctl { | ||
197 | __u32 enabled; | ||
198 | __u32 flags; | ||
199 | __u32 reserved[8]; | ||
200 | }; | ||
201 | |||
202 | /* for KVM_SET_VAPIC_ADDR */ | ||
203 | struct kvm_vapic_addr { | ||
204 | __u64 vapic_addr; | ||
205 | }; | ||
206 | |||
327 | #define KVMIO 0xAE | 207 | #define KVMIO 0xAE |
328 | 208 | ||
329 | /* | 209 | /* |
@@ -347,11 +227,21 @@ struct kvm_signal_mask { | |||
347 | */ | 227 | */ |
348 | #define KVM_CAP_IRQCHIP 0 | 228 | #define KVM_CAP_IRQCHIP 0 |
349 | #define KVM_CAP_HLT 1 | 229 | #define KVM_CAP_HLT 1 |
230 | #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 | ||
231 | #define KVM_CAP_USER_MEMORY 3 | ||
232 | #define KVM_CAP_SET_TSS_ADDR 4 | ||
233 | #define KVM_CAP_EXT_CPUID 5 | ||
234 | #define KVM_CAP_VAPIC 6 | ||
350 | 235 | ||
351 | /* | 236 | /* |
352 | * ioctls for VM fds | 237 | * ioctls for VM fds |
353 | */ | 238 | */ |
354 | #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) | 239 | #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) |
240 | #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) | ||
241 | #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) | ||
242 | #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46,\ | ||
243 | struct kvm_userspace_memory_region) | ||
244 | #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) | ||
355 | /* | 245 | /* |
356 | * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns | 246 | * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns |
357 | * a vcpu fd. | 247 | * a vcpu fd. |
@@ -359,6 +249,7 @@ struct kvm_signal_mask { | |||
359 | #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) | 249 | #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) |
360 | #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) | 250 | #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) |
361 | #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) | 251 | #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) |
252 | #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x48, struct kvm_cpuid2) | ||
362 | /* Device model IOC */ | 253 | /* Device model IOC */ |
363 | #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) | 254 | #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) |
364 | #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) | 255 | #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) |
@@ -384,5 +275,11 @@ struct kvm_signal_mask { | |||
384 | #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) | 275 | #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) |
385 | #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) | 276 | #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) |
386 | #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) | 277 | #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) |
278 | #define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) | ||
279 | #define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2) | ||
280 | /* Available with KVM_CAP_VAPIC */ | ||
281 | #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl) | ||
282 | /* Available with KVM_CAP_VAPIC */ | ||
283 | #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) | ||
387 | 284 | ||
388 | #endif | 285 | #endif |