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 15051b24e34SJan Kiszka #define KVM_EXIT_UNKNOWN 0 15151b24e34SJan Kiszka #define KVM_EXIT_EXCEPTION 1 15251b24e34SJan Kiszka #define KVM_EXIT_IO 2 15351b24e34SJan Kiszka #define KVM_EXIT_HYPERCALL 3 15451b24e34SJan Kiszka #define KVM_EXIT_DEBUG 4 15551b24e34SJan Kiszka #define KVM_EXIT_HLT 5 15651b24e34SJan Kiszka #define KVM_EXIT_MMIO 6 15751b24e34SJan Kiszka #define KVM_EXIT_IRQ_WINDOW_OPEN 7 15851b24e34SJan Kiszka #define KVM_EXIT_SHUTDOWN 8 15951b24e34SJan Kiszka #define KVM_EXIT_FAIL_ENTRY 9 16051b24e34SJan Kiszka #define KVM_EXIT_INTR 10 16151b24e34SJan Kiszka #define KVM_EXIT_SET_TPR 11 16251b24e34SJan Kiszka #define KVM_EXIT_TPR_ACCESS 12 16351b24e34SJan Kiszka #define KVM_EXIT_S390_SIEIC 13 16451b24e34SJan Kiszka #define KVM_EXIT_S390_RESET 14 165a9fd1654SJens Freimann #define KVM_EXIT_DCR 15 /* deprecated */ 16651b24e34SJan Kiszka #define KVM_EXIT_NMI 16 16751b24e34SJan Kiszka #define KVM_EXIT_INTERNAL_ERROR 17 16851b24e34SJan Kiszka #define KVM_EXIT_OSI 18 1697c6da3deSAlexander Graf #define KVM_EXIT_PAPR_HCALL 19 1701529ae1bSAlexander Graf #define KVM_EXIT_S390_UCONTROL 20 171d4834ff9SAlexander Graf #define KVM_EXIT_WATCHDOG 21 172d3dccee1SAlexander Graf #define KVM_EXIT_S390_TSCH 22 173d3dccee1SAlexander Graf #define KVM_EXIT_EPR 23 174b061808dSAlexander Graf #define KVM_EXIT_SYSTEM_EVENT 24 17551b24e34SJan Kiszka 17651b24e34SJan Kiszka /* For KVM_EXIT_INTERNAL_ERROR */ 177d4834ff9SAlexander Graf /* Emulate instruction failed. */ 17851b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_EMULATION 1 179d4834ff9SAlexander Graf /* Encounter unexpected simultaneous exceptions. */ 18051b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_SIMUL_EX 2 181d4834ff9SAlexander Graf /* Encounter unexpected vm-exit due to delivery event. */ 182d4834ff9SAlexander Graf #define KVM_INTERNAL_ERROR_DELIVERY_EV 3 18351b24e34SJan Kiszka 18451b24e34SJan Kiszka /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ 18551b24e34SJan Kiszka struct kvm_run { 18651b24e34SJan Kiszka /* in */ 18751b24e34SJan Kiszka __u8 request_interrupt_window; 18851b24e34SJan Kiszka __u8 padding1[7]; 18951b24e34SJan Kiszka 19051b24e34SJan Kiszka /* out */ 19151b24e34SJan Kiszka __u32 exit_reason; 19251b24e34SJan Kiszka __u8 ready_for_interrupt_injection; 19351b24e34SJan Kiszka __u8 if_flag; 19451b24e34SJan Kiszka __u8 padding2[2]; 19551b24e34SJan Kiszka 19651b24e34SJan Kiszka /* in (pre_kvm_run), out (post_kvm_run) */ 19751b24e34SJan Kiszka __u64 cr8; 19851b24e34SJan Kiszka __u64 apic_base; 19951b24e34SJan Kiszka 20051b24e34SJan Kiszka #ifdef __KVM_S390 20151b24e34SJan Kiszka /* the processor status word for s390 */ 20251b24e34SJan Kiszka __u64 psw_mask; /* psw upper half */ 20351b24e34SJan Kiszka __u64 psw_addr; /* psw lower half */ 20451b24e34SJan Kiszka #endif 20551b24e34SJan Kiszka union { 20651b24e34SJan Kiszka /* KVM_EXIT_UNKNOWN */ 20751b24e34SJan Kiszka struct { 20851b24e34SJan Kiszka __u64 hardware_exit_reason; 20951b24e34SJan Kiszka } hw; 21051b24e34SJan Kiszka /* KVM_EXIT_FAIL_ENTRY */ 21151b24e34SJan Kiszka struct { 21251b24e34SJan Kiszka __u64 hardware_entry_failure_reason; 21351b24e34SJan Kiszka } fail_entry; 21451b24e34SJan Kiszka /* KVM_EXIT_EXCEPTION */ 21551b24e34SJan Kiszka struct { 21651b24e34SJan Kiszka __u32 exception; 21751b24e34SJan Kiszka __u32 error_code; 21851b24e34SJan Kiszka } ex; 21951b24e34SJan Kiszka /* KVM_EXIT_IO */ 22051b24e34SJan Kiszka struct { 22151b24e34SJan Kiszka #define KVM_EXIT_IO_IN 0 22251b24e34SJan Kiszka #define KVM_EXIT_IO_OUT 1 22351b24e34SJan Kiszka __u8 direction; 22451b24e34SJan Kiszka __u8 size; /* bytes */ 22551b24e34SJan Kiszka __u16 port; 22651b24e34SJan Kiszka __u32 count; 22751b24e34SJan Kiszka __u64 data_offset; /* relative to kvm_run start */ 22851b24e34SJan Kiszka } io; 22951b24e34SJan Kiszka struct { 23051b24e34SJan Kiszka struct kvm_debug_exit_arch arch; 23151b24e34SJan Kiszka } debug; 23251b24e34SJan Kiszka /* KVM_EXIT_MMIO */ 23351b24e34SJan Kiszka struct { 23451b24e34SJan Kiszka __u64 phys_addr; 23551b24e34SJan Kiszka __u8 data[8]; 23651b24e34SJan Kiszka __u32 len; 23751b24e34SJan Kiszka __u8 is_write; 23851b24e34SJan Kiszka } mmio; 23951b24e34SJan Kiszka /* KVM_EXIT_HYPERCALL */ 24051b24e34SJan Kiszka struct { 24151b24e34SJan Kiszka __u64 nr; 24251b24e34SJan Kiszka __u64 args[6]; 24351b24e34SJan Kiszka __u64 ret; 24451b24e34SJan Kiszka __u32 longmode; 24551b24e34SJan Kiszka __u32 pad; 24651b24e34SJan Kiszka } hypercall; 24751b24e34SJan Kiszka /* KVM_EXIT_TPR_ACCESS */ 24851b24e34SJan Kiszka struct { 24951b24e34SJan Kiszka __u64 rip; 25051b24e34SJan Kiszka __u32 is_write; 25151b24e34SJan Kiszka __u32 pad; 25251b24e34SJan Kiszka } tpr_access; 25351b24e34SJan Kiszka /* KVM_EXIT_S390_SIEIC */ 25451b24e34SJan Kiszka struct { 25551b24e34SJan Kiszka __u8 icptcode; 25651b24e34SJan Kiszka __u16 ipa; 25751b24e34SJan Kiszka __u32 ipb; 25851b24e34SJan Kiszka } s390_sieic; 25951b24e34SJan Kiszka /* KVM_EXIT_S390_RESET */ 26051b24e34SJan Kiszka #define KVM_S390_RESET_POR 1 26151b24e34SJan Kiszka #define KVM_S390_RESET_CLEAR 2 26251b24e34SJan Kiszka #define KVM_S390_RESET_SUBSYSTEM 4 26351b24e34SJan Kiszka #define KVM_S390_RESET_CPU_INIT 8 26451b24e34SJan Kiszka #define KVM_S390_RESET_IPL 16 26551b24e34SJan Kiszka __u64 s390_reset_flags; 2661529ae1bSAlexander Graf /* KVM_EXIT_S390_UCONTROL */ 2671529ae1bSAlexander Graf struct { 2681529ae1bSAlexander Graf __u64 trans_exc_code; 2691529ae1bSAlexander Graf __u32 pgm_code; 2701529ae1bSAlexander Graf } s390_ucontrol; 271a9fd1654SJens Freimann /* KVM_EXIT_DCR (deprecated) */ 27251b24e34SJan Kiszka struct { 27351b24e34SJan Kiszka __u32 dcrn; 27451b24e34SJan Kiszka __u32 data; 27551b24e34SJan Kiszka __u8 is_write; 27651b24e34SJan Kiszka } dcr; 27751b24e34SJan Kiszka struct { 27851b24e34SJan Kiszka __u32 suberror; 27951b24e34SJan Kiszka /* Available with KVM_CAP_INTERNAL_ERROR_DATA: */ 28051b24e34SJan Kiszka __u32 ndata; 28151b24e34SJan Kiszka __u64 data[16]; 28251b24e34SJan Kiszka } internal; 28351b24e34SJan Kiszka /* KVM_EXIT_OSI */ 28451b24e34SJan Kiszka struct { 28551b24e34SJan Kiszka __u64 gprs[32]; 28651b24e34SJan Kiszka } osi; 2877c6da3deSAlexander Graf struct { 2887c6da3deSAlexander Graf __u64 nr; 2897c6da3deSAlexander Graf __u64 ret; 2907c6da3deSAlexander Graf __u64 args[9]; 2917c6da3deSAlexander Graf } papr_hcall; 292d3dccee1SAlexander Graf /* KVM_EXIT_S390_TSCH */ 293d3dccee1SAlexander Graf struct { 294d3dccee1SAlexander Graf __u16 subchannel_id; 295d3dccee1SAlexander Graf __u16 subchannel_nr; 296d3dccee1SAlexander Graf __u32 io_int_parm; 297d3dccee1SAlexander Graf __u32 io_int_word; 298d3dccee1SAlexander Graf __u32 ipb; 299d3dccee1SAlexander Graf __u8 dequeued; 300d3dccee1SAlexander Graf } s390_tsch; 301d3dccee1SAlexander Graf /* KVM_EXIT_EPR */ 302d3dccee1SAlexander Graf struct { 303d3dccee1SAlexander Graf __u32 epr; 304d3dccee1SAlexander Graf } epr; 305b061808dSAlexander Graf /* KVM_EXIT_SYSTEM_EVENT */ 306b061808dSAlexander Graf struct { 307b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_SHUTDOWN 1 308b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_RESET 2 309b061808dSAlexander Graf __u32 type; 310b061808dSAlexander Graf __u64 flags; 311b061808dSAlexander Graf } system_event; 31251b24e34SJan Kiszka /* Fix the size of the union. */ 31351b24e34SJan Kiszka char padding[256]; 31451b24e34SJan Kiszka }; 3151529ae1bSAlexander Graf 3161529ae1bSAlexander Graf /* 3171529ae1bSAlexander Graf * shared registers between kvm and userspace. 3181529ae1bSAlexander Graf * kvm_valid_regs specifies the register classes set by the host 3191529ae1bSAlexander Graf * kvm_dirty_regs specified the register classes dirtied by userspace 3201529ae1bSAlexander Graf * struct kvm_sync_regs is architecture specific, as well as the 3211529ae1bSAlexander Graf * bits for kvm_valid_regs and kvm_dirty_regs 3221529ae1bSAlexander Graf */ 3231529ae1bSAlexander Graf __u64 kvm_valid_regs; 3241529ae1bSAlexander Graf __u64 kvm_dirty_regs; 3251529ae1bSAlexander Graf union { 3261529ae1bSAlexander Graf struct kvm_sync_regs regs; 3271529ae1bSAlexander Graf char padding[1024]; 3281529ae1bSAlexander Graf } s; 32951b24e34SJan Kiszka }; 33051b24e34SJan Kiszka 33151b24e34SJan Kiszka /* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */ 33251b24e34SJan Kiszka 33351b24e34SJan Kiszka struct kvm_coalesced_mmio_zone { 33451b24e34SJan Kiszka __u64 addr; 33551b24e34SJan Kiszka __u32 size; 33651b24e34SJan Kiszka __u32 pad; 33751b24e34SJan Kiszka }; 33851b24e34SJan Kiszka 33951b24e34SJan Kiszka struct kvm_coalesced_mmio { 34051b24e34SJan Kiszka __u64 phys_addr; 34151b24e34SJan Kiszka __u32 len; 34251b24e34SJan Kiszka __u32 pad; 34351b24e34SJan Kiszka __u8 data[8]; 34451b24e34SJan Kiszka }; 34551b24e34SJan Kiszka 34651b24e34SJan Kiszka struct kvm_coalesced_mmio_ring { 34751b24e34SJan Kiszka __u32 first, last; 34851b24e34SJan Kiszka struct kvm_coalesced_mmio coalesced_mmio[0]; 34951b24e34SJan Kiszka }; 35051b24e34SJan Kiszka 35151b24e34SJan Kiszka #define KVM_COALESCED_MMIO_MAX \ 35251b24e34SJan Kiszka ((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \ 35351b24e34SJan Kiszka sizeof(struct kvm_coalesced_mmio)) 35451b24e34SJan Kiszka 35551b24e34SJan Kiszka /* for KVM_TRANSLATE */ 35651b24e34SJan Kiszka struct kvm_translation { 35751b24e34SJan Kiszka /* in */ 35851b24e34SJan Kiszka __u64 linear_address; 35951b24e34SJan Kiszka 36051b24e34SJan Kiszka /* out */ 36151b24e34SJan Kiszka __u64 physical_address; 36251b24e34SJan Kiszka __u8 valid; 36351b24e34SJan Kiszka __u8 writeable; 36451b24e34SJan Kiszka __u8 usermode; 36551b24e34SJan Kiszka __u8 pad[5]; 36651b24e34SJan Kiszka }; 36751b24e34SJan Kiszka 36851b24e34SJan Kiszka /* for KVM_INTERRUPT */ 36951b24e34SJan Kiszka struct kvm_interrupt { 37051b24e34SJan Kiszka /* in */ 37151b24e34SJan Kiszka __u32 irq; 37251b24e34SJan Kiszka }; 37351b24e34SJan Kiszka 37451b24e34SJan Kiszka /* for KVM_GET_DIRTY_LOG */ 37551b24e34SJan Kiszka struct kvm_dirty_log { 37651b24e34SJan Kiszka __u32 slot; 37751b24e34SJan Kiszka __u32 padding1; 37851b24e34SJan Kiszka union { 37951b24e34SJan Kiszka void *dirty_bitmap; /* one bit per page */ 38051b24e34SJan Kiszka __u64 padding2; 38151b24e34SJan Kiszka }; 38251b24e34SJan Kiszka }; 38351b24e34SJan Kiszka 38451b24e34SJan Kiszka /* for KVM_SET_SIGNAL_MASK */ 38551b24e34SJan Kiszka struct kvm_signal_mask { 38651b24e34SJan Kiszka __u32 len; 38751b24e34SJan Kiszka __u8 sigset[0]; 38851b24e34SJan Kiszka }; 38951b24e34SJan Kiszka 39051b24e34SJan Kiszka /* for KVM_TPR_ACCESS_REPORTING */ 39151b24e34SJan Kiszka struct kvm_tpr_access_ctl { 39251b24e34SJan Kiszka __u32 enabled; 39351b24e34SJan Kiszka __u32 flags; 39451b24e34SJan Kiszka __u32 reserved[8]; 39551b24e34SJan Kiszka }; 39651b24e34SJan Kiszka 39751b24e34SJan Kiszka /* for KVM_SET_VAPIC_ADDR */ 39851b24e34SJan Kiszka struct kvm_vapic_addr { 39951b24e34SJan Kiszka __u64 vapic_addr; 40051b24e34SJan Kiszka }; 40151b24e34SJan Kiszka 402a9fd1654SJens Freimann /* for KVM_SET_MP_STATE */ 40351b24e34SJan Kiszka 404a9fd1654SJens Freimann /* not all states are valid on all architectures */ 40551b24e34SJan Kiszka #define KVM_MP_STATE_RUNNABLE 0 40651b24e34SJan Kiszka #define KVM_MP_STATE_UNINITIALIZED 1 40751b24e34SJan Kiszka #define KVM_MP_STATE_INIT_RECEIVED 2 40851b24e34SJan Kiszka #define KVM_MP_STATE_HALTED 3 40951b24e34SJan Kiszka #define KVM_MP_STATE_SIPI_RECEIVED 4 410a9fd1654SJens Freimann #define KVM_MP_STATE_STOPPED 5 411a9fd1654SJens Freimann #define KVM_MP_STATE_CHECK_STOP 6 412a9fd1654SJens Freimann #define KVM_MP_STATE_OPERATING 7 413a9fd1654SJens Freimann #define KVM_MP_STATE_LOAD 8 41451b24e34SJan Kiszka 41551b24e34SJan Kiszka struct kvm_mp_state { 41651b24e34SJan Kiszka __u32 mp_state; 41751b24e34SJan Kiszka }; 41851b24e34SJan Kiszka 41951b24e34SJan Kiszka struct kvm_s390_psw { 42051b24e34SJan Kiszka __u64 mask; 42151b24e34SJan Kiszka __u64 addr; 42251b24e34SJan Kiszka }; 42351b24e34SJan Kiszka 42451b24e34SJan Kiszka /* valid values for type in kvm_s390_interrupt */ 42551b24e34SJan Kiszka #define KVM_S390_SIGP_STOP 0xfffe0000u 42651b24e34SJan Kiszka #define KVM_S390_PROGRAM_INT 0xfffe0001u 42751b24e34SJan Kiszka #define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u 42851b24e34SJan Kiszka #define KVM_S390_RESTART 0xfffe0003u 429216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_INIT 0xfffe0004u 430216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_DONE 0xfffe0005u 431d3dccee1SAlexander Graf #define KVM_S390_MCHK 0xfffe1000u 43276eb98d5SJens Freimann #define KVM_S390_INT_CLOCK_COMP 0xffff1004u 43376eb98d5SJens Freimann #define KVM_S390_INT_CPU_TIMER 0xffff1005u 43451b24e34SJan Kiszka #define KVM_S390_INT_VIRTIO 0xffff2603u 43551b24e34SJan Kiszka #define KVM_S390_INT_SERVICE 0xffff2401u 43651b24e34SJan Kiszka #define KVM_S390_INT_EMERGENCY 0xffff1201u 4371529ae1bSAlexander Graf #define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u 438d3dccee1SAlexander Graf /* Anything below 0xfffe0000u is taken by INT_IO */ 439d3dccee1SAlexander Graf #define KVM_S390_INT_IO(ai,cssid,ssid,schid) \ 440d3dccee1SAlexander Graf (((schid)) | \ 441d3dccee1SAlexander Graf ((ssid) << 16) | \ 442d3dccee1SAlexander Graf ((cssid) << 18) | \ 443d3dccee1SAlexander Graf ((ai) << 26)) 444d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MIN 0x00000000u 445d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MAX 0xfffdffffu 446d3dccee1SAlexander Graf 44751b24e34SJan Kiszka 44851b24e34SJan Kiszka struct kvm_s390_interrupt { 44951b24e34SJan Kiszka __u32 type; 45051b24e34SJan Kiszka __u32 parm; 45151b24e34SJan Kiszka __u64 parm64; 45251b24e34SJan Kiszka }; 45351b24e34SJan Kiszka 454216db403SChristian Borntraeger struct kvm_s390_io_info { 455216db403SChristian Borntraeger __u16 subchannel_id; 456216db403SChristian Borntraeger __u16 subchannel_nr; 457216db403SChristian Borntraeger __u32 io_int_parm; 458216db403SChristian Borntraeger __u32 io_int_word; 459216db403SChristian Borntraeger }; 460216db403SChristian Borntraeger 461216db403SChristian Borntraeger struct kvm_s390_ext_info { 462216db403SChristian Borntraeger __u32 ext_params; 463216db403SChristian Borntraeger __u32 pad; 464216db403SChristian Borntraeger __u64 ext_params2; 465216db403SChristian Borntraeger }; 466216db403SChristian Borntraeger 467216db403SChristian Borntraeger struct kvm_s390_pgm_info { 468216db403SChristian Borntraeger __u64 trans_exc_code; 469216db403SChristian Borntraeger __u64 mon_code; 470216db403SChristian Borntraeger __u64 per_address; 471216db403SChristian Borntraeger __u32 data_exc_code; 472216db403SChristian Borntraeger __u16 code; 473216db403SChristian Borntraeger __u16 mon_class_nr; 474216db403SChristian Borntraeger __u8 per_code; 475216db403SChristian Borntraeger __u8 per_atmid; 476216db403SChristian Borntraeger __u8 exc_access_id; 477216db403SChristian Borntraeger __u8 per_access_id; 478216db403SChristian Borntraeger __u8 op_access_id; 479216db403SChristian Borntraeger __u8 pad[3]; 480216db403SChristian Borntraeger }; 481216db403SChristian Borntraeger 482216db403SChristian Borntraeger struct kvm_s390_prefix_info { 483216db403SChristian Borntraeger __u32 address; 484216db403SChristian Borntraeger }; 485216db403SChristian Borntraeger 486216db403SChristian Borntraeger struct kvm_s390_extcall_info { 487216db403SChristian Borntraeger __u16 code; 488216db403SChristian Borntraeger }; 489216db403SChristian Borntraeger 490216db403SChristian Borntraeger struct kvm_s390_emerg_info { 491216db403SChristian Borntraeger __u16 code; 492216db403SChristian Borntraeger }; 493216db403SChristian Borntraeger 494216db403SChristian Borntraeger struct kvm_s390_mchk_info { 495216db403SChristian Borntraeger __u64 cr14; 496216db403SChristian Borntraeger __u64 mcic; 497216db403SChristian Borntraeger __u64 failing_storage_address; 498216db403SChristian Borntraeger __u32 ext_damage_code; 499216db403SChristian Borntraeger __u32 pad; 500216db403SChristian Borntraeger __u8 fixed_logout[16]; 501216db403SChristian Borntraeger }; 502216db403SChristian Borntraeger 503216db403SChristian Borntraeger struct kvm_s390_irq { 504216db403SChristian Borntraeger __u64 type; 505216db403SChristian Borntraeger union { 506216db403SChristian Borntraeger struct kvm_s390_io_info io; 507216db403SChristian Borntraeger struct kvm_s390_ext_info ext; 508216db403SChristian Borntraeger struct kvm_s390_pgm_info pgm; 509216db403SChristian Borntraeger struct kvm_s390_emerg_info emerg; 510216db403SChristian Borntraeger struct kvm_s390_extcall_info extcall; 511216db403SChristian Borntraeger struct kvm_s390_prefix_info prefix; 512216db403SChristian Borntraeger struct kvm_s390_mchk_info mchk; 513216db403SChristian Borntraeger char reserved[64]; 514216db403SChristian Borntraeger } u; 515216db403SChristian Borntraeger }; 516216db403SChristian Borntraeger 51751b24e34SJan Kiszka /* for KVM_SET_GUEST_DEBUG */ 51851b24e34SJan Kiszka 51951b24e34SJan Kiszka #define KVM_GUESTDBG_ENABLE 0x00000001 52051b24e34SJan Kiszka #define KVM_GUESTDBG_SINGLESTEP 0x00000002 52151b24e34SJan Kiszka 52251b24e34SJan Kiszka struct kvm_guest_debug { 52351b24e34SJan Kiszka __u32 control; 52451b24e34SJan Kiszka __u32 pad; 52551b24e34SJan Kiszka struct kvm_guest_debug_arch arch; 52651b24e34SJan Kiszka }; 52751b24e34SJan Kiszka 52851b24e34SJan Kiszka enum { 52951b24e34SJan Kiszka kvm_ioeventfd_flag_nr_datamatch, 53051b24e34SJan Kiszka kvm_ioeventfd_flag_nr_pio, 53151b24e34SJan Kiszka kvm_ioeventfd_flag_nr_deassign, 532cae7f586SAlexander Graf kvm_ioeventfd_flag_nr_virtio_ccw_notify, 53376eb98d5SJens Freimann kvm_ioeventfd_flag_nr_fast_mmio, 53451b24e34SJan Kiszka kvm_ioeventfd_flag_nr_max, 53551b24e34SJan Kiszka }; 53651b24e34SJan Kiszka 53751b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) 53851b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) 53951b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) 540cae7f586SAlexander Graf #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ 541cae7f586SAlexander Graf (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify) 54251b24e34SJan Kiszka 54351b24e34SJan Kiszka #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1) 54451b24e34SJan Kiszka 54551b24e34SJan Kiszka struct kvm_ioeventfd { 54651b24e34SJan Kiszka __u64 datamatch; 54751b24e34SJan Kiszka __u64 addr; /* legal pio/mmio address */ 54876eb98d5SJens Freimann __u32 len; /* 1, 2, 4, or 8 bytes; or 0 to ignore length */ 54951b24e34SJan Kiszka __s32 fd; 55051b24e34SJan Kiszka __u32 flags; 55151b24e34SJan Kiszka __u8 pad[36]; 55251b24e34SJan Kiszka }; 55351b24e34SJan Kiszka 55451b24e34SJan Kiszka /* for KVM_ENABLE_CAP */ 55551b24e34SJan Kiszka struct kvm_enable_cap { 55651b24e34SJan Kiszka /* in */ 55751b24e34SJan Kiszka __u32 cap; 55851b24e34SJan Kiszka __u32 flags; 55951b24e34SJan Kiszka __u64 args[4]; 56051b24e34SJan Kiszka __u8 pad[64]; 56151b24e34SJan Kiszka }; 56251b24e34SJan Kiszka 56351b24e34SJan Kiszka /* for KVM_PPC_GET_PVINFO */ 56451b24e34SJan Kiszka struct kvm_ppc_pvinfo { 56551b24e34SJan Kiszka /* out */ 56651b24e34SJan Kiszka __u32 flags; 56751b24e34SJan Kiszka __u32 hcall[4]; 56851b24e34SJan Kiszka __u8 pad[108]; 56951b24e34SJan Kiszka }; 57051b24e34SJan Kiszka 57180a3eb10SJan Kiszka /* for KVM_PPC_GET_SMMU_INFO */ 57280a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_MAX_SZ 8 57380a3eb10SJan Kiszka 57480a3eb10SJan Kiszka struct kvm_ppc_one_page_size { 57580a3eb10SJan Kiszka __u32 page_shift; /* Page shift (or 0) */ 57680a3eb10SJan Kiszka __u32 pte_enc; /* Encoding in the HPTE (>>12) */ 57780a3eb10SJan Kiszka }; 57880a3eb10SJan Kiszka 57980a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size { 58080a3eb10SJan Kiszka __u32 page_shift; /* Base page shift of segment (or 0) */ 58180a3eb10SJan Kiszka __u32 slb_enc; /* SLB encoding for BookS */ 58280a3eb10SJan Kiszka struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ]; 58380a3eb10SJan Kiszka }; 58480a3eb10SJan Kiszka 58580a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_REAL 0x00000001 58680a3eb10SJan Kiszka #define KVM_PPC_1T_SEGMENTS 0x00000002 58780a3eb10SJan Kiszka 58880a3eb10SJan Kiszka struct kvm_ppc_smmu_info { 58980a3eb10SJan Kiszka __u64 flags; 59080a3eb10SJan Kiszka __u32 slb_size; 59180a3eb10SJan Kiszka __u32 pad; 59280a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; 59380a3eb10SJan Kiszka }; 59480a3eb10SJan Kiszka 595d4834ff9SAlexander Graf #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) 596d4834ff9SAlexander Graf 59751b24e34SJan Kiszka #define KVMIO 0xAE 59851b24e34SJan Kiszka 5991529ae1bSAlexander Graf /* machine type bits, to be used as argument to KVM_CREATE_VM */ 6001529ae1bSAlexander Graf #define KVM_VM_S390_UCONTROL 1 6011529ae1bSAlexander Graf 602bf63839fSAlex Williamson /* on ppc, 0 indicate default, 1 should force HV and 2 PR */ 603bf63839fSAlex Williamson #define KVM_VM_PPC_HV 1 604bf63839fSAlex Williamson #define KVM_VM_PPC_PR 2 605bf63839fSAlex Williamson 6061529ae1bSAlexander Graf #define KVM_S390_SIE_PAGE_OFFSET 1 6071529ae1bSAlexander Graf 60851b24e34SJan Kiszka /* 60951b24e34SJan Kiszka * ioctls for /dev/kvm fds: 61051b24e34SJan Kiszka */ 61151b24e34SJan Kiszka #define KVM_GET_API_VERSION _IO(KVMIO, 0x00) 61251b24e34SJan Kiszka #define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ 61351b24e34SJan Kiszka #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) 61451b24e34SJan Kiszka 61551b24e34SJan Kiszka #define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06) 61651b24e34SJan Kiszka /* 61751b24e34SJan Kiszka * Check if a kvm extension is available. Argument is extension number, 61851b24e34SJan Kiszka * return is 1 (yes) or 0 (no, sorry). 61951b24e34SJan Kiszka */ 62051b24e34SJan Kiszka #define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03) 62151b24e34SJan Kiszka /* 62251b24e34SJan Kiszka * Get size for mmap(vcpu_fd) 62351b24e34SJan Kiszka */ 62451b24e34SJan Kiszka #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ 62551b24e34SJan Kiszka #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) 62651b24e34SJan Kiszka #define KVM_TRACE_ENABLE __KVM_DEPRECATED_MAIN_W_0x06 62751b24e34SJan Kiszka #define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07 62851b24e34SJan Kiszka #define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08 629bf63839fSAlex Williamson #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) 63051b24e34SJan Kiszka 63151b24e34SJan Kiszka /* 63251b24e34SJan Kiszka * Extension capability list. 63351b24e34SJan Kiszka */ 63451b24e34SJan Kiszka #define KVM_CAP_IRQCHIP 0 63551b24e34SJan Kiszka #define KVM_CAP_HLT 1 63651b24e34SJan Kiszka #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 63751b24e34SJan Kiszka #define KVM_CAP_USER_MEMORY 3 63851b24e34SJan Kiszka #define KVM_CAP_SET_TSS_ADDR 4 63951b24e34SJan Kiszka #define KVM_CAP_VAPIC 6 64051b24e34SJan Kiszka #define KVM_CAP_EXT_CPUID 7 64151b24e34SJan Kiszka #define KVM_CAP_CLOCKSOURCE 8 6427c6da3deSAlexander Graf #define KVM_CAP_NR_VCPUS 9 /* returns recommended max vcpus per vm */ 64351b24e34SJan Kiszka #define KVM_CAP_NR_MEMSLOTS 10 /* returns max memory slots per vm */ 64451b24e34SJan Kiszka #define KVM_CAP_PIT 11 64551b24e34SJan Kiszka #define KVM_CAP_NOP_IO_DELAY 12 64651b24e34SJan Kiszka #define KVM_CAP_PV_MMU 13 64751b24e34SJan Kiszka #define KVM_CAP_MP_STATE 14 64851b24e34SJan Kiszka #define KVM_CAP_COALESCED_MMIO 15 64951b24e34SJan Kiszka #define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ 65051b24e34SJan Kiszka #define KVM_CAP_DEVICE_ASSIGNMENT 17 65151b24e34SJan Kiszka #define KVM_CAP_IOMMU 18 65251b24e34SJan Kiszka #ifdef __KVM_HAVE_MSI 65351b24e34SJan Kiszka #define KVM_CAP_DEVICE_MSI 20 65451b24e34SJan Kiszka #endif 65551b24e34SJan Kiszka /* Bug in KVM_SET_USER_MEMORY_REGION fixed: */ 65651b24e34SJan Kiszka #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21 65751b24e34SJan Kiszka #define KVM_CAP_USER_NMI 22 65851b24e34SJan Kiszka #ifdef __KVM_HAVE_GUEST_DEBUG 65951b24e34SJan Kiszka #define KVM_CAP_SET_GUEST_DEBUG 23 66051b24e34SJan Kiszka #endif 66151b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 66251b24e34SJan Kiszka #define KVM_CAP_REINJECT_CONTROL 24 66351b24e34SJan Kiszka #endif 66451b24e34SJan Kiszka #define KVM_CAP_IRQ_ROUTING 25 66551b24e34SJan Kiszka #define KVM_CAP_IRQ_INJECT_STATUS 26 66651b24e34SJan Kiszka #define KVM_CAP_DEVICE_DEASSIGNMENT 27 66751b24e34SJan Kiszka #ifdef __KVM_HAVE_MSIX 66851b24e34SJan Kiszka #define KVM_CAP_DEVICE_MSIX 28 66951b24e34SJan Kiszka #endif 67051b24e34SJan Kiszka #define KVM_CAP_ASSIGN_DEV_IRQ 29 67151b24e34SJan Kiszka /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ 67251b24e34SJan Kiszka #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 67351b24e34SJan Kiszka #ifdef __KVM_HAVE_MCE 67451b24e34SJan Kiszka #define KVM_CAP_MCE 31 67551b24e34SJan Kiszka #endif 67651b24e34SJan Kiszka #define KVM_CAP_IRQFD 32 67751b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 67851b24e34SJan Kiszka #define KVM_CAP_PIT2 33 67951b24e34SJan Kiszka #endif 68051b24e34SJan Kiszka #define KVM_CAP_SET_BOOT_CPU_ID 34 68151b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT_STATE2 68251b24e34SJan Kiszka #define KVM_CAP_PIT_STATE2 35 68351b24e34SJan Kiszka #endif 68451b24e34SJan Kiszka #define KVM_CAP_IOEVENTFD 36 68551b24e34SJan Kiszka #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 68651b24e34SJan Kiszka #ifdef __KVM_HAVE_XEN_HVM 68751b24e34SJan Kiszka #define KVM_CAP_XEN_HVM 38 68851b24e34SJan Kiszka #endif 68951b24e34SJan Kiszka #define KVM_CAP_ADJUST_CLOCK 39 69051b24e34SJan Kiszka #define KVM_CAP_INTERNAL_ERROR_DATA 40 69151b24e34SJan Kiszka #ifdef __KVM_HAVE_VCPU_EVENTS 69251b24e34SJan Kiszka #define KVM_CAP_VCPU_EVENTS 41 69351b24e34SJan Kiszka #endif 69451b24e34SJan Kiszka #define KVM_CAP_S390_PSW 42 69551b24e34SJan Kiszka #define KVM_CAP_PPC_SEGSTATE 43 69651b24e34SJan Kiszka #define KVM_CAP_HYPERV 44 69751b24e34SJan Kiszka #define KVM_CAP_HYPERV_VAPIC 45 69851b24e34SJan Kiszka #define KVM_CAP_HYPERV_SPIN 46 69951b24e34SJan Kiszka #define KVM_CAP_PCI_SEGMENT 47 70051b24e34SJan Kiszka #define KVM_CAP_PPC_PAIRED_SINGLES 48 70151b24e34SJan Kiszka #define KVM_CAP_INTR_SHADOW 49 70251b24e34SJan Kiszka #ifdef __KVM_HAVE_DEBUGREGS 70351b24e34SJan Kiszka #define KVM_CAP_DEBUGREGS 50 70451b24e34SJan Kiszka #endif 70551b24e34SJan Kiszka #define KVM_CAP_X86_ROBUST_SINGLESTEP 51 70651b24e34SJan Kiszka #define KVM_CAP_PPC_OSI 52 70751b24e34SJan Kiszka #define KVM_CAP_PPC_UNSET_IRQ 53 70851b24e34SJan Kiszka #define KVM_CAP_ENABLE_CAP 54 70951b24e34SJan Kiszka #ifdef __KVM_HAVE_XSAVE 71051b24e34SJan Kiszka #define KVM_CAP_XSAVE 55 71151b24e34SJan Kiszka #endif 71251b24e34SJan Kiszka #ifdef __KVM_HAVE_XCRS 71351b24e34SJan Kiszka #define KVM_CAP_XCRS 56 71451b24e34SJan Kiszka #endif 71551b24e34SJan Kiszka #define KVM_CAP_PPC_GET_PVINFO 57 71651b24e34SJan Kiszka #define KVM_CAP_PPC_IRQ_LEVEL 58 71751b24e34SJan Kiszka #define KVM_CAP_ASYNC_PF 59 71851b24e34SJan Kiszka #define KVM_CAP_TSC_CONTROL 60 71951b24e34SJan Kiszka #define KVM_CAP_GET_TSC_KHZ 61 72051b24e34SJan Kiszka #define KVM_CAP_PPC_BOOKE_SREGS 62 7217c6da3deSAlexander Graf #define KVM_CAP_SPAPR_TCE 63 7227c6da3deSAlexander Graf #define KVM_CAP_PPC_SMT 64 7237c6da3deSAlexander Graf #define KVM_CAP_PPC_RMA 65 7247c6da3deSAlexander Graf #define KVM_CAP_MAX_VCPUS 66 /* returns max vcpus per vm */ 7259d4e4f8cSAlexander Graf #define KVM_CAP_PPC_HIOR 67 7267c6da3deSAlexander Graf #define KVM_CAP_PPC_PAPR 68 727a54fc080SAlexander Graf #define KVM_CAP_SW_TLB 69 7289d4e4f8cSAlexander Graf #define KVM_CAP_ONE_REG 70 7291529ae1bSAlexander Graf #define KVM_CAP_S390_GMAP 71 7301529ae1bSAlexander Graf #define KVM_CAP_TSC_DEADLINE_TIMER 72 7311529ae1bSAlexander Graf #define KVM_CAP_S390_UCONTROL 73 7321529ae1bSAlexander Graf #define KVM_CAP_SYNC_REGS 74 7339ab2195dSMarcelo Tosatti #define KVM_CAP_PCI_2_3 75 7349ab2195dSMarcelo Tosatti #define KVM_CAP_KVMCLOCK_CTRL 76 73580a3eb10SJan Kiszka #define KVM_CAP_SIGNAL_MSI 77 73680a3eb10SJan Kiszka #define KVM_CAP_PPC_GET_SMMU_INFO 78 7372a60dba4SAlexander Graf #define KVM_CAP_S390_COW 79 738651682dcSMichael S. Tsirkin #define KVM_CAP_PPC_ALLOC_HTAB 80 739716b8e4dSAlex Williamson #define KVM_CAP_READONLY_MEM 81 740716b8e4dSAlex Williamson #define KVM_CAP_IRQFD_RESAMPLE 82 741d4834ff9SAlexander Graf #define KVM_CAP_PPC_BOOKE_WATCHDOG 83 742d4834ff9SAlexander Graf #define KVM_CAP_PPC_HTAB_FD 84 743d3dccee1SAlexander Graf #define KVM_CAP_S390_CSS_SUPPORT 85 744d3dccee1SAlexander Graf #define KVM_CAP_PPC_EPR 86 745eadd0e44SPeter Maydell #define KVM_CAP_ARM_PSCI 87 746eadd0e44SPeter Maydell #define KVM_CAP_ARM_SET_DEVICE_ADDR 88 747e098b453SAlexey Kardashevskiy #define KVM_CAP_DEVICE_CTRL 89 748e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_MPIC 90 749e098b453SAlexey Kardashevskiy #define KVM_CAP_PPC_RTAS 91 750e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_XICS 92 751c5daeae1SAlexey Kardashevskiy #define KVM_CAP_ARM_EL1_32BIT 93 7524f265607SAndrew Jones #define KVM_CAP_SPAPR_MULTITCE 94 753bf63839fSAlex Williamson #define KVM_CAP_EXT_EMUL_CPUID 95 75448a5f3bcSVadim Rozenfeld #define KVM_CAP_HYPERV_TIME 96 7559ffd2685SCornelia Huck #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97 7569ffd2685SCornelia Huck #define KVM_CAP_ENABLE_CAP_VM 98 7579ffd2685SCornelia Huck #define KVM_CAP_S390_IRQCHIP 99 75876eb98d5SJens Freimann #define KVM_CAP_IOEVENTFD_NO_LENGTH 100 75976eb98d5SJens Freimann #define KVM_CAP_VM_ATTRIBUTES 101 760b061808dSAlexander Graf #define KVM_CAP_ARM_PSCI_0_2 102 761b061808dSAlexander Graf #define KVM_CAP_PPC_FIXUP_HCALL 103 762a9fd1654SJens Freimann #define KVM_CAP_PPC_ENABLE_HCALL 104 763a9fd1654SJens Freimann #define KVM_CAP_CHECK_EXTENSION_VM 105 76451b24e34SJan Kiszka 76551b24e34SJan Kiszka #ifdef KVM_CAP_IRQ_ROUTING 76651b24e34SJan Kiszka 76751b24e34SJan Kiszka struct kvm_irq_routing_irqchip { 76851b24e34SJan Kiszka __u32 irqchip; 76951b24e34SJan Kiszka __u32 pin; 77051b24e34SJan Kiszka }; 77151b24e34SJan Kiszka 77251b24e34SJan Kiszka struct kvm_irq_routing_msi { 77351b24e34SJan Kiszka __u32 address_lo; 77451b24e34SJan Kiszka __u32 address_hi; 77551b24e34SJan Kiszka __u32 data; 77651b24e34SJan Kiszka __u32 pad; 77751b24e34SJan Kiszka }; 77851b24e34SJan Kiszka 7799ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter { 7809ffd2685SCornelia Huck __u64 ind_addr; 7819ffd2685SCornelia Huck __u64 summary_addr; 7829ffd2685SCornelia Huck __u64 ind_offset; 7839ffd2685SCornelia Huck __u32 summary_offset; 7849ffd2685SCornelia Huck __u32 adapter_id; 7859ffd2685SCornelia Huck }; 7869ffd2685SCornelia Huck 78751b24e34SJan Kiszka /* gsi routing entry types */ 78851b24e34SJan Kiszka #define KVM_IRQ_ROUTING_IRQCHIP 1 78951b24e34SJan Kiszka #define KVM_IRQ_ROUTING_MSI 2 7909ffd2685SCornelia Huck #define KVM_IRQ_ROUTING_S390_ADAPTER 3 79151b24e34SJan Kiszka 79251b24e34SJan Kiszka struct kvm_irq_routing_entry { 79351b24e34SJan Kiszka __u32 gsi; 79451b24e34SJan Kiszka __u32 type; 79551b24e34SJan Kiszka __u32 flags; 79651b24e34SJan Kiszka __u32 pad; 79751b24e34SJan Kiszka union { 79851b24e34SJan Kiszka struct kvm_irq_routing_irqchip irqchip; 79951b24e34SJan Kiszka struct kvm_irq_routing_msi msi; 8009ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter adapter; 80151b24e34SJan Kiszka __u32 pad[8]; 80251b24e34SJan Kiszka } u; 80351b24e34SJan Kiszka }; 80451b24e34SJan Kiszka 80551b24e34SJan Kiszka struct kvm_irq_routing { 80651b24e34SJan Kiszka __u32 nr; 80751b24e34SJan Kiszka __u32 flags; 80851b24e34SJan Kiszka struct kvm_irq_routing_entry entries[0]; 80951b24e34SJan Kiszka }; 81051b24e34SJan Kiszka 81151b24e34SJan Kiszka #endif 81251b24e34SJan Kiszka 81351b24e34SJan Kiszka #ifdef KVM_CAP_MCE 81451b24e34SJan Kiszka /* x86 MCE */ 81551b24e34SJan Kiszka struct kvm_x86_mce { 81651b24e34SJan Kiszka __u64 status; 81751b24e34SJan Kiszka __u64 addr; 81851b24e34SJan Kiszka __u64 misc; 81951b24e34SJan Kiszka __u64 mcg_status; 82051b24e34SJan Kiszka __u8 bank; 82151b24e34SJan Kiszka __u8 pad1[7]; 82251b24e34SJan Kiszka __u64 pad2[3]; 82351b24e34SJan Kiszka }; 82451b24e34SJan Kiszka #endif 82551b24e34SJan Kiszka 82651b24e34SJan Kiszka #ifdef KVM_CAP_XEN_HVM 82751b24e34SJan Kiszka struct kvm_xen_hvm_config { 82851b24e34SJan Kiszka __u32 flags; 82951b24e34SJan Kiszka __u32 msr; 83051b24e34SJan Kiszka __u64 blob_addr_32; 83151b24e34SJan Kiszka __u64 blob_addr_64; 83251b24e34SJan Kiszka __u8 blob_size_32; 83351b24e34SJan Kiszka __u8 blob_size_64; 83451b24e34SJan Kiszka __u8 pad2[30]; 83551b24e34SJan Kiszka }; 83651b24e34SJan Kiszka #endif 83751b24e34SJan Kiszka 83851b24e34SJan Kiszka #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0) 839716b8e4dSAlex Williamson /* 840716b8e4dSAlex Williamson * Available with KVM_CAP_IRQFD_RESAMPLE 841716b8e4dSAlex Williamson * 842716b8e4dSAlex Williamson * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies 843716b8e4dSAlex Williamson * the irqfd to operate in resampling mode for level triggered interrupt 844716b8e4dSAlex Williamson * emlation. See Documentation/virtual/kvm/api.txt. 845716b8e4dSAlex Williamson */ 846716b8e4dSAlex Williamson #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1) 84751b24e34SJan Kiszka 84851b24e34SJan Kiszka struct kvm_irqfd { 84951b24e34SJan Kiszka __u32 fd; 85051b24e34SJan Kiszka __u32 gsi; 85151b24e34SJan Kiszka __u32 flags; 852716b8e4dSAlex Williamson __u32 resamplefd; 853716b8e4dSAlex Williamson __u8 pad[16]; 85451b24e34SJan Kiszka }; 85551b24e34SJan Kiszka 85651b24e34SJan Kiszka struct kvm_clock_data { 85751b24e34SJan Kiszka __u64 clock; 85851b24e34SJan Kiszka __u32 flags; 85951b24e34SJan Kiszka __u32 pad[9]; 86051b24e34SJan Kiszka }; 86151b24e34SJan Kiszka 862a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_NOHV 0 863a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_HV 1 864a54fc080SAlexander Graf 865a54fc080SAlexander Graf struct kvm_config_tlb { 866a54fc080SAlexander Graf __u64 params; 867a54fc080SAlexander Graf __u64 array; 868a54fc080SAlexander Graf __u32 mmu_type; 869a54fc080SAlexander Graf __u32 array_len; 870a54fc080SAlexander Graf }; 871a54fc080SAlexander Graf 872a54fc080SAlexander Graf struct kvm_dirty_tlb { 873a54fc080SAlexander Graf __u64 bitmap; 874a54fc080SAlexander Graf __u32 num_dirty; 875a54fc080SAlexander Graf }; 876a54fc080SAlexander Graf 8779d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 8789d4e4f8cSAlexander Graf 879a31be480SAlexander Graf #define KVM_REG_ARCH_MASK 0xff00000000000000ULL 880a31be480SAlexander Graf #define KVM_REG_GENERIC 0x0000000000000000ULL 8819d4e4f8cSAlexander Graf 8829d4e4f8cSAlexander Graf /* 8839d4e4f8cSAlexander Graf * Architecture specific registers are to be defined in arch headers and 8849d4e4f8cSAlexander Graf * ORed with the arch identifier. 8859d4e4f8cSAlexander Graf */ 886a31be480SAlexander Graf #define KVM_REG_PPC 0x1000000000000000ULL 887a31be480SAlexander Graf #define KVM_REG_X86 0x2000000000000000ULL 888a31be480SAlexander Graf #define KVM_REG_IA64 0x3000000000000000ULL 889a31be480SAlexander Graf #define KVM_REG_ARM 0x4000000000000000ULL 890a31be480SAlexander Graf #define KVM_REG_S390 0x5000000000000000ULL 891c5daeae1SAlexey Kardashevskiy #define KVM_REG_ARM64 0x6000000000000000ULL 892c5daeae1SAlexey Kardashevskiy #define KVM_REG_MIPS 0x7000000000000000ULL 893a31be480SAlexander Graf 894a31be480SAlexander Graf #define KVM_REG_SIZE_SHIFT 52 895a31be480SAlexander Graf #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL 896a31be480SAlexander Graf #define KVM_REG_SIZE_U8 0x0000000000000000ULL 897a31be480SAlexander Graf #define KVM_REG_SIZE_U16 0x0010000000000000ULL 898a31be480SAlexander Graf #define KVM_REG_SIZE_U32 0x0020000000000000ULL 899a31be480SAlexander Graf #define KVM_REG_SIZE_U64 0x0030000000000000ULL 900a31be480SAlexander Graf #define KVM_REG_SIZE_U128 0x0040000000000000ULL 901a31be480SAlexander Graf #define KVM_REG_SIZE_U256 0x0050000000000000ULL 902a31be480SAlexander Graf #define KVM_REG_SIZE_U512 0x0060000000000000ULL 903a31be480SAlexander Graf #define KVM_REG_SIZE_U1024 0x0070000000000000ULL 9049d4e4f8cSAlexander Graf 905eadd0e44SPeter Maydell struct kvm_reg_list { 906eadd0e44SPeter Maydell __u64 n; /* number of regs */ 907eadd0e44SPeter Maydell __u64 reg[0]; 908eadd0e44SPeter Maydell }; 909eadd0e44SPeter Maydell 9109d4e4f8cSAlexander Graf struct kvm_one_reg { 9119d4e4f8cSAlexander Graf __u64 id; 912a31be480SAlexander Graf __u64 addr; 9139d4e4f8cSAlexander Graf }; 9149d4e4f8cSAlexander Graf 91580a3eb10SJan Kiszka struct kvm_msi { 91680a3eb10SJan Kiszka __u32 address_lo; 91780a3eb10SJan Kiszka __u32 address_hi; 91880a3eb10SJan Kiszka __u32 data; 91980a3eb10SJan Kiszka __u32 flags; 92080a3eb10SJan Kiszka __u8 pad[16]; 92180a3eb10SJan Kiszka }; 92280a3eb10SJan Kiszka 923eadd0e44SPeter Maydell struct kvm_arm_device_addr { 924eadd0e44SPeter Maydell __u64 id; 925eadd0e44SPeter Maydell __u64 addr; 926eadd0e44SPeter Maydell }; 927eadd0e44SPeter Maydell 92851b24e34SJan Kiszka /* 929e098b453SAlexey Kardashevskiy * Device control API, available with KVM_CAP_DEVICE_CTRL 930e098b453SAlexey Kardashevskiy */ 931e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE_TEST 1 932e098b453SAlexey Kardashevskiy 933e098b453SAlexey Kardashevskiy struct kvm_create_device { 934e098b453SAlexey Kardashevskiy __u32 type; /* in: KVM_DEV_TYPE_xxx */ 935e098b453SAlexey Kardashevskiy __u32 fd; /* out: device handle */ 936e098b453SAlexey Kardashevskiy __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */ 937e098b453SAlexey Kardashevskiy }; 938e098b453SAlexey Kardashevskiy 939e098b453SAlexey Kardashevskiy struct kvm_device_attr { 940e098b453SAlexey Kardashevskiy __u32 flags; /* no flags currently defined */ 941e098b453SAlexey Kardashevskiy __u32 group; /* device-defined */ 942e098b453SAlexey Kardashevskiy __u64 attr; /* group-defined */ 943e098b453SAlexey Kardashevskiy __u64 addr; /* userspace address of attr data */ 944e098b453SAlexey Kardashevskiy }; 945e098b453SAlexey Kardashevskiy 946bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP 1 947bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP_ADD 1 948bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP_DEL 2 949*444b1996SArd Biesheuvel 950*444b1996SArd Biesheuvel enum kvm_device_type { 951*444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_20 = 1, 952*444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_20 KVM_DEV_TYPE_FSL_MPIC_20 953*444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_42, 954*444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_42 KVM_DEV_TYPE_FSL_MPIC_42 955*444b1996SArd Biesheuvel KVM_DEV_TYPE_XICS, 956*444b1996SArd Biesheuvel #define KVM_DEV_TYPE_XICS KVM_DEV_TYPE_XICS 957*444b1996SArd Biesheuvel KVM_DEV_TYPE_VFIO, 958*444b1996SArd Biesheuvel #define KVM_DEV_TYPE_VFIO KVM_DEV_TYPE_VFIO 959*444b1996SArd Biesheuvel KVM_DEV_TYPE_ARM_VGIC_V2, 960*444b1996SArd Biesheuvel #define KVM_DEV_TYPE_ARM_VGIC_V2 KVM_DEV_TYPE_ARM_VGIC_V2 961*444b1996SArd Biesheuvel KVM_DEV_TYPE_FLIC, 962*444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_FLIC 963*444b1996SArd Biesheuvel KVM_DEV_TYPE_MAX, 964*444b1996SArd Biesheuvel }; 965e098b453SAlexey Kardashevskiy 966e098b453SAlexey Kardashevskiy /* 96751b24e34SJan Kiszka * ioctls for VM fds 96851b24e34SJan Kiszka */ 96951b24e34SJan Kiszka #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) 97051b24e34SJan Kiszka /* 97151b24e34SJan Kiszka * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns 97251b24e34SJan Kiszka * a vcpu fd. 97351b24e34SJan Kiszka */ 97451b24e34SJan Kiszka #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) 97551b24e34SJan Kiszka #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) 97651b24e34SJan Kiszka /* KVM_SET_MEMORY_ALIAS is obsolete: */ 97751b24e34SJan Kiszka #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) 97851b24e34SJan Kiszka #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) 97951b24e34SJan Kiszka #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) 98051b24e34SJan Kiszka #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ 98151b24e34SJan Kiszka struct kvm_userspace_memory_region) 98251b24e34SJan Kiszka #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) 98351b24e34SJan Kiszka #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64) 9841529ae1bSAlexander Graf 9851529ae1bSAlexander Graf /* enable ucontrol for s390 */ 9861529ae1bSAlexander Graf struct kvm_s390_ucas_mapping { 9871529ae1bSAlexander Graf __u64 user_addr; 9881529ae1bSAlexander Graf __u64 vcpu_addr; 9891529ae1bSAlexander Graf __u64 length; 9901529ae1bSAlexander Graf }; 9911529ae1bSAlexander Graf #define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping) 9921529ae1bSAlexander Graf #define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping) 9931529ae1bSAlexander Graf #define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long) 9941529ae1bSAlexander Graf 99551b24e34SJan Kiszka /* Device model IOC */ 99651b24e34SJan Kiszka #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) 99751b24e34SJan Kiszka #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) 99851b24e34SJan Kiszka #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) 99951b24e34SJan Kiszka #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) 100051b24e34SJan Kiszka #define KVM_CREATE_PIT _IO(KVMIO, 0x64) 100151b24e34SJan Kiszka #define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state) 100251b24e34SJan Kiszka #define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state) 100351b24e34SJan Kiszka #define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level) 100451b24e34SJan Kiszka #define KVM_REGISTER_COALESCED_MMIO \ 100551b24e34SJan Kiszka _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone) 100651b24e34SJan Kiszka #define KVM_UNREGISTER_COALESCED_MMIO \ 100751b24e34SJan Kiszka _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone) 100851b24e34SJan Kiszka #define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \ 100951b24e34SJan Kiszka struct kvm_assigned_pci_dev) 101051b24e34SJan Kiszka #define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing) 101151b24e34SJan Kiszka /* deprecated, replaced by KVM_ASSIGN_DEV_IRQ */ 101251b24e34SJan Kiszka #define KVM_ASSIGN_IRQ __KVM_DEPRECATED_VM_R_0x70 101351b24e34SJan Kiszka #define KVM_ASSIGN_DEV_IRQ _IOW(KVMIO, 0x70, struct kvm_assigned_irq) 101451b24e34SJan Kiszka #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71) 101551b24e34SJan Kiszka #define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, \ 101651b24e34SJan Kiszka struct kvm_assigned_pci_dev) 101751b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_NR _IOW(KVMIO, 0x73, \ 101851b24e34SJan Kiszka struct kvm_assigned_msix_nr) 101951b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO, 0x74, \ 102051b24e34SJan Kiszka struct kvm_assigned_msix_entry) 102151b24e34SJan Kiszka #define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq) 102251b24e34SJan Kiszka #define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd) 102351b24e34SJan Kiszka #define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config) 102451b24e34SJan Kiszka #define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78) 102551b24e34SJan Kiszka #define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd) 102651b24e34SJan Kiszka #define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config) 102751b24e34SJan Kiszka #define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data) 102851b24e34SJan Kiszka #define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data) 102951b24e34SJan Kiszka /* Available with KVM_CAP_PIT_STATE2 */ 103051b24e34SJan Kiszka #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) 103151b24e34SJan Kiszka #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) 103251b24e34SJan Kiszka /* Available with KVM_CAP_PPC_GET_PVINFO */ 103351b24e34SJan Kiszka #define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo) 103451b24e34SJan Kiszka /* Available with KVM_CAP_TSC_CONTROL */ 103551b24e34SJan Kiszka #define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2) 103651b24e34SJan Kiszka #define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3) 10379ab2195dSMarcelo Tosatti /* Available with KVM_CAP_PCI_2_3 */ 10389ab2195dSMarcelo Tosatti #define KVM_ASSIGN_SET_INTX_MASK _IOW(KVMIO, 0xa4, \ 10399ab2195dSMarcelo Tosatti struct kvm_assigned_pci_dev) 104080a3eb10SJan Kiszka /* Available with KVM_CAP_SIGNAL_MSI */ 104180a3eb10SJan Kiszka #define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi) 104280a3eb10SJan Kiszka /* Available with KVM_CAP_PPC_GET_SMMU_INFO */ 104380a3eb10SJan Kiszka #define KVM_PPC_GET_SMMU_INFO _IOR(KVMIO, 0xa6, struct kvm_ppc_smmu_info) 1044651682dcSMichael S. Tsirkin /* Available with KVM_CAP_PPC_ALLOC_HTAB */ 1045651682dcSMichael S. Tsirkin #define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32) 1046d4834ff9SAlexander Graf #define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce) 1047d4834ff9SAlexander Graf /* Available with KVM_CAP_RMA */ 1048d4834ff9SAlexander Graf #define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma) 1049d4834ff9SAlexander Graf /* Available with KVM_CAP_PPC_HTAB_FD */ 1050d4834ff9SAlexander Graf #define KVM_PPC_GET_HTAB_FD _IOW(KVMIO, 0xaa, struct kvm_get_htab_fd) 1051eadd0e44SPeter Maydell /* Available with KVM_CAP_ARM_SET_DEVICE_ADDR */ 1052eadd0e44SPeter Maydell #define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr) 1053e098b453SAlexey Kardashevskiy /* Available with KVM_CAP_PPC_RTAS */ 1054e098b453SAlexey Kardashevskiy #define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args) 1055e098b453SAlexey Kardashevskiy 1056e098b453SAlexey Kardashevskiy /* ioctl for vm fd */ 1057e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) 1058e098b453SAlexey Kardashevskiy 1059e098b453SAlexey Kardashevskiy /* ioctls for fds returned by KVM_CREATE_DEVICE */ 1060e098b453SAlexey Kardashevskiy #define KVM_SET_DEVICE_ATTR _IOW(KVMIO, 0xe1, struct kvm_device_attr) 1061e098b453SAlexey Kardashevskiy #define KVM_GET_DEVICE_ATTR _IOW(KVMIO, 0xe2, struct kvm_device_attr) 1062e098b453SAlexey Kardashevskiy #define KVM_HAS_DEVICE_ATTR _IOW(KVMIO, 0xe3, struct kvm_device_attr) 106351b24e34SJan Kiszka 106451b24e34SJan Kiszka /* 106551b24e34SJan Kiszka * ioctls for vcpu fds 106651b24e34SJan Kiszka */ 106751b24e34SJan Kiszka #define KVM_RUN _IO(KVMIO, 0x80) 106851b24e34SJan Kiszka #define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs) 106951b24e34SJan Kiszka #define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs) 107051b24e34SJan Kiszka #define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs) 107151b24e34SJan Kiszka #define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs) 107251b24e34SJan Kiszka #define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation) 107351b24e34SJan Kiszka #define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt) 107451b24e34SJan Kiszka /* KVM_DEBUG_GUEST is no longer supported, use KVM_SET_GUEST_DEBUG instead */ 107551b24e34SJan Kiszka #define KVM_DEBUG_GUEST __KVM_DEPRECATED_VCPU_W_0x87 107651b24e34SJan Kiszka #define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs) 107751b24e34SJan Kiszka #define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs) 107851b24e34SJan Kiszka #define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid) 107951b24e34SJan Kiszka #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask) 108051b24e34SJan Kiszka #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu) 108151b24e34SJan Kiszka #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) 108251b24e34SJan Kiszka #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) 108351b24e34SJan Kiszka #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) 108451b24e34SJan Kiszka #define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) 108551b24e34SJan Kiszka #define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2) 108651b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 108751b24e34SJan Kiszka #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl) 108851b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 108951b24e34SJan Kiszka #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) 109051b24e34SJan Kiszka /* valid for virtual machine (for floating interrupt)_and_ vcpu */ 109151b24e34SJan Kiszka #define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt) 109251b24e34SJan Kiszka /* store status for s390 */ 109351b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_NOADDR (-1ul) 109451b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_PREFIXED (-2ul) 109551b24e34SJan Kiszka #define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long) 109651b24e34SJan Kiszka /* initial ipl psw for s390 */ 109751b24e34SJan Kiszka #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw) 109851b24e34SJan Kiszka /* initial reset for s390 */ 109951b24e34SJan Kiszka #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) 110051b24e34SJan Kiszka #define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) 110151b24e34SJan Kiszka #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) 1102*444b1996SArd Biesheuvel /* Available with KVM_CAP_USER_NMI */ 110351b24e34SJan Kiszka #define KVM_NMI _IO(KVMIO, 0x9a) 110451b24e34SJan Kiszka /* Available with KVM_CAP_SET_GUEST_DEBUG */ 110551b24e34SJan Kiszka #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) 110651b24e34SJan Kiszka /* MCE for x86 */ 110751b24e34SJan Kiszka #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64) 110851b24e34SJan Kiszka #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64) 110951b24e34SJan Kiszka #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) 111051b24e34SJan Kiszka /* IA64 stack access */ 111151b24e34SJan Kiszka #define KVM_IA64_VCPU_GET_STACK _IOR(KVMIO, 0x9a, void *) 111251b24e34SJan Kiszka #define KVM_IA64_VCPU_SET_STACK _IOW(KVMIO, 0x9b, void *) 111351b24e34SJan Kiszka /* Available with KVM_CAP_VCPU_EVENTS */ 111451b24e34SJan Kiszka #define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events) 111551b24e34SJan Kiszka #define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events) 111651b24e34SJan Kiszka /* Available with KVM_CAP_DEBUGREGS */ 111751b24e34SJan Kiszka #define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs) 111851b24e34SJan Kiszka #define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs) 11199ffd2685SCornelia Huck /* 11209ffd2685SCornelia Huck * vcpu version available with KVM_ENABLE_CAP 11219ffd2685SCornelia Huck * vm version available with KVM_CAP_ENABLE_CAP_VM 11229ffd2685SCornelia Huck */ 112351b24e34SJan Kiszka #define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap) 112451b24e34SJan Kiszka /* Available with KVM_CAP_XSAVE */ 112551b24e34SJan Kiszka #define KVM_GET_XSAVE _IOR(KVMIO, 0xa4, struct kvm_xsave) 112651b24e34SJan Kiszka #define KVM_SET_XSAVE _IOW(KVMIO, 0xa5, struct kvm_xsave) 112751b24e34SJan Kiszka /* Available with KVM_CAP_XCRS */ 112851b24e34SJan Kiszka #define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs) 112951b24e34SJan Kiszka #define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs) 1130a54fc080SAlexander Graf /* Available with KVM_CAP_SW_TLB */ 1131a54fc080SAlexander Graf #define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb) 11329d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 1133a31be480SAlexander Graf #define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg) 11349d4e4f8cSAlexander Graf #define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg) 11359ab2195dSMarcelo Tosatti /* VM is being stopped by host */ 11369ab2195dSMarcelo Tosatti #define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad) 1137eadd0e44SPeter Maydell #define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init) 1138bf63839fSAlex Williamson #define KVM_ARM_PREFERRED_TARGET _IOR(KVMIO, 0xaf, struct kvm_vcpu_init) 1139eadd0e44SPeter Maydell #define KVM_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list) 114051b24e34SJan Kiszka 114151b24e34SJan Kiszka #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) 11429ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) 11439ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2) 114451b24e34SJan Kiszka 114551b24e34SJan Kiszka struct kvm_assigned_pci_dev { 114651b24e34SJan Kiszka __u32 assigned_dev_id; 114751b24e34SJan Kiszka __u32 busnr; 114851b24e34SJan Kiszka __u32 devfn; 114951b24e34SJan Kiszka __u32 flags; 115051b24e34SJan Kiszka __u32 segnr; 115151b24e34SJan Kiszka union { 115251b24e34SJan Kiszka __u32 reserved[11]; 115351b24e34SJan Kiszka }; 115451b24e34SJan Kiszka }; 115551b24e34SJan Kiszka 115651b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_INTX (1 << 0) 115751b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSI (1 << 1) 115851b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSIX (1 << 2) 115951b24e34SJan Kiszka 116051b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_INTX (1 << 8) 116151b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSI (1 << 9) 116251b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10) 116351b24e34SJan Kiszka 116451b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MASK 0x00ff 116551b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MASK 0xff00 116651b24e34SJan Kiszka 116751b24e34SJan Kiszka struct kvm_assigned_irq { 116851b24e34SJan Kiszka __u32 assigned_dev_id; 11697c6da3deSAlexander Graf __u32 host_irq; /* ignored (legacy field) */ 117051b24e34SJan Kiszka __u32 guest_irq; 117151b24e34SJan Kiszka __u32 flags; 117251b24e34SJan Kiszka union { 117351b24e34SJan Kiszka __u32 reserved[12]; 117451b24e34SJan Kiszka }; 117551b24e34SJan Kiszka }; 117651b24e34SJan Kiszka 117751b24e34SJan Kiszka struct kvm_assigned_msix_nr { 117851b24e34SJan Kiszka __u32 assigned_dev_id; 117951b24e34SJan Kiszka __u16 entry_nr; 118051b24e34SJan Kiszka __u16 padding; 118151b24e34SJan Kiszka }; 118251b24e34SJan Kiszka 118351b24e34SJan Kiszka #define KVM_MAX_MSIX_PER_DEV 256 118451b24e34SJan Kiszka struct kvm_assigned_msix_entry { 118551b24e34SJan Kiszka __u32 assigned_dev_id; 118651b24e34SJan Kiszka __u32 gsi; 118751b24e34SJan Kiszka __u16 entry; /* The index of entry in the MSI-X table */ 118851b24e34SJan Kiszka __u16 padding[3]; 118951b24e34SJan Kiszka }; 119051b24e34SJan Kiszka 119151b24e34SJan Kiszka #endif /* __LINUX_KVM_H */ 1192