blob: 708b9c32a5da9c2ff095d672fc75db8819a88254 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_KVM_H
2#define _ASM_X86_KVM_H
Jerone Youngf6a40e32007-11-19 17:06:31 -06003
4/*
5 * KVM x86 specific structures and definitions
6 *
7 */
8
Jaswinder Singh Rajputcef37672009-01-30 22:46:08 +05309#include <linux/types.h>
Jerone Youngf6a40e32007-11-19 17:06:31 -060010#include <linux/ioctl.h>
11
Avi Kivity7a0eb192009-01-19 14:57:52 +020012/* Select x86 specific features in <linux/kvm.h> */
13#define __KVM_HAVE_PIT
14#define __KVM_HAVE_IOAPIC
15#define __KVM_HAVE_DEVICE_ASSIGNMENT
16#define __KVM_HAVE_MSI
17#define __KVM_HAVE_USER_NMI
Avi Kivity91b2ae72009-01-19 14:57:52 +020018#define __KVM_HAVE_GUEST_DEBUG
Sheng Yangd510d6c2009-02-25 17:22:28 +080019#define __KVM_HAVE_MSIX
Huang Ying890ca9a2009-05-11 16:48:15 +080020#define __KVM_HAVE_MCE
Avi Kivity7a0eb192009-01-19 14:57:52 +020021
Jerone Young244d57e2007-11-19 17:06:36 -060022/* Architectural interrupt line count. */
23#define KVM_NR_INTERRUPTS 256
24
Jerone Youngf6a40e32007-11-19 17:06:31 -060025struct kvm_memory_alias {
26 __u32 slot; /* this has a different namespace than memory slots */
27 __u32 flags;
28 __u64 guest_phys_addr;
29 __u64 memory_size;
30 __u64 target_phys_addr;
31};
32
Jerone Youngda1386a2007-11-19 17:06:32 -060033/* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
34struct kvm_pic_state {
35 __u8 last_irr; /* edge detection */
36 __u8 irr; /* interrupt request register */
37 __u8 imr; /* interrupt mask register */
38 __u8 isr; /* interrupt service register */
39 __u8 priority_add; /* highest irq priority */
40 __u8 irq_base;
41 __u8 read_reg_select;
42 __u8 poll;
43 __u8 special_mask;
44 __u8 init_state;
45 __u8 auto_eoi;
46 __u8 rotate_on_auto_eoi;
47 __u8 special_fully_nested_mode;
48 __u8 init4; /* true if 4 byte init */
49 __u8 elcr; /* PIIX edge/trigger selection */
50 __u8 elcr_mask;
51};
52
53#define KVM_IOAPIC_NUM_PINS 24
54struct kvm_ioapic_state {
55 __u64 base_address;
56 __u32 ioregsel;
57 __u32 id;
58 __u32 irr;
59 __u32 pad;
60 union {
61 __u64 bits;
62 struct {
63 __u8 vector;
64 __u8 delivery_mode:3;
65 __u8 dest_mode:1;
66 __u8 delivery_status:1;
67 __u8 polarity:1;
68 __u8 remote_irr:1;
69 __u8 trig_mode:1;
70 __u8 mask:1;
71 __u8 reserve:7;
72 __u8 reserved[4];
73 __u8 dest_id;
74 } fields;
75 } redirtbl[KVM_IOAPIC_NUM_PINS];
76};
77
78#define KVM_IRQCHIP_PIC_MASTER 0
79#define KVM_IRQCHIP_PIC_SLAVE 1
80#define KVM_IRQCHIP_IOAPIC 2
81
Jerone Young19d30b12007-11-19 17:06:33 -060082/* for KVM_GET_REGS and KVM_SET_REGS */
83struct kvm_regs {
84 /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
85 __u64 rax, rbx, rcx, rdx;
86 __u64 rsi, rdi, rsp, rbp;
87 __u64 r8, r9, r10, r11;
88 __u64 r12, r13, r14, r15;
89 __u64 rip, rflags;
90};
91
Jerone Youngd9ecf922007-11-19 17:06:34 -060092/* for KVM_GET_LAPIC and KVM_SET_LAPIC */
93#define KVM_APIC_REG_SIZE 0x400
94struct kvm_lapic_state {
95 char regs[KVM_APIC_REG_SIZE];
96};
97
Jerone Young3a56b202007-11-19 17:06:35 -060098struct kvm_segment {
99 __u64 base;
100 __u32 limit;
101 __u16 selector;
102 __u8 type;
103 __u8 present, dpl, db, s, l, g, avl;
104 __u8 unusable;
105 __u8 padding;
106};
107
108struct kvm_dtable {
109 __u64 base;
110 __u16 limit;
111 __u16 padding[3];
112};
113
114
Jerone Young244d57e2007-11-19 17:06:36 -0600115/* for KVM_GET_SREGS and KVM_SET_SREGS */
116struct kvm_sregs {
117 /* out (KVM_GET_SREGS) / in (KVM_SET_SREGS) */
118 struct kvm_segment cs, ds, es, fs, gs, ss;
119 struct kvm_segment tr, ldt;
120 struct kvm_dtable gdt, idt;
121 __u64 cr0, cr2, cr3, cr4, cr8;
122 __u64 efer;
123 __u64 apic_base;
124 __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
125};
126
Christian Ehrhardt6f723c72008-01-08 08:04:50 +0100127/* 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
Jerone Young244d57e2007-11-19 17:06:36 -0600142struct kvm_msr_entry {
143 __u32 index;
144 __u32 reserved;
145 __u64 data;
146};
147
148/* for KVM_GET_MSRS and KVM_SET_MSRS */
149struct kvm_msrs {
150 __u32 nmsrs; /* number of msrs in entries */
151 __u32 pad;
152
153 struct kvm_msr_entry entries[0];
154};
155
156/* for KVM_GET_MSR_INDEX_LIST */
157struct kvm_msr_list {
158 __u32 nmsrs; /* number of msrs in entries */
159 __u32 indices[0];
160};
161
162
Jerone Younga162dd52007-11-19 17:06:37 -0600163struct kvm_cpuid_entry {
164 __u32 function;
165 __u32 eax;
166 __u32 ebx;
167 __u32 ecx;
168 __u32 edx;
169 __u32 padding;
170};
171
172/* for KVM_SET_CPUID */
173struct kvm_cpuid {
174 __u32 nent;
175 __u32 padding;
176 struct kvm_cpuid_entry entries[0];
177};
178
Dan Kenigsberg07716712007-11-21 17:10:04 +0200179struct kvm_cpuid_entry2 {
180 __u32 function;
181 __u32 index;
182 __u32 flags;
183 __u32 eax;
184 __u32 ebx;
185 __u32 ecx;
186 __u32 edx;
187 __u32 padding[3];
188};
189
190#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX 1
191#define KVM_CPUID_FLAG_STATEFUL_FUNC 2
192#define KVM_CPUID_FLAG_STATE_READ_NEXT 4
193
194/* for KVM_SET_CPUID2 */
195struct kvm_cpuid2 {
196 __u32 nent;
197 __u32 padding;
198 struct kvm_cpuid_entry2 entries[0];
199};
Jerone Younga162dd52007-11-19 17:06:37 -0600200
Sheng Yange0f63cb2008-03-04 00:50:59 +0800201/* for KVM_GET_PIT and KVM_SET_PIT */
202struct kvm_pit_channel_state {
203 __u32 count; /* can be 65536 */
204 __u16 latched_count;
205 __u8 count_latched;
206 __u8 status_latched;
207 __u8 status;
208 __u8 read_state;
209 __u8 write_state;
210 __u8 write_latch;
211 __u8 rw_mode;
212 __u8 mode;
213 __u8 bcd;
214 __u8 gate;
215 __s64 count_load_time;
216};
217
Jan Kiszkad0bfb942008-12-15 13:52:10 +0100218struct kvm_debug_exit_arch {
219 __u32 exception;
220 __u32 pad;
221 __u64 pc;
222 __u64 dr6;
223 __u64 dr7;
224};
225
226#define KVM_GUESTDBG_USE_SW_BP 0x00010000
227#define KVM_GUESTDBG_USE_HW_BP 0x00020000
228#define KVM_GUESTDBG_INJECT_DB 0x00040000
229#define KVM_GUESTDBG_INJECT_BP 0x00080000
230
231/* for KVM_SET_GUEST_DEBUG */
232struct kvm_guest_debug_arch {
233 __u64 debugreg[8];
234};
235
Sheng Yange0f63cb2008-03-04 00:50:59 +0800236struct kvm_pit_state {
237 struct kvm_pit_channel_state channels[3];
238};
Marcelo Tosatti52d939a2008-12-30 15:55:06 -0200239
240struct kvm_reinject_control {
241 __u8 pit_reinject;
242 __u8 reserved[31];
243};
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700244#endif /* _ASM_X86_KVM_H */