151b24e34SJan Kiszka #ifndef __LINUX_KVM_H 251b24e34SJan Kiszka #define __LINUX_KVM_H 351b24e34SJan Kiszka 451b24e34SJan Kiszka /* 551b24e34SJan Kiszka * Userspace interface for /dev/kvm - kernel based virtual machine 651b24e34SJan Kiszka * 751b24e34SJan Kiszka * Note: you must update KVM_API_VERSION if you change this interface. 851b24e34SJan Kiszka */ 951b24e34SJan Kiszka 1051b24e34SJan Kiszka #include <linux/types.h> 1151b24e34SJan Kiszka 1251b24e34SJan Kiszka #include <linux/ioctl.h> 1351b24e34SJan Kiszka #include <asm/kvm.h> 1451b24e34SJan Kiszka 1551b24e34SJan Kiszka #define KVM_API_VERSION 12 1651b24e34SJan Kiszka 1751b24e34SJan Kiszka /* *** Deprecated interfaces *** */ 1851b24e34SJan Kiszka 1951b24e34SJan Kiszka #define KVM_TRC_SHIFT 16 2051b24e34SJan Kiszka 2151b24e34SJan Kiszka #define KVM_TRC_ENTRYEXIT (1 << KVM_TRC_SHIFT) 2251b24e34SJan Kiszka #define KVM_TRC_HANDLER (1 << (KVM_TRC_SHIFT + 1)) 2351b24e34SJan Kiszka 2451b24e34SJan Kiszka #define KVM_TRC_VMENTRY (KVM_TRC_ENTRYEXIT + 0x01) 2551b24e34SJan Kiszka #define KVM_TRC_VMEXIT (KVM_TRC_ENTRYEXIT + 0x02) 2651b24e34SJan Kiszka #define KVM_TRC_PAGE_FAULT (KVM_TRC_HANDLER + 0x01) 2751b24e34SJan Kiszka 2851b24e34SJan Kiszka #define KVM_TRC_HEAD_SIZE 12 2951b24e34SJan Kiszka #define KVM_TRC_CYCLE_SIZE 8 3051b24e34SJan Kiszka #define KVM_TRC_EXTRA_MAX 7 3151b24e34SJan Kiszka 3251b24e34SJan Kiszka #define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02) 3351b24e34SJan Kiszka #define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03) 3451b24e34SJan Kiszka #define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04) 3551b24e34SJan Kiszka #define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05) 3651b24e34SJan Kiszka #define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06) 3751b24e34SJan Kiszka #define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07) 3851b24e34SJan Kiszka #define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08) 3951b24e34SJan Kiszka #define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09) 4051b24e34SJan Kiszka #define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A) 4151b24e34SJan Kiszka #define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B) 4251b24e34SJan Kiszka #define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C) 4351b24e34SJan Kiszka #define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D) 4451b24e34SJan Kiszka #define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E) 4551b24e34SJan Kiszka #define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F) 4651b24e34SJan Kiszka #define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10) 4751b24e34SJan Kiszka #define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11) 4851b24e34SJan Kiszka #define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12) 4951b24e34SJan Kiszka #define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13) 5051b24e34SJan Kiszka #define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14) 5151b24e34SJan Kiszka #define KVM_TRC_TDP_FAULT (KVM_TRC_HANDLER + 0x15) 5251b24e34SJan Kiszka #define KVM_TRC_GTLB_WRITE (KVM_TRC_HANDLER + 0x16) 5351b24e34SJan Kiszka #define KVM_TRC_STLB_WRITE (KVM_TRC_HANDLER + 0x17) 5451b24e34SJan Kiszka #define KVM_TRC_STLB_INVAL (KVM_TRC_HANDLER + 0x18) 5551b24e34SJan Kiszka #define KVM_TRC_PPC_INSTR (KVM_TRC_HANDLER + 0x19) 5651b24e34SJan Kiszka 5751b24e34SJan Kiszka struct kvm_user_trace_setup { 5851b24e34SJan Kiszka __u32 buf_size; 5951b24e34SJan Kiszka __u32 buf_nr; 6051b24e34SJan Kiszka }; 6151b24e34SJan Kiszka 6251b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_W_0x06 \ 6351b24e34SJan Kiszka _IOW(KVMIO, 0x06, struct kvm_user_trace_setup) 6451b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_0x07 _IO(KVMIO, 0x07) 6551b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_0x08 _IO(KVMIO, 0x08) 6651b24e34SJan Kiszka 6751b24e34SJan Kiszka #define __KVM_DEPRECATED_VM_R_0x70 _IOR(KVMIO, 0x70, struct kvm_assigned_irq) 6851b24e34SJan Kiszka 6951b24e34SJan Kiszka struct kvm_breakpoint { 7051b24e34SJan Kiszka __u32 enabled; 7151b24e34SJan Kiszka __u32 padding; 7251b24e34SJan Kiszka __u64 address; 7351b24e34SJan Kiszka }; 7451b24e34SJan Kiszka 7551b24e34SJan Kiszka struct kvm_debug_guest { 7651b24e34SJan Kiszka __u32 enabled; 7751b24e34SJan Kiszka __u32 pad; 7851b24e34SJan Kiszka struct kvm_breakpoint breakpoints[4]; 7951b24e34SJan Kiszka __u32 singlestep; 8051b24e34SJan Kiszka }; 8151b24e34SJan Kiszka 8251b24e34SJan Kiszka #define __KVM_DEPRECATED_VCPU_W_0x87 _IOW(KVMIO, 0x87, struct kvm_debug_guest) 8351b24e34SJan Kiszka 8451b24e34SJan Kiszka /* *** End of deprecated interfaces *** */ 8551b24e34SJan Kiszka 8651b24e34SJan Kiszka 8751b24e34SJan Kiszka /* for KVM_CREATE_MEMORY_REGION */ 8851b24e34SJan Kiszka struct kvm_memory_region { 8951b24e34SJan Kiszka __u32 slot; 9051b24e34SJan Kiszka __u32 flags; 9151b24e34SJan Kiszka __u64 guest_phys_addr; 9251b24e34SJan Kiszka __u64 memory_size; /* bytes */ 9351b24e34SJan Kiszka }; 9451b24e34SJan Kiszka 9551b24e34SJan Kiszka /* for KVM_SET_USER_MEMORY_REGION */ 9651b24e34SJan Kiszka struct kvm_userspace_memory_region { 9751b24e34SJan Kiszka __u32 slot; 9851b24e34SJan Kiszka __u32 flags; 9951b24e34SJan Kiszka __u64 guest_phys_addr; 10051b24e34SJan Kiszka __u64 memory_size; /* bytes */ 10151b24e34SJan Kiszka __u64 userspace_addr; /* start of the userspace allocated memory */ 10251b24e34SJan Kiszka }; 10351b24e34SJan Kiszka 104716b8e4dSAlex Williamson /* 105716b8e4dSAlex Williamson * The bit 0 ~ bit 15 of kvm_memory_region::flags are visible for userspace, 106716b8e4dSAlex Williamson * other bits are reserved for kvm internal use which are defined in 107716b8e4dSAlex Williamson * include/linux/kvm_host.h. 108716b8e4dSAlex Williamson */ 109716b8e4dSAlex Williamson #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) 110716b8e4dSAlex Williamson #define KVM_MEM_READONLY (1UL << 1) 11151b24e34SJan Kiszka 11251b24e34SJan Kiszka /* for KVM_IRQ_LINE */ 11351b24e34SJan Kiszka struct kvm_irq_level { 11451b24e34SJan Kiszka /* 11551b24e34SJan Kiszka * ACPI gsi notion of irq. 11651b24e34SJan Kiszka * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47.. 11751b24e34SJan Kiszka * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23.. 118eadd0e44SPeter Maydell * For ARM: See Documentation/virtual/kvm/api.txt 11951b24e34SJan Kiszka */ 12051b24e34SJan Kiszka union { 12151b24e34SJan Kiszka __u32 irq; 12251b24e34SJan Kiszka __s32 status; 12351b24e34SJan Kiszka }; 12451b24e34SJan Kiszka __u32 level; 12551b24e34SJan Kiszka }; 12651b24e34SJan Kiszka 12751b24e34SJan Kiszka 12851b24e34SJan Kiszka struct kvm_irqchip { 12951b24e34SJan Kiszka __u32 chip_id; 13051b24e34SJan Kiszka __u32 pad; 13151b24e34SJan Kiszka union { 13251b24e34SJan Kiszka char dummy[512]; /* reserving space */ 13351b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 13451b24e34SJan Kiszka struct kvm_pic_state pic; 13551b24e34SJan Kiszka #endif 13651b24e34SJan Kiszka #ifdef __KVM_HAVE_IOAPIC 13751b24e34SJan Kiszka struct kvm_ioapic_state ioapic; 13851b24e34SJan Kiszka #endif 13951b24e34SJan Kiszka } chip; 14051b24e34SJan Kiszka }; 14151b24e34SJan Kiszka 14251b24e34SJan Kiszka /* for KVM_CREATE_PIT2 */ 14351b24e34SJan Kiszka struct kvm_pit_config { 14451b24e34SJan Kiszka __u32 flags; 14551b24e34SJan Kiszka __u32 pad[15]; 14651b24e34SJan Kiszka }; 14751b24e34SJan Kiszka 14851b24e34SJan Kiszka #define KVM_PIT_SPEAKER_DUMMY 1 14951b24e34SJan Kiszka 1507a52ce8aSCornelia Huck struct kvm_s390_skeys { 1517a52ce8aSCornelia Huck __u64 start_gfn; 1527a52ce8aSCornelia Huck __u64 count; 1537a52ce8aSCornelia Huck __u64 skeydata_addr; 1547a52ce8aSCornelia Huck __u32 flags; 1557a52ce8aSCornelia Huck __u32 reserved[9]; 1567a52ce8aSCornelia Huck }; 157fff02bc0SPaolo Bonzini 158fff02bc0SPaolo Bonzini struct kvm_hyperv_exit { 159fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV_SYNIC 1 160fff02bc0SPaolo Bonzini __u32 type; 161fff02bc0SPaolo Bonzini union { 162fff02bc0SPaolo Bonzini struct { 163fff02bc0SPaolo Bonzini __u32 msr; 164fff02bc0SPaolo Bonzini __u64 control; 165fff02bc0SPaolo Bonzini __u64 evt_page; 166fff02bc0SPaolo Bonzini __u64 msg_page; 167fff02bc0SPaolo Bonzini } synic; 168fff02bc0SPaolo Bonzini } u; 169fff02bc0SPaolo Bonzini }; 170fff02bc0SPaolo Bonzini 1717a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS_NONE 1 1727a52ce8aSCornelia Huck #define KVM_S390_SKEYS_MAX 1048576 1737a52ce8aSCornelia Huck 17451b24e34SJan Kiszka #define KVM_EXIT_UNKNOWN 0 17551b24e34SJan Kiszka #define KVM_EXIT_EXCEPTION 1 17651b24e34SJan Kiszka #define KVM_EXIT_IO 2 17751b24e34SJan Kiszka #define KVM_EXIT_HYPERCALL 3 17851b24e34SJan Kiszka #define KVM_EXIT_DEBUG 4 17951b24e34SJan Kiszka #define KVM_EXIT_HLT 5 18051b24e34SJan Kiszka #define KVM_EXIT_MMIO 6 18151b24e34SJan Kiszka #define KVM_EXIT_IRQ_WINDOW_OPEN 7 18251b24e34SJan Kiszka #define KVM_EXIT_SHUTDOWN 8 18351b24e34SJan Kiszka #define KVM_EXIT_FAIL_ENTRY 9 18451b24e34SJan Kiszka #define KVM_EXIT_INTR 10 18551b24e34SJan Kiszka #define KVM_EXIT_SET_TPR 11 18651b24e34SJan Kiszka #define KVM_EXIT_TPR_ACCESS 12 18751b24e34SJan Kiszka #define KVM_EXIT_S390_SIEIC 13 18851b24e34SJan Kiszka #define KVM_EXIT_S390_RESET 14 189a9fd1654SJens Freimann #define KVM_EXIT_DCR 15 /* deprecated */ 19051b24e34SJan Kiszka #define KVM_EXIT_NMI 16 19151b24e34SJan Kiszka #define KVM_EXIT_INTERNAL_ERROR 17 19251b24e34SJan Kiszka #define KVM_EXIT_OSI 18 1937c6da3deSAlexander Graf #define KVM_EXIT_PAPR_HCALL 19 1941529ae1bSAlexander Graf #define KVM_EXIT_S390_UCONTROL 20 195d4834ff9SAlexander Graf #define KVM_EXIT_WATCHDOG 21 196d3dccee1SAlexander Graf #define KVM_EXIT_S390_TSCH 22 197d3dccee1SAlexander Graf #define KVM_EXIT_EPR 23 198b061808dSAlexander Graf #define KVM_EXIT_SYSTEM_EVENT 24 1997a52ce8aSCornelia Huck #define KVM_EXIT_S390_STSI 25 2003a824b15SPaolo Bonzini #define KVM_EXIT_IOAPIC_EOI 26 201fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV 27 20251b24e34SJan Kiszka 20351b24e34SJan Kiszka /* For KVM_EXIT_INTERNAL_ERROR */ 204d4834ff9SAlexander Graf /* Emulate instruction failed. */ 20551b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_EMULATION 1 206d4834ff9SAlexander Graf /* Encounter unexpected simultaneous exceptions. */ 20751b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_SIMUL_EX 2 208d4834ff9SAlexander Graf /* Encounter unexpected vm-exit due to delivery event. */ 209d4834ff9SAlexander Graf #define KVM_INTERNAL_ERROR_DELIVERY_EV 3 21051b24e34SJan Kiszka 21151b24e34SJan Kiszka /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ 21251b24e34SJan Kiszka struct kvm_run { 21351b24e34SJan Kiszka /* in */ 21451b24e34SJan Kiszka __u8 request_interrupt_window; 21551b24e34SJan Kiszka __u8 padding1[7]; 21651b24e34SJan Kiszka 21751b24e34SJan Kiszka /* out */ 21851b24e34SJan Kiszka __u32 exit_reason; 21951b24e34SJan Kiszka __u8 ready_for_interrupt_injection; 22051b24e34SJan Kiszka __u8 if_flag; 22124a31426SPaolo Bonzini __u16 flags; 22251b24e34SJan Kiszka 22351b24e34SJan Kiszka /* in (pre_kvm_run), out (post_kvm_run) */ 22451b24e34SJan Kiszka __u64 cr8; 22551b24e34SJan Kiszka __u64 apic_base; 22651b24e34SJan Kiszka 22751b24e34SJan Kiszka #ifdef __KVM_S390 22851b24e34SJan Kiszka /* the processor status word for s390 */ 22951b24e34SJan Kiszka __u64 psw_mask; /* psw upper half */ 23051b24e34SJan Kiszka __u64 psw_addr; /* psw lower half */ 23151b24e34SJan Kiszka #endif 23251b24e34SJan Kiszka union { 23351b24e34SJan Kiszka /* KVM_EXIT_UNKNOWN */ 23451b24e34SJan Kiszka struct { 23551b24e34SJan Kiszka __u64 hardware_exit_reason; 23651b24e34SJan Kiszka } hw; 23751b24e34SJan Kiszka /* KVM_EXIT_FAIL_ENTRY */ 23851b24e34SJan Kiszka struct { 23951b24e34SJan Kiszka __u64 hardware_entry_failure_reason; 24051b24e34SJan Kiszka } fail_entry; 24151b24e34SJan Kiszka /* KVM_EXIT_EXCEPTION */ 24251b24e34SJan Kiszka struct { 24351b24e34SJan Kiszka __u32 exception; 24451b24e34SJan Kiszka __u32 error_code; 24551b24e34SJan Kiszka } ex; 24651b24e34SJan Kiszka /* KVM_EXIT_IO */ 24751b24e34SJan Kiszka struct { 24851b24e34SJan Kiszka #define KVM_EXIT_IO_IN 0 24951b24e34SJan Kiszka #define KVM_EXIT_IO_OUT 1 25051b24e34SJan Kiszka __u8 direction; 25151b24e34SJan Kiszka __u8 size; /* bytes */ 25251b24e34SJan Kiszka __u16 port; 25351b24e34SJan Kiszka __u32 count; 25451b24e34SJan Kiszka __u64 data_offset; /* relative to kvm_run start */ 25551b24e34SJan Kiszka } io; 2563a824b15SPaolo Bonzini /* KVM_EXIT_DEBUG */ 25751b24e34SJan Kiszka struct { 25851b24e34SJan Kiszka struct kvm_debug_exit_arch arch; 25951b24e34SJan Kiszka } debug; 26051b24e34SJan Kiszka /* KVM_EXIT_MMIO */ 26151b24e34SJan Kiszka struct { 26251b24e34SJan Kiszka __u64 phys_addr; 26351b24e34SJan Kiszka __u8 data[8]; 26451b24e34SJan Kiszka __u32 len; 26551b24e34SJan Kiszka __u8 is_write; 26651b24e34SJan Kiszka } mmio; 26751b24e34SJan Kiszka /* KVM_EXIT_HYPERCALL */ 26851b24e34SJan Kiszka struct { 26951b24e34SJan Kiszka __u64 nr; 27051b24e34SJan Kiszka __u64 args[6]; 27151b24e34SJan Kiszka __u64 ret; 27251b24e34SJan Kiszka __u32 longmode; 27351b24e34SJan Kiszka __u32 pad; 27451b24e34SJan Kiszka } hypercall; 27551b24e34SJan Kiszka /* KVM_EXIT_TPR_ACCESS */ 27651b24e34SJan Kiszka struct { 27751b24e34SJan Kiszka __u64 rip; 27851b24e34SJan Kiszka __u32 is_write; 27951b24e34SJan Kiszka __u32 pad; 28051b24e34SJan Kiszka } tpr_access; 28151b24e34SJan Kiszka /* KVM_EXIT_S390_SIEIC */ 28251b24e34SJan Kiszka struct { 28351b24e34SJan Kiszka __u8 icptcode; 28451b24e34SJan Kiszka __u16 ipa; 28551b24e34SJan Kiszka __u32 ipb; 28651b24e34SJan Kiszka } s390_sieic; 28751b24e34SJan Kiszka /* KVM_EXIT_S390_RESET */ 28851b24e34SJan Kiszka #define KVM_S390_RESET_POR 1 28951b24e34SJan Kiszka #define KVM_S390_RESET_CLEAR 2 29051b24e34SJan Kiszka #define KVM_S390_RESET_SUBSYSTEM 4 29151b24e34SJan Kiszka #define KVM_S390_RESET_CPU_INIT 8 29251b24e34SJan Kiszka #define KVM_S390_RESET_IPL 16 29351b24e34SJan Kiszka __u64 s390_reset_flags; 2941529ae1bSAlexander Graf /* KVM_EXIT_S390_UCONTROL */ 2951529ae1bSAlexander Graf struct { 2961529ae1bSAlexander Graf __u64 trans_exc_code; 2971529ae1bSAlexander Graf __u32 pgm_code; 2981529ae1bSAlexander Graf } s390_ucontrol; 299a9fd1654SJens Freimann /* KVM_EXIT_DCR (deprecated) */ 30051b24e34SJan Kiszka struct { 30151b24e34SJan Kiszka __u32 dcrn; 30251b24e34SJan Kiszka __u32 data; 30351b24e34SJan Kiszka __u8 is_write; 30451b24e34SJan Kiszka } dcr; 3053a824b15SPaolo Bonzini /* KVM_EXIT_INTERNAL_ERROR */ 30651b24e34SJan Kiszka struct { 30751b24e34SJan Kiszka __u32 suberror; 30851b24e34SJan Kiszka /* Available with KVM_CAP_INTERNAL_ERROR_DATA: */ 30951b24e34SJan Kiszka __u32 ndata; 31051b24e34SJan Kiszka __u64 data[16]; 31151b24e34SJan Kiszka } internal; 31251b24e34SJan Kiszka /* KVM_EXIT_OSI */ 31351b24e34SJan Kiszka struct { 31451b24e34SJan Kiszka __u64 gprs[32]; 31551b24e34SJan Kiszka } osi; 3163a824b15SPaolo Bonzini /* KVM_EXIT_PAPR_HCALL */ 3177c6da3deSAlexander Graf struct { 3187c6da3deSAlexander Graf __u64 nr; 3197c6da3deSAlexander Graf __u64 ret; 3207c6da3deSAlexander Graf __u64 args[9]; 3217c6da3deSAlexander Graf } papr_hcall; 322d3dccee1SAlexander Graf /* KVM_EXIT_S390_TSCH */ 323d3dccee1SAlexander Graf struct { 324d3dccee1SAlexander Graf __u16 subchannel_id; 325d3dccee1SAlexander Graf __u16 subchannel_nr; 326d3dccee1SAlexander Graf __u32 io_int_parm; 327d3dccee1SAlexander Graf __u32 io_int_word; 328d3dccee1SAlexander Graf __u32 ipb; 329d3dccee1SAlexander Graf __u8 dequeued; 330d3dccee1SAlexander Graf } s390_tsch; 331d3dccee1SAlexander Graf /* KVM_EXIT_EPR */ 332d3dccee1SAlexander Graf struct { 333d3dccee1SAlexander Graf __u32 epr; 334d3dccee1SAlexander Graf } epr; 335b061808dSAlexander Graf /* KVM_EXIT_SYSTEM_EVENT */ 336b061808dSAlexander Graf struct { 337b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_SHUTDOWN 1 338b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_RESET 2 339120758fbSPaolo Bonzini #define KVM_SYSTEM_EVENT_CRASH 3 340b061808dSAlexander Graf __u32 type; 341b061808dSAlexander Graf __u64 flags; 342b061808dSAlexander Graf } system_event; 3437a52ce8aSCornelia Huck /* KVM_EXIT_S390_STSI */ 3447a52ce8aSCornelia Huck struct { 3457a52ce8aSCornelia Huck __u64 addr; 3467a52ce8aSCornelia Huck __u8 ar; 3477a52ce8aSCornelia Huck __u8 reserved; 3487a52ce8aSCornelia Huck __u8 fc; 3497a52ce8aSCornelia Huck __u8 sel1; 3507a52ce8aSCornelia Huck __u16 sel2; 3517a52ce8aSCornelia Huck } s390_stsi; 3523a824b15SPaolo Bonzini /* KVM_EXIT_IOAPIC_EOI */ 3533a824b15SPaolo Bonzini struct { 3543a824b15SPaolo Bonzini __u8 vector; 3553a824b15SPaolo Bonzini } eoi; 356fff02bc0SPaolo Bonzini /* KVM_EXIT_HYPERV */ 357fff02bc0SPaolo Bonzini struct kvm_hyperv_exit hyperv; 35851b24e34SJan Kiszka /* Fix the size of the union. */ 35951b24e34SJan Kiszka char padding[256]; 36051b24e34SJan Kiszka }; 3611529ae1bSAlexander Graf 3621529ae1bSAlexander Graf /* 3631529ae1bSAlexander Graf * shared registers between kvm and userspace. 3641529ae1bSAlexander Graf * kvm_valid_regs specifies the register classes set by the host 3651529ae1bSAlexander Graf * kvm_dirty_regs specified the register classes dirtied by userspace 3661529ae1bSAlexander Graf * struct kvm_sync_regs is architecture specific, as well as the 3671529ae1bSAlexander Graf * bits for kvm_valid_regs and kvm_dirty_regs 3681529ae1bSAlexander Graf */ 3691529ae1bSAlexander Graf __u64 kvm_valid_regs; 3701529ae1bSAlexander Graf __u64 kvm_dirty_regs; 3711529ae1bSAlexander Graf union { 3721529ae1bSAlexander Graf struct kvm_sync_regs regs; 3737a52ce8aSCornelia Huck char padding[2048]; 3741529ae1bSAlexander Graf } s; 37551b24e34SJan Kiszka }; 37651b24e34SJan Kiszka 37751b24e34SJan Kiszka /* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */ 37851b24e34SJan Kiszka 37951b24e34SJan Kiszka struct kvm_coalesced_mmio_zone { 38051b24e34SJan Kiszka __u64 addr; 38151b24e34SJan Kiszka __u32 size; 38251b24e34SJan Kiszka __u32 pad; 38351b24e34SJan Kiszka }; 38451b24e34SJan Kiszka 38551b24e34SJan Kiszka struct kvm_coalesced_mmio { 38651b24e34SJan Kiszka __u64 phys_addr; 38751b24e34SJan Kiszka __u32 len; 38851b24e34SJan Kiszka __u32 pad; 38951b24e34SJan Kiszka __u8 data[8]; 39051b24e34SJan Kiszka }; 39151b24e34SJan Kiszka 39251b24e34SJan Kiszka struct kvm_coalesced_mmio_ring { 39351b24e34SJan Kiszka __u32 first, last; 39451b24e34SJan Kiszka struct kvm_coalesced_mmio coalesced_mmio[0]; 39551b24e34SJan Kiszka }; 39651b24e34SJan Kiszka 39751b24e34SJan Kiszka #define KVM_COALESCED_MMIO_MAX \ 39851b24e34SJan Kiszka ((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \ 39951b24e34SJan Kiszka sizeof(struct kvm_coalesced_mmio)) 40051b24e34SJan Kiszka 40151b24e34SJan Kiszka /* for KVM_TRANSLATE */ 40251b24e34SJan Kiszka struct kvm_translation { 40351b24e34SJan Kiszka /* in */ 40451b24e34SJan Kiszka __u64 linear_address; 40551b24e34SJan Kiszka 40651b24e34SJan Kiszka /* out */ 40751b24e34SJan Kiszka __u64 physical_address; 40851b24e34SJan Kiszka __u8 valid; 40951b24e34SJan Kiszka __u8 writeable; 41051b24e34SJan Kiszka __u8 usermode; 41151b24e34SJan Kiszka __u8 pad[5]; 41251b24e34SJan Kiszka }; 41351b24e34SJan Kiszka 4147a52ce8aSCornelia Huck /* for KVM_S390_MEM_OP */ 4157a52ce8aSCornelia Huck struct kvm_s390_mem_op { 4167a52ce8aSCornelia Huck /* in */ 4177a52ce8aSCornelia Huck __u64 gaddr; /* the guest address */ 4187a52ce8aSCornelia Huck __u64 flags; /* flags */ 4197a52ce8aSCornelia Huck __u32 size; /* amount of bytes */ 4207a52ce8aSCornelia Huck __u32 op; /* type of operation */ 4217a52ce8aSCornelia Huck __u64 buf; /* buffer in userspace */ 4227a52ce8aSCornelia Huck __u8 ar; /* the access register number */ 4237a52ce8aSCornelia Huck __u8 reserved[31]; /* should be set to 0 */ 4247a52ce8aSCornelia Huck }; 4257a52ce8aSCornelia Huck /* types for kvm_s390_mem_op->op */ 4267a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_READ 0 4277a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_WRITE 1 4287a52ce8aSCornelia Huck /* flags for kvm_s390_mem_op->flags */ 4297a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0) 4307a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1) 4317a52ce8aSCornelia Huck 43251b24e34SJan Kiszka /* for KVM_INTERRUPT */ 43351b24e34SJan Kiszka struct kvm_interrupt { 43451b24e34SJan Kiszka /* in */ 43551b24e34SJan Kiszka __u32 irq; 43651b24e34SJan Kiszka }; 43751b24e34SJan Kiszka 43851b24e34SJan Kiszka /* for KVM_GET_DIRTY_LOG */ 43951b24e34SJan Kiszka struct kvm_dirty_log { 44051b24e34SJan Kiszka __u32 slot; 44151b24e34SJan Kiszka __u32 padding1; 44251b24e34SJan Kiszka union { 44351b24e34SJan Kiszka void *dirty_bitmap; /* one bit per page */ 44451b24e34SJan Kiszka __u64 padding2; 44551b24e34SJan Kiszka }; 44651b24e34SJan Kiszka }; 44751b24e34SJan Kiszka 44851b24e34SJan Kiszka /* for KVM_SET_SIGNAL_MASK */ 44951b24e34SJan Kiszka struct kvm_signal_mask { 45051b24e34SJan Kiszka __u32 len; 45151b24e34SJan Kiszka __u8 sigset[0]; 45251b24e34SJan Kiszka }; 45351b24e34SJan Kiszka 45451b24e34SJan Kiszka /* for KVM_TPR_ACCESS_REPORTING */ 45551b24e34SJan Kiszka struct kvm_tpr_access_ctl { 45651b24e34SJan Kiszka __u32 enabled; 45751b24e34SJan Kiszka __u32 flags; 45851b24e34SJan Kiszka __u32 reserved[8]; 45951b24e34SJan Kiszka }; 46051b24e34SJan Kiszka 46151b24e34SJan Kiszka /* for KVM_SET_VAPIC_ADDR */ 46251b24e34SJan Kiszka struct kvm_vapic_addr { 46351b24e34SJan Kiszka __u64 vapic_addr; 46451b24e34SJan Kiszka }; 46551b24e34SJan Kiszka 466a9fd1654SJens Freimann /* for KVM_SET_MP_STATE */ 46751b24e34SJan Kiszka 468a9fd1654SJens Freimann /* not all states are valid on all architectures */ 46951b24e34SJan Kiszka #define KVM_MP_STATE_RUNNABLE 0 47051b24e34SJan Kiszka #define KVM_MP_STATE_UNINITIALIZED 1 47151b24e34SJan Kiszka #define KVM_MP_STATE_INIT_RECEIVED 2 47251b24e34SJan Kiszka #define KVM_MP_STATE_HALTED 3 47351b24e34SJan Kiszka #define KVM_MP_STATE_SIPI_RECEIVED 4 474a9fd1654SJens Freimann #define KVM_MP_STATE_STOPPED 5 475a9fd1654SJens Freimann #define KVM_MP_STATE_CHECK_STOP 6 476a9fd1654SJens Freimann #define KVM_MP_STATE_OPERATING 7 477a9fd1654SJens Freimann #define KVM_MP_STATE_LOAD 8 47851b24e34SJan Kiszka 47951b24e34SJan Kiszka struct kvm_mp_state { 48051b24e34SJan Kiszka __u32 mp_state; 48151b24e34SJan Kiszka }; 48251b24e34SJan Kiszka 48351b24e34SJan Kiszka struct kvm_s390_psw { 48451b24e34SJan Kiszka __u64 mask; 48551b24e34SJan Kiszka __u64 addr; 48651b24e34SJan Kiszka }; 48751b24e34SJan Kiszka 48851b24e34SJan Kiszka /* valid values for type in kvm_s390_interrupt */ 48951b24e34SJan Kiszka #define KVM_S390_SIGP_STOP 0xfffe0000u 49051b24e34SJan Kiszka #define KVM_S390_PROGRAM_INT 0xfffe0001u 49151b24e34SJan Kiszka #define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u 49251b24e34SJan Kiszka #define KVM_S390_RESTART 0xfffe0003u 493216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_INIT 0xfffe0004u 494216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_DONE 0xfffe0005u 495d3dccee1SAlexander Graf #define KVM_S390_MCHK 0xfffe1000u 49676eb98d5SJens Freimann #define KVM_S390_INT_CLOCK_COMP 0xffff1004u 49776eb98d5SJens Freimann #define KVM_S390_INT_CPU_TIMER 0xffff1005u 49851b24e34SJan Kiszka #define KVM_S390_INT_VIRTIO 0xffff2603u 49951b24e34SJan Kiszka #define KVM_S390_INT_SERVICE 0xffff2401u 50051b24e34SJan Kiszka #define KVM_S390_INT_EMERGENCY 0xffff1201u 5011529ae1bSAlexander Graf #define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u 502d3dccee1SAlexander Graf /* Anything below 0xfffe0000u is taken by INT_IO */ 503d3dccee1SAlexander Graf #define KVM_S390_INT_IO(ai,cssid,ssid,schid) \ 504d3dccee1SAlexander Graf (((schid)) | \ 505d3dccee1SAlexander Graf ((ssid) << 16) | \ 506d3dccee1SAlexander Graf ((cssid) << 18) | \ 507d3dccee1SAlexander Graf ((ai) << 26)) 508d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MIN 0x00000000u 509d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MAX 0xfffdffffu 510120758fbSPaolo Bonzini #define KVM_S390_INT_IO_AI_MASK 0x04000000u 511d3dccee1SAlexander Graf 51251b24e34SJan Kiszka 51351b24e34SJan Kiszka struct kvm_s390_interrupt { 51451b24e34SJan Kiszka __u32 type; 51551b24e34SJan Kiszka __u32 parm; 51651b24e34SJan Kiszka __u64 parm64; 51751b24e34SJan Kiszka }; 51851b24e34SJan Kiszka 519216db403SChristian Borntraeger struct kvm_s390_io_info { 520216db403SChristian Borntraeger __u16 subchannel_id; 521216db403SChristian Borntraeger __u16 subchannel_nr; 522216db403SChristian Borntraeger __u32 io_int_parm; 523216db403SChristian Borntraeger __u32 io_int_word; 524216db403SChristian Borntraeger }; 525216db403SChristian Borntraeger 526216db403SChristian Borntraeger struct kvm_s390_ext_info { 527216db403SChristian Borntraeger __u32 ext_params; 528216db403SChristian Borntraeger __u32 pad; 529216db403SChristian Borntraeger __u64 ext_params2; 530216db403SChristian Borntraeger }; 531216db403SChristian Borntraeger 532216db403SChristian Borntraeger struct kvm_s390_pgm_info { 533216db403SChristian Borntraeger __u64 trans_exc_code; 534216db403SChristian Borntraeger __u64 mon_code; 535216db403SChristian Borntraeger __u64 per_address; 536216db403SChristian Borntraeger __u32 data_exc_code; 537216db403SChristian Borntraeger __u16 code; 538216db403SChristian Borntraeger __u16 mon_class_nr; 539216db403SChristian Borntraeger __u8 per_code; 540216db403SChristian Borntraeger __u8 per_atmid; 541216db403SChristian Borntraeger __u8 exc_access_id; 542216db403SChristian Borntraeger __u8 per_access_id; 543216db403SChristian Borntraeger __u8 op_access_id; 544*66fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_VALID 0x01 545*66fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_0 0x02 546*66fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_1 0x04 547*66fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_MASK 0x06 548*66fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_NO_REWIND 0x08 549*66fb2d54SCornelia Huck __u8 flags; 550*66fb2d54SCornelia Huck __u8 pad[2]; 551216db403SChristian Borntraeger }; 552216db403SChristian Borntraeger 553216db403SChristian Borntraeger struct kvm_s390_prefix_info { 554216db403SChristian Borntraeger __u32 address; 555216db403SChristian Borntraeger }; 556216db403SChristian Borntraeger 557216db403SChristian Borntraeger struct kvm_s390_extcall_info { 558216db403SChristian Borntraeger __u16 code; 559216db403SChristian Borntraeger }; 560216db403SChristian Borntraeger 561216db403SChristian Borntraeger struct kvm_s390_emerg_info { 562216db403SChristian Borntraeger __u16 code; 563216db403SChristian Borntraeger }; 564216db403SChristian Borntraeger 56551628b18SChristian Borntraeger #define KVM_S390_STOP_FLAG_STORE_STATUS 0x01 56651628b18SChristian Borntraeger struct kvm_s390_stop_info { 56751628b18SChristian Borntraeger __u32 flags; 56851628b18SChristian Borntraeger }; 56951628b18SChristian Borntraeger 570216db403SChristian Borntraeger struct kvm_s390_mchk_info { 571216db403SChristian Borntraeger __u64 cr14; 572216db403SChristian Borntraeger __u64 mcic; 573216db403SChristian Borntraeger __u64 failing_storage_address; 574216db403SChristian Borntraeger __u32 ext_damage_code; 575216db403SChristian Borntraeger __u32 pad; 576216db403SChristian Borntraeger __u8 fixed_logout[16]; 577216db403SChristian Borntraeger }; 578216db403SChristian Borntraeger 579216db403SChristian Borntraeger struct kvm_s390_irq { 580216db403SChristian Borntraeger __u64 type; 581216db403SChristian Borntraeger union { 582216db403SChristian Borntraeger struct kvm_s390_io_info io; 583216db403SChristian Borntraeger struct kvm_s390_ext_info ext; 584216db403SChristian Borntraeger struct kvm_s390_pgm_info pgm; 585216db403SChristian Borntraeger struct kvm_s390_emerg_info emerg; 586216db403SChristian Borntraeger struct kvm_s390_extcall_info extcall; 587216db403SChristian Borntraeger struct kvm_s390_prefix_info prefix; 58851628b18SChristian Borntraeger struct kvm_s390_stop_info stop; 589216db403SChristian Borntraeger struct kvm_s390_mchk_info mchk; 590216db403SChristian Borntraeger char reserved[64]; 591216db403SChristian Borntraeger } u; 592216db403SChristian Borntraeger }; 593216db403SChristian Borntraeger 5947a52ce8aSCornelia Huck struct kvm_s390_irq_state { 5957a52ce8aSCornelia Huck __u64 buf; 5967a52ce8aSCornelia Huck __u32 flags; 5977a52ce8aSCornelia Huck __u32 len; 5987a52ce8aSCornelia Huck __u32 reserved[4]; 5997a52ce8aSCornelia Huck }; 6007a52ce8aSCornelia Huck 60151b24e34SJan Kiszka /* for KVM_SET_GUEST_DEBUG */ 60251b24e34SJan Kiszka 60351b24e34SJan Kiszka #define KVM_GUESTDBG_ENABLE 0x00000001 60451b24e34SJan Kiszka #define KVM_GUESTDBG_SINGLESTEP 0x00000002 60551b24e34SJan Kiszka 60651b24e34SJan Kiszka struct kvm_guest_debug { 60751b24e34SJan Kiszka __u32 control; 60851b24e34SJan Kiszka __u32 pad; 60951b24e34SJan Kiszka struct kvm_guest_debug_arch arch; 61051b24e34SJan Kiszka }; 61151b24e34SJan Kiszka 61251b24e34SJan Kiszka enum { 61351b24e34SJan Kiszka kvm_ioeventfd_flag_nr_datamatch, 61451b24e34SJan Kiszka kvm_ioeventfd_flag_nr_pio, 61551b24e34SJan Kiszka kvm_ioeventfd_flag_nr_deassign, 616cae7f586SAlexander Graf kvm_ioeventfd_flag_nr_virtio_ccw_notify, 61776eb98d5SJens Freimann kvm_ioeventfd_flag_nr_fast_mmio, 61851b24e34SJan Kiszka kvm_ioeventfd_flag_nr_max, 61951b24e34SJan Kiszka }; 62051b24e34SJan Kiszka 62151b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) 62251b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) 62351b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) 624cae7f586SAlexander Graf #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ 625cae7f586SAlexander Graf (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify) 62651b24e34SJan Kiszka 62751b24e34SJan Kiszka #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1) 62851b24e34SJan Kiszka 62951b24e34SJan Kiszka struct kvm_ioeventfd { 63051b24e34SJan Kiszka __u64 datamatch; 63151b24e34SJan Kiszka __u64 addr; /* legal pio/mmio address */ 63276eb98d5SJens Freimann __u32 len; /* 1, 2, 4, or 8 bytes; or 0 to ignore length */ 63351b24e34SJan Kiszka __s32 fd; 63451b24e34SJan Kiszka __u32 flags; 63551b24e34SJan Kiszka __u8 pad[36]; 63651b24e34SJan Kiszka }; 63751b24e34SJan Kiszka 63851b24e34SJan Kiszka /* for KVM_ENABLE_CAP */ 63951b24e34SJan Kiszka struct kvm_enable_cap { 64051b24e34SJan Kiszka /* in */ 64151b24e34SJan Kiszka __u32 cap; 64251b24e34SJan Kiszka __u32 flags; 64351b24e34SJan Kiszka __u64 args[4]; 64451b24e34SJan Kiszka __u8 pad[64]; 64551b24e34SJan Kiszka }; 64651b24e34SJan Kiszka 64751b24e34SJan Kiszka /* for KVM_PPC_GET_PVINFO */ 64851b24e34SJan Kiszka struct kvm_ppc_pvinfo { 64951b24e34SJan Kiszka /* out */ 65051b24e34SJan Kiszka __u32 flags; 65151b24e34SJan Kiszka __u32 hcall[4]; 65251b24e34SJan Kiszka __u8 pad[108]; 65351b24e34SJan Kiszka }; 65451b24e34SJan Kiszka 65580a3eb10SJan Kiszka /* for KVM_PPC_GET_SMMU_INFO */ 65680a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_MAX_SZ 8 65780a3eb10SJan Kiszka 65880a3eb10SJan Kiszka struct kvm_ppc_one_page_size { 65980a3eb10SJan Kiszka __u32 page_shift; /* Page shift (or 0) */ 66080a3eb10SJan Kiszka __u32 pte_enc; /* Encoding in the HPTE (>>12) */ 66180a3eb10SJan Kiszka }; 66280a3eb10SJan Kiszka 66380a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size { 66480a3eb10SJan Kiszka __u32 page_shift; /* Base page shift of segment (or 0) */ 66580a3eb10SJan Kiszka __u32 slb_enc; /* SLB encoding for BookS */ 66680a3eb10SJan Kiszka struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ]; 66780a3eb10SJan Kiszka }; 66880a3eb10SJan Kiszka 66980a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_REAL 0x00000001 67080a3eb10SJan Kiszka #define KVM_PPC_1T_SEGMENTS 0x00000002 67180a3eb10SJan Kiszka 67280a3eb10SJan Kiszka struct kvm_ppc_smmu_info { 67380a3eb10SJan Kiszka __u64 flags; 67480a3eb10SJan Kiszka __u32 slb_size; 67580a3eb10SJan Kiszka __u32 pad; 67680a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; 67780a3eb10SJan Kiszka }; 67880a3eb10SJan Kiszka 679d4834ff9SAlexander Graf #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) 680d4834ff9SAlexander Graf 68151b24e34SJan Kiszka #define KVMIO 0xAE 68251b24e34SJan Kiszka 6831529ae1bSAlexander Graf /* machine type bits, to be used as argument to KVM_CREATE_VM */ 6841529ae1bSAlexander Graf #define KVM_VM_S390_UCONTROL 1 6851529ae1bSAlexander Graf 686bf63839fSAlex Williamson /* on ppc, 0 indicate default, 1 should force HV and 2 PR */ 687bf63839fSAlex Williamson #define KVM_VM_PPC_HV 1 688bf63839fSAlex Williamson #define KVM_VM_PPC_PR 2 689bf63839fSAlex Williamson 6901529ae1bSAlexander Graf #define KVM_S390_SIE_PAGE_OFFSET 1 6911529ae1bSAlexander Graf 69251b24e34SJan Kiszka /* 69351b24e34SJan Kiszka * ioctls for /dev/kvm fds: 69451b24e34SJan Kiszka */ 69551b24e34SJan Kiszka #define KVM_GET_API_VERSION _IO(KVMIO, 0x00) 69651b24e34SJan Kiszka #define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ 69751b24e34SJan Kiszka #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) 69851b24e34SJan Kiszka 69951b24e34SJan Kiszka #define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06) 70051b24e34SJan Kiszka /* 70151b24e34SJan Kiszka * Check if a kvm extension is available. Argument is extension number, 70251b24e34SJan Kiszka * return is 1 (yes) or 0 (no, sorry). 70351b24e34SJan Kiszka */ 70451b24e34SJan Kiszka #define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03) 70551b24e34SJan Kiszka /* 70651b24e34SJan Kiszka * Get size for mmap(vcpu_fd) 70751b24e34SJan Kiszka */ 70851b24e34SJan Kiszka #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ 70951b24e34SJan Kiszka #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) 71051b24e34SJan Kiszka #define KVM_TRACE_ENABLE __KVM_DEPRECATED_MAIN_W_0x06 71151b24e34SJan Kiszka #define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07 71251b24e34SJan Kiszka #define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08 713bf63839fSAlex Williamson #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) 71451b24e34SJan Kiszka 71551b24e34SJan Kiszka /* 71651b24e34SJan Kiszka * Extension capability list. 71751b24e34SJan Kiszka */ 71851b24e34SJan Kiszka #define KVM_CAP_IRQCHIP 0 71951b24e34SJan Kiszka #define KVM_CAP_HLT 1 72051b24e34SJan Kiszka #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 72151b24e34SJan Kiszka #define KVM_CAP_USER_MEMORY 3 72251b24e34SJan Kiszka #define KVM_CAP_SET_TSS_ADDR 4 72351b24e34SJan Kiszka #define KVM_CAP_VAPIC 6 72451b24e34SJan Kiszka #define KVM_CAP_EXT_CPUID 7 72551b24e34SJan Kiszka #define KVM_CAP_CLOCKSOURCE 8 7267c6da3deSAlexander Graf #define KVM_CAP_NR_VCPUS 9 /* returns recommended max vcpus per vm */ 72751b24e34SJan Kiszka #define KVM_CAP_NR_MEMSLOTS 10 /* returns max memory slots per vm */ 72851b24e34SJan Kiszka #define KVM_CAP_PIT 11 72951b24e34SJan Kiszka #define KVM_CAP_NOP_IO_DELAY 12 73051b24e34SJan Kiszka #define KVM_CAP_PV_MMU 13 73151b24e34SJan Kiszka #define KVM_CAP_MP_STATE 14 73251b24e34SJan Kiszka #define KVM_CAP_COALESCED_MMIO 15 73351b24e34SJan Kiszka #define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ 73451b24e34SJan Kiszka #define KVM_CAP_IOMMU 18 73551b24e34SJan Kiszka /* Bug in KVM_SET_USER_MEMORY_REGION fixed: */ 73651b24e34SJan Kiszka #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21 73751b24e34SJan Kiszka #define KVM_CAP_USER_NMI 22 73851b24e34SJan Kiszka #ifdef __KVM_HAVE_GUEST_DEBUG 73951b24e34SJan Kiszka #define KVM_CAP_SET_GUEST_DEBUG 23 74051b24e34SJan Kiszka #endif 74151b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 74251b24e34SJan Kiszka #define KVM_CAP_REINJECT_CONTROL 24 74351b24e34SJan Kiszka #endif 74451b24e34SJan Kiszka #define KVM_CAP_IRQ_ROUTING 25 74551b24e34SJan Kiszka #define KVM_CAP_IRQ_INJECT_STATUS 26 74651b24e34SJan Kiszka #define KVM_CAP_ASSIGN_DEV_IRQ 29 74751b24e34SJan Kiszka /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ 74851b24e34SJan Kiszka #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 74951b24e34SJan Kiszka #ifdef __KVM_HAVE_MCE 75051b24e34SJan Kiszka #define KVM_CAP_MCE 31 75151b24e34SJan Kiszka #endif 75251b24e34SJan Kiszka #define KVM_CAP_IRQFD 32 75351b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 75451b24e34SJan Kiszka #define KVM_CAP_PIT2 33 75551b24e34SJan Kiszka #endif 75651b24e34SJan Kiszka #define KVM_CAP_SET_BOOT_CPU_ID 34 75751b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT_STATE2 75851b24e34SJan Kiszka #define KVM_CAP_PIT_STATE2 35 75951b24e34SJan Kiszka #endif 76051b24e34SJan Kiszka #define KVM_CAP_IOEVENTFD 36 76151b24e34SJan Kiszka #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 76251b24e34SJan Kiszka #ifdef __KVM_HAVE_XEN_HVM 76351b24e34SJan Kiszka #define KVM_CAP_XEN_HVM 38 76451b24e34SJan Kiszka #endif 76551b24e34SJan Kiszka #define KVM_CAP_ADJUST_CLOCK 39 76651b24e34SJan Kiszka #define KVM_CAP_INTERNAL_ERROR_DATA 40 76751b24e34SJan Kiszka #ifdef __KVM_HAVE_VCPU_EVENTS 76851b24e34SJan Kiszka #define KVM_CAP_VCPU_EVENTS 41 76951b24e34SJan Kiszka #endif 77051b24e34SJan Kiszka #define KVM_CAP_S390_PSW 42 77151b24e34SJan Kiszka #define KVM_CAP_PPC_SEGSTATE 43 77251b24e34SJan Kiszka #define KVM_CAP_HYPERV 44 77351b24e34SJan Kiszka #define KVM_CAP_HYPERV_VAPIC 45 77451b24e34SJan Kiszka #define KVM_CAP_HYPERV_SPIN 46 77551b24e34SJan Kiszka #define KVM_CAP_PCI_SEGMENT 47 77651b24e34SJan Kiszka #define KVM_CAP_PPC_PAIRED_SINGLES 48 77751b24e34SJan Kiszka #define KVM_CAP_INTR_SHADOW 49 77851b24e34SJan Kiszka #ifdef __KVM_HAVE_DEBUGREGS 77951b24e34SJan Kiszka #define KVM_CAP_DEBUGREGS 50 78051b24e34SJan Kiszka #endif 78151b24e34SJan Kiszka #define KVM_CAP_X86_ROBUST_SINGLESTEP 51 78251b24e34SJan Kiszka #define KVM_CAP_PPC_OSI 52 78351b24e34SJan Kiszka #define KVM_CAP_PPC_UNSET_IRQ 53 78451b24e34SJan Kiszka #define KVM_CAP_ENABLE_CAP 54 78551b24e34SJan Kiszka #ifdef __KVM_HAVE_XSAVE 78651b24e34SJan Kiszka #define KVM_CAP_XSAVE 55 78751b24e34SJan Kiszka #endif 78851b24e34SJan Kiszka #ifdef __KVM_HAVE_XCRS 78951b24e34SJan Kiszka #define KVM_CAP_XCRS 56 79051b24e34SJan Kiszka #endif 79151b24e34SJan Kiszka #define KVM_CAP_PPC_GET_PVINFO 57 79251b24e34SJan Kiszka #define KVM_CAP_PPC_IRQ_LEVEL 58 79351b24e34SJan Kiszka #define KVM_CAP_ASYNC_PF 59 79451b24e34SJan Kiszka #define KVM_CAP_TSC_CONTROL 60 79551b24e34SJan Kiszka #define KVM_CAP_GET_TSC_KHZ 61 79651b24e34SJan Kiszka #define KVM_CAP_PPC_BOOKE_SREGS 62 7977c6da3deSAlexander Graf #define KVM_CAP_SPAPR_TCE 63 7987c6da3deSAlexander Graf #define KVM_CAP_PPC_SMT 64 7997c6da3deSAlexander Graf #define KVM_CAP_PPC_RMA 65 8007c6da3deSAlexander Graf #define KVM_CAP_MAX_VCPUS 66 /* returns max vcpus per vm */ 8019d4e4f8cSAlexander Graf #define KVM_CAP_PPC_HIOR 67 8027c6da3deSAlexander Graf #define KVM_CAP_PPC_PAPR 68 803a54fc080SAlexander Graf #define KVM_CAP_SW_TLB 69 8049d4e4f8cSAlexander Graf #define KVM_CAP_ONE_REG 70 8051529ae1bSAlexander Graf #define KVM_CAP_S390_GMAP 71 8061529ae1bSAlexander Graf #define KVM_CAP_TSC_DEADLINE_TIMER 72 8071529ae1bSAlexander Graf #define KVM_CAP_S390_UCONTROL 73 8081529ae1bSAlexander Graf #define KVM_CAP_SYNC_REGS 74 8099ab2195dSMarcelo Tosatti #define KVM_CAP_PCI_2_3 75 8109ab2195dSMarcelo Tosatti #define KVM_CAP_KVMCLOCK_CTRL 76 81180a3eb10SJan Kiszka #define KVM_CAP_SIGNAL_MSI 77 81280a3eb10SJan Kiszka #define KVM_CAP_PPC_GET_SMMU_INFO 78 8132a60dba4SAlexander Graf #define KVM_CAP_S390_COW 79 814651682dcSMichael S. Tsirkin #define KVM_CAP_PPC_ALLOC_HTAB 80 815716b8e4dSAlex Williamson #define KVM_CAP_READONLY_MEM 81 816716b8e4dSAlex Williamson #define KVM_CAP_IRQFD_RESAMPLE 82 817d4834ff9SAlexander Graf #define KVM_CAP_PPC_BOOKE_WATCHDOG 83 818d4834ff9SAlexander Graf #define KVM_CAP_PPC_HTAB_FD 84 819d3dccee1SAlexander Graf #define KVM_CAP_S390_CSS_SUPPORT 85 820d3dccee1SAlexander Graf #define KVM_CAP_PPC_EPR 86 821eadd0e44SPeter Maydell #define KVM_CAP_ARM_PSCI 87 822eadd0e44SPeter Maydell #define KVM_CAP_ARM_SET_DEVICE_ADDR 88 823e098b453SAlexey Kardashevskiy #define KVM_CAP_DEVICE_CTRL 89 824e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_MPIC 90 825e098b453SAlexey Kardashevskiy #define KVM_CAP_PPC_RTAS 91 826e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_XICS 92 827c5daeae1SAlexey Kardashevskiy #define KVM_CAP_ARM_EL1_32BIT 93 8284f265607SAndrew Jones #define KVM_CAP_SPAPR_MULTITCE 94 829bf63839fSAlex Williamson #define KVM_CAP_EXT_EMUL_CPUID 95 83048a5f3bcSVadim Rozenfeld #define KVM_CAP_HYPERV_TIME 96 8319ffd2685SCornelia Huck #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97 8329ffd2685SCornelia Huck #define KVM_CAP_ENABLE_CAP_VM 98 8339ffd2685SCornelia Huck #define KVM_CAP_S390_IRQCHIP 99 83476eb98d5SJens Freimann #define KVM_CAP_IOEVENTFD_NO_LENGTH 100 83576eb98d5SJens Freimann #define KVM_CAP_VM_ATTRIBUTES 101 836b061808dSAlexander Graf #define KVM_CAP_ARM_PSCI_0_2 102 837b061808dSAlexander Graf #define KVM_CAP_PPC_FIXUP_HCALL 103 838a9fd1654SJens Freimann #define KVM_CAP_PPC_ENABLE_HCALL 104 839a9fd1654SJens Freimann #define KVM_CAP_CHECK_EXTENSION_VM 105 84051628b18SChristian Borntraeger #define KVM_CAP_S390_USER_SIGP 106 8417a52ce8aSCornelia Huck #define KVM_CAP_S390_VECTOR_REGISTERS 107 8427a52ce8aSCornelia Huck #define KVM_CAP_S390_MEM_OP 108 8437a52ce8aSCornelia Huck #define KVM_CAP_S390_USER_STSI 109 8447a52ce8aSCornelia Huck #define KVM_CAP_S390_SKEYS 110 8457a52ce8aSCornelia Huck #define KVM_CAP_MIPS_FPU 111 8467a52ce8aSCornelia Huck #define KVM_CAP_MIPS_MSA 112 8477a52ce8aSCornelia Huck #define KVM_CAP_S390_INJECT_IRQ 113 8487a52ce8aSCornelia Huck #define KVM_CAP_S390_IRQ_STATE 114 8497a52ce8aSCornelia Huck #define KVM_CAP_PPC_HWRNG 115 85024a31426SPaolo Bonzini #define KVM_CAP_DISABLE_QUIRKS 116 85124a31426SPaolo Bonzini #define KVM_CAP_X86_SMM 117 85224a31426SPaolo Bonzini #define KVM_CAP_MULTI_ADDRESS_SPACE 118 8533a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_BPS 119 8543a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_WPS 120 8553a824b15SPaolo Bonzini #define KVM_CAP_SPLIT_IRQCHIP 121 8563a824b15SPaolo Bonzini #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122 857fff02bc0SPaolo Bonzini #define KVM_CAP_HYPERV_SYNIC 123 858*66fb2d54SCornelia Huck #define KVM_CAP_S390_RI 124 85951b24e34SJan Kiszka 86051b24e34SJan Kiszka #ifdef KVM_CAP_IRQ_ROUTING 86151b24e34SJan Kiszka 86251b24e34SJan Kiszka struct kvm_irq_routing_irqchip { 86351b24e34SJan Kiszka __u32 irqchip; 86451b24e34SJan Kiszka __u32 pin; 86551b24e34SJan Kiszka }; 86651b24e34SJan Kiszka 86751b24e34SJan Kiszka struct kvm_irq_routing_msi { 86851b24e34SJan Kiszka __u32 address_lo; 86951b24e34SJan Kiszka __u32 address_hi; 87051b24e34SJan Kiszka __u32 data; 87151b24e34SJan Kiszka __u32 pad; 87251b24e34SJan Kiszka }; 87351b24e34SJan Kiszka 8749ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter { 8759ffd2685SCornelia Huck __u64 ind_addr; 8769ffd2685SCornelia Huck __u64 summary_addr; 8779ffd2685SCornelia Huck __u64 ind_offset; 8789ffd2685SCornelia Huck __u32 summary_offset; 8799ffd2685SCornelia Huck __u32 adapter_id; 8809ffd2685SCornelia Huck }; 8819ffd2685SCornelia Huck 882fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint { 883fff02bc0SPaolo Bonzini __u32 vcpu; 884fff02bc0SPaolo Bonzini __u32 sint; 885fff02bc0SPaolo Bonzini }; 886fff02bc0SPaolo Bonzini 88751b24e34SJan Kiszka /* gsi routing entry types */ 88851b24e34SJan Kiszka #define KVM_IRQ_ROUTING_IRQCHIP 1 88951b24e34SJan Kiszka #define KVM_IRQ_ROUTING_MSI 2 8909ffd2685SCornelia Huck #define KVM_IRQ_ROUTING_S390_ADAPTER 3 891fff02bc0SPaolo Bonzini #define KVM_IRQ_ROUTING_HV_SINT 4 89251b24e34SJan Kiszka 89351b24e34SJan Kiszka struct kvm_irq_routing_entry { 89451b24e34SJan Kiszka __u32 gsi; 89551b24e34SJan Kiszka __u32 type; 89651b24e34SJan Kiszka __u32 flags; 89751b24e34SJan Kiszka __u32 pad; 89851b24e34SJan Kiszka union { 89951b24e34SJan Kiszka struct kvm_irq_routing_irqchip irqchip; 90051b24e34SJan Kiszka struct kvm_irq_routing_msi msi; 9019ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter adapter; 902fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint hv_sint; 90351b24e34SJan Kiszka __u32 pad[8]; 90451b24e34SJan Kiszka } u; 90551b24e34SJan Kiszka }; 90651b24e34SJan Kiszka 90751b24e34SJan Kiszka struct kvm_irq_routing { 90851b24e34SJan Kiszka __u32 nr; 90951b24e34SJan Kiszka __u32 flags; 91051b24e34SJan Kiszka struct kvm_irq_routing_entry entries[0]; 91151b24e34SJan Kiszka }; 91251b24e34SJan Kiszka 91351b24e34SJan Kiszka #endif 91451b24e34SJan Kiszka 91551b24e34SJan Kiszka #ifdef KVM_CAP_MCE 91651b24e34SJan Kiszka /* x86 MCE */ 91751b24e34SJan Kiszka struct kvm_x86_mce { 91851b24e34SJan Kiszka __u64 status; 91951b24e34SJan Kiszka __u64 addr; 92051b24e34SJan Kiszka __u64 misc; 92151b24e34SJan Kiszka __u64 mcg_status; 92251b24e34SJan Kiszka __u8 bank; 92351b24e34SJan Kiszka __u8 pad1[7]; 92451b24e34SJan Kiszka __u64 pad2[3]; 92551b24e34SJan Kiszka }; 92651b24e34SJan Kiszka #endif 92751b24e34SJan Kiszka 92851b24e34SJan Kiszka #ifdef KVM_CAP_XEN_HVM 92951b24e34SJan Kiszka struct kvm_xen_hvm_config { 93051b24e34SJan Kiszka __u32 flags; 93151b24e34SJan Kiszka __u32 msr; 93251b24e34SJan Kiszka __u64 blob_addr_32; 93351b24e34SJan Kiszka __u64 blob_addr_64; 93451b24e34SJan Kiszka __u8 blob_size_32; 93551b24e34SJan Kiszka __u8 blob_size_64; 93651b24e34SJan Kiszka __u8 pad2[30]; 93751b24e34SJan Kiszka }; 93851b24e34SJan Kiszka #endif 93951b24e34SJan Kiszka 94051b24e34SJan Kiszka #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0) 941716b8e4dSAlex Williamson /* 942716b8e4dSAlex Williamson * Available with KVM_CAP_IRQFD_RESAMPLE 943716b8e4dSAlex Williamson * 944716b8e4dSAlex Williamson * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies 945716b8e4dSAlex Williamson * the irqfd to operate in resampling mode for level triggered interrupt 94625b8b39bSAlexey Kardashevskiy * emulation. See Documentation/virtual/kvm/api.txt. 947716b8e4dSAlex Williamson */ 948716b8e4dSAlex Williamson #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1) 94951b24e34SJan Kiszka 95051b24e34SJan Kiszka struct kvm_irqfd { 95151b24e34SJan Kiszka __u32 fd; 95251b24e34SJan Kiszka __u32 gsi; 95351b24e34SJan Kiszka __u32 flags; 954716b8e4dSAlex Williamson __u32 resamplefd; 955716b8e4dSAlex Williamson __u8 pad[16]; 95651b24e34SJan Kiszka }; 95751b24e34SJan Kiszka 95851b24e34SJan Kiszka struct kvm_clock_data { 95951b24e34SJan Kiszka __u64 clock; 96051b24e34SJan Kiszka __u32 flags; 96151b24e34SJan Kiszka __u32 pad[9]; 96251b24e34SJan Kiszka }; 96351b24e34SJan Kiszka 964a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_NOHV 0 965a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_HV 1 966a54fc080SAlexander Graf 967a54fc080SAlexander Graf struct kvm_config_tlb { 968a54fc080SAlexander Graf __u64 params; 969a54fc080SAlexander Graf __u64 array; 970a54fc080SAlexander Graf __u32 mmu_type; 971a54fc080SAlexander Graf __u32 array_len; 972a54fc080SAlexander Graf }; 973a54fc080SAlexander Graf 974a54fc080SAlexander Graf struct kvm_dirty_tlb { 975a54fc080SAlexander Graf __u64 bitmap; 976a54fc080SAlexander Graf __u32 num_dirty; 977a54fc080SAlexander Graf }; 978a54fc080SAlexander Graf 9799d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 9809d4e4f8cSAlexander Graf 981a31be480SAlexander Graf #define KVM_REG_ARCH_MASK 0xff00000000000000ULL 982a31be480SAlexander Graf #define KVM_REG_GENERIC 0x0000000000000000ULL 9839d4e4f8cSAlexander Graf 9849d4e4f8cSAlexander Graf /* 9859d4e4f8cSAlexander Graf * Architecture specific registers are to be defined in arch headers and 9869d4e4f8cSAlexander Graf * ORed with the arch identifier. 9879d4e4f8cSAlexander Graf */ 988a31be480SAlexander Graf #define KVM_REG_PPC 0x1000000000000000ULL 989a31be480SAlexander Graf #define KVM_REG_X86 0x2000000000000000ULL 990a31be480SAlexander Graf #define KVM_REG_IA64 0x3000000000000000ULL 991a31be480SAlexander Graf #define KVM_REG_ARM 0x4000000000000000ULL 992a31be480SAlexander Graf #define KVM_REG_S390 0x5000000000000000ULL 993c5daeae1SAlexey Kardashevskiy #define KVM_REG_ARM64 0x6000000000000000ULL 994c5daeae1SAlexey Kardashevskiy #define KVM_REG_MIPS 0x7000000000000000ULL 995a31be480SAlexander Graf 996a31be480SAlexander Graf #define KVM_REG_SIZE_SHIFT 52 997a31be480SAlexander Graf #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL 998a31be480SAlexander Graf #define KVM_REG_SIZE_U8 0x0000000000000000ULL 999a31be480SAlexander Graf #define KVM_REG_SIZE_U16 0x0010000000000000ULL 1000a31be480SAlexander Graf #define KVM_REG_SIZE_U32 0x0020000000000000ULL 1001a31be480SAlexander Graf #define KVM_REG_SIZE_U64 0x0030000000000000ULL 1002a31be480SAlexander Graf #define KVM_REG_SIZE_U128 0x0040000000000000ULL 1003a31be480SAlexander Graf #define KVM_REG_SIZE_U256 0x0050000000000000ULL 1004a31be480SAlexander Graf #define KVM_REG_SIZE_U512 0x0060000000000000ULL 1005a31be480SAlexander Graf #define KVM_REG_SIZE_U1024 0x0070000000000000ULL 10069d4e4f8cSAlexander Graf 1007eadd0e44SPeter Maydell struct kvm_reg_list { 1008eadd0e44SPeter Maydell __u64 n; /* number of regs */ 1009eadd0e44SPeter Maydell __u64 reg[0]; 1010eadd0e44SPeter Maydell }; 1011eadd0e44SPeter Maydell 10129d4e4f8cSAlexander Graf struct kvm_one_reg { 10139d4e4f8cSAlexander Graf __u64 id; 1014a31be480SAlexander Graf __u64 addr; 10159d4e4f8cSAlexander Graf }; 10169d4e4f8cSAlexander Graf 101780a3eb10SJan Kiszka struct kvm_msi { 101880a3eb10SJan Kiszka __u32 address_lo; 101980a3eb10SJan Kiszka __u32 address_hi; 102080a3eb10SJan Kiszka __u32 data; 102180a3eb10SJan Kiszka __u32 flags; 102280a3eb10SJan Kiszka __u8 pad[16]; 102380a3eb10SJan Kiszka }; 102480a3eb10SJan Kiszka 1025eadd0e44SPeter Maydell struct kvm_arm_device_addr { 1026eadd0e44SPeter Maydell __u64 id; 1027eadd0e44SPeter Maydell __u64 addr; 1028eadd0e44SPeter Maydell }; 1029eadd0e44SPeter Maydell 103051b24e34SJan Kiszka /* 1031e098b453SAlexey Kardashevskiy * Device control API, available with KVM_CAP_DEVICE_CTRL 1032e098b453SAlexey Kardashevskiy */ 1033e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE_TEST 1 1034e098b453SAlexey Kardashevskiy 1035e098b453SAlexey Kardashevskiy struct kvm_create_device { 1036e098b453SAlexey Kardashevskiy __u32 type; /* in: KVM_DEV_TYPE_xxx */ 1037e098b453SAlexey Kardashevskiy __u32 fd; /* out: device handle */ 1038e098b453SAlexey Kardashevskiy __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */ 1039e098b453SAlexey Kardashevskiy }; 1040e098b453SAlexey Kardashevskiy 1041e098b453SAlexey Kardashevskiy struct kvm_device_attr { 1042e098b453SAlexey Kardashevskiy __u32 flags; /* no flags currently defined */ 1043e098b453SAlexey Kardashevskiy __u32 group; /* device-defined */ 1044e098b453SAlexey Kardashevskiy __u64 attr; /* group-defined */ 1045e098b453SAlexey Kardashevskiy __u64 addr; /* userspace address of attr data */ 1046e098b453SAlexey Kardashevskiy }; 1047e098b453SAlexey Kardashevskiy 1048bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP 1 1049bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP_ADD 1 1050bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP_DEL 2 1051444b1996SArd Biesheuvel 1052444b1996SArd Biesheuvel enum kvm_device_type { 1053444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_20 = 1, 1054444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_20 KVM_DEV_TYPE_FSL_MPIC_20 1055444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_42, 1056444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_42 KVM_DEV_TYPE_FSL_MPIC_42 1057444b1996SArd Biesheuvel KVM_DEV_TYPE_XICS, 1058444b1996SArd Biesheuvel #define KVM_DEV_TYPE_XICS KVM_DEV_TYPE_XICS 1059444b1996SArd Biesheuvel KVM_DEV_TYPE_VFIO, 1060444b1996SArd Biesheuvel #define KVM_DEV_TYPE_VFIO KVM_DEV_TYPE_VFIO 1061444b1996SArd Biesheuvel KVM_DEV_TYPE_ARM_VGIC_V2, 1062444b1996SArd Biesheuvel #define KVM_DEV_TYPE_ARM_VGIC_V2 KVM_DEV_TYPE_ARM_VGIC_V2 1063444b1996SArd Biesheuvel KVM_DEV_TYPE_FLIC, 1064444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_FLIC 106551628b18SChristian Borntraeger KVM_DEV_TYPE_ARM_VGIC_V3, 106651628b18SChristian Borntraeger #define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3 1067444b1996SArd Biesheuvel KVM_DEV_TYPE_MAX, 1068444b1996SArd Biesheuvel }; 1069e098b453SAlexey Kardashevskiy 1070e098b453SAlexey Kardashevskiy /* 107151b24e34SJan Kiszka * ioctls for VM fds 107251b24e34SJan Kiszka */ 107351b24e34SJan Kiszka #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) 107451b24e34SJan Kiszka /* 107551b24e34SJan Kiszka * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns 107651b24e34SJan Kiszka * a vcpu fd. 107751b24e34SJan Kiszka */ 107851b24e34SJan Kiszka #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) 107951b24e34SJan Kiszka #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) 108051b24e34SJan Kiszka /* KVM_SET_MEMORY_ALIAS is obsolete: */ 108151b24e34SJan Kiszka #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) 108251b24e34SJan Kiszka #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) 108351b24e34SJan Kiszka #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) 108451b24e34SJan Kiszka #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ 108551b24e34SJan Kiszka struct kvm_userspace_memory_region) 108651b24e34SJan Kiszka #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) 108751b24e34SJan Kiszka #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64) 10881529ae1bSAlexander Graf 10891529ae1bSAlexander Graf /* enable ucontrol for s390 */ 10901529ae1bSAlexander Graf struct kvm_s390_ucas_mapping { 10911529ae1bSAlexander Graf __u64 user_addr; 10921529ae1bSAlexander Graf __u64 vcpu_addr; 10931529ae1bSAlexander Graf __u64 length; 10941529ae1bSAlexander Graf }; 10951529ae1bSAlexander Graf #define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping) 10961529ae1bSAlexander Graf #define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping) 10971529ae1bSAlexander Graf #define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long) 10981529ae1bSAlexander Graf 109951b24e34SJan Kiszka /* Device model IOC */ 110051b24e34SJan Kiszka #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) 110151b24e34SJan Kiszka #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) 110251b24e34SJan Kiszka #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) 110351b24e34SJan Kiszka #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) 110451b24e34SJan Kiszka #define KVM_CREATE_PIT _IO(KVMIO, 0x64) 110551b24e34SJan Kiszka #define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state) 110651b24e34SJan Kiszka #define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state) 110751b24e34SJan Kiszka #define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level) 110851b24e34SJan Kiszka #define KVM_REGISTER_COALESCED_MMIO \ 110951b24e34SJan Kiszka _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone) 111051b24e34SJan Kiszka #define KVM_UNREGISTER_COALESCED_MMIO \ 111151b24e34SJan Kiszka _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone) 111251b24e34SJan Kiszka #define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \ 111351b24e34SJan Kiszka struct kvm_assigned_pci_dev) 111451b24e34SJan Kiszka #define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing) 111551b24e34SJan Kiszka /* deprecated, replaced by KVM_ASSIGN_DEV_IRQ */ 111651b24e34SJan Kiszka #define KVM_ASSIGN_IRQ __KVM_DEPRECATED_VM_R_0x70 111751b24e34SJan Kiszka #define KVM_ASSIGN_DEV_IRQ _IOW(KVMIO, 0x70, struct kvm_assigned_irq) 111851b24e34SJan Kiszka #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71) 111951b24e34SJan Kiszka #define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, \ 112051b24e34SJan Kiszka struct kvm_assigned_pci_dev) 112151b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_NR _IOW(KVMIO, 0x73, \ 112251b24e34SJan Kiszka struct kvm_assigned_msix_nr) 112351b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO, 0x74, \ 112451b24e34SJan Kiszka struct kvm_assigned_msix_entry) 112551b24e34SJan Kiszka #define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq) 112651b24e34SJan Kiszka #define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd) 112751b24e34SJan Kiszka #define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config) 112851b24e34SJan Kiszka #define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78) 112951b24e34SJan Kiszka #define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd) 113051b24e34SJan Kiszka #define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config) 113151b24e34SJan Kiszka #define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data) 113251b24e34SJan Kiszka #define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data) 113351b24e34SJan Kiszka /* Available with KVM_CAP_PIT_STATE2 */ 113451b24e34SJan Kiszka #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) 113551b24e34SJan Kiszka #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) 113651b24e34SJan Kiszka /* Available with KVM_CAP_PPC_GET_PVINFO */ 113751b24e34SJan Kiszka #define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo) 113851b24e34SJan Kiszka /* Available with KVM_CAP_TSC_CONTROL */ 113951b24e34SJan Kiszka #define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2) 114051b24e34SJan Kiszka #define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3) 11419ab2195dSMarcelo Tosatti /* Available with KVM_CAP_PCI_2_3 */ 11429ab2195dSMarcelo Tosatti #define KVM_ASSIGN_SET_INTX_MASK _IOW(KVMIO, 0xa4, \ 11439ab2195dSMarcelo Tosatti struct kvm_assigned_pci_dev) 114480a3eb10SJan Kiszka /* Available with KVM_CAP_SIGNAL_MSI */ 114580a3eb10SJan Kiszka #define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi) 114680a3eb10SJan Kiszka /* Available with KVM_CAP_PPC_GET_SMMU_INFO */ 114780a3eb10SJan Kiszka #define KVM_PPC_GET_SMMU_INFO _IOR(KVMIO, 0xa6, struct kvm_ppc_smmu_info) 1148651682dcSMichael S. Tsirkin /* Available with KVM_CAP_PPC_ALLOC_HTAB */ 1149651682dcSMichael S. Tsirkin #define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32) 1150d4834ff9SAlexander Graf #define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce) 1151d4834ff9SAlexander Graf /* Available with KVM_CAP_RMA */ 1152d4834ff9SAlexander Graf #define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma) 1153d4834ff9SAlexander Graf /* Available with KVM_CAP_PPC_HTAB_FD */ 1154d4834ff9SAlexander Graf #define KVM_PPC_GET_HTAB_FD _IOW(KVMIO, 0xaa, struct kvm_get_htab_fd) 1155eadd0e44SPeter Maydell /* Available with KVM_CAP_ARM_SET_DEVICE_ADDR */ 1156eadd0e44SPeter Maydell #define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr) 1157e098b453SAlexey Kardashevskiy /* Available with KVM_CAP_PPC_RTAS */ 1158e098b453SAlexey Kardashevskiy #define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args) 1159e098b453SAlexey Kardashevskiy 1160e098b453SAlexey Kardashevskiy /* ioctl for vm fd */ 1161e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) 1162e098b453SAlexey Kardashevskiy 1163e098b453SAlexey Kardashevskiy /* ioctls for fds returned by KVM_CREATE_DEVICE */ 1164e098b453SAlexey Kardashevskiy #define KVM_SET_DEVICE_ATTR _IOW(KVMIO, 0xe1, struct kvm_device_attr) 1165e098b453SAlexey Kardashevskiy #define KVM_GET_DEVICE_ATTR _IOW(KVMIO, 0xe2, struct kvm_device_attr) 1166e098b453SAlexey Kardashevskiy #define KVM_HAS_DEVICE_ATTR _IOW(KVMIO, 0xe3, struct kvm_device_attr) 116751b24e34SJan Kiszka 116851b24e34SJan Kiszka /* 116951b24e34SJan Kiszka * ioctls for vcpu fds 117051b24e34SJan Kiszka */ 117151b24e34SJan Kiszka #define KVM_RUN _IO(KVMIO, 0x80) 117251b24e34SJan Kiszka #define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs) 117351b24e34SJan Kiszka #define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs) 117451b24e34SJan Kiszka #define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs) 117551b24e34SJan Kiszka #define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs) 117651b24e34SJan Kiszka #define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation) 117751b24e34SJan Kiszka #define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt) 117851b24e34SJan Kiszka /* KVM_DEBUG_GUEST is no longer supported, use KVM_SET_GUEST_DEBUG instead */ 117951b24e34SJan Kiszka #define KVM_DEBUG_GUEST __KVM_DEPRECATED_VCPU_W_0x87 118051b24e34SJan Kiszka #define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs) 118151b24e34SJan Kiszka #define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs) 118251b24e34SJan Kiszka #define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid) 118351b24e34SJan Kiszka #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask) 118451b24e34SJan Kiszka #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu) 118551b24e34SJan Kiszka #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) 118651b24e34SJan Kiszka #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) 118751b24e34SJan Kiszka #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) 118851b24e34SJan Kiszka #define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) 118951b24e34SJan Kiszka #define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2) 119051b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 119151b24e34SJan Kiszka #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl) 119251b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 119351b24e34SJan Kiszka #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) 119451b24e34SJan Kiszka /* valid for virtual machine (for floating interrupt)_and_ vcpu */ 119551b24e34SJan Kiszka #define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt) 119651b24e34SJan Kiszka /* store status for s390 */ 119751b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_NOADDR (-1ul) 119851b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_PREFIXED (-2ul) 119951b24e34SJan Kiszka #define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long) 120051b24e34SJan Kiszka /* initial ipl psw for s390 */ 120151b24e34SJan Kiszka #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw) 120251b24e34SJan Kiszka /* initial reset for s390 */ 120351b24e34SJan Kiszka #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) 120451b24e34SJan Kiszka #define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) 120551b24e34SJan Kiszka #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) 1206444b1996SArd Biesheuvel /* Available with KVM_CAP_USER_NMI */ 120751b24e34SJan Kiszka #define KVM_NMI _IO(KVMIO, 0x9a) 120851b24e34SJan Kiszka /* Available with KVM_CAP_SET_GUEST_DEBUG */ 120951b24e34SJan Kiszka #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) 121051b24e34SJan Kiszka /* MCE for x86 */ 121151b24e34SJan Kiszka #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64) 121251b24e34SJan Kiszka #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64) 121351b24e34SJan Kiszka #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) 121451b24e34SJan Kiszka /* Available with KVM_CAP_VCPU_EVENTS */ 121551b24e34SJan Kiszka #define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events) 121651b24e34SJan Kiszka #define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events) 121751b24e34SJan Kiszka /* Available with KVM_CAP_DEBUGREGS */ 121851b24e34SJan Kiszka #define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs) 121951b24e34SJan Kiszka #define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs) 12209ffd2685SCornelia Huck /* 12219ffd2685SCornelia Huck * vcpu version available with KVM_ENABLE_CAP 12229ffd2685SCornelia Huck * vm version available with KVM_CAP_ENABLE_CAP_VM 12239ffd2685SCornelia Huck */ 122451b24e34SJan Kiszka #define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap) 122551b24e34SJan Kiszka /* Available with KVM_CAP_XSAVE */ 122651b24e34SJan Kiszka #define KVM_GET_XSAVE _IOR(KVMIO, 0xa4, struct kvm_xsave) 122751b24e34SJan Kiszka #define KVM_SET_XSAVE _IOW(KVMIO, 0xa5, struct kvm_xsave) 122851b24e34SJan Kiszka /* Available with KVM_CAP_XCRS */ 122951b24e34SJan Kiszka #define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs) 123051b24e34SJan Kiszka #define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs) 1231a54fc080SAlexander Graf /* Available with KVM_CAP_SW_TLB */ 1232a54fc080SAlexander Graf #define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb) 12339d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 1234a31be480SAlexander Graf #define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg) 12359d4e4f8cSAlexander Graf #define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg) 12369ab2195dSMarcelo Tosatti /* VM is being stopped by host */ 12379ab2195dSMarcelo Tosatti #define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad) 1238eadd0e44SPeter Maydell #define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init) 1239bf63839fSAlex Williamson #define KVM_ARM_PREFERRED_TARGET _IOR(KVMIO, 0xaf, struct kvm_vcpu_init) 1240eadd0e44SPeter Maydell #define KVM_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list) 12417a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_MEM_OP */ 12427a52ce8aSCornelia Huck #define KVM_S390_MEM_OP _IOW(KVMIO, 0xb1, struct kvm_s390_mem_op) 12437a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_SKEYS */ 12447a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS _IOW(KVMIO, 0xb2, struct kvm_s390_skeys) 12457a52ce8aSCornelia Huck #define KVM_S390_SET_SKEYS _IOW(KVMIO, 0xb3, struct kvm_s390_skeys) 12467a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_INJECT_IRQ */ 12477a52ce8aSCornelia Huck #define KVM_S390_IRQ _IOW(KVMIO, 0xb4, struct kvm_s390_irq) 12487a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_IRQ_STATE */ 12497a52ce8aSCornelia Huck #define KVM_S390_SET_IRQ_STATE _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state) 12507a52ce8aSCornelia Huck #define KVM_S390_GET_IRQ_STATE _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state) 125124a31426SPaolo Bonzini /* Available with KVM_CAP_X86_SMM */ 125224a31426SPaolo Bonzini #define KVM_SMI _IO(KVMIO, 0xb7) 125351b24e34SJan Kiszka 125451b24e34SJan Kiszka #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) 12559ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) 12569ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2) 125751b24e34SJan Kiszka 125851b24e34SJan Kiszka struct kvm_assigned_pci_dev { 125951b24e34SJan Kiszka __u32 assigned_dev_id; 126051b24e34SJan Kiszka __u32 busnr; 126151b24e34SJan Kiszka __u32 devfn; 126251b24e34SJan Kiszka __u32 flags; 126351b24e34SJan Kiszka __u32 segnr; 126451b24e34SJan Kiszka union { 126551b24e34SJan Kiszka __u32 reserved[11]; 126651b24e34SJan Kiszka }; 126751b24e34SJan Kiszka }; 126851b24e34SJan Kiszka 126951b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_INTX (1 << 0) 127051b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSI (1 << 1) 127151b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSIX (1 << 2) 127251b24e34SJan Kiszka 127351b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_INTX (1 << 8) 127451b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSI (1 << 9) 127551b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10) 127651b24e34SJan Kiszka 127751b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MASK 0x00ff 127851b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MASK 0xff00 127951b24e34SJan Kiszka 128051b24e34SJan Kiszka struct kvm_assigned_irq { 128151b24e34SJan Kiszka __u32 assigned_dev_id; 12827c6da3deSAlexander Graf __u32 host_irq; /* ignored (legacy field) */ 128351b24e34SJan Kiszka __u32 guest_irq; 128451b24e34SJan Kiszka __u32 flags; 128551b24e34SJan Kiszka union { 128651b24e34SJan Kiszka __u32 reserved[12]; 128751b24e34SJan Kiszka }; 128851b24e34SJan Kiszka }; 128951b24e34SJan Kiszka 129051b24e34SJan Kiszka struct kvm_assigned_msix_nr { 129151b24e34SJan Kiszka __u32 assigned_dev_id; 129251b24e34SJan Kiszka __u16 entry_nr; 129351b24e34SJan Kiszka __u16 padding; 129451b24e34SJan Kiszka }; 129551b24e34SJan Kiszka 129651b24e34SJan Kiszka #define KVM_MAX_MSIX_PER_DEV 256 129751b24e34SJan Kiszka struct kvm_assigned_msix_entry { 129851b24e34SJan Kiszka __u32 assigned_dev_id; 129951b24e34SJan Kiszka __u32 gsi; 130051b24e34SJan Kiszka __u16 entry; /* The index of entry in the MSI-X table */ 130151b24e34SJan Kiszka __u16 padding[3]; 130251b24e34SJan Kiszka }; 130351b24e34SJan Kiszka 130451b24e34SJan Kiszka #endif /* __LINUX_KVM_H */ 1305