5 * KVM x86 specific structures and definitions
9 #include <linux/types.h>
10 #include <linux/ioctl.h>
28 /* Select x86 specific features in <linux/kvm.h> */
29 #define __KVM_HAVE_PIT
30 #define __KVM_HAVE_IOAPIC
31 #define __KVM_HAVE_IRQ_LINE
32 #define __KVM_HAVE_MSI
33 #define __KVM_HAVE_USER_NMI
34 #define __KVM_HAVE_GUEST_DEBUG
35 #define __KVM_HAVE_MSIX
36 #define __KVM_HAVE_MCE
37 #define __KVM_HAVE_PIT_STATE2
38 #define __KVM_HAVE_XEN_HVM
39 #define __KVM_HAVE_VCPU_EVENTS
40 #define __KVM_HAVE_DEBUGREGS
41 #define __KVM_HAVE_XSAVE
42 #define __KVM_HAVE_XCRS
43 #define __KVM_HAVE_READONLY_MEM
45 /* Architectural interrupt line count. */
46 #define KVM_NR_INTERRUPTS 256
48 struct kvm_memory_alias
{
49 __u32 slot
; /* this has a different namespace than memory slots */
51 __u64 guest_phys_addr
;
53 __u64 target_phys_addr
;
56 /* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
57 struct kvm_pic_state
{
58 __u8 last_irr
; /* edge detection */
59 __u8 irr
; /* interrupt request register */
60 __u8 imr
; /* interrupt mask register */
61 __u8 isr
; /* interrupt service register */
62 __u8 priority_add
; /* highest irq priority */
69 __u8 rotate_on_auto_eoi
;
70 __u8 special_fully_nested_mode
;
71 __u8 init4
; /* true if 4 byte init */
72 __u8 elcr
; /* PIIX edge/trigger selection */
76 #define KVM_IOAPIC_NUM_PINS 24
77 struct kvm_ioapic_state
{
89 __u8 delivery_status
:1;
98 } redirtbl
[KVM_IOAPIC_NUM_PINS
];
101 #define KVM_IRQCHIP_PIC_MASTER 0
102 #define KVM_IRQCHIP_PIC_SLAVE 1
103 #define KVM_IRQCHIP_IOAPIC 2
104 #define KVM_NR_IRQCHIPS 3
106 /* for KVM_GET_REGS and KVM_SET_REGS */
108 /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
109 __u64 rax
, rbx
, rcx
, rdx
;
110 __u64 rsi
, rdi
, rsp
, rbp
;
111 __u64 r8
, r9
, r10
, r11
;
112 __u64 r12
, r13
, r14
, r15
;
116 /* for KVM_GET_LAPIC and KVM_SET_LAPIC */
117 #define KVM_APIC_REG_SIZE 0x400
118 struct kvm_lapic_state
{
119 char regs
[KVM_APIC_REG_SIZE
];
127 __u8 present
, dpl
, db
, s
, l
, g
, avl
;
139 /* for KVM_GET_SREGS and KVM_SET_SREGS */
141 /* out (KVM_GET_SREGS) / in (KVM_SET_SREGS) */
142 struct kvm_segment cs
, ds
, es
, fs
, gs
, ss
;
143 struct kvm_segment tr
, ldt
;
144 struct kvm_dtable gdt
, idt
;
145 __u64 cr0
, cr2
, cr3
, cr4
, cr8
;
148 __u64 interrupt_bitmap
[(KVM_NR_INTERRUPTS
+ 63) / 64];
151 /* for KVM_GET_FPU and KVM_SET_FPU */
156 __u8 ftwx
; /* in fxsave format */
166 struct kvm_msr_entry
{
172 /* for KVM_GET_MSRS and KVM_SET_MSRS */
174 __u32 nmsrs
; /* number of msrs in entries */
177 struct kvm_msr_entry entries
[0];
180 /* for KVM_GET_MSR_INDEX_LIST */
181 struct kvm_msr_list
{
182 __u32 nmsrs
; /* number of msrs in entries */
187 struct kvm_cpuid_entry
{
196 /* for KVM_SET_CPUID */
200 struct kvm_cpuid_entry entries
[0];
203 struct kvm_cpuid_entry2
{
214 #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX BIT(0)
215 #define KVM_CPUID_FLAG_STATEFUL_FUNC BIT(1)
216 #define KVM_CPUID_FLAG_STATE_READ_NEXT BIT(2)
218 /* for KVM_SET_CPUID2 */
222 struct kvm_cpuid_entry2 entries
[0];
225 /* for KVM_GET_PIT and KVM_SET_PIT */
226 struct kvm_pit_channel_state
{
227 __u32 count
; /* can be 65536 */
239 __s64 count_load_time
;
242 struct kvm_debug_exit_arch
{
250 #define KVM_GUESTDBG_USE_SW_BP 0x00010000
251 #define KVM_GUESTDBG_USE_HW_BP 0x00020000
252 #define KVM_GUESTDBG_INJECT_DB 0x00040000
253 #define KVM_GUESTDBG_INJECT_BP 0x00080000
255 /* for KVM_SET_GUEST_DEBUG */
256 struct kvm_guest_debug_arch
{
260 struct kvm_pit_state
{
261 struct kvm_pit_channel_state channels
[3];
264 #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001
266 struct kvm_pit_state2
{
267 struct kvm_pit_channel_state channels
[3];
272 struct kvm_reinject_control
{
277 /* When set in flags, include corresponding fields on KVM_SET_VCPU_EVENTS */
278 #define KVM_VCPUEVENT_VALID_NMI_PENDING 0x00000001
279 #define KVM_VCPUEVENT_VALID_SIPI_VECTOR 0x00000002
280 #define KVM_VCPUEVENT_VALID_SHADOW 0x00000004
282 /* Interrupt shadow states */
283 #define KVM_X86_SHADOW_INT_MOV_SS 0x01
284 #define KVM_X86_SHADOW_INT_STI 0x02
286 /* for KVM_GET/SET_VCPU_EVENTS */
287 struct kvm_vcpu_events
{
312 /* for KVM_GET/SET_DEBUGREGS */
313 struct kvm_debugregs
{
321 /* for KVM_CAP_XSAVE */
326 #define KVM_MAX_XCRS 16
337 struct kvm_xcr xcrs
[KVM_MAX_XCRS
];
341 /* definition of registers in kvm_run */
342 struct kvm_sync_regs
{
345 #endif /* _ASM_X86_KVM_H */