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 11278f064eSEduardo Habkost #include <linux/const.h> 1251b24e34SJan Kiszka #include <linux/types.h> 1351b24e34SJan Kiszka 1451b24e34SJan Kiszka #include <linux/ioctl.h> 1551b24e34SJan Kiszka #include <asm/kvm.h> 1651b24e34SJan Kiszka 1751b24e34SJan Kiszka #define KVM_API_VERSION 12 1851b24e34SJan Kiszka 1951b24e34SJan Kiszka /* *** Deprecated interfaces *** */ 2051b24e34SJan Kiszka 2151b24e34SJan Kiszka #define KVM_TRC_SHIFT 16 2251b24e34SJan Kiszka 2351b24e34SJan Kiszka #define KVM_TRC_ENTRYEXIT (1 << KVM_TRC_SHIFT) 2451b24e34SJan Kiszka #define KVM_TRC_HANDLER (1 << (KVM_TRC_SHIFT + 1)) 2551b24e34SJan Kiszka 2651b24e34SJan Kiszka #define KVM_TRC_VMENTRY (KVM_TRC_ENTRYEXIT + 0x01) 2751b24e34SJan Kiszka #define KVM_TRC_VMEXIT (KVM_TRC_ENTRYEXIT + 0x02) 2851b24e34SJan Kiszka #define KVM_TRC_PAGE_FAULT (KVM_TRC_HANDLER + 0x01) 2951b24e34SJan Kiszka 3051b24e34SJan Kiszka #define KVM_TRC_HEAD_SIZE 12 3151b24e34SJan Kiszka #define KVM_TRC_CYCLE_SIZE 8 3251b24e34SJan Kiszka #define KVM_TRC_EXTRA_MAX 7 3351b24e34SJan Kiszka 3451b24e34SJan Kiszka #define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02) 3551b24e34SJan Kiszka #define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03) 3651b24e34SJan Kiszka #define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04) 3751b24e34SJan Kiszka #define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05) 3851b24e34SJan Kiszka #define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06) 3951b24e34SJan Kiszka #define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07) 4051b24e34SJan Kiszka #define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08) 4151b24e34SJan Kiszka #define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09) 4251b24e34SJan Kiszka #define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A) 4351b24e34SJan Kiszka #define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B) 4451b24e34SJan Kiszka #define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C) 4551b24e34SJan Kiszka #define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D) 4651b24e34SJan Kiszka #define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E) 4751b24e34SJan Kiszka #define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F) 4851b24e34SJan Kiszka #define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10) 4951b24e34SJan Kiszka #define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11) 5051b24e34SJan Kiszka #define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12) 5151b24e34SJan Kiszka #define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13) 5251b24e34SJan Kiszka #define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14) 5351b24e34SJan Kiszka #define KVM_TRC_TDP_FAULT (KVM_TRC_HANDLER + 0x15) 5451b24e34SJan Kiszka #define KVM_TRC_GTLB_WRITE (KVM_TRC_HANDLER + 0x16) 5551b24e34SJan Kiszka #define KVM_TRC_STLB_WRITE (KVM_TRC_HANDLER + 0x17) 5651b24e34SJan Kiszka #define KVM_TRC_STLB_INVAL (KVM_TRC_HANDLER + 0x18) 5751b24e34SJan Kiszka #define KVM_TRC_PPC_INSTR (KVM_TRC_HANDLER + 0x19) 5851b24e34SJan Kiszka 5951b24e34SJan Kiszka struct kvm_user_trace_setup { 6051b24e34SJan Kiszka __u32 buf_size; 6151b24e34SJan Kiszka __u32 buf_nr; 6251b24e34SJan Kiszka }; 6351b24e34SJan Kiszka 6451b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_W_0x06 \ 6551b24e34SJan Kiszka _IOW(KVMIO, 0x06, struct kvm_user_trace_setup) 6651b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_0x07 _IO(KVMIO, 0x07) 6751b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_0x08 _IO(KVMIO, 0x08) 6851b24e34SJan Kiszka 6951b24e34SJan Kiszka #define __KVM_DEPRECATED_VM_R_0x70 _IOR(KVMIO, 0x70, struct kvm_assigned_irq) 7051b24e34SJan Kiszka 7151b24e34SJan Kiszka struct kvm_breakpoint { 7251b24e34SJan Kiszka __u32 enabled; 7351b24e34SJan Kiszka __u32 padding; 7451b24e34SJan Kiszka __u64 address; 7551b24e34SJan Kiszka }; 7651b24e34SJan Kiszka 7751b24e34SJan Kiszka struct kvm_debug_guest { 7851b24e34SJan Kiszka __u32 enabled; 7951b24e34SJan Kiszka __u32 pad; 8051b24e34SJan Kiszka struct kvm_breakpoint breakpoints[4]; 8151b24e34SJan Kiszka __u32 singlestep; 8251b24e34SJan Kiszka }; 8351b24e34SJan Kiszka 8451b24e34SJan Kiszka #define __KVM_DEPRECATED_VCPU_W_0x87 _IOW(KVMIO, 0x87, struct kvm_debug_guest) 8551b24e34SJan Kiszka 8651b24e34SJan Kiszka /* *** End of deprecated interfaces *** */ 8751b24e34SJan Kiszka 8851b24e34SJan Kiszka 8951b24e34SJan Kiszka /* for KVM_SET_USER_MEMORY_REGION */ 9051b24e34SJan Kiszka struct kvm_userspace_memory_region { 9151b24e34SJan Kiszka __u32 slot; 9251b24e34SJan Kiszka __u32 flags; 9351b24e34SJan Kiszka __u64 guest_phys_addr; 9451b24e34SJan Kiszka __u64 memory_size; /* bytes */ 9551b24e34SJan Kiszka __u64 userspace_addr; /* start of the userspace allocated memory */ 9651b24e34SJan Kiszka }; 9751b24e34SJan Kiszka 98716b8e4dSAlex Williamson /* 9993d7620cSAvihai Horon * The bit 0 ~ bit 15 of kvm_userspace_memory_region::flags are visible for 10093d7620cSAvihai Horon * userspace, other bits are reserved for kvm internal use which are defined 10193d7620cSAvihai Horon * in include/linux/kvm_host.h. 102716b8e4dSAlex Williamson */ 103716b8e4dSAlex Williamson #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) 104716b8e4dSAlex Williamson #define KVM_MEM_READONLY (1UL << 1) 10551b24e34SJan Kiszka 10651b24e34SJan Kiszka /* for KVM_IRQ_LINE */ 10751b24e34SJan Kiszka struct kvm_irq_level { 10851b24e34SJan Kiszka /* 10951b24e34SJan Kiszka * ACPI gsi notion of irq. 11051b24e34SJan Kiszka * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47.. 11151b24e34SJan Kiszka * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23.. 112f76b348eSCornelia Huck * For ARM: See Documentation/virt/kvm/api.rst 11351b24e34SJan Kiszka */ 11451b24e34SJan Kiszka union { 11551b24e34SJan Kiszka __u32 irq; 11651b24e34SJan Kiszka __s32 status; 11751b24e34SJan Kiszka }; 11851b24e34SJan Kiszka __u32 level; 11951b24e34SJan Kiszka }; 12051b24e34SJan Kiszka 12151b24e34SJan Kiszka 12251b24e34SJan Kiszka struct kvm_irqchip { 12351b24e34SJan Kiszka __u32 chip_id; 12451b24e34SJan Kiszka __u32 pad; 12551b24e34SJan Kiszka union { 12651b24e34SJan Kiszka char dummy[512]; /* reserving space */ 12751b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 12851b24e34SJan Kiszka struct kvm_pic_state pic; 12951b24e34SJan Kiszka #endif 13051b24e34SJan Kiszka #ifdef __KVM_HAVE_IOAPIC 13151b24e34SJan Kiszka struct kvm_ioapic_state ioapic; 13251b24e34SJan Kiszka #endif 13351b24e34SJan Kiszka } chip; 13451b24e34SJan Kiszka }; 13551b24e34SJan Kiszka 13651b24e34SJan Kiszka /* for KVM_CREATE_PIT2 */ 13751b24e34SJan Kiszka struct kvm_pit_config { 13851b24e34SJan Kiszka __u32 flags; 13951b24e34SJan Kiszka __u32 pad[15]; 14051b24e34SJan Kiszka }; 14151b24e34SJan Kiszka 14251b24e34SJan Kiszka #define KVM_PIT_SPEAKER_DUMMY 1 14351b24e34SJan Kiszka 1447a52ce8aSCornelia Huck struct kvm_s390_skeys { 1457a52ce8aSCornelia Huck __u64 start_gfn; 1467a52ce8aSCornelia Huck __u64 count; 1477a52ce8aSCornelia Huck __u64 skeydata_addr; 1487a52ce8aSCornelia Huck __u32 flags; 1497a52ce8aSCornelia Huck __u32 reserved[9]; 1507a52ce8aSCornelia Huck }; 151fff02bc0SPaolo Bonzini 1523272f0e2SChristian Borntraeger #define KVM_S390_CMMA_PEEK (1 << 0) 1533272f0e2SChristian Borntraeger 1543272f0e2SChristian Borntraeger /** 1553272f0e2SChristian Borntraeger * kvm_s390_cmma_log - Used for CMMA migration. 1563272f0e2SChristian Borntraeger * 1573272f0e2SChristian Borntraeger * Used both for input and output. 1583272f0e2SChristian Borntraeger * 1593272f0e2SChristian Borntraeger * @start_gfn: Guest page number to start from. 1603272f0e2SChristian Borntraeger * @count: Size of the result buffer. 1613272f0e2SChristian Borntraeger * @flags: Control operation mode via KVM_S390_CMMA_* flags 1623272f0e2SChristian Borntraeger * @remaining: Used with KVM_S390_GET_CMMA_BITS. Indicates how many dirty 1633272f0e2SChristian Borntraeger * pages are still remaining. 1643272f0e2SChristian Borntraeger * @mask: Used with KVM_S390_SET_CMMA_BITS. Bitmap of bits to actually set 1653272f0e2SChristian Borntraeger * in the PGSTE. 1663272f0e2SChristian Borntraeger * @values: Pointer to the values buffer. 1673272f0e2SChristian Borntraeger * 1683272f0e2SChristian Borntraeger * Used in KVM_S390_{G,S}ET_CMMA_BITS ioctls. 1693272f0e2SChristian Borntraeger */ 1703272f0e2SChristian Borntraeger struct kvm_s390_cmma_log { 1713272f0e2SChristian Borntraeger __u64 start_gfn; 1723272f0e2SChristian Borntraeger __u32 count; 1733272f0e2SChristian Borntraeger __u32 flags; 1743272f0e2SChristian Borntraeger union { 1753272f0e2SChristian Borntraeger __u64 remaining; 1763272f0e2SChristian Borntraeger __u64 mask; 1773272f0e2SChristian Borntraeger }; 1783272f0e2SChristian Borntraeger __u64 values; 1793272f0e2SChristian Borntraeger }; 1803272f0e2SChristian Borntraeger 181fff02bc0SPaolo Bonzini struct kvm_hyperv_exit { 182fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV_SYNIC 1 183b89485a5SPaolo Bonzini #define KVM_EXIT_HYPERV_HCALL 2 184f76b348eSCornelia Huck #define KVM_EXIT_HYPERV_SYNDBG 3 185fff02bc0SPaolo Bonzini __u32 type; 186f76b348eSCornelia Huck __u32 pad1; 187fff02bc0SPaolo Bonzini union { 188fff02bc0SPaolo Bonzini struct { 189fff02bc0SPaolo Bonzini __u32 msr; 190f76b348eSCornelia Huck __u32 pad2; 191fff02bc0SPaolo Bonzini __u64 control; 192fff02bc0SPaolo Bonzini __u64 evt_page; 193fff02bc0SPaolo Bonzini __u64 msg_page; 194fff02bc0SPaolo Bonzini } synic; 195b89485a5SPaolo Bonzini struct { 196b89485a5SPaolo Bonzini __u64 input; 197b89485a5SPaolo Bonzini __u64 result; 198b89485a5SPaolo Bonzini __u64 params[2]; 199b89485a5SPaolo Bonzini } hcall; 200f76b348eSCornelia Huck struct { 201f76b348eSCornelia Huck __u32 msr; 202f76b348eSCornelia Huck __u32 pad2; 203f76b348eSCornelia Huck __u64 control; 204f76b348eSCornelia Huck __u64 status; 205f76b348eSCornelia Huck __u64 send_page; 206f76b348eSCornelia Huck __u64 recv_page; 207f76b348eSCornelia Huck __u64 pending_page; 208f76b348eSCornelia Huck } syndbg; 209fff02bc0SPaolo Bonzini } u; 210fff02bc0SPaolo Bonzini }; 211fff02bc0SPaolo Bonzini 212278f064eSEduardo Habkost struct kvm_xen_exit { 213278f064eSEduardo Habkost #define KVM_EXIT_XEN_HCALL 1 214278f064eSEduardo Habkost __u32 type; 215278f064eSEduardo Habkost union { 216278f064eSEduardo Habkost struct { 217278f064eSEduardo Habkost __u32 longmode; 218278f064eSEduardo Habkost __u32 cpl; 219278f064eSEduardo Habkost __u64 input; 220278f064eSEduardo Habkost __u64 result; 221278f064eSEduardo Habkost __u64 params[6]; 222278f064eSEduardo Habkost } hcall; 223278f064eSEduardo Habkost } u; 224278f064eSEduardo Habkost }; 225278f064eSEduardo Habkost 2267a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS_NONE 1 2277a52ce8aSCornelia Huck #define KVM_S390_SKEYS_MAX 1048576 2287a52ce8aSCornelia Huck 22951b24e34SJan Kiszka #define KVM_EXIT_UNKNOWN 0 23051b24e34SJan Kiszka #define KVM_EXIT_EXCEPTION 1 23151b24e34SJan Kiszka #define KVM_EXIT_IO 2 23251b24e34SJan Kiszka #define KVM_EXIT_HYPERCALL 3 23351b24e34SJan Kiszka #define KVM_EXIT_DEBUG 4 23451b24e34SJan Kiszka #define KVM_EXIT_HLT 5 23551b24e34SJan Kiszka #define KVM_EXIT_MMIO 6 23651b24e34SJan Kiszka #define KVM_EXIT_IRQ_WINDOW_OPEN 7 23751b24e34SJan Kiszka #define KVM_EXIT_SHUTDOWN 8 23851b24e34SJan Kiszka #define KVM_EXIT_FAIL_ENTRY 9 23951b24e34SJan Kiszka #define KVM_EXIT_INTR 10 24051b24e34SJan Kiszka #define KVM_EXIT_SET_TPR 11 24151b24e34SJan Kiszka #define KVM_EXIT_TPR_ACCESS 12 24251b24e34SJan Kiszka #define KVM_EXIT_S390_SIEIC 13 24351b24e34SJan Kiszka #define KVM_EXIT_S390_RESET 14 244a9fd1654SJens Freimann #define KVM_EXIT_DCR 15 /* deprecated */ 24551b24e34SJan Kiszka #define KVM_EXIT_NMI 16 24651b24e34SJan Kiszka #define KVM_EXIT_INTERNAL_ERROR 17 24751b24e34SJan Kiszka #define KVM_EXIT_OSI 18 2487c6da3deSAlexander Graf #define KVM_EXIT_PAPR_HCALL 19 2491529ae1bSAlexander Graf #define KVM_EXIT_S390_UCONTROL 20 250d4834ff9SAlexander Graf #define KVM_EXIT_WATCHDOG 21 251d3dccee1SAlexander Graf #define KVM_EXIT_S390_TSCH 22 252d3dccee1SAlexander Graf #define KVM_EXIT_EPR 23 253b061808dSAlexander Graf #define KVM_EXIT_SYSTEM_EVENT 24 2547a52ce8aSCornelia Huck #define KVM_EXIT_S390_STSI 25 2553a824b15SPaolo Bonzini #define KVM_EXIT_IOAPIC_EOI 26 256fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV 27 2572a886794SGreg Kurz #define KVM_EXIT_ARM_NISV 28 25853ba2eeeSMatthew Rosato #define KVM_EXIT_X86_RDMSR 29 25953ba2eeeSMatthew Rosato #define KVM_EXIT_X86_WRMSR 30 260b3c818a4SEric Farman #define KVM_EXIT_DIRTY_RING_FULL 31 261278f064eSEduardo Habkost #define KVM_EXIT_AP_RESET_HOLD 32 262278f064eSEduardo Habkost #define KVM_EXIT_X86_BUS_LOCK 33 263278f064eSEduardo Habkost #define KVM_EXIT_XEN 34 26443709a0cSPaolo Bonzini #define KVM_EXIT_RISCV_SBI 35 265d525f73fSChenyi Qiang #define KVM_EXIT_RISCV_CSR 36 266d525f73fSChenyi Qiang #define KVM_EXIT_NOTIFY 37 267*efb91426SDaniel Henrique Barboza #define KVM_EXIT_LOONGARCH_IOCSR 38 26851b24e34SJan Kiszka 26951b24e34SJan Kiszka /* For KVM_EXIT_INTERNAL_ERROR */ 270d4834ff9SAlexander Graf /* Emulate instruction failed. */ 27151b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_EMULATION 1 272d4834ff9SAlexander Graf /* Encounter unexpected simultaneous exceptions. */ 27351b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_SIMUL_EX 2 274d4834ff9SAlexander Graf /* Encounter unexpected vm-exit due to delivery event. */ 275d4834ff9SAlexander Graf #define KVM_INTERNAL_ERROR_DELIVERY_EV 3 276f363d039SEric Auger /* Encounter unexpected vm-exit reason */ 277f363d039SEric Auger #define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON 4 27851b24e34SJan Kiszka 279327d4b7fSBharata B Rao /* Flags that describe what fields in emulation_failure hold valid data. */ 280327d4b7fSBharata B Rao #define KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES (1ULL << 0) 281327d4b7fSBharata B Rao 28251b24e34SJan Kiszka /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ 28351b24e34SJan Kiszka struct kvm_run { 28451b24e34SJan Kiszka /* in */ 28551b24e34SJan Kiszka __u8 request_interrupt_window; 2863a5eb5b4SPaolo Bonzini __u8 immediate_exit; 2873a5eb5b4SPaolo Bonzini __u8 padding1[6]; 28851b24e34SJan Kiszka 28951b24e34SJan Kiszka /* out */ 29051b24e34SJan Kiszka __u32 exit_reason; 29151b24e34SJan Kiszka __u8 ready_for_interrupt_injection; 29251b24e34SJan Kiszka __u8 if_flag; 29324a31426SPaolo Bonzini __u16 flags; 29451b24e34SJan Kiszka 29551b24e34SJan Kiszka /* in (pre_kvm_run), out (post_kvm_run) */ 29651b24e34SJan Kiszka __u64 cr8; 29751b24e34SJan Kiszka __u64 apic_base; 29851b24e34SJan Kiszka 29951b24e34SJan Kiszka #ifdef __KVM_S390 30051b24e34SJan Kiszka /* the processor status word for s390 */ 30151b24e34SJan Kiszka __u64 psw_mask; /* psw upper half */ 30251b24e34SJan Kiszka __u64 psw_addr; /* psw lower half */ 30351b24e34SJan Kiszka #endif 30451b24e34SJan Kiszka union { 30551b24e34SJan Kiszka /* KVM_EXIT_UNKNOWN */ 30651b24e34SJan Kiszka struct { 30751b24e34SJan Kiszka __u64 hardware_exit_reason; 30851b24e34SJan Kiszka } hw; 30951b24e34SJan Kiszka /* KVM_EXIT_FAIL_ENTRY */ 31051b24e34SJan Kiszka struct { 31151b24e34SJan Kiszka __u64 hardware_entry_failure_reason; 312e6546342SJason Wang __u32 cpu; 31351b24e34SJan Kiszka } fail_entry; 31451b24e34SJan Kiszka /* KVM_EXIT_EXCEPTION */ 31551b24e34SJan Kiszka struct { 31651b24e34SJan Kiszka __u32 exception; 31751b24e34SJan Kiszka __u32 error_code; 31851b24e34SJan Kiszka } ex; 31951b24e34SJan Kiszka /* KVM_EXIT_IO */ 32051b24e34SJan Kiszka struct { 32151b24e34SJan Kiszka #define KVM_EXIT_IO_IN 0 32251b24e34SJan Kiszka #define KVM_EXIT_IO_OUT 1 32351b24e34SJan Kiszka __u8 direction; 32451b24e34SJan Kiszka __u8 size; /* bytes */ 32551b24e34SJan Kiszka __u16 port; 32651b24e34SJan Kiszka __u32 count; 32751b24e34SJan Kiszka __u64 data_offset; /* relative to kvm_run start */ 32851b24e34SJan Kiszka } io; 3293a824b15SPaolo Bonzini /* KVM_EXIT_DEBUG */ 33051b24e34SJan Kiszka struct { 33151b24e34SJan Kiszka struct kvm_debug_exit_arch arch; 33251b24e34SJan Kiszka } debug; 33351b24e34SJan Kiszka /* KVM_EXIT_MMIO */ 33451b24e34SJan Kiszka struct { 33551b24e34SJan Kiszka __u64 phys_addr; 33651b24e34SJan Kiszka __u8 data[8]; 33751b24e34SJan Kiszka __u32 len; 33851b24e34SJan Kiszka __u8 is_write; 33951b24e34SJan Kiszka } mmio; 340*efb91426SDaniel Henrique Barboza /* KVM_EXIT_LOONGARCH_IOCSR */ 341*efb91426SDaniel Henrique Barboza struct { 342*efb91426SDaniel Henrique Barboza __u64 phys_addr; 343*efb91426SDaniel Henrique Barboza __u8 data[8]; 344*efb91426SDaniel Henrique Barboza __u32 len; 345*efb91426SDaniel Henrique Barboza __u8 is_write; 346*efb91426SDaniel Henrique Barboza } iocsr_io; 34751b24e34SJan Kiszka /* KVM_EXIT_HYPERCALL */ 34851b24e34SJan Kiszka struct { 34951b24e34SJan Kiszka __u64 nr; 35051b24e34SJan Kiszka __u64 args[6]; 35151b24e34SJan Kiszka __u64 ret; 352d0bf492fSCédric Le Goater 353d0bf492fSCédric Le Goater union { 35451b24e34SJan Kiszka __u32 longmode; 355d0bf492fSCédric Le Goater __u64 flags; 356d0bf492fSCédric Le Goater }; 35751b24e34SJan Kiszka } hypercall; 35851b24e34SJan Kiszka /* KVM_EXIT_TPR_ACCESS */ 35951b24e34SJan Kiszka struct { 36051b24e34SJan Kiszka __u64 rip; 36151b24e34SJan Kiszka __u32 is_write; 36251b24e34SJan Kiszka __u32 pad; 36351b24e34SJan Kiszka } tpr_access; 36451b24e34SJan Kiszka /* KVM_EXIT_S390_SIEIC */ 36551b24e34SJan Kiszka struct { 36651b24e34SJan Kiszka __u8 icptcode; 36751b24e34SJan Kiszka __u16 ipa; 36851b24e34SJan Kiszka __u32 ipb; 36951b24e34SJan Kiszka } s390_sieic; 37051b24e34SJan Kiszka /* KVM_EXIT_S390_RESET */ 37151b24e34SJan Kiszka #define KVM_S390_RESET_POR 1 37251b24e34SJan Kiszka #define KVM_S390_RESET_CLEAR 2 37351b24e34SJan Kiszka #define KVM_S390_RESET_SUBSYSTEM 4 37451b24e34SJan Kiszka #define KVM_S390_RESET_CPU_INIT 8 37551b24e34SJan Kiszka #define KVM_S390_RESET_IPL 16 37651b24e34SJan Kiszka __u64 s390_reset_flags; 3771529ae1bSAlexander Graf /* KVM_EXIT_S390_UCONTROL */ 3781529ae1bSAlexander Graf struct { 3791529ae1bSAlexander Graf __u64 trans_exc_code; 3801529ae1bSAlexander Graf __u32 pgm_code; 3811529ae1bSAlexander Graf } s390_ucontrol; 382a9fd1654SJens Freimann /* KVM_EXIT_DCR (deprecated) */ 38351b24e34SJan Kiszka struct { 38451b24e34SJan Kiszka __u32 dcrn; 38551b24e34SJan Kiszka __u32 data; 38651b24e34SJan Kiszka __u8 is_write; 38751b24e34SJan Kiszka } dcr; 3883a824b15SPaolo Bonzini /* KVM_EXIT_INTERNAL_ERROR */ 38951b24e34SJan Kiszka struct { 39051b24e34SJan Kiszka __u32 suberror; 39151b24e34SJan Kiszka /* Available with KVM_CAP_INTERNAL_ERROR_DATA: */ 39251b24e34SJan Kiszka __u32 ndata; 39351b24e34SJan Kiszka __u64 data[16]; 39451b24e34SJan Kiszka } internal; 395327d4b7fSBharata B Rao /* 396327d4b7fSBharata B Rao * KVM_INTERNAL_ERROR_EMULATION 397327d4b7fSBharata B Rao * 398327d4b7fSBharata B Rao * "struct emulation_failure" is an overlay of "struct internal" 399327d4b7fSBharata B Rao * that is used for the KVM_INTERNAL_ERROR_EMULATION sub-type of 400327d4b7fSBharata B Rao * KVM_EXIT_INTERNAL_ERROR. Note, unlike other internal error 401327d4b7fSBharata B Rao * sub-types, this struct is ABI! It also needs to be backwards 402327d4b7fSBharata B Rao * compatible with "struct internal". Take special care that 403327d4b7fSBharata B Rao * "ndata" is correct, that new fields are enumerated in "flags", 404327d4b7fSBharata B Rao * and that each flag enumerates fields that are 64-bit aligned 405327d4b7fSBharata B Rao * and sized (so that ndata+internal.data[] is valid/accurate). 40643709a0cSPaolo Bonzini * 40743709a0cSPaolo Bonzini * Space beyond the defined fields may be used to store arbitrary 40843709a0cSPaolo Bonzini * debug information relating to the emulation failure. It is 40943709a0cSPaolo Bonzini * accounted for in "ndata" but the format is unspecified and is 41043709a0cSPaolo Bonzini * not represented in "flags". Any such information is *not* ABI! 411327d4b7fSBharata B Rao */ 412327d4b7fSBharata B Rao struct { 413327d4b7fSBharata B Rao __u32 suberror; 414327d4b7fSBharata B Rao __u32 ndata; 415327d4b7fSBharata B Rao __u64 flags; 41643709a0cSPaolo Bonzini union { 41743709a0cSPaolo Bonzini struct { 418327d4b7fSBharata B Rao __u8 insn_size; 419327d4b7fSBharata B Rao __u8 insn_bytes[15]; 42043709a0cSPaolo Bonzini }; 42143709a0cSPaolo Bonzini }; 42243709a0cSPaolo Bonzini /* Arbitrary debug data may follow. */ 423327d4b7fSBharata B Rao } emulation_failure; 42451b24e34SJan Kiszka /* KVM_EXIT_OSI */ 42551b24e34SJan Kiszka struct { 42651b24e34SJan Kiszka __u64 gprs[32]; 42751b24e34SJan Kiszka } osi; 4283a824b15SPaolo Bonzini /* KVM_EXIT_PAPR_HCALL */ 4297c6da3deSAlexander Graf struct { 4307c6da3deSAlexander Graf __u64 nr; 4317c6da3deSAlexander Graf __u64 ret; 4327c6da3deSAlexander Graf __u64 args[9]; 4337c6da3deSAlexander Graf } papr_hcall; 434d3dccee1SAlexander Graf /* KVM_EXIT_S390_TSCH */ 435d3dccee1SAlexander Graf struct { 436d3dccee1SAlexander Graf __u16 subchannel_id; 437d3dccee1SAlexander Graf __u16 subchannel_nr; 438d3dccee1SAlexander Graf __u32 io_int_parm; 439d3dccee1SAlexander Graf __u32 io_int_word; 440d3dccee1SAlexander Graf __u32 ipb; 441d3dccee1SAlexander Graf __u8 dequeued; 442d3dccee1SAlexander Graf } s390_tsch; 443d3dccee1SAlexander Graf /* KVM_EXIT_EPR */ 444d3dccee1SAlexander Graf struct { 445d3dccee1SAlexander Graf __u32 epr; 446d3dccee1SAlexander Graf } epr; 447b061808dSAlexander Graf /* KVM_EXIT_SYSTEM_EVENT */ 448b061808dSAlexander Graf struct { 449b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_SHUTDOWN 1 450b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_RESET 2 451120758fbSPaolo Bonzini #define KVM_SYSTEM_EVENT_CRASH 3 452d525f73fSChenyi Qiang #define KVM_SYSTEM_EVENT_WAKEUP 4 453d525f73fSChenyi Qiang #define KVM_SYSTEM_EVENT_SUSPEND 5 454d525f73fSChenyi Qiang #define KVM_SYSTEM_EVENT_SEV_TERM 6 455b061808dSAlexander Graf __u32 type; 456e4082063SAlex Williamson __u32 ndata; 457e4082063SAlex Williamson union { 458b061808dSAlexander Graf __u64 flags; 459e4082063SAlex Williamson __u64 data[16]; 460e4082063SAlex Williamson }; 461b061808dSAlexander Graf } system_event; 4627a52ce8aSCornelia Huck /* KVM_EXIT_S390_STSI */ 4637a52ce8aSCornelia Huck struct { 4647a52ce8aSCornelia Huck __u64 addr; 4657a52ce8aSCornelia Huck __u8 ar; 4667a52ce8aSCornelia Huck __u8 reserved; 4677a52ce8aSCornelia Huck __u8 fc; 4687a52ce8aSCornelia Huck __u8 sel1; 4697a52ce8aSCornelia Huck __u16 sel2; 4707a52ce8aSCornelia Huck } s390_stsi; 4713a824b15SPaolo Bonzini /* KVM_EXIT_IOAPIC_EOI */ 4723a824b15SPaolo Bonzini struct { 4733a824b15SPaolo Bonzini __u8 vector; 4743a824b15SPaolo Bonzini } eoi; 475fff02bc0SPaolo Bonzini /* KVM_EXIT_HYPERV */ 476fff02bc0SPaolo Bonzini struct kvm_hyperv_exit hyperv; 4772a886794SGreg Kurz /* KVM_EXIT_ARM_NISV */ 4782a886794SGreg Kurz struct { 4792a886794SGreg Kurz __u64 esr_iss; 4802a886794SGreg Kurz __u64 fault_ipa; 4812a886794SGreg Kurz } arm_nisv; 48253ba2eeeSMatthew Rosato /* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */ 48353ba2eeeSMatthew Rosato struct { 48453ba2eeeSMatthew Rosato __u8 error; /* user -> kernel */ 48553ba2eeeSMatthew Rosato __u8 pad[7]; 48653ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_INVAL (1 << 0) 48753ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_UNKNOWN (1 << 1) 48853ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_FILTER (1 << 2) 48993d7620cSAvihai Horon #define KVM_MSR_EXIT_REASON_VALID_MASK (KVM_MSR_EXIT_REASON_INVAL | \ 49093d7620cSAvihai Horon KVM_MSR_EXIT_REASON_UNKNOWN | \ 49193d7620cSAvihai Horon KVM_MSR_EXIT_REASON_FILTER) 49253ba2eeeSMatthew Rosato __u32 reason; /* kernel -> user */ 49353ba2eeeSMatthew Rosato __u32 index; /* kernel -> user */ 49453ba2eeeSMatthew Rosato __u64 data; /* kernel <-> user */ 49553ba2eeeSMatthew Rosato } msr; 496278f064eSEduardo Habkost /* KVM_EXIT_XEN */ 497278f064eSEduardo Habkost struct kvm_xen_exit xen; 49843709a0cSPaolo Bonzini /* KVM_EXIT_RISCV_SBI */ 49943709a0cSPaolo Bonzini struct { 50043709a0cSPaolo Bonzini unsigned long extension_id; 50143709a0cSPaolo Bonzini unsigned long function_id; 50243709a0cSPaolo Bonzini unsigned long args[6]; 50343709a0cSPaolo Bonzini unsigned long ret[2]; 50443709a0cSPaolo Bonzini } riscv_sbi; 505d525f73fSChenyi Qiang /* KVM_EXIT_RISCV_CSR */ 506d525f73fSChenyi Qiang struct { 507d525f73fSChenyi Qiang unsigned long csr_num; 508d525f73fSChenyi Qiang unsigned long new_value; 509d525f73fSChenyi Qiang unsigned long write_mask; 510d525f73fSChenyi Qiang unsigned long ret_value; 511d525f73fSChenyi Qiang } riscv_csr; 512d525f73fSChenyi Qiang /* KVM_EXIT_NOTIFY */ 513d525f73fSChenyi Qiang struct { 514d525f73fSChenyi Qiang #define KVM_NOTIFY_CONTEXT_INVALID (1 << 0) 515d525f73fSChenyi Qiang __u32 flags; 516d525f73fSChenyi Qiang } notify; 51751b24e34SJan Kiszka /* Fix the size of the union. */ 51851b24e34SJan Kiszka char padding[256]; 51951b24e34SJan Kiszka }; 5201529ae1bSAlexander Graf 52165a6d8ddSPeter Maydell /* 2048 is the size of the char array used to bound/pad the size 52265a6d8ddSPeter Maydell * of the union that holds sync regs. 52365a6d8ddSPeter Maydell */ 52465a6d8ddSPeter Maydell #define SYNC_REGS_SIZE_BYTES 2048 5251529ae1bSAlexander Graf /* 5261529ae1bSAlexander Graf * shared registers between kvm and userspace. 5271529ae1bSAlexander Graf * kvm_valid_regs specifies the register classes set by the host 5281529ae1bSAlexander Graf * kvm_dirty_regs specified the register classes dirtied by userspace 5291529ae1bSAlexander Graf * struct kvm_sync_regs is architecture specific, as well as the 5301529ae1bSAlexander Graf * bits for kvm_valid_regs and kvm_dirty_regs 5311529ae1bSAlexander Graf */ 5321529ae1bSAlexander Graf __u64 kvm_valid_regs; 5331529ae1bSAlexander Graf __u64 kvm_dirty_regs; 5341529ae1bSAlexander Graf union { 5351529ae1bSAlexander Graf struct kvm_sync_regs regs; 53665a6d8ddSPeter Maydell char padding[SYNC_REGS_SIZE_BYTES]; 5371529ae1bSAlexander Graf } s; 53851b24e34SJan Kiszka }; 53951b24e34SJan Kiszka 54051b24e34SJan Kiszka /* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */ 54151b24e34SJan Kiszka 54251b24e34SJan Kiszka struct kvm_coalesced_mmio_zone { 54351b24e34SJan Kiszka __u64 addr; 54451b24e34SJan Kiszka __u32 size; 545966f2ec3SPaolo Bonzini union { 54651b24e34SJan Kiszka __u32 pad; 547966f2ec3SPaolo Bonzini __u32 pio; 548966f2ec3SPaolo Bonzini }; 54951b24e34SJan Kiszka }; 55051b24e34SJan Kiszka 55151b24e34SJan Kiszka struct kvm_coalesced_mmio { 55251b24e34SJan Kiszka __u64 phys_addr; 55351b24e34SJan Kiszka __u32 len; 554966f2ec3SPaolo Bonzini union { 55551b24e34SJan Kiszka __u32 pad; 556966f2ec3SPaolo Bonzini __u32 pio; 557966f2ec3SPaolo Bonzini }; 55851b24e34SJan Kiszka __u8 data[8]; 55951b24e34SJan Kiszka }; 56051b24e34SJan Kiszka 56151b24e34SJan Kiszka struct kvm_coalesced_mmio_ring { 56251b24e34SJan Kiszka __u32 first, last; 563d525f73fSChenyi Qiang struct kvm_coalesced_mmio coalesced_mmio[]; 56451b24e34SJan Kiszka }; 56551b24e34SJan Kiszka 56651b24e34SJan Kiszka #define KVM_COALESCED_MMIO_MAX \ 56751b24e34SJan Kiszka ((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \ 56851b24e34SJan Kiszka sizeof(struct kvm_coalesced_mmio)) 56951b24e34SJan Kiszka 57051b24e34SJan Kiszka /* for KVM_TRANSLATE */ 57151b24e34SJan Kiszka struct kvm_translation { 57251b24e34SJan Kiszka /* in */ 57351b24e34SJan Kiszka __u64 linear_address; 57451b24e34SJan Kiszka 57551b24e34SJan Kiszka /* out */ 57651b24e34SJan Kiszka __u64 physical_address; 57751b24e34SJan Kiszka __u8 valid; 57851b24e34SJan Kiszka __u8 writeable; 57951b24e34SJan Kiszka __u8 usermode; 58051b24e34SJan Kiszka __u8 pad[5]; 58151b24e34SJan Kiszka }; 58251b24e34SJan Kiszka 5837a52ce8aSCornelia Huck /* for KVM_S390_MEM_OP */ 5847a52ce8aSCornelia Huck struct kvm_s390_mem_op { 5857a52ce8aSCornelia Huck /* in */ 5867a52ce8aSCornelia Huck __u64 gaddr; /* the guest address */ 5877a52ce8aSCornelia Huck __u64 flags; /* flags */ 5887a52ce8aSCornelia Huck __u32 size; /* amount of bytes */ 5897a52ce8aSCornelia Huck __u32 op; /* type of operation */ 5907a52ce8aSCornelia Huck __u64 buf; /* buffer in userspace */ 591dc6f8d45SCornelia Huck union { 592e4082063SAlex Williamson struct { 5937a52ce8aSCornelia Huck __u8 ar; /* the access register number */ 594e4082063SAlex Williamson __u8 key; /* access key, ignored if flag unset */ 595c5c0fdbeSDavid 'Digit' Turner __u8 pad1[6]; /* ignored */ 596c5c0fdbeSDavid 'Digit' Turner __u64 old_addr; /* ignored if cmpxchg flag unset */ 597e4082063SAlex Williamson }; 598dc6f8d45SCornelia Huck __u32 sida_offset; /* offset into the sida */ 599e4082063SAlex Williamson __u8 reserved[32]; /* ignored */ 600dc6f8d45SCornelia Huck }; 6017a52ce8aSCornelia Huck }; 6027a52ce8aSCornelia Huck /* types for kvm_s390_mem_op->op */ 6037a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_READ 0 6047a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_WRITE 1 605dc6f8d45SCornelia Huck #define KVM_S390_MEMOP_SIDA_READ 2 606dc6f8d45SCornelia Huck #define KVM_S390_MEMOP_SIDA_WRITE 3 607e4082063SAlex Williamson #define KVM_S390_MEMOP_ABSOLUTE_READ 4 608e4082063SAlex Williamson #define KVM_S390_MEMOP_ABSOLUTE_WRITE 5 609c5c0fdbeSDavid 'Digit' Turner #define KVM_S390_MEMOP_ABSOLUTE_CMPXCHG 6 610c5c0fdbeSDavid 'Digit' Turner 6117a52ce8aSCornelia Huck /* flags for kvm_s390_mem_op->flags */ 6127a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0) 6137a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1) 614e4082063SAlex Williamson #define KVM_S390_MEMOP_F_SKEY_PROTECTION (1ULL << 2) 6157a52ce8aSCornelia Huck 616c5c0fdbeSDavid 'Digit' Turner /* flags specifying extension support via KVM_CAP_S390_MEM_OP_EXTENSION */ 617c5c0fdbeSDavid 'Digit' Turner #define KVM_S390_MEMOP_EXTENSION_CAP_BASE (1 << 0) 618c5c0fdbeSDavid 'Digit' Turner #define KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG (1 << 1) 619c5c0fdbeSDavid 'Digit' Turner 62051b24e34SJan Kiszka /* for KVM_INTERRUPT */ 62151b24e34SJan Kiszka struct kvm_interrupt { 62251b24e34SJan Kiszka /* in */ 62351b24e34SJan Kiszka __u32 irq; 62451b24e34SJan Kiszka }; 62551b24e34SJan Kiszka 62651b24e34SJan Kiszka /* for KVM_GET_DIRTY_LOG */ 62751b24e34SJan Kiszka struct kvm_dirty_log { 62851b24e34SJan Kiszka __u32 slot; 62951b24e34SJan Kiszka __u32 padding1; 63051b24e34SJan Kiszka union { 63151b24e34SJan Kiszka void *dirty_bitmap; /* one bit per page */ 63251b24e34SJan Kiszka __u64 padding2; 63351b24e34SJan Kiszka }; 63451b24e34SJan Kiszka }; 63551b24e34SJan Kiszka 636da054c64SPaolo Bonzini /* for KVM_CLEAR_DIRTY_LOG */ 637da054c64SPaolo Bonzini struct kvm_clear_dirty_log { 638da054c64SPaolo Bonzini __u32 slot; 639da054c64SPaolo Bonzini __u32 num_pages; 640da054c64SPaolo Bonzini __u64 first_page; 641da054c64SPaolo Bonzini union { 642da054c64SPaolo Bonzini void *dirty_bitmap; /* one bit per page */ 643da054c64SPaolo Bonzini __u64 padding2; 644da054c64SPaolo Bonzini }; 645da054c64SPaolo Bonzini }; 646da054c64SPaolo Bonzini 64751b24e34SJan Kiszka /* for KVM_SET_SIGNAL_MASK */ 64851b24e34SJan Kiszka struct kvm_signal_mask { 64951b24e34SJan Kiszka __u32 len; 650d525f73fSChenyi Qiang __u8 sigset[]; 65151b24e34SJan Kiszka }; 65251b24e34SJan Kiszka 65351b24e34SJan Kiszka /* for KVM_TPR_ACCESS_REPORTING */ 65451b24e34SJan Kiszka struct kvm_tpr_access_ctl { 65551b24e34SJan Kiszka __u32 enabled; 65651b24e34SJan Kiszka __u32 flags; 65751b24e34SJan Kiszka __u32 reserved[8]; 65851b24e34SJan Kiszka }; 65951b24e34SJan Kiszka 66051b24e34SJan Kiszka /* for KVM_SET_VAPIC_ADDR */ 66151b24e34SJan Kiszka struct kvm_vapic_addr { 66251b24e34SJan Kiszka __u64 vapic_addr; 66351b24e34SJan Kiszka }; 66451b24e34SJan Kiszka 665a9fd1654SJens Freimann /* for KVM_SET_MP_STATE */ 66651b24e34SJan Kiszka 667a9fd1654SJens Freimann /* not all states are valid on all architectures */ 66851b24e34SJan Kiszka #define KVM_MP_STATE_RUNNABLE 0 66951b24e34SJan Kiszka #define KVM_MP_STATE_UNINITIALIZED 1 67051b24e34SJan Kiszka #define KVM_MP_STATE_INIT_RECEIVED 2 67151b24e34SJan Kiszka #define KVM_MP_STATE_HALTED 3 67251b24e34SJan Kiszka #define KVM_MP_STATE_SIPI_RECEIVED 4 673a9fd1654SJens Freimann #define KVM_MP_STATE_STOPPED 5 674a9fd1654SJens Freimann #define KVM_MP_STATE_CHECK_STOP 6 675a9fd1654SJens Freimann #define KVM_MP_STATE_OPERATING 7 676a9fd1654SJens Freimann #define KVM_MP_STATE_LOAD 8 677278f064eSEduardo Habkost #define KVM_MP_STATE_AP_RESET_HOLD 9 678d525f73fSChenyi Qiang #define KVM_MP_STATE_SUSPENDED 10 67951b24e34SJan Kiszka 68051b24e34SJan Kiszka struct kvm_mp_state { 68151b24e34SJan Kiszka __u32 mp_state; 68251b24e34SJan Kiszka }; 68351b24e34SJan Kiszka 68451b24e34SJan Kiszka struct kvm_s390_psw { 68551b24e34SJan Kiszka __u64 mask; 68651b24e34SJan Kiszka __u64 addr; 68751b24e34SJan Kiszka }; 68851b24e34SJan Kiszka 68951b24e34SJan Kiszka /* valid values for type in kvm_s390_interrupt */ 69051b24e34SJan Kiszka #define KVM_S390_SIGP_STOP 0xfffe0000u 69151b24e34SJan Kiszka #define KVM_S390_PROGRAM_INT 0xfffe0001u 69251b24e34SJan Kiszka #define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u 69351b24e34SJan Kiszka #define KVM_S390_RESTART 0xfffe0003u 694216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_INIT 0xfffe0004u 695216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_DONE 0xfffe0005u 696d3dccee1SAlexander Graf #define KVM_S390_MCHK 0xfffe1000u 69776eb98d5SJens Freimann #define KVM_S390_INT_CLOCK_COMP 0xffff1004u 69876eb98d5SJens Freimann #define KVM_S390_INT_CPU_TIMER 0xffff1005u 69951b24e34SJan Kiszka #define KVM_S390_INT_VIRTIO 0xffff2603u 70051b24e34SJan Kiszka #define KVM_S390_INT_SERVICE 0xffff2401u 70151b24e34SJan Kiszka #define KVM_S390_INT_EMERGENCY 0xffff1201u 7021529ae1bSAlexander Graf #define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u 703d3dccee1SAlexander Graf /* Anything below 0xfffe0000u is taken by INT_IO */ 704d3dccee1SAlexander Graf #define KVM_S390_INT_IO(ai,cssid,ssid,schid) \ 705d3dccee1SAlexander Graf (((schid)) | \ 706d3dccee1SAlexander Graf ((ssid) << 16) | \ 707d3dccee1SAlexander Graf ((cssid) << 18) | \ 708d3dccee1SAlexander Graf ((ai) << 26)) 709d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MIN 0x00000000u 710d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MAX 0xfffdffffu 711120758fbSPaolo Bonzini #define KVM_S390_INT_IO_AI_MASK 0x04000000u 712d3dccee1SAlexander Graf 71351b24e34SJan Kiszka 71451b24e34SJan Kiszka struct kvm_s390_interrupt { 71551b24e34SJan Kiszka __u32 type; 71651b24e34SJan Kiszka __u32 parm; 71751b24e34SJan Kiszka __u64 parm64; 71851b24e34SJan Kiszka }; 71951b24e34SJan Kiszka 720216db403SChristian Borntraeger struct kvm_s390_io_info { 721216db403SChristian Borntraeger __u16 subchannel_id; 722216db403SChristian Borntraeger __u16 subchannel_nr; 723216db403SChristian Borntraeger __u32 io_int_parm; 724216db403SChristian Borntraeger __u32 io_int_word; 725216db403SChristian Borntraeger }; 726216db403SChristian Borntraeger 727216db403SChristian Borntraeger struct kvm_s390_ext_info { 728216db403SChristian Borntraeger __u32 ext_params; 729216db403SChristian Borntraeger __u32 pad; 730216db403SChristian Borntraeger __u64 ext_params2; 731216db403SChristian Borntraeger }; 732216db403SChristian Borntraeger 733216db403SChristian Borntraeger struct kvm_s390_pgm_info { 734216db403SChristian Borntraeger __u64 trans_exc_code; 735216db403SChristian Borntraeger __u64 mon_code; 736216db403SChristian Borntraeger __u64 per_address; 737216db403SChristian Borntraeger __u32 data_exc_code; 738216db403SChristian Borntraeger __u16 code; 739216db403SChristian Borntraeger __u16 mon_class_nr; 740216db403SChristian Borntraeger __u8 per_code; 741216db403SChristian Borntraeger __u8 per_atmid; 742216db403SChristian Borntraeger __u8 exc_access_id; 743216db403SChristian Borntraeger __u8 per_access_id; 744216db403SChristian Borntraeger __u8 op_access_id; 74566fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_VALID 0x01 74666fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_0 0x02 74766fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_1 0x04 74866fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_MASK 0x06 74966fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_NO_REWIND 0x08 75066fb2d54SCornelia Huck __u8 flags; 75166fb2d54SCornelia Huck __u8 pad[2]; 752216db403SChristian Borntraeger }; 753216db403SChristian Borntraeger 754216db403SChristian Borntraeger struct kvm_s390_prefix_info { 755216db403SChristian Borntraeger __u32 address; 756216db403SChristian Borntraeger }; 757216db403SChristian Borntraeger 758216db403SChristian Borntraeger struct kvm_s390_extcall_info { 759216db403SChristian Borntraeger __u16 code; 760216db403SChristian Borntraeger }; 761216db403SChristian Borntraeger 762216db403SChristian Borntraeger struct kvm_s390_emerg_info { 763216db403SChristian Borntraeger __u16 code; 764216db403SChristian Borntraeger }; 765216db403SChristian Borntraeger 76651628b18SChristian Borntraeger #define KVM_S390_STOP_FLAG_STORE_STATUS 0x01 76751628b18SChristian Borntraeger struct kvm_s390_stop_info { 76851628b18SChristian Borntraeger __u32 flags; 76951628b18SChristian Borntraeger }; 77051628b18SChristian Borntraeger 771216db403SChristian Borntraeger struct kvm_s390_mchk_info { 772216db403SChristian Borntraeger __u64 cr14; 773216db403SChristian Borntraeger __u64 mcic; 774216db403SChristian Borntraeger __u64 failing_storage_address; 775216db403SChristian Borntraeger __u32 ext_damage_code; 776216db403SChristian Borntraeger __u32 pad; 777216db403SChristian Borntraeger __u8 fixed_logout[16]; 778216db403SChristian Borntraeger }; 779216db403SChristian Borntraeger 780216db403SChristian Borntraeger struct kvm_s390_irq { 781216db403SChristian Borntraeger __u64 type; 782216db403SChristian Borntraeger union { 783216db403SChristian Borntraeger struct kvm_s390_io_info io; 784216db403SChristian Borntraeger struct kvm_s390_ext_info ext; 785216db403SChristian Borntraeger struct kvm_s390_pgm_info pgm; 786216db403SChristian Borntraeger struct kvm_s390_emerg_info emerg; 787216db403SChristian Borntraeger struct kvm_s390_extcall_info extcall; 788216db403SChristian Borntraeger struct kvm_s390_prefix_info prefix; 78951628b18SChristian Borntraeger struct kvm_s390_stop_info stop; 790216db403SChristian Borntraeger struct kvm_s390_mchk_info mchk; 791216db403SChristian Borntraeger char reserved[64]; 792216db403SChristian Borntraeger } u; 793216db403SChristian Borntraeger }; 794216db403SChristian Borntraeger 7957a52ce8aSCornelia Huck struct kvm_s390_irq_state { 7967a52ce8aSCornelia Huck __u64 buf; 7979cbb6362SCornelia Huck __u32 flags; /* will stay unused for compatibility reasons */ 7987a52ce8aSCornelia Huck __u32 len; 7999cbb6362SCornelia Huck __u32 reserved[4]; /* will stay unused for compatibility reasons */ 8007a52ce8aSCornelia Huck }; 8017a52ce8aSCornelia Huck 80251b24e34SJan Kiszka /* for KVM_SET_GUEST_DEBUG */ 80351b24e34SJan Kiszka 80451b24e34SJan Kiszka #define KVM_GUESTDBG_ENABLE 0x00000001 80551b24e34SJan Kiszka #define KVM_GUESTDBG_SINGLESTEP 0x00000002 80651b24e34SJan Kiszka 80751b24e34SJan Kiszka struct kvm_guest_debug { 80851b24e34SJan Kiszka __u32 control; 80951b24e34SJan Kiszka __u32 pad; 81051b24e34SJan Kiszka struct kvm_guest_debug_arch arch; 81151b24e34SJan Kiszka }; 81251b24e34SJan Kiszka 81351b24e34SJan Kiszka enum { 81451b24e34SJan Kiszka kvm_ioeventfd_flag_nr_datamatch, 81551b24e34SJan Kiszka kvm_ioeventfd_flag_nr_pio, 81651b24e34SJan Kiszka kvm_ioeventfd_flag_nr_deassign, 817cae7f586SAlexander Graf kvm_ioeventfd_flag_nr_virtio_ccw_notify, 81876eb98d5SJens Freimann kvm_ioeventfd_flag_nr_fast_mmio, 81951b24e34SJan Kiszka kvm_ioeventfd_flag_nr_max, 82051b24e34SJan Kiszka }; 82151b24e34SJan Kiszka 82251b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) 82351b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) 82451b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) 825cae7f586SAlexander Graf #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ 826cae7f586SAlexander Graf (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify) 82751b24e34SJan Kiszka 82851b24e34SJan Kiszka #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1) 82951b24e34SJan Kiszka 83051b24e34SJan Kiszka struct kvm_ioeventfd { 83151b24e34SJan Kiszka __u64 datamatch; 83251b24e34SJan Kiszka __u64 addr; /* legal pio/mmio address */ 83376eb98d5SJens Freimann __u32 len; /* 1, 2, 4, or 8 bytes; or 0 to ignore length */ 83451b24e34SJan Kiszka __s32 fd; 83551b24e34SJan Kiszka __u32 flags; 83651b24e34SJan Kiszka __u8 pad[36]; 83751b24e34SJan Kiszka }; 83851b24e34SJan Kiszka 83965a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) 84077d361b1SEric Auger #define KVM_X86_DISABLE_EXITS_HLT (1 << 1) 84165a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) 842d38d201fSWanpeng Li #define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3) 84365a6d8ddSPeter Maydell #define KVM_X86_DISABLE_VALID_EXITS (KVM_X86_DISABLE_EXITS_MWAIT | \ 84477d361b1SEric Auger KVM_X86_DISABLE_EXITS_HLT | \ 845d38d201fSWanpeng Li KVM_X86_DISABLE_EXITS_PAUSE | \ 846d38d201fSWanpeng Li KVM_X86_DISABLE_EXITS_CSTATE) 84765a6d8ddSPeter Maydell 84851b24e34SJan Kiszka /* for KVM_ENABLE_CAP */ 84951b24e34SJan Kiszka struct kvm_enable_cap { 85051b24e34SJan Kiszka /* in */ 85151b24e34SJan Kiszka __u32 cap; 85251b24e34SJan Kiszka __u32 flags; 85351b24e34SJan Kiszka __u64 args[4]; 85451b24e34SJan Kiszka __u8 pad[64]; 85551b24e34SJan Kiszka }; 85651b24e34SJan Kiszka 85751b24e34SJan Kiszka /* for KVM_PPC_GET_PVINFO */ 8583a5eb5b4SPaolo Bonzini 8593a5eb5b4SPaolo Bonzini #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) 8603a5eb5b4SPaolo Bonzini 86151b24e34SJan Kiszka struct kvm_ppc_pvinfo { 86251b24e34SJan Kiszka /* out */ 86351b24e34SJan Kiszka __u32 flags; 86451b24e34SJan Kiszka __u32 hcall[4]; 86551b24e34SJan Kiszka __u8 pad[108]; 86651b24e34SJan Kiszka }; 86751b24e34SJan Kiszka 86880a3eb10SJan Kiszka /* for KVM_PPC_GET_SMMU_INFO */ 86980a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_MAX_SZ 8 87080a3eb10SJan Kiszka 87180a3eb10SJan Kiszka struct kvm_ppc_one_page_size { 87280a3eb10SJan Kiszka __u32 page_shift; /* Page shift (or 0) */ 87380a3eb10SJan Kiszka __u32 pte_enc; /* Encoding in the HPTE (>>12) */ 87480a3eb10SJan Kiszka }; 87580a3eb10SJan Kiszka 87680a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size { 87780a3eb10SJan Kiszka __u32 page_shift; /* Base page shift of segment (or 0) */ 87880a3eb10SJan Kiszka __u32 slb_enc; /* SLB encoding for BookS */ 87980a3eb10SJan Kiszka struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ]; 88080a3eb10SJan Kiszka }; 88180a3eb10SJan Kiszka 88280a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_REAL 0x00000001 88380a3eb10SJan Kiszka #define KVM_PPC_1T_SEGMENTS 0x00000002 884966f2ec3SPaolo Bonzini #define KVM_PPC_NO_HASH 0x00000004 88580a3eb10SJan Kiszka 88680a3eb10SJan Kiszka struct kvm_ppc_smmu_info { 88780a3eb10SJan Kiszka __u64 flags; 88880a3eb10SJan Kiszka __u32 slb_size; 889d4083f50SAlexey Perevalov __u16 data_keys; /* # storage keys supported for data */ 890d4083f50SAlexey Perevalov __u16 instr_keys; /* # storage keys supported for instructions */ 89180a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; 89280a3eb10SJan Kiszka }; 89380a3eb10SJan Kiszka 8943a5eb5b4SPaolo Bonzini /* for KVM_PPC_RESIZE_HPT_{PREPARE,COMMIT} */ 8953a5eb5b4SPaolo Bonzini struct kvm_ppc_resize_hpt { 8963a5eb5b4SPaolo Bonzini __u64 flags; 8973a5eb5b4SPaolo Bonzini __u32 shift; 8983a5eb5b4SPaolo Bonzini __u32 pad; 8993a5eb5b4SPaolo Bonzini }; 900d4834ff9SAlexander Graf 90151b24e34SJan Kiszka #define KVMIO 0xAE 90251b24e34SJan Kiszka 9031529ae1bSAlexander Graf /* machine type bits, to be used as argument to KVM_CREATE_VM */ 9041529ae1bSAlexander Graf #define KVM_VM_S390_UCONTROL 1 9051529ae1bSAlexander Graf 906bf63839fSAlex Williamson /* on ppc, 0 indicate default, 1 should force HV and 2 PR */ 907bf63839fSAlex Williamson #define KVM_VM_PPC_HV 1 908bf63839fSAlex Williamson #define KVM_VM_PPC_PR 2 909bf63839fSAlex Williamson 91094c7fefcSAndrew Jones /* on MIPS, 0 indicates auto, 1 forces VZ ASE, 2 forces trap & emulate */ 91194c7fefcSAndrew Jones #define KVM_VM_MIPS_AUTO 0 91274c98e20SCornelia Huck #define KVM_VM_MIPS_VZ 1 91394c7fefcSAndrew Jones #define KVM_VM_MIPS_TE 2 91474c98e20SCornelia Huck 9151529ae1bSAlexander Graf #define KVM_S390_SIE_PAGE_OFFSET 1 9161529ae1bSAlexander Graf 91751b24e34SJan Kiszka /* 918da054c64SPaolo Bonzini * On arm64, machine type can be used to request the physical 919da054c64SPaolo Bonzini * address size for the VM. Bits[7-0] are reserved for the guest 920da054c64SPaolo Bonzini * PA size shift (i.e, log2(PA_Size)). For backward compatibility, 921da054c64SPaolo Bonzini * value 0 implies the default IPA size, 40bits. 922da054c64SPaolo Bonzini */ 923da054c64SPaolo Bonzini #define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL 924da054c64SPaolo Bonzini #define KVM_VM_TYPE_ARM_IPA_SIZE(x) \ 925da054c64SPaolo Bonzini ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK) 926da054c64SPaolo Bonzini /* 92751b24e34SJan Kiszka * ioctls for /dev/kvm fds: 92851b24e34SJan Kiszka */ 92951b24e34SJan Kiszka #define KVM_GET_API_VERSION _IO(KVMIO, 0x00) 93051b24e34SJan Kiszka #define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ 93151b24e34SJan Kiszka #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) 93251b24e34SJan Kiszka 93351b24e34SJan Kiszka #define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06) 93451b24e34SJan Kiszka /* 93551b24e34SJan Kiszka * Check if a kvm extension is available. Argument is extension number, 93651b24e34SJan Kiszka * return is 1 (yes) or 0 (no, sorry). 93751b24e34SJan Kiszka */ 93851b24e34SJan Kiszka #define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03) 93951b24e34SJan Kiszka /* 94051b24e34SJan Kiszka * Get size for mmap(vcpu_fd) 94151b24e34SJan Kiszka */ 94251b24e34SJan Kiszka #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ 94351b24e34SJan Kiszka #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) 94451b24e34SJan Kiszka #define KVM_TRACE_ENABLE __KVM_DEPRECATED_MAIN_W_0x06 94551b24e34SJan Kiszka #define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07 94651b24e34SJan Kiszka #define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08 947bf63839fSAlex Williamson #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) 9489f2d175dSPaolo Bonzini #define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_msr_list) 94951b24e34SJan Kiszka 95051b24e34SJan Kiszka /* 95151b24e34SJan Kiszka * Extension capability list. 95251b24e34SJan Kiszka */ 95351b24e34SJan Kiszka #define KVM_CAP_IRQCHIP 0 95451b24e34SJan Kiszka #define KVM_CAP_HLT 1 95551b24e34SJan Kiszka #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 95651b24e34SJan Kiszka #define KVM_CAP_USER_MEMORY 3 95751b24e34SJan Kiszka #define KVM_CAP_SET_TSS_ADDR 4 95851b24e34SJan Kiszka #define KVM_CAP_VAPIC 6 95951b24e34SJan Kiszka #define KVM_CAP_EXT_CPUID 7 96051b24e34SJan Kiszka #define KVM_CAP_CLOCKSOURCE 8 9617c6da3deSAlexander Graf #define KVM_CAP_NR_VCPUS 9 /* returns recommended max vcpus per vm */ 96251b24e34SJan Kiszka #define KVM_CAP_NR_MEMSLOTS 10 /* returns max memory slots per vm */ 96351b24e34SJan Kiszka #define KVM_CAP_PIT 11 96451b24e34SJan Kiszka #define KVM_CAP_NOP_IO_DELAY 12 96551b24e34SJan Kiszka #define KVM_CAP_PV_MMU 13 96651b24e34SJan Kiszka #define KVM_CAP_MP_STATE 14 96751b24e34SJan Kiszka #define KVM_CAP_COALESCED_MMIO 15 96851b24e34SJan Kiszka #define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ 96951b24e34SJan Kiszka #define KVM_CAP_IOMMU 18 97051b24e34SJan Kiszka /* Bug in KVM_SET_USER_MEMORY_REGION fixed: */ 97151b24e34SJan Kiszka #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21 97251b24e34SJan Kiszka #define KVM_CAP_USER_NMI 22 97351b24e34SJan Kiszka #ifdef __KVM_HAVE_GUEST_DEBUG 97451b24e34SJan Kiszka #define KVM_CAP_SET_GUEST_DEBUG 23 97551b24e34SJan Kiszka #endif 97651b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 97751b24e34SJan Kiszka #define KVM_CAP_REINJECT_CONTROL 24 97851b24e34SJan Kiszka #endif 97951b24e34SJan Kiszka #define KVM_CAP_IRQ_ROUTING 25 98051b24e34SJan Kiszka #define KVM_CAP_IRQ_INJECT_STATUS 26 98151b24e34SJan Kiszka #define KVM_CAP_ASSIGN_DEV_IRQ 29 98251b24e34SJan Kiszka /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ 98351b24e34SJan Kiszka #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 98451b24e34SJan Kiszka #ifdef __KVM_HAVE_MCE 98551b24e34SJan Kiszka #define KVM_CAP_MCE 31 98651b24e34SJan Kiszka #endif 98751b24e34SJan Kiszka #define KVM_CAP_IRQFD 32 98851b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 98951b24e34SJan Kiszka #define KVM_CAP_PIT2 33 99051b24e34SJan Kiszka #endif 99151b24e34SJan Kiszka #define KVM_CAP_SET_BOOT_CPU_ID 34 99251b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT_STATE2 99351b24e34SJan Kiszka #define KVM_CAP_PIT_STATE2 35 99451b24e34SJan Kiszka #endif 99551b24e34SJan Kiszka #define KVM_CAP_IOEVENTFD 36 99651b24e34SJan Kiszka #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 99751b24e34SJan Kiszka #ifdef __KVM_HAVE_XEN_HVM 99851b24e34SJan Kiszka #define KVM_CAP_XEN_HVM 38 99951b24e34SJan Kiszka #endif 100051b24e34SJan Kiszka #define KVM_CAP_ADJUST_CLOCK 39 100151b24e34SJan Kiszka #define KVM_CAP_INTERNAL_ERROR_DATA 40 100251b24e34SJan Kiszka #ifdef __KVM_HAVE_VCPU_EVENTS 100351b24e34SJan Kiszka #define KVM_CAP_VCPU_EVENTS 41 100451b24e34SJan Kiszka #endif 100551b24e34SJan Kiszka #define KVM_CAP_S390_PSW 42 100651b24e34SJan Kiszka #define KVM_CAP_PPC_SEGSTATE 43 100751b24e34SJan Kiszka #define KVM_CAP_HYPERV 44 100851b24e34SJan Kiszka #define KVM_CAP_HYPERV_VAPIC 45 100951b24e34SJan Kiszka #define KVM_CAP_HYPERV_SPIN 46 101051b24e34SJan Kiszka #define KVM_CAP_PCI_SEGMENT 47 101151b24e34SJan Kiszka #define KVM_CAP_PPC_PAIRED_SINGLES 48 101251b24e34SJan Kiszka #define KVM_CAP_INTR_SHADOW 49 101351b24e34SJan Kiszka #ifdef __KVM_HAVE_DEBUGREGS 101451b24e34SJan Kiszka #define KVM_CAP_DEBUGREGS 50 101551b24e34SJan Kiszka #endif 101651b24e34SJan Kiszka #define KVM_CAP_X86_ROBUST_SINGLESTEP 51 101751b24e34SJan Kiszka #define KVM_CAP_PPC_OSI 52 101851b24e34SJan Kiszka #define KVM_CAP_PPC_UNSET_IRQ 53 101951b24e34SJan Kiszka #define KVM_CAP_ENABLE_CAP 54 102051b24e34SJan Kiszka #ifdef __KVM_HAVE_XSAVE 102151b24e34SJan Kiszka #define KVM_CAP_XSAVE 55 102251b24e34SJan Kiszka #endif 102351b24e34SJan Kiszka #ifdef __KVM_HAVE_XCRS 102451b24e34SJan Kiszka #define KVM_CAP_XCRS 56 102551b24e34SJan Kiszka #endif 102651b24e34SJan Kiszka #define KVM_CAP_PPC_GET_PVINFO 57 102751b24e34SJan Kiszka #define KVM_CAP_PPC_IRQ_LEVEL 58 102851b24e34SJan Kiszka #define KVM_CAP_ASYNC_PF 59 102951b24e34SJan Kiszka #define KVM_CAP_TSC_CONTROL 60 103051b24e34SJan Kiszka #define KVM_CAP_GET_TSC_KHZ 61 103151b24e34SJan Kiszka #define KVM_CAP_PPC_BOOKE_SREGS 62 10327c6da3deSAlexander Graf #define KVM_CAP_SPAPR_TCE 63 10337c6da3deSAlexander Graf #define KVM_CAP_PPC_SMT 64 10347c6da3deSAlexander Graf #define KVM_CAP_PPC_RMA 65 10357c6da3deSAlexander Graf #define KVM_CAP_MAX_VCPUS 66 /* returns max vcpus per vm */ 10369d4e4f8cSAlexander Graf #define KVM_CAP_PPC_HIOR 67 10377c6da3deSAlexander Graf #define KVM_CAP_PPC_PAPR 68 1038a54fc080SAlexander Graf #define KVM_CAP_SW_TLB 69 10399d4e4f8cSAlexander Graf #define KVM_CAP_ONE_REG 70 10401529ae1bSAlexander Graf #define KVM_CAP_S390_GMAP 71 10411529ae1bSAlexander Graf #define KVM_CAP_TSC_DEADLINE_TIMER 72 10421529ae1bSAlexander Graf #define KVM_CAP_S390_UCONTROL 73 10431529ae1bSAlexander Graf #define KVM_CAP_SYNC_REGS 74 10449ab2195dSMarcelo Tosatti #define KVM_CAP_PCI_2_3 75 10459ab2195dSMarcelo Tosatti #define KVM_CAP_KVMCLOCK_CTRL 76 104680a3eb10SJan Kiszka #define KVM_CAP_SIGNAL_MSI 77 104780a3eb10SJan Kiszka #define KVM_CAP_PPC_GET_SMMU_INFO 78 10482a60dba4SAlexander Graf #define KVM_CAP_S390_COW 79 1049651682dcSMichael S. Tsirkin #define KVM_CAP_PPC_ALLOC_HTAB 80 1050716b8e4dSAlex Williamson #define KVM_CAP_READONLY_MEM 81 1051716b8e4dSAlex Williamson #define KVM_CAP_IRQFD_RESAMPLE 82 1052d4834ff9SAlexander Graf #define KVM_CAP_PPC_BOOKE_WATCHDOG 83 1053d4834ff9SAlexander Graf #define KVM_CAP_PPC_HTAB_FD 84 1054d3dccee1SAlexander Graf #define KVM_CAP_S390_CSS_SUPPORT 85 1055d3dccee1SAlexander Graf #define KVM_CAP_PPC_EPR 86 1056eadd0e44SPeter Maydell #define KVM_CAP_ARM_PSCI 87 1057eadd0e44SPeter Maydell #define KVM_CAP_ARM_SET_DEVICE_ADDR 88 1058e098b453SAlexey Kardashevskiy #define KVM_CAP_DEVICE_CTRL 89 1059e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_MPIC 90 1060e098b453SAlexey Kardashevskiy #define KVM_CAP_PPC_RTAS 91 1061e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_XICS 92 1062c5daeae1SAlexey Kardashevskiy #define KVM_CAP_ARM_EL1_32BIT 93 10634f265607SAndrew Jones #define KVM_CAP_SPAPR_MULTITCE 94 1064bf63839fSAlex Williamson #define KVM_CAP_EXT_EMUL_CPUID 95 106548a5f3bcSVadim Rozenfeld #define KVM_CAP_HYPERV_TIME 96 10669ffd2685SCornelia Huck #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97 10679ffd2685SCornelia Huck #define KVM_CAP_ENABLE_CAP_VM 98 10689ffd2685SCornelia Huck #define KVM_CAP_S390_IRQCHIP 99 106976eb98d5SJens Freimann #define KVM_CAP_IOEVENTFD_NO_LENGTH 100 107076eb98d5SJens Freimann #define KVM_CAP_VM_ATTRIBUTES 101 1071b061808dSAlexander Graf #define KVM_CAP_ARM_PSCI_0_2 102 1072b061808dSAlexander Graf #define KVM_CAP_PPC_FIXUP_HCALL 103 1073a9fd1654SJens Freimann #define KVM_CAP_PPC_ENABLE_HCALL 104 1074a9fd1654SJens Freimann #define KVM_CAP_CHECK_EXTENSION_VM 105 107551628b18SChristian Borntraeger #define KVM_CAP_S390_USER_SIGP 106 10767a52ce8aSCornelia Huck #define KVM_CAP_S390_VECTOR_REGISTERS 107 10777a52ce8aSCornelia Huck #define KVM_CAP_S390_MEM_OP 108 10787a52ce8aSCornelia Huck #define KVM_CAP_S390_USER_STSI 109 10797a52ce8aSCornelia Huck #define KVM_CAP_S390_SKEYS 110 10807a52ce8aSCornelia Huck #define KVM_CAP_MIPS_FPU 111 10817a52ce8aSCornelia Huck #define KVM_CAP_MIPS_MSA 112 10827a52ce8aSCornelia Huck #define KVM_CAP_S390_INJECT_IRQ 113 10837a52ce8aSCornelia Huck #define KVM_CAP_S390_IRQ_STATE 114 10847a52ce8aSCornelia Huck #define KVM_CAP_PPC_HWRNG 115 108524a31426SPaolo Bonzini #define KVM_CAP_DISABLE_QUIRKS 116 108624a31426SPaolo Bonzini #define KVM_CAP_X86_SMM 117 108724a31426SPaolo Bonzini #define KVM_CAP_MULTI_ADDRESS_SPACE 118 10883a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_BPS 119 10893a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_WPS 120 10903a824b15SPaolo Bonzini #define KVM_CAP_SPLIT_IRQCHIP 121 10913a824b15SPaolo Bonzini #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122 1092fff02bc0SPaolo Bonzini #define KVM_CAP_HYPERV_SYNIC 123 109366fb2d54SCornelia Huck #define KVM_CAP_S390_RI 124 1094b89485a5SPaolo Bonzini #define KVM_CAP_SPAPR_TCE_64 125 1095b89485a5SPaolo Bonzini #define KVM_CAP_ARM_PMU_V3 126 1096b89485a5SPaolo Bonzini #define KVM_CAP_VCPU_ATTRIBUTES 127 1097ff804f15SCornelia Huck #define KVM_CAP_MAX_VCPU_ID 128 1098dbdfea92SCornelia Huck #define KVM_CAP_X2APIC_API 129 1099dbdfea92SCornelia Huck #define KVM_CAP_S390_USER_INSTR0 130 1100dbdfea92SCornelia Huck #define KVM_CAP_MSI_DEVID 131 1101dbdfea92SCornelia Huck #define KVM_CAP_PPC_HTM 132 11023a5eb5b4SPaolo Bonzini #define KVM_CAP_SPAPR_RESIZE_HPT 133 11033a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_RADIX 134 11043a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_HASH_V3 135 11053a5eb5b4SPaolo Bonzini #define KVM_CAP_IMMEDIATE_EXIT 136 110674c98e20SCornelia Huck #define KVM_CAP_MIPS_VZ 137 110774c98e20SCornelia Huck #define KVM_CAP_MIPS_TE 138 110874c98e20SCornelia Huck #define KVM_CAP_MIPS_64BIT 139 110974c98e20SCornelia Huck #define KVM_CAP_S390_GS 140 111074c98e20SCornelia Huck #define KVM_CAP_S390_AIS 141 111174c98e20SCornelia Huck #define KVM_CAP_SPAPR_TCE_VFIO 142 111265a6d8ddSPeter Maydell #define KVM_CAP_X86_DISABLE_EXITS 143 111374c98e20SCornelia Huck #define KVM_CAP_ARM_USER_IRQ 144 11143272f0e2SChristian Borntraeger #define KVM_CAP_S390_CMMA_MIGRATION 145 11153272f0e2SChristian Borntraeger #define KVM_CAP_PPC_FWNMI 146 11163272f0e2SChristian Borntraeger #define KVM_CAP_PPC_SMT_POSSIBLE 147 1117ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_SYNIC2 148 1118ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_VP_INDEX 149 1119dd873966SEric Auger #define KVM_CAP_S390_AIS_MIGRATION 150 11209cbb6362SCornelia Huck #define KVM_CAP_PPC_GET_CPU_CHAR 151 11219cbb6362SCornelia Huck #define KVM_CAP_S390_BPB 152 11229f2d175dSPaolo Bonzini #define KVM_CAP_GET_MSR_FEATURES 153 112365a6d8ddSPeter Maydell #define KVM_CAP_HYPERV_EVENTFD 154 112477d361b1SEric Auger #define KVM_CAP_HYPERV_TLBFLUSH 155 1125d36f7de8SCornelia Huck #define KVM_CAP_S390_HPAGE_1M 156 1126d36f7de8SCornelia Huck #define KVM_CAP_NESTED_STATE 157 11278f3cd250SCornelia Huck #define KVM_CAP_ARM_INJECT_SERROR_ESR 158 11288f3cd250SCornelia Huck #define KVM_CAP_MSR_PLATFORM_INFO 159 1129966f2ec3SPaolo Bonzini #define KVM_CAP_PPC_NESTED_HV 160 1130966f2ec3SPaolo Bonzini #define KVM_CAP_HYPERV_SEND_IPI 161 1131966f2ec3SPaolo Bonzini #define KVM_CAP_COALESCED_PIO 162 1132966f2ec3SPaolo Bonzini #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163 1133966f2ec3SPaolo Bonzini #define KVM_CAP_EXCEPTION_PAYLOAD 164 1134da054c64SPaolo Bonzini #define KVM_CAP_ARM_VM_IPA_SIZE 165 1135d9cb4336SCornelia Huck #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166 /* Obsolete */ 1136da054c64SPaolo Bonzini #define KVM_CAP_HYPERV_CPUID 167 1137d9cb4336SCornelia Huck #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 168 1138d9cb4336SCornelia Huck #define KVM_CAP_PPC_IRQ_XIVE 169 1139d9cb4336SCornelia Huck #define KVM_CAP_ARM_SVE 170 1140d9cb4336SCornelia Huck #define KVM_CAP_ARM_PTRAUTH_ADDRESS 171 1141d9cb4336SCornelia Huck #define KVM_CAP_ARM_PTRAUTH_GENERIC 172 1142f363d039SEric Auger #define KVM_CAP_PMU_EVENT_FILTER 173 1143f363d039SEric Auger #define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174 1144f363d039SEric Auger #define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175 11452a886794SGreg Kurz #define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 176 11462a886794SGreg Kurz #define KVM_CAP_ARM_NISV_TO_USER 177 11472a886794SGreg Kurz #define KVM_CAP_ARM_INJECT_EXT_DABT 178 1148ddda3748SCornelia Huck #define KVM_CAP_S390_VCPU_RESETS 179 1149dc6f8d45SCornelia Huck #define KVM_CAP_S390_PROTECTED 180 1150dc6f8d45SCornelia Huck #define KVM_CAP_PPC_SECURE_GUEST 181 1151f76b348eSCornelia Huck #define KVM_CAP_HALT_POLL 182 1152f76b348eSCornelia Huck #define KVM_CAP_ASYNC_PF_INT 183 1153e6546342SJason Wang #define KVM_CAP_LAST_CPU 184 1154e6546342SJason Wang #define KVM_CAP_SMALLER_MAXPHYADDR 185 1155e6546342SJason Wang #define KVM_CAP_S390_DIAG318 186 115694c7fefcSAndrew Jones #define KVM_CAP_STEAL_TIME 187 115753ba2eeeSMatthew Rosato #define KVM_CAP_X86_USER_SPACE_MSR 188 115853ba2eeeSMatthew Rosato #define KVM_CAP_X86_MSR_FILTER 189 115953ba2eeeSMatthew Rosato #define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190 1160b3c818a4SEric Farman #define KVM_CAP_SYS_HYPERV_CPUID 191 1161b3c818a4SEric Farman #define KVM_CAP_DIRTY_LOG_RING 192 1162278f064eSEduardo Habkost #define KVM_CAP_X86_BUS_LOCK_EXIT 193 1163278f064eSEduardo Habkost #define KVM_CAP_PPC_DAWR1 194 1164278f064eSEduardo Habkost #define KVM_CAP_SET_GUEST_DEBUG2 195 1165278f064eSEduardo Habkost #define KVM_CAP_SGX_ATTRIBUTE 196 1166278f064eSEduardo Habkost #define KVM_CAP_VM_COPY_ENC_CONTEXT_FROM 197 1167278f064eSEduardo Habkost #define KVM_CAP_PTP_KVM 198 1168327d4b7fSBharata B Rao #define KVM_CAP_HYPERV_ENFORCE_CPUID 199 1169327d4b7fSBharata B Rao #define KVM_CAP_SREGS2 200 1170327d4b7fSBharata B Rao #define KVM_CAP_EXIT_HYPERCALL 201 1171327d4b7fSBharata B Rao #define KVM_CAP_PPC_RPT_INVALIDATE 202 1172327d4b7fSBharata B Rao #define KVM_CAP_BINARY_STATS_FD 203 1173327d4b7fSBharata B Rao #define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204 1174327d4b7fSBharata B Rao #define KVM_CAP_ARM_MTE 205 1175ef17dd6aSVivek Goyal #define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206 1176ef17dd6aSVivek Goyal #define KVM_CAP_VM_GPA_BITS 207 1177ef17dd6aSVivek Goyal #define KVM_CAP_XSAVE2 208 11781ea5208fSPaolo Bonzini #define KVM_CAP_SYS_ATTRIBUTES 209 1179e4082063SAlex Williamson #define KVM_CAP_PPC_AIL_MODE_3 210 1180e4082063SAlex Williamson #define KVM_CAP_S390_MEM_OP_EXTENSION 211 1181e4082063SAlex Williamson #define KVM_CAP_PMU_CAPABILITY 212 1182e4082063SAlex Williamson #define KVM_CAP_DISABLE_QUIRKS2 213 1183d525f73fSChenyi Qiang #define KVM_CAP_VM_TSC_CONTROL 214 1184e4082063SAlex Williamson #define KVM_CAP_SYSTEM_EVENT_DATA 215 1185d525f73fSChenyi Qiang #define KVM_CAP_ARM_SYSTEM_SUSPEND 216 1186d525f73fSChenyi Qiang #define KVM_CAP_S390_PROTECTED_DUMP 217 1187d525f73fSChenyi Qiang #define KVM_CAP_X86_TRIPLE_FAULT_EVENT 218 1188d525f73fSChenyi Qiang #define KVM_CAP_X86_NOTIFY_VMEXIT 219 1189d525f73fSChenyi Qiang #define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220 1190d525f73fSChenyi Qiang #define KVM_CAP_S390_ZPCI_OP 221 1191d525f73fSChenyi Qiang #define KVM_CAP_S390_CPU_TOPOLOGY 222 119293e0932bSPeter Xu #define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223 119393d7620cSAvihai Horon #define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224 119493d7620cSAvihai Horon #define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225 1195c5c0fdbeSDavid 'Digit' Turner #define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226 1196d0bf492fSCédric Le Goater #define KVM_CAP_COUNTER_OFFSET 227 1197d0bf492fSCédric Le Goater #define KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 228 1198d0bf492fSCédric Le Goater #define KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES 229 1199*efb91426SDaniel Henrique Barboza #define KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES 230 120051b24e34SJan Kiszka 120151b24e34SJan Kiszka #ifdef KVM_CAP_IRQ_ROUTING 120251b24e34SJan Kiszka 120351b24e34SJan Kiszka struct kvm_irq_routing_irqchip { 120451b24e34SJan Kiszka __u32 irqchip; 120551b24e34SJan Kiszka __u32 pin; 120651b24e34SJan Kiszka }; 120751b24e34SJan Kiszka 120851b24e34SJan Kiszka struct kvm_irq_routing_msi { 120951b24e34SJan Kiszka __u32 address_lo; 121051b24e34SJan Kiszka __u32 address_hi; 121151b24e34SJan Kiszka __u32 data; 1212dbdfea92SCornelia Huck union { 121351b24e34SJan Kiszka __u32 pad; 1214dbdfea92SCornelia Huck __u32 devid; 1215dbdfea92SCornelia Huck }; 121651b24e34SJan Kiszka }; 121751b24e34SJan Kiszka 12189ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter { 12199ffd2685SCornelia Huck __u64 ind_addr; 12209ffd2685SCornelia Huck __u64 summary_addr; 12219ffd2685SCornelia Huck __u64 ind_offset; 12229ffd2685SCornelia Huck __u32 summary_offset; 12239ffd2685SCornelia Huck __u32 adapter_id; 12249ffd2685SCornelia Huck }; 12259ffd2685SCornelia Huck 1226fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint { 1227fff02bc0SPaolo Bonzini __u32 vcpu; 1228fff02bc0SPaolo Bonzini __u32 sint; 1229fff02bc0SPaolo Bonzini }; 1230fff02bc0SPaolo Bonzini 1231ef17dd6aSVivek Goyal struct kvm_irq_routing_xen_evtchn { 1232ef17dd6aSVivek Goyal __u32 port; 1233ef17dd6aSVivek Goyal __u32 vcpu; 1234ef17dd6aSVivek Goyal __u32 priority; 1235ef17dd6aSVivek Goyal }; 1236ef17dd6aSVivek Goyal 1237ef17dd6aSVivek Goyal #define KVM_IRQ_ROUTING_XEN_EVTCHN_PRIO_2LEVEL ((__u32)(-1)) 1238ef17dd6aSVivek Goyal 123951b24e34SJan Kiszka /* gsi routing entry types */ 124051b24e34SJan Kiszka #define KVM_IRQ_ROUTING_IRQCHIP 1 124151b24e34SJan Kiszka #define KVM_IRQ_ROUTING_MSI 2 12429ffd2685SCornelia Huck #define KVM_IRQ_ROUTING_S390_ADAPTER 3 1243fff02bc0SPaolo Bonzini #define KVM_IRQ_ROUTING_HV_SINT 4 1244ef17dd6aSVivek Goyal #define KVM_IRQ_ROUTING_XEN_EVTCHN 5 124551b24e34SJan Kiszka 124651b24e34SJan Kiszka struct kvm_irq_routing_entry { 124751b24e34SJan Kiszka __u32 gsi; 124851b24e34SJan Kiszka __u32 type; 124951b24e34SJan Kiszka __u32 flags; 125051b24e34SJan Kiszka __u32 pad; 125151b24e34SJan Kiszka union { 125251b24e34SJan Kiszka struct kvm_irq_routing_irqchip irqchip; 125351b24e34SJan Kiszka struct kvm_irq_routing_msi msi; 12549ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter adapter; 1255fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint hv_sint; 1256ef17dd6aSVivek Goyal struct kvm_irq_routing_xen_evtchn xen_evtchn; 125751b24e34SJan Kiszka __u32 pad[8]; 125851b24e34SJan Kiszka } u; 125951b24e34SJan Kiszka }; 126051b24e34SJan Kiszka 126151b24e34SJan Kiszka struct kvm_irq_routing { 126251b24e34SJan Kiszka __u32 nr; 126351b24e34SJan Kiszka __u32 flags; 1264d525f73fSChenyi Qiang struct kvm_irq_routing_entry entries[]; 126551b24e34SJan Kiszka }; 126651b24e34SJan Kiszka 126751b24e34SJan Kiszka #endif 126851b24e34SJan Kiszka 126951b24e34SJan Kiszka #ifdef KVM_CAP_MCE 127051b24e34SJan Kiszka /* x86 MCE */ 127151b24e34SJan Kiszka struct kvm_x86_mce { 127251b24e34SJan Kiszka __u64 status; 127351b24e34SJan Kiszka __u64 addr; 127451b24e34SJan Kiszka __u64 misc; 127551b24e34SJan Kiszka __u64 mcg_status; 127651b24e34SJan Kiszka __u8 bank; 127751b24e34SJan Kiszka __u8 pad1[7]; 127851b24e34SJan Kiszka __u64 pad2[3]; 127951b24e34SJan Kiszka }; 128051b24e34SJan Kiszka #endif 128151b24e34SJan Kiszka 128251b24e34SJan Kiszka #ifdef KVM_CAP_XEN_HVM 1283278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR (1 << 0) 1284278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL (1 << 1) 1285278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2) 1286278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3) 1287ef17dd6aSVivek Goyal #define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4) 1288d525f73fSChenyi Qiang #define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5) 128993d7620cSAvihai Horon #define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG (1 << 6) 1290278f064eSEduardo Habkost 129151b24e34SJan Kiszka struct kvm_xen_hvm_config { 129251b24e34SJan Kiszka __u32 flags; 129351b24e34SJan Kiszka __u32 msr; 129451b24e34SJan Kiszka __u64 blob_addr_32; 129551b24e34SJan Kiszka __u64 blob_addr_64; 129651b24e34SJan Kiszka __u8 blob_size_32; 129751b24e34SJan Kiszka __u8 blob_size_64; 129851b24e34SJan Kiszka __u8 pad2[30]; 129951b24e34SJan Kiszka }; 130051b24e34SJan Kiszka #endif 130151b24e34SJan Kiszka 130251b24e34SJan Kiszka #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0) 1303716b8e4dSAlex Williamson /* 1304716b8e4dSAlex Williamson * Available with KVM_CAP_IRQFD_RESAMPLE 1305716b8e4dSAlex Williamson * 1306716b8e4dSAlex Williamson * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies 1307716b8e4dSAlex Williamson * the irqfd to operate in resampling mode for level triggered interrupt 1308f76b348eSCornelia Huck * emulation. See Documentation/virt/kvm/api.rst. 1309716b8e4dSAlex Williamson */ 1310716b8e4dSAlex Williamson #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1) 131151b24e34SJan Kiszka 131251b24e34SJan Kiszka struct kvm_irqfd { 131351b24e34SJan Kiszka __u32 fd; 131451b24e34SJan Kiszka __u32 gsi; 131551b24e34SJan Kiszka __u32 flags; 1316716b8e4dSAlex Williamson __u32 resamplefd; 1317716b8e4dSAlex Williamson __u8 pad[16]; 131851b24e34SJan Kiszka }; 131951b24e34SJan Kiszka 1320bc204035SMarcelo Tosatti /* For KVM_CAP_ADJUST_CLOCK */ 1321bc204035SMarcelo Tosatti 1322bc204035SMarcelo Tosatti /* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags. */ 1323bc204035SMarcelo Tosatti #define KVM_CLOCK_TSC_STABLE 2 132443709a0cSPaolo Bonzini #define KVM_CLOCK_REALTIME (1 << 2) 132543709a0cSPaolo Bonzini #define KVM_CLOCK_HOST_TSC (1 << 3) 1326bc204035SMarcelo Tosatti 132751b24e34SJan Kiszka struct kvm_clock_data { 132851b24e34SJan Kiszka __u64 clock; 132951b24e34SJan Kiszka __u32 flags; 133043709a0cSPaolo Bonzini __u32 pad0; 133143709a0cSPaolo Bonzini __u64 realtime; 133243709a0cSPaolo Bonzini __u64 host_tsc; 133343709a0cSPaolo Bonzini __u32 pad[4]; 133451b24e34SJan Kiszka }; 133551b24e34SJan Kiszka 1336bc204035SMarcelo Tosatti /* For KVM_CAP_SW_TLB */ 1337bc204035SMarcelo Tosatti 1338a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_NOHV 0 1339a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_HV 1 1340a54fc080SAlexander Graf 1341a54fc080SAlexander Graf struct kvm_config_tlb { 1342a54fc080SAlexander Graf __u64 params; 1343a54fc080SAlexander Graf __u64 array; 1344a54fc080SAlexander Graf __u32 mmu_type; 1345a54fc080SAlexander Graf __u32 array_len; 1346a54fc080SAlexander Graf }; 1347a54fc080SAlexander Graf 1348a54fc080SAlexander Graf struct kvm_dirty_tlb { 1349a54fc080SAlexander Graf __u64 bitmap; 1350a54fc080SAlexander Graf __u32 num_dirty; 1351a54fc080SAlexander Graf }; 1352a54fc080SAlexander Graf 13539d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 13549d4e4f8cSAlexander Graf 1355a31be480SAlexander Graf #define KVM_REG_ARCH_MASK 0xff00000000000000ULL 1356a31be480SAlexander Graf #define KVM_REG_GENERIC 0x0000000000000000ULL 13579d4e4f8cSAlexander Graf 13589d4e4f8cSAlexander Graf /* 13599d4e4f8cSAlexander Graf * Architecture specific registers are to be defined in arch headers and 13609d4e4f8cSAlexander Graf * ORed with the arch identifier. 13619d4e4f8cSAlexander Graf */ 1362a31be480SAlexander Graf #define KVM_REG_PPC 0x1000000000000000ULL 1363a31be480SAlexander Graf #define KVM_REG_X86 0x2000000000000000ULL 1364a31be480SAlexander Graf #define KVM_REG_IA64 0x3000000000000000ULL 1365a31be480SAlexander Graf #define KVM_REG_ARM 0x4000000000000000ULL 1366a31be480SAlexander Graf #define KVM_REG_S390 0x5000000000000000ULL 1367c5daeae1SAlexey Kardashevskiy #define KVM_REG_ARM64 0x6000000000000000ULL 1368c5daeae1SAlexey Kardashevskiy #define KVM_REG_MIPS 0x7000000000000000ULL 1369f363d039SEric Auger #define KVM_REG_RISCV 0x8000000000000000ULL 1370*efb91426SDaniel Henrique Barboza #define KVM_REG_LOONGARCH 0x9000000000000000ULL 1371a31be480SAlexander Graf 1372a31be480SAlexander Graf #define KVM_REG_SIZE_SHIFT 52 1373a31be480SAlexander Graf #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL 1374a31be480SAlexander Graf #define KVM_REG_SIZE_U8 0x0000000000000000ULL 1375a31be480SAlexander Graf #define KVM_REG_SIZE_U16 0x0010000000000000ULL 1376a31be480SAlexander Graf #define KVM_REG_SIZE_U32 0x0020000000000000ULL 1377a31be480SAlexander Graf #define KVM_REG_SIZE_U64 0x0030000000000000ULL 1378a31be480SAlexander Graf #define KVM_REG_SIZE_U128 0x0040000000000000ULL 1379a31be480SAlexander Graf #define KVM_REG_SIZE_U256 0x0050000000000000ULL 1380a31be480SAlexander Graf #define KVM_REG_SIZE_U512 0x0060000000000000ULL 1381a31be480SAlexander Graf #define KVM_REG_SIZE_U1024 0x0070000000000000ULL 1382d9cb4336SCornelia Huck #define KVM_REG_SIZE_U2048 0x0080000000000000ULL 13839d4e4f8cSAlexander Graf 1384eadd0e44SPeter Maydell struct kvm_reg_list { 1385eadd0e44SPeter Maydell __u64 n; /* number of regs */ 1386d525f73fSChenyi Qiang __u64 reg[]; 1387eadd0e44SPeter Maydell }; 1388eadd0e44SPeter Maydell 13899d4e4f8cSAlexander Graf struct kvm_one_reg { 13909d4e4f8cSAlexander Graf __u64 id; 1391a31be480SAlexander Graf __u64 addr; 13929d4e4f8cSAlexander Graf }; 13939d4e4f8cSAlexander Graf 1394dbdfea92SCornelia Huck #define KVM_MSI_VALID_DEVID (1U << 0) 139580a3eb10SJan Kiszka struct kvm_msi { 139680a3eb10SJan Kiszka __u32 address_lo; 139780a3eb10SJan Kiszka __u32 address_hi; 139880a3eb10SJan Kiszka __u32 data; 139980a3eb10SJan Kiszka __u32 flags; 1400dbdfea92SCornelia Huck __u32 devid; 1401dbdfea92SCornelia Huck __u8 pad[12]; 140280a3eb10SJan Kiszka }; 140380a3eb10SJan Kiszka 1404eadd0e44SPeter Maydell struct kvm_arm_device_addr { 1405eadd0e44SPeter Maydell __u64 id; 1406eadd0e44SPeter Maydell __u64 addr; 1407eadd0e44SPeter Maydell }; 1408eadd0e44SPeter Maydell 140951b24e34SJan Kiszka /* 1410e098b453SAlexey Kardashevskiy * Device control API, available with KVM_CAP_DEVICE_CTRL 1411e098b453SAlexey Kardashevskiy */ 1412e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE_TEST 1 1413e098b453SAlexey Kardashevskiy 1414e098b453SAlexey Kardashevskiy struct kvm_create_device { 1415e098b453SAlexey Kardashevskiy __u32 type; /* in: KVM_DEV_TYPE_xxx */ 1416e098b453SAlexey Kardashevskiy __u32 fd; /* out: device handle */ 1417e098b453SAlexey Kardashevskiy __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */ 1418e098b453SAlexey Kardashevskiy }; 1419e098b453SAlexey Kardashevskiy 1420e098b453SAlexey Kardashevskiy struct kvm_device_attr { 1421e098b453SAlexey Kardashevskiy __u32 flags; /* no flags currently defined */ 1422e098b453SAlexey Kardashevskiy __u32 group; /* device-defined */ 1423e098b453SAlexey Kardashevskiy __u64 attr; /* group-defined */ 1424e098b453SAlexey Kardashevskiy __u64 addr; /* userspace address of attr data */ 1425e098b453SAlexey Kardashevskiy }; 1426e098b453SAlexey Kardashevskiy 1427da3c22c7SThomas Huth #define KVM_DEV_VFIO_FILE 1 1428da3c22c7SThomas Huth 1429da3c22c7SThomas Huth #define KVM_DEV_VFIO_FILE_ADD 1 1430da3c22c7SThomas Huth #define KVM_DEV_VFIO_FILE_DEL 2 1431da3c22c7SThomas Huth 1432da3c22c7SThomas Huth /* KVM_DEV_VFIO_GROUP aliases are for compile time uapi compatibility */ 1433da3c22c7SThomas Huth #define KVM_DEV_VFIO_GROUP KVM_DEV_VFIO_FILE 1434da3c22c7SThomas Huth 1435da3c22c7SThomas Huth #define KVM_DEV_VFIO_GROUP_ADD KVM_DEV_VFIO_FILE_ADD 1436da3c22c7SThomas Huth #define KVM_DEV_VFIO_GROUP_DEL KVM_DEV_VFIO_FILE_DEL 143774c98e20SCornelia Huck #define KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE 3 1438444b1996SArd Biesheuvel 1439444b1996SArd Biesheuvel enum kvm_device_type { 1440444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_20 = 1, 1441444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_20 KVM_DEV_TYPE_FSL_MPIC_20 1442444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_42, 1443444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_42 KVM_DEV_TYPE_FSL_MPIC_42 1444444b1996SArd Biesheuvel KVM_DEV_TYPE_XICS, 1445444b1996SArd Biesheuvel #define KVM_DEV_TYPE_XICS KVM_DEV_TYPE_XICS 1446444b1996SArd Biesheuvel KVM_DEV_TYPE_VFIO, 1447444b1996SArd Biesheuvel #define KVM_DEV_TYPE_VFIO KVM_DEV_TYPE_VFIO 1448444b1996SArd Biesheuvel KVM_DEV_TYPE_ARM_VGIC_V2, 1449444b1996SArd Biesheuvel #define KVM_DEV_TYPE_ARM_VGIC_V2 KVM_DEV_TYPE_ARM_VGIC_V2 1450444b1996SArd Biesheuvel KVM_DEV_TYPE_FLIC, 1451444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_FLIC 145251628b18SChristian Borntraeger KVM_DEV_TYPE_ARM_VGIC_V3, 145351628b18SChristian Borntraeger #define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3 1454dbdfea92SCornelia Huck KVM_DEV_TYPE_ARM_VGIC_ITS, 1455dbdfea92SCornelia Huck #define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS 1456d9cb4336SCornelia Huck KVM_DEV_TYPE_XIVE, 1457d9cb4336SCornelia Huck #define KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_XIVE 14582a886794SGreg Kurz KVM_DEV_TYPE_ARM_PV_TIME, 14592a886794SGreg Kurz #define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME 1460d0bf492fSCédric Le Goater KVM_DEV_TYPE_RISCV_AIA, 1461d0bf492fSCédric Le Goater #define KVM_DEV_TYPE_RISCV_AIA KVM_DEV_TYPE_RISCV_AIA 1462444b1996SArd Biesheuvel KVM_DEV_TYPE_MAX, 1463444b1996SArd Biesheuvel }; 1464e098b453SAlexey Kardashevskiy 146574c98e20SCornelia Huck struct kvm_vfio_spapr_tce { 146674c98e20SCornelia Huck __s32 groupfd; 146774c98e20SCornelia Huck __s32 tablefd; 146874c98e20SCornelia Huck }; 146974c98e20SCornelia Huck 1470e098b453SAlexey Kardashevskiy /* 147151b24e34SJan Kiszka * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns 147251b24e34SJan Kiszka * a vcpu fd. 147351b24e34SJan Kiszka */ 147451b24e34SJan Kiszka #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) 147551b24e34SJan Kiszka #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) 147651b24e34SJan Kiszka #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) 1477d0bf492fSCédric Le Goater #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) /* deprecated */ 147851b24e34SJan Kiszka #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ 147951b24e34SJan Kiszka struct kvm_userspace_memory_region) 148051b24e34SJan Kiszka #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) 148151b24e34SJan Kiszka #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64) 14821529ae1bSAlexander Graf 14831529ae1bSAlexander Graf /* enable ucontrol for s390 */ 14841529ae1bSAlexander Graf struct kvm_s390_ucas_mapping { 14851529ae1bSAlexander Graf __u64 user_addr; 14861529ae1bSAlexander Graf __u64 vcpu_addr; 14871529ae1bSAlexander Graf __u64 length; 14881529ae1bSAlexander Graf }; 14891529ae1bSAlexander Graf #define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping) 14901529ae1bSAlexander Graf #define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping) 14911529ae1bSAlexander Graf #define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long) 14921529ae1bSAlexander Graf 149351b24e34SJan Kiszka /* Device model IOC */ 149451b24e34SJan Kiszka #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) 149551b24e34SJan Kiszka #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) 149651b24e34SJan Kiszka #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) 149751b24e34SJan Kiszka #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) 149851b24e34SJan Kiszka #define KVM_CREATE_PIT _IO(KVMIO, 0x64) 149951b24e34SJan Kiszka #define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state) 150051b24e34SJan Kiszka #define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state) 150151b24e34SJan Kiszka #define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level) 150251b24e34SJan Kiszka #define KVM_REGISTER_COALESCED_MMIO \ 150351b24e34SJan Kiszka _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone) 150451b24e34SJan Kiszka #define KVM_UNREGISTER_COALESCED_MMIO \ 150551b24e34SJan Kiszka _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone) 150651b24e34SJan Kiszka #define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \ 150751b24e34SJan Kiszka struct kvm_assigned_pci_dev) 150851b24e34SJan Kiszka #define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing) 150951b24e34SJan Kiszka /* deprecated, replaced by KVM_ASSIGN_DEV_IRQ */ 151051b24e34SJan Kiszka #define KVM_ASSIGN_IRQ __KVM_DEPRECATED_VM_R_0x70 151151b24e34SJan Kiszka #define KVM_ASSIGN_DEV_IRQ _IOW(KVMIO, 0x70, struct kvm_assigned_irq) 151251b24e34SJan Kiszka #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71) 151351b24e34SJan Kiszka #define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, \ 151451b24e34SJan Kiszka struct kvm_assigned_pci_dev) 151551b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_NR _IOW(KVMIO, 0x73, \ 151651b24e34SJan Kiszka struct kvm_assigned_msix_nr) 151751b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO, 0x74, \ 151851b24e34SJan Kiszka struct kvm_assigned_msix_entry) 151951b24e34SJan Kiszka #define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq) 152051b24e34SJan Kiszka #define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd) 152151b24e34SJan Kiszka #define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config) 152251b24e34SJan Kiszka #define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78) 152351b24e34SJan Kiszka #define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd) 152451b24e34SJan Kiszka #define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config) 152551b24e34SJan Kiszka #define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data) 152651b24e34SJan Kiszka #define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data) 152751b24e34SJan Kiszka /* Available with KVM_CAP_PIT_STATE2 */ 152851b24e34SJan Kiszka #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) 152951b24e34SJan Kiszka #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) 153051b24e34SJan Kiszka /* Available with KVM_CAP_PPC_GET_PVINFO */ 153151b24e34SJan Kiszka #define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo) 1532d525f73fSChenyi Qiang /* Available with KVM_CAP_TSC_CONTROL for a vCPU, or with 1533d525f73fSChenyi Qiang * KVM_CAP_VM_TSC_CONTROL to set defaults for a VM */ 153451b24e34SJan Kiszka #define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2) 153551b24e34SJan Kiszka #define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3) 15369ab2195dSMarcelo Tosatti /* Available with KVM_CAP_PCI_2_3 */ 15379ab2195dSMarcelo Tosatti #define KVM_ASSIGN_SET_INTX_MASK _IOW(KVMIO, 0xa4, \ 15389ab2195dSMarcelo Tosatti struct kvm_assigned_pci_dev) 153980a3eb10SJan Kiszka /* Available with KVM_CAP_SIGNAL_MSI */ 154080a3eb10SJan Kiszka #define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi) 154180a3eb10SJan Kiszka /* Available with KVM_CAP_PPC_GET_SMMU_INFO */ 154280a3eb10SJan Kiszka #define KVM_PPC_GET_SMMU_INFO _IOR(KVMIO, 0xa6, struct kvm_ppc_smmu_info) 1543651682dcSMichael S. Tsirkin /* Available with KVM_CAP_PPC_ALLOC_HTAB */ 1544651682dcSMichael S. Tsirkin #define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32) 1545d4834ff9SAlexander Graf #define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce) 1546b89485a5SPaolo Bonzini #define KVM_CREATE_SPAPR_TCE_64 _IOW(KVMIO, 0xa8, \ 1547b89485a5SPaolo Bonzini struct kvm_create_spapr_tce_64) 1548d4834ff9SAlexander Graf /* Available with KVM_CAP_RMA */ 1549d4834ff9SAlexander Graf #define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma) 1550d4834ff9SAlexander Graf /* Available with KVM_CAP_PPC_HTAB_FD */ 1551d4834ff9SAlexander Graf #define KVM_PPC_GET_HTAB_FD _IOW(KVMIO, 0xaa, struct kvm_get_htab_fd) 1552eadd0e44SPeter Maydell /* Available with KVM_CAP_ARM_SET_DEVICE_ADDR */ 1553eadd0e44SPeter Maydell #define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr) 1554e098b453SAlexey Kardashevskiy /* Available with KVM_CAP_PPC_RTAS */ 1555e098b453SAlexey Kardashevskiy #define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args) 15563a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_SPAPR_RESIZE_HPT */ 15573a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt) 15583a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt) 15593a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */ 15603a5eb5b4SPaolo Bonzini #define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg) 15613a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_PPC_RADIX_MMU */ 15623a5eb5b4SPaolo Bonzini #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info) 15639cbb6362SCornelia Huck /* Available with KVM_CAP_PPC_GET_CPU_CHAR */ 15649cbb6362SCornelia Huck #define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char) 1565f363d039SEric Auger /* Available with KVM_CAP_PMU_EVENT_FILTER */ 1566f363d039SEric Auger #define KVM_SET_PMU_EVENT_FILTER _IOW(KVMIO, 0xb2, struct kvm_pmu_event_filter) 156750fd0c37SBharata B Rao #define KVM_PPC_SVM_OFF _IO(KVMIO, 0xb3) 1568327d4b7fSBharata B Rao #define KVM_ARM_MTE_COPY_TAGS _IOR(KVMIO, 0xb4, struct kvm_arm_copy_mte_tags) 1569d0bf492fSCédric Le Goater /* Available with KVM_CAP_COUNTER_OFFSET */ 1570d0bf492fSCédric Le Goater #define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO, 0xb5, struct kvm_arm_counter_offset) 1571*efb91426SDaniel Henrique Barboza #define KVM_ARM_GET_REG_WRITABLE_MASKS _IOR(KVMIO, 0xb6, struct reg_mask_range) 1572e098b453SAlexey Kardashevskiy 1573e098b453SAlexey Kardashevskiy /* ioctl for vm fd */ 1574e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) 1575e098b453SAlexey Kardashevskiy 1576e098b453SAlexey Kardashevskiy /* ioctls for fds returned by KVM_CREATE_DEVICE */ 1577e098b453SAlexey Kardashevskiy #define KVM_SET_DEVICE_ATTR _IOW(KVMIO, 0xe1, struct kvm_device_attr) 1578e098b453SAlexey Kardashevskiy #define KVM_GET_DEVICE_ATTR _IOW(KVMIO, 0xe2, struct kvm_device_attr) 1579e098b453SAlexey Kardashevskiy #define KVM_HAS_DEVICE_ATTR _IOW(KVMIO, 0xe3, struct kvm_device_attr) 158051b24e34SJan Kiszka 158151b24e34SJan Kiszka /* 158251b24e34SJan Kiszka * ioctls for vcpu fds 158351b24e34SJan Kiszka */ 158451b24e34SJan Kiszka #define KVM_RUN _IO(KVMIO, 0x80) 158551b24e34SJan Kiszka #define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs) 158651b24e34SJan Kiszka #define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs) 158751b24e34SJan Kiszka #define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs) 158851b24e34SJan Kiszka #define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs) 158951b24e34SJan Kiszka #define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation) 159051b24e34SJan Kiszka #define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt) 159151b24e34SJan Kiszka /* KVM_DEBUG_GUEST is no longer supported, use KVM_SET_GUEST_DEBUG instead */ 159251b24e34SJan Kiszka #define KVM_DEBUG_GUEST __KVM_DEPRECATED_VCPU_W_0x87 159351b24e34SJan Kiszka #define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs) 159451b24e34SJan Kiszka #define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs) 159551b24e34SJan Kiszka #define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid) 159651b24e34SJan Kiszka #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask) 159751b24e34SJan Kiszka #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu) 159851b24e34SJan Kiszka #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) 159951b24e34SJan Kiszka #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) 160051b24e34SJan Kiszka #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) 160151b24e34SJan Kiszka #define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) 160251b24e34SJan Kiszka #define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2) 160351b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 160451b24e34SJan Kiszka #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl) 160551b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 160651b24e34SJan Kiszka #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) 160751b24e34SJan Kiszka /* valid for virtual machine (for floating interrupt)_and_ vcpu */ 160851b24e34SJan Kiszka #define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt) 160951b24e34SJan Kiszka /* store status for s390 */ 161051b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_NOADDR (-1ul) 161151b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_PREFIXED (-2ul) 161251b24e34SJan Kiszka #define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long) 161351b24e34SJan Kiszka /* initial ipl psw for s390 */ 161451b24e34SJan Kiszka #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw) 161551b24e34SJan Kiszka /* initial reset for s390 */ 161651b24e34SJan Kiszka #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) 161751b24e34SJan Kiszka #define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) 161851b24e34SJan Kiszka #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) 1619444b1996SArd Biesheuvel /* Available with KVM_CAP_USER_NMI */ 162051b24e34SJan Kiszka #define KVM_NMI _IO(KVMIO, 0x9a) 162151b24e34SJan Kiszka /* Available with KVM_CAP_SET_GUEST_DEBUG */ 162251b24e34SJan Kiszka #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) 162351b24e34SJan Kiszka /* MCE for x86 */ 162451b24e34SJan Kiszka #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64) 162551b24e34SJan Kiszka #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64) 162651b24e34SJan Kiszka #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) 162751b24e34SJan Kiszka /* Available with KVM_CAP_VCPU_EVENTS */ 162851b24e34SJan Kiszka #define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events) 162951b24e34SJan Kiszka #define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events) 163051b24e34SJan Kiszka /* Available with KVM_CAP_DEBUGREGS */ 163151b24e34SJan Kiszka #define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs) 163251b24e34SJan Kiszka #define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs) 16339ffd2685SCornelia Huck /* 1634d0bf492fSCédric Le Goater * vcpu version available with KVM_CAP_ENABLE_CAP 16359ffd2685SCornelia Huck * vm version available with KVM_CAP_ENABLE_CAP_VM 16369ffd2685SCornelia Huck */ 163751b24e34SJan Kiszka #define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap) 163851b24e34SJan Kiszka /* Available with KVM_CAP_XSAVE */ 163951b24e34SJan Kiszka #define KVM_GET_XSAVE _IOR(KVMIO, 0xa4, struct kvm_xsave) 164051b24e34SJan Kiszka #define KVM_SET_XSAVE _IOW(KVMIO, 0xa5, struct kvm_xsave) 164151b24e34SJan Kiszka /* Available with KVM_CAP_XCRS */ 164251b24e34SJan Kiszka #define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs) 164351b24e34SJan Kiszka #define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs) 1644a54fc080SAlexander Graf /* Available with KVM_CAP_SW_TLB */ 1645a54fc080SAlexander Graf #define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb) 16469d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 1647a31be480SAlexander Graf #define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg) 16489d4e4f8cSAlexander Graf #define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg) 16499ab2195dSMarcelo Tosatti /* VM is being stopped by host */ 16509ab2195dSMarcelo Tosatti #define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad) 1651eadd0e44SPeter Maydell #define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init) 1652bf63839fSAlex Williamson #define KVM_ARM_PREFERRED_TARGET _IOR(KVMIO, 0xaf, struct kvm_vcpu_init) 1653eadd0e44SPeter Maydell #define KVM_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list) 16547a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_MEM_OP */ 16557a52ce8aSCornelia Huck #define KVM_S390_MEM_OP _IOW(KVMIO, 0xb1, struct kvm_s390_mem_op) 16567a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_SKEYS */ 16577a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS _IOW(KVMIO, 0xb2, struct kvm_s390_skeys) 16587a52ce8aSCornelia Huck #define KVM_S390_SET_SKEYS _IOW(KVMIO, 0xb3, struct kvm_s390_skeys) 16597a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_INJECT_IRQ */ 16607a52ce8aSCornelia Huck #define KVM_S390_IRQ _IOW(KVMIO, 0xb4, struct kvm_s390_irq) 16617a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_IRQ_STATE */ 16627a52ce8aSCornelia Huck #define KVM_S390_SET_IRQ_STATE _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state) 16637a52ce8aSCornelia Huck #define KVM_S390_GET_IRQ_STATE _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state) 166424a31426SPaolo Bonzini /* Available with KVM_CAP_X86_SMM */ 166524a31426SPaolo Bonzini #define KVM_SMI _IO(KVMIO, 0xb7) 16663272f0e2SChristian Borntraeger /* Available with KVM_CAP_S390_CMMA_MIGRATION */ 1667ab6e1550SChristian Borntraeger #define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log) 16683272f0e2SChristian Borntraeger #define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log) 16699f2d175dSPaolo Bonzini /* Memory Encryption Commands */ 16709f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_OP _IOWR(KVMIO, 0xba, unsigned long) 16719f2d175dSPaolo Bonzini 16729f2d175dSPaolo Bonzini struct kvm_enc_region { 16739f2d175dSPaolo Bonzini __u64 addr; 16749f2d175dSPaolo Bonzini __u64 size; 16759f2d175dSPaolo Bonzini }; 16769f2d175dSPaolo Bonzini 16779f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_REG_REGION _IOR(KVMIO, 0xbb, struct kvm_enc_region) 16789f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_UNREG_REGION _IOR(KVMIO, 0xbc, struct kvm_enc_region) 16799f2d175dSPaolo Bonzini 168065a6d8ddSPeter Maydell /* Available with KVM_CAP_HYPERV_EVENTFD */ 168165a6d8ddSPeter Maydell #define KVM_HYPERV_EVENTFD _IOW(KVMIO, 0xbd, struct kvm_hyperv_eventfd) 168265a6d8ddSPeter Maydell 1683d36f7de8SCornelia Huck /* Available with KVM_CAP_NESTED_STATE */ 1684d36f7de8SCornelia Huck #define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state) 1685d36f7de8SCornelia Huck #define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state) 168665a6d8ddSPeter Maydell 1687d9cb4336SCornelia Huck /* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT_2 */ 1688da054c64SPaolo Bonzini #define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log) 1689da054c64SPaolo Bonzini 1690b3c818a4SEric Farman /* Available with KVM_CAP_HYPERV_CPUID (vcpu) / KVM_CAP_SYS_HYPERV_CPUID (system) */ 1691da054c64SPaolo Bonzini #define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2) 1692da054c64SPaolo Bonzini 1693d9cb4336SCornelia Huck /* Available with KVM_CAP_ARM_SVE */ 1694d9cb4336SCornelia Huck #define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int) 1695d9cb4336SCornelia Huck 1696ddda3748SCornelia Huck /* Available with KVM_CAP_S390_VCPU_RESETS */ 1697ddda3748SCornelia Huck #define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3) 1698ddda3748SCornelia Huck #define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4) 1699ddda3748SCornelia Huck 1700dc6f8d45SCornelia Huck struct kvm_s390_pv_sec_parm { 1701dc6f8d45SCornelia Huck __u64 origin; 1702dc6f8d45SCornelia Huck __u64 length; 1703dc6f8d45SCornelia Huck }; 1704dc6f8d45SCornelia Huck 1705dc6f8d45SCornelia Huck struct kvm_s390_pv_unp { 1706dc6f8d45SCornelia Huck __u64 addr; 1707dc6f8d45SCornelia Huck __u64 size; 1708dc6f8d45SCornelia Huck __u64 tweak; 1709dc6f8d45SCornelia Huck }; 1710dc6f8d45SCornelia Huck 1711d525f73fSChenyi Qiang enum pv_cmd_dmp_id { 1712d525f73fSChenyi Qiang KVM_PV_DUMP_INIT, 1713d525f73fSChenyi Qiang KVM_PV_DUMP_CONFIG_STOR_STATE, 1714d525f73fSChenyi Qiang KVM_PV_DUMP_COMPLETE, 1715d525f73fSChenyi Qiang KVM_PV_DUMP_CPU, 1716d525f73fSChenyi Qiang }; 1717d525f73fSChenyi Qiang 1718d525f73fSChenyi Qiang struct kvm_s390_pv_dmp { 1719d525f73fSChenyi Qiang __u64 subcmd; 1720d525f73fSChenyi Qiang __u64 buff_addr; 1721d525f73fSChenyi Qiang __u64 buff_len; 1722d525f73fSChenyi Qiang __u64 gaddr; /* For dump storage state */ 1723d525f73fSChenyi Qiang __u64 reserved[4]; 1724d525f73fSChenyi Qiang }; 1725d525f73fSChenyi Qiang 1726d525f73fSChenyi Qiang enum pv_cmd_info_id { 1727d525f73fSChenyi Qiang KVM_PV_INFO_VM, 1728d525f73fSChenyi Qiang KVM_PV_INFO_DUMP, 1729d525f73fSChenyi Qiang }; 1730d525f73fSChenyi Qiang 1731d525f73fSChenyi Qiang struct kvm_s390_pv_info_dump { 1732d525f73fSChenyi Qiang __u64 dump_cpu_buffer_len; 1733d525f73fSChenyi Qiang __u64 dump_config_mem_buffer_per_1m; 1734d525f73fSChenyi Qiang __u64 dump_config_finalize_len; 1735d525f73fSChenyi Qiang }; 1736d525f73fSChenyi Qiang 1737d525f73fSChenyi Qiang struct kvm_s390_pv_info_vm { 1738d525f73fSChenyi Qiang __u64 inst_calls_list[4]; 1739d525f73fSChenyi Qiang __u64 max_cpus; 1740d525f73fSChenyi Qiang __u64 max_guests; 1741d525f73fSChenyi Qiang __u64 max_guest_addr; 1742d525f73fSChenyi Qiang __u64 feature_indication; 1743d525f73fSChenyi Qiang }; 1744d525f73fSChenyi Qiang 1745d525f73fSChenyi Qiang struct kvm_s390_pv_info_header { 1746d525f73fSChenyi Qiang __u32 id; 1747d525f73fSChenyi Qiang __u32 len_max; 1748d525f73fSChenyi Qiang __u32 len_written; 1749d525f73fSChenyi Qiang __u32 reserved; 1750d525f73fSChenyi Qiang }; 1751d525f73fSChenyi Qiang 1752d525f73fSChenyi Qiang struct kvm_s390_pv_info { 1753d525f73fSChenyi Qiang struct kvm_s390_pv_info_header header; 1754d525f73fSChenyi Qiang union { 1755d525f73fSChenyi Qiang struct kvm_s390_pv_info_dump dump; 1756d525f73fSChenyi Qiang struct kvm_s390_pv_info_vm vm; 1757d525f73fSChenyi Qiang }; 1758d525f73fSChenyi Qiang }; 1759d525f73fSChenyi Qiang 1760dc6f8d45SCornelia Huck enum pv_cmd_id { 1761dc6f8d45SCornelia Huck KVM_PV_ENABLE, 1762dc6f8d45SCornelia Huck KVM_PV_DISABLE, 1763dc6f8d45SCornelia Huck KVM_PV_SET_SEC_PARMS, 1764dc6f8d45SCornelia Huck KVM_PV_UNPACK, 1765dc6f8d45SCornelia Huck KVM_PV_VERIFY, 1766dc6f8d45SCornelia Huck KVM_PV_PREP_RESET, 1767dc6f8d45SCornelia Huck KVM_PV_UNSHARE_ALL, 1768d525f73fSChenyi Qiang KVM_PV_INFO, 1769d525f73fSChenyi Qiang KVM_PV_DUMP, 177093d7620cSAvihai Horon KVM_PV_ASYNC_CLEANUP_PREPARE, 177193d7620cSAvihai Horon KVM_PV_ASYNC_CLEANUP_PERFORM, 1772dc6f8d45SCornelia Huck }; 1773dc6f8d45SCornelia Huck 1774dc6f8d45SCornelia Huck struct kvm_pv_cmd { 1775dc6f8d45SCornelia Huck __u32 cmd; /* Command to be executed */ 1776dc6f8d45SCornelia Huck __u16 rc; /* Ultravisor return code */ 1777dc6f8d45SCornelia Huck __u16 rrc; /* Ultravisor return reason code */ 1778dc6f8d45SCornelia Huck __u64 data; /* Data or address */ 1779dc6f8d45SCornelia Huck __u32 flags; /* flags for future extensions. Must be 0 for now */ 1780dc6f8d45SCornelia Huck __u32 reserved[3]; 1781dc6f8d45SCornelia Huck }; 1782dc6f8d45SCornelia Huck 1783dc6f8d45SCornelia Huck /* Available with KVM_CAP_S390_PROTECTED */ 1784dc6f8d45SCornelia Huck #define KVM_S390_PV_COMMAND _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd) 1785dc6f8d45SCornelia Huck 178653ba2eeeSMatthew Rosato /* Available with KVM_CAP_X86_MSR_FILTER */ 178753ba2eeeSMatthew Rosato #define KVM_X86_SET_MSR_FILTER _IOW(KVMIO, 0xc6, struct kvm_msr_filter) 178853ba2eeeSMatthew Rosato 1789b3c818a4SEric Farman /* Available with KVM_CAP_DIRTY_LOG_RING */ 1790b3c818a4SEric Farman #define KVM_RESET_DIRTY_RINGS _IO(KVMIO, 0xc7) 1791b3c818a4SEric Farman 1792278f064eSEduardo Habkost /* Per-VM Xen attributes */ 1793278f064eSEduardo Habkost #define KVM_XEN_HVM_GET_ATTR _IOWR(KVMIO, 0xc8, struct kvm_xen_hvm_attr) 1794278f064eSEduardo Habkost #define KVM_XEN_HVM_SET_ATTR _IOW(KVMIO, 0xc9, struct kvm_xen_hvm_attr) 1795278f064eSEduardo Habkost 1796278f064eSEduardo Habkost struct kvm_xen_hvm_attr { 1797278f064eSEduardo Habkost __u16 type; 1798278f064eSEduardo Habkost __u16 pad[3]; 1799278f064eSEduardo Habkost union { 1800278f064eSEduardo Habkost __u8 long_mode; 1801278f064eSEduardo Habkost __u8 vector; 180293d7620cSAvihai Horon __u8 runstate_update_flag; 1803278f064eSEduardo Habkost struct { 1804278f064eSEduardo Habkost __u64 gfn; 180593d7620cSAvihai Horon #define KVM_XEN_INVALID_GFN ((__u64)-1) 1806278f064eSEduardo Habkost } shared_info; 1807d525f73fSChenyi Qiang struct { 1808d525f73fSChenyi Qiang __u32 send_port; 1809d525f73fSChenyi Qiang __u32 type; /* EVTCHNSTAT_ipi / EVTCHNSTAT_interdomain */ 1810d525f73fSChenyi Qiang __u32 flags; 1811d525f73fSChenyi Qiang #define KVM_XEN_EVTCHN_DEASSIGN (1 << 0) 1812d525f73fSChenyi Qiang #define KVM_XEN_EVTCHN_UPDATE (1 << 1) 1813d525f73fSChenyi Qiang #define KVM_XEN_EVTCHN_RESET (1 << 2) 1814d525f73fSChenyi Qiang /* 1815d525f73fSChenyi Qiang * Events sent by the guest are either looped back to 1816d525f73fSChenyi Qiang * the guest itself (potentially on a different port#) 1817d525f73fSChenyi Qiang * or signalled via an eventfd. 1818d525f73fSChenyi Qiang */ 1819d525f73fSChenyi Qiang union { 1820d525f73fSChenyi Qiang struct { 1821d525f73fSChenyi Qiang __u32 port; 1822d525f73fSChenyi Qiang __u32 vcpu; 1823d525f73fSChenyi Qiang __u32 priority; 1824d525f73fSChenyi Qiang } port; 1825d525f73fSChenyi Qiang struct { 1826d525f73fSChenyi Qiang __u32 port; /* Zero for eventfd */ 1827d525f73fSChenyi Qiang __s32 fd; 1828d525f73fSChenyi Qiang } eventfd; 1829d525f73fSChenyi Qiang __u32 padding[4]; 1830d525f73fSChenyi Qiang } deliver; 1831d525f73fSChenyi Qiang } evtchn; 1832d525f73fSChenyi Qiang __u32 xen_version; 1833278f064eSEduardo Habkost __u64 pad[8]; 1834278f064eSEduardo Habkost } u; 1835278f064eSEduardo Habkost }; 1836278f064eSEduardo Habkost 183793d7620cSAvihai Horon 1838278f064eSEduardo Habkost /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */ 1839278f064eSEduardo Habkost #define KVM_XEN_ATTR_TYPE_LONG_MODE 0x0 1840278f064eSEduardo Habkost #define KVM_XEN_ATTR_TYPE_SHARED_INFO 0x1 1841278f064eSEduardo Habkost #define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR 0x2 1842d525f73fSChenyi Qiang /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */ 1843d525f73fSChenyi Qiang #define KVM_XEN_ATTR_TYPE_EVTCHN 0x3 1844d525f73fSChenyi Qiang #define KVM_XEN_ATTR_TYPE_XEN_VERSION 0x4 184593d7620cSAvihai Horon /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG */ 184693d7620cSAvihai Horon #define KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG 0x5 1847278f064eSEduardo Habkost 1848278f064eSEduardo Habkost /* Per-vCPU Xen attributes */ 1849278f064eSEduardo Habkost #define KVM_XEN_VCPU_GET_ATTR _IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr) 1850278f064eSEduardo Habkost #define KVM_XEN_VCPU_SET_ATTR _IOW(KVMIO, 0xcb, struct kvm_xen_vcpu_attr) 1851278f064eSEduardo Habkost 1852d525f73fSChenyi Qiang /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */ 1853d525f73fSChenyi Qiang #define KVM_XEN_HVM_EVTCHN_SEND _IOW(KVMIO, 0xd0, struct kvm_irq_routing_xen_evtchn) 1854d525f73fSChenyi Qiang 1855327d4b7fSBharata B Rao #define KVM_GET_SREGS2 _IOR(KVMIO, 0xcc, struct kvm_sregs2) 1856327d4b7fSBharata B Rao #define KVM_SET_SREGS2 _IOW(KVMIO, 0xcd, struct kvm_sregs2) 1857327d4b7fSBharata B Rao 1858278f064eSEduardo Habkost struct kvm_xen_vcpu_attr { 1859278f064eSEduardo Habkost __u16 type; 1860278f064eSEduardo Habkost __u16 pad[3]; 1861278f064eSEduardo Habkost union { 1862278f064eSEduardo Habkost __u64 gpa; 186393d7620cSAvihai Horon #define KVM_XEN_INVALID_GPA ((__u64)-1) 1864278f064eSEduardo Habkost __u64 pad[8]; 1865278f064eSEduardo Habkost struct { 1866278f064eSEduardo Habkost __u64 state; 1867278f064eSEduardo Habkost __u64 state_entry_time; 1868278f064eSEduardo Habkost __u64 time_running; 1869278f064eSEduardo Habkost __u64 time_runnable; 1870278f064eSEduardo Habkost __u64 time_blocked; 1871278f064eSEduardo Habkost __u64 time_offline; 1872278f064eSEduardo Habkost } runstate; 1873d525f73fSChenyi Qiang __u32 vcpu_id; 1874d525f73fSChenyi Qiang struct { 1875d525f73fSChenyi Qiang __u32 port; 1876d525f73fSChenyi Qiang __u32 priority; 1877d525f73fSChenyi Qiang __u64 expires_ns; 1878d525f73fSChenyi Qiang } timer; 1879d525f73fSChenyi Qiang __u8 vector; 1880278f064eSEduardo Habkost } u; 1881278f064eSEduardo Habkost }; 1882278f064eSEduardo Habkost 1883278f064eSEduardo Habkost /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */ 1884278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO 0x0 1885278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO 0x1 1886278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR 0x2 1887278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT 0x3 1888278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 0x4 1889278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 0x5 1890d525f73fSChenyi Qiang /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */ 1891d525f73fSChenyi Qiang #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID 0x6 1892d525f73fSChenyi Qiang #define KVM_XEN_VCPU_ATTR_TYPE_TIMER 0x7 1893d525f73fSChenyi Qiang #define KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR 0x8 1894278f064eSEduardo Habkost 18959f2d175dSPaolo Bonzini /* Secure Encrypted Virtualization command */ 18969f2d175dSPaolo Bonzini enum sev_cmd_id { 18979f2d175dSPaolo Bonzini /* Guest initialization commands */ 18989f2d175dSPaolo Bonzini KVM_SEV_INIT = 0, 18999f2d175dSPaolo Bonzini KVM_SEV_ES_INIT, 19009f2d175dSPaolo Bonzini /* Guest launch commands */ 19019f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_START, 19029f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_UPDATE_DATA, 19039f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_UPDATE_VMSA, 19049f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_SECRET, 19059f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_MEASURE, 19069f2d175dSPaolo Bonzini KVM_SEV_LAUNCH_FINISH, 19079f2d175dSPaolo Bonzini /* Guest migration commands (outgoing) */ 19089f2d175dSPaolo Bonzini KVM_SEV_SEND_START, 19099f2d175dSPaolo Bonzini KVM_SEV_SEND_UPDATE_DATA, 19109f2d175dSPaolo Bonzini KVM_SEV_SEND_UPDATE_VMSA, 19119f2d175dSPaolo Bonzini KVM_SEV_SEND_FINISH, 19129f2d175dSPaolo Bonzini /* Guest migration commands (incoming) */ 19139f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_START, 19149f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_UPDATE_DATA, 19159f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_UPDATE_VMSA, 19169f2d175dSPaolo Bonzini KVM_SEV_RECEIVE_FINISH, 19179f2d175dSPaolo Bonzini /* Guest status and debug commands */ 19189f2d175dSPaolo Bonzini KVM_SEV_GUEST_STATUS, 19199f2d175dSPaolo Bonzini KVM_SEV_DBG_DECRYPT, 19209f2d175dSPaolo Bonzini KVM_SEV_DBG_ENCRYPT, 19219f2d175dSPaolo Bonzini /* Guest certificates commands */ 19229f2d175dSPaolo Bonzini KVM_SEV_CERT_EXPORT, 19233ea1a802SBrijesh Singh /* Attestation report */ 19243ea1a802SBrijesh Singh KVM_SEV_GET_ATTESTATION_REPORT, 1925278f064eSEduardo Habkost /* Guest Migration Extension */ 1926278f064eSEduardo Habkost KVM_SEV_SEND_CANCEL, 19279f2d175dSPaolo Bonzini 19289f2d175dSPaolo Bonzini KVM_SEV_NR_MAX, 19299f2d175dSPaolo Bonzini }; 19309f2d175dSPaolo Bonzini 19319f2d175dSPaolo Bonzini struct kvm_sev_cmd { 19329f2d175dSPaolo Bonzini __u32 id; 19339f2d175dSPaolo Bonzini __u64 data; 19349f2d175dSPaolo Bonzini __u32 error; 19359f2d175dSPaolo Bonzini __u32 sev_fd; 19369f2d175dSPaolo Bonzini }; 19379f2d175dSPaolo Bonzini 19389f2d175dSPaolo Bonzini struct kvm_sev_launch_start { 19399f2d175dSPaolo Bonzini __u32 handle; 19409f2d175dSPaolo Bonzini __u32 policy; 19419f2d175dSPaolo Bonzini __u64 dh_uaddr; 19429f2d175dSPaolo Bonzini __u32 dh_len; 19439f2d175dSPaolo Bonzini __u64 session_uaddr; 19449f2d175dSPaolo Bonzini __u32 session_len; 19459f2d175dSPaolo Bonzini }; 19469f2d175dSPaolo Bonzini 19479f2d175dSPaolo Bonzini struct kvm_sev_launch_update_data { 19489f2d175dSPaolo Bonzini __u64 uaddr; 19499f2d175dSPaolo Bonzini __u32 len; 19509f2d175dSPaolo Bonzini }; 19519f2d175dSPaolo Bonzini 19529f2d175dSPaolo Bonzini 19539f2d175dSPaolo Bonzini struct kvm_sev_launch_secret { 19549f2d175dSPaolo Bonzini __u64 hdr_uaddr; 19559f2d175dSPaolo Bonzini __u32 hdr_len; 19569f2d175dSPaolo Bonzini __u64 guest_uaddr; 19579f2d175dSPaolo Bonzini __u32 guest_len; 19589f2d175dSPaolo Bonzini __u64 trans_uaddr; 19599f2d175dSPaolo Bonzini __u32 trans_len; 19609f2d175dSPaolo Bonzini }; 19619f2d175dSPaolo Bonzini 19629f2d175dSPaolo Bonzini struct kvm_sev_launch_measure { 19639f2d175dSPaolo Bonzini __u64 uaddr; 19649f2d175dSPaolo Bonzini __u32 len; 19659f2d175dSPaolo Bonzini }; 19669f2d175dSPaolo Bonzini 19679f2d175dSPaolo Bonzini struct kvm_sev_guest_status { 19689f2d175dSPaolo Bonzini __u32 handle; 19699f2d175dSPaolo Bonzini __u32 policy; 19709f2d175dSPaolo Bonzini __u32 state; 19719f2d175dSPaolo Bonzini }; 19729f2d175dSPaolo Bonzini 19739f2d175dSPaolo Bonzini struct kvm_sev_dbg { 19749f2d175dSPaolo Bonzini __u64 src_uaddr; 19759f2d175dSPaolo Bonzini __u64 dst_uaddr; 19769f2d175dSPaolo Bonzini __u32 len; 19779f2d175dSPaolo Bonzini }; 197851b24e34SJan Kiszka 19793ea1a802SBrijesh Singh struct kvm_sev_attestation_report { 19803ea1a802SBrijesh Singh __u8 mnonce[16]; 19813ea1a802SBrijesh Singh __u64 uaddr; 19823ea1a802SBrijesh Singh __u32 len; 19833ea1a802SBrijesh Singh }; 19843ea1a802SBrijesh Singh 1985278f064eSEduardo Habkost struct kvm_sev_send_start { 1986278f064eSEduardo Habkost __u32 policy; 1987278f064eSEduardo Habkost __u64 pdh_cert_uaddr; 1988278f064eSEduardo Habkost __u32 pdh_cert_len; 1989278f064eSEduardo Habkost __u64 plat_certs_uaddr; 1990278f064eSEduardo Habkost __u32 plat_certs_len; 1991278f064eSEduardo Habkost __u64 amd_certs_uaddr; 1992278f064eSEduardo Habkost __u32 amd_certs_len; 1993278f064eSEduardo Habkost __u64 session_uaddr; 1994278f064eSEduardo Habkost __u32 session_len; 1995278f064eSEduardo Habkost }; 1996278f064eSEduardo Habkost 1997278f064eSEduardo Habkost struct kvm_sev_send_update_data { 1998278f064eSEduardo Habkost __u64 hdr_uaddr; 1999278f064eSEduardo Habkost __u32 hdr_len; 2000278f064eSEduardo Habkost __u64 guest_uaddr; 2001278f064eSEduardo Habkost __u32 guest_len; 2002278f064eSEduardo Habkost __u64 trans_uaddr; 2003278f064eSEduardo Habkost __u32 trans_len; 2004278f064eSEduardo Habkost }; 2005278f064eSEduardo Habkost 2006278f064eSEduardo Habkost struct kvm_sev_receive_start { 2007278f064eSEduardo Habkost __u32 handle; 2008278f064eSEduardo Habkost __u32 policy; 2009278f064eSEduardo Habkost __u64 pdh_uaddr; 2010278f064eSEduardo Habkost __u32 pdh_len; 2011278f064eSEduardo Habkost __u64 session_uaddr; 2012278f064eSEduardo Habkost __u32 session_len; 2013278f064eSEduardo Habkost }; 2014278f064eSEduardo Habkost 2015278f064eSEduardo Habkost struct kvm_sev_receive_update_data { 2016278f064eSEduardo Habkost __u64 hdr_uaddr; 2017278f064eSEduardo Habkost __u32 hdr_len; 2018278f064eSEduardo Habkost __u64 guest_uaddr; 2019278f064eSEduardo Habkost __u32 guest_len; 2020278f064eSEduardo Habkost __u64 trans_uaddr; 2021278f064eSEduardo Habkost __u32 trans_len; 2022278f064eSEduardo Habkost }; 2023278f064eSEduardo Habkost 202451b24e34SJan Kiszka #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) 20259ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) 20269ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2) 202751b24e34SJan Kiszka 202851b24e34SJan Kiszka struct kvm_assigned_pci_dev { 202951b24e34SJan Kiszka __u32 assigned_dev_id; 203051b24e34SJan Kiszka __u32 busnr; 203151b24e34SJan Kiszka __u32 devfn; 203251b24e34SJan Kiszka __u32 flags; 203351b24e34SJan Kiszka __u32 segnr; 203451b24e34SJan Kiszka union { 203551b24e34SJan Kiszka __u32 reserved[11]; 203651b24e34SJan Kiszka }; 203751b24e34SJan Kiszka }; 203851b24e34SJan Kiszka 203951b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_INTX (1 << 0) 204051b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSI (1 << 1) 204151b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSIX (1 << 2) 204251b24e34SJan Kiszka 204351b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_INTX (1 << 8) 204451b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSI (1 << 9) 204551b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10) 204651b24e34SJan Kiszka 204751b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MASK 0x00ff 204851b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MASK 0xff00 204951b24e34SJan Kiszka 205051b24e34SJan Kiszka struct kvm_assigned_irq { 205151b24e34SJan Kiszka __u32 assigned_dev_id; 20527c6da3deSAlexander Graf __u32 host_irq; /* ignored (legacy field) */ 205351b24e34SJan Kiszka __u32 guest_irq; 205451b24e34SJan Kiszka __u32 flags; 205551b24e34SJan Kiszka union { 205651b24e34SJan Kiszka __u32 reserved[12]; 205751b24e34SJan Kiszka }; 205851b24e34SJan Kiszka }; 205951b24e34SJan Kiszka 206051b24e34SJan Kiszka struct kvm_assigned_msix_nr { 206151b24e34SJan Kiszka __u32 assigned_dev_id; 206251b24e34SJan Kiszka __u16 entry_nr; 206351b24e34SJan Kiszka __u16 padding; 206451b24e34SJan Kiszka }; 206551b24e34SJan Kiszka 206651b24e34SJan Kiszka #define KVM_MAX_MSIX_PER_DEV 256 206751b24e34SJan Kiszka struct kvm_assigned_msix_entry { 206851b24e34SJan Kiszka __u32 assigned_dev_id; 206951b24e34SJan Kiszka __u32 gsi; 207051b24e34SJan Kiszka __u16 entry; /* The index of entry in the MSI-X table */ 207151b24e34SJan Kiszka __u16 padding[3]; 207251b24e34SJan Kiszka }; 207351b24e34SJan Kiszka 2074dbdfea92SCornelia Huck #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0) 2075dbdfea92SCornelia Huck #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) 2076dbdfea92SCornelia Huck 207774c98e20SCornelia Huck /* Available with KVM_CAP_ARM_USER_IRQ */ 207874c98e20SCornelia Huck 207974c98e20SCornelia Huck /* Bits for run->s.regs.device_irq_level */ 208074c98e20SCornelia Huck #define KVM_ARM_DEV_EL1_VTIMER (1 << 0) 208174c98e20SCornelia Huck #define KVM_ARM_DEV_EL1_PTIMER (1 << 1) 208274c98e20SCornelia Huck #define KVM_ARM_DEV_PMU (1 << 2) 208374c98e20SCornelia Huck 208465a6d8ddSPeter Maydell struct kvm_hyperv_eventfd { 208565a6d8ddSPeter Maydell __u32 conn_id; 208665a6d8ddSPeter Maydell __s32 fd; 208765a6d8ddSPeter Maydell __u32 flags; 208865a6d8ddSPeter Maydell __u32 padding[3]; 208965a6d8ddSPeter Maydell }; 209065a6d8ddSPeter Maydell 209165a6d8ddSPeter Maydell #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff 209265a6d8ddSPeter Maydell #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0) 209365a6d8ddSPeter Maydell 2094dc6f8d45SCornelia Huck #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0) 2095dc6f8d45SCornelia Huck #define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1) 2096dc6f8d45SCornelia Huck 2097b3c818a4SEric Farman /* 2098b3c818a4SEric Farman * Arch needs to define the macro after implementing the dirty ring 2099b3c818a4SEric Farman * feature. KVM_DIRTY_LOG_PAGE_OFFSET should be defined as the 2100b3c818a4SEric Farman * starting page offset of the dirty ring structures. 2101b3c818a4SEric Farman */ 2102b3c818a4SEric Farman #ifndef KVM_DIRTY_LOG_PAGE_OFFSET 2103b3c818a4SEric Farman #define KVM_DIRTY_LOG_PAGE_OFFSET 0 2104b3c818a4SEric Farman #endif 2105b3c818a4SEric Farman 2106b3c818a4SEric Farman /* 2107b3c818a4SEric Farman * KVM dirty GFN flags, defined as: 2108b3c818a4SEric Farman * 2109b3c818a4SEric Farman * |---------------+---------------+--------------| 2110b3c818a4SEric Farman * | bit 1 (reset) | bit 0 (dirty) | Status | 2111b3c818a4SEric Farman * |---------------+---------------+--------------| 2112b3c818a4SEric Farman * | 0 | 0 | Invalid GFN | 2113b3c818a4SEric Farman * | 0 | 1 | Dirty GFN | 2114b3c818a4SEric Farman * | 1 | X | GFN to reset | 2115b3c818a4SEric Farman * |---------------+---------------+--------------| 2116b3c818a4SEric Farman * 2117b3c818a4SEric Farman * Lifecycle of a dirty GFN goes like: 2118b3c818a4SEric Farman * 2119b3c818a4SEric Farman * dirtied harvested reset 2120b3c818a4SEric Farman * 00 -----------> 01 -------------> 1X -------+ 2121b3c818a4SEric Farman * ^ | 2122b3c818a4SEric Farman * | | 2123b3c818a4SEric Farman * +------------------------------------------+ 2124b3c818a4SEric Farman * 2125b3c818a4SEric Farman * The userspace program is only responsible for the 01->1X state 2126b3c818a4SEric Farman * conversion after harvesting an entry. Also, it must not skip any 2127b3c818a4SEric Farman * dirty bits, so that dirty bits are always harvested in sequence. 2128b3c818a4SEric Farman */ 2129278f064eSEduardo Habkost #define KVM_DIRTY_GFN_F_DIRTY _BITUL(0) 2130278f064eSEduardo Habkost #define KVM_DIRTY_GFN_F_RESET _BITUL(1) 2131b3c818a4SEric Farman #define KVM_DIRTY_GFN_F_MASK 0x3 2132b3c818a4SEric Farman 2133b3c818a4SEric Farman /* 2134b3c818a4SEric Farman * KVM dirty rings should be mapped at KVM_DIRTY_LOG_PAGE_OFFSET of 2135b3c818a4SEric Farman * per-vcpu mmaped regions as an array of struct kvm_dirty_gfn. The 2136b3c818a4SEric Farman * size of the gfn buffer is decided by the first argument when 2137b3c818a4SEric Farman * enabling KVM_CAP_DIRTY_LOG_RING. 2138b3c818a4SEric Farman */ 2139b3c818a4SEric Farman struct kvm_dirty_gfn { 2140b3c818a4SEric Farman __u32 flags; 2141b3c818a4SEric Farman __u32 slot; 2142b3c818a4SEric Farman __u64 offset; 2143b3c818a4SEric Farman }; 2144b3c818a4SEric Farman 2145278f064eSEduardo Habkost #define KVM_BUS_LOCK_DETECTION_OFF (1 << 0) 2146278f064eSEduardo Habkost #define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1) 2147278f064eSEduardo Habkost 2148e4082063SAlex Williamson #define KVM_PMU_CAP_DISABLE (1 << 0) 2149e4082063SAlex Williamson 2150327d4b7fSBharata B Rao /** 2151327d4b7fSBharata B Rao * struct kvm_stats_header - Header of per vm/vcpu binary statistics data. 2152327d4b7fSBharata B Rao * @flags: Some extra information for header, always 0 for now. 2153327d4b7fSBharata B Rao * @name_size: The size in bytes of the memory which contains statistics 2154327d4b7fSBharata B Rao * name string including trailing '\0'. The memory is allocated 2155327d4b7fSBharata B Rao * at the send of statistics descriptor. 2156327d4b7fSBharata B Rao * @num_desc: The number of statistics the vm or vcpu has. 2157327d4b7fSBharata B Rao * @id_offset: The offset of the vm/vcpu stats' id string in the file pointed 2158327d4b7fSBharata B Rao * by vm/vcpu stats fd. 2159327d4b7fSBharata B Rao * @desc_offset: The offset of the vm/vcpu stats' descriptor block in the file 2160327d4b7fSBharata B Rao * pointd by vm/vcpu stats fd. 2161327d4b7fSBharata B Rao * @data_offset: The offset of the vm/vcpu stats' data block in the file 2162327d4b7fSBharata B Rao * pointed by vm/vcpu stats fd. 2163327d4b7fSBharata B Rao * 2164327d4b7fSBharata B Rao * This is the header userspace needs to read from stats fd before any other 2165327d4b7fSBharata B Rao * readings. It is used by userspace to discover all the information about the 2166327d4b7fSBharata B Rao * vm/vcpu's binary statistics. 2167327d4b7fSBharata B Rao * Userspace reads this header from the start of the vm/vcpu's stats fd. 2168327d4b7fSBharata B Rao */ 2169327d4b7fSBharata B Rao struct kvm_stats_header { 2170327d4b7fSBharata B Rao __u32 flags; 2171327d4b7fSBharata B Rao __u32 name_size; 2172327d4b7fSBharata B Rao __u32 num_desc; 2173327d4b7fSBharata B Rao __u32 id_offset; 2174327d4b7fSBharata B Rao __u32 desc_offset; 2175327d4b7fSBharata B Rao __u32 data_offset; 2176327d4b7fSBharata B Rao }; 2177327d4b7fSBharata B Rao 2178327d4b7fSBharata B Rao #define KVM_STATS_TYPE_SHIFT 0 2179327d4b7fSBharata B Rao #define KVM_STATS_TYPE_MASK (0xF << KVM_STATS_TYPE_SHIFT) 2180327d4b7fSBharata B Rao #define KVM_STATS_TYPE_CUMULATIVE (0x0 << KVM_STATS_TYPE_SHIFT) 2181327d4b7fSBharata B Rao #define KVM_STATS_TYPE_INSTANT (0x1 << KVM_STATS_TYPE_SHIFT) 2182327d4b7fSBharata B Rao #define KVM_STATS_TYPE_PEAK (0x2 << KVM_STATS_TYPE_SHIFT) 218343709a0cSPaolo Bonzini #define KVM_STATS_TYPE_LINEAR_HIST (0x3 << KVM_STATS_TYPE_SHIFT) 218443709a0cSPaolo Bonzini #define KVM_STATS_TYPE_LOG_HIST (0x4 << KVM_STATS_TYPE_SHIFT) 218543709a0cSPaolo Bonzini #define KVM_STATS_TYPE_MAX KVM_STATS_TYPE_LOG_HIST 2186327d4b7fSBharata B Rao 2187327d4b7fSBharata B Rao #define KVM_STATS_UNIT_SHIFT 4 2188327d4b7fSBharata B Rao #define KVM_STATS_UNIT_MASK (0xF << KVM_STATS_UNIT_SHIFT) 2189327d4b7fSBharata B Rao #define KVM_STATS_UNIT_NONE (0x0 << KVM_STATS_UNIT_SHIFT) 2190327d4b7fSBharata B Rao #define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT) 2191327d4b7fSBharata B Rao #define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT) 2192327d4b7fSBharata B Rao #define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT) 2193105bb7cdSPaolo Bonzini #define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT) 2194d525f73fSChenyi Qiang #define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_BOOLEAN 2195327d4b7fSBharata B Rao 2196327d4b7fSBharata B Rao #define KVM_STATS_BASE_SHIFT 8 2197327d4b7fSBharata B Rao #define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT) 2198327d4b7fSBharata B Rao #define KVM_STATS_BASE_POW10 (0x0 << KVM_STATS_BASE_SHIFT) 2199327d4b7fSBharata B Rao #define KVM_STATS_BASE_POW2 (0x1 << KVM_STATS_BASE_SHIFT) 2200327d4b7fSBharata B Rao #define KVM_STATS_BASE_MAX KVM_STATS_BASE_POW2 2201327d4b7fSBharata B Rao 2202327d4b7fSBharata B Rao /** 2203327d4b7fSBharata B Rao * struct kvm_stats_desc - Descriptor of a KVM statistics. 2204327d4b7fSBharata B Rao * @flags: Annotations of the stats, like type, unit, etc. 2205327d4b7fSBharata B Rao * @exponent: Used together with @flags to determine the unit. 2206327d4b7fSBharata B Rao * @size: The number of data items for this stats. 2207327d4b7fSBharata B Rao * Every data item is of type __u64. 2208327d4b7fSBharata B Rao * @offset: The offset of the stats to the start of stat structure in 220943709a0cSPaolo Bonzini * structure kvm or kvm_vcpu. 221043709a0cSPaolo Bonzini * @bucket_size: A parameter value used for histogram stats. It is only used 221143709a0cSPaolo Bonzini * for linear histogram stats, specifying the size of the bucket; 2212327d4b7fSBharata B Rao * @name: The name string for the stats. Its size is indicated by the 2213327d4b7fSBharata B Rao * &kvm_stats_header->name_size. 2214327d4b7fSBharata B Rao */ 2215327d4b7fSBharata B Rao struct kvm_stats_desc { 2216327d4b7fSBharata B Rao __u32 flags; 2217327d4b7fSBharata B Rao __s16 exponent; 2218327d4b7fSBharata B Rao __u16 size; 2219327d4b7fSBharata B Rao __u32 offset; 222043709a0cSPaolo Bonzini __u32 bucket_size; 2221327d4b7fSBharata B Rao char name[]; 2222327d4b7fSBharata B Rao }; 2223327d4b7fSBharata B Rao 2224327d4b7fSBharata B Rao #define KVM_GET_STATS_FD _IO(KVMIO, 0xce) 2225327d4b7fSBharata B Rao 22261ea5208fSPaolo Bonzini /* Available with KVM_CAP_XSAVE2 */ 22271ea5208fSPaolo Bonzini #define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave) 22281ea5208fSPaolo Bonzini 2229d525f73fSChenyi Qiang /* Available with KVM_CAP_S390_PROTECTED_DUMP */ 2230d525f73fSChenyi Qiang #define KVM_S390_PV_CPU_COMMAND _IOWR(KVMIO, 0xd0, struct kvm_pv_cmd) 2231d525f73fSChenyi Qiang 2232d525f73fSChenyi Qiang /* Available with KVM_CAP_X86_NOTIFY_VMEXIT */ 2233d525f73fSChenyi Qiang #define KVM_X86_NOTIFY_VMEXIT_ENABLED (1ULL << 0) 2234d525f73fSChenyi Qiang #define KVM_X86_NOTIFY_VMEXIT_USER (1ULL << 1) 2235d525f73fSChenyi Qiang 2236d525f73fSChenyi Qiang /* Available with KVM_CAP_S390_ZPCI_OP */ 2237d525f73fSChenyi Qiang #define KVM_S390_ZPCI_OP _IOW(KVMIO, 0xd1, struct kvm_s390_zpci_op) 2238d525f73fSChenyi Qiang 2239d525f73fSChenyi Qiang struct kvm_s390_zpci_op { 2240d525f73fSChenyi Qiang /* in */ 2241d525f73fSChenyi Qiang __u32 fh; /* target device */ 2242d525f73fSChenyi Qiang __u8 op; /* operation to perform */ 2243d525f73fSChenyi Qiang __u8 pad[3]; 2244d525f73fSChenyi Qiang union { 2245d525f73fSChenyi Qiang /* for KVM_S390_ZPCIOP_REG_AEN */ 2246d525f73fSChenyi Qiang struct { 2247d525f73fSChenyi Qiang __u64 ibv; /* Guest addr of interrupt bit vector */ 2248d525f73fSChenyi Qiang __u64 sb; /* Guest addr of summary bit */ 2249d525f73fSChenyi Qiang __u32 flags; 2250d525f73fSChenyi Qiang __u32 noi; /* Number of interrupts */ 2251d525f73fSChenyi Qiang __u8 isc; /* Guest interrupt subclass */ 2252d525f73fSChenyi Qiang __u8 sbo; /* Offset of guest summary bit vector */ 2253d525f73fSChenyi Qiang __u16 pad; 2254d525f73fSChenyi Qiang } reg_aen; 2255d525f73fSChenyi Qiang __u64 reserved[8]; 2256d525f73fSChenyi Qiang } u; 2257d525f73fSChenyi Qiang }; 2258d525f73fSChenyi Qiang 2259d525f73fSChenyi Qiang /* types for kvm_s390_zpci_op->op */ 2260d525f73fSChenyi Qiang #define KVM_S390_ZPCIOP_REG_AEN 0 2261d525f73fSChenyi Qiang #define KVM_S390_ZPCIOP_DEREG_AEN 1 2262d525f73fSChenyi Qiang 2263d525f73fSChenyi Qiang /* flags for kvm_s390_zpci_op->u.reg_aen.flags */ 2264d525f73fSChenyi Qiang #define KVM_S390_ZPCIOP_REGAEN_HOST (1 << 0) 2265d525f73fSChenyi Qiang 226651b24e34SJan Kiszka #endif /* __LINUX_KVM_H */ 2267