diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-13 13:02:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-13 13:02:11 -0400 |
commit | 3749c66c67fb5c257771815c186bc32290cacf44 (patch) | |
tree | de6634f722a9b79c60fabbd605660e46741f7160 /include/linux | |
parent | 835c34a1687f524c37d4fb8bad18d642c74bed8d (diff) | |
parent | 8a45450d0a559912873428077908f9bc1411042c (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: (106 commits)
KVM: Replace enum by #define
KVM: Skip pio instruction when it is emulated, not executed
KVM: x86 emulator: popf
KVM: x86 emulator: fix src, dst value initialization
KVM: x86 emulator: jmp abs
KVM: x86 emulator: lea
KVM: X86 emulator: jump conditional short
KVM: x86 emulator: imlpement jump conditional relative
KVM: x86 emulator: sort opcodes into ascending order
KVM: Improve emulation failure reporting
KVM: x86 emulator: pushf
KVM: x86 emulator: call near
KVM: x86 emulator: push imm8
KVM: VMX: Fix exit qualification width on i386
KVM: Move main vcpu loop into subarch independent code
KVM: VMX: Move vm entry failure handling to the exit handler
KVM: MMU: Don't do GFP_NOWAIT allocations
KVM: Rename kvm_arch_ops to kvm_x86_ops
KVM: Simplify memory allocation
KVM: Hoist SVM's get_cs_db_l_bits into core code.
...
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/kvm.h | 128 |
1 files changed, 106 insertions, 22 deletions
diff --git a/include/linux/kvm.h b/include/linux/kvm.h index e6edca81ab84..057a7f34ee36 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h | |||
@@ -4,8 +4,7 @@ | |||
4 | /* | 4 | /* |
5 | * Userspace interface for /dev/kvm - kernel based virtual machine | 5 | * Userspace interface for /dev/kvm - kernel based virtual machine |
6 | * | 6 | * |
7 | * Note: this interface is considered experimental and may change without | 7 | * Note: you must update KVM_API_VERSION if you change this interface. |
8 | * notice. | ||
9 | */ | 8 | */ |
10 | 9 | ||
11 | #include <asm/types.h> | 10 | #include <asm/types.h> |
@@ -13,14 +12,8 @@ | |||
13 | 12 | ||
14 | #define KVM_API_VERSION 12 | 13 | #define KVM_API_VERSION 12 |
15 | 14 | ||
16 | /* | 15 | /* Architectural interrupt line count. */ |
17 | * Architectural interrupt line count, and the size of the bitmap needed | ||
18 | * to hold them. | ||
19 | */ | ||
20 | #define KVM_NR_INTERRUPTS 256 | 16 | #define KVM_NR_INTERRUPTS 256 |
21 | #define KVM_IRQ_BITMAP_SIZE_BYTES ((KVM_NR_INTERRUPTS + 7) / 8) | ||
22 | #define KVM_IRQ_BITMAP_SIZE(type) (KVM_IRQ_BITMAP_SIZE_BYTES / sizeof(type)) | ||
23 | |||
24 | 17 | ||
25 | /* for KVM_CREATE_MEMORY_REGION */ | 18 | /* for KVM_CREATE_MEMORY_REGION */ |
26 | struct kvm_memory_region { | 19 | struct kvm_memory_region { |
@@ -41,20 +34,89 @@ struct kvm_memory_alias { | |||
41 | __u64 target_phys_addr; | 34 | __u64 target_phys_addr; |
42 | }; | 35 | }; |
43 | 36 | ||
44 | enum kvm_exit_reason { | 37 | /* for KVM_IRQ_LINE */ |
45 | KVM_EXIT_UNKNOWN = 0, | 38 | struct kvm_irq_level { |
46 | KVM_EXIT_EXCEPTION = 1, | 39 | /* |
47 | KVM_EXIT_IO = 2, | 40 | * ACPI gsi notion of irq. |
48 | KVM_EXIT_HYPERCALL = 3, | 41 | * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47.. |
49 | KVM_EXIT_DEBUG = 4, | 42 | * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23.. |
50 | KVM_EXIT_HLT = 5, | 43 | */ |
51 | KVM_EXIT_MMIO = 6, | 44 | __u32 irq; |
52 | KVM_EXIT_IRQ_WINDOW_OPEN = 7, | 45 | __u32 level; |
53 | KVM_EXIT_SHUTDOWN = 8, | 46 | }; |
54 | KVM_EXIT_FAIL_ENTRY = 9, | 47 | |
55 | KVM_EXIT_INTR = 10, | 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]; | ||
56 | }; | 91 | }; |
57 | 92 | ||
93 | #define KVM_IRQCHIP_PIC_MASTER 0 | ||
94 | #define KVM_IRQCHIP_PIC_SLAVE 1 | ||
95 | #define KVM_IRQCHIP_IOAPIC 2 | ||
96 | |||
97 | struct kvm_irqchip { | ||
98 | __u32 chip_id; | ||
99 | __u32 pad; | ||
100 | union { | ||
101 | char dummy[512]; /* reserving space */ | ||
102 | struct kvm_pic_state pic; | ||
103 | struct kvm_ioapic_state ioapic; | ||
104 | } chip; | ||
105 | }; | ||
106 | |||
107 | #define KVM_EXIT_UNKNOWN 0 | ||
108 | #define KVM_EXIT_EXCEPTION 1 | ||
109 | #define KVM_EXIT_IO 2 | ||
110 | #define KVM_EXIT_HYPERCALL 3 | ||
111 | #define KVM_EXIT_DEBUG 4 | ||
112 | #define KVM_EXIT_HLT 5 | ||
113 | #define KVM_EXIT_MMIO 6 | ||
114 | #define KVM_EXIT_IRQ_WINDOW_OPEN 7 | ||
115 | #define KVM_EXIT_SHUTDOWN 8 | ||
116 | #define KVM_EXIT_FAIL_ENTRY 9 | ||
117 | #define KVM_EXIT_INTR 10 | ||
118 | #define KVM_EXIT_SET_TPR 11 | ||
119 | |||
58 | /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ | 120 | /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ |
59 | struct kvm_run { | 121 | struct kvm_run { |
60 | /* in */ | 122 | /* in */ |
@@ -106,11 +168,14 @@ struct kvm_run { | |||
106 | } mmio; | 168 | } mmio; |
107 | /* KVM_EXIT_HYPERCALL */ | 169 | /* KVM_EXIT_HYPERCALL */ |
108 | struct { | 170 | struct { |
171 | __u64 nr; | ||
109 | __u64 args[6]; | 172 | __u64 args[6]; |
110 | __u64 ret; | 173 | __u64 ret; |
111 | __u32 longmode; | 174 | __u32 longmode; |
112 | __u32 pad; | 175 | __u32 pad; |
113 | } hypercall; | 176 | } hypercall; |
177 | /* Fix the size of the union. */ | ||
178 | char padding[256]; | ||
114 | }; | 179 | }; |
115 | }; | 180 | }; |
116 | 181 | ||
@@ -139,6 +204,12 @@ struct kvm_fpu { | |||
139 | __u32 pad2; | 204 | __u32 pad2; |
140 | }; | 205 | }; |
141 | 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 | |||
142 | struct kvm_segment { | 213 | struct kvm_segment { |
143 | __u64 base; | 214 | __u64 base; |
144 | __u32 limit; | 215 | __u32 limit; |
@@ -164,7 +235,7 @@ struct kvm_sregs { | |||
164 | __u64 cr0, cr2, cr3, cr4, cr8; | 235 | __u64 cr0, cr2, cr3, cr4, cr8; |
165 | __u64 efer; | 236 | __u64 efer; |
166 | __u64 apic_base; | 237 | __u64 apic_base; |
167 | __u64 interrupt_bitmap[KVM_IRQ_BITMAP_SIZE(__u64)]; | 238 | __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64]; |
168 | }; | 239 | }; |
169 | 240 | ||
170 | struct kvm_msr_entry { | 241 | struct kvm_msr_entry { |
@@ -272,6 +343,12 @@ struct kvm_signal_mask { | |||
272 | #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ | 343 | #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ |
273 | 344 | ||
274 | /* | 345 | /* |
346 | * Extension capability list. | ||
347 | */ | ||
348 | #define KVM_CAP_IRQCHIP 0 | ||
349 | #define KVM_CAP_HLT 1 | ||
350 | |||
351 | /* | ||
275 | * ioctls for VM fds | 352 | * ioctls for VM fds |
276 | */ | 353 | */ |
277 | #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) | 354 | #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) |
@@ -282,6 +359,11 @@ struct kvm_signal_mask { | |||
282 | #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) | 359 | #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) |
283 | #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) | 360 | #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) | 361 | #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) |
362 | /* Device model IOC */ | ||
363 | #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) | ||
364 | #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) | ||
365 | #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) | ||
366 | #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) | ||
285 | 367 | ||
286 | /* | 368 | /* |
287 | * ioctls for vcpu fds | 369 | * ioctls for vcpu fds |
@@ -300,5 +382,7 @@ struct kvm_signal_mask { | |||
300 | #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask) | 382 | #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask) |
301 | #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu) | 383 | #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu) |
302 | #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) | 384 | #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) |
385 | #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) | ||
386 | #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) | ||
303 | 387 | ||
304 | #endif | 388 | #endif |