5 * KVM x86 specific structures and definitions
9 #include <linux/types.h>
10 #include <linux/ioctl.h>
12 /* Select x86 specific features in <linux/kvm.h> */
13 #define __KVM_HAVE_PIT
14 #define __KVM_HAVE_IOAPIC
15 #define __KVM_HAVE_IRQ_LINE
16 #define __KVM_HAVE_DEVICE_ASSIGNMENT
17 #define __KVM_HAVE_MSI
18 #define __KVM_HAVE_USER_NMI
19 #define __KVM_HAVE_GUEST_DEBUG
20 #define __KVM_HAVE_MSIX
21 #define __KVM_HAVE_MCE
22 #define __KVM_HAVE_PIT_STATE2
23 #define __KVM_HAVE_XEN_HVM
24 #define __KVM_HAVE_VCPU_EVENTS
25 #define __KVM_HAVE_DEBUGREGS
26 #define __KVM_HAVE_XSAVE
27 #define __KVM_HAVE_XCRS
28 #define __KVM_HAVE_READONLY_MEM
30 /* Architectural interrupt line count. */
31 #define KVM_NR_INTERRUPTS 256
33 struct kvm_memory_alias {
34 __u32 slot; /* this has a different namespace than memory slots */
36 __u64 guest_phys_addr;
38 __u64 target_phys_addr;
41 /* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
42 struct kvm_pic_state {
43 __u8 last_irr; /* edge detection */
44 __u8 irr; /* interrupt request register */
45 __u8 imr; /* interrupt mask register */
46 __u8 isr; /* interrupt service register */
47 __u8 priority_add; /* highest irq priority */
54 __u8 rotate_on_auto_eoi;
55 __u8 special_fully_nested_mode;
56 __u8 init4; /* true if 4 byte init */
57 __u8 elcr; /* PIIX edge/trigger selection */
61 #define KVM_IOAPIC_NUM_PINS 24
62 struct kvm_ioapic_state {
74 __u8 delivery_status:1;
83 } redirtbl[KVM_IOAPIC_NUM_PINS];
86 #define KVM_IRQCHIP_PIC_MASTER 0
87 #define KVM_IRQCHIP_PIC_SLAVE 1
88 #define KVM_IRQCHIP_IOAPIC 2
89 #define KVM_NR_IRQCHIPS 3
91 /* for KVM_GET_REGS and KVM_SET_REGS */
93 /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
94 __u64 rax, rbx, rcx, rdx;
95 __u64 rsi, rdi, rsp, rbp;
96 __u64 r8, r9, r10, r11;
97 __u64 r12, r13, r14, r15;
101 /* for KVM_GET_LAPIC and KVM_SET_LAPIC */
102 #define KVM_APIC_REG_SIZE 0x400
103 struct kvm_lapic_state {
104 char regs[KVM_APIC_REG_SIZE];
112 __u8 present, dpl, db, s, l, g, avl;
124 /* for KVM_GET_SREGS and KVM_SET_SREGS */
126 /* out (KVM_GET_SREGS) / in (KVM_SET_SREGS) */
127 struct kvm_segment cs, ds, es, fs, gs, ss;
128 struct kvm_segment tr, ldt;
129 struct kvm_dtable gdt, idt;
130 __u64 cr0, cr2, cr3, cr4, cr8;
133 __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
136 /* for KVM_GET_FPU and KVM_SET_FPU */
141 __u8 ftwx; /* in fxsave format */
151 struct kvm_msr_entry {
157 /* for KVM_GET_MSRS and KVM_SET_MSRS */
159 __u32 nmsrs; /* number of msrs in entries */
162 struct kvm_msr_entry entries[0];
165 /* for KVM_GET_MSR_INDEX_LIST */
166 struct kvm_msr_list {
167 __u32 nmsrs; /* number of msrs in entries */
172 struct kvm_cpuid_entry {
181 /* for KVM_SET_CPUID */
185 struct kvm_cpuid_entry entries[0];
188 struct kvm_cpuid_entry2 {
199 #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX 1
200 #define KVM_CPUID_FLAG_STATEFUL_FUNC 2
201 #define KVM_CPUID_FLAG_STATE_READ_NEXT 4
203 /* for KVM_SET_CPUID2 */
207 struct kvm_cpuid_entry2 entries[0];
210 /* for KVM_GET_PIT and KVM_SET_PIT */
211 struct kvm_pit_channel_state {
212 __u32 count; /* can be 65536 */
224 __s64 count_load_time;
227 struct kvm_debug_exit_arch {
235 #define KVM_GUESTDBG_USE_SW_BP 0x00010000
236 #define KVM_GUESTDBG_USE_HW_BP 0x00020000
237 #define KVM_GUESTDBG_INJECT_DB 0x00040000
238 #define KVM_GUESTDBG_INJECT_BP 0x00080000
240 /* for KVM_SET_GUEST_DEBUG */
241 struct kvm_guest_debug_arch {
245 struct kvm_pit_state {
246 struct kvm_pit_channel_state channels[3];
249 #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001
251 struct kvm_pit_state2 {
252 struct kvm_pit_channel_state channels[3];
257 struct kvm_reinject_control {
262 /* When set in flags, include corresponding fields on KVM_SET_VCPU_EVENTS */
263 #define KVM_VCPUEVENT_VALID_NMI_PENDING 0x00000001
264 #define KVM_VCPUEVENT_VALID_SIPI_VECTOR 0x00000002
265 #define KVM_VCPUEVENT_VALID_SHADOW 0x00000004
267 /* Interrupt shadow states */
268 #define KVM_X86_SHADOW_INT_MOV_SS 0x01
269 #define KVM_X86_SHADOW_INT_STI 0x02
271 /* for KVM_GET/SET_VCPU_EVENTS */
272 struct kvm_vcpu_events {
297 /* for KVM_GET/SET_DEBUGREGS */
298 struct kvm_debugregs {
306 /* for KVM_CAP_XSAVE */
311 #define KVM_MAX_XCRS 16
322 struct kvm_xcr xcrs[KVM_MAX_XCRS];
326 /* definition of registers in kvm_run */
327 struct kvm_sync_regs {
330 #endif /* _ASM_X86_KVM_H */