1 #ifndef __LINUX_KVM_X86_H
2 #define __LINUX_KVM_X86_H
5 * KVM x86 specific structures and definitions
10 #include <linux/ioctl.h>
12 /* Architectural interrupt line count. */
13 #define KVM_NR_INTERRUPTS 256
15 struct kvm_memory_alias
{
16 __u32 slot
; /* this has a different namespace than memory slots */
18 __u64 guest_phys_addr
;
20 __u64 target_phys_addr
;
23 /* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
24 struct kvm_pic_state
{
25 __u8 last_irr
; /* edge detection */
26 __u8 irr
; /* interrupt request register */
27 __u8 imr
; /* interrupt mask register */
28 __u8 isr
; /* interrupt service register */
29 __u8 priority_add
; /* highest irq priority */
36 __u8 rotate_on_auto_eoi
;
37 __u8 special_fully_nested_mode
;
38 __u8 init4
; /* true if 4 byte init */
39 __u8 elcr
; /* PIIX edge/trigger selection */
43 #define KVM_IOAPIC_NUM_PINS 24
44 struct kvm_ioapic_state
{
56 __u8 delivery_status
:1;
65 } redirtbl
[KVM_IOAPIC_NUM_PINS
];
68 #define KVM_IRQCHIP_PIC_MASTER 0
69 #define KVM_IRQCHIP_PIC_SLAVE 1
70 #define KVM_IRQCHIP_IOAPIC 2
72 /* for KVM_GET_REGS and KVM_SET_REGS */
74 /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
75 __u64 rax
, rbx
, rcx
, rdx
;
76 __u64 rsi
, rdi
, rsp
, rbp
;
77 __u64 r8
, r9
, r10
, r11
;
78 __u64 r12
, r13
, r14
, r15
;
82 /* for KVM_GET_LAPIC and KVM_SET_LAPIC */
83 #define KVM_APIC_REG_SIZE 0x400
84 struct kvm_lapic_state
{
85 char regs
[KVM_APIC_REG_SIZE
];
93 __u8 present
, dpl
, db
, s
, l
, g
, avl
;
105 /* for KVM_GET_SREGS and KVM_SET_SREGS */
107 /* out (KVM_GET_SREGS) / in (KVM_SET_SREGS) */
108 struct kvm_segment cs
, ds
, es
, fs
, gs
, ss
;
109 struct kvm_segment tr
, ldt
;
110 struct kvm_dtable gdt
, idt
;
111 __u64 cr0
, cr2
, cr3
, cr4
, cr8
;
114 __u64 interrupt_bitmap
[(KVM_NR_INTERRUPTS
+ 63) / 64];
117 /* for KVM_GET_FPU and KVM_SET_FPU */
122 __u8 ftwx
; /* in fxsave format */
132 struct kvm_msr_entry
{
138 /* for KVM_GET_MSRS and KVM_SET_MSRS */
140 __u32 nmsrs
; /* number of msrs in entries */
143 struct kvm_msr_entry entries
[0];
146 /* for KVM_GET_MSR_INDEX_LIST */
147 struct kvm_msr_list
{
148 __u32 nmsrs
; /* number of msrs in entries */
153 struct kvm_cpuid_entry
{
162 /* for KVM_SET_CPUID */
166 struct kvm_cpuid_entry entries
[0];
169 struct kvm_cpuid_entry2
{
180 #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX 1
181 #define KVM_CPUID_FLAG_STATEFUL_FUNC 2
182 #define KVM_CPUID_FLAG_STATE_READ_NEXT 4
184 /* for KVM_SET_CPUID2 */
188 struct kvm_cpuid_entry2 entries
[0];
191 /* for KVM_GET_PIT and KVM_SET_PIT */
192 struct kvm_pit_channel_state
{
193 __u32 count
; /* can be 65536 */
205 __s64 count_load_time
;
208 struct kvm_pit_state
{
209 struct kvm_pit_channel_state channels
[3];
212 #define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02)
213 #define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03)
214 #define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04)
215 #define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05)
216 #define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06)
217 #define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07)
218 #define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08)
219 #define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09)
220 #define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A)
221 #define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B)
222 #define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C)
223 #define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D)
224 #define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E)
225 #define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F)
226 #define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10)
227 #define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11)
228 #define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12)
229 #define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13)
230 #define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14)