1dd873966SEric Auger /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 251b24e34SJan Kiszka #ifndef __LINUX_KVM_H 351b24e34SJan Kiszka #define __LINUX_KVM_H 451b24e34SJan Kiszka 551b24e34SJan Kiszka /* 651b24e34SJan Kiszka * Userspace interface for /dev/kvm - kernel based virtual machine 751b24e34SJan Kiszka * 851b24e34SJan Kiszka * Note: you must update KVM_API_VERSION if you change this interface. 951b24e34SJan Kiszka */ 1051b24e34SJan Kiszka 1151b24e34SJan Kiszka #include <linux/types.h> 1251b24e34SJan Kiszka 1351b24e34SJan Kiszka #include <linux/ioctl.h> 1451b24e34SJan Kiszka #include <asm/kvm.h> 1551b24e34SJan Kiszka 1651b24e34SJan Kiszka #define KVM_API_VERSION 12 1751b24e34SJan Kiszka 1851b24e34SJan Kiszka /* *** Deprecated interfaces *** */ 1951b24e34SJan Kiszka 2051b24e34SJan Kiszka #define KVM_TRC_SHIFT 16 2151b24e34SJan Kiszka 2251b24e34SJan Kiszka #define KVM_TRC_ENTRYEXIT (1 << KVM_TRC_SHIFT) 2351b24e34SJan Kiszka #define KVM_TRC_HANDLER (1 << (KVM_TRC_SHIFT + 1)) 2451b24e34SJan Kiszka 2551b24e34SJan Kiszka #define KVM_TRC_VMENTRY (KVM_TRC_ENTRYEXIT + 0x01) 2651b24e34SJan Kiszka #define KVM_TRC_VMEXIT (KVM_TRC_ENTRYEXIT + 0x02) 2751b24e34SJan Kiszka #define KVM_TRC_PAGE_FAULT (KVM_TRC_HANDLER + 0x01) 2851b24e34SJan Kiszka 2951b24e34SJan Kiszka #define KVM_TRC_HEAD_SIZE 12 3051b24e34SJan Kiszka #define KVM_TRC_CYCLE_SIZE 8 3151b24e34SJan Kiszka #define KVM_TRC_EXTRA_MAX 7 3251b24e34SJan Kiszka 3351b24e34SJan Kiszka #define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02) 3451b24e34SJan Kiszka #define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03) 3551b24e34SJan Kiszka #define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04) 3651b24e34SJan Kiszka #define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05) 3751b24e34SJan Kiszka #define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06) 3851b24e34SJan Kiszka #define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07) 3951b24e34SJan Kiszka #define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08) 4051b24e34SJan Kiszka #define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09) 4151b24e34SJan Kiszka #define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A) 4251b24e34SJan Kiszka #define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B) 4351b24e34SJan Kiszka #define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C) 4451b24e34SJan Kiszka #define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D) 4551b24e34SJan Kiszka #define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E) 4651b24e34SJan Kiszka #define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F) 4751b24e34SJan Kiszka #define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10) 4851b24e34SJan Kiszka #define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11) 4951b24e34SJan Kiszka #define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12) 5051b24e34SJan Kiszka #define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13) 5151b24e34SJan Kiszka #define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14) 5251b24e34SJan Kiszka #define KVM_TRC_TDP_FAULT (KVM_TRC_HANDLER + 0x15) 5351b24e34SJan Kiszka #define KVM_TRC_GTLB_WRITE (KVM_TRC_HANDLER + 0x16) 5451b24e34SJan Kiszka #define KVM_TRC_STLB_WRITE (KVM_TRC_HANDLER + 0x17) 5551b24e34SJan Kiszka #define KVM_TRC_STLB_INVAL (KVM_TRC_HANDLER + 0x18) 5651b24e34SJan Kiszka #define KVM_TRC_PPC_INSTR (KVM_TRC_HANDLER + 0x19) 5751b24e34SJan Kiszka 5851b24e34SJan Kiszka struct kvm_user_trace_setup { 5951b24e34SJan Kiszka __u32 buf_size; 6051b24e34SJan Kiszka __u32 buf_nr; 6151b24e34SJan Kiszka }; 6251b24e34SJan Kiszka 6351b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_W_0x06 \ 6451b24e34SJan Kiszka _IOW(KVMIO, 0x06, struct kvm_user_trace_setup) 6551b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_0x07 _IO(KVMIO, 0x07) 6651b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_0x08 _IO(KVMIO, 0x08) 6751b24e34SJan Kiszka 6851b24e34SJan Kiszka #define __KVM_DEPRECATED_VM_R_0x70 _IOR(KVMIO, 0x70, struct kvm_assigned_irq) 6951b24e34SJan Kiszka 7051b24e34SJan Kiszka struct kvm_breakpoint { 7151b24e34SJan Kiszka __u32 enabled; 7251b24e34SJan Kiszka __u32 padding; 7351b24e34SJan Kiszka __u64 address; 7451b24e34SJan Kiszka }; 7551b24e34SJan Kiszka 7651b24e34SJan Kiszka struct kvm_debug_guest { 7751b24e34SJan Kiszka __u32 enabled; 7851b24e34SJan Kiszka __u32 pad; 7951b24e34SJan Kiszka struct kvm_breakpoint breakpoints[4]; 8051b24e34SJan Kiszka __u32 singlestep; 8151b24e34SJan Kiszka }; 8251b24e34SJan Kiszka 8351b24e34SJan Kiszka #define __KVM_DEPRECATED_VCPU_W_0x87 _IOW(KVMIO, 0x87, struct kvm_debug_guest) 8451b24e34SJan Kiszka 8551b24e34SJan Kiszka /* *** End of deprecated interfaces *** */ 8651b24e34SJan Kiszka 8751b24e34SJan Kiszka 8851b24e34SJan Kiszka /* for KVM_CREATE_MEMORY_REGION */ 8951b24e34SJan Kiszka struct kvm_memory_region { 9051b24e34SJan Kiszka __u32 slot; 9151b24e34SJan Kiszka __u32 flags; 9251b24e34SJan Kiszka __u64 guest_phys_addr; 9351b24e34SJan Kiszka __u64 memory_size; /* bytes */ 9451b24e34SJan Kiszka }; 9551b24e34SJan Kiszka 9651b24e34SJan Kiszka /* for KVM_SET_USER_MEMORY_REGION */ 9751b24e34SJan Kiszka struct kvm_userspace_memory_region { 9851b24e34SJan Kiszka __u32 slot; 9951b24e34SJan Kiszka __u32 flags; 10051b24e34SJan Kiszka __u64 guest_phys_addr; 10151b24e34SJan Kiszka __u64 memory_size; /* bytes */ 10251b24e34SJan Kiszka __u64 userspace_addr; /* start of the userspace allocated memory */ 10351b24e34SJan Kiszka }; 10451b24e34SJan Kiszka 105716b8e4dSAlex Williamson /* 106716b8e4dSAlex Williamson * The bit 0 ~ bit 15 of kvm_memory_region::flags are visible for userspace, 107716b8e4dSAlex Williamson * other bits are reserved for kvm internal use which are defined in 108716b8e4dSAlex Williamson * include/linux/kvm_host.h. 109716b8e4dSAlex Williamson */ 110716b8e4dSAlex Williamson #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) 111716b8e4dSAlex Williamson #define KVM_MEM_READONLY (1UL << 1) 11251b24e34SJan Kiszka 11351b24e34SJan Kiszka /* for KVM_IRQ_LINE */ 11451b24e34SJan Kiszka struct kvm_irq_level { 11551b24e34SJan Kiszka /* 11651b24e34SJan Kiszka * ACPI gsi notion of irq. 11751b24e34SJan Kiszka * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47.. 11851b24e34SJan Kiszka * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23.. 119f76b348eSCornelia Huck * For ARM: See Documentation/virt/kvm/api.rst 12051b24e34SJan Kiszka */ 12151b24e34SJan Kiszka union { 12251b24e34SJan Kiszka __u32 irq; 12351b24e34SJan Kiszka __s32 status; 12451b24e34SJan Kiszka }; 12551b24e34SJan Kiszka __u32 level; 12651b24e34SJan Kiszka }; 12751b24e34SJan Kiszka 12851b24e34SJan Kiszka 12951b24e34SJan Kiszka struct kvm_irqchip { 13051b24e34SJan Kiszka __u32 chip_id; 13151b24e34SJan Kiszka __u32 pad; 13251b24e34SJan Kiszka union { 13351b24e34SJan Kiszka char dummy[512]; /* reserving space */ 13451b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 13551b24e34SJan Kiszka struct kvm_pic_state pic; 13651b24e34SJan Kiszka #endif 13751b24e34SJan Kiszka #ifdef __KVM_HAVE_IOAPIC 13851b24e34SJan Kiszka struct kvm_ioapic_state ioapic; 13951b24e34SJan Kiszka #endif 14051b24e34SJan Kiszka } chip; 14151b24e34SJan Kiszka }; 14251b24e34SJan Kiszka 14351b24e34SJan Kiszka /* for KVM_CREATE_PIT2 */ 14451b24e34SJan Kiszka struct kvm_pit_config { 14551b24e34SJan Kiszka __u32 flags; 14651b24e34SJan Kiszka __u32 pad[15]; 14751b24e34SJan Kiszka }; 14851b24e34SJan Kiszka 14951b24e34SJan Kiszka #define KVM_PIT_SPEAKER_DUMMY 1 15051b24e34SJan Kiszka 1517a52ce8aSCornelia Huck struct kvm_s390_skeys { 1527a52ce8aSCornelia Huck __u64 start_gfn; 1537a52ce8aSCornelia Huck __u64 count; 1547a52ce8aSCornelia Huck __u64 skeydata_addr; 1557a52ce8aSCornelia Huck __u32 flags; 1567a52ce8aSCornelia Huck __u32 reserved[9]; 1577a52ce8aSCornelia Huck }; 158fff02bc0SPaolo Bonzini 1593272f0e2SChristian Borntraeger #define KVM_S390_CMMA_PEEK (1 << 0) 1603272f0e2SChristian Borntraeger 1613272f0e2SChristian Borntraeger /** 1623272f0e2SChristian Borntraeger * kvm_s390_cmma_log - Used for CMMA migration. 1633272f0e2SChristian Borntraeger * 1643272f0e2SChristian Borntraeger * Used both for input and output. 1653272f0e2SChristian Borntraeger * 1663272f0e2SChristian Borntraeger * @start_gfn: Guest page number to start from. 1673272f0e2SChristian Borntraeger * @count: Size of the result buffer. 1683272f0e2SChristian Borntraeger * @flags: Control operation mode via KVM_S390_CMMA_* flags 1693272f0e2SChristian Borntraeger * @remaining: Used with KVM_S390_GET_CMMA_BITS. Indicates how many dirty 1703272f0e2SChristian Borntraeger * pages are still remaining. 1713272f0e2SChristian Borntraeger * @mask: Used with KVM_S390_SET_CMMA_BITS. Bitmap of bits to actually set 1723272f0e2SChristian Borntraeger * in the PGSTE. 1733272f0e2SChristian Borntraeger * @values: Pointer to the values buffer. 1743272f0e2SChristian Borntraeger * 1753272f0e2SChristian Borntraeger * Used in KVM_S390_{G,S}ET_CMMA_BITS ioctls. 1763272f0e2SChristian Borntraeger */ 1773272f0e2SChristian Borntraeger struct kvm_s390_cmma_log { 1783272f0e2SChristian Borntraeger __u64 start_gfn; 1793272f0e2SChristian Borntraeger __u32 count; 1803272f0e2SChristian Borntraeger __u32 flags; 1813272f0e2SChristian Borntraeger union { 1823272f0e2SChristian Borntraeger __u64 remaining; 1833272f0e2SChristian Borntraeger __u64 mask; 1843272f0e2SChristian Borntraeger }; 1853272f0e2SChristian Borntraeger __u64 values; 1863272f0e2SChristian Borntraeger }; 1873272f0e2SChristian Borntraeger 188fff02bc0SPaolo Bonzini struct kvm_hyperv_exit { 189fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV_SYNIC 1 190b89485a5SPaolo Bonzini #define KVM_EXIT_HYPERV_HCALL 2 191f76b348eSCornelia Huck #define KVM_EXIT_HYPERV_SYNDBG 3 192fff02bc0SPaolo Bonzini __u32 type; 193f76b348eSCornelia Huck __u32 pad1; 194fff02bc0SPaolo Bonzini union { 195fff02bc0SPaolo Bonzini struct { 196fff02bc0SPaolo Bonzini __u32 msr; 197f76b348eSCornelia Huck __u32 pad2; 198fff02bc0SPaolo Bonzini __u64 control; 199fff02bc0SPaolo Bonzini __u64 evt_page; 200fff02bc0SPaolo Bonzini __u64 msg_page; 201fff02bc0SPaolo Bonzini } synic; 202b89485a5SPaolo Bonzini struct { 203b89485a5SPaolo Bonzini __u64 input; 204b89485a5SPaolo Bonzini __u64 result; 205b89485a5SPaolo Bonzini __u64 params[2]; 206b89485a5SPaolo Bonzini } hcall; 207f76b348eSCornelia Huck struct { 208f76b348eSCornelia Huck __u32 msr; 209f76b348eSCornelia Huck __u32 pad2; 210f76b348eSCornelia Huck __u64 control; 211f76b348eSCornelia Huck __u64 status; 212f76b348eSCornelia Huck __u64 send_page; 213f76b348eSCornelia Huck __u64 recv_page; 214f76b348eSCornelia Huck __u64 pending_page; 215f76b348eSCornelia Huck } syndbg; 216fff02bc0SPaolo Bonzini } u; 217fff02bc0SPaolo Bonzini }; 218fff02bc0SPaolo Bonzini 2197a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS_NONE 1 2207a52ce8aSCornelia Huck #define KVM_S390_SKEYS_MAX 1048576 2217a52ce8aSCornelia Huck 22251b24e34SJan Kiszka #define KVM_EXIT_UNKNOWN 0 22351b24e34SJan Kiszka #define KVM_EXIT_EXCEPTION 1 22451b24e34SJan Kiszka #define KVM_EXIT_IO 2 22551b24e34SJan Kiszka #define KVM_EXIT_HYPERCALL 3 22651b24e34SJan Kiszka #define KVM_EXIT_DEBUG 4 22751b24e34SJan Kiszka #define KVM_EXIT_HLT 5 22851b24e34SJan Kiszka #define KVM_EXIT_MMIO 6 22951b24e34SJan Kiszka #define KVM_EXIT_IRQ_WINDOW_OPEN 7 23051b24e34SJan Kiszka #define KVM_EXIT_SHUTDOWN 8 23151b24e34SJan Kiszka #define KVM_EXIT_FAIL_ENTRY 9 23251b24e34SJan Kiszka #define KVM_EXIT_INTR 10 23351b24e34SJan Kiszka #define KVM_EXIT_SET_TPR 11 23451b24e34SJan Kiszka #define KVM_EXIT_TPR_ACCESS 12 23551b24e34SJan Kiszka #define KVM_EXIT_S390_SIEIC 13 23651b24e34SJan Kiszka #define KVM_EXIT_S390_RESET 14 237a9fd1654SJens Freimann #define KVM_EXIT_DCR 15 /* deprecated */ 23851b24e34SJan Kiszka #define KVM_EXIT_NMI 16 23951b24e34SJan Kiszka #define KVM_EXIT_INTERNAL_ERROR 17 24051b24e34SJan Kiszka #define KVM_EXIT_OSI 18 2417c6da3deSAlexander Graf #define KVM_EXIT_PAPR_HCALL 19 2421529ae1bSAlexander Graf #define KVM_EXIT_S390_UCONTROL 20 243d4834ff9SAlexander Graf #define KVM_EXIT_WATCHDOG 21 244d3dccee1SAlexander Graf #define KVM_EXIT_S390_TSCH 22 245d3dccee1SAlexander Graf #define KVM_EXIT_EPR 23 246b061808dSAlexander Graf #define KVM_EXIT_SYSTEM_EVENT 24 2477a52ce8aSCornelia Huck #define KVM_EXIT_S390_STSI 25 2483a824b15SPaolo Bonzini #define KVM_EXIT_IOAPIC_EOI 26 249fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV 27 2502a886794SGreg Kurz #define KVM_EXIT_ARM_NISV 28 25151b24e34SJan Kiszka 25251b24e34SJan Kiszka /* For KVM_EXIT_INTERNAL_ERROR */ 253d4834ff9SAlexander Graf /* Emulate instruction failed. */ 25451b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_EMULATION 1 255d4834ff9SAlexander Graf /* Encounter unexpected simultaneous exceptions. */ 25651b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_SIMUL_EX 2 257d4834ff9SAlexander Graf /* Encounter unexpected vm-exit due to delivery event. */ 258d4834ff9SAlexander Graf #define KVM_INTERNAL_ERROR_DELIVERY_EV 3 259f363d039SEric Auger /* Encounter unexpected vm-exit reason */ 260f363d039SEric Auger #define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON 4 26151b24e34SJan Kiszka 26251b24e34SJan Kiszka /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ 26351b24e34SJan Kiszka struct kvm_run { 26451b24e34SJan Kiszka /* in */ 26551b24e34SJan Kiszka __u8 request_interrupt_window; 2663a5eb5b4SPaolo Bonzini __u8 immediate_exit; 2673a5eb5b4SPaolo Bonzini __u8 padding1[6]; 26851b24e34SJan Kiszka 26951b24e34SJan Kiszka /* out */ 27051b24e34SJan Kiszka __u32 exit_reason; 27151b24e34SJan Kiszka __u8 ready_for_interrupt_injection; 27251b24e34SJan Kiszka __u8 if_flag; 27324a31426SPaolo Bonzini __u16 flags; 27451b24e34SJan Kiszka 27551b24e34SJan Kiszka /* in (pre_kvm_run), out (post_kvm_run) */ 27651b24e34SJan Kiszka __u64 cr8; 27751b24e34SJan Kiszka __u64 apic_base; 27851b24e34SJan Kiszka 27951b24e34SJan Kiszka #ifdef __KVM_S390 28051b24e34SJan Kiszka /* the processor status word for s390 */ 28151b24e34SJan Kiszka __u64 psw_mask; /* psw upper half */ 28251b24e34SJan Kiszka __u64 psw_addr; /* psw lower half */ 28351b24e34SJan Kiszka #endif 28451b24e34SJan Kiszka union { 28551b24e34SJan Kiszka /* KVM_EXIT_UNKNOWN */ 28651b24e34SJan Kiszka struct { 28751b24e34SJan Kiszka __u64 hardware_exit_reason; 28851b24e34SJan Kiszka } hw; 28951b24e34SJan Kiszka /* KVM_EXIT_FAIL_ENTRY */ 29051b24e34SJan Kiszka struct { 29151b24e34SJan Kiszka __u64 hardware_entry_failure_reason; 292e6546342SJason Wang __u32 cpu; 29351b24e34SJan Kiszka } fail_entry; 29451b24e34SJan Kiszka /* KVM_EXIT_EXCEPTION */ 29551b24e34SJan Kiszka struct { 29651b24e34SJan Kiszka __u32 exception; 29751b24e34SJan Kiszka __u32 error_code; 29851b24e34SJan Kiszka } ex; 29951b24e34SJan Kiszka /* KVM_EXIT_IO */ 30051b24e34SJan Kiszka struct { 30151b24e34SJan Kiszka #define KVM_EXIT_IO_IN 0 30251b24e34SJan Kiszka #define KVM_EXIT_IO_OUT 1 30351b24e34SJan Kiszka __u8 direction; 30451b24e34SJan Kiszka __u8 size; /* bytes */ 30551b24e34SJan Kiszka __u16 port; 30651b24e34SJan Kiszka __u32 count; 30751b24e34SJan Kiszka __u64 data_offset; /* relative to kvm_run start */ 30851b24e34SJan Kiszka } io; 3093a824b15SPaolo Bonzini /* KVM_EXIT_DEBUG */ 31051b24e34SJan Kiszka struct { 31151b24e34SJan Kiszka struct kvm_debug_exit_arch arch; 31251b24e34SJan Kiszka } debug; 31351b24e34SJan Kiszka /* KVM_EXIT_MMIO */ 31451b24e34SJan Kiszka struct { 31551b24e34SJan Kiszka __u64 phys_addr; 31651b24e34SJan Kiszka __u8 data[8]; 31751b24e34SJan Kiszka __u32 len; 31851b24e34SJan Kiszka __u8 is_write; 31951b24e34SJan Kiszka } mmio; 32051b24e34SJan Kiszka /* KVM_EXIT_HYPERCALL */ 32151b24e34SJan Kiszka struct { 32251b24e34SJan Kiszka __u64 nr; 32351b24e34SJan Kiszka __u64 args[6]; 32451b24e34SJan Kiszka __u64 ret; 32551b24e34SJan Kiszka __u32 longmode; 32651b24e34SJan Kiszka __u32 pad; 32751b24e34SJan Kiszka } hypercall; 32851b24e34SJan Kiszka /* KVM_EXIT_TPR_ACCESS */ 32951b24e34SJan Kiszka struct { 33051b24e34SJan Kiszka __u64 rip; 33151b24e34SJan Kiszka __u32 is_write; 33251b24e34SJan Kiszka __u32 pad; 33351b24e34SJan Kiszka } tpr_access; 33451b24e34SJan Kiszka /* KVM_EXIT_S390_SIEIC */ 33551b24e34SJan Kiszka struct { 33651b24e34SJan Kiszka __u8 icptcode; 33751b24e34SJan Kiszka __u16 ipa; 33851b24e34SJan Kiszka __u32 ipb; 33951b24e34SJan Kiszka } s390_sieic; 34051b24e34SJan Kiszka /* KVM_EXIT_S390_RESET */ 34151b24e34SJan Kiszka #define KVM_S390_RESET_POR 1 34251b24e34SJan Kiszka #define KVM_S390_RESET_CLEAR 2 34351b24e34SJan Kiszka #define KVM_S390_RESET_SUBSYSTEM 4 34451b24e34SJan Kiszka #define KVM_S390_RESET_CPU_INIT 8 34551b24e34SJan Kiszka #define KVM_S390_RESET_IPL 16 34651b24e34SJan Kiszka __u64 s390_reset_flags; 3471529ae1bSAlexander Graf /* KVM_EXIT_S390_UCONTROL */ 3481529ae1bSAlexander Graf struct { 3491529ae1bSAlexander Graf __u64 trans_exc_code; 3501529ae1bSAlexander Graf __u32 pgm_code; 3511529ae1bSAlexander Graf } s390_ucontrol; 352a9fd1654SJens Freimann /* KVM_EXIT_DCR (deprecated) */ 35351b24e34SJan Kiszka struct { 35451b24e34SJan Kiszka __u32 dcrn; 35551b24e34SJan Kiszka __u32 data; 35651b24e34SJan Kiszka __u8 is_write; 35751b24e34SJan Kiszka } dcr; 3583a824b15SPaolo Bonzini /* KVM_EXIT_INTERNAL_ERROR */ 35951b24e34SJan Kiszka struct { 36051b24e34SJan Kiszka __u32 suberror; 36151b24e34SJan Kiszka /* Available with KVM_CAP_INTERNAL_ERROR_DATA: */ 36251b24e34SJan Kiszka __u32 ndata; 36351b24e34SJan Kiszka __u64 data[16]; 36451b24e34SJan Kiszka } internal; 36551b24e34SJan Kiszka /* KVM_EXIT_OSI */ 36651b24e34SJan Kiszka struct { 36751b24e34SJan Kiszka __u64 gprs[32]; 36851b24e34SJan Kiszka } osi; 3693a824b15SPaolo Bonzini /* KVM_EXIT_PAPR_HCALL */ 3707c6da3deSAlexander Graf struct { 3717c6da3deSAlexander Graf __u64 nr; 3727c6da3deSAlexander Graf __u64 ret; 3737c6da3deSAlexander Graf __u64 args[9]; 3747c6da3deSAlexander Graf } papr_hcall; 375d3dccee1SAlexander Graf /* KVM_EXIT_S390_TSCH */ 376d3dccee1SAlexander Graf struct { 377d3dccee1SAlexander Graf __u16 subchannel_id; 378d3dccee1SAlexander Graf __u16 subchannel_nr; 379d3dccee1SAlexander Graf __u32 io_int_parm; 380d3dccee1SAlexander Graf __u32 io_int_word; 381d3dccee1SAlexander Graf __u32 ipb; 382d3dccee1SAlexander Graf __u8 dequeued; 383d3dccee1SAlexander Graf } s390_tsch; 384d3dccee1SAlexander Graf /* KVM_EXIT_EPR */ 385d3dccee1SAlexander Graf struct { 386d3dccee1SAlexander Graf __u32 epr; 387d3dccee1SAlexander Graf } epr; 388b061808dSAlexander Graf /* KVM_EXIT_SYSTEM_EVENT */ 389b061808dSAlexander Graf struct { 390b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_SHUTDOWN 1 391b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_RESET 2 392120758fbSPaolo Bonzini #define KVM_SYSTEM_EVENT_CRASH 3 393b061808dSAlexander Graf __u32 type; 394b061808dSAlexander Graf __u64 flags; 395b061808dSAlexander Graf } system_event; 3967a52ce8aSCornelia Huck /* KVM_EXIT_S390_STSI */ 3977a52ce8aSCornelia Huck struct { 3987a52ce8aSCornelia Huck __u64 addr; 3997a52ce8aSCornelia Huck __u8 ar; 4007a52ce8aSCornelia Huck __u8 reserved; 4017a52ce8aSCornelia Huck __u8 fc; 4027a52ce8aSCornelia Huck __u8 sel1; 4037a52ce8aSCornelia Huck __u16 sel2; 4047a52ce8aSCornelia Huck } s390_stsi; 4053a824b15SPaolo Bonzini /* KVM_EXIT_IOAPIC_EOI */ 4063a824b15SPaolo Bonzini struct { 4073a824b15SPaolo Bonzini __u8 vector; 4083a824b15SPaolo Bonzini } eoi; 409fff02bc0SPaolo Bonzini /* KVM_EXIT_HYPERV */ 410fff02bc0SPaolo Bonzini struct kvm_hyperv_exit hyperv; 4112a886794SGreg Kurz /* KVM_EXIT_ARM_NISV */ 4122a886794SGreg Kurz struct { 4132a886794SGreg Kurz __u64 esr_iss; 4142a886794SGreg Kurz __u64 fault_ipa; 4152a886794SGreg Kurz } arm_nisv; 41651b24e34SJan Kiszka /* Fix the size of the union. */ 41751b24e34SJan Kiszka char padding[256]; 41851b24e34SJan Kiszka }; 4191529ae1bSAlexander Graf 42065a6d8ddSPeter Maydell /* 2048 is the size of the char array used to bound/pad the size 42165a6d8ddSPeter Maydell * of the union that holds sync regs. 42265a6d8ddSPeter Maydell */ 42365a6d8ddSPeter Maydell #define SYNC_REGS_SIZE_BYTES 2048 4241529ae1bSAlexander Graf /* 4251529ae1bSAlexander Graf * shared registers between kvm and userspace. 4261529ae1bSAlexander Graf * kvm_valid_regs specifies the register classes set by the host 4271529ae1bSAlexander Graf * kvm_dirty_regs specified the register classes dirtied by userspace 4281529ae1bSAlexander Graf * struct kvm_sync_regs is architecture specific, as well as the 4291529ae1bSAlexander Graf * bits for kvm_valid_regs and kvm_dirty_regs 4301529ae1bSAlexander Graf */ 4311529ae1bSAlexander Graf __u64 kvm_valid_regs; 4321529ae1bSAlexander Graf __u64 kvm_dirty_regs; 4331529ae1bSAlexander Graf union { 4341529ae1bSAlexander Graf struct kvm_sync_regs regs; 43565a6d8ddSPeter Maydell char padding[SYNC_REGS_SIZE_BYTES]; 4361529ae1bSAlexander Graf } s; 43751b24e34SJan Kiszka }; 43851b24e34SJan Kiszka 43951b24e34SJan Kiszka /* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */ 44051b24e34SJan Kiszka 44151b24e34SJan Kiszka struct kvm_coalesced_mmio_zone { 44251b24e34SJan Kiszka __u64 addr; 44351b24e34SJan Kiszka __u32 size; 444966f2ec3SPaolo Bonzini union { 44551b24e34SJan Kiszka __u32 pad; 446966f2ec3SPaolo Bonzini __u32 pio; 447966f2ec3SPaolo Bonzini }; 44851b24e34SJan Kiszka }; 44951b24e34SJan Kiszka 45051b24e34SJan Kiszka struct kvm_coalesced_mmio { 45151b24e34SJan Kiszka __u64 phys_addr; 45251b24e34SJan Kiszka __u32 len; 453966f2ec3SPaolo Bonzini union { 45451b24e34SJan Kiszka __u32 pad; 455966f2ec3SPaolo Bonzini __u32 pio; 456966f2ec3SPaolo Bonzini }; 45751b24e34SJan Kiszka __u8 data[8]; 45851b24e34SJan Kiszka }; 45951b24e34SJan Kiszka 46051b24e34SJan Kiszka struct kvm_coalesced_mmio_ring { 46151b24e34SJan Kiszka __u32 first, last; 46251b24e34SJan Kiszka struct kvm_coalesced_mmio coalesced_mmio[0]; 46351b24e34SJan Kiszka }; 46451b24e34SJan Kiszka 46551b24e34SJan Kiszka #define KVM_COALESCED_MMIO_MAX \ 46651b24e34SJan Kiszka ((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \ 46751b24e34SJan Kiszka sizeof(struct kvm_coalesced_mmio)) 46851b24e34SJan Kiszka 46951b24e34SJan Kiszka /* for KVM_TRANSLATE */ 47051b24e34SJan Kiszka struct kvm_translation { 47151b24e34SJan Kiszka /* in */ 47251b24e34SJan Kiszka __u64 linear_address; 47351b24e34SJan Kiszka 47451b24e34SJan Kiszka /* out */ 47551b24e34SJan Kiszka __u64 physical_address; 47651b24e34SJan Kiszka __u8 valid; 47751b24e34SJan Kiszka __u8 writeable; 47851b24e34SJan Kiszka __u8 usermode; 47951b24e34SJan Kiszka __u8 pad[5]; 48051b24e34SJan Kiszka }; 48151b24e34SJan Kiszka 4827a52ce8aSCornelia Huck /* for KVM_S390_MEM_OP */ 4837a52ce8aSCornelia Huck struct kvm_s390_mem_op { 4847a52ce8aSCornelia Huck /* in */ 4857a52ce8aSCornelia Huck __u64 gaddr; /* the guest address */ 4867a52ce8aSCornelia Huck __u64 flags; /* flags */ 4877a52ce8aSCornelia Huck __u32 size; /* amount of bytes */ 4887a52ce8aSCornelia Huck __u32 op; /* type of operation */ 4897a52ce8aSCornelia Huck __u64 buf; /* buffer in userspace */ 490dc6f8d45SCornelia Huck union { 4917a52ce8aSCornelia Huck __u8 ar; /* the access register number */ 492dc6f8d45SCornelia Huck __u32 sida_offset; /* offset into the sida */ 493dc6f8d45SCornelia Huck __u8 reserved[32]; /* should be set to 0 */ 494dc6f8d45SCornelia Huck }; 4957a52ce8aSCornelia Huck }; 4967a52ce8aSCornelia Huck /* types for kvm_s390_mem_op->op */ 4977a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_READ 0 4987a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_WRITE 1 499dc6f8d45SCornelia Huck #define KVM_S390_MEMOP_SIDA_READ 2 500dc6f8d45SCornelia Huck #define KVM_S390_MEMOP_SIDA_WRITE 3 5017a52ce8aSCornelia Huck /* flags for kvm_s390_mem_op->flags */ 5027a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0) 5037a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1) 5047a52ce8aSCornelia Huck 50551b24e34SJan Kiszka /* for KVM_INTERRUPT */ 50651b24e34SJan Kiszka struct kvm_interrupt { 50751b24e34SJan Kiszka /* in */ 50851b24e34SJan Kiszka __u32 irq; 50951b24e34SJan Kiszka }; 51051b24e34SJan Kiszka 51151b24e34SJan Kiszka /* for KVM_GET_DIRTY_LOG */ 51251b24e34SJan Kiszka struct kvm_dirty_log { 51351b24e34SJan Kiszka __u32 slot; 51451b24e34SJan Kiszka __u32 padding1; 51551b24e34SJan Kiszka union { 51651b24e34SJan Kiszka void *dirty_bitmap; /* one bit per page */ 51751b24e34SJan Kiszka __u64 padding2; 51851b24e34SJan Kiszka }; 51951b24e34SJan Kiszka }; 52051b24e34SJan Kiszka 521da054c64SPaolo Bonzini /* for KVM_CLEAR_DIRTY_LOG */ 522da054c64SPaolo Bonzini struct kvm_clear_dirty_log { 523da054c64SPaolo Bonzini __u32 slot; 524da054c64SPaolo Bonzini __u32 num_pages; 525da054c64SPaolo Bonzini __u64 first_page; 526da054c64SPaolo Bonzini union { 527da054c64SPaolo Bonzini void *dirty_bitmap; /* one bit per page */ 528da054c64SPaolo Bonzini __u64 padding2; 529da054c64SPaolo Bonzini }; 530da054c64SPaolo Bonzini }; 531da054c64SPaolo Bonzini 53251b24e34SJan Kiszka /* for KVM_SET_SIGNAL_MASK */ 53351b24e34SJan Kiszka struct kvm_signal_mask { 53451b24e34SJan Kiszka __u32 len; 53551b24e34SJan Kiszka __u8 sigset[0]; 53651b24e34SJan Kiszka }; 53751b24e34SJan Kiszka 53851b24e34SJan Kiszka /* for KVM_TPR_ACCESS_REPORTING */ 53951b24e34SJan Kiszka struct kvm_tpr_access_ctl { 54051b24e34SJan Kiszka __u32 enabled; 54151b24e34SJan Kiszka __u32 flags; 54251b24e34SJan Kiszka __u32 reserved[8]; 54351b24e34SJan Kiszka }; 54451b24e34SJan Kiszka 54551b24e34SJan Kiszka /* for KVM_SET_VAPIC_ADDR */ 54651b24e34SJan Kiszka struct kvm_vapic_addr { 54751b24e34SJan Kiszka __u64 vapic_addr; 54851b24e34SJan Kiszka }; 54951b24e34SJan Kiszka 550a9fd1654SJens Freimann /* for KVM_SET_MP_STATE */ 55151b24e34SJan Kiszka 552a9fd1654SJens Freimann /* not all states are valid on all architectures */ 55351b24e34SJan Kiszka #define KVM_MP_STATE_RUNNABLE 0 55451b24e34SJan Kiszka #define KVM_MP_STATE_UNINITIALIZED 1 55551b24e34SJan Kiszka #define KVM_MP_STATE_INIT_RECEIVED 2 55651b24e34SJan Kiszka #define KVM_MP_STATE_HALTED 3 55751b24e34SJan Kiszka #define KVM_MP_STATE_SIPI_RECEIVED 4 558a9fd1654SJens Freimann #define KVM_MP_STATE_STOPPED 5 559a9fd1654SJens Freimann #define KVM_MP_STATE_CHECK_STOP 6 560a9fd1654SJens Freimann #define KVM_MP_STATE_OPERATING 7 561a9fd1654SJens Freimann #define KVM_MP_STATE_LOAD 8 56251b24e34SJan Kiszka 56351b24e34SJan Kiszka struct kvm_mp_state { 56451b24e34SJan Kiszka __u32 mp_state; 56551b24e34SJan Kiszka }; 56651b24e34SJan Kiszka 56751b24e34SJan Kiszka struct kvm_s390_psw { 56851b24e34SJan Kiszka __u64 mask; 56951b24e34SJan Kiszka __u64 addr; 57051b24e34SJan Kiszka }; 57151b24e34SJan Kiszka 57251b24e34SJan Kiszka /* valid values for type in kvm_s390_interrupt */ 57351b24e34SJan Kiszka #define KVM_S390_SIGP_STOP 0xfffe0000u 57451b24e34SJan Kiszka #define KVM_S390_PROGRAM_INT 0xfffe0001u 57551b24e34SJan Kiszka #define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u 57651b24e34SJan Kiszka #define KVM_S390_RESTART 0xfffe0003u 577216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_INIT 0xfffe0004u 578216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_DONE 0xfffe0005u 579d3dccee1SAlexander Graf #define KVM_S390_MCHK 0xfffe1000u 58076eb98d5SJens Freimann #define KVM_S390_INT_CLOCK_COMP 0xffff1004u 58176eb98d5SJens Freimann #define KVM_S390_INT_CPU_TIMER 0xffff1005u 58251b24e34SJan Kiszka #define KVM_S390_INT_VIRTIO 0xffff2603u 58351b24e34SJan Kiszka #define KVM_S390_INT_SERVICE 0xffff2401u 58451b24e34SJan Kiszka #define KVM_S390_INT_EMERGENCY 0xffff1201u 5851529ae1bSAlexander Graf #define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u 586d3dccee1SAlexander Graf /* Anything below 0xfffe0000u is taken by INT_IO */ 587d3dccee1SAlexander Graf #define KVM_S390_INT_IO(ai,cssid,ssid,schid) \ 588d3dccee1SAlexander Graf (((schid)) | \ 589d3dccee1SAlexander Graf ((ssid) << 16) | \ 590d3dccee1SAlexander Graf ((cssid) << 18) | \ 591d3dccee1SAlexander Graf ((ai) << 26)) 592d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MIN 0x00000000u 593d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MAX 0xfffdffffu 594120758fbSPaolo Bonzini #define KVM_S390_INT_IO_AI_MASK 0x04000000u 595d3dccee1SAlexander Graf 59651b24e34SJan Kiszka 59751b24e34SJan Kiszka struct kvm_s390_interrupt { 59851b24e34SJan Kiszka __u32 type; 59951b24e34SJan Kiszka __u32 parm; 60051b24e34SJan Kiszka __u64 parm64; 60151b24e34SJan Kiszka }; 60251b24e34SJan Kiszka 603216db403SChristian Borntraeger struct kvm_s390_io_info { 604216db403SChristian Borntraeger __u16 subchannel_id; 605216db403SChristian Borntraeger __u16 subchannel_nr; 606216db403SChristian Borntraeger __u32 io_int_parm; 607216db403SChristian Borntraeger __u32 io_int_word; 608216db403SChristian Borntraeger }; 609216db403SChristian Borntraeger 610216db403SChristian Borntraeger struct kvm_s390_ext_info { 611216db403SChristian Borntraeger __u32 ext_params; 612216db403SChristian Borntraeger __u32 pad; 613216db403SChristian Borntraeger __u64 ext_params2; 614216db403SChristian Borntraeger }; 615216db403SChristian Borntraeger 616216db403SChristian Borntraeger struct kvm_s390_pgm_info { 617216db403SChristian Borntraeger __u64 trans_exc_code; 618216db403SChristian Borntraeger __u64 mon_code; 619216db403SChristian Borntraeger __u64 per_address; 620216db403SChristian Borntraeger __u32 data_exc_code; 621216db403SChristian Borntraeger __u16 code; 622216db403SChristian Borntraeger __u16 mon_class_nr; 623216db403SChristian Borntraeger __u8 per_code; 624216db403SChristian Borntraeger __u8 per_atmid; 625216db403SChristian Borntraeger __u8 exc_access_id; 626216db403SChristian Borntraeger __u8 per_access_id; 627216db403SChristian Borntraeger __u8 op_access_id; 62866fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_VALID 0x01 62966fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_0 0x02 63066fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_1 0x04 63166fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_MASK 0x06 63266fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_NO_REWIND 0x08 63366fb2d54SCornelia Huck __u8 flags; 63466fb2d54SCornelia Huck __u8 pad[2]; 635216db403SChristian Borntraeger }; 636216db403SChristian Borntraeger 637216db403SChristian Borntraeger struct kvm_s390_prefix_info { 638216db403SChristian Borntraeger __u32 address; 639216db403SChristian Borntraeger }; 640216db403SChristian Borntraeger 641216db403SChristian Borntraeger struct kvm_s390_extcall_info { 642216db403SChristian Borntraeger __u16 code; 643216db403SChristian Borntraeger }; 644216db403SChristian Borntraeger 645216db403SChristian Borntraeger struct kvm_s390_emerg_info { 646216db403SChristian Borntraeger __u16 code; 647216db403SChristian Borntraeger }; 648216db403SChristian Borntraeger 64951628b18SChristian Borntraeger #define KVM_S390_STOP_FLAG_STORE_STATUS 0x01 65051628b18SChristian Borntraeger struct kvm_s390_stop_info { 65151628b18SChristian Borntraeger __u32 flags; 65251628b18SChristian Borntraeger }; 65351628b18SChristian Borntraeger 654216db403SChristian Borntraeger struct kvm_s390_mchk_info { 655216db403SChristian Borntraeger __u64 cr14; 656216db403SChristian Borntraeger __u64 mcic; 657216db403SChristian Borntraeger __u64 failing_storage_address; 658216db403SChristian Borntraeger __u32 ext_damage_code; 659216db403SChristian Borntraeger __u32 pad; 660216db403SChristian Borntraeger __u8 fixed_logout[16]; 661216db403SChristian Borntraeger }; 662216db403SChristian Borntraeger 663216db403SChristian Borntraeger struct kvm_s390_irq { 664216db403SChristian Borntraeger __u64 type; 665216db403SChristian Borntraeger union { 666216db403SChristian Borntraeger struct kvm_s390_io_info io; 667216db403SChristian Borntraeger struct kvm_s390_ext_info ext; 668216db403SChristian Borntraeger struct kvm_s390_pgm_info pgm; 669216db403SChristian Borntraeger struct kvm_s390_emerg_info emerg; 670216db403SChristian Borntraeger struct kvm_s390_extcall_info extcall; 671216db403SChristian Borntraeger struct kvm_s390_prefix_info prefix; 67251628b18SChristian Borntraeger struct kvm_s390_stop_info stop; 673216db403SChristian Borntraeger struct kvm_s390_mchk_info mchk; 674216db403SChristian Borntraeger char reserved[64]; 675216db403SChristian Borntraeger } u; 676216db403SChristian Borntraeger }; 677216db403SChristian Borntraeger 6787a52ce8aSCornelia Huck struct kvm_s390_irq_state { 6797a52ce8aSCornelia Huck __u64 buf; 6809cbb6362SCornelia Huck __u32 flags; /* will stay unused for compatibility reasons */ 6817a52ce8aSCornelia Huck __u32 len; 6829cbb6362SCornelia Huck __u32 reserved[4]; /* will stay unused for compatibility reasons */ 6837a52ce8aSCornelia Huck }; 6847a52ce8aSCornelia Huck 68551b24e34SJan Kiszka /* for KVM_SET_GUEST_DEBUG */ 68651b24e34SJan Kiszka 68751b24e34SJan Kiszka #define KVM_GUESTDBG_ENABLE 0x00000001 68851b24e34SJan Kiszka #define KVM_GUESTDBG_SINGLESTEP 0x00000002 68951b24e34SJan Kiszka 69051b24e34SJan Kiszka struct kvm_guest_debug { 69151b24e34SJan Kiszka __u32 control; 69251b24e34SJan Kiszka __u32 pad; 69351b24e34SJan Kiszka struct kvm_guest_debug_arch arch; 69451b24e34SJan Kiszka }; 69551b24e34SJan Kiszka 69651b24e34SJan Kiszka enum { 69751b24e34SJan Kiszka kvm_ioeventfd_flag_nr_datamatch, 69851b24e34SJan Kiszka kvm_ioeventfd_flag_nr_pio, 69951b24e34SJan Kiszka kvm_ioeventfd_flag_nr_deassign, 700cae7f586SAlexander Graf kvm_ioeventfd_flag_nr_virtio_ccw_notify, 70176eb98d5SJens Freimann kvm_ioeventfd_flag_nr_fast_mmio, 70251b24e34SJan Kiszka kvm_ioeventfd_flag_nr_max, 70351b24e34SJan Kiszka }; 70451b24e34SJan Kiszka 70551b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) 70651b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) 70751b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) 708cae7f586SAlexander Graf #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ 709cae7f586SAlexander Graf (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify) 71051b24e34SJan Kiszka 71151b24e34SJan Kiszka #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1) 71251b24e34SJan Kiszka 71351b24e34SJan Kiszka struct kvm_ioeventfd { 71451b24e34SJan Kiszka __u64 datamatch; 71551b24e34SJan Kiszka __u64 addr; /* legal pio/mmio address */ 71676eb98d5SJens Freimann __u32 len; /* 1, 2, 4, or 8 bytes; or 0 to ignore length */ 71751b24e34SJan Kiszka __s32 fd; 71851b24e34SJan Kiszka __u32 flags; 71951b24e34SJan Kiszka __u8 pad[36]; 72051b24e34SJan Kiszka }; 72151b24e34SJan Kiszka 72265a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) 72377d361b1SEric Auger #define KVM_X86_DISABLE_EXITS_HLT (1 << 1) 72465a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) 725d38d201fSWanpeng Li #define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3) 72665a6d8ddSPeter Maydell #define KVM_X86_DISABLE_VALID_EXITS (KVM_X86_DISABLE_EXITS_MWAIT | \ 72777d361b1SEric Auger KVM_X86_DISABLE_EXITS_HLT | \ 728d38d201fSWanpeng Li KVM_X86_DISABLE_EXITS_PAUSE | \ 729d38d201fSWanpeng Li KVM_X86_DISABLE_EXITS_CSTATE) 73065a6d8ddSPeter Maydell 73151b24e34SJan Kiszka /* for KVM_ENABLE_CAP */ 73251b24e34SJan Kiszka struct kvm_enable_cap { 73351b24e34SJan Kiszka /* in */ 73451b24e34SJan Kiszka __u32 cap; 73551b24e34SJan Kiszka __u32 flags; 73651b24e34SJan Kiszka __u64 args[4]; 73751b24e34SJan Kiszka __u8 pad[64]; 73851b24e34SJan Kiszka }; 73951b24e34SJan Kiszka 74051b24e34SJan Kiszka /* for KVM_PPC_GET_PVINFO */ 7413a5eb5b4SPaolo Bonzini 7423a5eb5b4SPaolo Bonzini #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) 7433a5eb5b4SPaolo Bonzini 74451b24e34SJan Kiszka struct kvm_ppc_pvinfo { 74551b24e34SJan Kiszka /* out */ 74651b24e34SJan Kiszka __u32 flags; 74751b24e34SJan Kiszka __u32 hcall[4]; 74851b24e34SJan Kiszka __u8 pad[108]; 74951b24e34SJan Kiszka }; 75051b24e34SJan Kiszka 75180a3eb10SJan Kiszka /* for KVM_PPC_GET_SMMU_INFO */ 75280a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_MAX_SZ 8 75380a3eb10SJan Kiszka 75480a3eb10SJan Kiszka struct kvm_ppc_one_page_size { 75580a3eb10SJan Kiszka __u32 page_shift; /* Page shift (or 0) */ 75680a3eb10SJan Kiszka __u32 pte_enc; /* Encoding in the HPTE (>>12) */ 75780a3eb10SJan Kiszka }; 75880a3eb10SJan Kiszka 75980a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size { 76080a3eb10SJan Kiszka __u32 page_shift; /* Base page shift of segment (or 0) */ 76180a3eb10SJan Kiszka __u32 slb_enc; /* SLB encoding for BookS */ 76280a3eb10SJan Kiszka struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ]; 76380a3eb10SJan Kiszka }; 76480a3eb10SJan Kiszka 76580a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_REAL 0x00000001 76680a3eb10SJan Kiszka #define KVM_PPC_1T_SEGMENTS 0x00000002 767966f2ec3SPaolo Bonzini #define KVM_PPC_NO_HASH 0x00000004 76880a3eb10SJan Kiszka 76980a3eb10SJan Kiszka struct kvm_ppc_smmu_info { 77080a3eb10SJan Kiszka __u64 flags; 77180a3eb10SJan Kiszka __u32 slb_size; 772d4083f50SAlexey Perevalov __u16 data_keys; /* # storage keys supported for data */ 773d4083f50SAlexey Perevalov __u16 instr_keys; /* # storage keys supported for instructions */ 77480a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; 77580a3eb10SJan Kiszka }; 77680a3eb10SJan Kiszka 7773a5eb5b4SPaolo Bonzini /* for KVM_PPC_RESIZE_HPT_{PREPARE,COMMIT} */ 7783a5eb5b4SPaolo Bonzini struct kvm_ppc_resize_hpt { 7793a5eb5b4SPaolo Bonzini __u64 flags; 7803a5eb5b4SPaolo Bonzini __u32 shift; 7813a5eb5b4SPaolo Bonzini __u32 pad; 7823a5eb5b4SPaolo Bonzini }; 783d4834ff9SAlexander Graf 78451b24e34SJan Kiszka #define KVMIO 0xAE 78551b24e34SJan Kiszka 7861529ae1bSAlexander Graf /* machine type bits, to be used as argument to KVM_CREATE_VM */ 7871529ae1bSAlexander Graf #define KVM_VM_S390_UCONTROL 1 7881529ae1bSAlexander Graf 789bf63839fSAlex Williamson /* on ppc, 0 indicate default, 1 should force HV and 2 PR */ 790bf63839fSAlex Williamson #define KVM_VM_PPC_HV 1 791bf63839fSAlex Williamson #define KVM_VM_PPC_PR 2 792bf63839fSAlex Williamson 793*94c7fefcSAndrew Jones /* on MIPS, 0 indicates auto, 1 forces VZ ASE, 2 forces trap & emulate */ 794*94c7fefcSAndrew Jones #define KVM_VM_MIPS_AUTO 0 79574c98e20SCornelia Huck #define KVM_VM_MIPS_VZ 1 796*94c7fefcSAndrew Jones #define KVM_VM_MIPS_TE 2 79774c98e20SCornelia Huck 7981529ae1bSAlexander Graf #define KVM_S390_SIE_PAGE_OFFSET 1 7991529ae1bSAlexander Graf 80051b24e34SJan Kiszka /* 801da054c64SPaolo Bonzini * On arm64, machine type can be used to request the physical 802da054c64SPaolo Bonzini * address size for the VM. Bits[7-0] are reserved for the guest 803da054c64SPaolo Bonzini * PA size shift (i.e, log2(PA_Size)). For backward compatibility, 804da054c64SPaolo Bonzini * value 0 implies the default IPA size, 40bits. 805da054c64SPaolo Bonzini */ 806da054c64SPaolo Bonzini #define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL 807da054c64SPaolo Bonzini #define KVM_VM_TYPE_ARM_IPA_SIZE(x) \ 808da054c64SPaolo Bonzini ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK) 809da054c64SPaolo Bonzini /* 81051b24e34SJan Kiszka * ioctls for /dev/kvm fds: 81151b24e34SJan Kiszka */ 81251b24e34SJan Kiszka #define KVM_GET_API_VERSION _IO(KVMIO, 0x00) 81351b24e34SJan Kiszka #define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ 81451b24e34SJan Kiszka #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) 81551b24e34SJan Kiszka 81651b24e34SJan Kiszka #define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06) 81751b24e34SJan Kiszka /* 81851b24e34SJan Kiszka * Check if a kvm extension is available. Argument is extension number, 81951b24e34SJan Kiszka * return is 1 (yes) or 0 (no, sorry). 82051b24e34SJan Kiszka */ 82151b24e34SJan Kiszka #define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03) 82251b24e34SJan Kiszka /* 82351b24e34SJan Kiszka * Get size for mmap(vcpu_fd) 82451b24e34SJan Kiszka */ 82551b24e34SJan Kiszka #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ 82651b24e34SJan Kiszka #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) 82751b24e34SJan Kiszka #define KVM_TRACE_ENABLE __KVM_DEPRECATED_MAIN_W_0x06 82851b24e34SJan Kiszka #define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07 82951b24e34SJan Kiszka #define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08 830bf63839fSAlex Williamson #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) 8319f2d175dSPaolo Bonzini #define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_msr_list) 83251b24e34SJan Kiszka 83351b24e34SJan Kiszka /* 83451b24e34SJan Kiszka * Extension capability list. 83551b24e34SJan Kiszka */ 83651b24e34SJan Kiszka #define KVM_CAP_IRQCHIP 0 83751b24e34SJan Kiszka #define KVM_CAP_HLT 1 83851b24e34SJan Kiszka #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 83951b24e34SJan Kiszka #define KVM_CAP_USER_MEMORY 3 84051b24e34SJan Kiszka #define KVM_CAP_SET_TSS_ADDR 4 84151b24e34SJan Kiszka #define KVM_CAP_VAPIC 6 84251b24e34SJan Kiszka #define KVM_CAP_EXT_CPUID 7 84351b24e34SJan Kiszka #define KVM_CAP_CLOCKSOURCE 8 8447c6da3deSAlexander Graf #define KVM_CAP_NR_VCPUS 9 /* returns recommended max vcpus per vm */ 84551b24e34SJan Kiszka #define KVM_CAP_NR_MEMSLOTS 10 /* returns max memory slots per vm */ 84651b24e34SJan Kiszka #define KVM_CAP_PIT 11 84751b24e34SJan Kiszka #define KVM_CAP_NOP_IO_DELAY 12 84851b24e34SJan Kiszka #define KVM_CAP_PV_MMU 13 84951b24e34SJan Kiszka #define KVM_CAP_MP_STATE 14 85051b24e34SJan Kiszka #define KVM_CAP_COALESCED_MMIO 15 85151b24e34SJan Kiszka #define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ 85251b24e34SJan Kiszka #define KVM_CAP_IOMMU 18 85351b24e34SJan Kiszka /* Bug in KVM_SET_USER_MEMORY_REGION fixed: */ 85451b24e34SJan Kiszka #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21 85551b24e34SJan Kiszka #define KVM_CAP_USER_NMI 22 85651b24e34SJan Kiszka #ifdef __KVM_HAVE_GUEST_DEBUG 85751b24e34SJan Kiszka #define KVM_CAP_SET_GUEST_DEBUG 23 85851b24e34SJan Kiszka #endif 85951b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 86051b24e34SJan Kiszka #define KVM_CAP_REINJECT_CONTROL 24 86151b24e34SJan Kiszka #endif 86251b24e34SJan Kiszka #define KVM_CAP_IRQ_ROUTING 25 86351b24e34SJan Kiszka #define KVM_CAP_IRQ_INJECT_STATUS 26 86451b24e34SJan Kiszka #define KVM_CAP_ASSIGN_DEV_IRQ 29 86551b24e34SJan Kiszka /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ 86651b24e34SJan Kiszka #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 86751b24e34SJan Kiszka #ifdef __KVM_HAVE_MCE 86851b24e34SJan Kiszka #define KVM_CAP_MCE 31 86951b24e34SJan Kiszka #endif 87051b24e34SJan Kiszka #define KVM_CAP_IRQFD 32 87151b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 87251b24e34SJan Kiszka #define KVM_CAP_PIT2 33 87351b24e34SJan Kiszka #endif 87451b24e34SJan Kiszka #define KVM_CAP_SET_BOOT_CPU_ID 34 87551b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT_STATE2 87651b24e34SJan Kiszka #define KVM_CAP_PIT_STATE2 35 87751b24e34SJan Kiszka #endif 87851b24e34SJan Kiszka #define KVM_CAP_IOEVENTFD 36 87951b24e34SJan Kiszka #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 88051b24e34SJan Kiszka #ifdef __KVM_HAVE_XEN_HVM 88151b24e34SJan Kiszka #define KVM_CAP_XEN_HVM 38 88251b24e34SJan Kiszka #endif 88351b24e34SJan Kiszka #define KVM_CAP_ADJUST_CLOCK 39 88451b24e34SJan Kiszka #define KVM_CAP_INTERNAL_ERROR_DATA 40 88551b24e34SJan Kiszka #ifdef __KVM_HAVE_VCPU_EVENTS 88651b24e34SJan Kiszka #define KVM_CAP_VCPU_EVENTS 41 88751b24e34SJan Kiszka #endif 88851b24e34SJan Kiszka #define KVM_CAP_S390_PSW 42 88951b24e34SJan Kiszka #define KVM_CAP_PPC_SEGSTATE 43 89051b24e34SJan Kiszka #define KVM_CAP_HYPERV 44 89151b24e34SJan Kiszka #define KVM_CAP_HYPERV_VAPIC 45 89251b24e34SJan Kiszka #define KVM_CAP_HYPERV_SPIN 46 89351b24e34SJan Kiszka #define KVM_CAP_PCI_SEGMENT 47 89451b24e34SJan Kiszka #define KVM_CAP_PPC_PAIRED_SINGLES 48 89551b24e34SJan Kiszka #define KVM_CAP_INTR_SHADOW 49 89651b24e34SJan Kiszka #ifdef __KVM_HAVE_DEBUGREGS 89751b24e34SJan Kiszka #define KVM_CAP_DEBUGREGS 50 89851b24e34SJan Kiszka #endif 89951b24e34SJan Kiszka #define KVM_CAP_X86_ROBUST_SINGLESTEP 51 90051b24e34SJan Kiszka #define KVM_CAP_PPC_OSI 52 90151b24e34SJan Kiszka #define KVM_CAP_PPC_UNSET_IRQ 53 90251b24e34SJan Kiszka #define KVM_CAP_ENABLE_CAP 54 90351b24e34SJan Kiszka #ifdef __KVM_HAVE_XSAVE 90451b24e34SJan Kiszka #define KVM_CAP_XSAVE 55 90551b24e34SJan Kiszka #endif 90651b24e34SJan Kiszka #ifdef __KVM_HAVE_XCRS 90751b24e34SJan Kiszka #define KVM_CAP_XCRS 56 90851b24e34SJan Kiszka #endif 90951b24e34SJan Kiszka #define KVM_CAP_PPC_GET_PVINFO 57 91051b24e34SJan Kiszka #define KVM_CAP_PPC_IRQ_LEVEL 58 91151b24e34SJan Kiszka #define KVM_CAP_ASYNC_PF 59 91251b24e34SJan Kiszka #define KVM_CAP_TSC_CONTROL 60 91351b24e34SJan Kiszka #define KVM_CAP_GET_TSC_KHZ 61 91451b24e34SJan Kiszka #define KVM_CAP_PPC_BOOKE_SREGS 62 9157c6da3deSAlexander Graf #define KVM_CAP_SPAPR_TCE 63 9167c6da3deSAlexander Graf #define KVM_CAP_PPC_SMT 64 9177c6da3deSAlexander Graf #define KVM_CAP_PPC_RMA 65 9187c6da3deSAlexander Graf #define KVM_CAP_MAX_VCPUS 66 /* returns max vcpus per vm */ 9199d4e4f8cSAlexander Graf #define KVM_CAP_PPC_HIOR 67 9207c6da3deSAlexander Graf #define KVM_CAP_PPC_PAPR 68 921a54fc080SAlexander Graf #define KVM_CAP_SW_TLB 69 9229d4e4f8cSAlexander Graf #define KVM_CAP_ONE_REG 70 9231529ae1bSAlexander Graf #define KVM_CAP_S390_GMAP 71 9241529ae1bSAlexander Graf #define KVM_CAP_TSC_DEADLINE_TIMER 72 9251529ae1bSAlexander Graf #define KVM_CAP_S390_UCONTROL 73 9261529ae1bSAlexander Graf #define KVM_CAP_SYNC_REGS 74 9279ab2195dSMarcelo Tosatti #define KVM_CAP_PCI_2_3 75 9289ab2195dSMarcelo Tosatti #define KVM_CAP_KVMCLOCK_CTRL 76 92980a3eb10SJan Kiszka #define KVM_CAP_SIGNAL_MSI 77 93080a3eb10SJan Kiszka #define KVM_CAP_PPC_GET_SMMU_INFO 78 9312a60dba4SAlexander Graf #define KVM_CAP_S390_COW 79 932651682dcSMichael S. Tsirkin #define KVM_CAP_PPC_ALLOC_HTAB 80 933716b8e4dSAlex Williamson #define KVM_CAP_READONLY_MEM 81 934716b8e4dSAlex Williamson #define KVM_CAP_IRQFD_RESAMPLE 82 935d4834ff9SAlexander Graf #define KVM_CAP_PPC_BOOKE_WATCHDOG 83 936d4834ff9SAlexander Graf #define KVM_CAP_PPC_HTAB_FD 84 937d3dccee1SAlexander Graf #define KVM_CAP_S390_CSS_SUPPORT 85 938d3dccee1SAlexander Graf #define KVM_CAP_PPC_EPR 86 939eadd0e44SPeter Maydell #define KVM_CAP_ARM_PSCI 87 940eadd0e44SPeter Maydell #define KVM_CAP_ARM_SET_DEVICE_ADDR 88 941e098b453SAlexey Kardashevskiy #define KVM_CAP_DEVICE_CTRL 89 942e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_MPIC 90 943e098b453SAlexey Kardashevskiy #define KVM_CAP_PPC_RTAS 91 944e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_XICS 92 945c5daeae1SAlexey Kardashevskiy #define KVM_CAP_ARM_EL1_32BIT 93 9464f265607SAndrew Jones #define KVM_CAP_SPAPR_MULTITCE 94 947bf63839fSAlex Williamson #define KVM_CAP_EXT_EMUL_CPUID 95 94848a5f3bcSVadim Rozenfeld #define KVM_CAP_HYPERV_TIME 96 9499ffd2685SCornelia Huck #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97 9509ffd2685SCornelia Huck #define KVM_CAP_ENABLE_CAP_VM 98 9519ffd2685SCornelia Huck #define KVM_CAP_S390_IRQCHIP 99 95276eb98d5SJens Freimann #define KVM_CAP_IOEVENTFD_NO_LENGTH 100 95376eb98d5SJens Freimann #define KVM_CAP_VM_ATTRIBUTES 101 954b061808dSAlexander Graf #define KVM_CAP_ARM_PSCI_0_2 102 955b061808dSAlexander Graf #define KVM_CAP_PPC_FIXUP_HCALL 103 956a9fd1654SJens Freimann #define KVM_CAP_PPC_ENABLE_HCALL 104 957a9fd1654SJens Freimann #define KVM_CAP_CHECK_EXTENSION_VM 105 95851628b18SChristian Borntraeger #define KVM_CAP_S390_USER_SIGP 106 9597a52ce8aSCornelia Huck #define KVM_CAP_S390_VECTOR_REGISTERS 107 9607a52ce8aSCornelia Huck #define KVM_CAP_S390_MEM_OP 108 9617a52ce8aSCornelia Huck #define KVM_CAP_S390_USER_STSI 109 9627a52ce8aSCornelia Huck #define KVM_CAP_S390_SKEYS 110 9637a52ce8aSCornelia Huck #define KVM_CAP_MIPS_FPU 111 9647a52ce8aSCornelia Huck #define KVM_CAP_MIPS_MSA 112 9657a52ce8aSCornelia Huck #define KVM_CAP_S390_INJECT_IRQ 113 9667a52ce8aSCornelia Huck #define KVM_CAP_S390_IRQ_STATE 114 9677a52ce8aSCornelia Huck #define KVM_CAP_PPC_HWRNG 115 96824a31426SPaolo Bonzini #define KVM_CAP_DISABLE_QUIRKS 116 96924a31426SPaolo Bonzini #define KVM_CAP_X86_SMM 117 97024a31426SPaolo Bonzini #define KVM_CAP_MULTI_ADDRESS_SPACE 118 9713a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_BPS 119 9723a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_WPS 120 9733a824b15SPaolo Bonzini #define KVM_CAP_SPLIT_IRQCHIP 121 9743a824b15SPaolo Bonzini #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122 975fff02bc0SPaolo Bonzini #define KVM_CAP_HYPERV_SYNIC 123 97666fb2d54SCornelia Huck #define KVM_CAP_S390_RI 124 977b89485a5SPaolo Bonzini #define KVM_CAP_SPAPR_TCE_64 125 978b89485a5SPaolo Bonzini #define KVM_CAP_ARM_PMU_V3 126 979b89485a5SPaolo Bonzini #define KVM_CAP_VCPU_ATTRIBUTES 127 980ff804f15SCornelia Huck #define KVM_CAP_MAX_VCPU_ID 128 981dbdfea92SCornelia Huck #define KVM_CAP_X2APIC_API 129 982dbdfea92SCornelia Huck #define KVM_CAP_S390_USER_INSTR0 130 983dbdfea92SCornelia Huck #define KVM_CAP_MSI_DEVID 131 984dbdfea92SCornelia Huck #define KVM_CAP_PPC_HTM 132 9853a5eb5b4SPaolo Bonzini #define KVM_CAP_SPAPR_RESIZE_HPT 133 9863a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_RADIX 134 9873a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_HASH_V3 135 9883a5eb5b4SPaolo Bonzini #define KVM_CAP_IMMEDIATE_EXIT 136 98974c98e20SCornelia Huck #define KVM_CAP_MIPS_VZ 137 99074c98e20SCornelia Huck #define KVM_CAP_MIPS_TE 138 99174c98e20SCornelia Huck #define KVM_CAP_MIPS_64BIT 139 99274c98e20SCornelia Huck #define KVM_CAP_S390_GS 140 99374c98e20SCornelia Huck #define KVM_CAP_S390_AIS 141 99474c98e20SCornelia Huck #define KVM_CAP_SPAPR_TCE_VFIO 142 99565a6d8ddSPeter Maydell #define KVM_CAP_X86_DISABLE_EXITS 143 99674c98e20SCornelia Huck #define KVM_CAP_ARM_USER_IRQ 144 9973272f0e2SChristian Borntraeger #define KVM_CAP_S390_CMMA_MIGRATION 145 9983272f0e2SChristian Borntraeger #define KVM_CAP_PPC_FWNMI 146 9993272f0e2SChristian Borntraeger #define KVM_CAP_PPC_SMT_POSSIBLE 147 1000ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_SYNIC2 148 1001ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_VP_INDEX 149 1002dd873966SEric Auger #define KVM_CAP_S390_AIS_MIGRATION 150 10039cbb6362SCornelia Huck #define KVM_CAP_PPC_GET_CPU_CHAR 151 10049cbb6362SCornelia Huck #define KVM_CAP_S390_BPB 152 10059f2d175dSPaolo Bonzini #define KVM_CAP_GET_MSR_FEATURES 153 100665a6d8ddSPeter Maydell #define KVM_CAP_HYPERV_EVENTFD 154 100777d361b1SEric Auger #define KVM_CAP_HYPERV_TLBFLUSH 155 1008d36f7de8SCornelia Huck #define KVM_CAP_S390_HPAGE_1M 156 1009d36f7de8SCornelia Huck #define KVM_CAP_NESTED_STATE 157 10108f3cd250SCornelia Huck #define KVM_CAP_ARM_INJECT_SERROR_ESR 158 10118f3cd250SCornelia Huck #define KVM_CAP_MSR_PLATFORM_INFO 159 1012966f2ec3SPaolo Bonzini #define KVM_CAP_PPC_NESTED_HV 160 1013966f2ec3SPaolo Bonzini #define KVM_CAP_HYPERV_SEND_IPI 161 1014966f2ec3SPaolo Bonzini #define KVM_CAP_COALESCED_PIO 162 1015966f2ec3SPaolo Bonzini #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163 1016966f2ec3SPaolo Bonzini #define KVM_CAP_EXCEPTION_PAYLOAD 164 1017da054c64SPaolo Bonzini #define KVM_CAP_ARM_VM_IPA_SIZE 165 1018d9cb4336SCornelia Huck #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166 /* Obsolete */ 1019da054c64SPaolo Bonzini #define KVM_CAP_HYPERV_CPUID 167 1020d9cb4336SCornelia Huck #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 168 1021d9cb4336SCornelia Huck #define KVM_CAP_PPC_IRQ_XIVE 169 1022d9cb4336SCornelia Huck #define KVM_CAP_ARM_SVE 170 1023d9cb4336SCornelia Huck #define KVM_CAP_ARM_PTRAUTH_ADDRESS 171 1024d9cb4336SCornelia Huck #define KVM_CAP_ARM_PTRAUTH_GENERIC 172 1025f363d039SEric Auger #define KVM_CAP_PMU_EVENT_FILTER 173 1026f363d039SEric Auger #define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174 1027f363d039SEric Auger #define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175 10282a886794SGreg Kurz #define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 176 10292a886794SGreg Kurz #define KVM_CAP_ARM_NISV_TO_USER 177 10302a886794SGreg Kurz #define KVM_CAP_ARM_INJECT_EXT_DABT 178 1031ddda3748SCornelia Huck #define KVM_CAP_S390_VCPU_RESETS 179 1032dc6f8d45SCornelia Huck #define KVM_CAP_S390_PROTECTED 180 1033dc6f8d45SCornelia Huck #define KVM_CAP_PPC_SECURE_GUEST 181 1034f76b348eSCornelia Huck #define KVM_CAP_HALT_POLL 182 1035f76b348eSCornelia Huck #define KVM_CAP_ASYNC_PF_INT 183 1036e6546342SJason Wang #define KVM_CAP_LAST_CPU 184 1037e6546342SJason Wang #define KVM_CAP_SMALLER_MAXPHYADDR 185 1038e6546342SJason Wang #define KVM_CAP_S390_DIAG318 186 1039*94c7fefcSAndrew Jones #define KVM_CAP_STEAL_TIME 187 104051b24e34SJan Kiszka 104151b24e34SJan Kiszka #ifdef KVM_CAP_IRQ_ROUTING 104251b24e34SJan Kiszka 104351b24e34SJan Kiszka struct kvm_irq_routing_irqchip { 104451b24e34SJan Kiszka __u32 irqchip; 104551b24e34SJan Kiszka __u32 pin; 104651b24e34SJan Kiszka }; 104751b24e34SJan Kiszka 104851b24e34SJan Kiszka struct kvm_irq_routing_msi { 104951b24e34SJan Kiszka __u32 address_lo; 105051b24e34SJan Kiszka __u32 address_hi; 105151b24e34SJan Kiszka __u32 data; 1052dbdfea92SCornelia Huck union { 105351b24e34SJan Kiszka __u32 pad; 1054dbdfea92SCornelia Huck __u32 devid; 1055dbdfea92SCornelia Huck }; 105651b24e34SJan Kiszka }; 105751b24e34SJan Kiszka 10589ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter { 10599ffd2685SCornelia Huck __u64 ind_addr; 10609ffd2685SCornelia Huck __u64 summary_addr; 10619ffd2685SCornelia Huck __u64 ind_offset; 10629ffd2685SCornelia Huck __u32 summary_offset; 10639ffd2685SCornelia Huck __u32 adapter_id; 10649ffd2685SCornelia Huck }; 10659ffd2685SCornelia Huck 1066fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint { 1067fff02bc0SPaolo Bonzini __u32 vcpu; 1068fff02bc0SPaolo Bonzini __u32 sint; 1069fff02bc0SPaolo Bonzini }; 1070fff02bc0SPaolo Bonzini 107151b24e34SJan Kiszka /* gsi routing entry types */ 107251b24e34SJan Kiszka #define KVM_IRQ_ROUTING_IRQCHIP 1 107351b24e34SJan Kiszka #define KVM_IRQ_ROUTING_MSI 2 10749ffd2685SCornelia Huck #define KVM_IRQ_ROUTING_S390_ADAPTER 3 1075fff02bc0SPaolo Bonzini #define KVM_IRQ_ROUTING_HV_SINT 4 107651b24e34SJan Kiszka 107751b24e34SJan Kiszka struct kvm_irq_routing_entry { 107851b24e34SJan Kiszka __u32 gsi; 107951b24e34SJan Kiszka __u32 type; 108051b24e34SJan Kiszka __u32 flags; 108151b24e34SJan Kiszka __u32 pad; 108251b24e34SJan Kiszka union { 108351b24e34SJan Kiszka struct kvm_irq_routing_irqchip irqchip; 108451b24e34SJan Kiszka struct kvm_irq_routing_msi msi; 10859ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter adapter; 1086fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint hv_sint; 108751b24e34SJan Kiszka __u32 pad[8]; 108851b24e34SJan Kiszka } u; 108951b24e34SJan Kiszka }; 109051b24e34SJan Kiszka 109151b24e34SJan Kiszka struct kvm_irq_routing { 109251b24e34SJan Kiszka __u32 nr; 109351b24e34SJan Kiszka __u32 flags; 109451b24e34SJan Kiszka struct kvm_irq_routing_entry entries[0]; 109551b24e34SJan Kiszka }; 109651b24e34SJan Kiszka 109751b24e34SJan Kiszka #endif 109851b24e34SJan Kiszka 109951b24e34SJan Kiszka #ifdef KVM_CAP_MCE 110051b24e34SJan Kiszka /* x86 MCE */ 110151b24e34SJan Kiszka struct kvm_x86_mce { 110251b24e34SJan Kiszka __u64 status; 110351b24e34SJan Kiszka __u64 addr; 110451b24e34SJan Kiszka __u64 misc; 110551b24e34SJan Kiszka __u64 mcg_status; 110651b24e34SJan Kiszka __u8 bank; 110751b24e34SJan Kiszka __u8 pad1[7]; 110851b24e34SJan Kiszka __u64 pad2[3]; 110951b24e34SJan Kiszka }; 111051b24e34SJan Kiszka #endif 111151b24e34SJan Kiszka 111251b24e34SJan Kiszka #ifdef KVM_CAP_XEN_HVM 111351b24e34SJan Kiszka struct kvm_xen_hvm_config { 111451b24e34SJan Kiszka __u32 flags; 111551b24e34SJan Kiszka __u32 msr; 111651b24e34SJan Kiszka __u64 blob_addr_32; 111751b24e34SJan Kiszka __u64 blob_addr_64; 111851b24e34SJan Kiszka __u8 blob_size_32; 111951b24e34SJan Kiszka __u8 blob_size_64; 112051b24e34SJan Kiszka __u8 pad2[30]; 112151b24e34SJan Kiszka }; 112251b24e34SJan Kiszka #endif 112351b24e34SJan Kiszka 112451b24e34SJan Kiszka #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0) 1125716b8e4dSAlex Williamson /* 1126716b8e4dSAlex Williamson * Available with KVM_CAP_IRQFD_RESAMPLE 1127716b8e4dSAlex Williamson * 1128716b8e4dSAlex Williamson * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies 1129716b8e4dSAlex Williamson * the irqfd to operate in resampling mode for level triggered interrupt 1130f76b348eSCornelia Huck * emulation. See Documentation/virt/kvm/api.rst. 1131716b8e4dSAlex Williamson */ 1132716b8e4dSAlex Williamson #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1) 113351b24e34SJan Kiszka 113451b24e34SJan Kiszka struct kvm_irqfd { 113551b24e34SJan Kiszka __u32 fd; 113651b24e34SJan Kiszka __u32 gsi; 113751b24e34SJan Kiszka __u32 flags; 1138716b8e4dSAlex Williamson __u32 resamplefd; 1139716b8e4dSAlex Williamson __u8 pad[16]; 114051b24e34SJan Kiszka }; 114151b24e34SJan Kiszka 1142bc204035SMarcelo Tosatti /* For KVM_CAP_ADJUST_CLOCK */ 1143bc204035SMarcelo Tosatti 1144bc204035SMarcelo Tosatti /* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags. */ 1145bc204035SMarcelo Tosatti #define KVM_CLOCK_TSC_STABLE 2 1146bc204035SMarcelo Tosatti 114751b24e34SJan Kiszka struct kvm_clock_data { 114851b24e34SJan Kiszka __u64 clock; 114951b24e34SJan Kiszka __u32 flags; 115051b24e34SJan Kiszka __u32 pad[9]; 115151b24e34SJan Kiszka }; 115251b24e34SJan Kiszka 1153bc204035SMarcelo Tosatti /* For KVM_CAP_SW_TLB */ 1154bc204035SMarcelo Tosatti 1155a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_NOHV 0 1156a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_HV 1 1157a54fc080SAlexander Graf 1158a54fc080SAlexander Graf struct kvm_config_tlb { 1159a54fc080SAlexander Graf __u64 params; 1160a54fc080SAlexander Graf __u64 array; 1161a54fc080SAlexander Graf __u32 mmu_type; 1162a54fc080SAlexander Graf __u32 array_len; 1163a54fc080SAlexander Graf }; 1164a54fc080SAlexander Graf 1165a54fc080SAlexander Graf struct kvm_dirty_tlb { 1166a54fc080SAlexander Graf __u64 bitmap; 1167a54fc080SAlexander Graf __u32 num_dirty; 1168a54fc080SAlexander Graf }; 1169a54fc080SAlexander Graf 11709d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 11719d4e4f8cSAlexander Graf 1172a31be480SAlexander Graf #define KVM_REG_ARCH_MASK 0xff00000000000000ULL 1173a31be480SAlexander Graf #define KVM_REG_GENERIC 0x0000000000000000ULL 11749d4e4f8cSAlexander Graf 11759d4e4f8cSAlexander Graf /* 11769d4e4f8cSAlexander Graf * Architecture specific registers are to be defined in arch headers and 11779d4e4f8cSAlexander Graf * ORed with the arch identifier. 11789d4e4f8cSAlexander Graf */ 1179a31be480SAlexander Graf #define KVM_REG_PPC 0x1000000000000000ULL 1180a31be480SAlexander Graf #define KVM_REG_X86 0x2000000000000000ULL 1181a31be480SAlexander Graf #define KVM_REG_IA64 0x3000000000000000ULL 1182a31be480SAlexander Graf #define KVM_REG_ARM 0x4000000000000000ULL 1183a31be480SAlexander Graf #define KVM_REG_S390 0x5000000000000000ULL 1184c5daeae1SAlexey Kardashevskiy #define KVM_REG_ARM64 0x6000000000000000ULL 1185c5daeae1SAlexey Kardashevskiy #define KVM_REG_MIPS 0x7000000000000000ULL 1186f363d039SEric Auger #define KVM_REG_RISCV 0x8000000000000000ULL 1187a31be480SAlexander Graf 1188a31be480SAlexander Graf #define KVM_REG_SIZE_SHIFT 52 1189a31be480SAlexander Graf #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL 1190a31be480SAlexander Graf #define KVM_REG_SIZE_U8 0x0000000000000000ULL 1191a31be480SAlexander Graf #define KVM_REG_SIZE_U16 0x0010000000000000ULL 1192a31be480SAlexander Graf #define KVM_REG_SIZE_U32 0x0020000000000000ULL 1193a31be480SAlexander Graf #define KVM_REG_SIZE_U64 0x0030000000000000ULL 1194a31be480SAlexander Graf #define KVM_REG_SIZE_U128 0x0040000000000000ULL 1195a31be480SAlexander Graf #define KVM_REG_SIZE_U256 0x0050000000000000ULL 1196a31be480SAlexander Graf #define KVM_REG_SIZE_U512 0x0060000000000000ULL 1197a31be480SAlexander Graf #define KVM_REG_SIZE_U1024 0x0070000000000000ULL 1198d9cb4336SCornelia Huck #define KVM_REG_SIZE_U2048 0x0080000000000000ULL 11999d4e4f8cSAlexander Graf 1200eadd0e44SPeter Maydell struct kvm_reg_list { 1201eadd0e44SPeter Maydell __u64 n; /* number of regs */ 1202eadd0e44SPeter Maydell __u64 reg[0]; 1203eadd0e44SPeter Maydell }; 1204eadd0e44SPeter Maydell 12059d4e4f8cSAlexander Graf struct kvm_one_reg { 12069d4e4f8cSAlexander Graf __u64 id; 1207a31be480SAlexander Graf __u64 addr; 12089d4e4f8cSAlexander Graf }; 12099d4e4f8cSAlexander Graf 1210dbdfea92SCornelia Huck #define KVM_MSI_VALID_DEVID (1U << 0) 121180a3eb10SJan Kiszka struct kvm_msi { 121280a3eb10SJan Kiszka __u32 address_lo; 121380a3eb10SJan Kiszka __u32 address_hi; 121480a3eb10SJan Kiszka __u32 data; 121580a3eb10SJan Kiszka __u32 flags; 1216dbdfea92SCornelia Huck __u32 devid; 1217dbdfea92SCornelia Huck __u8 pad[12]; 121880a3eb10SJan Kiszka }; 121980a3eb10SJan Kiszka 1220eadd0e44SPeter Maydell struct kvm_arm_device_addr { 1221eadd0e44SPeter Maydell __u64 id; 1222eadd0e44SPeter Maydell __u64 addr; 1223eadd0e44SPeter Maydell }; 1224eadd0e44SPeter Maydell 122551b24e34SJan Kiszka /* 1226e098b453SAlexey Kardashevskiy * Device control API, available with KVM_CAP_DEVICE_CTRL 1227e098b453SAlexey Kardashevskiy */ 1228e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE_TEST 1 1229e098b453SAlexey Kardashevskiy 1230e098b453SAlexey Kardashevskiy struct kvm_create_device { 1231e098b453SAlexey Kardashevskiy __u32 type; /* in: KVM_DEV_TYPE_xxx */ 1232e098b453SAlexey Kardashevskiy __u32 fd; /* out: device handle */ 1233e098b453SAlexey Kardashevskiy __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */ 1234e098b453SAlexey Kardashevskiy }; 1235e098b453SAlexey Kardashevskiy 1236e098b453SAlexey Kardashevskiy struct kvm_device_attr { 1237e098b453SAlexey Kardashevskiy __u32 flags; /* no flags currently defined */ 1238e098b453SAlexey Kardashevskiy __u32 group; /* device-defined */ 1239e098b453SAlexey Kardashevskiy __u64 attr; /* group-defined */ 1240e098b453SAlexey Kardashevskiy __u64 addr; /* userspace address of attr data */ 1241e098b453SAlexey Kardashevskiy }; 1242e098b453SAlexey Kardashevskiy 1243bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP 1 1244bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP_ADD 1 1245bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP_DEL 2 124674c98e20SCornelia Huck #define KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE 3 1247444b1996SArd Biesheuvel 1248444b1996SArd Biesheuvel enum kvm_device_type { 1249444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_20 = 1, 1250444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_20 KVM_DEV_TYPE_FSL_MPIC_20 1251444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_42, 1252444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_42 KVM_DEV_TYPE_FSL_MPIC_42 1253444b1996SArd Biesheuvel KVM_DEV_TYPE_XICS, 1254444b1996SArd Biesheuvel #define KVM_DEV_TYPE_XICS KVM_DEV_TYPE_XICS 1255444b1996SArd Biesheuvel KVM_DEV_TYPE_VFIO, 1256444b1996SArd Biesheuvel #define KVM_DEV_TYPE_VFIO KVM_DEV_TYPE_VFIO 1257444b1996SArd Biesheuvel KVM_DEV_TYPE_ARM_VGIC_V2, 1258444b1996SArd Biesheuvel #define KVM_DEV_TYPE_ARM_VGIC_V2 KVM_DEV_TYPE_ARM_VGIC_V2 1259444b1996SArd Biesheuvel KVM_DEV_TYPE_FLIC, 1260444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_FLIC 126151628b18SChristian Borntraeger KVM_DEV_TYPE_ARM_VGIC_V3, 126251628b18SChristian Borntraeger #define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3 1263dbdfea92SCornelia Huck KVM_DEV_TYPE_ARM_VGIC_ITS, 1264dbdfea92SCornelia Huck #define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS 1265d9cb4336SCornelia Huck KVM_DEV_TYPE_XIVE, 1266d9cb4336SCornelia Huck #define KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_XIVE 12672a886794SGreg Kurz KVM_DEV_TYPE_ARM_PV_TIME, 12682a886794SGreg Kurz #define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME 1269444b1996SArd Biesheuvel KVM_DEV_TYPE_MAX, 1270444b1996SArd Biesheuvel }; 1271e098b453SAlexey Kardashevskiy 127274c98e20SCornelia Huck struct kvm_vfio_spapr_tce { 127374c98e20SCornelia Huck __s32 groupfd; 127474c98e20SCornelia Huck __s32 tablefd; 127574c98e20SCornelia Huck }; 127674c98e20SCornelia Huck 1277e098b453SAlexey Kardashevskiy /* 127851b24e34SJan Kiszka * ioctls for VM fds 127951b24e34SJan Kiszka */ 128051b24e34SJan Kiszka #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) 128151b24e34SJan Kiszka /* 128251b24e34SJan Kiszka * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns 128351b24e34SJan Kiszka * a vcpu fd. 128451b24e34SJan Kiszka */ 128551b24e34SJan Kiszka #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) 128651b24e34SJan Kiszka #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) 128751b24e34SJan Kiszka /* KVM_SET_MEMORY_ALIAS is obsolete: */ 128851b24e34SJan Kiszka #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) 128951b24e34SJan Kiszka #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) 129051b24e34SJan Kiszka #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) 129151b24e34SJan Kiszka #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ 129251b24e34SJan Kiszka struct kvm_userspace_memory_region) 129351b24e34SJan Kiszka #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) 129451b24e34SJan Kiszka #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64) 12951529ae1bSAlexander Graf 12961529ae1bSAlexander Graf /* enable ucontrol for s390 */ 12971529ae1bSAlexander Graf struct kvm_s390_ucas_mapping { 12981529ae1bSAlexander Graf __u64 user_addr; 12991529ae1bSAlexander Graf __u64 vcpu_addr; 13001529ae1bSAlexander Graf __u64 length; 13011529ae1bSAlexander Graf }; 13021529ae1bSAlexander Graf #define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping) 13031529ae1bSAlexander Graf #define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping) 13041529ae1bSAlexander Graf #define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long) 13051529ae1bSAlexander Graf 130651b24e34SJan Kiszka /* Device model IOC */ 130751b24e34SJan Kiszka #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) 130851b24e34SJan Kiszka #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) 130951b24e34SJan Kiszka #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) 131051b24e34SJan Kiszka #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) 131151b24e34SJan Kiszka #define KVM_CREATE_PIT _IO(KVMIO, 0x64) 131251b24e34SJan Kiszka #define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state) 131351b24e34SJan Kiszka #define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state) 131451b24e34SJan Kiszka #define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level) 131551b24e34SJan Kiszka #define KVM_REGISTER_COALESCED_MMIO \ 131651b24e34SJan Kiszka _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone) 131751b24e34SJan Kiszka #define KVM_UNREGISTER_COALESCED_MMIO \ 131851b24e34SJan Kiszka _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone) 131951b24e34SJan Kiszka #define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \ 132051b24e34SJan Kiszka struct kvm_assigned_pci_dev) 132151b24e34SJan Kiszka #define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing) 132251b24e34SJan Kiszka /* deprecated, replaced by KVM_ASSIGN_DEV_IRQ */ 132351b24e34SJan Kiszka #define KVM_ASSIGN_IRQ __KVM_DEPRECATED_VM_R_0x70 132451b24e34SJan Kiszka #define KVM_ASSIGN_DEV_IRQ _IOW(KVMIO, 0x70, struct kvm_assigned_irq) 132551b24e34SJan Kiszka #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71) 132651b24e34SJan Kiszka #define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, \ 132751b24e34SJan Kiszka struct kvm_assigned_pci_dev) 132851b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_NR _IOW(KVMIO, 0x73, \ 132951b24e34SJan Kiszka struct kvm_assigned_msix_nr) 133051b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO, 0x74, \ 133151b24e34SJan Kiszka struct kvm_assigned_msix_entry) 133251b24e34SJan Kiszka #define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq) 133351b24e34SJan Kiszka #define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd) 133451b24e34SJan Kiszka #define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config) 133551b24e34SJan Kiszka #define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78) 133651b24e34SJan Kiszka #define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd) 133751b24e34SJan Kiszka #define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config) 133851b24e34SJan Kiszka #define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data) 133951b24e34SJan Kiszka #define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data) 134051b24e34SJan Kiszka /* Available with KVM_CAP_PIT_STATE2 */ 134151b24e34SJan Kiszka #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) 134251b24e34SJan Kiszka #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) 134351b24e34SJan Kiszka /* Available with KVM_CAP_PPC_GET_PVINFO */ 134451b24e34SJan Kiszka #define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo) 134551b24e34SJan Kiszka /* Available with KVM_CAP_TSC_CONTROL */ 134651b24e34SJan Kiszka #define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2) 134751b24e34SJan Kiszka #define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3) 13489ab2195dSMarcelo Tosatti /* Available with KVM_CAP_PCI_2_3 */ 13499ab2195dSMarcelo Tosatti #define KVM_ASSIGN_SET_INTX_MASK _IOW(KVMIO, 0xa4, \ 13509ab2195dSMarcelo Tosatti struct kvm_assigned_pci_dev) 135180a3eb10SJan Kiszka /* Available with KVM_CAP_SIGNAL_MSI */ 135280a3eb10SJan Kiszka #define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi) 135380a3eb10SJan Kiszka /* Available with KVM_CAP_PPC_GET_SMMU_INFO */ 135480a3eb10SJan Kiszka #define KVM_PPC_GET_SMMU_INFO _IOR(KVMIO, 0xa6, struct kvm_ppc_smmu_info) 1355651682dcSMichael S. Tsirkin /* Available with KVM_CAP_PPC_ALLOC_HTAB */ 1356651682dcSMichael S. Tsirkin #define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32) 1357d4834ff9SAlexander Graf #define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce) 1358b89485a5SPaolo Bonzini #define KVM_CREATE_SPAPR_TCE_64 _IOW(KVMIO, 0xa8, \ 1359b89485a5SPaolo Bonzini struct kvm_create_spapr_tce_64) 1360d4834ff9SAlexander Graf /* Available with KVM_CAP_RMA */ 1361d4834ff9SAlexander Graf #define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma) 1362d4834ff9SAlexander Graf /* Available with KVM_CAP_PPC_HTAB_FD */ 1363d4834ff9SAlexander Graf #define KVM_PPC_GET_HTAB_FD _IOW(KVMIO, 0xaa, struct kvm_get_htab_fd) 1364eadd0e44SPeter Maydell /* Available with KVM_CAP_ARM_SET_DEVICE_ADDR */ 1365eadd0e44SPeter Maydell #define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr) 1366e098b453SAlexey Kardashevskiy /* Available with KVM_CAP_PPC_RTAS */ 1367e098b453SAlexey Kardashevskiy #define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args) 13683a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_SPAPR_RESIZE_HPT */ 13693a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt) 13703a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt) 13713a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */ 13723a5eb5b4SPaolo Bonzini #define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg) 13733a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_PPC_RADIX_MMU */ 13743a5eb5b4SPaolo Bonzini #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info) 13759cbb6362SCornelia Huck /* Available with KVM_CAP_PPC_GET_CPU_CHAR */ 13769cbb6362SCornelia Huck #define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char) 1377f363d039SEric Auger /* Available with KVM_CAP_PMU_EVENT_FILTER */ 1378f363d039SEric Auger #define KVM_SET_PMU_EVENT_FILTER _IOW(KVMIO, 0xb2, struct kvm_pmu_event_filter) 137950fd0c37SBharata B Rao #define KVM_PPC_SVM_OFF _IO(KVMIO, 0xb3) 1380e098b453SAlexey Kardashevskiy 1381e098b453SAlexey Kardashevskiy /* ioctl for vm fd */ 1382e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) 1383e098b453SAlexey Kardashevskiy 1384e098b453SAlexey Kardashevskiy /* ioctls for fds returned by KVM_CREATE_DEVICE */ 1385e098b453SAlexey Kardashevskiy #define KVM_SET_DEVICE_ATTR _IOW(KVMIO, 0xe1, struct kvm_device_attr) 1386e098b453SAlexey Kardashevskiy #define KVM_GET_DEVICE_ATTR _IOW(KVMIO, 0xe2, struct kvm_device_attr) 1387e098b453SAlexey Kardashevskiy #define KVM_HAS_DEVICE_ATTR _IOW(KVMIO, 0xe3, struct kvm_device_attr) 138851b24e34SJan Kiszka 138951b24e34SJan Kiszka /* 139051b24e34SJan Kiszka * ioctls for vcpu fds 139151b24e34SJan Kiszka */ 139251b24e34SJan Kiszka #define KVM_RUN _IO(KVMIO, 0x80) 139351b24e34SJan Kiszka #define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs) 139451b24e34SJan Kiszka #define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs) 139551b24e34SJan Kiszka #define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs) 139651b24e34SJan Kiszka #define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs) 139751b24e34SJan Kiszka #define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation) 139851b24e34SJan Kiszka #define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt) 139951b24e34SJan Kiszka /* KVM_DEBUG_GUEST is no longer supported, use KVM_SET_GUEST_DEBUG instead */ 140051b24e34SJan Kiszka #define KVM_DEBUG_GUEST __KVM_DEPRECATED_VCPU_W_0x87 140151b24e34SJan Kiszka #define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs) 140251b24e34SJan Kiszka #define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs) 140351b24e34SJan Kiszka #define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid) 140451b24e34SJan Kiszka #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask) 140551b24e34SJan Kiszka #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu) 140651b24e34SJan Kiszka #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) 140751b24e34SJan Kiszka #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) 140851b24e34SJan Kiszka #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) 140951b24e34SJan Kiszka #define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) 141051b24e34SJan Kiszka #define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2) 141151b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 141251b24e34SJan Kiszka #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl) 141351b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 141451b24e34SJan Kiszka #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) 141551b24e34SJan Kiszka /* valid for virtual machine (for floating interrupt)_and_ vcpu */ 141651b24e34SJan Kiszka #define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt) 141751b24e34SJan Kiszka /* store status for s390 */ 141851b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_NOADDR (-1ul) 141951b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_PREFIXED (-2ul) 142051b24e34SJan Kiszka #define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long) 142151b24e34SJan Kiszka /* initial ipl psw for s390 */ 142251b24e34SJan Kiszka #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw) 142351b24e34SJan Kiszka /* initial reset for s390 */ 142451b24e34SJan Kiszka #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) 142551b24e34SJan Kiszka #define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) 142651b24e34SJan Kiszka #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) 1427444b1996SArd Biesheuvel /* Available with KVM_CAP_USER_NMI */ 142851b24e34SJan Kiszka #define KVM_NMI _IO(KVMIO, 0x9a) 142951b24e34SJan Kiszka /* Available with KVM_CAP_SET_GUEST_DEBUG */ 143051b24e34SJan Kiszka #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) 143151b24e34SJan Kiszka /* MCE for x86 */ 143251b24e34SJan Kiszka #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64) 143351b24e34SJan Kiszka #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64) 143451b24e34SJan Kiszka #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) 143551b24e34SJan Kiszka /* Available with KVM_CAP_VCPU_EVENTS */ 143651b24e34SJan Kiszka #define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events) 143751b24e34SJan Kiszka #define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events) 143851b24e34SJan Kiszka /* Available with KVM_CAP_DEBUGREGS */ 143951b24e34SJan Kiszka #define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs) 144051b24e34SJan Kiszka #define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs) 14419ffd2685SCornelia Huck /* 14429ffd2685SCornelia Huck * vcpu version available with KVM_ENABLE_CAP 14439ffd2685SCornelia Huck * vm version available with KVM_CAP_ENABLE_CAP_VM 14449ffd2685SCornelia Huck */ 144551b24e34SJan Kiszka #define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap) 144651b24e34SJan Kiszka /* Available with KVM_CAP_XSAVE */ 144751b24e34SJan Kiszka #define KVM_GET_XSAVE _IOR(KVMIO, 0xa4, struct kvm_xsave) 144851b24e34SJan Kiszka #define KVM_SET_XSAVE _IOW(KVMIO, 0xa5, struct kvm_xsave) 144951b24e34SJan Kiszka /* Available with KVM_CAP_XCRS */ 145051b24e34SJan Kiszka #define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs) 145151b24e34SJan Kiszka #define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs) 1452a54fc080SAlexander Graf /* Available with KVM_CAP_SW_TLB */ 1453a54fc080SAlexander Graf #define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb) 14549d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 1455a31be480SAlexander Graf #define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg) 14569d4e4f8cSAlexander Graf #define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg) 14579ab2195dSMarcelo Tosatti /* VM is being stopped by host */ 14589ab2195dSMarcelo Tosatti #define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad) 1459eadd0e44SPeter Maydell #define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init) 1460bf63839fSAlex Williamson #define KVM_ARM_PREFERRED_TARGET _IOR(KVMIO, 0xaf, struct kvm_vcpu_init) 1461eadd0e44SPeter Maydell #define KVM_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list) 14627a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_MEM_OP */ 14637a52ce8aSCornelia Huck #define KVM_S390_MEM_OP _IOW(KVMIO, 0xb1, struct kvm_s390_mem_op) 14647a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_SKEYS */ 14657a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS _IOW(KVMIO, 0xb2, struct kvm_s390_skeys) 14667a52ce8aSCornelia Huck #define KVM_S390_SET_SKEYS _IOW(KVMIO, 0xb3, struct kvm_s390_skeys) 14677a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_INJECT_IRQ */ 14687a52ce8aSCornelia Huck #define KVM_S390_IRQ _IOW(KVMIO, 0xb4, struct kvm_s390_irq) 14697a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_IRQ_STATE */ 14707a52ce8aSCornelia Huck #define KVM_S390_SET_IRQ_STATE _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state) 14717a52ce8aSCornelia Huck #define KVM_S390_GET_IRQ_STATE _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state) 147224a31426SPaolo Bonzini /* Available with KVM_CAP_X86_SMM */ 147324a31426SPaolo Bonzini #define KVM_SMI _IO(KVMIO, 0xb7) 14743272f0e2SChristian Borntraeger /* Available with KVM_CAP_S390_CMMA_MIGRATION */ 1475ab6e1550SChristian Borntraeger #define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log) 14763272f0e2SChristian Borntraeger #define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log) 14779f2d175dSPaolo Bonzini /* Memory Encryption Commands */ 14789f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_OP _IOWR(KVMIO, 0xba, unsigned long) 14799f2d175dSPaolo Bonzini 14809f2d175dSPaolo Bonzini struct kvm_enc_region { 14819f2d175dSPaolo Bonzini __u64 addr; 14829f2d175dSPaolo Bonzini __u64 size; 14839f2d175dSPaolo Bonzini }; 14849f2d175dSPaolo Bonzini 14859f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_REG_REGION _IOR(KVMIO, 0xbb, struct kvm_enc_region) 14869f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_UNREG_REGION _IOR(KVMIO, 0xbc, struct kvm_enc_region) 14879f2d175dSPaolo Bonzini 148865a6d8ddSPeter Maydell /* Available with KVM_CAP_HYPERV_EVENTFD */ 148965a6d8ddSPeter Maydell #define KVM_HYPERV_EVENTFD _IOW(KVMIO, 0xbd, struct kvm_hyperv_eventfd) 149065a6d8ddSPeter Maydell 1491d36f7de8SCornelia Huck /* Available with KVM_CAP_NESTED_STATE */ 1492d36f7de8SCornelia Huck #define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state) 1493d36f7de8SCornelia Huck #define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state) 149465a6d8ddSPeter Maydell 1495d9cb4336SCornelia Huck /* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT_2 */ 1496da054c64SPaolo Bonzini #define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log) 1497da054c64SPaolo Bonzini 1498da054c64SPaolo Bonzini /* Available with KVM_CAP_HYPERV_CPUID */ 1499da054c64SPaolo Bonzini #define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2) 1500da054c64SPaolo Bonzini 1501d9cb4336SCornelia Huck /* Available with KVM_CAP_ARM_SVE */ 1502d9cb4336SCornelia Huck #define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int) 1503d9cb4336SCornelia Huck 1504ddda3748SCornelia Huck /* Available with KVM_CAP_S390_VCPU_RESETS */ 1505ddda3748SCornelia Huck #define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3) 1506ddda3748SCornelia Huck #define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4) 1507ddda3748SCornelia Huck 1508dc6f8d45SCornelia Huck struct kvm_s390_pv_sec_parm { 1509dc6f8d45SCornelia Huck __u64 origin; 1510dc6f8d45SCornelia Huck __u64 length; 1511dc6f8d45SCornelia Huck }; 1512dc6f8d45SCornelia Huck 1513dc6f8d45SCornelia Huck struct kvm_s390_pv_unp { 1514dc6f8d45SCornelia Huck __u64 addr; 1515dc6f8d45SCornelia Huck __u64 size; 1516dc6f8d45SCornelia Huck __u64 tweak; 1517dc6f8d45SCornelia Huck }; 1518dc6f8d45SCornelia Huck 1519dc6f8d45SCornelia Huck enum pv_cmd_id { 1520dc6f8d45SCornelia Huck KVM_PV_ENABLE, 1521dc6f8d45SCornelia Huck KVM_PV_DISABLE, 1522dc6f8d45SCornelia Huck KVM_PV_SET_SEC_PARMS, 1523dc6f8d45SCornelia Huck KVM_PV_UNPACK, 1524dc6f8d45SCornelia Huck KVM_PV_VERIFY, 1525dc6f8d45SCornelia Huck KVM_PV_PREP_RESET, 1526dc6f8d45SCornelia Huck KVM_PV_UNSHARE_ALL, 1527dc6f8d45SCornelia Huck }; 1528dc6f8d45SCornelia Huck 1529dc6f8d45SCornelia Huck struct kvm_pv_cmd { 1530dc6f8d45SCornelia Huck __u32 cmd; /* Command to be executed */ 1531dc6f8d45SCornelia Huck __u16 rc; /* Ultravisor return code */ 1532dc6f8d45SCornelia Huck __u16 rrc; /* Ultravisor return reason code */ 1533dc6f8d45SCornelia Huck __u64 data; /* Data or address */ 1534dc6f8d45SCornelia Huck __u32 flags; /* flags for future extensions. Must be 0 for now */ 1535dc6f8d45SCornelia Huck __u32 reserved[3]; 1536dc6f8d45SCornelia Huck }; 1537dc6f8d45SCornelia Huck 1538dc6f8d45SCornelia Huck /* Available with KVM_CAP_S390_PROTECTED */ 1539dc6f8d45SCornelia Huck #define KVM_S390_PV_COMMAND _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd) 1540dc6f8d45SCornelia Huck 15419f2d175dSPaolo Bonzini /* Secure Encrypted Virtualization command */ 15429f2d175dSPaolo Bonzini enum sev_cmd_id { 15439f2d175dSPaolo Bonzini /* Guest initialization commands */ 15449f2d175dSPaolo Bonzini KVM_SEV_INIT = 0, 15459f2d175dSPaolo Bonzini KVM_SEV_ES_INIT, 15469f2d175dSPaolo Bonzini /* Guest launch commands */ 15479f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_START, 15489f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_UPDATE_DATA, 15499f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_UPDATE_VMSA, 15509f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_SECRET, 15519f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_MEASURE, 15529f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_FINISH, 15539f2d175dSPaolo Bonzini /* Guest migration commands (outgoing) */ 15549f2d175dSPaolo Bonzini KVM_SEV_SEND_START, 15559f2d175dSPaolo Bonzini KVM_SEV_SEND_UPDATE_DATA, 15569f2d175dSPaolo Bonzini KVM_SEV_SEND_UPDATE_VMSA, 15579f2d175dSPaolo Bonzini KVM_SEV_SEND_FINISH, 15589f2d175dSPaolo Bonzini /* Guest migration commands (incoming) */ 15599f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_START, 15609f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_UPDATE_DATA, 15619f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_UPDATE_VMSA, 15629f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_FINISH, 15639f2d175dSPaolo Bonzini /* Guest status and debug commands */ 15649f2d175dSPaolo Bonzini KVM_SEV_GUEST_STATUS, 15659f2d175dSPaolo Bonzini KVM_SEV_DBG_DECRYPT, 15669f2d175dSPaolo Bonzini KVM_SEV_DBG_ENCRYPT, 15679f2d175dSPaolo Bonzini /* Guest certificates commands */ 15689f2d175dSPaolo Bonzini KVM_SEV_CERT_EXPORT, 15699f2d175dSPaolo Bonzini 15709f2d175dSPaolo Bonzini KVM_SEV_NR_MAX, 15719f2d175dSPaolo Bonzini }; 15729f2d175dSPaolo Bonzini 15739f2d175dSPaolo Bonzini struct kvm_sev_cmd { 15749f2d175dSPaolo Bonzini __u32 id; 15759f2d175dSPaolo Bonzini __u64 data; 15769f2d175dSPaolo Bonzini __u32 error; 15779f2d175dSPaolo Bonzini __u32 sev_fd; 15789f2d175dSPaolo Bonzini }; 15799f2d175dSPaolo Bonzini 15809f2d175dSPaolo Bonzini struct kvm_sev_launch_start { 15819f2d175dSPaolo Bonzini __u32 handle; 15829f2d175dSPaolo Bonzini __u32 policy; 15839f2d175dSPaolo Bonzini __u64 dh_uaddr; 15849f2d175dSPaolo Bonzini __u32 dh_len; 15859f2d175dSPaolo Bonzini __u64 session_uaddr; 15869f2d175dSPaolo Bonzini __u32 session_len; 15879f2d175dSPaolo Bonzini }; 15889f2d175dSPaolo Bonzini 15899f2d175dSPaolo Bonzini struct kvm_sev_launch_update_data { 15909f2d175dSPaolo Bonzini __u64 uaddr; 15919f2d175dSPaolo Bonzini __u32 len; 15929f2d175dSPaolo Bonzini }; 15939f2d175dSPaolo Bonzini 15949f2d175dSPaolo Bonzini 15959f2d175dSPaolo Bonzini struct kvm_sev_launch_secret { 15969f2d175dSPaolo Bonzini __u64 hdr_uaddr; 15979f2d175dSPaolo Bonzini __u32 hdr_len; 15989f2d175dSPaolo Bonzini __u64 guest_uaddr; 15999f2d175dSPaolo Bonzini __u32 guest_len; 16009f2d175dSPaolo Bonzini __u64 trans_uaddr; 16019f2d175dSPaolo Bonzini __u32 trans_len; 16029f2d175dSPaolo Bonzini }; 16039f2d175dSPaolo Bonzini 16049f2d175dSPaolo Bonzini struct kvm_sev_launch_measure { 16059f2d175dSPaolo Bonzini __u64 uaddr; 16069f2d175dSPaolo Bonzini __u32 len; 16079f2d175dSPaolo Bonzini }; 16089f2d175dSPaolo Bonzini 16099f2d175dSPaolo Bonzini struct kvm_sev_guest_status { 16109f2d175dSPaolo Bonzini __u32 handle; 16119f2d175dSPaolo Bonzini __u32 policy; 16129f2d175dSPaolo Bonzini __u32 state; 16139f2d175dSPaolo Bonzini }; 16149f2d175dSPaolo Bonzini 16159f2d175dSPaolo Bonzini struct kvm_sev_dbg { 16169f2d175dSPaolo Bonzini __u64 src_uaddr; 16179f2d175dSPaolo Bonzini __u64 dst_uaddr; 16189f2d175dSPaolo Bonzini __u32 len; 16199f2d175dSPaolo Bonzini }; 162051b24e34SJan Kiszka 162151b24e34SJan Kiszka #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) 16229ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) 16239ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2) 162451b24e34SJan Kiszka 162551b24e34SJan Kiszka struct kvm_assigned_pci_dev { 162651b24e34SJan Kiszka __u32 assigned_dev_id; 162751b24e34SJan Kiszka __u32 busnr; 162851b24e34SJan Kiszka __u32 devfn; 162951b24e34SJan Kiszka __u32 flags; 163051b24e34SJan Kiszka __u32 segnr; 163151b24e34SJan Kiszka union { 163251b24e34SJan Kiszka __u32 reserved[11]; 163351b24e34SJan Kiszka }; 163451b24e34SJan Kiszka }; 163551b24e34SJan Kiszka 163651b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_INTX (1 << 0) 163751b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSI (1 << 1) 163851b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSIX (1 << 2) 163951b24e34SJan Kiszka 164051b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_INTX (1 << 8) 164151b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSI (1 << 9) 164251b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10) 164351b24e34SJan Kiszka 164451b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MASK 0x00ff 164551b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MASK 0xff00 164651b24e34SJan Kiszka 164751b24e34SJan Kiszka struct kvm_assigned_irq { 164851b24e34SJan Kiszka __u32 assigned_dev_id; 16497c6da3deSAlexander Graf __u32 host_irq; /* ignored (legacy field) */ 165051b24e34SJan Kiszka __u32 guest_irq; 165151b24e34SJan Kiszka __u32 flags; 165251b24e34SJan Kiszka union { 165351b24e34SJan Kiszka __u32 reserved[12]; 165451b24e34SJan Kiszka }; 165551b24e34SJan Kiszka }; 165651b24e34SJan Kiszka 165751b24e34SJan Kiszka struct kvm_assigned_msix_nr { 165851b24e34SJan Kiszka __u32 assigned_dev_id; 165951b24e34SJan Kiszka __u16 entry_nr; 166051b24e34SJan Kiszka __u16 padding; 166151b24e34SJan Kiszka }; 166251b24e34SJan Kiszka 166351b24e34SJan Kiszka #define KVM_MAX_MSIX_PER_DEV 256 166451b24e34SJan Kiszka struct kvm_assigned_msix_entry { 166551b24e34SJan Kiszka __u32 assigned_dev_id; 166651b24e34SJan Kiszka __u32 gsi; 166751b24e34SJan Kiszka __u16 entry; /* The index of entry in the MSI-X table */ 166851b24e34SJan Kiszka __u16 padding[3]; 166951b24e34SJan Kiszka }; 167051b24e34SJan Kiszka 1671dbdfea92SCornelia Huck #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0) 1672dbdfea92SCornelia Huck #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) 1673dbdfea92SCornelia Huck 167474c98e20SCornelia Huck /* Available with KVM_CAP_ARM_USER_IRQ */ 167574c98e20SCornelia Huck 167674c98e20SCornelia Huck /* Bits for run->s.regs.device_irq_level */ 167774c98e20SCornelia Huck #define KVM_ARM_DEV_EL1_VTIMER (1 << 0) 167874c98e20SCornelia Huck #define KVM_ARM_DEV_EL1_PTIMER (1 << 1) 167974c98e20SCornelia Huck #define KVM_ARM_DEV_PMU (1 << 2) 168074c98e20SCornelia Huck 168165a6d8ddSPeter Maydell struct kvm_hyperv_eventfd { 168265a6d8ddSPeter Maydell __u32 conn_id; 168365a6d8ddSPeter Maydell __s32 fd; 168465a6d8ddSPeter Maydell __u32 flags; 168565a6d8ddSPeter Maydell __u32 padding[3]; 168665a6d8ddSPeter Maydell }; 168765a6d8ddSPeter Maydell 168865a6d8ddSPeter Maydell #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff 168965a6d8ddSPeter Maydell #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0) 169065a6d8ddSPeter Maydell 1691dc6f8d45SCornelia Huck #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0) 1692dc6f8d45SCornelia Huck #define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1) 1693dc6f8d45SCornelia Huck 169451b24e34SJan Kiszka #endif /* __LINUX_KVM_H */ 1695