1607ca46eSDavid Howells #ifndef __LINUX_KVM_H 2607ca46eSDavid Howells #define __LINUX_KVM_H 3607ca46eSDavid Howells 4607ca46eSDavid Howells /* 5607ca46eSDavid Howells * Userspace interface for /dev/kvm - kernel based virtual machine 6607ca46eSDavid Howells * 7607ca46eSDavid Howells * Note: you must update KVM_API_VERSION if you change this interface. 8607ca46eSDavid Howells */ 9607ca46eSDavid Howells 10607ca46eSDavid Howells #include <linux/types.h> 11607ca46eSDavid Howells #include <linux/compiler.h> 12607ca46eSDavid Howells #include <linux/ioctl.h> 13607ca46eSDavid Howells #include <asm/kvm.h> 14607ca46eSDavid Howells 15607ca46eSDavid Howells #define KVM_API_VERSION 12 16607ca46eSDavid Howells 17607ca46eSDavid Howells /* *** Deprecated interfaces *** */ 18607ca46eSDavid Howells 19607ca46eSDavid Howells #define KVM_TRC_SHIFT 16 20607ca46eSDavid Howells 21607ca46eSDavid Howells #define KVM_TRC_ENTRYEXIT (1 << KVM_TRC_SHIFT) 22607ca46eSDavid Howells #define KVM_TRC_HANDLER (1 << (KVM_TRC_SHIFT + 1)) 23607ca46eSDavid Howells 24607ca46eSDavid Howells #define KVM_TRC_VMENTRY (KVM_TRC_ENTRYEXIT + 0x01) 25607ca46eSDavid Howells #define KVM_TRC_VMEXIT (KVM_TRC_ENTRYEXIT + 0x02) 26607ca46eSDavid Howells #define KVM_TRC_PAGE_FAULT (KVM_TRC_HANDLER + 0x01) 27607ca46eSDavid Howells 28607ca46eSDavid Howells #define KVM_TRC_HEAD_SIZE 12 29607ca46eSDavid Howells #define KVM_TRC_CYCLE_SIZE 8 30607ca46eSDavid Howells #define KVM_TRC_EXTRA_MAX 7 31607ca46eSDavid Howells 32607ca46eSDavid Howells #define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02) 33607ca46eSDavid Howells #define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03) 34607ca46eSDavid Howells #define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04) 35607ca46eSDavid Howells #define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05) 36607ca46eSDavid Howells #define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06) 37607ca46eSDavid Howells #define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07) 38607ca46eSDavid Howells #define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08) 39607ca46eSDavid Howells #define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09) 40607ca46eSDavid Howells #define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A) 41607ca46eSDavid Howells #define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B) 42607ca46eSDavid Howells #define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C) 43607ca46eSDavid Howells #define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D) 44607ca46eSDavid Howells #define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E) 45607ca46eSDavid Howells #define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F) 46607ca46eSDavid Howells #define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10) 47607ca46eSDavid Howells #define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11) 48607ca46eSDavid Howells #define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12) 49607ca46eSDavid Howells #define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13) 50607ca46eSDavid Howells #define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14) 51607ca46eSDavid Howells #define KVM_TRC_TDP_FAULT (KVM_TRC_HANDLER + 0x15) 52607ca46eSDavid Howells #define KVM_TRC_GTLB_WRITE (KVM_TRC_HANDLER + 0x16) 53607ca46eSDavid Howells #define KVM_TRC_STLB_WRITE (KVM_TRC_HANDLER + 0x17) 54607ca46eSDavid Howells #define KVM_TRC_STLB_INVAL (KVM_TRC_HANDLER + 0x18) 55607ca46eSDavid Howells #define KVM_TRC_PPC_INSTR (KVM_TRC_HANDLER + 0x19) 56607ca46eSDavid Howells 57607ca46eSDavid Howells struct kvm_user_trace_setup { 58607ca46eSDavid Howells __u32 buf_size; 59607ca46eSDavid Howells __u32 buf_nr; 60607ca46eSDavid Howells }; 61607ca46eSDavid Howells 62607ca46eSDavid Howells #define __KVM_DEPRECATED_MAIN_W_0x06 \ 63607ca46eSDavid Howells _IOW(KVMIO, 0x06, struct kvm_user_trace_setup) 64607ca46eSDavid Howells #define __KVM_DEPRECATED_MAIN_0x07 _IO(KVMIO, 0x07) 65607ca46eSDavid Howells #define __KVM_DEPRECATED_MAIN_0x08 _IO(KVMIO, 0x08) 66607ca46eSDavid Howells 67607ca46eSDavid Howells #define __KVM_DEPRECATED_VM_R_0x70 _IOR(KVMIO, 0x70, struct kvm_assigned_irq) 68607ca46eSDavid Howells 69607ca46eSDavid Howells struct kvm_breakpoint { 70607ca46eSDavid Howells __u32 enabled; 71607ca46eSDavid Howells __u32 padding; 72607ca46eSDavid Howells __u64 address; 73607ca46eSDavid Howells }; 74607ca46eSDavid Howells 75607ca46eSDavid Howells struct kvm_debug_guest { 76607ca46eSDavid Howells __u32 enabled; 77607ca46eSDavid Howells __u32 pad; 78607ca46eSDavid Howells struct kvm_breakpoint breakpoints[4]; 79607ca46eSDavid Howells __u32 singlestep; 80607ca46eSDavid Howells }; 81607ca46eSDavid Howells 82607ca46eSDavid Howells #define __KVM_DEPRECATED_VCPU_W_0x87 _IOW(KVMIO, 0x87, struct kvm_debug_guest) 83607ca46eSDavid Howells 84607ca46eSDavid Howells /* *** End of deprecated interfaces *** */ 85607ca46eSDavid Howells 86607ca46eSDavid Howells 87607ca46eSDavid Howells /* for KVM_CREATE_MEMORY_REGION */ 88607ca46eSDavid Howells struct kvm_memory_region { 89607ca46eSDavid Howells __u32 slot; 90607ca46eSDavid Howells __u32 flags; 91607ca46eSDavid Howells __u64 guest_phys_addr; 92607ca46eSDavid Howells __u64 memory_size; /* bytes */ 93607ca46eSDavid Howells }; 94607ca46eSDavid Howells 95607ca46eSDavid Howells /* for KVM_SET_USER_MEMORY_REGION */ 96607ca46eSDavid Howells struct kvm_userspace_memory_region { 97607ca46eSDavid Howells __u32 slot; 98607ca46eSDavid Howells __u32 flags; 99607ca46eSDavid Howells __u64 guest_phys_addr; 100607ca46eSDavid Howells __u64 memory_size; /* bytes */ 101607ca46eSDavid Howells __u64 userspace_addr; /* start of the userspace allocated memory */ 102607ca46eSDavid Howells }; 103607ca46eSDavid Howells 104607ca46eSDavid Howells /* 105607ca46eSDavid Howells * The bit 0 ~ bit 15 of kvm_memory_region::flags are visible for userspace, 106607ca46eSDavid Howells * other bits are reserved for kvm internal use which are defined in 107607ca46eSDavid Howells * include/linux/kvm_host.h. 108607ca46eSDavid Howells */ 109607ca46eSDavid Howells #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) 110607ca46eSDavid Howells #define KVM_MEM_READONLY (1UL << 1) 111607ca46eSDavid Howells 112607ca46eSDavid Howells /* for KVM_IRQ_LINE */ 113607ca46eSDavid Howells struct kvm_irq_level { 114607ca46eSDavid Howells /* 115607ca46eSDavid Howells * ACPI gsi notion of irq. 116607ca46eSDavid Howells * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47.. 117607ca46eSDavid Howells * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23.. 11886ce8535SChristoffer Dall * For ARM: See Documentation/virtual/kvm/api.txt 119607ca46eSDavid Howells */ 120607ca46eSDavid Howells union { 121607ca46eSDavid Howells __u32 irq; 122607ca46eSDavid Howells __s32 status; 123607ca46eSDavid Howells }; 124607ca46eSDavid Howells __u32 level; 125607ca46eSDavid Howells }; 126607ca46eSDavid Howells 127607ca46eSDavid Howells 128607ca46eSDavid Howells struct kvm_irqchip { 129607ca46eSDavid Howells __u32 chip_id; 130607ca46eSDavid Howells __u32 pad; 131607ca46eSDavid Howells union { 132607ca46eSDavid Howells char dummy[512]; /* reserving space */ 133607ca46eSDavid Howells #ifdef __KVM_HAVE_PIT 134607ca46eSDavid Howells struct kvm_pic_state pic; 135607ca46eSDavid Howells #endif 136607ca46eSDavid Howells #ifdef __KVM_HAVE_IOAPIC 137607ca46eSDavid Howells struct kvm_ioapic_state ioapic; 138607ca46eSDavid Howells #endif 139607ca46eSDavid Howells } chip; 140607ca46eSDavid Howells }; 141607ca46eSDavid Howells 142607ca46eSDavid Howells /* for KVM_CREATE_PIT2 */ 143607ca46eSDavid Howells struct kvm_pit_config { 144607ca46eSDavid Howells __u32 flags; 145607ca46eSDavid Howells __u32 pad[15]; 146607ca46eSDavid Howells }; 147607ca46eSDavid Howells 148607ca46eSDavid Howells #define KVM_PIT_SPEAKER_DUMMY 1 149607ca46eSDavid Howells 15030ee2a98SJason J. Herne struct kvm_s390_skeys { 15130ee2a98SJason J. Herne __u64 start_gfn; 15230ee2a98SJason J. Herne __u64 count; 15330ee2a98SJason J. Herne __u64 skeydata_addr; 15430ee2a98SJason J. Herne __u32 flags; 15530ee2a98SJason J. Herne __u32 reserved[9]; 15630ee2a98SJason J. Herne }; 157db397571SAndrey Smetanin 1584036e387SClaudio Imbrenda #define KVM_S390_CMMA_PEEK (1 << 0) 1594036e387SClaudio Imbrenda 1604036e387SClaudio Imbrenda /** 1614036e387SClaudio Imbrenda * kvm_s390_cmma_log - Used for CMMA migration. 1624036e387SClaudio Imbrenda * 1634036e387SClaudio Imbrenda * Used both for input and output. 1644036e387SClaudio Imbrenda * 1654036e387SClaudio Imbrenda * @start_gfn: Guest page number to start from. 1664036e387SClaudio Imbrenda * @count: Size of the result buffer. 1674036e387SClaudio Imbrenda * @flags: Control operation mode via KVM_S390_CMMA_* flags 1684036e387SClaudio Imbrenda * @remaining: Used with KVM_S390_GET_CMMA_BITS. Indicates how many dirty 1694036e387SClaudio Imbrenda * pages are still remaining. 1704036e387SClaudio Imbrenda * @mask: Used with KVM_S390_SET_CMMA_BITS. Bitmap of bits to actually set 1714036e387SClaudio Imbrenda * in the PGSTE. 1724036e387SClaudio Imbrenda * @values: Pointer to the values buffer. 1734036e387SClaudio Imbrenda * 1744036e387SClaudio Imbrenda * Used in KVM_S390_{G,S}ET_CMMA_BITS ioctls. 1754036e387SClaudio Imbrenda */ 1764036e387SClaudio Imbrenda struct kvm_s390_cmma_log { 1774036e387SClaudio Imbrenda __u64 start_gfn; 1784036e387SClaudio Imbrenda __u32 count; 1794036e387SClaudio Imbrenda __u32 flags; 1804036e387SClaudio Imbrenda union { 1814036e387SClaudio Imbrenda __u64 remaining; 1824036e387SClaudio Imbrenda __u64 mask; 1834036e387SClaudio Imbrenda }; 1844036e387SClaudio Imbrenda __u64 values; 1854036e387SClaudio Imbrenda }; 1864036e387SClaudio Imbrenda 187db397571SAndrey Smetanin struct kvm_hyperv_exit { 188db397571SAndrey Smetanin #define KVM_EXIT_HYPERV_SYNIC 1 18983326e43SAndrey Smetanin #define KVM_EXIT_HYPERV_HCALL 2 190db397571SAndrey Smetanin __u32 type; 191db397571SAndrey Smetanin union { 192db397571SAndrey Smetanin struct { 193db397571SAndrey Smetanin __u32 msr; 194db397571SAndrey Smetanin __u64 control; 195db397571SAndrey Smetanin __u64 evt_page; 196db397571SAndrey Smetanin __u64 msg_page; 197db397571SAndrey Smetanin } synic; 19883326e43SAndrey Smetanin struct { 19983326e43SAndrey Smetanin __u64 input; 20083326e43SAndrey Smetanin __u64 result; 20183326e43SAndrey Smetanin __u64 params[2]; 20283326e43SAndrey Smetanin } hcall; 203db397571SAndrey Smetanin } u; 204db397571SAndrey Smetanin }; 205db397571SAndrey Smetanin 20630ee2a98SJason J. Herne #define KVM_S390_GET_SKEYS_NONE 1 20730ee2a98SJason J. Herne #define KVM_S390_SKEYS_MAX 1048576 20830ee2a98SJason J. Herne 209607ca46eSDavid Howells #define KVM_EXIT_UNKNOWN 0 210607ca46eSDavid Howells #define KVM_EXIT_EXCEPTION 1 211607ca46eSDavid Howells #define KVM_EXIT_IO 2 212607ca46eSDavid Howells #define KVM_EXIT_HYPERCALL 3 213607ca46eSDavid Howells #define KVM_EXIT_DEBUG 4 214607ca46eSDavid Howells #define KVM_EXIT_HLT 5 215607ca46eSDavid Howells #define KVM_EXIT_MMIO 6 216607ca46eSDavid Howells #define KVM_EXIT_IRQ_WINDOW_OPEN 7 217607ca46eSDavid Howells #define KVM_EXIT_SHUTDOWN 8 218607ca46eSDavid Howells #define KVM_EXIT_FAIL_ENTRY 9 219607ca46eSDavid Howells #define KVM_EXIT_INTR 10 220607ca46eSDavid Howells #define KVM_EXIT_SET_TPR 11 221607ca46eSDavid Howells #define KVM_EXIT_TPR_ACCESS 12 222607ca46eSDavid Howells #define KVM_EXIT_S390_SIEIC 13 223607ca46eSDavid Howells #define KVM_EXIT_S390_RESET 14 224ce91ddc4SAlexander Graf #define KVM_EXIT_DCR 15 /* deprecated */ 225607ca46eSDavid Howells #define KVM_EXIT_NMI 16 226607ca46eSDavid Howells #define KVM_EXIT_INTERNAL_ERROR 17 227607ca46eSDavid Howells #define KVM_EXIT_OSI 18 228607ca46eSDavid Howells #define KVM_EXIT_PAPR_HCALL 19 229607ca46eSDavid Howells #define KVM_EXIT_S390_UCONTROL 20 23019bf7f8aSMarcelo Tosatti #define KVM_EXIT_WATCHDOG 21 231fa6b7fe9SCornelia Huck #define KVM_EXIT_S390_TSCH 22 2321c810636SAlexander Graf #define KVM_EXIT_EPR 23 2338ad6b634SAnup Patel #define KVM_EXIT_SYSTEM_EVENT 24 234e44fc8c9SEkaterina Tumanova #define KVM_EXIT_S390_STSI 25 2357543a635SSteve Rutherford #define KVM_EXIT_IOAPIC_EOI 26 236db397571SAndrey Smetanin #define KVM_EXIT_HYPERV 27 237607ca46eSDavid Howells 238607ca46eSDavid Howells /* For KVM_EXIT_INTERNAL_ERROR */ 23919bf7f8aSMarcelo Tosatti /* Emulate instruction failed. */ 240607ca46eSDavid Howells #define KVM_INTERNAL_ERROR_EMULATION 1 24119bf7f8aSMarcelo Tosatti /* Encounter unexpected simultaneous exceptions. */ 242607ca46eSDavid Howells #define KVM_INTERNAL_ERROR_SIMUL_EX 2 24319bf7f8aSMarcelo Tosatti /* Encounter unexpected vm-exit due to delivery event. */ 24419bf7f8aSMarcelo Tosatti #define KVM_INTERNAL_ERROR_DELIVERY_EV 3 245607ca46eSDavid Howells 246607ca46eSDavid Howells /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ 247607ca46eSDavid Howells struct kvm_run { 248607ca46eSDavid Howells /* in */ 249607ca46eSDavid Howells __u8 request_interrupt_window; 250460df4c1SPaolo Bonzini __u8 immediate_exit; 251460df4c1SPaolo Bonzini __u8 padding1[6]; 252607ca46eSDavid Howells 253607ca46eSDavid Howells /* out */ 254607ca46eSDavid Howells __u32 exit_reason; 255607ca46eSDavid Howells __u8 ready_for_interrupt_injection; 256607ca46eSDavid Howells __u8 if_flag; 257f077825aSPaolo Bonzini __u16 flags; 258607ca46eSDavid Howells 259607ca46eSDavid Howells /* in (pre_kvm_run), out (post_kvm_run) */ 260607ca46eSDavid Howells __u64 cr8; 261607ca46eSDavid Howells __u64 apic_base; 262607ca46eSDavid Howells 263607ca46eSDavid Howells #ifdef __KVM_S390 264607ca46eSDavid Howells /* the processor status word for s390 */ 265607ca46eSDavid Howells __u64 psw_mask; /* psw upper half */ 266607ca46eSDavid Howells __u64 psw_addr; /* psw lower half */ 267607ca46eSDavid Howells #endif 268607ca46eSDavid Howells union { 269607ca46eSDavid Howells /* KVM_EXIT_UNKNOWN */ 270607ca46eSDavid Howells struct { 271607ca46eSDavid Howells __u64 hardware_exit_reason; 272607ca46eSDavid Howells } hw; 273607ca46eSDavid Howells /* KVM_EXIT_FAIL_ENTRY */ 274607ca46eSDavid Howells struct { 275607ca46eSDavid Howells __u64 hardware_entry_failure_reason; 276607ca46eSDavid Howells } fail_entry; 277607ca46eSDavid Howells /* KVM_EXIT_EXCEPTION */ 278607ca46eSDavid Howells struct { 279607ca46eSDavid Howells __u32 exception; 280607ca46eSDavid Howells __u32 error_code; 281607ca46eSDavid Howells } ex; 282607ca46eSDavid Howells /* KVM_EXIT_IO */ 283607ca46eSDavid Howells struct { 284607ca46eSDavid Howells #define KVM_EXIT_IO_IN 0 285607ca46eSDavid Howells #define KVM_EXIT_IO_OUT 1 286607ca46eSDavid Howells __u8 direction; 287607ca46eSDavid Howells __u8 size; /* bytes */ 288607ca46eSDavid Howells __u16 port; 289607ca46eSDavid Howells __u32 count; 290607ca46eSDavid Howells __u64 data_offset; /* relative to kvm_run start */ 291607ca46eSDavid Howells } io; 2928ab30c15SAlex Bennée /* KVM_EXIT_DEBUG */ 293607ca46eSDavid Howells struct { 294607ca46eSDavid Howells struct kvm_debug_exit_arch arch; 295607ca46eSDavid Howells } debug; 296607ca46eSDavid Howells /* KVM_EXIT_MMIO */ 297607ca46eSDavid Howells struct { 298607ca46eSDavid Howells __u64 phys_addr; 299607ca46eSDavid Howells __u8 data[8]; 300607ca46eSDavid Howells __u32 len; 301607ca46eSDavid Howells __u8 is_write; 302607ca46eSDavid Howells } mmio; 303607ca46eSDavid Howells /* KVM_EXIT_HYPERCALL */ 304607ca46eSDavid Howells struct { 305607ca46eSDavid Howells __u64 nr; 306607ca46eSDavid Howells __u64 args[6]; 307607ca46eSDavid Howells __u64 ret; 308607ca46eSDavid Howells __u32 longmode; 309607ca46eSDavid Howells __u32 pad; 310607ca46eSDavid Howells } hypercall; 311607ca46eSDavid Howells /* KVM_EXIT_TPR_ACCESS */ 312607ca46eSDavid Howells struct { 313607ca46eSDavid Howells __u64 rip; 314607ca46eSDavid Howells __u32 is_write; 315607ca46eSDavid Howells __u32 pad; 316607ca46eSDavid Howells } tpr_access; 317607ca46eSDavid Howells /* KVM_EXIT_S390_SIEIC */ 318607ca46eSDavid Howells struct { 319607ca46eSDavid Howells __u8 icptcode; 320607ca46eSDavid Howells __u16 ipa; 321607ca46eSDavid Howells __u32 ipb; 322607ca46eSDavid Howells } s390_sieic; 323607ca46eSDavid Howells /* KVM_EXIT_S390_RESET */ 324607ca46eSDavid Howells #define KVM_S390_RESET_POR 1 325607ca46eSDavid Howells #define KVM_S390_RESET_CLEAR 2 326607ca46eSDavid Howells #define KVM_S390_RESET_SUBSYSTEM 4 327607ca46eSDavid Howells #define KVM_S390_RESET_CPU_INIT 8 328607ca46eSDavid Howells #define KVM_S390_RESET_IPL 16 329607ca46eSDavid Howells __u64 s390_reset_flags; 330607ca46eSDavid Howells /* KVM_EXIT_S390_UCONTROL */ 331607ca46eSDavid Howells struct { 332607ca46eSDavid Howells __u64 trans_exc_code; 333607ca46eSDavid Howells __u32 pgm_code; 334607ca46eSDavid Howells } s390_ucontrol; 335ce91ddc4SAlexander Graf /* KVM_EXIT_DCR (deprecated) */ 336607ca46eSDavid Howells struct { 337607ca46eSDavid Howells __u32 dcrn; 338607ca46eSDavid Howells __u32 data; 339607ca46eSDavid Howells __u8 is_write; 340607ca46eSDavid Howells } dcr; 3418ab30c15SAlex Bennée /* KVM_EXIT_INTERNAL_ERROR */ 342607ca46eSDavid Howells struct { 343607ca46eSDavid Howells __u32 suberror; 344607ca46eSDavid Howells /* Available with KVM_CAP_INTERNAL_ERROR_DATA: */ 345607ca46eSDavid Howells __u32 ndata; 346607ca46eSDavid Howells __u64 data[16]; 347607ca46eSDavid Howells } internal; 348607ca46eSDavid Howells /* KVM_EXIT_OSI */ 349607ca46eSDavid Howells struct { 350607ca46eSDavid Howells __u64 gprs[32]; 351607ca46eSDavid Howells } osi; 3528ab30c15SAlex Bennée /* KVM_EXIT_PAPR_HCALL */ 353607ca46eSDavid Howells struct { 354607ca46eSDavid Howells __u64 nr; 355607ca46eSDavid Howells __u64 ret; 356607ca46eSDavid Howells __u64 args[9]; 357607ca46eSDavid Howells } papr_hcall; 358fa6b7fe9SCornelia Huck /* KVM_EXIT_S390_TSCH */ 359fa6b7fe9SCornelia Huck struct { 360fa6b7fe9SCornelia Huck __u16 subchannel_id; 361fa6b7fe9SCornelia Huck __u16 subchannel_nr; 362fa6b7fe9SCornelia Huck __u32 io_int_parm; 363fa6b7fe9SCornelia Huck __u32 io_int_word; 364fa6b7fe9SCornelia Huck __u32 ipb; 365fa6b7fe9SCornelia Huck __u8 dequeued; 366fa6b7fe9SCornelia Huck } s390_tsch; 3671c810636SAlexander Graf /* KVM_EXIT_EPR */ 3681c810636SAlexander Graf struct { 3691c810636SAlexander Graf __u32 epr; 3701c810636SAlexander Graf } epr; 3718ad6b634SAnup Patel /* KVM_EXIT_SYSTEM_EVENT */ 3728ad6b634SAnup Patel struct { 3738ad6b634SAnup Patel #define KVM_SYSTEM_EVENT_SHUTDOWN 1 3748ad6b634SAnup Patel #define KVM_SYSTEM_EVENT_RESET 2 3752ce79189SAndrey Smetanin #define KVM_SYSTEM_EVENT_CRASH 3 3768ad6b634SAnup Patel __u32 type; 3778ad6b634SAnup Patel __u64 flags; 3788ad6b634SAnup Patel } system_event; 379e44fc8c9SEkaterina Tumanova /* KVM_EXIT_S390_STSI */ 380e44fc8c9SEkaterina Tumanova struct { 381e44fc8c9SEkaterina Tumanova __u64 addr; 382e44fc8c9SEkaterina Tumanova __u8 ar; 383e44fc8c9SEkaterina Tumanova __u8 reserved; 384e44fc8c9SEkaterina Tumanova __u8 fc; 385e44fc8c9SEkaterina Tumanova __u8 sel1; 386e44fc8c9SEkaterina Tumanova __u16 sel2; 387e44fc8c9SEkaterina Tumanova } s390_stsi; 3887543a635SSteve Rutherford /* KVM_EXIT_IOAPIC_EOI */ 3897543a635SSteve Rutherford struct { 3907543a635SSteve Rutherford __u8 vector; 3917543a635SSteve Rutherford } eoi; 392db397571SAndrey Smetanin /* KVM_EXIT_HYPERV */ 393db397571SAndrey Smetanin struct kvm_hyperv_exit hyperv; 394607ca46eSDavid Howells /* Fix the size of the union. */ 395607ca46eSDavid Howells char padding[256]; 396607ca46eSDavid Howells }; 397607ca46eSDavid Howells 398607ca46eSDavid Howells /* 399607ca46eSDavid Howells * shared registers between kvm and userspace. 400607ca46eSDavid Howells * kvm_valid_regs specifies the register classes set by the host 401607ca46eSDavid Howells * kvm_dirty_regs specified the register classes dirtied by userspace 402607ca46eSDavid Howells * struct kvm_sync_regs is architecture specific, as well as the 403607ca46eSDavid Howells * bits for kvm_valid_regs and kvm_dirty_regs 404607ca46eSDavid Howells */ 405607ca46eSDavid Howells __u64 kvm_valid_regs; 406607ca46eSDavid Howells __u64 kvm_dirty_regs; 407607ca46eSDavid Howells union { 408607ca46eSDavid Howells struct kvm_sync_regs regs; 40968c55750SEric Farman char padding[2048]; 410607ca46eSDavid Howells } s; 411607ca46eSDavid Howells }; 412607ca46eSDavid Howells 413607ca46eSDavid Howells /* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */ 414607ca46eSDavid Howells 415607ca46eSDavid Howells struct kvm_coalesced_mmio_zone { 416607ca46eSDavid Howells __u64 addr; 417607ca46eSDavid Howells __u32 size; 418607ca46eSDavid Howells __u32 pad; 419607ca46eSDavid Howells }; 420607ca46eSDavid Howells 421607ca46eSDavid Howells struct kvm_coalesced_mmio { 422607ca46eSDavid Howells __u64 phys_addr; 423607ca46eSDavid Howells __u32 len; 424607ca46eSDavid Howells __u32 pad; 425607ca46eSDavid Howells __u8 data[8]; 426607ca46eSDavid Howells }; 427607ca46eSDavid Howells 428607ca46eSDavid Howells struct kvm_coalesced_mmio_ring { 429607ca46eSDavid Howells __u32 first, last; 430607ca46eSDavid Howells struct kvm_coalesced_mmio coalesced_mmio[0]; 431607ca46eSDavid Howells }; 432607ca46eSDavid Howells 433607ca46eSDavid Howells #define KVM_COALESCED_MMIO_MAX \ 434607ca46eSDavid Howells ((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \ 435607ca46eSDavid Howells sizeof(struct kvm_coalesced_mmio)) 436607ca46eSDavid Howells 437607ca46eSDavid Howells /* for KVM_TRANSLATE */ 438607ca46eSDavid Howells struct kvm_translation { 439607ca46eSDavid Howells /* in */ 440607ca46eSDavid Howells __u64 linear_address; 441607ca46eSDavid Howells 442607ca46eSDavid Howells /* out */ 443607ca46eSDavid Howells __u64 physical_address; 444607ca46eSDavid Howells __u8 valid; 445607ca46eSDavid Howells __u8 writeable; 446607ca46eSDavid Howells __u8 usermode; 447607ca46eSDavid Howells __u8 pad[5]; 448607ca46eSDavid Howells }; 449607ca46eSDavid Howells 45041408c28SThomas Huth /* for KVM_S390_MEM_OP */ 45141408c28SThomas Huth struct kvm_s390_mem_op { 45241408c28SThomas Huth /* in */ 45341408c28SThomas Huth __u64 gaddr; /* the guest address */ 45441408c28SThomas Huth __u64 flags; /* flags */ 45541408c28SThomas Huth __u32 size; /* amount of bytes */ 45641408c28SThomas Huth __u32 op; /* type of operation */ 45741408c28SThomas Huth __u64 buf; /* buffer in userspace */ 45841408c28SThomas Huth __u8 ar; /* the access register number */ 45941408c28SThomas Huth __u8 reserved[31]; /* should be set to 0 */ 46041408c28SThomas Huth }; 46141408c28SThomas Huth /* types for kvm_s390_mem_op->op */ 46241408c28SThomas Huth #define KVM_S390_MEMOP_LOGICAL_READ 0 46341408c28SThomas Huth #define KVM_S390_MEMOP_LOGICAL_WRITE 1 46441408c28SThomas Huth /* flags for kvm_s390_mem_op->flags */ 46541408c28SThomas Huth #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0) 46641408c28SThomas Huth #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1) 46741408c28SThomas Huth 468607ca46eSDavid Howells /* for KVM_INTERRUPT */ 469607ca46eSDavid Howells struct kvm_interrupt { 470607ca46eSDavid Howells /* in */ 471607ca46eSDavid Howells __u32 irq; 472607ca46eSDavid Howells }; 473607ca46eSDavid Howells 474607ca46eSDavid Howells /* for KVM_GET_DIRTY_LOG */ 475607ca46eSDavid Howells struct kvm_dirty_log { 476607ca46eSDavid Howells __u32 slot; 477607ca46eSDavid Howells __u32 padding1; 478607ca46eSDavid Howells union { 479607ca46eSDavid Howells void __user *dirty_bitmap; /* one bit per page */ 480607ca46eSDavid Howells __u64 padding2; 481607ca46eSDavid Howells }; 482607ca46eSDavid Howells }; 483607ca46eSDavid Howells 484607ca46eSDavid Howells /* for KVM_SET_SIGNAL_MASK */ 485607ca46eSDavid Howells struct kvm_signal_mask { 486607ca46eSDavid Howells __u32 len; 487607ca46eSDavid Howells __u8 sigset[0]; 488607ca46eSDavid Howells }; 489607ca46eSDavid Howells 490607ca46eSDavid Howells /* for KVM_TPR_ACCESS_REPORTING */ 491607ca46eSDavid Howells struct kvm_tpr_access_ctl { 492607ca46eSDavid Howells __u32 enabled; 493607ca46eSDavid Howells __u32 flags; 494607ca46eSDavid Howells __u32 reserved[8]; 495607ca46eSDavid Howells }; 496607ca46eSDavid Howells 497607ca46eSDavid Howells /* for KVM_SET_VAPIC_ADDR */ 498607ca46eSDavid Howells struct kvm_vapic_addr { 499607ca46eSDavid Howells __u64 vapic_addr; 500607ca46eSDavid Howells }; 501607ca46eSDavid Howells 5020b4820d6SDavid Hildenbrand /* for KVM_SET_MP_STATE */ 503607ca46eSDavid Howells 5040b4820d6SDavid Hildenbrand /* not all states are valid on all architectures */ 505607ca46eSDavid Howells #define KVM_MP_STATE_RUNNABLE 0 506607ca46eSDavid Howells #define KVM_MP_STATE_UNINITIALIZED 1 507607ca46eSDavid Howells #define KVM_MP_STATE_INIT_RECEIVED 2 508607ca46eSDavid Howells #define KVM_MP_STATE_HALTED 3 509607ca46eSDavid Howells #define KVM_MP_STATE_SIPI_RECEIVED 4 5106352e4d2SDavid Hildenbrand #define KVM_MP_STATE_STOPPED 5 5116352e4d2SDavid Hildenbrand #define KVM_MP_STATE_CHECK_STOP 6 5126352e4d2SDavid Hildenbrand #define KVM_MP_STATE_OPERATING 7 5136352e4d2SDavid Hildenbrand #define KVM_MP_STATE_LOAD 8 514607ca46eSDavid Howells 515607ca46eSDavid Howells struct kvm_mp_state { 516607ca46eSDavid Howells __u32 mp_state; 517607ca46eSDavid Howells }; 518607ca46eSDavid Howells 519607ca46eSDavid Howells struct kvm_s390_psw { 520607ca46eSDavid Howells __u64 mask; 521607ca46eSDavid Howells __u64 addr; 522607ca46eSDavid Howells }; 523607ca46eSDavid Howells 524607ca46eSDavid Howells /* valid values for type in kvm_s390_interrupt */ 525607ca46eSDavid Howells #define KVM_S390_SIGP_STOP 0xfffe0000u 526607ca46eSDavid Howells #define KVM_S390_PROGRAM_INT 0xfffe0001u 527607ca46eSDavid Howells #define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u 528607ca46eSDavid Howells #define KVM_S390_RESTART 0xfffe0003u 5293c038e6bSDominik Dingel #define KVM_S390_INT_PFAULT_INIT 0xfffe0004u 5303c038e6bSDominik Dingel #define KVM_S390_INT_PFAULT_DONE 0xfffe0005u 53148a3e950SCornelia Huck #define KVM_S390_MCHK 0xfffe1000u 532e029ae5bSThomas Huth #define KVM_S390_INT_CLOCK_COMP 0xffff1004u 533e029ae5bSThomas Huth #define KVM_S390_INT_CPU_TIMER 0xffff1005u 534607ca46eSDavid Howells #define KVM_S390_INT_VIRTIO 0xffff2603u 535607ca46eSDavid Howells #define KVM_S390_INT_SERVICE 0xffff2401u 536607ca46eSDavid Howells #define KVM_S390_INT_EMERGENCY 0xffff1201u 537607ca46eSDavid Howells #define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u 538d8346b7dSCornelia Huck /* Anything below 0xfffe0000u is taken by INT_IO */ 539d8346b7dSCornelia Huck #define KVM_S390_INT_IO(ai,cssid,ssid,schid) \ 540d8346b7dSCornelia Huck (((schid)) | \ 541d8346b7dSCornelia Huck ((ssid) << 16) | \ 542d8346b7dSCornelia Huck ((cssid) << 18) | \ 543d8346b7dSCornelia Huck ((ai) << 26)) 544d8346b7dSCornelia Huck #define KVM_S390_INT_IO_MIN 0x00000000u 545d8346b7dSCornelia Huck #define KVM_S390_INT_IO_MAX 0xfffdffffu 546a37281b6SDavid Hildenbrand #define KVM_S390_INT_IO_AI_MASK 0x04000000u 547d8346b7dSCornelia Huck 548607ca46eSDavid Howells 549607ca46eSDavid Howells struct kvm_s390_interrupt { 550607ca46eSDavid Howells __u32 type; 551607ca46eSDavid Howells __u32 parm; 552607ca46eSDavid Howells __u64 parm64; 553607ca46eSDavid Howells }; 554607ca46eSDavid Howells 55581aa8efeSJens Freimann struct kvm_s390_io_info { 55681aa8efeSJens Freimann __u16 subchannel_id; 55781aa8efeSJens Freimann __u16 subchannel_nr; 55881aa8efeSJens Freimann __u32 io_int_parm; 55981aa8efeSJens Freimann __u32 io_int_word; 56081aa8efeSJens Freimann }; 56181aa8efeSJens Freimann 56281aa8efeSJens Freimann struct kvm_s390_ext_info { 56381aa8efeSJens Freimann __u32 ext_params; 56481aa8efeSJens Freimann __u32 pad; 56581aa8efeSJens Freimann __u64 ext_params2; 56681aa8efeSJens Freimann }; 56781aa8efeSJens Freimann 56881aa8efeSJens Freimann struct kvm_s390_pgm_info { 56981aa8efeSJens Freimann __u64 trans_exc_code; 57081aa8efeSJens Freimann __u64 mon_code; 57181aa8efeSJens Freimann __u64 per_address; 57281aa8efeSJens Freimann __u32 data_exc_code; 57381aa8efeSJens Freimann __u16 code; 57481aa8efeSJens Freimann __u16 mon_class_nr; 57581aa8efeSJens Freimann __u8 per_code; 57681aa8efeSJens Freimann __u8 per_atmid; 57781aa8efeSJens Freimann __u8 exc_access_id; 57881aa8efeSJens Freimann __u8 per_access_id; 57981aa8efeSJens Freimann __u8 op_access_id; 580634790b8SDavid Hildenbrand #define KVM_S390_PGM_FLAGS_ILC_VALID 0x01 581634790b8SDavid Hildenbrand #define KVM_S390_PGM_FLAGS_ILC_0 0x02 582634790b8SDavid Hildenbrand #define KVM_S390_PGM_FLAGS_ILC_1 0x04 583634790b8SDavid Hildenbrand #define KVM_S390_PGM_FLAGS_ILC_MASK 0x06 584eaa4f416SDavid Hildenbrand #define KVM_S390_PGM_FLAGS_NO_REWIND 0x08 585634790b8SDavid Hildenbrand __u8 flags; 586634790b8SDavid Hildenbrand __u8 pad[2]; 58781aa8efeSJens Freimann }; 58881aa8efeSJens Freimann 58981aa8efeSJens Freimann struct kvm_s390_prefix_info { 59081aa8efeSJens Freimann __u32 address; 59181aa8efeSJens Freimann }; 59281aa8efeSJens Freimann 59381aa8efeSJens Freimann struct kvm_s390_extcall_info { 59481aa8efeSJens Freimann __u16 code; 59581aa8efeSJens Freimann }; 59681aa8efeSJens Freimann 59781aa8efeSJens Freimann struct kvm_s390_emerg_info { 59881aa8efeSJens Freimann __u16 code; 59981aa8efeSJens Freimann }; 60081aa8efeSJens Freimann 6012822545fSDavid Hildenbrand #define KVM_S390_STOP_FLAG_STORE_STATUS 0x01 6022822545fSDavid Hildenbrand struct kvm_s390_stop_info { 6032822545fSDavid Hildenbrand __u32 flags; 6042822545fSDavid Hildenbrand }; 6052822545fSDavid Hildenbrand 60681aa8efeSJens Freimann struct kvm_s390_mchk_info { 60781aa8efeSJens Freimann __u64 cr14; 60881aa8efeSJens Freimann __u64 mcic; 60981aa8efeSJens Freimann __u64 failing_storage_address; 61081aa8efeSJens Freimann __u32 ext_damage_code; 61181aa8efeSJens Freimann __u32 pad; 61281aa8efeSJens Freimann __u8 fixed_logout[16]; 61381aa8efeSJens Freimann }; 61481aa8efeSJens Freimann 61581aa8efeSJens Freimann struct kvm_s390_irq { 61681aa8efeSJens Freimann __u64 type; 61781aa8efeSJens Freimann union { 61881aa8efeSJens Freimann struct kvm_s390_io_info io; 61981aa8efeSJens Freimann struct kvm_s390_ext_info ext; 62081aa8efeSJens Freimann struct kvm_s390_pgm_info pgm; 62181aa8efeSJens Freimann struct kvm_s390_emerg_info emerg; 62281aa8efeSJens Freimann struct kvm_s390_extcall_info extcall; 62381aa8efeSJens Freimann struct kvm_s390_prefix_info prefix; 6242822545fSDavid Hildenbrand struct kvm_s390_stop_info stop; 62581aa8efeSJens Freimann struct kvm_s390_mchk_info mchk; 62681aa8efeSJens Freimann char reserved[64]; 62781aa8efeSJens Freimann } u; 62881aa8efeSJens Freimann }; 62981aa8efeSJens Freimann 630816c7667SJens Freimann struct kvm_s390_irq_state { 631816c7667SJens Freimann __u64 buf; 632816c7667SJens Freimann __u32 flags; 633816c7667SJens Freimann __u32 len; 634816c7667SJens Freimann __u32 reserved[4]; 635816c7667SJens Freimann }; 636816c7667SJens Freimann 637607ca46eSDavid Howells /* for KVM_SET_GUEST_DEBUG */ 638607ca46eSDavid Howells 639607ca46eSDavid Howells #define KVM_GUESTDBG_ENABLE 0x00000001 640607ca46eSDavid Howells #define KVM_GUESTDBG_SINGLESTEP 0x00000002 641607ca46eSDavid Howells 642607ca46eSDavid Howells struct kvm_guest_debug { 643607ca46eSDavid Howells __u32 control; 644607ca46eSDavid Howells __u32 pad; 645607ca46eSDavid Howells struct kvm_guest_debug_arch arch; 646607ca46eSDavid Howells }; 647607ca46eSDavid Howells 648607ca46eSDavid Howells enum { 649607ca46eSDavid Howells kvm_ioeventfd_flag_nr_datamatch, 650607ca46eSDavid Howells kvm_ioeventfd_flag_nr_pio, 651607ca46eSDavid Howells kvm_ioeventfd_flag_nr_deassign, 6522b83451bSCornelia Huck kvm_ioeventfd_flag_nr_virtio_ccw_notify, 65368c3b4d1SMichael S. Tsirkin kvm_ioeventfd_flag_nr_fast_mmio, 654607ca46eSDavid Howells kvm_ioeventfd_flag_nr_max, 655607ca46eSDavid Howells }; 656607ca46eSDavid Howells 657607ca46eSDavid Howells #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) 658607ca46eSDavid Howells #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) 659607ca46eSDavid Howells #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) 6602b83451bSCornelia Huck #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ 6612b83451bSCornelia Huck (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify) 662607ca46eSDavid Howells 663607ca46eSDavid Howells #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1) 664607ca46eSDavid Howells 665607ca46eSDavid Howells struct kvm_ioeventfd { 666607ca46eSDavid Howells __u64 datamatch; 667607ca46eSDavid Howells __u64 addr; /* legal pio/mmio address */ 668f848a5a8SMichael S. Tsirkin __u32 len; /* 1, 2, 4, or 8 bytes; or 0 to ignore length */ 669607ca46eSDavid Howells __s32 fd; 670607ca46eSDavid Howells __u32 flags; 671607ca46eSDavid Howells __u8 pad[36]; 672607ca46eSDavid Howells }; 673607ca46eSDavid Howells 674607ca46eSDavid Howells /* for KVM_ENABLE_CAP */ 675607ca46eSDavid Howells struct kvm_enable_cap { 676607ca46eSDavid Howells /* in */ 677607ca46eSDavid Howells __u32 cap; 678607ca46eSDavid Howells __u32 flags; 679607ca46eSDavid Howells __u64 args[4]; 680607ca46eSDavid Howells __u8 pad[64]; 681607ca46eSDavid Howells }; 682607ca46eSDavid Howells 683607ca46eSDavid Howells /* for KVM_PPC_GET_PVINFO */ 684a91d5df2SDavid Gibson 685a91d5df2SDavid Gibson #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) 686a91d5df2SDavid Gibson 687607ca46eSDavid Howells struct kvm_ppc_pvinfo { 688607ca46eSDavid Howells /* out */ 689607ca46eSDavid Howells __u32 flags; 690607ca46eSDavid Howells __u32 hcall[4]; 691607ca46eSDavid Howells __u8 pad[108]; 692607ca46eSDavid Howells }; 693607ca46eSDavid Howells 694607ca46eSDavid Howells /* for KVM_PPC_GET_SMMU_INFO */ 695607ca46eSDavid Howells #define KVM_PPC_PAGE_SIZES_MAX_SZ 8 696607ca46eSDavid Howells 697607ca46eSDavid Howells struct kvm_ppc_one_page_size { 698607ca46eSDavid Howells __u32 page_shift; /* Page shift (or 0) */ 699607ca46eSDavid Howells __u32 pte_enc; /* Encoding in the HPTE (>>12) */ 700607ca46eSDavid Howells }; 701607ca46eSDavid Howells 702607ca46eSDavid Howells struct kvm_ppc_one_seg_page_size { 703607ca46eSDavid Howells __u32 page_shift; /* Base page shift of segment (or 0) */ 704607ca46eSDavid Howells __u32 slb_enc; /* SLB encoding for BookS */ 705607ca46eSDavid Howells struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ]; 706607ca46eSDavid Howells }; 707607ca46eSDavid Howells 708607ca46eSDavid Howells #define KVM_PPC_PAGE_SIZES_REAL 0x00000001 709607ca46eSDavid Howells #define KVM_PPC_1T_SEGMENTS 0x00000002 710607ca46eSDavid Howells 711607ca46eSDavid Howells struct kvm_ppc_smmu_info { 712607ca46eSDavid Howells __u64 flags; 713607ca46eSDavid Howells __u32 slb_size; 714607ca46eSDavid Howells __u32 pad; 715607ca46eSDavid Howells struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ]; 716607ca46eSDavid Howells }; 717607ca46eSDavid Howells 718ef1ead0cSDavid Gibson /* for KVM_PPC_RESIZE_HPT_{PREPARE,COMMIT} */ 719ef1ead0cSDavid Gibson struct kvm_ppc_resize_hpt { 720ef1ead0cSDavid Gibson __u64 flags; 721ef1ead0cSDavid Gibson __u32 shift; 722ef1ead0cSDavid Gibson __u32 pad; 723ef1ead0cSDavid Gibson }; 724ef1ead0cSDavid Gibson 725607ca46eSDavid Howells #define KVMIO 0xAE 726607ca46eSDavid Howells 727607ca46eSDavid Howells /* machine type bits, to be used as argument to KVM_CREATE_VM */ 728607ca46eSDavid Howells #define KVM_VM_S390_UCONTROL 1 729607ca46eSDavid Howells 730cbbc58d4SAneesh Kumar K.V /* on ppc, 0 indicate default, 1 should force HV and 2 PR */ 731cbbc58d4SAneesh Kumar K.V #define KVM_VM_PPC_HV 1 732cbbc58d4SAneesh Kumar K.V #define KVM_VM_PPC_PR 2 733cbbc58d4SAneesh Kumar K.V 734a8a3c426SJames Hogan /* on MIPS, 0 forces trap & emulate, 1 forces VZ ASE */ 735a8a3c426SJames Hogan #define KVM_VM_MIPS_TE 0 736a8a3c426SJames Hogan #define KVM_VM_MIPS_VZ 1 737a8a3c426SJames Hogan 738607ca46eSDavid Howells #define KVM_S390_SIE_PAGE_OFFSET 1 739607ca46eSDavid Howells 740607ca46eSDavid Howells /* 741607ca46eSDavid Howells * ioctls for /dev/kvm fds: 742607ca46eSDavid Howells */ 743607ca46eSDavid Howells #define KVM_GET_API_VERSION _IO(KVMIO, 0x00) 744607ca46eSDavid Howells #define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ 745607ca46eSDavid Howells #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) 746607ca46eSDavid Howells 747607ca46eSDavid Howells #define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06) 748607ca46eSDavid Howells /* 749607ca46eSDavid Howells * Check if a kvm extension is available. Argument is extension number, 750607ca46eSDavid Howells * return is 1 (yes) or 0 (no, sorry). 751607ca46eSDavid Howells */ 752607ca46eSDavid Howells #define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03) 753607ca46eSDavid Howells /* 754607ca46eSDavid Howells * Get size for mmap(vcpu_fd) 755607ca46eSDavid Howells */ 756607ca46eSDavid Howells #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ 757607ca46eSDavid Howells #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) 758607ca46eSDavid Howells #define KVM_TRACE_ENABLE __KVM_DEPRECATED_MAIN_W_0x06 759607ca46eSDavid Howells #define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07 760607ca46eSDavid Howells #define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08 7619c15bb1dSBorislav Petkov #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) 762607ca46eSDavid Howells 763607ca46eSDavid Howells /* 764607ca46eSDavid Howells * Extension capability list. 765607ca46eSDavid Howells */ 766607ca46eSDavid Howells #define KVM_CAP_IRQCHIP 0 767607ca46eSDavid Howells #define KVM_CAP_HLT 1 768607ca46eSDavid Howells #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 769607ca46eSDavid Howells #define KVM_CAP_USER_MEMORY 3 770607ca46eSDavid Howells #define KVM_CAP_SET_TSS_ADDR 4 771607ca46eSDavid Howells #define KVM_CAP_VAPIC 6 772607ca46eSDavid Howells #define KVM_CAP_EXT_CPUID 7 773607ca46eSDavid Howells #define KVM_CAP_CLOCKSOURCE 8 774607ca46eSDavid Howells #define KVM_CAP_NR_VCPUS 9 /* returns recommended max vcpus per vm */ 775607ca46eSDavid Howells #define KVM_CAP_NR_MEMSLOTS 10 /* returns max memory slots per vm */ 776607ca46eSDavid Howells #define KVM_CAP_PIT 11 777607ca46eSDavid Howells #define KVM_CAP_NOP_IO_DELAY 12 778607ca46eSDavid Howells #define KVM_CAP_PV_MMU 13 779607ca46eSDavid Howells #define KVM_CAP_MP_STATE 14 780607ca46eSDavid Howells #define KVM_CAP_COALESCED_MMIO 15 781607ca46eSDavid Howells #define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ 782607ca46eSDavid Howells #define KVM_CAP_IOMMU 18 783607ca46eSDavid Howells /* Bug in KVM_SET_USER_MEMORY_REGION fixed: */ 784607ca46eSDavid Howells #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21 785607ca46eSDavid Howells #define KVM_CAP_USER_NMI 22 786607ca46eSDavid Howells #ifdef __KVM_HAVE_GUEST_DEBUG 787607ca46eSDavid Howells #define KVM_CAP_SET_GUEST_DEBUG 23 788607ca46eSDavid Howells #endif 789607ca46eSDavid Howells #ifdef __KVM_HAVE_PIT 790607ca46eSDavid Howells #define KVM_CAP_REINJECT_CONTROL 24 791607ca46eSDavid Howells #endif 792607ca46eSDavid Howells #define KVM_CAP_IRQ_ROUTING 25 793607ca46eSDavid Howells #define KVM_CAP_IRQ_INJECT_STATUS 26 794607ca46eSDavid Howells #define KVM_CAP_ASSIGN_DEV_IRQ 29 795607ca46eSDavid Howells /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ 796607ca46eSDavid Howells #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 797607ca46eSDavid Howells #ifdef __KVM_HAVE_MCE 798607ca46eSDavid Howells #define KVM_CAP_MCE 31 799607ca46eSDavid Howells #endif 800607ca46eSDavid Howells #define KVM_CAP_IRQFD 32 801607ca46eSDavid Howells #ifdef __KVM_HAVE_PIT 802607ca46eSDavid Howells #define KVM_CAP_PIT2 33 803607ca46eSDavid Howells #endif 804607ca46eSDavid Howells #define KVM_CAP_SET_BOOT_CPU_ID 34 805607ca46eSDavid Howells #ifdef __KVM_HAVE_PIT_STATE2 806607ca46eSDavid Howells #define KVM_CAP_PIT_STATE2 35 807607ca46eSDavid Howells #endif 808607ca46eSDavid Howells #define KVM_CAP_IOEVENTFD 36 809607ca46eSDavid Howells #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 810607ca46eSDavid Howells #ifdef __KVM_HAVE_XEN_HVM 811607ca46eSDavid Howells #define KVM_CAP_XEN_HVM 38 812607ca46eSDavid Howells #endif 813607ca46eSDavid Howells #define KVM_CAP_ADJUST_CLOCK 39 814607ca46eSDavid Howells #define KVM_CAP_INTERNAL_ERROR_DATA 40 815607ca46eSDavid Howells #ifdef __KVM_HAVE_VCPU_EVENTS 816607ca46eSDavid Howells #define KVM_CAP_VCPU_EVENTS 41 817607ca46eSDavid Howells #endif 818607ca46eSDavid Howells #define KVM_CAP_S390_PSW 42 819607ca46eSDavid Howells #define KVM_CAP_PPC_SEGSTATE 43 820607ca46eSDavid Howells #define KVM_CAP_HYPERV 44 821607ca46eSDavid Howells #define KVM_CAP_HYPERV_VAPIC 45 822607ca46eSDavid Howells #define KVM_CAP_HYPERV_SPIN 46 823607ca46eSDavid Howells #define KVM_CAP_PCI_SEGMENT 47 824607ca46eSDavid Howells #define KVM_CAP_PPC_PAIRED_SINGLES 48 825607ca46eSDavid Howells #define KVM_CAP_INTR_SHADOW 49 826607ca46eSDavid Howells #ifdef __KVM_HAVE_DEBUGREGS 827607ca46eSDavid Howells #define KVM_CAP_DEBUGREGS 50 828607ca46eSDavid Howells #endif 829607ca46eSDavid Howells #define KVM_CAP_X86_ROBUST_SINGLESTEP 51 830607ca46eSDavid Howells #define KVM_CAP_PPC_OSI 52 831607ca46eSDavid Howells #define KVM_CAP_PPC_UNSET_IRQ 53 832607ca46eSDavid Howells #define KVM_CAP_ENABLE_CAP 54 833607ca46eSDavid Howells #ifdef __KVM_HAVE_XSAVE 834607ca46eSDavid Howells #define KVM_CAP_XSAVE 55 835607ca46eSDavid Howells #endif 836607ca46eSDavid Howells #ifdef __KVM_HAVE_XCRS 837607ca46eSDavid Howells #define KVM_CAP_XCRS 56 838607ca46eSDavid Howells #endif 839607ca46eSDavid Howells #define KVM_CAP_PPC_GET_PVINFO 57 840607ca46eSDavid Howells #define KVM_CAP_PPC_IRQ_LEVEL 58 841607ca46eSDavid Howells #define KVM_CAP_ASYNC_PF 59 842607ca46eSDavid Howells #define KVM_CAP_TSC_CONTROL 60 843607ca46eSDavid Howells #define KVM_CAP_GET_TSC_KHZ 61 844607ca46eSDavid Howells #define KVM_CAP_PPC_BOOKE_SREGS 62 845607ca46eSDavid Howells #define KVM_CAP_SPAPR_TCE 63 846607ca46eSDavid Howells #define KVM_CAP_PPC_SMT 64 847607ca46eSDavid Howells #define KVM_CAP_PPC_RMA 65 848607ca46eSDavid Howells #define KVM_CAP_MAX_VCPUS 66 /* returns max vcpus per vm */ 849607ca46eSDavid Howells #define KVM_CAP_PPC_HIOR 67 850607ca46eSDavid Howells #define KVM_CAP_PPC_PAPR 68 851607ca46eSDavid Howells #define KVM_CAP_SW_TLB 69 852607ca46eSDavid Howells #define KVM_CAP_ONE_REG 70 853607ca46eSDavid Howells #define KVM_CAP_S390_GMAP 71 854607ca46eSDavid Howells #define KVM_CAP_TSC_DEADLINE_TIMER 72 855607ca46eSDavid Howells #define KVM_CAP_S390_UCONTROL 73 856607ca46eSDavid Howells #define KVM_CAP_SYNC_REGS 74 857607ca46eSDavid Howells #define KVM_CAP_PCI_2_3 75 858607ca46eSDavid Howells #define KVM_CAP_KVMCLOCK_CTRL 76 859607ca46eSDavid Howells #define KVM_CAP_SIGNAL_MSI 77 860607ca46eSDavid Howells #define KVM_CAP_PPC_GET_SMMU_INFO 78 861607ca46eSDavid Howells #define KVM_CAP_S390_COW 79 862607ca46eSDavid Howells #define KVM_CAP_PPC_ALLOC_HTAB 80 863607ca46eSDavid Howells #define KVM_CAP_READONLY_MEM 81 864607ca46eSDavid Howells #define KVM_CAP_IRQFD_RESAMPLE 82 86519bf7f8aSMarcelo Tosatti #define KVM_CAP_PPC_BOOKE_WATCHDOG 83 866a2932923SPaul Mackerras #define KVM_CAP_PPC_HTAB_FD 84 867fa6b7fe9SCornelia Huck #define KVM_CAP_S390_CSS_SUPPORT 85 8681c810636SAlexander Graf #define KVM_CAP_PPC_EPR 86 869aa024c2fSMarc Zyngier #define KVM_CAP_ARM_PSCI 87 8703401d546SChristoffer Dall #define KVM_CAP_ARM_SET_DEVICE_ADDR 88 871852b6d57SScott Wood #define KVM_CAP_DEVICE_CTRL 89 872eb1e4f43SScott Wood #define KVM_CAP_IRQ_MPIC 90 8738e591cb7SMichael Ellerman #define KVM_CAP_PPC_RTAS 91 8745975a2e0SPaul Mackerras #define KVM_CAP_IRQ_XICS 92 8750d854a60SMarc Zyngier #define KVM_CAP_ARM_EL1_32BIT 93 8760bd50dc9SAlexey Kardashevskiy #define KVM_CAP_SPAPR_MULTITCE 94 8779c15bb1dSBorislav Petkov #define KVM_CAP_EXT_EMUL_CPUID 95 878e984097bSVadim Rozenfeld #define KVM_CAP_HYPERV_TIME 96 879100943c5SGabriel L. Somlo #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97 880d938dc55SCornelia Huck #define KVM_CAP_ENABLE_CAP_VM 98 88184223598SCornelia Huck #define KVM_CAP_S390_IRQCHIP 99 882f848a5a8SMichael S. Tsirkin #define KVM_CAP_IOEVENTFD_NO_LENGTH 100 88363b5cf04SMarcelo Tosatti #define KVM_CAP_VM_ATTRIBUTES 101 884717abd20SAnup Patel #define KVM_CAP_ARM_PSCI_0_2 102 88553ea2e46SPaolo Bonzini #define KVM_CAP_PPC_FIXUP_HCALL 103 886699a0ea0SPaul Mackerras #define KVM_CAP_PPC_ENABLE_HCALL 104 88792b591a4SAlexander Graf #define KVM_CAP_CHECK_EXTENSION_VM 105 8882444b352SDavid Hildenbrand #define KVM_CAP_S390_USER_SIGP 106 88968c55750SEric Farman #define KVM_CAP_S390_VECTOR_REGISTERS 107 89041408c28SThomas Huth #define KVM_CAP_S390_MEM_OP 108 891e44fc8c9SEkaterina Tumanova #define KVM_CAP_S390_USER_STSI 109 89230ee2a98SJason J. Herne #define KVM_CAP_S390_SKEYS 110 8935fafd874SJames Hogan #define KVM_CAP_MIPS_FPU 111 894d952bd07SJames Hogan #define KVM_CAP_MIPS_MSA 112 89547b43c52SJens Freimann #define KVM_CAP_S390_INJECT_IRQ 113 896816c7667SJens Freimann #define KVM_CAP_S390_IRQ_STATE 114 897e928e9cbSMichael Ellerman #define KVM_CAP_PPC_HWRNG 115 89890de4a18SNadav Amit #define KVM_CAP_DISABLE_QUIRKS 116 899f077825aSPaolo Bonzini #define KVM_CAP_X86_SMM 117 900f481b069SPaolo Bonzini #define KVM_CAP_MULTI_ADDRESS_SPACE 118 9015540546bSAlex Bennée #define KVM_CAP_GUEST_DEBUG_HW_BPS 119 9025540546bSAlex Bennée #define KVM_CAP_GUEST_DEBUG_HW_WPS 120 90349df6397SSteve Rutherford #define KVM_CAP_SPLIT_IRQCHIP 121 904e9ea5069SJason Wang #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122 9055c919412SAndrey Smetanin #define KVM_CAP_HYPERV_SYNIC 123 906c6e5f166SFan Zhang #define KVM_CAP_S390_RI 124 90701d01d69SAlexey Kardashevskiy #define KVM_CAP_SPAPR_TCE_64 125 908ab92f308SPaolo Bonzini #define KVM_CAP_ARM_PMU_V3 126 909ab92f308SPaolo Bonzini #define KVM_CAP_VCPU_ATTRIBUTES 127 9100b1b1dfdSGreg Kurz #define KVM_CAP_MAX_VCPU_ID 128 91137131313SRadim Krčmář #define KVM_CAP_X2APIC_API 129 9126502a34cSDavid Hildenbrand #define KVM_CAP_S390_USER_INSTR0 130 913912902ceSRadim Krčmář #define KVM_CAP_MSI_DEVID 131 91423528bb2SSam Bobroff #define KVM_CAP_PPC_HTM 132 915ef1ead0cSDavid Gibson #define KVM_CAP_SPAPR_RESIZE_HPT 133 916c9270132SPaul Mackerras #define KVM_CAP_PPC_MMU_RADIX 134 917c9270132SPaul Mackerras #define KVM_CAP_PPC_MMU_HASH_V3 135 918460df4c1SPaolo Bonzini #define KVM_CAP_IMMEDIATE_EXIT 136 919a8a3c426SJames Hogan #define KVM_CAP_MIPS_VZ 137 920a8a3c426SJames Hogan #define KVM_CAP_MIPS_TE 138 921578fd61dSJames Hogan #define KVM_CAP_MIPS_64BIT 139 922f7b1a77dSRadim Krčmář #define KVM_CAP_S390_GS 140 923f7b1a77dSRadim Krčmář #define KVM_CAP_S390_AIS 141 9244898d3f4SAlexey Kardashevskiy #define KVM_CAP_SPAPR_TCE_VFIO 142 925668fffa3SMichael S. Tsirkin #define KVM_CAP_X86_GUEST_MWAIT 143 926c24a7be2SPaolo Bonzini #define KVM_CAP_ARM_USER_IRQ 144 9274036e387SClaudio Imbrenda #define KVM_CAP_S390_CMMA_MIGRATION 145 9288a53e7e5SPaolo Bonzini #define KVM_CAP_PPC_FWNMI 146 9298a53e7e5SPaolo Bonzini #define KVM_CAP_PPC_SMT_POSSIBLE 147 930607ca46eSDavid Howells 931607ca46eSDavid Howells #ifdef KVM_CAP_IRQ_ROUTING 932607ca46eSDavid Howells 933607ca46eSDavid Howells struct kvm_irq_routing_irqchip { 934607ca46eSDavid Howells __u32 irqchip; 935607ca46eSDavid Howells __u32 pin; 936607ca46eSDavid Howells }; 937607ca46eSDavid Howells 938607ca46eSDavid Howells struct kvm_irq_routing_msi { 939607ca46eSDavid Howells __u32 address_lo; 940607ca46eSDavid Howells __u32 address_hi; 941607ca46eSDavid Howells __u32 data; 94276a10b86SEric Auger union { 943607ca46eSDavid Howells __u32 pad; 94476a10b86SEric Auger __u32 devid; 94576a10b86SEric Auger }; 946607ca46eSDavid Howells }; 947607ca46eSDavid Howells 94884223598SCornelia Huck struct kvm_irq_routing_s390_adapter { 94984223598SCornelia Huck __u64 ind_addr; 95084223598SCornelia Huck __u64 summary_addr; 95184223598SCornelia Huck __u64 ind_offset; 95284223598SCornelia Huck __u32 summary_offset; 95384223598SCornelia Huck __u32 adapter_id; 95484223598SCornelia Huck }; 95584223598SCornelia Huck 9565c919412SAndrey Smetanin struct kvm_irq_routing_hv_sint { 9575c919412SAndrey Smetanin __u32 vcpu; 9585c919412SAndrey Smetanin __u32 sint; 9595c919412SAndrey Smetanin }; 9605c919412SAndrey Smetanin 961607ca46eSDavid Howells /* gsi routing entry types */ 962607ca46eSDavid Howells #define KVM_IRQ_ROUTING_IRQCHIP 1 963607ca46eSDavid Howells #define KVM_IRQ_ROUTING_MSI 2 96484223598SCornelia Huck #define KVM_IRQ_ROUTING_S390_ADAPTER 3 9655c919412SAndrey Smetanin #define KVM_IRQ_ROUTING_HV_SINT 4 966607ca46eSDavid Howells 967607ca46eSDavid Howells struct kvm_irq_routing_entry { 968607ca46eSDavid Howells __u32 gsi; 969607ca46eSDavid Howells __u32 type; 970607ca46eSDavid Howells __u32 flags; 971607ca46eSDavid Howells __u32 pad; 972607ca46eSDavid Howells union { 973607ca46eSDavid Howells struct kvm_irq_routing_irqchip irqchip; 974607ca46eSDavid Howells struct kvm_irq_routing_msi msi; 97584223598SCornelia Huck struct kvm_irq_routing_s390_adapter adapter; 9765c919412SAndrey Smetanin struct kvm_irq_routing_hv_sint hv_sint; 977607ca46eSDavid Howells __u32 pad[8]; 978607ca46eSDavid Howells } u; 979607ca46eSDavid Howells }; 980607ca46eSDavid Howells 981607ca46eSDavid Howells struct kvm_irq_routing { 982607ca46eSDavid Howells __u32 nr; 983607ca46eSDavid Howells __u32 flags; 984607ca46eSDavid Howells struct kvm_irq_routing_entry entries[0]; 985607ca46eSDavid Howells }; 986607ca46eSDavid Howells 987607ca46eSDavid Howells #endif 988607ca46eSDavid Howells 989607ca46eSDavid Howells #ifdef KVM_CAP_MCE 990607ca46eSDavid Howells /* x86 MCE */ 991607ca46eSDavid Howells struct kvm_x86_mce { 992607ca46eSDavid Howells __u64 status; 993607ca46eSDavid Howells __u64 addr; 994607ca46eSDavid Howells __u64 misc; 995607ca46eSDavid Howells __u64 mcg_status; 996607ca46eSDavid Howells __u8 bank; 997607ca46eSDavid Howells __u8 pad1[7]; 998607ca46eSDavid Howells __u64 pad2[3]; 999607ca46eSDavid Howells }; 1000607ca46eSDavid Howells #endif 1001607ca46eSDavid Howells 1002607ca46eSDavid Howells #ifdef KVM_CAP_XEN_HVM 1003607ca46eSDavid Howells struct kvm_xen_hvm_config { 1004607ca46eSDavid Howells __u32 flags; 1005607ca46eSDavid Howells __u32 msr; 1006607ca46eSDavid Howells __u64 blob_addr_32; 1007607ca46eSDavid Howells __u64 blob_addr_64; 1008607ca46eSDavid Howells __u8 blob_size_32; 1009607ca46eSDavid Howells __u8 blob_size_64; 1010607ca46eSDavid Howells __u8 pad2[30]; 1011607ca46eSDavid Howells }; 1012607ca46eSDavid Howells #endif 1013607ca46eSDavid Howells 1014607ca46eSDavid Howells #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0) 1015607ca46eSDavid Howells /* 1016607ca46eSDavid Howells * Available with KVM_CAP_IRQFD_RESAMPLE 1017607ca46eSDavid Howells * 1018607ca46eSDavid Howells * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies 1019607ca46eSDavid Howells * the irqfd to operate in resampling mode for level triggered interrupt 1020ea2c6d97STiejun Chen * emulation. See Documentation/virtual/kvm/api.txt. 1021607ca46eSDavid Howells */ 1022607ca46eSDavid Howells #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1) 1023607ca46eSDavid Howells 1024607ca46eSDavid Howells struct kvm_irqfd { 1025607ca46eSDavid Howells __u32 fd; 1026607ca46eSDavid Howells __u32 gsi; 1027607ca46eSDavid Howells __u32 flags; 1028607ca46eSDavid Howells __u32 resamplefd; 1029607ca46eSDavid Howells __u8 pad[16]; 1030607ca46eSDavid Howells }; 1031607ca46eSDavid Howells 1032e3fd9a93SPaolo Bonzini /* For KVM_CAP_ADJUST_CLOCK */ 1033e3fd9a93SPaolo Bonzini 1034e3fd9a93SPaolo Bonzini /* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags. */ 1035e3fd9a93SPaolo Bonzini #define KVM_CLOCK_TSC_STABLE 2 1036e3fd9a93SPaolo Bonzini 1037607ca46eSDavid Howells struct kvm_clock_data { 1038607ca46eSDavid Howells __u64 clock; 1039607ca46eSDavid Howells __u32 flags; 1040607ca46eSDavid Howells __u32 pad[9]; 1041607ca46eSDavid Howells }; 1042607ca46eSDavid Howells 1043e3fd9a93SPaolo Bonzini /* For KVM_CAP_SW_TLB */ 1044e3fd9a93SPaolo Bonzini 1045607ca46eSDavid Howells #define KVM_MMU_FSL_BOOKE_NOHV 0 1046607ca46eSDavid Howells #define KVM_MMU_FSL_BOOKE_HV 1 1047607ca46eSDavid Howells 1048607ca46eSDavid Howells struct kvm_config_tlb { 1049607ca46eSDavid Howells __u64 params; 1050607ca46eSDavid Howells __u64 array; 1051607ca46eSDavid Howells __u32 mmu_type; 1052607ca46eSDavid Howells __u32 array_len; 1053607ca46eSDavid Howells }; 1054607ca46eSDavid Howells 1055607ca46eSDavid Howells struct kvm_dirty_tlb { 1056607ca46eSDavid Howells __u64 bitmap; 1057607ca46eSDavid Howells __u32 num_dirty; 1058607ca46eSDavid Howells }; 1059607ca46eSDavid Howells 1060607ca46eSDavid Howells /* Available with KVM_CAP_ONE_REG */ 1061607ca46eSDavid Howells 1062607ca46eSDavid Howells #define KVM_REG_ARCH_MASK 0xff00000000000000ULL 1063607ca46eSDavid Howells #define KVM_REG_GENERIC 0x0000000000000000ULL 1064607ca46eSDavid Howells 1065607ca46eSDavid Howells /* 1066607ca46eSDavid Howells * Architecture specific registers are to be defined in arch headers and 1067607ca46eSDavid Howells * ORed with the arch identifier. 1068607ca46eSDavid Howells */ 1069607ca46eSDavid Howells #define KVM_REG_PPC 0x1000000000000000ULL 1070607ca46eSDavid Howells #define KVM_REG_X86 0x2000000000000000ULL 1071607ca46eSDavid Howells #define KVM_REG_IA64 0x3000000000000000ULL 1072607ca46eSDavid Howells #define KVM_REG_ARM 0x4000000000000000ULL 1073607ca46eSDavid Howells #define KVM_REG_S390 0x5000000000000000ULL 10747c8c5e6aSMarc Zyngier #define KVM_REG_ARM64 0x6000000000000000ULL 10752a8fedd0SDavid Daney #define KVM_REG_MIPS 0x7000000000000000ULL 1076607ca46eSDavid Howells 1077607ca46eSDavid Howells #define KVM_REG_SIZE_SHIFT 52 1078607ca46eSDavid Howells #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL 1079607ca46eSDavid Howells #define KVM_REG_SIZE_U8 0x0000000000000000ULL 1080607ca46eSDavid Howells #define KVM_REG_SIZE_U16 0x0010000000000000ULL 1081607ca46eSDavid Howells #define KVM_REG_SIZE_U32 0x0020000000000000ULL 1082607ca46eSDavid Howells #define KVM_REG_SIZE_U64 0x0030000000000000ULL 1083607ca46eSDavid Howells #define KVM_REG_SIZE_U128 0x0040000000000000ULL 1084607ca46eSDavid Howells #define KVM_REG_SIZE_U256 0x0050000000000000ULL 1085607ca46eSDavid Howells #define KVM_REG_SIZE_U512 0x0060000000000000ULL 1086607ca46eSDavid Howells #define KVM_REG_SIZE_U1024 0x0070000000000000ULL 1087607ca46eSDavid Howells 1088749cf76cSChristoffer Dall struct kvm_reg_list { 1089749cf76cSChristoffer Dall __u64 n; /* number of regs */ 1090749cf76cSChristoffer Dall __u64 reg[0]; 1091749cf76cSChristoffer Dall }; 1092749cf76cSChristoffer Dall 1093607ca46eSDavid Howells struct kvm_one_reg { 1094607ca46eSDavid Howells __u64 id; 1095607ca46eSDavid Howells __u64 addr; 1096607ca46eSDavid Howells }; 1097607ca46eSDavid Howells 10982b8ddd93SAndre Przywara #define KVM_MSI_VALID_DEVID (1U << 0) 1099607ca46eSDavid Howells struct kvm_msi { 1100607ca46eSDavid Howells __u32 address_lo; 1101607ca46eSDavid Howells __u32 address_hi; 1102607ca46eSDavid Howells __u32 data; 1103607ca46eSDavid Howells __u32 flags; 11042b8ddd93SAndre Przywara __u32 devid; 11052b8ddd93SAndre Przywara __u8 pad[12]; 1106607ca46eSDavid Howells }; 1107607ca46eSDavid Howells 11083401d546SChristoffer Dall struct kvm_arm_device_addr { 11093401d546SChristoffer Dall __u64 id; 11103401d546SChristoffer Dall __u64 addr; 11113401d546SChristoffer Dall }; 11123401d546SChristoffer Dall 1113607ca46eSDavid Howells /* 1114852b6d57SScott Wood * Device control API, available with KVM_CAP_DEVICE_CTRL 1115852b6d57SScott Wood */ 1116852b6d57SScott Wood #define KVM_CREATE_DEVICE_TEST 1 1117852b6d57SScott Wood 1118852b6d57SScott Wood struct kvm_create_device { 1119852b6d57SScott Wood __u32 type; /* in: KVM_DEV_TYPE_xxx */ 1120852b6d57SScott Wood __u32 fd; /* out: device handle */ 1121852b6d57SScott Wood __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */ 1122852b6d57SScott Wood }; 1123852b6d57SScott Wood 1124852b6d57SScott Wood struct kvm_device_attr { 1125852b6d57SScott Wood __u32 flags; /* no flags currently defined */ 1126852b6d57SScott Wood __u32 group; /* device-defined */ 1127852b6d57SScott Wood __u64 attr; /* group-defined */ 1128852b6d57SScott Wood __u64 addr; /* userspace address of attr data */ 1129852b6d57SScott Wood }; 1130852b6d57SScott Wood 1131ec53500fSAlex Williamson #define KVM_DEV_VFIO_GROUP 1 1132ec53500fSAlex Williamson #define KVM_DEV_VFIO_GROUP_ADD 1 1133ec53500fSAlex Williamson #define KVM_DEV_VFIO_GROUP_DEL 2 1134121f80baSAlexey Kardashevskiy #define KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE 3 1135d60eacb0SWill Deacon 1136d60eacb0SWill Deacon enum kvm_device_type { 1137d60eacb0SWill Deacon KVM_DEV_TYPE_FSL_MPIC_20 = 1, 1138d60eacb0SWill Deacon #define KVM_DEV_TYPE_FSL_MPIC_20 KVM_DEV_TYPE_FSL_MPIC_20 1139d60eacb0SWill Deacon KVM_DEV_TYPE_FSL_MPIC_42, 1140d60eacb0SWill Deacon #define KVM_DEV_TYPE_FSL_MPIC_42 KVM_DEV_TYPE_FSL_MPIC_42 1141d60eacb0SWill Deacon KVM_DEV_TYPE_XICS, 1142d60eacb0SWill Deacon #define KVM_DEV_TYPE_XICS KVM_DEV_TYPE_XICS 1143d60eacb0SWill Deacon KVM_DEV_TYPE_VFIO, 1144d60eacb0SWill Deacon #define KVM_DEV_TYPE_VFIO KVM_DEV_TYPE_VFIO 1145d60eacb0SWill Deacon KVM_DEV_TYPE_ARM_VGIC_V2, 1146d60eacb0SWill Deacon #define KVM_DEV_TYPE_ARM_VGIC_V2 KVM_DEV_TYPE_ARM_VGIC_V2 1147d60eacb0SWill Deacon KVM_DEV_TYPE_FLIC, 1148d60eacb0SWill Deacon #define KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_FLIC 1149a0675c25SAndre Przywara KVM_DEV_TYPE_ARM_VGIC_V3, 1150a0675c25SAndre Przywara #define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3 11511085fdc6SAndre Przywara KVM_DEV_TYPE_ARM_VGIC_ITS, 11521085fdc6SAndre Przywara #define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS 1153d60eacb0SWill Deacon KVM_DEV_TYPE_MAX, 1154d60eacb0SWill Deacon }; 11555df554adSScott Wood 1156121f80baSAlexey Kardashevskiy struct kvm_vfio_spapr_tce { 1157121f80baSAlexey Kardashevskiy __s32 groupfd; 1158121f80baSAlexey Kardashevskiy __s32 tablefd; 1159121f80baSAlexey Kardashevskiy }; 1160121f80baSAlexey Kardashevskiy 1161852b6d57SScott Wood /* 1162607ca46eSDavid Howells * ioctls for VM fds 1163607ca46eSDavid Howells */ 1164607ca46eSDavid Howells #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) 1165607ca46eSDavid Howells /* 1166607ca46eSDavid Howells * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns 1167607ca46eSDavid Howells * a vcpu fd. 1168607ca46eSDavid Howells */ 1169607ca46eSDavid Howells #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) 1170607ca46eSDavid Howells #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) 1171607ca46eSDavid Howells /* KVM_SET_MEMORY_ALIAS is obsolete: */ 1172607ca46eSDavid Howells #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) 1173607ca46eSDavid Howells #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) 1174607ca46eSDavid Howells #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) 1175607ca46eSDavid Howells #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ 1176607ca46eSDavid Howells struct kvm_userspace_memory_region) 1177607ca46eSDavid Howells #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) 1178607ca46eSDavid Howells #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64) 1179607ca46eSDavid Howells 1180607ca46eSDavid Howells /* enable ucontrol for s390 */ 1181607ca46eSDavid Howells struct kvm_s390_ucas_mapping { 1182607ca46eSDavid Howells __u64 user_addr; 1183607ca46eSDavid Howells __u64 vcpu_addr; 1184607ca46eSDavid Howells __u64 length; 1185607ca46eSDavid Howells }; 1186607ca46eSDavid Howells #define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping) 1187607ca46eSDavid Howells #define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping) 1188607ca46eSDavid Howells #define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long) 1189607ca46eSDavid Howells 1190607ca46eSDavid Howells /* Device model IOC */ 1191607ca46eSDavid Howells #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) 1192607ca46eSDavid Howells #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) 1193607ca46eSDavid Howells #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) 1194607ca46eSDavid Howells #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) 1195607ca46eSDavid Howells #define KVM_CREATE_PIT _IO(KVMIO, 0x64) 1196607ca46eSDavid Howells #define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state) 1197607ca46eSDavid Howells #define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state) 1198607ca46eSDavid Howells #define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level) 1199607ca46eSDavid Howells #define KVM_REGISTER_COALESCED_MMIO \ 1200607ca46eSDavid Howells _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone) 1201607ca46eSDavid Howells #define KVM_UNREGISTER_COALESCED_MMIO \ 1202607ca46eSDavid Howells _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone) 1203607ca46eSDavid Howells #define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \ 1204607ca46eSDavid Howells struct kvm_assigned_pci_dev) 1205607ca46eSDavid Howells #define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing) 1206607ca46eSDavid Howells /* deprecated, replaced by KVM_ASSIGN_DEV_IRQ */ 1207607ca46eSDavid Howells #define KVM_ASSIGN_IRQ __KVM_DEPRECATED_VM_R_0x70 1208607ca46eSDavid Howells #define KVM_ASSIGN_DEV_IRQ _IOW(KVMIO, 0x70, struct kvm_assigned_irq) 1209607ca46eSDavid Howells #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71) 1210607ca46eSDavid Howells #define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, \ 1211607ca46eSDavid Howells struct kvm_assigned_pci_dev) 1212607ca46eSDavid Howells #define KVM_ASSIGN_SET_MSIX_NR _IOW(KVMIO, 0x73, \ 1213607ca46eSDavid Howells struct kvm_assigned_msix_nr) 1214607ca46eSDavid Howells #define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO, 0x74, \ 1215607ca46eSDavid Howells struct kvm_assigned_msix_entry) 1216607ca46eSDavid Howells #define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq) 1217607ca46eSDavid Howells #define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd) 1218607ca46eSDavid Howells #define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config) 1219607ca46eSDavid Howells #define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78) 1220607ca46eSDavid Howells #define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd) 1221607ca46eSDavid Howells #define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config) 1222607ca46eSDavid Howells #define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data) 1223607ca46eSDavid Howells #define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data) 1224607ca46eSDavid Howells /* Available with KVM_CAP_PIT_STATE2 */ 1225607ca46eSDavid Howells #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) 1226607ca46eSDavid Howells #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) 1227607ca46eSDavid Howells /* Available with KVM_CAP_PPC_GET_PVINFO */ 1228607ca46eSDavid Howells #define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo) 1229607ca46eSDavid Howells /* Available with KVM_CAP_TSC_CONTROL */ 1230607ca46eSDavid Howells #define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2) 1231607ca46eSDavid Howells #define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3) 1232607ca46eSDavid Howells /* Available with KVM_CAP_PCI_2_3 */ 1233607ca46eSDavid Howells #define KVM_ASSIGN_SET_INTX_MASK _IOW(KVMIO, 0xa4, \ 1234607ca46eSDavid Howells struct kvm_assigned_pci_dev) 1235607ca46eSDavid Howells /* Available with KVM_CAP_SIGNAL_MSI */ 1236607ca46eSDavid Howells #define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi) 1237607ca46eSDavid Howells /* Available with KVM_CAP_PPC_GET_SMMU_INFO */ 1238607ca46eSDavid Howells #define KVM_PPC_GET_SMMU_INFO _IOR(KVMIO, 0xa6, struct kvm_ppc_smmu_info) 1239607ca46eSDavid Howells /* Available with KVM_CAP_PPC_ALLOC_HTAB */ 1240607ca46eSDavid Howells #define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32) 124119bf7f8aSMarcelo Tosatti #define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce) 124258ded420SAlexey Kardashevskiy #define KVM_CREATE_SPAPR_TCE_64 _IOW(KVMIO, 0xa8, \ 124358ded420SAlexey Kardashevskiy struct kvm_create_spapr_tce_64) 124419bf7f8aSMarcelo Tosatti /* Available with KVM_CAP_RMA */ 124519bf7f8aSMarcelo Tosatti #define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma) 1246a2932923SPaul Mackerras /* Available with KVM_CAP_PPC_HTAB_FD */ 1247a2932923SPaul Mackerras #define KVM_PPC_GET_HTAB_FD _IOW(KVMIO, 0xaa, struct kvm_get_htab_fd) 12483401d546SChristoffer Dall /* Available with KVM_CAP_ARM_SET_DEVICE_ADDR */ 12493401d546SChristoffer Dall #define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr) 12508e591cb7SMichael Ellerman /* Available with KVM_CAP_PPC_RTAS */ 12518e591cb7SMichael Ellerman #define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args) 1252ef1ead0cSDavid Gibson /* Available with KVM_CAP_SPAPR_RESIZE_HPT */ 1253ef1ead0cSDavid Gibson #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt) 1254ef1ead0cSDavid Gibson #define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt) 1255c9270132SPaul Mackerras /* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */ 1256c9270132SPaul Mackerras #define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg) 1257c9270132SPaul Mackerras /* Available with KVM_CAP_PPC_RADIX_MMU */ 1258c9270132SPaul Mackerras #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info) 1259607ca46eSDavid Howells 1260852b6d57SScott Wood /* ioctl for vm fd */ 1261852b6d57SScott Wood #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) 1262852b6d57SScott Wood 1263852b6d57SScott Wood /* ioctls for fds returned by KVM_CREATE_DEVICE */ 1264852b6d57SScott Wood #define KVM_SET_DEVICE_ATTR _IOW(KVMIO, 0xe1, struct kvm_device_attr) 1265852b6d57SScott Wood #define KVM_GET_DEVICE_ATTR _IOW(KVMIO, 0xe2, struct kvm_device_attr) 1266852b6d57SScott Wood #define KVM_HAS_DEVICE_ATTR _IOW(KVMIO, 0xe3, struct kvm_device_attr) 1267852b6d57SScott Wood 1268607ca46eSDavid Howells /* 1269607ca46eSDavid Howells * ioctls for vcpu fds 1270607ca46eSDavid Howells */ 1271607ca46eSDavid Howells #define KVM_RUN _IO(KVMIO, 0x80) 1272607ca46eSDavid Howells #define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs) 1273607ca46eSDavid Howells #define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs) 1274607ca46eSDavid Howells #define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs) 1275607ca46eSDavid Howells #define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs) 1276607ca46eSDavid Howells #define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation) 1277607ca46eSDavid Howells #define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt) 1278607ca46eSDavid Howells /* KVM_DEBUG_GUEST is no longer supported, use KVM_SET_GUEST_DEBUG instead */ 1279607ca46eSDavid Howells #define KVM_DEBUG_GUEST __KVM_DEPRECATED_VCPU_W_0x87 1280607ca46eSDavid Howells #define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs) 1281607ca46eSDavid Howells #define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs) 1282607ca46eSDavid Howells #define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid) 1283607ca46eSDavid Howells #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask) 1284607ca46eSDavid Howells #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu) 1285607ca46eSDavid Howells #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) 1286607ca46eSDavid Howells #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) 1287607ca46eSDavid Howells #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) 1288607ca46eSDavid Howells #define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) 1289607ca46eSDavid Howells #define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2) 1290607ca46eSDavid Howells /* Available with KVM_CAP_VAPIC */ 1291607ca46eSDavid Howells #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl) 1292607ca46eSDavid Howells /* Available with KVM_CAP_VAPIC */ 1293607ca46eSDavid Howells #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) 1294607ca46eSDavid Howells /* valid for virtual machine (for floating interrupt)_and_ vcpu */ 1295607ca46eSDavid Howells #define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt) 1296607ca46eSDavid Howells /* store status for s390 */ 1297607ca46eSDavid Howells #define KVM_S390_STORE_STATUS_NOADDR (-1ul) 1298607ca46eSDavid Howells #define KVM_S390_STORE_STATUS_PREFIXED (-2ul) 1299607ca46eSDavid Howells #define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long) 1300607ca46eSDavid Howells /* initial ipl psw for s390 */ 1301607ca46eSDavid Howells #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw) 1302607ca46eSDavid Howells /* initial reset for s390 */ 1303607ca46eSDavid Howells #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) 1304607ca46eSDavid Howells #define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) 1305607ca46eSDavid Howells #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) 130644b5ce73SChristoffer Dall /* Available with KVM_CAP_USER_NMI */ 1307607ca46eSDavid Howells #define KVM_NMI _IO(KVMIO, 0x9a) 1308607ca46eSDavid Howells /* Available with KVM_CAP_SET_GUEST_DEBUG */ 1309607ca46eSDavid Howells #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) 1310607ca46eSDavid Howells /* MCE for x86 */ 1311607ca46eSDavid Howells #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64) 1312607ca46eSDavid Howells #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64) 1313607ca46eSDavid Howells #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) 1314607ca46eSDavid Howells /* Available with KVM_CAP_VCPU_EVENTS */ 1315607ca46eSDavid Howells #define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events) 1316607ca46eSDavid Howells #define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events) 1317607ca46eSDavid Howells /* Available with KVM_CAP_DEBUGREGS */ 1318607ca46eSDavid Howells #define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs) 1319607ca46eSDavid Howells #define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs) 1320d938dc55SCornelia Huck /* 1321d938dc55SCornelia Huck * vcpu version available with KVM_ENABLE_CAP 1322d938dc55SCornelia Huck * vm version available with KVM_CAP_ENABLE_CAP_VM 1323d938dc55SCornelia Huck */ 1324607ca46eSDavid Howells #define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap) 1325607ca46eSDavid Howells /* Available with KVM_CAP_XSAVE */ 1326607ca46eSDavid Howells #define KVM_GET_XSAVE _IOR(KVMIO, 0xa4, struct kvm_xsave) 1327607ca46eSDavid Howells #define KVM_SET_XSAVE _IOW(KVMIO, 0xa5, struct kvm_xsave) 1328607ca46eSDavid Howells /* Available with KVM_CAP_XCRS */ 1329607ca46eSDavid Howells #define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs) 1330607ca46eSDavid Howells #define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs) 1331607ca46eSDavid Howells /* Available with KVM_CAP_SW_TLB */ 1332607ca46eSDavid Howells #define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb) 1333607ca46eSDavid Howells /* Available with KVM_CAP_ONE_REG */ 1334607ca46eSDavid Howells #define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg) 1335607ca46eSDavid Howells #define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg) 1336607ca46eSDavid Howells /* VM is being stopped by host */ 1337607ca46eSDavid Howells #define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad) 1338749cf76cSChristoffer Dall #define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init) 133942c4e0c7SAnup Patel #define KVM_ARM_PREFERRED_TARGET _IOR(KVMIO, 0xaf, struct kvm_vcpu_init) 1340749cf76cSChristoffer Dall #define KVM_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list) 134141408c28SThomas Huth /* Available with KVM_CAP_S390_MEM_OP */ 134241408c28SThomas Huth #define KVM_S390_MEM_OP _IOW(KVMIO, 0xb1, struct kvm_s390_mem_op) 134330ee2a98SJason J. Herne /* Available with KVM_CAP_S390_SKEYS */ 134430ee2a98SJason J. Herne #define KVM_S390_GET_SKEYS _IOW(KVMIO, 0xb2, struct kvm_s390_skeys) 134530ee2a98SJason J. Herne #define KVM_S390_SET_SKEYS _IOW(KVMIO, 0xb3, struct kvm_s390_skeys) 134647b43c52SJens Freimann /* Available with KVM_CAP_S390_INJECT_IRQ */ 134747b43c52SJens Freimann #define KVM_S390_IRQ _IOW(KVMIO, 0xb4, struct kvm_s390_irq) 1348816c7667SJens Freimann /* Available with KVM_CAP_S390_IRQ_STATE */ 1349816c7667SJens Freimann #define KVM_S390_SET_IRQ_STATE _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state) 1350816c7667SJens Freimann #define KVM_S390_GET_IRQ_STATE _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state) 1351f077825aSPaolo Bonzini /* Available with KVM_CAP_X86_SMM */ 1352f077825aSPaolo Bonzini #define KVM_SMI _IO(KVMIO, 0xb7) 13534036e387SClaudio Imbrenda /* Available with KVM_CAP_S390_CMMA_MIGRATION */ 1354*949c0336SGleb Fotengauer-Malinovskiy #define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log) 13554036e387SClaudio Imbrenda #define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log) 1356607ca46eSDavid Howells 1357607ca46eSDavid Howells #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) 1358607ca46eSDavid Howells #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) 1359607ca46eSDavid Howells #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2) 1360607ca46eSDavid Howells 1361607ca46eSDavid Howells struct kvm_assigned_pci_dev { 1362607ca46eSDavid Howells __u32 assigned_dev_id; 1363607ca46eSDavid Howells __u32 busnr; 1364607ca46eSDavid Howells __u32 devfn; 1365607ca46eSDavid Howells __u32 flags; 1366607ca46eSDavid Howells __u32 segnr; 1367607ca46eSDavid Howells union { 1368607ca46eSDavid Howells __u32 reserved[11]; 1369607ca46eSDavid Howells }; 1370607ca46eSDavid Howells }; 1371607ca46eSDavid Howells 1372607ca46eSDavid Howells #define KVM_DEV_IRQ_HOST_INTX (1 << 0) 1373607ca46eSDavid Howells #define KVM_DEV_IRQ_HOST_MSI (1 << 1) 1374607ca46eSDavid Howells #define KVM_DEV_IRQ_HOST_MSIX (1 << 2) 1375607ca46eSDavid Howells 1376607ca46eSDavid Howells #define KVM_DEV_IRQ_GUEST_INTX (1 << 8) 1377607ca46eSDavid Howells #define KVM_DEV_IRQ_GUEST_MSI (1 << 9) 1378607ca46eSDavid Howells #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10) 1379607ca46eSDavid Howells 1380607ca46eSDavid Howells #define KVM_DEV_IRQ_HOST_MASK 0x00ff 1381607ca46eSDavid Howells #define KVM_DEV_IRQ_GUEST_MASK 0xff00 1382607ca46eSDavid Howells 1383607ca46eSDavid Howells struct kvm_assigned_irq { 1384607ca46eSDavid Howells __u32 assigned_dev_id; 1385607ca46eSDavid Howells __u32 host_irq; /* ignored (legacy field) */ 1386607ca46eSDavid Howells __u32 guest_irq; 1387607ca46eSDavid Howells __u32 flags; 1388607ca46eSDavid Howells union { 1389607ca46eSDavid Howells __u32 reserved[12]; 1390607ca46eSDavid Howells }; 1391607ca46eSDavid Howells }; 1392607ca46eSDavid Howells 1393607ca46eSDavid Howells struct kvm_assigned_msix_nr { 1394607ca46eSDavid Howells __u32 assigned_dev_id; 1395607ca46eSDavid Howells __u16 entry_nr; 1396607ca46eSDavid Howells __u16 padding; 1397607ca46eSDavid Howells }; 1398607ca46eSDavid Howells 1399607ca46eSDavid Howells #define KVM_MAX_MSIX_PER_DEV 256 1400607ca46eSDavid Howells struct kvm_assigned_msix_entry { 1401607ca46eSDavid Howells __u32 assigned_dev_id; 1402607ca46eSDavid Howells __u32 gsi; 1403607ca46eSDavid Howells __u16 entry; /* The index of entry in the MSI-X table */ 1404607ca46eSDavid Howells __u16 padding[3]; 1405607ca46eSDavid Howells }; 1406607ca46eSDavid Howells 140737131313SRadim Krčmář #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0) 1408c519265fSRadim Krčmář #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1) 140937131313SRadim Krčmář 14103fe17e68SAlexander Graf /* Available with KVM_CAP_ARM_USER_IRQ */ 14113fe17e68SAlexander Graf 14123fe17e68SAlexander Graf /* Bits for run->s.regs.device_irq_level */ 14133fe17e68SAlexander Graf #define KVM_ARM_DEV_EL1_VTIMER (1 << 0) 14143fe17e68SAlexander Graf #define KVM_ARM_DEV_EL1_PTIMER (1 << 1) 14153fe17e68SAlexander Graf #define KVM_ARM_DEV_PMU (1 << 2) 14163fe17e68SAlexander Graf 1417607ca46eSDavid Howells #endif /* __LINUX_KVM_H */ 1418