10437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#ifndef _ASM_X86_KVM_H
20437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define _ASM_X86_KVM_H
30437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
40437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/*
50437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris * KVM x86 specific structures and definitions
60437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris *
70437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris */
80437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
90437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#include <linux/types.h>
100437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#include <linux/ioctl.h>
110437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
120437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define DE_VECTOR 0
130437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define DB_VECTOR 1
140437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define BP_VECTOR 3
150437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define OF_VECTOR 4
160437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define BR_VECTOR 5
170437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define UD_VECTOR 6
180437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define NM_VECTOR 7
190437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define DF_VECTOR 8
200437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define TS_VECTOR 10
210437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define NP_VECTOR 11
220437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define SS_VECTOR 12
230437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define GP_VECTOR 13
240437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define PF_VECTOR 14
250437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define MF_VECTOR 16
267c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris#define AC_VECTOR 17
270437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define MC_VECTOR 18
287c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris#define XM_VECTOR 19
297c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris#define VE_VECTOR 20
300437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
310437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* Select x86 specific features in <linux/kvm.h> */
320437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_PIT
330437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_IOAPIC
340437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_IRQ_LINE
350437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_MSI
360437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_USER_NMI
370437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_GUEST_DEBUG
380437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_MSIX
390437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_MCE
400437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_PIT_STATE2
410437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_XEN_HVM
420437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_VCPU_EVENTS
430437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_DEBUGREGS
440437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_XSAVE
450437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_XCRS
460437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define __KVM_HAVE_READONLY_MEM
470437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
480437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* Architectural interrupt line count. */
490437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_NR_INTERRUPTS 256
500437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
510437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_memory_alias {
520437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 slot;  /* this has a different namespace than memory slots */
530437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 flags;
540437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 guest_phys_addr;
550437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 memory_size;
560437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 target_phys_addr;
570437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
580437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
590437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
600437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_pic_state {
610437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 last_irr;	/* edge detection */
620437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 irr;		/* interrupt request register */
630437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 imr;		/* interrupt mask register */
640437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 isr;		/* interrupt service register */
650437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 priority_add;	/* highest irq priority */
660437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 irq_base;
670437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 read_reg_select;
680437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 poll;
690437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 special_mask;
700437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 init_state;
710437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 auto_eoi;
720437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 rotate_on_auto_eoi;
730437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 special_fully_nested_mode;
740437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 init4;		/* true if 4 byte init */
750437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 elcr;		/* PIIX edge/trigger selection */
760437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 elcr_mask;
770437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
780437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
790437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_IOAPIC_NUM_PINS  24
800437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_ioapic_state {
810437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 base_address;
820437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 ioregsel;
830437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 id;
840437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 irr;
850437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 pad;
860437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	union {
870437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u64 bits;
880437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		struct {
890437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris			__u8 vector;
900437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris			__u8 delivery_mode:3;
910437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris			__u8 dest_mode:1;
920437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris			__u8 delivery_status:1;
930437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris			__u8 polarity:1;
940437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris			__u8 remote_irr:1;
950437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris			__u8 trig_mode:1;
960437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris			__u8 mask:1;
970437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris			__u8 reserve:7;
980437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris			__u8 reserved[4];
990437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris			__u8 dest_id;
1000437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		} fields;
1010437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	} redirtbl[KVM_IOAPIC_NUM_PINS];
1020437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
1030437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1040437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_IRQCHIP_PIC_MASTER   0
1050437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_IRQCHIP_PIC_SLAVE    1
1060437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_IRQCHIP_IOAPIC       2
1070437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_NR_IRQCHIPS          3
1080437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
10912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define KVM_RUN_X86_SMM		 (1 << 0)
11012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
1110437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_GET_REGS and KVM_SET_REGS */
1120437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_regs {
1130437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	/* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
1140437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 rax, rbx, rcx, rdx;
1150437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 rsi, rdi, rsp, rbp;
1160437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 r8,  r9,  r10, r11;
1170437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 r12, r13, r14, r15;
1180437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 rip, rflags;
1190437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
1200437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1210437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_GET_LAPIC and KVM_SET_LAPIC */
1220437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_APIC_REG_SIZE 0x400
1230437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_lapic_state {
1240437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	char regs[KVM_APIC_REG_SIZE];
1250437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
1260437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1270437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_segment {
1280437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 base;
1290437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 limit;
1300437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u16 selector;
1310437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8  type;
1320437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8  present, dpl, db, s, l, g, avl;
1330437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8  unusable;
1340437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8  padding;
1350437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
1360437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1370437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_dtable {
1380437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 base;
1390437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u16 limit;
1400437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u16 padding[3];
1410437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
1420437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1430437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1440437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_GET_SREGS and KVM_SET_SREGS */
1450437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_sregs {
1460437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	/* out (KVM_GET_SREGS) / in (KVM_SET_SREGS) */
1470437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct kvm_segment cs, ds, es, fs, gs, ss;
1480437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct kvm_segment tr, ldt;
1490437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct kvm_dtable gdt, idt;
1500437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 cr0, cr2, cr3, cr4, cr8;
1510437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 efer;
1520437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 apic_base;
1530437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
1540437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
1550437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1560437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_GET_FPU and KVM_SET_FPU */
1570437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_fpu {
1580437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8  fpr[8][16];
1590437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u16 fcw;
1600437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u16 fsw;
1610437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8  ftwx;  /* in fxsave format */
1620437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8  pad1;
1630437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u16 last_opcode;
1640437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 last_ip;
1650437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 last_dp;
1660437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8  xmm[16][16];
1670437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 mxcsr;
1680437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 pad2;
1690437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
1700437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1710437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_msr_entry {
1720437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 index;
1730437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 reserved;
1740437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 data;
1750437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
1760437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1770437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_GET_MSRS and KVM_SET_MSRS */
1780437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_msrs {
1790437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 nmsrs; /* number of msrs in entries */
1800437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 pad;
1810437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1820437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct kvm_msr_entry entries[0];
1830437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
1840437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1850437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_GET_MSR_INDEX_LIST */
1860437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_msr_list {
1870437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 nmsrs; /* number of msrs in entries */
1880437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 indices[0];
1890437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
1900437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1910437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
1920437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_cpuid_entry {
1930437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 function;
1940437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 eax;
1950437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 ebx;
1960437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 ecx;
1970437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 edx;
1980437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 padding;
1990437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
2000437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2010437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_SET_CPUID */
2020437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_cpuid {
2030437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 nent;
2040437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 padding;
2050437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct kvm_cpuid_entry entries[0];
2060437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
2070437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2080437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_cpuid_entry2 {
2090437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 function;
2100437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 index;
2110437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 flags;
2120437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 eax;
2130437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 ebx;
2140437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 ecx;
2150437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 edx;
2160437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 padding[3];
2170437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
2180437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
219e084501669a4e4931c9d648351ecd7d595b81b79Christopher Ferris#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX		BIT(0)
220e084501669a4e4931c9d648351ecd7d595b81b79Christopher Ferris#define KVM_CPUID_FLAG_STATEFUL_FUNC		BIT(1)
221e084501669a4e4931c9d648351ecd7d595b81b79Christopher Ferris#define KVM_CPUID_FLAG_STATE_READ_NEXT		BIT(2)
2220437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2230437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_SET_CPUID2 */
2240437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_cpuid2 {
2250437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 nent;
2260437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 padding;
2270437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct kvm_cpuid_entry2 entries[0];
2280437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
2290437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2300437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_GET_PIT and KVM_SET_PIT */
2310437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_pit_channel_state {
2320437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 count; /* can be 65536 */
2330437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u16 latched_count;
2340437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 count_latched;
2350437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 status_latched;
2360437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 status;
2370437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 read_state;
2380437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 write_state;
2390437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 write_latch;
2400437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 rw_mode;
2410437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 mode;
2420437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 bcd;
2430437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 gate;
2440437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__s64 count_load_time;
2450437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
2460437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2470437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_debug_exit_arch {
2480437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 exception;
2490437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 pad;
2500437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 pc;
2510437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 dr6;
2520437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 dr7;
2530437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
2540437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2550437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_GUESTDBG_USE_SW_BP		0x00010000
2560437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_GUESTDBG_USE_HW_BP		0x00020000
2570437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_GUESTDBG_INJECT_DB		0x00040000
2580437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_GUESTDBG_INJECT_BP		0x00080000
2590437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2600437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_SET_GUEST_DEBUG */
2610437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_guest_debug_arch {
2620437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 debugreg[8];
2630437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
2640437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2650437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_pit_state {
2660437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct kvm_pit_channel_state channels[3];
2670437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
2680437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2690437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_PIT_FLAGS_HPET_LEGACY  0x00000001
2700437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2710437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_pit_state2 {
2720437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct kvm_pit_channel_state channels[3];
2730437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 flags;
2740437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 reserved[9];
2750437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
2760437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2770437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_reinject_control {
2780437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 pit_reinject;
2790437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u8 reserved[31];
2800437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
2810437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2820437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* When set in flags, include corresponding fields on KVM_SET_VCPU_EVENTS */
2830437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_VCPUEVENT_VALID_NMI_PENDING	0x00000001
2840437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_VCPUEVENT_VALID_SIPI_VECTOR	0x00000002
2850437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_VCPUEVENT_VALID_SHADOW	0x00000004
28612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define KVM_VCPUEVENT_VALID_SMM		0x00000008
2870437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2880437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* Interrupt shadow states */
2890437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_X86_SHADOW_INT_MOV_SS	0x01
2900437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_X86_SHADOW_INT_STI		0x02
2910437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
2920437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_GET/SET_VCPU_EVENTS */
2930437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_vcpu_events {
2940437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct {
2950437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 injected;
2960437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 nr;
2970437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 has_error_code;
2980437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 pad;
2990437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u32 error_code;
3000437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	} exception;
3010437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct {
3020437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 injected;
3030437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 nr;
3040437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 soft;
3050437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 shadow;
3060437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	} interrupt;
3070437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct {
3080437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 injected;
3090437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 pending;
3100437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 masked;
3110437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris		__u8 pad;
3120437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	} nmi;
3130437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 sipi_vector;
3140437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 flags;
31512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	struct {
31612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris		__u8 smm;
31712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris		__u8 pending;
31812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris		__u8 smm_inside_nmi;
31912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris		__u8 latched_init;
32012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	} smi;
32112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 reserved[9];
3220437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
3230437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
3240437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_GET/SET_DEBUGREGS */
3250437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_debugregs {
3260437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 db[4];
3270437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 dr6;
3280437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 dr7;
3290437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 flags;
3300437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 reserved[9];
3310437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
3320437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
3330437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* for KVM_CAP_XSAVE */
3340437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_xsave {
3350437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 region[1024];
3360437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
3370437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
3380437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#define KVM_MAX_XCRS	16
3390437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
3400437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_xcr {
3410437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 xcr;
3420437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 reserved;
3430437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 value;
3440437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
3450437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
3460437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_xcrs {
3470437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 nr_xcrs;
3480437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u32 flags;
3490437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	struct kvm_xcr xcrs[KVM_MAX_XCRS];
3500437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris	__u64 padding[16];
3510437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
3520437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
3530437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris/* definition of registers in kvm_run */
3540437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferrisstruct kvm_sync_regs {
3550437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris};
3560437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris
35712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define KVM_X86_QUIRK_LINT0_REENABLED	(1 << 0)
35812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define KVM_X86_QUIRK_CD_NW_CLEARED	(1 << 1)
35912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
3600437c52788a98ab8ea84041c6b1f8d7a93e872f6Christopher Ferris#endif /* _ASM_X86_KVM_H */
361