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.. 119eadd0e44SPeter Maydell * For ARM: See Documentation/virtual/kvm/api.txt 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 191fff02bc0SPaolo Bonzini __u32 type; 192fff02bc0SPaolo Bonzini union { 193fff02bc0SPaolo Bonzini struct { 194fff02bc0SPaolo Bonzini __u32 msr; 195fff02bc0SPaolo Bonzini __u64 control; 196fff02bc0SPaolo Bonzini __u64 evt_page; 197fff02bc0SPaolo Bonzini __u64 msg_page; 198fff02bc0SPaolo Bonzini } synic; 199b89485a5SPaolo Bonzini struct { 200b89485a5SPaolo Bonzini __u64 input; 201b89485a5SPaolo Bonzini __u64 result; 202b89485a5SPaolo Bonzini __u64 params[2]; 203b89485a5SPaolo Bonzini } hcall; 204fff02bc0SPaolo Bonzini } u; 205fff02bc0SPaolo Bonzini }; 206fff02bc0SPaolo Bonzini 2077a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS_NONE 1 2087a52ce8aSCornelia Huck #define KVM_S390_SKEYS_MAX 1048576 2097a52ce8aSCornelia Huck 21051b24e34SJan Kiszka #define KVM_EXIT_UNKNOWN 0 21151b24e34SJan Kiszka #define KVM_EXIT_EXCEPTION 1 21251b24e34SJan Kiszka #define KVM_EXIT_IO 2 21351b24e34SJan Kiszka #define KVM_EXIT_HYPERCALL 3 21451b24e34SJan Kiszka #define KVM_EXIT_DEBUG 4 21551b24e34SJan Kiszka #define KVM_EXIT_HLT 5 21651b24e34SJan Kiszka #define KVM_EXIT_MMIO 6 21751b24e34SJan Kiszka #define KVM_EXIT_IRQ_WINDOW_OPEN 7 21851b24e34SJan Kiszka #define KVM_EXIT_SHUTDOWN 8 21951b24e34SJan Kiszka #define KVM_EXIT_FAIL_ENTRY 9 22051b24e34SJan Kiszka #define KVM_EXIT_INTR 10 22151b24e34SJan Kiszka #define KVM_EXIT_SET_TPR 11 22251b24e34SJan Kiszka #define KVM_EXIT_TPR_ACCESS 12 22351b24e34SJan Kiszka #define KVM_EXIT_S390_SIEIC 13 22451b24e34SJan Kiszka #define KVM_EXIT_S390_RESET 14 225a9fd1654SJens Freimann #define KVM_EXIT_DCR 15 /* deprecated */ 22651b24e34SJan Kiszka #define KVM_EXIT_NMI 16 22751b24e34SJan Kiszka #define KVM_EXIT_INTERNAL_ERROR 17 22851b24e34SJan Kiszka #define KVM_EXIT_OSI 18 2297c6da3deSAlexander Graf #define KVM_EXIT_PAPR_HCALL 19 2301529ae1bSAlexander Graf #define KVM_EXIT_S390_UCONTROL 20 231d4834ff9SAlexander Graf #define KVM_EXIT_WATCHDOG 21 232d3dccee1SAlexander Graf #define KVM_EXIT_S390_TSCH 22 233d3dccee1SAlexander Graf #define KVM_EXIT_EPR 23 234b061808dSAlexander Graf #define KVM_EXIT_SYSTEM_EVENT 24 2357a52ce8aSCornelia Huck #define KVM_EXIT_S390_STSI 25 2363a824b15SPaolo Bonzini #define KVM_EXIT_IOAPIC_EOI 26 237fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV 27 23851b24e34SJan Kiszka 23951b24e34SJan Kiszka /* For KVM_EXIT_INTERNAL_ERROR */ 240d4834ff9SAlexander Graf /* Emulate instruction failed. */ 24151b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_EMULATION 1 242d4834ff9SAlexander Graf /* Encounter unexpected simultaneous exceptions. */ 24351b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_SIMUL_EX 2 244d4834ff9SAlexander Graf /* Encounter unexpected vm-exit due to delivery event. */ 245d4834ff9SAlexander Graf #define KVM_INTERNAL_ERROR_DELIVERY_EV 3 24651b24e34SJan Kiszka 24751b24e34SJan Kiszka /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ 24851b24e34SJan Kiszka struct kvm_run { 24951b24e34SJan Kiszka /* in */ 25051b24e34SJan Kiszka __u8 request_interrupt_window; 2513a5eb5b4SPaolo Bonzini __u8 immediate_exit; 2523a5eb5b4SPaolo Bonzini __u8 padding1[6]; 25351b24e34SJan Kiszka 25451b24e34SJan Kiszka /* out */ 25551b24e34SJan Kiszka __u32 exit_reason; 25651b24e34SJan Kiszka __u8 ready_for_interrupt_injection; 25751b24e34SJan Kiszka __u8 if_flag; 25824a31426SPaolo Bonzini __u16 flags; 25951b24e34SJan Kiszka 26051b24e34SJan Kiszka /* in (pre_kvm_run), out (post_kvm_run) */ 26151b24e34SJan Kiszka __u64 cr8; 26251b24e34SJan Kiszka __u64 apic_base; 26351b24e34SJan Kiszka 26451b24e34SJan Kiszka #ifdef __KVM_S390 26551b24e34SJan Kiszka /* the processor status word for s390 */ 26651b24e34SJan Kiszka __u64 psw_mask; /* psw upper half */ 26751b24e34SJan Kiszka __u64 psw_addr; /* psw lower half */ 26851b24e34SJan Kiszka #endif 26951b24e34SJan Kiszka union { 27051b24e34SJan Kiszka /* KVM_EXIT_UNKNOWN */ 27151b24e34SJan Kiszka struct { 27251b24e34SJan Kiszka __u64 hardware_exit_reason; 27351b24e34SJan Kiszka } hw; 27451b24e34SJan Kiszka /* KVM_EXIT_FAIL_ENTRY */ 27551b24e34SJan Kiszka struct { 27651b24e34SJan Kiszka __u64 hardware_entry_failure_reason; 27751b24e34SJan Kiszka } fail_entry; 27851b24e34SJan Kiszka /* KVM_EXIT_EXCEPTION */ 27951b24e34SJan Kiszka struct { 28051b24e34SJan Kiszka __u32 exception; 28151b24e34SJan Kiszka __u32 error_code; 28251b24e34SJan Kiszka } ex; 28351b24e34SJan Kiszka /* KVM_EXIT_IO */ 28451b24e34SJan Kiszka struct { 28551b24e34SJan Kiszka #define KVM_EXIT_IO_IN 0 28651b24e34SJan Kiszka #define KVM_EXIT_IO_OUT 1 28751b24e34SJan Kiszka __u8 direction; 28851b24e34SJan Kiszka __u8 size; /* bytes */ 28951b24e34SJan Kiszka __u16 port; 29051b24e34SJan Kiszka __u32 count; 29151b24e34SJan Kiszka __u64 data_offset; /* relative to kvm_run start */ 29251b24e34SJan Kiszka } io; 2933a824b15SPaolo Bonzini /* KVM_EXIT_DEBUG */ 29451b24e34SJan Kiszka struct { 29551b24e34SJan Kiszka struct kvm_debug_exit_arch arch; 29651b24e34SJan Kiszka } debug; 29751b24e34SJan Kiszka /* KVM_EXIT_MMIO */ 29851b24e34SJan Kiszka struct { 29951b24e34SJan Kiszka __u64 phys_addr; 30051b24e34SJan Kiszka __u8 data[8]; 30151b24e34SJan Kiszka __u32 len; 30251b24e34SJan Kiszka __u8 is_write; 30351b24e34SJan Kiszka } mmio; 30451b24e34SJan Kiszka /* KVM_EXIT_HYPERCALL */ 30551b24e34SJan Kiszka struct { 30651b24e34SJan Kiszka __u64 nr; 30751b24e34SJan Kiszka __u64 args[6]; 30851b24e34SJan Kiszka __u64 ret; 30951b24e34SJan Kiszka __u32 longmode; 31051b24e34SJan Kiszka __u32 pad; 31151b24e34SJan Kiszka } hypercall; 31251b24e34SJan Kiszka /* KVM_EXIT_TPR_ACCESS */ 31351b24e34SJan Kiszka struct { 31451b24e34SJan Kiszka __u64 rip; 31551b24e34SJan Kiszka __u32 is_write; 31651b24e34SJan Kiszka __u32 pad; 31751b24e34SJan Kiszka } tpr_access; 31851b24e34SJan Kiszka /* KVM_EXIT_S390_SIEIC */ 31951b24e34SJan Kiszka struct { 32051b24e34SJan Kiszka __u8 icptcode; 32151b24e34SJan Kiszka __u16 ipa; 32251b24e34SJan Kiszka __u32 ipb; 32351b24e34SJan Kiszka } s390_sieic; 32451b24e34SJan Kiszka /* KVM_EXIT_S390_RESET */ 32551b24e34SJan Kiszka #define KVM_S390_RESET_POR 1 32651b24e34SJan Kiszka #define KVM_S390_RESET_CLEAR 2 32751b24e34SJan Kiszka #define KVM_S390_RESET_SUBSYSTEM 4 32851b24e34SJan Kiszka #define KVM_S390_RESET_CPU_INIT 8 32951b24e34SJan Kiszka #define KVM_S390_RESET_IPL 16 33051b24e34SJan Kiszka __u64 s390_reset_flags; 3311529ae1bSAlexander Graf /* KVM_EXIT_S390_UCONTROL */ 3321529ae1bSAlexander Graf struct { 3331529ae1bSAlexander Graf __u64 trans_exc_code; 3341529ae1bSAlexander Graf __u32 pgm_code; 3351529ae1bSAlexander Graf } s390_ucontrol; 336a9fd1654SJens Freimann /* KVM_EXIT_DCR (deprecated) */ 33751b24e34SJan Kiszka struct { 33851b24e34SJan Kiszka __u32 dcrn; 33951b24e34SJan Kiszka __u32 data; 34051b24e34SJan Kiszka __u8 is_write; 34151b24e34SJan Kiszka } dcr; 3423a824b15SPaolo Bonzini /* KVM_EXIT_INTERNAL_ERROR */ 34351b24e34SJan Kiszka struct { 34451b24e34SJan Kiszka __u32 suberror; 34551b24e34SJan Kiszka /* Available with KVM_CAP_INTERNAL_ERROR_DATA: */ 34651b24e34SJan Kiszka __u32 ndata; 34751b24e34SJan Kiszka __u64 data[16]; 34851b24e34SJan Kiszka } internal; 34951b24e34SJan Kiszka /* KVM_EXIT_OSI */ 35051b24e34SJan Kiszka struct { 35151b24e34SJan Kiszka __u64 gprs[32]; 35251b24e34SJan Kiszka } osi; 3533a824b15SPaolo Bonzini /* KVM_EXIT_PAPR_HCALL */ 3547c6da3deSAlexander Graf struct { 3557c6da3deSAlexander Graf __u64 nr; 3567c6da3deSAlexander Graf __u64 ret; 3577c6da3deSAlexander Graf __u64 args[9]; 3587c6da3deSAlexander Graf } papr_hcall; 359d3dccee1SAlexander Graf /* KVM_EXIT_S390_TSCH */ 360d3dccee1SAlexander Graf struct { 361d3dccee1SAlexander Graf __u16 subchannel_id; 362d3dccee1SAlexander Graf __u16 subchannel_nr; 363d3dccee1SAlexander Graf __u32 io_int_parm; 364d3dccee1SAlexander Graf __u32 io_int_word; 365d3dccee1SAlexander Graf __u32 ipb; 366d3dccee1SAlexander Graf __u8 dequeued; 367d3dccee1SAlexander Graf } s390_tsch; 368d3dccee1SAlexander Graf /* KVM_EXIT_EPR */ 369d3dccee1SAlexander Graf struct { 370d3dccee1SAlexander Graf __u32 epr; 371d3dccee1SAlexander Graf } epr; 372b061808dSAlexander Graf /* KVM_EXIT_SYSTEM_EVENT */ 373b061808dSAlexander Graf struct { 374b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_SHUTDOWN 1 375b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_RESET 2 376120758fbSPaolo Bonzini #define KVM_SYSTEM_EVENT_CRASH 3 377b061808dSAlexander Graf __u32 type; 378b061808dSAlexander Graf __u64 flags; 379b061808dSAlexander Graf } system_event; 3807a52ce8aSCornelia Huck /* KVM_EXIT_S390_STSI */ 3817a52ce8aSCornelia Huck struct { 3827a52ce8aSCornelia Huck __u64 addr; 3837a52ce8aSCornelia Huck __u8 ar; 3847a52ce8aSCornelia Huck __u8 reserved; 3857a52ce8aSCornelia Huck __u8 fc; 3867a52ce8aSCornelia Huck __u8 sel1; 3877a52ce8aSCornelia Huck __u16 sel2; 3887a52ce8aSCornelia Huck } s390_stsi; 3893a824b15SPaolo Bonzini /* KVM_EXIT_IOAPIC_EOI */ 3903a824b15SPaolo Bonzini struct { 3913a824b15SPaolo Bonzini __u8 vector; 3923a824b15SPaolo Bonzini } eoi; 393fff02bc0SPaolo Bonzini /* KVM_EXIT_HYPERV */ 394fff02bc0SPaolo Bonzini struct kvm_hyperv_exit hyperv; 39551b24e34SJan Kiszka /* Fix the size of the union. */ 39651b24e34SJan Kiszka char padding[256]; 39751b24e34SJan Kiszka }; 3981529ae1bSAlexander Graf 39965a6d8ddSPeter Maydell /* 2048 is the size of the char array used to bound/pad the size 40065a6d8ddSPeter Maydell * of the union that holds sync regs. 40165a6d8ddSPeter Maydell */ 40265a6d8ddSPeter Maydell #define SYNC_REGS_SIZE_BYTES 2048 4031529ae1bSAlexander Graf /* 4041529ae1bSAlexander Graf * shared registers between kvm and userspace. 4051529ae1bSAlexander Graf * kvm_valid_regs specifies the register classes set by the host 4061529ae1bSAlexander Graf * kvm_dirty_regs specified the register classes dirtied by userspace 4071529ae1bSAlexander Graf * struct kvm_sync_regs is architecture specific, as well as the 4081529ae1bSAlexander Graf * bits for kvm_valid_regs and kvm_dirty_regs 4091529ae1bSAlexander Graf */ 4101529ae1bSAlexander Graf __u64 kvm_valid_regs; 4111529ae1bSAlexander Graf __u64 kvm_dirty_regs; 4121529ae1bSAlexander Graf union { 4131529ae1bSAlexander Graf struct kvm_sync_regs regs; 41465a6d8ddSPeter Maydell char padding[SYNC_REGS_SIZE_BYTES]; 4151529ae1bSAlexander Graf } s; 41651b24e34SJan Kiszka }; 41751b24e34SJan Kiszka 41851b24e34SJan Kiszka /* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */ 41951b24e34SJan Kiszka 42051b24e34SJan Kiszka struct kvm_coalesced_mmio_zone { 42151b24e34SJan Kiszka __u64 addr; 42251b24e34SJan Kiszka __u32 size; 42351b24e34SJan Kiszka __u32 pad; 42451b24e34SJan Kiszka }; 42551b24e34SJan Kiszka 42651b24e34SJan Kiszka struct kvm_coalesced_mmio { 42751b24e34SJan Kiszka __u64 phys_addr; 42851b24e34SJan Kiszka __u32 len; 42951b24e34SJan Kiszka __u32 pad; 43051b24e34SJan Kiszka __u8 data[8]; 43151b24e34SJan Kiszka }; 43251b24e34SJan Kiszka 43351b24e34SJan Kiszka struct kvm_coalesced_mmio_ring { 43451b24e34SJan Kiszka __u32 first, last; 43551b24e34SJan Kiszka struct kvm_coalesced_mmio coalesced_mmio[0]; 43651b24e34SJan Kiszka }; 43751b24e34SJan Kiszka 43851b24e34SJan Kiszka #define KVM_COALESCED_MMIO_MAX \ 43951b24e34SJan Kiszka ((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \ 44051b24e34SJan Kiszka sizeof(struct kvm_coalesced_mmio)) 44151b24e34SJan Kiszka 44251b24e34SJan Kiszka /* for KVM_TRANSLATE */ 44351b24e34SJan Kiszka struct kvm_translation { 44451b24e34SJan Kiszka /* in */ 44551b24e34SJan Kiszka __u64 linear_address; 44651b24e34SJan Kiszka 44751b24e34SJan Kiszka /* out */ 44851b24e34SJan Kiszka __u64 physical_address; 44951b24e34SJan Kiszka __u8 valid; 45051b24e34SJan Kiszka __u8 writeable; 45151b24e34SJan Kiszka __u8 usermode; 45251b24e34SJan Kiszka __u8 pad[5]; 45351b24e34SJan Kiszka }; 45451b24e34SJan Kiszka 4557a52ce8aSCornelia Huck /* for KVM_S390_MEM_OP */ 4567a52ce8aSCornelia Huck struct kvm_s390_mem_op { 4577a52ce8aSCornelia Huck /* in */ 4587a52ce8aSCornelia Huck __u64 gaddr; /* the guest address */ 4597a52ce8aSCornelia Huck __u64 flags; /* flags */ 4607a52ce8aSCornelia Huck __u32 size; /* amount of bytes */ 4617a52ce8aSCornelia Huck __u32 op; /* type of operation */ 4627a52ce8aSCornelia Huck __u64 buf; /* buffer in userspace */ 4637a52ce8aSCornelia Huck __u8 ar; /* the access register number */ 4647a52ce8aSCornelia Huck __u8 reserved[31]; /* should be set to 0 */ 4657a52ce8aSCornelia Huck }; 4667a52ce8aSCornelia Huck /* types for kvm_s390_mem_op->op */ 4677a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_READ 0 4687a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_WRITE 1 4697a52ce8aSCornelia Huck /* flags for kvm_s390_mem_op->flags */ 4707a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0) 4717a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1) 4727a52ce8aSCornelia Huck 47351b24e34SJan Kiszka /* for KVM_INTERRUPT */ 47451b24e34SJan Kiszka struct kvm_interrupt { 47551b24e34SJan Kiszka /* in */ 47651b24e34SJan Kiszka __u32 irq; 47751b24e34SJan Kiszka }; 47851b24e34SJan Kiszka 47951b24e34SJan Kiszka /* for KVM_GET_DIRTY_LOG */ 48051b24e34SJan Kiszka struct kvm_dirty_log { 48151b24e34SJan Kiszka __u32 slot; 48251b24e34SJan Kiszka __u32 padding1; 48351b24e34SJan Kiszka union { 48451b24e34SJan Kiszka void *dirty_bitmap; /* one bit per page */ 48551b24e34SJan Kiszka __u64 padding2; 48651b24e34SJan Kiszka }; 48751b24e34SJan Kiszka }; 48851b24e34SJan Kiszka 48951b24e34SJan Kiszka /* for KVM_SET_SIGNAL_MASK */ 49051b24e34SJan Kiszka struct kvm_signal_mask { 49151b24e34SJan Kiszka __u32 len; 49251b24e34SJan Kiszka __u8 sigset[0]; 49351b24e34SJan Kiszka }; 49451b24e34SJan Kiszka 49551b24e34SJan Kiszka /* for KVM_TPR_ACCESS_REPORTING */ 49651b24e34SJan Kiszka struct kvm_tpr_access_ctl { 49751b24e34SJan Kiszka __u32 enabled; 49851b24e34SJan Kiszka __u32 flags; 49951b24e34SJan Kiszka __u32 reserved[8]; 50051b24e34SJan Kiszka }; 50151b24e34SJan Kiszka 50251b24e34SJan Kiszka /* for KVM_SET_VAPIC_ADDR */ 50351b24e34SJan Kiszka struct kvm_vapic_addr { 50451b24e34SJan Kiszka __u64 vapic_addr; 50551b24e34SJan Kiszka }; 50651b24e34SJan Kiszka 507a9fd1654SJens Freimann /* for KVM_SET_MP_STATE */ 50851b24e34SJan Kiszka 509a9fd1654SJens Freimann /* not all states are valid on all architectures */ 51051b24e34SJan Kiszka #define KVM_MP_STATE_RUNNABLE 0 51151b24e34SJan Kiszka #define KVM_MP_STATE_UNINITIALIZED 1 51251b24e34SJan Kiszka #define KVM_MP_STATE_INIT_RECEIVED 2 51351b24e34SJan Kiszka #define KVM_MP_STATE_HALTED 3 51451b24e34SJan Kiszka #define KVM_MP_STATE_SIPI_RECEIVED 4 515a9fd1654SJens Freimann #define KVM_MP_STATE_STOPPED 5 516a9fd1654SJens Freimann #define KVM_MP_STATE_CHECK_STOP 6 517a9fd1654SJens Freimann #define KVM_MP_STATE_OPERATING 7 518a9fd1654SJens Freimann #define KVM_MP_STATE_LOAD 8 51951b24e34SJan Kiszka 52051b24e34SJan Kiszka struct kvm_mp_state { 52151b24e34SJan Kiszka __u32 mp_state; 52251b24e34SJan Kiszka }; 52351b24e34SJan Kiszka 52451b24e34SJan Kiszka struct kvm_s390_psw { 52551b24e34SJan Kiszka __u64 mask; 52651b24e34SJan Kiszka __u64 addr; 52751b24e34SJan Kiszka }; 52851b24e34SJan Kiszka 52951b24e34SJan Kiszka /* valid values for type in kvm_s390_interrupt */ 53051b24e34SJan Kiszka #define KVM_S390_SIGP_STOP 0xfffe0000u 53151b24e34SJan Kiszka #define KVM_S390_PROGRAM_INT 0xfffe0001u 53251b24e34SJan Kiszka #define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u 53351b24e34SJan Kiszka #define KVM_S390_RESTART 0xfffe0003u 534216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_INIT 0xfffe0004u 535216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_DONE 0xfffe0005u 536d3dccee1SAlexander Graf #define KVM_S390_MCHK 0xfffe1000u 53776eb98d5SJens Freimann #define KVM_S390_INT_CLOCK_COMP 0xffff1004u 53876eb98d5SJens Freimann #define KVM_S390_INT_CPU_TIMER 0xffff1005u 53951b24e34SJan Kiszka #define KVM_S390_INT_VIRTIO 0xffff2603u 54051b24e34SJan Kiszka #define KVM_S390_INT_SERVICE 0xffff2401u 54151b24e34SJan Kiszka #define KVM_S390_INT_EMERGENCY 0xffff1201u 5421529ae1bSAlexander Graf #define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u 543d3dccee1SAlexander Graf /* Anything below 0xfffe0000u is taken by INT_IO */ 544d3dccee1SAlexander Graf #define KVM_S390_INT_IO(ai,cssid,ssid,schid) \ 545d3dccee1SAlexander Graf (((schid)) | \ 546d3dccee1SAlexander Graf ((ssid) << 16) | \ 547d3dccee1SAlexander Graf ((cssid) << 18) | \ 548d3dccee1SAlexander Graf ((ai) << 26)) 549d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MIN 0x00000000u 550d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MAX 0xfffdffffu 551120758fbSPaolo Bonzini #define KVM_S390_INT_IO_AI_MASK 0x04000000u 552d3dccee1SAlexander Graf 55351b24e34SJan Kiszka 55451b24e34SJan Kiszka struct kvm_s390_interrupt { 55551b24e34SJan Kiszka __u32 type; 55651b24e34SJan Kiszka __u32 parm; 55751b24e34SJan Kiszka __u64 parm64; 55851b24e34SJan Kiszka }; 55951b24e34SJan Kiszka 560216db403SChristian Borntraeger struct kvm_s390_io_info { 561216db403SChristian Borntraeger __u16 subchannel_id; 562216db403SChristian Borntraeger __u16 subchannel_nr; 563216db403SChristian Borntraeger __u32 io_int_parm; 564216db403SChristian Borntraeger __u32 io_int_word; 565216db403SChristian Borntraeger }; 566216db403SChristian Borntraeger 567216db403SChristian Borntraeger struct kvm_s390_ext_info { 568216db403SChristian Borntraeger __u32 ext_params; 569216db403SChristian Borntraeger __u32 pad; 570216db403SChristian Borntraeger __u64 ext_params2; 571216db403SChristian Borntraeger }; 572216db403SChristian Borntraeger 573216db403SChristian Borntraeger struct kvm_s390_pgm_info { 574216db403SChristian Borntraeger __u64 trans_exc_code; 575216db403SChristian Borntraeger __u64 mon_code; 576216db403SChristian Borntraeger __u64 per_address; 577216db403SChristian Borntraeger __u32 data_exc_code; 578216db403SChristian Borntraeger __u16 code; 579216db403SChristian Borntraeger __u16 mon_class_nr; 580216db403SChristian Borntraeger __u8 per_code; 581216db403SChristian Borntraeger __u8 per_atmid; 582216db403SChristian Borntraeger __u8 exc_access_id; 583216db403SChristian Borntraeger __u8 per_access_id; 584216db403SChristian Borntraeger __u8 op_access_id; 58566fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_VALID 0x01 58666fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_0 0x02 58766fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_1 0x04 58866fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_MASK 0x06 58966fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_NO_REWIND 0x08 59066fb2d54SCornelia Huck __u8 flags; 59166fb2d54SCornelia Huck __u8 pad[2]; 592216db403SChristian Borntraeger }; 593216db403SChristian Borntraeger 594216db403SChristian Borntraeger struct kvm_s390_prefix_info { 595216db403SChristian Borntraeger __u32 address; 596216db403SChristian Borntraeger }; 597216db403SChristian Borntraeger 598216db403SChristian Borntraeger struct kvm_s390_extcall_info { 599216db403SChristian Borntraeger __u16 code; 600216db403SChristian Borntraeger }; 601216db403SChristian Borntraeger 602216db403SChristian Borntraeger struct kvm_s390_emerg_info { 603216db403SChristian Borntraeger __u16 code; 604216db403SChristian Borntraeger }; 605216db403SChristian Borntraeger 60651628b18SChristian Borntraeger #define KVM_S390_STOP_FLAG_STORE_STATUS 0x01 60751628b18SChristian Borntraeger struct kvm_s390_stop_info { 60851628b18SChristian Borntraeger __u32 flags; 60951628b18SChristian Borntraeger }; 61051628b18SChristian Borntraeger 611216db403SChristian Borntraeger struct kvm_s390_mchk_info { 612216db403SChristian Borntraeger __u64 cr14; 613216db403SChristian Borntraeger __u64 mcic; 614216db403SChristian Borntraeger __u64 failing_storage_address; 615216db403SChristian Borntraeger __u32 ext_damage_code; 616216db403SChristian Borntraeger __u32 pad; 617216db403SChristian Borntraeger __u8 fixed_logout[16]; 618216db403SChristian Borntraeger }; 619216db403SChristian Borntraeger 620216db403SChristian Borntraeger struct kvm_s390_irq { 621216db403SChristian Borntraeger __u64 type; 622216db403SChristian Borntraeger union { 623216db403SChristian Borntraeger struct kvm_s390_io_info io; 624216db403SChristian Borntraeger struct kvm_s390_ext_info ext; 625216db403SChristian Borntraeger struct kvm_s390_pgm_info pgm; 626216db403SChristian Borntraeger struct kvm_s390_emerg_info emerg; 627216db403SChristian Borntraeger struct kvm_s390_extcall_info extcall; 628216db403SChristian Borntraeger struct kvm_s390_prefix_info prefix; 62951628b18SChristian Borntraeger struct kvm_s390_stop_info stop; 630216db403SChristian Borntraeger struct kvm_s390_mchk_info mchk; 631216db403SChristian Borntraeger char reserved[64]; 632216db403SChristian Borntraeger } u; 633216db403SChristian Borntraeger }; 634216db403SChristian Borntraeger 6357a52ce8aSCornelia Huck struct kvm_s390_irq_state { 6367a52ce8aSCornelia Huck __u64 buf; 6379cbb6362SCornelia Huck __u32 flags; /* will stay unused for compatibility reasons */ 6387a52ce8aSCornelia Huck __u32 len; 6399cbb6362SCornelia Huck __u32 reserved[4]; /* will stay unused for compatibility reasons */ 6407a52ce8aSCornelia Huck }; 6417a52ce8aSCornelia Huck 64251b24e34SJan Kiszka /* for KVM_SET_GUEST_DEBUG */ 64351b24e34SJan Kiszka 64451b24e34SJan Kiszka #define KVM_GUESTDBG_ENABLE 0x00000001 64551b24e34SJan Kiszka #define KVM_GUESTDBG_SINGLESTEP 0x00000002 64651b24e34SJan Kiszka 64751b24e34SJan Kiszka struct kvm_guest_debug { 64851b24e34SJan Kiszka __u32 control; 64951b24e34SJan Kiszka __u32 pad; 65051b24e34SJan Kiszka struct kvm_guest_debug_arch arch; 65151b24e34SJan Kiszka }; 65251b24e34SJan Kiszka 65351b24e34SJan Kiszka enum { 65451b24e34SJan Kiszka kvm_ioeventfd_flag_nr_datamatch, 65551b24e34SJan Kiszka kvm_ioeventfd_flag_nr_pio, 65651b24e34SJan Kiszka kvm_ioeventfd_flag_nr_deassign, 657cae7f586SAlexander Graf kvm_ioeventfd_flag_nr_virtio_ccw_notify, 65876eb98d5SJens Freimann kvm_ioeventfd_flag_nr_fast_mmio, 65951b24e34SJan Kiszka kvm_ioeventfd_flag_nr_max, 66051b24e34SJan Kiszka }; 66151b24e34SJan Kiszka 66251b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) 66351b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) 66451b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) 665cae7f586SAlexander Graf #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ 666cae7f586SAlexander Graf (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify) 66751b24e34SJan Kiszka 66851b24e34SJan Kiszka #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1) 66951b24e34SJan Kiszka 67051b24e34SJan Kiszka struct kvm_ioeventfd { 67151b24e34SJan Kiszka __u64 datamatch; 67251b24e34SJan Kiszka __u64 addr; /* legal pio/mmio address */ 67376eb98d5SJens Freimann __u32 len; /* 1, 2, 4, or 8 bytes; or 0 to ignore length */ 67451b24e34SJan Kiszka __s32 fd; 67551b24e34SJan Kiszka __u32 flags; 67651b24e34SJan Kiszka __u8 pad[36]; 67751b24e34SJan Kiszka }; 67851b24e34SJan Kiszka 67965a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) 68077d361b1SEric Auger #define KVM_X86_DISABLE_EXITS_HLT (1 << 1) 68165a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) 68265a6d8ddSPeter Maydell #define KVM_X86_DISABLE_VALID_EXITS (KVM_X86_DISABLE_EXITS_MWAIT | \ 68377d361b1SEric Auger KVM_X86_DISABLE_EXITS_HLT | \ 68465a6d8ddSPeter Maydell KVM_X86_DISABLE_EXITS_PAUSE) 68565a6d8ddSPeter Maydell 68651b24e34SJan Kiszka /* for KVM_ENABLE_CAP */ 68751b24e34SJan Kiszka struct kvm_enable_cap { 68851b24e34SJan Kiszka /* in */ 68951b24e34SJan Kiszka __u32 cap; 69051b24e34SJan Kiszka __u32 flags; 69151b24e34SJan Kiszka __u64 args[4]; 69251b24e34SJan Kiszka __u8 pad[64]; 69351b24e34SJan Kiszka }; 69451b24e34SJan Kiszka 69551b24e34SJan Kiszka /* for KVM_PPC_GET_PVINFO */ 6963a5eb5b4SPaolo Bonzini 6973a5eb5b4SPaolo Bonzini #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) 6983a5eb5b4SPaolo Bonzini 69951b24e34SJan Kiszka struct kvm_ppc_pvinfo { 70051b24e34SJan Kiszka /* out */ 70151b24e34SJan Kiszka __u32 flags; 70251b24e34SJan Kiszka __u32 hcall[4]; 70351b24e34SJan Kiszka __u8 pad[108]; 70451b24e34SJan Kiszka }; 70551b24e34SJan Kiszka 70680a3eb10SJan Kiszka /* for KVM_PPC_GET_SMMU_INFO */ 70780a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_MAX_SZ 8 70880a3eb10SJan Kiszka 70980a3eb10SJan Kiszka struct kvm_ppc_one_page_size { 71080a3eb10SJan Kiszka __u32 page_shift; /* Page shift (or 0) */ 71180a3eb10SJan Kiszka __u32 pte_enc; /* Encoding in the HPTE (>>12) */ 71280a3eb10SJan Kiszka }; 71380a3eb10SJan Kiszka 71480a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size { 71580a3eb10SJan Kiszka __u32 page_shift; /* Base page shift of segment (or 0) */ 71680a3eb10SJan Kiszka __u32 slb_enc; /* SLB encoding for BookS */ 71780a3eb10SJan Kiszka struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ]; 71880a3eb10SJan Kiszka }; 71980a3eb10SJan Kiszka 72080a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_REAL 0x00000001 72180a3eb10SJan Kiszka #define KVM_PPC_1T_SEGMENTS 0x00000002 72280a3eb10SJan Kiszka 72380a3eb10SJan Kiszka struct kvm_ppc_smmu_info { 72480a3eb10SJan Kiszka __u64 flags; 72580a3eb10SJan Kiszka __u32 slb_size; 726d4083f50SAlexey Perevalov __u16 data_keys; /* # storage keys supported for data */ 727d4083f50SAlexey Perevalov __u16 instr_keys; /* # storage keys supported for instructions */ 72880a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; 72980a3eb10SJan Kiszka }; 73080a3eb10SJan Kiszka 7313a5eb5b4SPaolo Bonzini /* for KVM_PPC_RESIZE_HPT_{PREPARE,COMMIT} */ 7323a5eb5b4SPaolo Bonzini struct kvm_ppc_resize_hpt { 7333a5eb5b4SPaolo Bonzini __u64 flags; 7343a5eb5b4SPaolo Bonzini __u32 shift; 7353a5eb5b4SPaolo Bonzini __u32 pad; 7363a5eb5b4SPaolo Bonzini }; 737d4834ff9SAlexander Graf 73851b24e34SJan Kiszka #define KVMIO 0xAE 73951b24e34SJan Kiszka 7401529ae1bSAlexander Graf /* machine type bits, to be used as argument to KVM_CREATE_VM */ 7411529ae1bSAlexander Graf #define KVM_VM_S390_UCONTROL 1 7421529ae1bSAlexander Graf 743bf63839fSAlex Williamson /* on ppc, 0 indicate default, 1 should force HV and 2 PR */ 744bf63839fSAlex Williamson #define KVM_VM_PPC_HV 1 745bf63839fSAlex Williamson #define KVM_VM_PPC_PR 2 746bf63839fSAlex Williamson 74774c98e20SCornelia Huck /* on MIPS, 0 forces trap & emulate, 1 forces VZ ASE */ 74874c98e20SCornelia Huck #define KVM_VM_MIPS_TE 0 74974c98e20SCornelia Huck #define KVM_VM_MIPS_VZ 1 75074c98e20SCornelia Huck 7511529ae1bSAlexander Graf #define KVM_S390_SIE_PAGE_OFFSET 1 7521529ae1bSAlexander Graf 75351b24e34SJan Kiszka /* 75451b24e34SJan Kiszka * ioctls for /dev/kvm fds: 75551b24e34SJan Kiszka */ 75651b24e34SJan Kiszka #define KVM_GET_API_VERSION _IO(KVMIO, 0x00) 75751b24e34SJan Kiszka #define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ 75851b24e34SJan Kiszka #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) 75951b24e34SJan Kiszka 76051b24e34SJan Kiszka #define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06) 76151b24e34SJan Kiszka /* 76251b24e34SJan Kiszka * Check if a kvm extension is available. Argument is extension number, 76351b24e34SJan Kiszka * return is 1 (yes) or 0 (no, sorry). 76451b24e34SJan Kiszka */ 76551b24e34SJan Kiszka #define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03) 76651b24e34SJan Kiszka /* 76751b24e34SJan Kiszka * Get size for mmap(vcpu_fd) 76851b24e34SJan Kiszka */ 76951b24e34SJan Kiszka #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ 77051b24e34SJan Kiszka #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) 77151b24e34SJan Kiszka #define KVM_TRACE_ENABLE __KVM_DEPRECATED_MAIN_W_0x06 77251b24e34SJan Kiszka #define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07 77351b24e34SJan Kiszka #define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08 774bf63839fSAlex Williamson #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) 7759f2d175dSPaolo Bonzini #define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_msr_list) 77651b24e34SJan Kiszka 77751b24e34SJan Kiszka /* 77851b24e34SJan Kiszka * Extension capability list. 77951b24e34SJan Kiszka */ 78051b24e34SJan Kiszka #define KVM_CAP_IRQCHIP 0 78151b24e34SJan Kiszka #define KVM_CAP_HLT 1 78251b24e34SJan Kiszka #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 78351b24e34SJan Kiszka #define KVM_CAP_USER_MEMORY 3 78451b24e34SJan Kiszka #define KVM_CAP_SET_TSS_ADDR 4 78551b24e34SJan Kiszka #define KVM_CAP_VAPIC 6 78651b24e34SJan Kiszka #define KVM_CAP_EXT_CPUID 7 78751b24e34SJan Kiszka #define KVM_CAP_CLOCKSOURCE 8 7887c6da3deSAlexander Graf #define KVM_CAP_NR_VCPUS 9 /* returns recommended max vcpus per vm */ 78951b24e34SJan Kiszka #define KVM_CAP_NR_MEMSLOTS 10 /* returns max memory slots per vm */ 79051b24e34SJan Kiszka #define KVM_CAP_PIT 11 79151b24e34SJan Kiszka #define KVM_CAP_NOP_IO_DELAY 12 79251b24e34SJan Kiszka #define KVM_CAP_PV_MMU 13 79351b24e34SJan Kiszka #define KVM_CAP_MP_STATE 14 79451b24e34SJan Kiszka #define KVM_CAP_COALESCED_MMIO 15 79551b24e34SJan Kiszka #define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ 79651b24e34SJan Kiszka #define KVM_CAP_IOMMU 18 79751b24e34SJan Kiszka /* Bug in KVM_SET_USER_MEMORY_REGION fixed: */ 79851b24e34SJan Kiszka #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21 79951b24e34SJan Kiszka #define KVM_CAP_USER_NMI 22 80051b24e34SJan Kiszka #ifdef __KVM_HAVE_GUEST_DEBUG 80151b24e34SJan Kiszka #define KVM_CAP_SET_GUEST_DEBUG 23 80251b24e34SJan Kiszka #endif 80351b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 80451b24e34SJan Kiszka #define KVM_CAP_REINJECT_CONTROL 24 80551b24e34SJan Kiszka #endif 80651b24e34SJan Kiszka #define KVM_CAP_IRQ_ROUTING 25 80751b24e34SJan Kiszka #define KVM_CAP_IRQ_INJECT_STATUS 26 80851b24e34SJan Kiszka #define KVM_CAP_ASSIGN_DEV_IRQ 29 80951b24e34SJan Kiszka /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ 81051b24e34SJan Kiszka #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 81151b24e34SJan Kiszka #ifdef __KVM_HAVE_MCE 81251b24e34SJan Kiszka #define KVM_CAP_MCE 31 81351b24e34SJan Kiszka #endif 81451b24e34SJan Kiszka #define KVM_CAP_IRQFD 32 81551b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 81651b24e34SJan Kiszka #define KVM_CAP_PIT2 33 81751b24e34SJan Kiszka #endif 81851b24e34SJan Kiszka #define KVM_CAP_SET_BOOT_CPU_ID 34 81951b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT_STATE2 82051b24e34SJan Kiszka #define KVM_CAP_PIT_STATE2 35 82151b24e34SJan Kiszka #endif 82251b24e34SJan Kiszka #define KVM_CAP_IOEVENTFD 36 82351b24e34SJan Kiszka #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 82451b24e34SJan Kiszka #ifdef __KVM_HAVE_XEN_HVM 82551b24e34SJan Kiszka #define KVM_CAP_XEN_HVM 38 82651b24e34SJan Kiszka #endif 82751b24e34SJan Kiszka #define KVM_CAP_ADJUST_CLOCK 39 82851b24e34SJan Kiszka #define KVM_CAP_INTERNAL_ERROR_DATA 40 82951b24e34SJan Kiszka #ifdef __KVM_HAVE_VCPU_EVENTS 83051b24e34SJan Kiszka #define KVM_CAP_VCPU_EVENTS 41 83151b24e34SJan Kiszka #endif 83251b24e34SJan Kiszka #define KVM_CAP_S390_PSW 42 83351b24e34SJan Kiszka #define KVM_CAP_PPC_SEGSTATE 43 83451b24e34SJan Kiszka #define KVM_CAP_HYPERV 44 83551b24e34SJan Kiszka #define KVM_CAP_HYPERV_VAPIC 45 83651b24e34SJan Kiszka #define KVM_CAP_HYPERV_SPIN 46 83751b24e34SJan Kiszka #define KVM_CAP_PCI_SEGMENT 47 83851b24e34SJan Kiszka #define KVM_CAP_PPC_PAIRED_SINGLES 48 83951b24e34SJan Kiszka #define KVM_CAP_INTR_SHADOW 49 84051b24e34SJan Kiszka #ifdef __KVM_HAVE_DEBUGREGS 84151b24e34SJan Kiszka #define KVM_CAP_DEBUGREGS 50 84251b24e34SJan Kiszka #endif 84351b24e34SJan Kiszka #define KVM_CAP_X86_ROBUST_SINGLESTEP 51 84451b24e34SJan Kiszka #define KVM_CAP_PPC_OSI 52 84551b24e34SJan Kiszka #define KVM_CAP_PPC_UNSET_IRQ 53 84651b24e34SJan Kiszka #define KVM_CAP_ENABLE_CAP 54 84751b24e34SJan Kiszka #ifdef __KVM_HAVE_XSAVE 84851b24e34SJan Kiszka #define KVM_CAP_XSAVE 55 84951b24e34SJan Kiszka #endif 85051b24e34SJan Kiszka #ifdef __KVM_HAVE_XCRS 85151b24e34SJan Kiszka #define KVM_CAP_XCRS 56 85251b24e34SJan Kiszka #endif 85351b24e34SJan Kiszka #define KVM_CAP_PPC_GET_PVINFO 57 85451b24e34SJan Kiszka #define KVM_CAP_PPC_IRQ_LEVEL 58 85551b24e34SJan Kiszka #define KVM_CAP_ASYNC_PF 59 85651b24e34SJan Kiszka #define KVM_CAP_TSC_CONTROL 60 85751b24e34SJan Kiszka #define KVM_CAP_GET_TSC_KHZ 61 85851b24e34SJan Kiszka #define KVM_CAP_PPC_BOOKE_SREGS 62 8597c6da3deSAlexander Graf #define KVM_CAP_SPAPR_TCE 63 8607c6da3deSAlexander Graf #define KVM_CAP_PPC_SMT 64 8617c6da3deSAlexander Graf #define KVM_CAP_PPC_RMA 65 8627c6da3deSAlexander Graf #define KVM_CAP_MAX_VCPUS 66 /* returns max vcpus per vm */ 8639d4e4f8cSAlexander Graf #define KVM_CAP_PPC_HIOR 67 8647c6da3deSAlexander Graf #define KVM_CAP_PPC_PAPR 68 865a54fc080SAlexander Graf #define KVM_CAP_SW_TLB 69 8669d4e4f8cSAlexander Graf #define KVM_CAP_ONE_REG 70 8671529ae1bSAlexander Graf #define KVM_CAP_S390_GMAP 71 8681529ae1bSAlexander Graf #define KVM_CAP_TSC_DEADLINE_TIMER 72 8691529ae1bSAlexander Graf #define KVM_CAP_S390_UCONTROL 73 8701529ae1bSAlexander Graf #define KVM_CAP_SYNC_REGS 74 8719ab2195dSMarcelo Tosatti #define KVM_CAP_PCI_2_3 75 8729ab2195dSMarcelo Tosatti #define KVM_CAP_KVMCLOCK_CTRL 76 87380a3eb10SJan Kiszka #define KVM_CAP_SIGNAL_MSI 77 87480a3eb10SJan Kiszka #define KVM_CAP_PPC_GET_SMMU_INFO 78 8752a60dba4SAlexander Graf #define KVM_CAP_S390_COW 79 876651682dcSMichael S. Tsirkin #define KVM_CAP_PPC_ALLOC_HTAB 80 877716b8e4dSAlex Williamson #define KVM_CAP_READONLY_MEM 81 878716b8e4dSAlex Williamson #define KVM_CAP_IRQFD_RESAMPLE 82 879d4834ff9SAlexander Graf #define KVM_CAP_PPC_BOOKE_WATCHDOG 83 880d4834ff9SAlexander Graf #define KVM_CAP_PPC_HTAB_FD 84 881d3dccee1SAlexander Graf #define KVM_CAP_S390_CSS_SUPPORT 85 882d3dccee1SAlexander Graf #define KVM_CAP_PPC_EPR 86 883eadd0e44SPeter Maydell #define KVM_CAP_ARM_PSCI 87 884eadd0e44SPeter Maydell #define KVM_CAP_ARM_SET_DEVICE_ADDR 88 885e098b453SAlexey Kardashevskiy #define KVM_CAP_DEVICE_CTRL 89 886e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_MPIC 90 887e098b453SAlexey Kardashevskiy #define KVM_CAP_PPC_RTAS 91 888e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_XICS 92 889c5daeae1SAlexey Kardashevskiy #define KVM_CAP_ARM_EL1_32BIT 93 8904f265607SAndrew Jones #define KVM_CAP_SPAPR_MULTITCE 94 891bf63839fSAlex Williamson #define KVM_CAP_EXT_EMUL_CPUID 95 89248a5f3bcSVadim Rozenfeld #define KVM_CAP_HYPERV_TIME 96 8939ffd2685SCornelia Huck #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97 8949ffd2685SCornelia Huck #define KVM_CAP_ENABLE_CAP_VM 98 8959ffd2685SCornelia Huck #define KVM_CAP_S390_IRQCHIP 99 89676eb98d5SJens Freimann #define KVM_CAP_IOEVENTFD_NO_LENGTH 100 89776eb98d5SJens Freimann #define KVM_CAP_VM_ATTRIBUTES 101 898b061808dSAlexander Graf #define KVM_CAP_ARM_PSCI_0_2 102 899b061808dSAlexander Graf #define KVM_CAP_PPC_FIXUP_HCALL 103 900a9fd1654SJens Freimann #define KVM_CAP_PPC_ENABLE_HCALL 104 901a9fd1654SJens Freimann #define KVM_CAP_CHECK_EXTENSION_VM 105 90251628b18SChristian Borntraeger #define KVM_CAP_S390_USER_SIGP 106 9037a52ce8aSCornelia Huck #define KVM_CAP_S390_VECTOR_REGISTERS 107 9047a52ce8aSCornelia Huck #define KVM_CAP_S390_MEM_OP 108 9057a52ce8aSCornelia Huck #define KVM_CAP_S390_USER_STSI 109 9067a52ce8aSCornelia Huck #define KVM_CAP_S390_SKEYS 110 9077a52ce8aSCornelia Huck #define KVM_CAP_MIPS_FPU 111 9087a52ce8aSCornelia Huck #define KVM_CAP_MIPS_MSA 112 9097a52ce8aSCornelia Huck #define KVM_CAP_S390_INJECT_IRQ 113 9107a52ce8aSCornelia Huck #define KVM_CAP_S390_IRQ_STATE 114 9117a52ce8aSCornelia Huck #define KVM_CAP_PPC_HWRNG 115 91224a31426SPaolo Bonzini #define KVM_CAP_DISABLE_QUIRKS 116 91324a31426SPaolo Bonzini #define KVM_CAP_X86_SMM 117 91424a31426SPaolo Bonzini #define KVM_CAP_MULTI_ADDRESS_SPACE 118 9153a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_BPS 119 9163a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_WPS 120 9173a824b15SPaolo Bonzini #define KVM_CAP_SPLIT_IRQCHIP 121 9183a824b15SPaolo Bonzini #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122 919fff02bc0SPaolo Bonzini #define KVM_CAP_HYPERV_SYNIC 123 92066fb2d54SCornelia Huck #define KVM_CAP_S390_RI 124 921b89485a5SPaolo Bonzini #define KVM_CAP_SPAPR_TCE_64 125 922b89485a5SPaolo Bonzini #define KVM_CAP_ARM_PMU_V3 126 923b89485a5SPaolo Bonzini #define KVM_CAP_VCPU_ATTRIBUTES 127 924ff804f15SCornelia Huck #define KVM_CAP_MAX_VCPU_ID 128 925dbdfea92SCornelia Huck #define KVM_CAP_X2APIC_API 129 926dbdfea92SCornelia Huck #define KVM_CAP_S390_USER_INSTR0 130 927dbdfea92SCornelia Huck #define KVM_CAP_MSI_DEVID 131 928dbdfea92SCornelia Huck #define KVM_CAP_PPC_HTM 132 9293a5eb5b4SPaolo Bonzini #define KVM_CAP_SPAPR_RESIZE_HPT 133 9303a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_RADIX 134 9313a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_HASH_V3 135 9323a5eb5b4SPaolo Bonzini #define KVM_CAP_IMMEDIATE_EXIT 136 93374c98e20SCornelia Huck #define KVM_CAP_MIPS_VZ 137 93474c98e20SCornelia Huck #define KVM_CAP_MIPS_TE 138 93574c98e20SCornelia Huck #define KVM_CAP_MIPS_64BIT 139 93674c98e20SCornelia Huck #define KVM_CAP_S390_GS 140 93774c98e20SCornelia Huck #define KVM_CAP_S390_AIS 141 93874c98e20SCornelia Huck #define KVM_CAP_SPAPR_TCE_VFIO 142 93965a6d8ddSPeter Maydell #define KVM_CAP_X86_DISABLE_EXITS 143 94074c98e20SCornelia Huck #define KVM_CAP_ARM_USER_IRQ 144 9413272f0e2SChristian Borntraeger #define KVM_CAP_S390_CMMA_MIGRATION 145 9423272f0e2SChristian Borntraeger #define KVM_CAP_PPC_FWNMI 146 9433272f0e2SChristian Borntraeger #define KVM_CAP_PPC_SMT_POSSIBLE 147 944ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_SYNIC2 148 945ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_VP_INDEX 149 946dd873966SEric Auger #define KVM_CAP_S390_AIS_MIGRATION 150 9479cbb6362SCornelia Huck #define KVM_CAP_PPC_GET_CPU_CHAR 151 9489cbb6362SCornelia Huck #define KVM_CAP_S390_BPB 152 9499f2d175dSPaolo Bonzini #define KVM_CAP_GET_MSR_FEATURES 153 95065a6d8ddSPeter Maydell #define KVM_CAP_HYPERV_EVENTFD 154 95177d361b1SEric Auger #define KVM_CAP_HYPERV_TLBFLUSH 155 952*d36f7de8SCornelia Huck #define KVM_CAP_S390_HPAGE_1M 156 953*d36f7de8SCornelia Huck #define KVM_CAP_NESTED_STATE 157 95451b24e34SJan Kiszka 95551b24e34SJan Kiszka #ifdef KVM_CAP_IRQ_ROUTING 95651b24e34SJan Kiszka 95751b24e34SJan Kiszka struct kvm_irq_routing_irqchip { 95851b24e34SJan Kiszka __u32 irqchip; 95951b24e34SJan Kiszka __u32 pin; 96051b24e34SJan Kiszka }; 96151b24e34SJan Kiszka 96251b24e34SJan Kiszka struct kvm_irq_routing_msi { 96351b24e34SJan Kiszka __u32 address_lo; 96451b24e34SJan Kiszka __u32 address_hi; 96551b24e34SJan Kiszka __u32 data; 966dbdfea92SCornelia Huck union { 96751b24e34SJan Kiszka __u32 pad; 968dbdfea92SCornelia Huck __u32 devid; 969dbdfea92SCornelia Huck }; 97051b24e34SJan Kiszka }; 97151b24e34SJan Kiszka 9729ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter { 9739ffd2685SCornelia Huck __u64 ind_addr; 9749ffd2685SCornelia Huck __u64 summary_addr; 9759ffd2685SCornelia Huck __u64 ind_offset; 9769ffd2685SCornelia Huck __u32 summary_offset; 9779ffd2685SCornelia Huck __u32 adapter_id; 9789ffd2685SCornelia Huck }; 9799ffd2685SCornelia Huck 980fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint { 981fff02bc0SPaolo Bonzini __u32 vcpu; 982fff02bc0SPaolo Bonzini __u32 sint; 983fff02bc0SPaolo Bonzini }; 984fff02bc0SPaolo Bonzini 98551b24e34SJan Kiszka /* gsi routing entry types */ 98651b24e34SJan Kiszka #define KVM_IRQ_ROUTING_IRQCHIP 1 98751b24e34SJan Kiszka #define KVM_IRQ_ROUTING_MSI 2 9889ffd2685SCornelia Huck #define KVM_IRQ_ROUTING_S390_ADAPTER 3 989fff02bc0SPaolo Bonzini #define KVM_IRQ_ROUTING_HV_SINT 4 99051b24e34SJan Kiszka 99151b24e34SJan Kiszka struct kvm_irq_routing_entry { 99251b24e34SJan Kiszka __u32 gsi; 99351b24e34SJan Kiszka __u32 type; 99451b24e34SJan Kiszka __u32 flags; 99551b24e34SJan Kiszka __u32 pad; 99651b24e34SJan Kiszka union { 99751b24e34SJan Kiszka struct kvm_irq_routing_irqchip irqchip; 99851b24e34SJan Kiszka struct kvm_irq_routing_msi msi; 9999ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter adapter; 1000fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint hv_sint; 100151b24e34SJan Kiszka __u32 pad[8]; 100251b24e34SJan Kiszka } u; 100351b24e34SJan Kiszka }; 100451b24e34SJan Kiszka 100551b24e34SJan Kiszka struct kvm_irq_routing { 100651b24e34SJan Kiszka __u32 nr; 100751b24e34SJan Kiszka __u32 flags; 100851b24e34SJan Kiszka struct kvm_irq_routing_entry entries[0]; 100951b24e34SJan Kiszka }; 101051b24e34SJan Kiszka 101151b24e34SJan Kiszka #endif 101251b24e34SJan Kiszka 101351b24e34SJan Kiszka #ifdef KVM_CAP_MCE 101451b24e34SJan Kiszka /* x86 MCE */ 101551b24e34SJan Kiszka struct kvm_x86_mce { 101651b24e34SJan Kiszka __u64 status; 101751b24e34SJan Kiszka __u64 addr; 101851b24e34SJan Kiszka __u64 misc; 101951b24e34SJan Kiszka __u64 mcg_status; 102051b24e34SJan Kiszka __u8 bank; 102151b24e34SJan Kiszka __u8 pad1[7]; 102251b24e34SJan Kiszka __u64 pad2[3]; 102351b24e34SJan Kiszka }; 102451b24e34SJan Kiszka #endif 102551b24e34SJan Kiszka 102651b24e34SJan Kiszka #ifdef KVM_CAP_XEN_HVM 102751b24e34SJan Kiszka struct kvm_xen_hvm_config { 102851b24e34SJan Kiszka __u32 flags; 102951b24e34SJan Kiszka __u32 msr; 103051b24e34SJan Kiszka __u64 blob_addr_32; 103151b24e34SJan Kiszka __u64 blob_addr_64; 103251b24e34SJan Kiszka __u8 blob_size_32; 103351b24e34SJan Kiszka __u8 blob_size_64; 103451b24e34SJan Kiszka __u8 pad2[30]; 103551b24e34SJan Kiszka }; 103651b24e34SJan Kiszka #endif 103751b24e34SJan Kiszka 103851b24e34SJan Kiszka #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0) 1039716b8e4dSAlex Williamson /* 1040716b8e4dSAlex Williamson * Available with KVM_CAP_IRQFD_RESAMPLE 1041716b8e4dSAlex Williamson * 1042716b8e4dSAlex Williamson * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies 1043716b8e4dSAlex Williamson * the irqfd to operate in resampling mode for level triggered interrupt 104425b8b39bSAlexey Kardashevskiy * emulation. See Documentation/virtual/kvm/api.txt. 1045716b8e4dSAlex Williamson */ 1046716b8e4dSAlex Williamson #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1) 104751b24e34SJan Kiszka 104851b24e34SJan Kiszka struct kvm_irqfd { 104951b24e34SJan Kiszka __u32 fd; 105051b24e34SJan Kiszka __u32 gsi; 105151b24e34SJan Kiszka __u32 flags; 1052716b8e4dSAlex Williamson __u32 resamplefd; 1053716b8e4dSAlex Williamson __u8 pad[16]; 105451b24e34SJan Kiszka }; 105551b24e34SJan Kiszka 1056bc204035SMarcelo Tosatti /* For KVM_CAP_ADJUST_CLOCK */ 1057bc204035SMarcelo Tosatti 1058bc204035SMarcelo Tosatti /* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags. */ 1059bc204035SMarcelo Tosatti #define KVM_CLOCK_TSC_STABLE 2 1060bc204035SMarcelo Tosatti 106151b24e34SJan Kiszka struct kvm_clock_data { 106251b24e34SJan Kiszka __u64 clock; 106351b24e34SJan Kiszka __u32 flags; 106451b24e34SJan Kiszka __u32 pad[9]; 106551b24e34SJan Kiszka }; 106651b24e34SJan Kiszka 1067bc204035SMarcelo Tosatti /* For KVM_CAP_SW_TLB */ 1068bc204035SMarcelo Tosatti 1069a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_NOHV 0 1070a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_HV 1 1071a54fc080SAlexander Graf 1072a54fc080SAlexander Graf struct kvm_config_tlb { 1073a54fc080SAlexander Graf __u64 params; 1074a54fc080SAlexander Graf __u64 array; 1075a54fc080SAlexander Graf __u32 mmu_type; 1076a54fc080SAlexander Graf __u32 array_len; 1077a54fc080SAlexander Graf }; 1078a54fc080SAlexander Graf 1079a54fc080SAlexander Graf struct kvm_dirty_tlb { 1080a54fc080SAlexander Graf __u64 bitmap; 1081a54fc080SAlexander Graf __u32 num_dirty; 1082a54fc080SAlexander Graf }; 1083a54fc080SAlexander Graf 10849d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 10859d4e4f8cSAlexander Graf 1086a31be480SAlexander Graf #define KVM_REG_ARCH_MASK 0xff00000000000000ULL 1087a31be480SAlexander Graf #define KVM_REG_GENERIC 0x0000000000000000ULL 10889d4e4f8cSAlexander Graf 10899d4e4f8cSAlexander Graf /* 10909d4e4f8cSAlexander Graf * Architecture specific registers are to be defined in arch headers and 10919d4e4f8cSAlexander Graf * ORed with the arch identifier. 10929d4e4f8cSAlexander Graf */ 1093a31be480SAlexander Graf #define KVM_REG_PPC 0x1000000000000000ULL 1094a31be480SAlexander Graf #define KVM_REG_X86 0x2000000000000000ULL 1095a31be480SAlexander Graf #define KVM_REG_IA64 0x3000000000000000ULL 1096a31be480SAlexander Graf #define KVM_REG_ARM 0x4000000000000000ULL 1097a31be480SAlexander Graf #define KVM_REG_S390 0x5000000000000000ULL 1098c5daeae1SAlexey Kardashevskiy #define KVM_REG_ARM64 0x6000000000000000ULL 1099c5daeae1SAlexey Kardashevskiy #define KVM_REG_MIPS 0x7000000000000000ULL 1100a31be480SAlexander Graf 1101a31be480SAlexander Graf #define KVM_REG_SIZE_SHIFT 52 1102a31be480SAlexander Graf #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL 1103a31be480SAlexander Graf #define KVM_REG_SIZE_U8 0x0000000000000000ULL 1104a31be480SAlexander Graf #define KVM_REG_SIZE_U16 0x0010000000000000ULL 1105a31be480SAlexander Graf #define KVM_REG_SIZE_U32 0x0020000000000000ULL 1106a31be480SAlexander Graf #define KVM_REG_SIZE_U64 0x0030000000000000ULL 1107a31be480SAlexander Graf #define KVM_REG_SIZE_U128 0x0040000000000000ULL 1108a31be480SAlexander Graf #define KVM_REG_SIZE_U256 0x0050000000000000ULL 1109a31be480SAlexander Graf #define KVM_REG_SIZE_U512 0x0060000000000000ULL 1110a31be480SAlexander Graf #define KVM_REG_SIZE_U1024 0x0070000000000000ULL 11119d4e4f8cSAlexander Graf 1112eadd0e44SPeter Maydell struct kvm_reg_list { 1113eadd0e44SPeter Maydell __u64 n; /* number of regs */ 1114eadd0e44SPeter Maydell __u64 reg[0]; 1115eadd0e44SPeter Maydell }; 1116eadd0e44SPeter Maydell 11179d4e4f8cSAlexander Graf struct kvm_one_reg { 11189d4e4f8cSAlexander Graf __u64 id; 1119a31be480SAlexander Graf __u64 addr; 11209d4e4f8cSAlexander Graf }; 11219d4e4f8cSAlexander Graf 1122dbdfea92SCornelia Huck #define KVM_MSI_VALID_DEVID (1U << 0) 112380a3eb10SJan Kiszka struct kvm_msi { 112480a3eb10SJan Kiszka __u32 address_lo; 112580a3eb10SJan Kiszka __u32 address_hi; 112680a3eb10SJan Kiszka __u32 data; 112780a3eb10SJan Kiszka __u32 flags; 1128dbdfea92SCornelia Huck __u32 devid; 1129dbdfea92SCornelia Huck __u8 pad[12]; 113080a3eb10SJan Kiszka }; 113180a3eb10SJan Kiszka 1132eadd0e44SPeter Maydell struct kvm_arm_device_addr { 1133eadd0e44SPeter Maydell __u64 id; 1134eadd0e44SPeter Maydell __u64 addr; 1135eadd0e44SPeter Maydell }; 1136eadd0e44SPeter Maydell 113751b24e34SJan Kiszka /* 1138e098b453SAlexey Kardashevskiy * Device control API, available with KVM_CAP_DEVICE_CTRL 1139e098b453SAlexey Kardashevskiy */ 1140e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE_TEST 1 1141e098b453SAlexey Kardashevskiy 1142e098b453SAlexey Kardashevskiy struct kvm_create_device { 1143e098b453SAlexey Kardashevskiy __u32 type; /* in: KVM_DEV_TYPE_xxx */ 1144e098b453SAlexey Kardashevskiy __u32 fd; /* out: device handle */ 1145e098b453SAlexey Kardashevskiy __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */ 1146e098b453SAlexey Kardashevskiy }; 1147e098b453SAlexey Kardashevskiy 1148e098b453SAlexey Kardashevskiy struct kvm_device_attr { 1149e098b453SAlexey Kardashevskiy __u32 flags; /* no flags currently defined */ 1150e098b453SAlexey Kardashevskiy __u32 group; /* device-defined */ 1151e098b453SAlexey Kardashevskiy __u64 attr; /* group-defined */ 1152e098b453SAlexey Kardashevskiy __u64 addr; /* userspace address of attr data */ 1153e098b453SAlexey Kardashevskiy }; 1154e098b453SAlexey Kardashevskiy 1155bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP 1 1156bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP_ADD 1 1157bf63839fSAlex Williamson #define KVM_DEV_VFIO_GROUP_DEL 2 115874c98e20SCornelia Huck #define KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE 3 1159444b1996SArd Biesheuvel 1160444b1996SArd Biesheuvel enum kvm_device_type { 1161444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_20 = 1, 1162444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_20 KVM_DEV_TYPE_FSL_MPIC_20 1163444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_42, 1164444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_42 KVM_DEV_TYPE_FSL_MPIC_42 1165444b1996SArd Biesheuvel KVM_DEV_TYPE_XICS, 1166444b1996SArd Biesheuvel #define KVM_DEV_TYPE_XICS KVM_DEV_TYPE_XICS 1167444b1996SArd Biesheuvel KVM_DEV_TYPE_VFIO, 1168444b1996SArd Biesheuvel #define KVM_DEV_TYPE_VFIO KVM_DEV_TYPE_VFIO 1169444b1996SArd Biesheuvel KVM_DEV_TYPE_ARM_VGIC_V2, 1170444b1996SArd Biesheuvel #define KVM_DEV_TYPE_ARM_VGIC_V2 KVM_DEV_TYPE_ARM_VGIC_V2 1171444b1996SArd Biesheuvel KVM_DEV_TYPE_FLIC, 1172444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_FLIC 117351628b18SChristian Borntraeger KVM_DEV_TYPE_ARM_VGIC_V3, 117451628b18SChristian Borntraeger #define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3 1175dbdfea92SCornelia Huck KVM_DEV_TYPE_ARM_VGIC_ITS, 1176dbdfea92SCornelia Huck #define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS 1177444b1996SArd Biesheuvel KVM_DEV_TYPE_MAX, 1178444b1996SArd Biesheuvel }; 1179e098b453SAlexey Kardashevskiy 118074c98e20SCornelia Huck struct kvm_vfio_spapr_tce { 118174c98e20SCornelia Huck __s32 groupfd; 118274c98e20SCornelia Huck __s32 tablefd; 118374c98e20SCornelia Huck }; 118474c98e20SCornelia Huck 1185e098b453SAlexey Kardashevskiy /* 118651b24e34SJan Kiszka * ioctls for VM fds 118751b24e34SJan Kiszka */ 118851b24e34SJan Kiszka #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) 118951b24e34SJan Kiszka /* 119051b24e34SJan Kiszka * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns 119151b24e34SJan Kiszka * a vcpu fd. 119251b24e34SJan Kiszka */ 119351b24e34SJan Kiszka #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) 119451b24e34SJan Kiszka #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) 119551b24e34SJan Kiszka /* KVM_SET_MEMORY_ALIAS is obsolete: */ 119651b24e34SJan Kiszka #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) 119751b24e34SJan Kiszka #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) 119851b24e34SJan Kiszka #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) 119951b24e34SJan Kiszka #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ 120051b24e34SJan Kiszka struct kvm_userspace_memory_region) 120151b24e34SJan Kiszka #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) 120251b24e34SJan Kiszka #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64) 12031529ae1bSAlexander Graf 12041529ae1bSAlexander Graf /* enable ucontrol for s390 */ 12051529ae1bSAlexander Graf struct kvm_s390_ucas_mapping { 12061529ae1bSAlexander Graf __u64 user_addr; 12071529ae1bSAlexander Graf __u64 vcpu_addr; 12081529ae1bSAlexander Graf __u64 length; 12091529ae1bSAlexander Graf }; 12101529ae1bSAlexander Graf #define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping) 12111529ae1bSAlexander Graf #define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping) 12121529ae1bSAlexander Graf #define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long) 12131529ae1bSAlexander Graf 121451b24e34SJan Kiszka /* Device model IOC */ 121551b24e34SJan Kiszka #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) 121651b24e34SJan Kiszka #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) 121751b24e34SJan Kiszka #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) 121851b24e34SJan Kiszka #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) 121951b24e34SJan Kiszka #define KVM_CREATE_PIT _IO(KVMIO, 0x64) 122051b24e34SJan Kiszka #define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state) 122151b24e34SJan Kiszka #define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state) 122251b24e34SJan Kiszka #define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level) 122351b24e34SJan Kiszka #define KVM_REGISTER_COALESCED_MMIO \ 122451b24e34SJan Kiszka _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone) 122551b24e34SJan Kiszka #define KVM_UNREGISTER_COALESCED_MMIO \ 122651b24e34SJan Kiszka _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone) 122751b24e34SJan Kiszka #define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \ 122851b24e34SJan Kiszka struct kvm_assigned_pci_dev) 122951b24e34SJan Kiszka #define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing) 123051b24e34SJan Kiszka /* deprecated, replaced by KVM_ASSIGN_DEV_IRQ */ 123151b24e34SJan Kiszka #define KVM_ASSIGN_IRQ __KVM_DEPRECATED_VM_R_0x70 123251b24e34SJan Kiszka #define KVM_ASSIGN_DEV_IRQ _IOW(KVMIO, 0x70, struct kvm_assigned_irq) 123351b24e34SJan Kiszka #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71) 123451b24e34SJan Kiszka #define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, \ 123551b24e34SJan Kiszka struct kvm_assigned_pci_dev) 123651b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_NR _IOW(KVMIO, 0x73, \ 123751b24e34SJan Kiszka struct kvm_assigned_msix_nr) 123851b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO, 0x74, \ 123951b24e34SJan Kiszka struct kvm_assigned_msix_entry) 124051b24e34SJan Kiszka #define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq) 124151b24e34SJan Kiszka #define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd) 124251b24e34SJan Kiszka #define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config) 124351b24e34SJan Kiszka #define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78) 124451b24e34SJan Kiszka #define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd) 124551b24e34SJan Kiszka #define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config) 124651b24e34SJan Kiszka #define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data) 124751b24e34SJan Kiszka #define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data) 124851b24e34SJan Kiszka /* Available with KVM_CAP_PIT_STATE2 */ 124951b24e34SJan Kiszka #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) 125051b24e34SJan Kiszka #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) 125151b24e34SJan Kiszka /* Available with KVM_CAP_PPC_GET_PVINFO */ 125251b24e34SJan Kiszka #define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo) 125351b24e34SJan Kiszka /* Available with KVM_CAP_TSC_CONTROL */ 125451b24e34SJan Kiszka #define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2) 125551b24e34SJan Kiszka #define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3) 12569ab2195dSMarcelo Tosatti /* Available with KVM_CAP_PCI_2_3 */ 12579ab2195dSMarcelo Tosatti #define KVM_ASSIGN_SET_INTX_MASK _IOW(KVMIO, 0xa4, \ 12589ab2195dSMarcelo Tosatti struct kvm_assigned_pci_dev) 125980a3eb10SJan Kiszka /* Available with KVM_CAP_SIGNAL_MSI */ 126080a3eb10SJan Kiszka #define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi) 126180a3eb10SJan Kiszka /* Available with KVM_CAP_PPC_GET_SMMU_INFO */ 126280a3eb10SJan Kiszka #define KVM_PPC_GET_SMMU_INFO _IOR(KVMIO, 0xa6, struct kvm_ppc_smmu_info) 1263651682dcSMichael S. Tsirkin /* Available with KVM_CAP_PPC_ALLOC_HTAB */ 1264651682dcSMichael S. Tsirkin #define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32) 1265d4834ff9SAlexander Graf #define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce) 1266b89485a5SPaolo Bonzini #define KVM_CREATE_SPAPR_TCE_64 _IOW(KVMIO, 0xa8, \ 1267b89485a5SPaolo Bonzini struct kvm_create_spapr_tce_64) 1268d4834ff9SAlexander Graf /* Available with KVM_CAP_RMA */ 1269d4834ff9SAlexander Graf #define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma) 1270d4834ff9SAlexander Graf /* Available with KVM_CAP_PPC_HTAB_FD */ 1271d4834ff9SAlexander Graf #define KVM_PPC_GET_HTAB_FD _IOW(KVMIO, 0xaa, struct kvm_get_htab_fd) 1272eadd0e44SPeter Maydell /* Available with KVM_CAP_ARM_SET_DEVICE_ADDR */ 1273eadd0e44SPeter Maydell #define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr) 1274e098b453SAlexey Kardashevskiy /* Available with KVM_CAP_PPC_RTAS */ 1275e098b453SAlexey Kardashevskiy #define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args) 12763a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_SPAPR_RESIZE_HPT */ 12773a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt) 12783a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt) 12793a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */ 12803a5eb5b4SPaolo Bonzini #define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg) 12813a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_PPC_RADIX_MMU */ 12823a5eb5b4SPaolo Bonzini #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info) 12839cbb6362SCornelia Huck /* Available with KVM_CAP_PPC_GET_CPU_CHAR */ 12849cbb6362SCornelia Huck #define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char) 1285e098b453SAlexey Kardashevskiy 1286e098b453SAlexey Kardashevskiy /* ioctl for vm fd */ 1287e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) 1288e098b453SAlexey Kardashevskiy 1289e098b453SAlexey Kardashevskiy /* ioctls for fds returned by KVM_CREATE_DEVICE */ 1290e098b453SAlexey Kardashevskiy #define KVM_SET_DEVICE_ATTR _IOW(KVMIO, 0xe1, struct kvm_device_attr) 1291e098b453SAlexey Kardashevskiy #define KVM_GET_DEVICE_ATTR _IOW(KVMIO, 0xe2, struct kvm_device_attr) 1292e098b453SAlexey Kardashevskiy #define KVM_HAS_DEVICE_ATTR _IOW(KVMIO, 0xe3, struct kvm_device_attr) 129351b24e34SJan Kiszka 129451b24e34SJan Kiszka /* 129551b24e34SJan Kiszka * ioctls for vcpu fds 129651b24e34SJan Kiszka */ 129751b24e34SJan Kiszka #define KVM_RUN _IO(KVMIO, 0x80) 129851b24e34SJan Kiszka #define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs) 129951b24e34SJan Kiszka #define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs) 130051b24e34SJan Kiszka #define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs) 130151b24e34SJan Kiszka #define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs) 130251b24e34SJan Kiszka #define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation) 130351b24e34SJan Kiszka #define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt) 130451b24e34SJan Kiszka /* KVM_DEBUG_GUEST is no longer supported, use KVM_SET_GUEST_DEBUG instead */ 130551b24e34SJan Kiszka #define KVM_DEBUG_GUEST __KVM_DEPRECATED_VCPU_W_0x87 130651b24e34SJan Kiszka #define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs) 130751b24e34SJan Kiszka #define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs) 130851b24e34SJan Kiszka #define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid) 130951b24e34SJan Kiszka #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask) 131051b24e34SJan Kiszka #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu) 131151b24e34SJan Kiszka #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) 131251b24e34SJan Kiszka #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) 131351b24e34SJan Kiszka #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) 131451b24e34SJan Kiszka #define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) 131551b24e34SJan Kiszka #define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2) 131651b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 131751b24e34SJan Kiszka #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl) 131851b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 131951b24e34SJan Kiszka #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) 132051b24e34SJan Kiszka /* valid for virtual machine (for floating interrupt)_and_ vcpu */ 132151b24e34SJan Kiszka #define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt) 132251b24e34SJan Kiszka /* store status for s390 */ 132351b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_NOADDR (-1ul) 132451b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_PREFIXED (-2ul) 132551b24e34SJan Kiszka #define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long) 132651b24e34SJan Kiszka /* initial ipl psw for s390 */ 132751b24e34SJan Kiszka #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw) 132851b24e34SJan Kiszka /* initial reset for s390 */ 132951b24e34SJan Kiszka #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) 133051b24e34SJan Kiszka #define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) 133151b24e34SJan Kiszka #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) 1332444b1996SArd Biesheuvel /* Available with KVM_CAP_USER_NMI */ 133351b24e34SJan Kiszka #define KVM_NMI _IO(KVMIO, 0x9a) 133451b24e34SJan Kiszka /* Available with KVM_CAP_SET_GUEST_DEBUG */ 133551b24e34SJan Kiszka #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) 133651b24e34SJan Kiszka /* MCE for x86 */ 133751b24e34SJan Kiszka #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64) 133851b24e34SJan Kiszka #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64) 133951b24e34SJan Kiszka #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) 134051b24e34SJan Kiszka /* Available with KVM_CAP_VCPU_EVENTS */ 134151b24e34SJan Kiszka #define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events) 134251b24e34SJan Kiszka #define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events) 134351b24e34SJan Kiszka /* Available with KVM_CAP_DEBUGREGS */ 134451b24e34SJan Kiszka #define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs) 134551b24e34SJan Kiszka #define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs) 13469ffd2685SCornelia Huck /* 13479ffd2685SCornelia Huck * vcpu version available with KVM_ENABLE_CAP 13489ffd2685SCornelia Huck * vm version available with KVM_CAP_ENABLE_CAP_VM 13499ffd2685SCornelia Huck */ 135051b24e34SJan Kiszka #define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap) 135151b24e34SJan Kiszka /* Available with KVM_CAP_XSAVE */ 135251b24e34SJan Kiszka #define KVM_GET_XSAVE _IOR(KVMIO, 0xa4, struct kvm_xsave) 135351b24e34SJan Kiszka #define KVM_SET_XSAVE _IOW(KVMIO, 0xa5, struct kvm_xsave) 135451b24e34SJan Kiszka /* Available with KVM_CAP_XCRS */ 135551b24e34SJan Kiszka #define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs) 135651b24e34SJan Kiszka #define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs) 1357a54fc080SAlexander Graf /* Available with KVM_CAP_SW_TLB */ 1358a54fc080SAlexander Graf #define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb) 13599d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 1360a31be480SAlexander Graf #define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg) 13619d4e4f8cSAlexander Graf #define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg) 13629ab2195dSMarcelo Tosatti /* VM is being stopped by host */ 13639ab2195dSMarcelo Tosatti #define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad) 1364eadd0e44SPeter Maydell #define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init) 1365bf63839fSAlex Williamson #define KVM_ARM_PREFERRED_TARGET _IOR(KVMIO, 0xaf, struct kvm_vcpu_init) 1366eadd0e44SPeter Maydell #define KVM_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list) 13677a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_MEM_OP */ 13687a52ce8aSCornelia Huck #define KVM_S390_MEM_OP _IOW(KVMIO, 0xb1, struct kvm_s390_mem_op) 13697a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_SKEYS */ 13707a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS _IOW(KVMIO, 0xb2, struct kvm_s390_skeys) 13717a52ce8aSCornelia Huck #define KVM_S390_SET_SKEYS _IOW(KVMIO, 0xb3, struct kvm_s390_skeys) 13727a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_INJECT_IRQ */ 13737a52ce8aSCornelia Huck #define KVM_S390_IRQ _IOW(KVMIO, 0xb4, struct kvm_s390_irq) 13747a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_IRQ_STATE */ 13757a52ce8aSCornelia Huck #define KVM_S390_SET_IRQ_STATE _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state) 13767a52ce8aSCornelia Huck #define KVM_S390_GET_IRQ_STATE _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state) 137724a31426SPaolo Bonzini /* Available with KVM_CAP_X86_SMM */ 137824a31426SPaolo Bonzini #define KVM_SMI _IO(KVMIO, 0xb7) 13793272f0e2SChristian Borntraeger /* Available with KVM_CAP_S390_CMMA_MIGRATION */ 1380ab6e1550SChristian Borntraeger #define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log) 13813272f0e2SChristian Borntraeger #define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log) 13829f2d175dSPaolo Bonzini /* Memory Encryption Commands */ 13839f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_OP _IOWR(KVMIO, 0xba, unsigned long) 13849f2d175dSPaolo Bonzini 13859f2d175dSPaolo Bonzini struct kvm_enc_region { 13869f2d175dSPaolo Bonzini __u64 addr; 13879f2d175dSPaolo Bonzini __u64 size; 13889f2d175dSPaolo Bonzini }; 13899f2d175dSPaolo Bonzini 13909f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_REG_REGION _IOR(KVMIO, 0xbb, struct kvm_enc_region) 13919f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_UNREG_REGION _IOR(KVMIO, 0xbc, struct kvm_enc_region) 13929f2d175dSPaolo Bonzini 139365a6d8ddSPeter Maydell /* Available with KVM_CAP_HYPERV_EVENTFD */ 139465a6d8ddSPeter Maydell #define KVM_HYPERV_EVENTFD _IOW(KVMIO, 0xbd, struct kvm_hyperv_eventfd) 139565a6d8ddSPeter Maydell 1396*d36f7de8SCornelia Huck /* Available with KVM_CAP_NESTED_STATE */ 1397*d36f7de8SCornelia Huck #define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state) 1398*d36f7de8SCornelia Huck #define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state) 139965a6d8ddSPeter Maydell 14009f2d175dSPaolo Bonzini /* Secure Encrypted Virtualization command */ 14019f2d175dSPaolo Bonzini enum sev_cmd_id { 14029f2d175dSPaolo Bonzini /* Guest initialization commands */ 14039f2d175dSPaolo Bonzini KVM_SEV_INIT = 0, 14049f2d175dSPaolo Bonzini KVM_SEV_ES_INIT, 14059f2d175dSPaolo Bonzini /* Guest launch commands */ 14069f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_START, 14079f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_UPDATE_DATA, 14089f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_UPDATE_VMSA, 14099f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_SECRET, 14109f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_MEASURE, 14119f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_FINISH, 14129f2d175dSPaolo Bonzini /* Guest migration commands (outgoing) */ 14139f2d175dSPaolo Bonzini KVM_SEV_SEND_START, 14149f2d175dSPaolo Bonzini KVM_SEV_SEND_UPDATE_DATA, 14159f2d175dSPaolo Bonzini KVM_SEV_SEND_UPDATE_VMSA, 14169f2d175dSPaolo Bonzini KVM_SEV_SEND_FINISH, 14179f2d175dSPaolo Bonzini /* Guest migration commands (incoming) */ 14189f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_START, 14199f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_UPDATE_DATA, 14209f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_UPDATE_VMSA, 14219f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_FINISH, 14229f2d175dSPaolo Bonzini /* Guest status and debug commands */ 14239f2d175dSPaolo Bonzini KVM_SEV_GUEST_STATUS, 14249f2d175dSPaolo Bonzini KVM_SEV_DBG_DECRYPT, 14259f2d175dSPaolo Bonzini KVM_SEV_DBG_ENCRYPT, 14269f2d175dSPaolo Bonzini /* Guest certificates commands */ 14279f2d175dSPaolo Bonzini KVM_SEV_CERT_EXPORT, 14289f2d175dSPaolo Bonzini 14299f2d175dSPaolo Bonzini KVM_SEV_NR_MAX, 14309f2d175dSPaolo Bonzini }; 14319f2d175dSPaolo Bonzini 14329f2d175dSPaolo Bonzini struct kvm_sev_cmd { 14339f2d175dSPaolo Bonzini __u32 id; 14349f2d175dSPaolo Bonzini __u64 data; 14359f2d175dSPaolo Bonzini __u32 error; 14369f2d175dSPaolo Bonzini __u32 sev_fd; 14379f2d175dSPaolo Bonzini }; 14389f2d175dSPaolo Bonzini 14399f2d175dSPaolo Bonzini struct kvm_sev_launch_start { 14409f2d175dSPaolo Bonzini __u32 handle; 14419f2d175dSPaolo Bonzini __u32 policy; 14429f2d175dSPaolo Bonzini __u64 dh_uaddr; 14439f2d175dSPaolo Bonzini __u32 dh_len; 14449f2d175dSPaolo Bonzini __u64 session_uaddr; 14459f2d175dSPaolo Bonzini __u32 session_len; 14469f2d175dSPaolo Bonzini }; 14479f2d175dSPaolo Bonzini 14489f2d175dSPaolo Bonzini struct kvm_sev_launch_update_data { 14499f2d175dSPaolo Bonzini __u64 uaddr; 14509f2d175dSPaolo Bonzini __u32 len; 14519f2d175dSPaolo Bonzini }; 14529f2d175dSPaolo Bonzini 14539f2d175dSPaolo Bonzini 14549f2d175dSPaolo Bonzini struct kvm_sev_launch_secret { 14559f2d175dSPaolo Bonzini __u64 hdr_uaddr; 14569f2d175dSPaolo Bonzini __u32 hdr_len; 14579f2d175dSPaolo Bonzini __u64 guest_uaddr; 14589f2d175dSPaolo Bonzini __u32 guest_len; 14599f2d175dSPaolo Bonzini __u64 trans_uaddr; 14609f2d175dSPaolo Bonzini __u32 trans_len; 14619f2d175dSPaolo Bonzini }; 14629f2d175dSPaolo Bonzini 14639f2d175dSPaolo Bonzini struct kvm_sev_launch_measure { 14649f2d175dSPaolo Bonzini __u64 uaddr; 14659f2d175dSPaolo Bonzini __u32 len; 14669f2d175dSPaolo Bonzini }; 14679f2d175dSPaolo Bonzini 14689f2d175dSPaolo Bonzini struct kvm_sev_guest_status { 14699f2d175dSPaolo Bonzini __u32 handle; 14709f2d175dSPaolo Bonzini __u32 policy; 14719f2d175dSPaolo Bonzini __u32 state; 14729f2d175dSPaolo Bonzini }; 14739f2d175dSPaolo Bonzini 14749f2d175dSPaolo Bonzini struct kvm_sev_dbg { 14759f2d175dSPaolo Bonzini __u64 src_uaddr; 14769f2d175dSPaolo Bonzini __u64 dst_uaddr; 14779f2d175dSPaolo Bonzini __u32 len; 14789f2d175dSPaolo Bonzini }; 147951b24e34SJan Kiszka 148051b24e34SJan Kiszka #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) 14819ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) 14829ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2) 148351b24e34SJan Kiszka 148451b24e34SJan Kiszka struct kvm_assigned_pci_dev { 148551b24e34SJan Kiszka __u32 assigned_dev_id; 148651b24e34SJan Kiszka __u32 busnr; 148751b24e34SJan Kiszka __u32 devfn; 148851b24e34SJan Kiszka __u32 flags; 148951b24e34SJan Kiszka __u32 segnr; 149051b24e34SJan Kiszka union { 149151b24e34SJan Kiszka __u32 reserved[11]; 149251b24e34SJan Kiszka }; 149351b24e34SJan Kiszka }; 149451b24e34SJan Kiszka 149551b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_INTX (1 << 0) 149651b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSI (1 << 1) 149751b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSIX (1 << 2) 149851b24e34SJan Kiszka 149951b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_INTX (1 << 8) 150051b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSI (1 << 9) 150151b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10) 150251b24e34SJan Kiszka 150351b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MASK 0x00ff 150451b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MASK 0xff00 150551b24e34SJan Kiszka 150651b24e34SJan Kiszka struct kvm_assigned_irq { 150751b24e34SJan Kiszka __u32 assigned_dev_id; 15087c6da3deSAlexander Graf __u32 host_irq; /* ignored (legacy field) */ 150951b24e34SJan Kiszka __u32 guest_irq; 151051b24e34SJan Kiszka __u32 flags; 151151b24e34SJan Kiszka union { 151251b24e34SJan Kiszka __u32 reserved[12]; 151351b24e34SJan Kiszka }; 151451b24e34SJan Kiszka }; 151551b24e34SJan Kiszka 151651b24e34SJan Kiszka struct kvm_assigned_msix_nr { 151751b24e34SJan Kiszka __u32 assigned_dev_id; 151851b24e34SJan Kiszka __u16 entry_nr; 151951b24e34SJan Kiszka __u16 padding; 152051b24e34SJan Kiszka }; 152151b24e34SJan Kiszka 152251b24e34SJan Kiszka #define KVM_MAX_MSIX_PER_DEV 256 152351b24e34SJan Kiszka struct kvm_assigned_msix_entry { 152451b24e34SJan Kiszka __u32 assigned_dev_id; 152551b24e34SJan Kiszka __u32 gsi; 152651b24e34SJan Kiszka __u16 entry; /* The index of entry in the MSI-X table */ 152751b24e34SJan Kiszka __u16 padding[3]; 152851b24e34SJan Kiszka }; 152951b24e34SJan Kiszka 1530dbdfea92SCornelia Huck #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0) 1531dbdfea92SCornelia Huck #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) 1532dbdfea92SCornelia Huck 153374c98e20SCornelia Huck /* Available with KVM_CAP_ARM_USER_IRQ */ 153474c98e20SCornelia Huck 153574c98e20SCornelia Huck /* Bits for run->s.regs.device_irq_level */ 153674c98e20SCornelia Huck #define KVM_ARM_DEV_EL1_VTIMER (1 << 0) 153774c98e20SCornelia Huck #define KVM_ARM_DEV_EL1_PTIMER (1 << 1) 153874c98e20SCornelia Huck #define KVM_ARM_DEV_PMU (1 << 2) 153974c98e20SCornelia Huck 154065a6d8ddSPeter Maydell struct kvm_hyperv_eventfd { 154165a6d8ddSPeter Maydell __u32 conn_id; 154265a6d8ddSPeter Maydell __s32 fd; 154365a6d8ddSPeter Maydell __u32 flags; 154465a6d8ddSPeter Maydell __u32 padding[3]; 154565a6d8ddSPeter Maydell }; 154665a6d8ddSPeter Maydell 154765a6d8ddSPeter Maydell #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff 154865a6d8ddSPeter Maydell #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0) 154965a6d8ddSPeter Maydell 155051b24e34SJan Kiszka #endif /* __LINUX_KVM_H */ 1551