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 19ab0c7fb2SPaolo Bonzini /* 20ab0c7fb2SPaolo Bonzini * Backwards-compatible definitions. 21ab0c7fb2SPaolo Bonzini */ 22ab0c7fb2SPaolo Bonzini #define __KVM_HAVE_GUEST_DEBUG 23ab0c7fb2SPaolo Bonzini 2451b24e34SJan Kiszka /* for KVM_SET_USER_MEMORY_REGION */ 2551b24e34SJan Kiszka struct kvm_userspace_memory_region { 2651b24e34SJan Kiszka __u32 slot; 2751b24e34SJan Kiszka __u32 flags; 2851b24e34SJan Kiszka __u64 guest_phys_addr; 2951b24e34SJan Kiszka __u64 memory_size; /* bytes */ 3051b24e34SJan Kiszka __u64 userspace_addr; /* start of the userspace allocated memory */ 3151b24e34SJan Kiszka }; 3251b24e34SJan Kiszka 336a02465fSDaniel Henrique Barboza /* for KVM_SET_USER_MEMORY_REGION2 */ 346a02465fSDaniel Henrique Barboza struct kvm_userspace_memory_region2 { 356a02465fSDaniel Henrique Barboza __u32 slot; 366a02465fSDaniel Henrique Barboza __u32 flags; 376a02465fSDaniel Henrique Barboza __u64 guest_phys_addr; 386a02465fSDaniel Henrique Barboza __u64 memory_size; 396a02465fSDaniel Henrique Barboza __u64 userspace_addr; 406a02465fSDaniel Henrique Barboza __u64 guest_memfd_offset; 416a02465fSDaniel Henrique Barboza __u32 guest_memfd; 426a02465fSDaniel Henrique Barboza __u32 pad1; 436a02465fSDaniel Henrique Barboza __u64 pad2[14]; 446a02465fSDaniel Henrique Barboza }; 456a02465fSDaniel Henrique Barboza 46716b8e4dSAlex Williamson /* 4793d7620cSAvihai Horon * The bit 0 ~ bit 15 of kvm_userspace_memory_region::flags are visible for 4893d7620cSAvihai Horon * userspace, other bits are reserved for kvm internal use which are defined 4993d7620cSAvihai Horon * in include/linux/kvm_host.h. 50716b8e4dSAlex Williamson */ 51716b8e4dSAlex Williamson #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) 52716b8e4dSAlex Williamson #define KVM_MEM_READONLY (1UL << 1) 536a02465fSDaniel Henrique Barboza #define KVM_MEM_GUEST_MEMFD (1UL << 2) 5451b24e34SJan Kiszka 5551b24e34SJan Kiszka /* for KVM_IRQ_LINE */ 5651b24e34SJan Kiszka struct kvm_irq_level { 5751b24e34SJan Kiszka /* 5851b24e34SJan Kiszka * ACPI gsi notion of irq. 5951b24e34SJan Kiszka * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47.. 6051b24e34SJan Kiszka * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23.. 61f76b348eSCornelia Huck * For ARM: See Documentation/virt/kvm/api.rst 6251b24e34SJan Kiszka */ 6351b24e34SJan Kiszka union { 6451b24e34SJan Kiszka __u32 irq; 6551b24e34SJan Kiszka __s32 status; 6651b24e34SJan Kiszka }; 6751b24e34SJan Kiszka __u32 level; 6851b24e34SJan Kiszka }; 6951b24e34SJan Kiszka 7051b24e34SJan Kiszka 7151b24e34SJan Kiszka struct kvm_irqchip { 7251b24e34SJan Kiszka __u32 chip_id; 7351b24e34SJan Kiszka __u32 pad; 7451b24e34SJan Kiszka union { 7551b24e34SJan Kiszka char dummy[512]; /* reserving space */ 7651b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 7751b24e34SJan Kiszka struct kvm_pic_state pic; 7851b24e34SJan Kiszka #endif 7951b24e34SJan Kiszka #ifdef __KVM_HAVE_IOAPIC 8051b24e34SJan Kiszka struct kvm_ioapic_state ioapic; 8151b24e34SJan Kiszka #endif 8251b24e34SJan Kiszka } chip; 8351b24e34SJan Kiszka }; 8451b24e34SJan Kiszka 8551b24e34SJan Kiszka /* for KVM_CREATE_PIT2 */ 8651b24e34SJan Kiszka struct kvm_pit_config { 8751b24e34SJan Kiszka __u32 flags; 8851b24e34SJan Kiszka __u32 pad[15]; 8951b24e34SJan Kiszka }; 9051b24e34SJan Kiszka 9151b24e34SJan Kiszka #define KVM_PIT_SPEAKER_DUMMY 1 9251b24e34SJan Kiszka 93fff02bc0SPaolo Bonzini struct kvm_hyperv_exit { 94fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV_SYNIC 1 95b89485a5SPaolo Bonzini #define KVM_EXIT_HYPERV_HCALL 2 96f76b348eSCornelia Huck #define KVM_EXIT_HYPERV_SYNDBG 3 97fff02bc0SPaolo Bonzini __u32 type; 98f76b348eSCornelia Huck __u32 pad1; 99fff02bc0SPaolo Bonzini union { 100fff02bc0SPaolo Bonzini struct { 101fff02bc0SPaolo Bonzini __u32 msr; 102f76b348eSCornelia Huck __u32 pad2; 103fff02bc0SPaolo Bonzini __u64 control; 104fff02bc0SPaolo Bonzini __u64 evt_page; 105fff02bc0SPaolo Bonzini __u64 msg_page; 106fff02bc0SPaolo Bonzini } synic; 107b89485a5SPaolo Bonzini struct { 108b89485a5SPaolo Bonzini __u64 input; 109b89485a5SPaolo Bonzini __u64 result; 110b89485a5SPaolo Bonzini __u64 params[2]; 111b89485a5SPaolo Bonzini } hcall; 112f76b348eSCornelia Huck struct { 113f76b348eSCornelia Huck __u32 msr; 114f76b348eSCornelia Huck __u32 pad2; 115f76b348eSCornelia Huck __u64 control; 116f76b348eSCornelia Huck __u64 status; 117f76b348eSCornelia Huck __u64 send_page; 118f76b348eSCornelia Huck __u64 recv_page; 119f76b348eSCornelia Huck __u64 pending_page; 120f76b348eSCornelia Huck } syndbg; 121fff02bc0SPaolo Bonzini } u; 122fff02bc0SPaolo Bonzini }; 123fff02bc0SPaolo Bonzini 124278f064eSEduardo Habkost struct kvm_xen_exit { 125278f064eSEduardo Habkost #define KVM_EXIT_XEN_HCALL 1 126278f064eSEduardo Habkost __u32 type; 127278f064eSEduardo Habkost union { 128278f064eSEduardo Habkost struct { 129278f064eSEduardo Habkost __u32 longmode; 130278f064eSEduardo Habkost __u32 cpl; 131278f064eSEduardo Habkost __u64 input; 132278f064eSEduardo Habkost __u64 result; 133278f064eSEduardo Habkost __u64 params[6]; 134278f064eSEduardo Habkost } hcall; 135278f064eSEduardo Habkost } u; 136278f064eSEduardo Habkost }; 137278f064eSEduardo Habkost 1387a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS_NONE 1 1397a52ce8aSCornelia Huck #define KVM_S390_SKEYS_MAX 1048576 1407a52ce8aSCornelia Huck 14151b24e34SJan Kiszka #define KVM_EXIT_UNKNOWN 0 14251b24e34SJan Kiszka #define KVM_EXIT_EXCEPTION 1 14351b24e34SJan Kiszka #define KVM_EXIT_IO 2 14451b24e34SJan Kiszka #define KVM_EXIT_HYPERCALL 3 14551b24e34SJan Kiszka #define KVM_EXIT_DEBUG 4 14651b24e34SJan Kiszka #define KVM_EXIT_HLT 5 14751b24e34SJan Kiszka #define KVM_EXIT_MMIO 6 14851b24e34SJan Kiszka #define KVM_EXIT_IRQ_WINDOW_OPEN 7 14951b24e34SJan Kiszka #define KVM_EXIT_SHUTDOWN 8 15051b24e34SJan Kiszka #define KVM_EXIT_FAIL_ENTRY 9 15151b24e34SJan Kiszka #define KVM_EXIT_INTR 10 15251b24e34SJan Kiszka #define KVM_EXIT_SET_TPR 11 15351b24e34SJan Kiszka #define KVM_EXIT_TPR_ACCESS 12 15451b24e34SJan Kiszka #define KVM_EXIT_S390_SIEIC 13 15551b24e34SJan Kiszka #define KVM_EXIT_S390_RESET 14 156a9fd1654SJens Freimann #define KVM_EXIT_DCR 15 /* deprecated */ 15751b24e34SJan Kiszka #define KVM_EXIT_NMI 16 15851b24e34SJan Kiszka #define KVM_EXIT_INTERNAL_ERROR 17 15951b24e34SJan Kiszka #define KVM_EXIT_OSI 18 1607c6da3deSAlexander Graf #define KVM_EXIT_PAPR_HCALL 19 1611529ae1bSAlexander Graf #define KVM_EXIT_S390_UCONTROL 20 162d4834ff9SAlexander Graf #define KVM_EXIT_WATCHDOG 21 163d3dccee1SAlexander Graf #define KVM_EXIT_S390_TSCH 22 164d3dccee1SAlexander Graf #define KVM_EXIT_EPR 23 165b061808dSAlexander Graf #define KVM_EXIT_SYSTEM_EVENT 24 1667a52ce8aSCornelia Huck #define KVM_EXIT_S390_STSI 25 1673a824b15SPaolo Bonzini #define KVM_EXIT_IOAPIC_EOI 26 168fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV 27 1692a886794SGreg Kurz #define KVM_EXIT_ARM_NISV 28 17053ba2eeeSMatthew Rosato #define KVM_EXIT_X86_RDMSR 29 17153ba2eeeSMatthew Rosato #define KVM_EXIT_X86_WRMSR 30 172b3c818a4SEric Farman #define KVM_EXIT_DIRTY_RING_FULL 31 173278f064eSEduardo Habkost #define KVM_EXIT_AP_RESET_HOLD 32 174278f064eSEduardo Habkost #define KVM_EXIT_X86_BUS_LOCK 33 175278f064eSEduardo Habkost #define KVM_EXIT_XEN 34 17643709a0cSPaolo Bonzini #define KVM_EXIT_RISCV_SBI 35 177d525f73fSChenyi Qiang #define KVM_EXIT_RISCV_CSR 36 178d525f73fSChenyi Qiang #define KVM_EXIT_NOTIFY 37 179efb91426SDaniel Henrique Barboza #define KVM_EXIT_LOONGARCH_IOCSR 38 1806a02465fSDaniel Henrique Barboza #define KVM_EXIT_MEMORY_FAULT 39 18151b24e34SJan Kiszka 18251b24e34SJan Kiszka /* For KVM_EXIT_INTERNAL_ERROR */ 183d4834ff9SAlexander Graf /* Emulate instruction failed. */ 18451b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_EMULATION 1 185d4834ff9SAlexander Graf /* Encounter unexpected simultaneous exceptions. */ 18651b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_SIMUL_EX 2 187d4834ff9SAlexander Graf /* Encounter unexpected vm-exit due to delivery event. */ 188d4834ff9SAlexander Graf #define KVM_INTERNAL_ERROR_DELIVERY_EV 3 189f363d039SEric Auger /* Encounter unexpected vm-exit reason */ 190f363d039SEric Auger #define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON 4 19151b24e34SJan Kiszka 192327d4b7fSBharata B Rao /* Flags that describe what fields in emulation_failure hold valid data. */ 193327d4b7fSBharata B Rao #define KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES (1ULL << 0) 194327d4b7fSBharata B Rao 19551b24e34SJan Kiszka /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ 19651b24e34SJan Kiszka struct kvm_run { 19751b24e34SJan Kiszka /* in */ 19851b24e34SJan Kiszka __u8 request_interrupt_window; 1993a5eb5b4SPaolo Bonzini __u8 immediate_exit; 2003a5eb5b4SPaolo Bonzini __u8 padding1[6]; 20151b24e34SJan Kiszka 20251b24e34SJan Kiszka /* out */ 20351b24e34SJan Kiszka __u32 exit_reason; 20451b24e34SJan Kiszka __u8 ready_for_interrupt_injection; 20551b24e34SJan Kiszka __u8 if_flag; 20624a31426SPaolo Bonzini __u16 flags; 20751b24e34SJan Kiszka 20851b24e34SJan Kiszka /* in (pre_kvm_run), out (post_kvm_run) */ 20951b24e34SJan Kiszka __u64 cr8; 21051b24e34SJan Kiszka __u64 apic_base; 21151b24e34SJan Kiszka 21251b24e34SJan Kiszka #ifdef __KVM_S390 21351b24e34SJan Kiszka /* the processor status word for s390 */ 21451b24e34SJan Kiszka __u64 psw_mask; /* psw upper half */ 21551b24e34SJan Kiszka __u64 psw_addr; /* psw lower half */ 21651b24e34SJan Kiszka #endif 21751b24e34SJan Kiszka union { 21851b24e34SJan Kiszka /* KVM_EXIT_UNKNOWN */ 21951b24e34SJan Kiszka struct { 22051b24e34SJan Kiszka __u64 hardware_exit_reason; 22151b24e34SJan Kiszka } hw; 22251b24e34SJan Kiszka /* KVM_EXIT_FAIL_ENTRY */ 22351b24e34SJan Kiszka struct { 22451b24e34SJan Kiszka __u64 hardware_entry_failure_reason; 225e6546342SJason Wang __u32 cpu; 22651b24e34SJan Kiszka } fail_entry; 22751b24e34SJan Kiszka /* KVM_EXIT_EXCEPTION */ 22851b24e34SJan Kiszka struct { 22951b24e34SJan Kiszka __u32 exception; 23051b24e34SJan Kiszka __u32 error_code; 23151b24e34SJan Kiszka } ex; 23251b24e34SJan Kiszka /* KVM_EXIT_IO */ 23351b24e34SJan Kiszka struct { 23451b24e34SJan Kiszka #define KVM_EXIT_IO_IN 0 23551b24e34SJan Kiszka #define KVM_EXIT_IO_OUT 1 23651b24e34SJan Kiszka __u8 direction; 23751b24e34SJan Kiszka __u8 size; /* bytes */ 23851b24e34SJan Kiszka __u16 port; 23951b24e34SJan Kiszka __u32 count; 24051b24e34SJan Kiszka __u64 data_offset; /* relative to kvm_run start */ 24151b24e34SJan Kiszka } io; 2423a824b15SPaolo Bonzini /* KVM_EXIT_DEBUG */ 24351b24e34SJan Kiszka struct { 24451b24e34SJan Kiszka struct kvm_debug_exit_arch arch; 24551b24e34SJan Kiszka } debug; 24651b24e34SJan Kiszka /* KVM_EXIT_MMIO */ 24751b24e34SJan Kiszka struct { 24851b24e34SJan Kiszka __u64 phys_addr; 24951b24e34SJan Kiszka __u8 data[8]; 25051b24e34SJan Kiszka __u32 len; 25151b24e34SJan Kiszka __u8 is_write; 25251b24e34SJan Kiszka } mmio; 253efb91426SDaniel Henrique Barboza /* KVM_EXIT_LOONGARCH_IOCSR */ 254efb91426SDaniel Henrique Barboza struct { 255efb91426SDaniel Henrique Barboza __u64 phys_addr; 256efb91426SDaniel Henrique Barboza __u8 data[8]; 257efb91426SDaniel Henrique Barboza __u32 len; 258efb91426SDaniel Henrique Barboza __u8 is_write; 259efb91426SDaniel Henrique Barboza } iocsr_io; 26051b24e34SJan Kiszka /* KVM_EXIT_HYPERCALL */ 26151b24e34SJan Kiszka struct { 26251b24e34SJan Kiszka __u64 nr; 26351b24e34SJan Kiszka __u64 args[6]; 26451b24e34SJan Kiszka __u64 ret; 265d0bf492fSCédric Le Goater 266d0bf492fSCédric Le Goater union { 26751b24e34SJan Kiszka __u32 longmode; 268d0bf492fSCédric Le Goater __u64 flags; 269d0bf492fSCédric Le Goater }; 27051b24e34SJan Kiszka } hypercall; 27151b24e34SJan Kiszka /* KVM_EXIT_TPR_ACCESS */ 27251b24e34SJan Kiszka struct { 27351b24e34SJan Kiszka __u64 rip; 27451b24e34SJan Kiszka __u32 is_write; 27551b24e34SJan Kiszka __u32 pad; 27651b24e34SJan Kiszka } tpr_access; 27751b24e34SJan Kiszka /* KVM_EXIT_S390_SIEIC */ 27851b24e34SJan Kiszka struct { 27951b24e34SJan Kiszka __u8 icptcode; 28051b24e34SJan Kiszka __u16 ipa; 28151b24e34SJan Kiszka __u32 ipb; 28251b24e34SJan Kiszka } s390_sieic; 28351b24e34SJan Kiszka /* KVM_EXIT_S390_RESET */ 28451b24e34SJan Kiszka __u64 s390_reset_flags; 2851529ae1bSAlexander Graf /* KVM_EXIT_S390_UCONTROL */ 2861529ae1bSAlexander Graf struct { 2871529ae1bSAlexander Graf __u64 trans_exc_code; 2881529ae1bSAlexander Graf __u32 pgm_code; 2891529ae1bSAlexander Graf } s390_ucontrol; 290a9fd1654SJens Freimann /* KVM_EXIT_DCR (deprecated) */ 29151b24e34SJan Kiszka struct { 29251b24e34SJan Kiszka __u32 dcrn; 29351b24e34SJan Kiszka __u32 data; 29451b24e34SJan Kiszka __u8 is_write; 29551b24e34SJan Kiszka } dcr; 2963a824b15SPaolo Bonzini /* KVM_EXIT_INTERNAL_ERROR */ 29751b24e34SJan Kiszka struct { 29851b24e34SJan Kiszka __u32 suberror; 29951b24e34SJan Kiszka /* Available with KVM_CAP_INTERNAL_ERROR_DATA: */ 30051b24e34SJan Kiszka __u32 ndata; 30151b24e34SJan Kiszka __u64 data[16]; 30251b24e34SJan Kiszka } internal; 303327d4b7fSBharata B Rao /* 304327d4b7fSBharata B Rao * KVM_INTERNAL_ERROR_EMULATION 305327d4b7fSBharata B Rao * 306327d4b7fSBharata B Rao * "struct emulation_failure" is an overlay of "struct internal" 307327d4b7fSBharata B Rao * that is used for the KVM_INTERNAL_ERROR_EMULATION sub-type of 308327d4b7fSBharata B Rao * KVM_EXIT_INTERNAL_ERROR. Note, unlike other internal error 309327d4b7fSBharata B Rao * sub-types, this struct is ABI! It also needs to be backwards 310327d4b7fSBharata B Rao * compatible with "struct internal". Take special care that 311327d4b7fSBharata B Rao * "ndata" is correct, that new fields are enumerated in "flags", 312327d4b7fSBharata B Rao * and that each flag enumerates fields that are 64-bit aligned 313327d4b7fSBharata B Rao * and sized (so that ndata+internal.data[] is valid/accurate). 31443709a0cSPaolo Bonzini * 31543709a0cSPaolo Bonzini * Space beyond the defined fields may be used to store arbitrary 31643709a0cSPaolo Bonzini * debug information relating to the emulation failure. It is 31743709a0cSPaolo Bonzini * accounted for in "ndata" but the format is unspecified and is 31843709a0cSPaolo Bonzini * not represented in "flags". Any such information is *not* ABI! 319327d4b7fSBharata B Rao */ 320327d4b7fSBharata B Rao struct { 321327d4b7fSBharata B Rao __u32 suberror; 322327d4b7fSBharata B Rao __u32 ndata; 323327d4b7fSBharata B Rao __u64 flags; 32443709a0cSPaolo Bonzini union { 32543709a0cSPaolo Bonzini struct { 326327d4b7fSBharata B Rao __u8 insn_size; 327327d4b7fSBharata B Rao __u8 insn_bytes[15]; 32843709a0cSPaolo Bonzini }; 32943709a0cSPaolo Bonzini }; 33043709a0cSPaolo Bonzini /* Arbitrary debug data may follow. */ 331327d4b7fSBharata B Rao } emulation_failure; 33251b24e34SJan Kiszka /* KVM_EXIT_OSI */ 33351b24e34SJan Kiszka struct { 33451b24e34SJan Kiszka __u64 gprs[32]; 33551b24e34SJan Kiszka } osi; 3363a824b15SPaolo Bonzini /* KVM_EXIT_PAPR_HCALL */ 3377c6da3deSAlexander Graf struct { 3387c6da3deSAlexander Graf __u64 nr; 3397c6da3deSAlexander Graf __u64 ret; 3407c6da3deSAlexander Graf __u64 args[9]; 3417c6da3deSAlexander Graf } papr_hcall; 342d3dccee1SAlexander Graf /* KVM_EXIT_S390_TSCH */ 343d3dccee1SAlexander Graf struct { 344d3dccee1SAlexander Graf __u16 subchannel_id; 345d3dccee1SAlexander Graf __u16 subchannel_nr; 346d3dccee1SAlexander Graf __u32 io_int_parm; 347d3dccee1SAlexander Graf __u32 io_int_word; 348d3dccee1SAlexander Graf __u32 ipb; 349d3dccee1SAlexander Graf __u8 dequeued; 350d3dccee1SAlexander Graf } s390_tsch; 351d3dccee1SAlexander Graf /* KVM_EXIT_EPR */ 352d3dccee1SAlexander Graf struct { 353d3dccee1SAlexander Graf __u32 epr; 354d3dccee1SAlexander Graf } epr; 355b061808dSAlexander Graf /* KVM_EXIT_SYSTEM_EVENT */ 356b061808dSAlexander Graf struct { 357b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_SHUTDOWN 1 358b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_RESET 2 359120758fbSPaolo Bonzini #define KVM_SYSTEM_EVENT_CRASH 3 360d525f73fSChenyi Qiang #define KVM_SYSTEM_EVENT_WAKEUP 4 361d525f73fSChenyi Qiang #define KVM_SYSTEM_EVENT_SUSPEND 5 362d525f73fSChenyi Qiang #define KVM_SYSTEM_EVENT_SEV_TERM 6 363b061808dSAlexander Graf __u32 type; 364e4082063SAlex Williamson __u32 ndata; 365e4082063SAlex Williamson union { 366b061808dSAlexander Graf __u64 flags; 367e4082063SAlex Williamson __u64 data[16]; 368e4082063SAlex Williamson }; 369b061808dSAlexander Graf } system_event; 3707a52ce8aSCornelia Huck /* KVM_EXIT_S390_STSI */ 3717a52ce8aSCornelia Huck struct { 3727a52ce8aSCornelia Huck __u64 addr; 3737a52ce8aSCornelia Huck __u8 ar; 3747a52ce8aSCornelia Huck __u8 reserved; 3757a52ce8aSCornelia Huck __u8 fc; 3767a52ce8aSCornelia Huck __u8 sel1; 3777a52ce8aSCornelia Huck __u16 sel2; 3787a52ce8aSCornelia Huck } s390_stsi; 3793a824b15SPaolo Bonzini /* KVM_EXIT_IOAPIC_EOI */ 3803a824b15SPaolo Bonzini struct { 3813a824b15SPaolo Bonzini __u8 vector; 3823a824b15SPaolo Bonzini } eoi; 383fff02bc0SPaolo Bonzini /* KVM_EXIT_HYPERV */ 384fff02bc0SPaolo Bonzini struct kvm_hyperv_exit hyperv; 3852a886794SGreg Kurz /* KVM_EXIT_ARM_NISV */ 3862a886794SGreg Kurz struct { 3872a886794SGreg Kurz __u64 esr_iss; 3882a886794SGreg Kurz __u64 fault_ipa; 3892a886794SGreg Kurz } arm_nisv; 39053ba2eeeSMatthew Rosato /* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */ 39153ba2eeeSMatthew Rosato struct { 39253ba2eeeSMatthew Rosato __u8 error; /* user -> kernel */ 39353ba2eeeSMatthew Rosato __u8 pad[7]; 39453ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_INVAL (1 << 0) 39553ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_UNKNOWN (1 << 1) 39653ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_FILTER (1 << 2) 39793d7620cSAvihai Horon #define KVM_MSR_EXIT_REASON_VALID_MASK (KVM_MSR_EXIT_REASON_INVAL | \ 39893d7620cSAvihai Horon KVM_MSR_EXIT_REASON_UNKNOWN | \ 39993d7620cSAvihai Horon KVM_MSR_EXIT_REASON_FILTER) 40053ba2eeeSMatthew Rosato __u32 reason; /* kernel -> user */ 40153ba2eeeSMatthew Rosato __u32 index; /* kernel -> user */ 40253ba2eeeSMatthew Rosato __u64 data; /* kernel <-> user */ 40353ba2eeeSMatthew Rosato } msr; 404278f064eSEduardo Habkost /* KVM_EXIT_XEN */ 405278f064eSEduardo Habkost struct kvm_xen_exit xen; 40643709a0cSPaolo Bonzini /* KVM_EXIT_RISCV_SBI */ 40743709a0cSPaolo Bonzini struct { 40843709a0cSPaolo Bonzini unsigned long extension_id; 40943709a0cSPaolo Bonzini unsigned long function_id; 41043709a0cSPaolo Bonzini unsigned long args[6]; 41143709a0cSPaolo Bonzini unsigned long ret[2]; 41243709a0cSPaolo Bonzini } riscv_sbi; 413d525f73fSChenyi Qiang /* KVM_EXIT_RISCV_CSR */ 414d525f73fSChenyi Qiang struct { 415d525f73fSChenyi Qiang unsigned long csr_num; 416d525f73fSChenyi Qiang unsigned long new_value; 417d525f73fSChenyi Qiang unsigned long write_mask; 418d525f73fSChenyi Qiang unsigned long ret_value; 419d525f73fSChenyi Qiang } riscv_csr; 420d525f73fSChenyi Qiang /* KVM_EXIT_NOTIFY */ 421d525f73fSChenyi Qiang struct { 422d525f73fSChenyi Qiang #define KVM_NOTIFY_CONTEXT_INVALID (1 << 0) 423d525f73fSChenyi Qiang __u32 flags; 424d525f73fSChenyi Qiang } notify; 4256a02465fSDaniel Henrique Barboza /* KVM_EXIT_MEMORY_FAULT */ 4266a02465fSDaniel Henrique Barboza struct { 4276a02465fSDaniel Henrique Barboza #define KVM_MEMORY_EXIT_FLAG_PRIVATE (1ULL << 3) 4286a02465fSDaniel Henrique Barboza __u64 flags; 4296a02465fSDaniel Henrique Barboza __u64 gpa; 4306a02465fSDaniel Henrique Barboza __u64 size; 4316a02465fSDaniel Henrique Barboza } memory_fault; 43251b24e34SJan Kiszka /* Fix the size of the union. */ 43351b24e34SJan Kiszka char padding[256]; 43451b24e34SJan Kiszka }; 4351529ae1bSAlexander Graf 43665a6d8ddSPeter Maydell /* 2048 is the size of the char array used to bound/pad the size 43765a6d8ddSPeter Maydell * of the union that holds sync regs. 43865a6d8ddSPeter Maydell */ 43965a6d8ddSPeter Maydell #define SYNC_REGS_SIZE_BYTES 2048 4401529ae1bSAlexander Graf /* 4411529ae1bSAlexander Graf * shared registers between kvm and userspace. 4421529ae1bSAlexander Graf * kvm_valid_regs specifies the register classes set by the host 4431529ae1bSAlexander Graf * kvm_dirty_regs specified the register classes dirtied by userspace 4441529ae1bSAlexander Graf * struct kvm_sync_regs is architecture specific, as well as the 4451529ae1bSAlexander Graf * bits for kvm_valid_regs and kvm_dirty_regs 4461529ae1bSAlexander Graf */ 4471529ae1bSAlexander Graf __u64 kvm_valid_regs; 4481529ae1bSAlexander Graf __u64 kvm_dirty_regs; 4491529ae1bSAlexander Graf union { 4501529ae1bSAlexander Graf struct kvm_sync_regs regs; 45165a6d8ddSPeter Maydell char padding[SYNC_REGS_SIZE_BYTES]; 4521529ae1bSAlexander Graf } s; 45351b24e34SJan Kiszka }; 45451b24e34SJan Kiszka 45551b24e34SJan Kiszka /* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */ 45651b24e34SJan Kiszka 45751b24e34SJan Kiszka struct kvm_coalesced_mmio_zone { 45851b24e34SJan Kiszka __u64 addr; 45951b24e34SJan Kiszka __u32 size; 460966f2ec3SPaolo Bonzini union { 46151b24e34SJan Kiszka __u32 pad; 462966f2ec3SPaolo Bonzini __u32 pio; 463966f2ec3SPaolo Bonzini }; 46451b24e34SJan Kiszka }; 46551b24e34SJan Kiszka 46651b24e34SJan Kiszka struct kvm_coalesced_mmio { 46751b24e34SJan Kiszka __u64 phys_addr; 46851b24e34SJan Kiszka __u32 len; 469966f2ec3SPaolo Bonzini union { 47051b24e34SJan Kiszka __u32 pad; 471966f2ec3SPaolo Bonzini __u32 pio; 472966f2ec3SPaolo Bonzini }; 47351b24e34SJan Kiszka __u8 data[8]; 47451b24e34SJan Kiszka }; 47551b24e34SJan Kiszka 47651b24e34SJan Kiszka struct kvm_coalesced_mmio_ring { 47751b24e34SJan Kiszka __u32 first, last; 478d525f73fSChenyi Qiang struct kvm_coalesced_mmio coalesced_mmio[]; 47951b24e34SJan Kiszka }; 48051b24e34SJan Kiszka 48151b24e34SJan Kiszka #define KVM_COALESCED_MMIO_MAX \ 48251b24e34SJan Kiszka ((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \ 48351b24e34SJan Kiszka sizeof(struct kvm_coalesced_mmio)) 48451b24e34SJan Kiszka 48551b24e34SJan Kiszka /* for KVM_TRANSLATE */ 48651b24e34SJan Kiszka struct kvm_translation { 48751b24e34SJan Kiszka /* in */ 48851b24e34SJan Kiszka __u64 linear_address; 48951b24e34SJan Kiszka 49051b24e34SJan Kiszka /* out */ 49151b24e34SJan Kiszka __u64 physical_address; 49251b24e34SJan Kiszka __u8 valid; 49351b24e34SJan Kiszka __u8 writeable; 49451b24e34SJan Kiszka __u8 usermode; 49551b24e34SJan Kiszka __u8 pad[5]; 49651b24e34SJan Kiszka }; 49751b24e34SJan Kiszka 49851b24e34SJan Kiszka /* for KVM_INTERRUPT */ 49951b24e34SJan Kiszka struct kvm_interrupt { 50051b24e34SJan Kiszka /* in */ 50151b24e34SJan Kiszka __u32 irq; 50251b24e34SJan Kiszka }; 50351b24e34SJan Kiszka 50451b24e34SJan Kiszka /* for KVM_GET_DIRTY_LOG */ 50551b24e34SJan Kiszka struct kvm_dirty_log { 50651b24e34SJan Kiszka __u32 slot; 50751b24e34SJan Kiszka __u32 padding1; 50851b24e34SJan Kiszka union { 50951b24e34SJan Kiszka void *dirty_bitmap; /* one bit per page */ 51051b24e34SJan Kiszka __u64 padding2; 51151b24e34SJan Kiszka }; 51251b24e34SJan Kiszka }; 51351b24e34SJan Kiszka 514da054c64SPaolo Bonzini /* for KVM_CLEAR_DIRTY_LOG */ 515da054c64SPaolo Bonzini struct kvm_clear_dirty_log { 516da054c64SPaolo Bonzini __u32 slot; 517da054c64SPaolo Bonzini __u32 num_pages; 518da054c64SPaolo Bonzini __u64 first_page; 519da054c64SPaolo Bonzini union { 520da054c64SPaolo Bonzini void *dirty_bitmap; /* one bit per page */ 521da054c64SPaolo Bonzini __u64 padding2; 522da054c64SPaolo Bonzini }; 523da054c64SPaolo Bonzini }; 524da054c64SPaolo Bonzini 52551b24e34SJan Kiszka /* for KVM_SET_SIGNAL_MASK */ 52651b24e34SJan Kiszka struct kvm_signal_mask { 52751b24e34SJan Kiszka __u32 len; 528d525f73fSChenyi Qiang __u8 sigset[]; 52951b24e34SJan Kiszka }; 53051b24e34SJan Kiszka 53151b24e34SJan Kiszka /* for KVM_TPR_ACCESS_REPORTING */ 53251b24e34SJan Kiszka struct kvm_tpr_access_ctl { 53351b24e34SJan Kiszka __u32 enabled; 53451b24e34SJan Kiszka __u32 flags; 53551b24e34SJan Kiszka __u32 reserved[8]; 53651b24e34SJan Kiszka }; 53751b24e34SJan Kiszka 53851b24e34SJan Kiszka /* for KVM_SET_VAPIC_ADDR */ 53951b24e34SJan Kiszka struct kvm_vapic_addr { 54051b24e34SJan Kiszka __u64 vapic_addr; 54151b24e34SJan Kiszka }; 54251b24e34SJan Kiszka 543a9fd1654SJens Freimann /* for KVM_SET_MP_STATE */ 54451b24e34SJan Kiszka 545a9fd1654SJens Freimann /* not all states are valid on all architectures */ 54651b24e34SJan Kiszka #define KVM_MP_STATE_RUNNABLE 0 54751b24e34SJan Kiszka #define KVM_MP_STATE_UNINITIALIZED 1 54851b24e34SJan Kiszka #define KVM_MP_STATE_INIT_RECEIVED 2 54951b24e34SJan Kiszka #define KVM_MP_STATE_HALTED 3 55051b24e34SJan Kiszka #define KVM_MP_STATE_SIPI_RECEIVED 4 551a9fd1654SJens Freimann #define KVM_MP_STATE_STOPPED 5 552a9fd1654SJens Freimann #define KVM_MP_STATE_CHECK_STOP 6 553a9fd1654SJens Freimann #define KVM_MP_STATE_OPERATING 7 554a9fd1654SJens Freimann #define KVM_MP_STATE_LOAD 8 555278f064eSEduardo Habkost #define KVM_MP_STATE_AP_RESET_HOLD 9 556d525f73fSChenyi Qiang #define KVM_MP_STATE_SUSPENDED 10 55751b24e34SJan Kiszka 55851b24e34SJan Kiszka struct kvm_mp_state { 55951b24e34SJan Kiszka __u32 mp_state; 56051b24e34SJan Kiszka }; 56151b24e34SJan Kiszka 56251b24e34SJan Kiszka /* for KVM_SET_GUEST_DEBUG */ 56351b24e34SJan Kiszka 56451b24e34SJan Kiszka #define KVM_GUESTDBG_ENABLE 0x00000001 56551b24e34SJan Kiszka #define KVM_GUESTDBG_SINGLESTEP 0x00000002 56651b24e34SJan Kiszka 56751b24e34SJan Kiszka struct kvm_guest_debug { 56851b24e34SJan Kiszka __u32 control; 56951b24e34SJan Kiszka __u32 pad; 57051b24e34SJan Kiszka struct kvm_guest_debug_arch arch; 57151b24e34SJan Kiszka }; 57251b24e34SJan Kiszka 57351b24e34SJan Kiszka enum { 57451b24e34SJan Kiszka kvm_ioeventfd_flag_nr_datamatch, 57551b24e34SJan Kiszka kvm_ioeventfd_flag_nr_pio, 57651b24e34SJan Kiszka kvm_ioeventfd_flag_nr_deassign, 577cae7f586SAlexander Graf kvm_ioeventfd_flag_nr_virtio_ccw_notify, 57876eb98d5SJens Freimann kvm_ioeventfd_flag_nr_fast_mmio, 57951b24e34SJan Kiszka kvm_ioeventfd_flag_nr_max, 58051b24e34SJan Kiszka }; 58151b24e34SJan Kiszka 58251b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch) 58351b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio) 58451b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign) 585cae7f586SAlexander Graf #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \ 586cae7f586SAlexander Graf (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify) 58751b24e34SJan Kiszka 58851b24e34SJan Kiszka #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1) 58951b24e34SJan Kiszka 59051b24e34SJan Kiszka struct kvm_ioeventfd { 59151b24e34SJan Kiszka __u64 datamatch; 59251b24e34SJan Kiszka __u64 addr; /* legal pio/mmio address */ 59376eb98d5SJens Freimann __u32 len; /* 1, 2, 4, or 8 bytes; or 0 to ignore length */ 59451b24e34SJan Kiszka __s32 fd; 59551b24e34SJan Kiszka __u32 flags; 59651b24e34SJan Kiszka __u8 pad[36]; 59751b24e34SJan Kiszka }; 59851b24e34SJan Kiszka 59965a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) 60077d361b1SEric Auger #define KVM_X86_DISABLE_EXITS_HLT (1 << 1) 60165a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) 602d38d201fSWanpeng Li #define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3) 60365a6d8ddSPeter Maydell #define KVM_X86_DISABLE_VALID_EXITS (KVM_X86_DISABLE_EXITS_MWAIT | \ 60477d361b1SEric Auger KVM_X86_DISABLE_EXITS_HLT | \ 605d38d201fSWanpeng Li KVM_X86_DISABLE_EXITS_PAUSE | \ 606d38d201fSWanpeng Li KVM_X86_DISABLE_EXITS_CSTATE) 60765a6d8ddSPeter Maydell 60851b24e34SJan Kiszka /* for KVM_ENABLE_CAP */ 60951b24e34SJan Kiszka struct kvm_enable_cap { 61051b24e34SJan Kiszka /* in */ 61151b24e34SJan Kiszka __u32 cap; 61251b24e34SJan Kiszka __u32 flags; 61351b24e34SJan Kiszka __u64 args[4]; 61451b24e34SJan Kiszka __u8 pad[64]; 61551b24e34SJan Kiszka }; 61651b24e34SJan Kiszka 61751b24e34SJan Kiszka #define KVMIO 0xAE 61851b24e34SJan Kiszka 6191529ae1bSAlexander Graf /* machine type bits, to be used as argument to KVM_CREATE_VM */ 6201529ae1bSAlexander Graf #define KVM_VM_S390_UCONTROL 1 6211529ae1bSAlexander Graf 622bf63839fSAlex Williamson /* on ppc, 0 indicate default, 1 should force HV and 2 PR */ 623bf63839fSAlex Williamson #define KVM_VM_PPC_HV 1 624bf63839fSAlex Williamson #define KVM_VM_PPC_PR 2 625bf63839fSAlex Williamson 62694c7fefcSAndrew Jones /* on MIPS, 0 indicates auto, 1 forces VZ ASE, 2 forces trap & emulate */ 62794c7fefcSAndrew Jones #define KVM_VM_MIPS_AUTO 0 62874c98e20SCornelia Huck #define KVM_VM_MIPS_VZ 1 62994c7fefcSAndrew Jones #define KVM_VM_MIPS_TE 2 63074c98e20SCornelia Huck 6311529ae1bSAlexander Graf #define KVM_S390_SIE_PAGE_OFFSET 1 6321529ae1bSAlexander Graf 63351b24e34SJan Kiszka /* 634da054c64SPaolo Bonzini * On arm64, machine type can be used to request the physical 635da054c64SPaolo Bonzini * address size for the VM. Bits[7-0] are reserved for the guest 636da054c64SPaolo Bonzini * PA size shift (i.e, log2(PA_Size)). For backward compatibility, 637da054c64SPaolo Bonzini * value 0 implies the default IPA size, 40bits. 638da054c64SPaolo Bonzini */ 639da054c64SPaolo Bonzini #define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL 640da054c64SPaolo Bonzini #define KVM_VM_TYPE_ARM_IPA_SIZE(x) \ 641da054c64SPaolo Bonzini ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK) 642da054c64SPaolo Bonzini /* 64351b24e34SJan Kiszka * ioctls for /dev/kvm fds: 64451b24e34SJan Kiszka */ 64551b24e34SJan Kiszka #define KVM_GET_API_VERSION _IO(KVMIO, 0x00) 64651b24e34SJan Kiszka #define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ 64751b24e34SJan Kiszka #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) 64851b24e34SJan Kiszka 64951b24e34SJan Kiszka #define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06) 65051b24e34SJan Kiszka /* 65151b24e34SJan Kiszka * Check if a kvm extension is available. Argument is extension number, 65251b24e34SJan Kiszka * return is 1 (yes) or 0 (no, sorry). 65351b24e34SJan Kiszka */ 65451b24e34SJan Kiszka #define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03) 65551b24e34SJan Kiszka /* 65651b24e34SJan Kiszka * Get size for mmap(vcpu_fd) 65751b24e34SJan Kiszka */ 65851b24e34SJan Kiszka #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ 65951b24e34SJan Kiszka #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) 660bf63839fSAlex Williamson #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) 6619f2d175dSPaolo Bonzini #define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_msr_list) 66251b24e34SJan Kiszka 66351b24e34SJan Kiszka /* 66451b24e34SJan Kiszka * Extension capability list. 66551b24e34SJan Kiszka */ 66651b24e34SJan Kiszka #define KVM_CAP_IRQCHIP 0 66751b24e34SJan Kiszka #define KVM_CAP_HLT 1 66851b24e34SJan Kiszka #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2 66951b24e34SJan Kiszka #define KVM_CAP_USER_MEMORY 3 67051b24e34SJan Kiszka #define KVM_CAP_SET_TSS_ADDR 4 67151b24e34SJan Kiszka #define KVM_CAP_VAPIC 6 67251b24e34SJan Kiszka #define KVM_CAP_EXT_CPUID 7 67351b24e34SJan Kiszka #define KVM_CAP_CLOCKSOURCE 8 6747c6da3deSAlexander Graf #define KVM_CAP_NR_VCPUS 9 /* returns recommended max vcpus per vm */ 67551b24e34SJan Kiszka #define KVM_CAP_NR_MEMSLOTS 10 /* returns max memory slots per vm */ 67651b24e34SJan Kiszka #define KVM_CAP_PIT 11 67751b24e34SJan Kiszka #define KVM_CAP_NOP_IO_DELAY 12 67851b24e34SJan Kiszka #define KVM_CAP_PV_MMU 13 67951b24e34SJan Kiszka #define KVM_CAP_MP_STATE 14 68051b24e34SJan Kiszka #define KVM_CAP_COALESCED_MMIO 15 68151b24e34SJan Kiszka #define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ 68251b24e34SJan Kiszka #define KVM_CAP_IOMMU 18 68351b24e34SJan Kiszka /* Bug in KVM_SET_USER_MEMORY_REGION fixed: */ 68451b24e34SJan Kiszka #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21 68551b24e34SJan Kiszka #define KVM_CAP_USER_NMI 22 68651b24e34SJan Kiszka #define KVM_CAP_SET_GUEST_DEBUG 23 68751b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 68851b24e34SJan Kiszka #define KVM_CAP_REINJECT_CONTROL 24 68951b24e34SJan Kiszka #endif 69051b24e34SJan Kiszka #define KVM_CAP_IRQ_ROUTING 25 69151b24e34SJan Kiszka #define KVM_CAP_IRQ_INJECT_STATUS 26 69251b24e34SJan Kiszka #define KVM_CAP_ASSIGN_DEV_IRQ 29 69351b24e34SJan Kiszka /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */ 69451b24e34SJan Kiszka #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30 69551b24e34SJan Kiszka #ifdef __KVM_HAVE_MCE 69651b24e34SJan Kiszka #define KVM_CAP_MCE 31 69751b24e34SJan Kiszka #endif 69851b24e34SJan Kiszka #define KVM_CAP_IRQFD 32 69951b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT 70051b24e34SJan Kiszka #define KVM_CAP_PIT2 33 70151b24e34SJan Kiszka #endif 70251b24e34SJan Kiszka #define KVM_CAP_SET_BOOT_CPU_ID 34 70351b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT_STATE2 70451b24e34SJan Kiszka #define KVM_CAP_PIT_STATE2 35 70551b24e34SJan Kiszka #endif 70651b24e34SJan Kiszka #define KVM_CAP_IOEVENTFD 36 70751b24e34SJan Kiszka #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 70851b24e34SJan Kiszka #ifdef __KVM_HAVE_XEN_HVM 70951b24e34SJan Kiszka #define KVM_CAP_XEN_HVM 38 71051b24e34SJan Kiszka #endif 71151b24e34SJan Kiszka #define KVM_CAP_ADJUST_CLOCK 39 71251b24e34SJan Kiszka #define KVM_CAP_INTERNAL_ERROR_DATA 40 71351b24e34SJan Kiszka #ifdef __KVM_HAVE_VCPU_EVENTS 71451b24e34SJan Kiszka #define KVM_CAP_VCPU_EVENTS 41 71551b24e34SJan Kiszka #endif 71651b24e34SJan Kiszka #define KVM_CAP_S390_PSW 42 71751b24e34SJan Kiszka #define KVM_CAP_PPC_SEGSTATE 43 71851b24e34SJan Kiszka #define KVM_CAP_HYPERV 44 71951b24e34SJan Kiszka #define KVM_CAP_HYPERV_VAPIC 45 72051b24e34SJan Kiszka #define KVM_CAP_HYPERV_SPIN 46 72151b24e34SJan Kiszka #define KVM_CAP_PCI_SEGMENT 47 72251b24e34SJan Kiszka #define KVM_CAP_PPC_PAIRED_SINGLES 48 72351b24e34SJan Kiszka #define KVM_CAP_INTR_SHADOW 49 72451b24e34SJan Kiszka #ifdef __KVM_HAVE_DEBUGREGS 72551b24e34SJan Kiszka #define KVM_CAP_DEBUGREGS 50 72651b24e34SJan Kiszka #endif 72751b24e34SJan Kiszka #define KVM_CAP_X86_ROBUST_SINGLESTEP 51 72851b24e34SJan Kiszka #define KVM_CAP_PPC_OSI 52 72951b24e34SJan Kiszka #define KVM_CAP_PPC_UNSET_IRQ 53 73051b24e34SJan Kiszka #define KVM_CAP_ENABLE_CAP 54 73151b24e34SJan Kiszka #ifdef __KVM_HAVE_XSAVE 73251b24e34SJan Kiszka #define KVM_CAP_XSAVE 55 73351b24e34SJan Kiszka #endif 73451b24e34SJan Kiszka #ifdef __KVM_HAVE_XCRS 73551b24e34SJan Kiszka #define KVM_CAP_XCRS 56 73651b24e34SJan Kiszka #endif 73751b24e34SJan Kiszka #define KVM_CAP_PPC_GET_PVINFO 57 73851b24e34SJan Kiszka #define KVM_CAP_PPC_IRQ_LEVEL 58 73951b24e34SJan Kiszka #define KVM_CAP_ASYNC_PF 59 74051b24e34SJan Kiszka #define KVM_CAP_TSC_CONTROL 60 74151b24e34SJan Kiszka #define KVM_CAP_GET_TSC_KHZ 61 74251b24e34SJan Kiszka #define KVM_CAP_PPC_BOOKE_SREGS 62 7437c6da3deSAlexander Graf #define KVM_CAP_SPAPR_TCE 63 7447c6da3deSAlexander Graf #define KVM_CAP_PPC_SMT 64 7457c6da3deSAlexander Graf #define KVM_CAP_PPC_RMA 65 7467c6da3deSAlexander Graf #define KVM_CAP_MAX_VCPUS 66 /* returns max vcpus per vm */ 7479d4e4f8cSAlexander Graf #define KVM_CAP_PPC_HIOR 67 7487c6da3deSAlexander Graf #define KVM_CAP_PPC_PAPR 68 749a54fc080SAlexander Graf #define KVM_CAP_SW_TLB 69 7509d4e4f8cSAlexander Graf #define KVM_CAP_ONE_REG 70 7511529ae1bSAlexander Graf #define KVM_CAP_S390_GMAP 71 7521529ae1bSAlexander Graf #define KVM_CAP_TSC_DEADLINE_TIMER 72 7531529ae1bSAlexander Graf #define KVM_CAP_S390_UCONTROL 73 7541529ae1bSAlexander Graf #define KVM_CAP_SYNC_REGS 74 7559ab2195dSMarcelo Tosatti #define KVM_CAP_PCI_2_3 75 7569ab2195dSMarcelo Tosatti #define KVM_CAP_KVMCLOCK_CTRL 76 75780a3eb10SJan Kiszka #define KVM_CAP_SIGNAL_MSI 77 75880a3eb10SJan Kiszka #define KVM_CAP_PPC_GET_SMMU_INFO 78 7592a60dba4SAlexander Graf #define KVM_CAP_S390_COW 79 760651682dcSMichael S. Tsirkin #define KVM_CAP_PPC_ALLOC_HTAB 80 761716b8e4dSAlex Williamson #define KVM_CAP_READONLY_MEM 81 762716b8e4dSAlex Williamson #define KVM_CAP_IRQFD_RESAMPLE 82 763d4834ff9SAlexander Graf #define KVM_CAP_PPC_BOOKE_WATCHDOG 83 764d4834ff9SAlexander Graf #define KVM_CAP_PPC_HTAB_FD 84 765d3dccee1SAlexander Graf #define KVM_CAP_S390_CSS_SUPPORT 85 766d3dccee1SAlexander Graf #define KVM_CAP_PPC_EPR 86 767eadd0e44SPeter Maydell #define KVM_CAP_ARM_PSCI 87 768eadd0e44SPeter Maydell #define KVM_CAP_ARM_SET_DEVICE_ADDR 88 769e098b453SAlexey Kardashevskiy #define KVM_CAP_DEVICE_CTRL 89 770e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_MPIC 90 771e098b453SAlexey Kardashevskiy #define KVM_CAP_PPC_RTAS 91 772e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_XICS 92 773c5daeae1SAlexey Kardashevskiy #define KVM_CAP_ARM_EL1_32BIT 93 7744f265607SAndrew Jones #define KVM_CAP_SPAPR_MULTITCE 94 775bf63839fSAlex Williamson #define KVM_CAP_EXT_EMUL_CPUID 95 77648a5f3bcSVadim Rozenfeld #define KVM_CAP_HYPERV_TIME 96 7779ffd2685SCornelia Huck #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97 7789ffd2685SCornelia Huck #define KVM_CAP_ENABLE_CAP_VM 98 7799ffd2685SCornelia Huck #define KVM_CAP_S390_IRQCHIP 99 78076eb98d5SJens Freimann #define KVM_CAP_IOEVENTFD_NO_LENGTH 100 78176eb98d5SJens Freimann #define KVM_CAP_VM_ATTRIBUTES 101 782b061808dSAlexander Graf #define KVM_CAP_ARM_PSCI_0_2 102 783b061808dSAlexander Graf #define KVM_CAP_PPC_FIXUP_HCALL 103 784a9fd1654SJens Freimann #define KVM_CAP_PPC_ENABLE_HCALL 104 785a9fd1654SJens Freimann #define KVM_CAP_CHECK_EXTENSION_VM 105 78651628b18SChristian Borntraeger #define KVM_CAP_S390_USER_SIGP 106 7877a52ce8aSCornelia Huck #define KVM_CAP_S390_VECTOR_REGISTERS 107 7887a52ce8aSCornelia Huck #define KVM_CAP_S390_MEM_OP 108 7897a52ce8aSCornelia Huck #define KVM_CAP_S390_USER_STSI 109 7907a52ce8aSCornelia Huck #define KVM_CAP_S390_SKEYS 110 7917a52ce8aSCornelia Huck #define KVM_CAP_MIPS_FPU 111 7927a52ce8aSCornelia Huck #define KVM_CAP_MIPS_MSA 112 7937a52ce8aSCornelia Huck #define KVM_CAP_S390_INJECT_IRQ 113 7947a52ce8aSCornelia Huck #define KVM_CAP_S390_IRQ_STATE 114 7957a52ce8aSCornelia Huck #define KVM_CAP_PPC_HWRNG 115 79624a31426SPaolo Bonzini #define KVM_CAP_DISABLE_QUIRKS 116 79724a31426SPaolo Bonzini #define KVM_CAP_X86_SMM 117 79824a31426SPaolo Bonzini #define KVM_CAP_MULTI_ADDRESS_SPACE 118 7993a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_BPS 119 8003a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_WPS 120 8013a824b15SPaolo Bonzini #define KVM_CAP_SPLIT_IRQCHIP 121 8023a824b15SPaolo Bonzini #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122 803fff02bc0SPaolo Bonzini #define KVM_CAP_HYPERV_SYNIC 123 80466fb2d54SCornelia Huck #define KVM_CAP_S390_RI 124 805b89485a5SPaolo Bonzini #define KVM_CAP_SPAPR_TCE_64 125 806b89485a5SPaolo Bonzini #define KVM_CAP_ARM_PMU_V3 126 807b89485a5SPaolo Bonzini #define KVM_CAP_VCPU_ATTRIBUTES 127 808ff804f15SCornelia Huck #define KVM_CAP_MAX_VCPU_ID 128 809dbdfea92SCornelia Huck #define KVM_CAP_X2APIC_API 129 810dbdfea92SCornelia Huck #define KVM_CAP_S390_USER_INSTR0 130 811dbdfea92SCornelia Huck #define KVM_CAP_MSI_DEVID 131 812dbdfea92SCornelia Huck #define KVM_CAP_PPC_HTM 132 8133a5eb5b4SPaolo Bonzini #define KVM_CAP_SPAPR_RESIZE_HPT 133 8143a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_RADIX 134 8153a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_HASH_V3 135 8163a5eb5b4SPaolo Bonzini #define KVM_CAP_IMMEDIATE_EXIT 136 81774c98e20SCornelia Huck #define KVM_CAP_MIPS_VZ 137 81874c98e20SCornelia Huck #define KVM_CAP_MIPS_TE 138 81974c98e20SCornelia Huck #define KVM_CAP_MIPS_64BIT 139 82074c98e20SCornelia Huck #define KVM_CAP_S390_GS 140 82174c98e20SCornelia Huck #define KVM_CAP_S390_AIS 141 82274c98e20SCornelia Huck #define KVM_CAP_SPAPR_TCE_VFIO 142 82365a6d8ddSPeter Maydell #define KVM_CAP_X86_DISABLE_EXITS 143 82474c98e20SCornelia Huck #define KVM_CAP_ARM_USER_IRQ 144 8253272f0e2SChristian Borntraeger #define KVM_CAP_S390_CMMA_MIGRATION 145 8263272f0e2SChristian Borntraeger #define KVM_CAP_PPC_FWNMI 146 8273272f0e2SChristian Borntraeger #define KVM_CAP_PPC_SMT_POSSIBLE 147 828ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_SYNIC2 148 829ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_VP_INDEX 149 830dd873966SEric Auger #define KVM_CAP_S390_AIS_MIGRATION 150 8319cbb6362SCornelia Huck #define KVM_CAP_PPC_GET_CPU_CHAR 151 8329cbb6362SCornelia Huck #define KVM_CAP_S390_BPB 152 8339f2d175dSPaolo Bonzini #define KVM_CAP_GET_MSR_FEATURES 153 83465a6d8ddSPeter Maydell #define KVM_CAP_HYPERV_EVENTFD 154 83577d361b1SEric Auger #define KVM_CAP_HYPERV_TLBFLUSH 155 836d36f7de8SCornelia Huck #define KVM_CAP_S390_HPAGE_1M 156 837d36f7de8SCornelia Huck #define KVM_CAP_NESTED_STATE 157 8388f3cd250SCornelia Huck #define KVM_CAP_ARM_INJECT_SERROR_ESR 158 8398f3cd250SCornelia Huck #define KVM_CAP_MSR_PLATFORM_INFO 159 840966f2ec3SPaolo Bonzini #define KVM_CAP_PPC_NESTED_HV 160 841966f2ec3SPaolo Bonzini #define KVM_CAP_HYPERV_SEND_IPI 161 842966f2ec3SPaolo Bonzini #define KVM_CAP_COALESCED_PIO 162 843966f2ec3SPaolo Bonzini #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163 844966f2ec3SPaolo Bonzini #define KVM_CAP_EXCEPTION_PAYLOAD 164 845da054c64SPaolo Bonzini #define KVM_CAP_ARM_VM_IPA_SIZE 165 846d9cb4336SCornelia Huck #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166 /* Obsolete */ 847da054c64SPaolo Bonzini #define KVM_CAP_HYPERV_CPUID 167 848d9cb4336SCornelia Huck #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 168 849d9cb4336SCornelia Huck #define KVM_CAP_PPC_IRQ_XIVE 169 850d9cb4336SCornelia Huck #define KVM_CAP_ARM_SVE 170 851d9cb4336SCornelia Huck #define KVM_CAP_ARM_PTRAUTH_ADDRESS 171 852d9cb4336SCornelia Huck #define KVM_CAP_ARM_PTRAUTH_GENERIC 172 853f363d039SEric Auger #define KVM_CAP_PMU_EVENT_FILTER 173 854f363d039SEric Auger #define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174 855f363d039SEric Auger #define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175 8562a886794SGreg Kurz #define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 176 8572a886794SGreg Kurz #define KVM_CAP_ARM_NISV_TO_USER 177 8582a886794SGreg Kurz #define KVM_CAP_ARM_INJECT_EXT_DABT 178 859ddda3748SCornelia Huck #define KVM_CAP_S390_VCPU_RESETS 179 860dc6f8d45SCornelia Huck #define KVM_CAP_S390_PROTECTED 180 861dc6f8d45SCornelia Huck #define KVM_CAP_PPC_SECURE_GUEST 181 862f76b348eSCornelia Huck #define KVM_CAP_HALT_POLL 182 863f76b348eSCornelia Huck #define KVM_CAP_ASYNC_PF_INT 183 864e6546342SJason Wang #define KVM_CAP_LAST_CPU 184 865e6546342SJason Wang #define KVM_CAP_SMALLER_MAXPHYADDR 185 866e6546342SJason Wang #define KVM_CAP_S390_DIAG318 186 86794c7fefcSAndrew Jones #define KVM_CAP_STEAL_TIME 187 86853ba2eeeSMatthew Rosato #define KVM_CAP_X86_USER_SPACE_MSR 188 86953ba2eeeSMatthew Rosato #define KVM_CAP_X86_MSR_FILTER 189 87053ba2eeeSMatthew Rosato #define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190 871b3c818a4SEric Farman #define KVM_CAP_SYS_HYPERV_CPUID 191 872b3c818a4SEric Farman #define KVM_CAP_DIRTY_LOG_RING 192 873278f064eSEduardo Habkost #define KVM_CAP_X86_BUS_LOCK_EXIT 193 874278f064eSEduardo Habkost #define KVM_CAP_PPC_DAWR1 194 875278f064eSEduardo Habkost #define KVM_CAP_SET_GUEST_DEBUG2 195 876278f064eSEduardo Habkost #define KVM_CAP_SGX_ATTRIBUTE 196 877278f064eSEduardo Habkost #define KVM_CAP_VM_COPY_ENC_CONTEXT_FROM 197 878278f064eSEduardo Habkost #define KVM_CAP_PTP_KVM 198 879327d4b7fSBharata B Rao #define KVM_CAP_HYPERV_ENFORCE_CPUID 199 880327d4b7fSBharata B Rao #define KVM_CAP_SREGS2 200 881327d4b7fSBharata B Rao #define KVM_CAP_EXIT_HYPERCALL 201 882327d4b7fSBharata B Rao #define KVM_CAP_PPC_RPT_INVALIDATE 202 883327d4b7fSBharata B Rao #define KVM_CAP_BINARY_STATS_FD 203 884327d4b7fSBharata B Rao #define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204 885327d4b7fSBharata B Rao #define KVM_CAP_ARM_MTE 205 886ef17dd6aSVivek Goyal #define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206 887ef17dd6aSVivek Goyal #define KVM_CAP_VM_GPA_BITS 207 888ef17dd6aSVivek Goyal #define KVM_CAP_XSAVE2 208 8891ea5208fSPaolo Bonzini #define KVM_CAP_SYS_ATTRIBUTES 209 890e4082063SAlex Williamson #define KVM_CAP_PPC_AIL_MODE_3 210 891e4082063SAlex Williamson #define KVM_CAP_S390_MEM_OP_EXTENSION 211 892e4082063SAlex Williamson #define KVM_CAP_PMU_CAPABILITY 212 893e4082063SAlex Williamson #define KVM_CAP_DISABLE_QUIRKS2 213 894d525f73fSChenyi Qiang #define KVM_CAP_VM_TSC_CONTROL 214 895e4082063SAlex Williamson #define KVM_CAP_SYSTEM_EVENT_DATA 215 896d525f73fSChenyi Qiang #define KVM_CAP_ARM_SYSTEM_SUSPEND 216 897d525f73fSChenyi Qiang #define KVM_CAP_S390_PROTECTED_DUMP 217 898d525f73fSChenyi Qiang #define KVM_CAP_X86_TRIPLE_FAULT_EVENT 218 899d525f73fSChenyi Qiang #define KVM_CAP_X86_NOTIFY_VMEXIT 219 900d525f73fSChenyi Qiang #define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220 901d525f73fSChenyi Qiang #define KVM_CAP_S390_ZPCI_OP 221 902d525f73fSChenyi Qiang #define KVM_CAP_S390_CPU_TOPOLOGY 222 90393e0932bSPeter Xu #define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223 90493d7620cSAvihai Horon #define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224 90593d7620cSAvihai Horon #define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225 906c5c0fdbeSDavid 'Digit' Turner #define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226 907d0bf492fSCédric Le Goater #define KVM_CAP_COUNTER_OFFSET 227 908d0bf492fSCédric Le Goater #define KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 228 909d0bf492fSCédric Le Goater #define KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES 229 910efb91426SDaniel Henrique Barboza #define KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES 230 9116a02465fSDaniel Henrique Barboza #define KVM_CAP_USER_MEMORY2 231 9126a02465fSDaniel Henrique Barboza #define KVM_CAP_MEMORY_FAULT_INFO 232 9136a02465fSDaniel Henrique Barboza #define KVM_CAP_MEMORY_ATTRIBUTES 233 9146a02465fSDaniel Henrique Barboza #define KVM_CAP_GUEST_MEMFD 234 9156a02465fSDaniel Henrique Barboza #define KVM_CAP_VM_TYPES 235 91651b24e34SJan Kiszka 91751b24e34SJan Kiszka struct kvm_irq_routing_irqchip { 91851b24e34SJan Kiszka __u32 irqchip; 91951b24e34SJan Kiszka __u32 pin; 92051b24e34SJan Kiszka }; 92151b24e34SJan Kiszka 92251b24e34SJan Kiszka struct kvm_irq_routing_msi { 92351b24e34SJan Kiszka __u32 address_lo; 92451b24e34SJan Kiszka __u32 address_hi; 92551b24e34SJan Kiszka __u32 data; 926dbdfea92SCornelia Huck union { 92751b24e34SJan Kiszka __u32 pad; 928dbdfea92SCornelia Huck __u32 devid; 929dbdfea92SCornelia Huck }; 93051b24e34SJan Kiszka }; 93151b24e34SJan Kiszka 9329ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter { 9339ffd2685SCornelia Huck __u64 ind_addr; 9349ffd2685SCornelia Huck __u64 summary_addr; 9359ffd2685SCornelia Huck __u64 ind_offset; 9369ffd2685SCornelia Huck __u32 summary_offset; 9379ffd2685SCornelia Huck __u32 adapter_id; 9389ffd2685SCornelia Huck }; 9399ffd2685SCornelia Huck 940fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint { 941fff02bc0SPaolo Bonzini __u32 vcpu; 942fff02bc0SPaolo Bonzini __u32 sint; 943fff02bc0SPaolo Bonzini }; 944fff02bc0SPaolo Bonzini 945ef17dd6aSVivek Goyal struct kvm_irq_routing_xen_evtchn { 946ef17dd6aSVivek Goyal __u32 port; 947ef17dd6aSVivek Goyal __u32 vcpu; 948ef17dd6aSVivek Goyal __u32 priority; 949ef17dd6aSVivek Goyal }; 950ef17dd6aSVivek Goyal 951ef17dd6aSVivek Goyal #define KVM_IRQ_ROUTING_XEN_EVTCHN_PRIO_2LEVEL ((__u32)(-1)) 952ef17dd6aSVivek Goyal 95351b24e34SJan Kiszka /* gsi routing entry types */ 95451b24e34SJan Kiszka #define KVM_IRQ_ROUTING_IRQCHIP 1 95551b24e34SJan Kiszka #define KVM_IRQ_ROUTING_MSI 2 9569ffd2685SCornelia Huck #define KVM_IRQ_ROUTING_S390_ADAPTER 3 957fff02bc0SPaolo Bonzini #define KVM_IRQ_ROUTING_HV_SINT 4 958ef17dd6aSVivek Goyal #define KVM_IRQ_ROUTING_XEN_EVTCHN 5 95951b24e34SJan Kiszka 96051b24e34SJan Kiszka struct kvm_irq_routing_entry { 96151b24e34SJan Kiszka __u32 gsi; 96251b24e34SJan Kiszka __u32 type; 96351b24e34SJan Kiszka __u32 flags; 96451b24e34SJan Kiszka __u32 pad; 96551b24e34SJan Kiszka union { 96651b24e34SJan Kiszka struct kvm_irq_routing_irqchip irqchip; 96751b24e34SJan Kiszka struct kvm_irq_routing_msi msi; 9689ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter adapter; 969fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint hv_sint; 970ef17dd6aSVivek Goyal struct kvm_irq_routing_xen_evtchn xen_evtchn; 97151b24e34SJan Kiszka __u32 pad[8]; 97251b24e34SJan Kiszka } u; 97351b24e34SJan Kiszka }; 97451b24e34SJan Kiszka 97551b24e34SJan Kiszka struct kvm_irq_routing { 97651b24e34SJan Kiszka __u32 nr; 97751b24e34SJan Kiszka __u32 flags; 978d525f73fSChenyi Qiang struct kvm_irq_routing_entry entries[]; 97951b24e34SJan Kiszka }; 98051b24e34SJan Kiszka 98151b24e34SJan Kiszka #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0) 982716b8e4dSAlex Williamson /* 983716b8e4dSAlex Williamson * Available with KVM_CAP_IRQFD_RESAMPLE 984716b8e4dSAlex Williamson * 985716b8e4dSAlex Williamson * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies 986716b8e4dSAlex Williamson * the irqfd to operate in resampling mode for level triggered interrupt 987f76b348eSCornelia Huck * emulation. See Documentation/virt/kvm/api.rst. 988716b8e4dSAlex Williamson */ 989716b8e4dSAlex Williamson #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1) 99051b24e34SJan Kiszka 99151b24e34SJan Kiszka struct kvm_irqfd { 99251b24e34SJan Kiszka __u32 fd; 99351b24e34SJan Kiszka __u32 gsi; 99451b24e34SJan Kiszka __u32 flags; 995716b8e4dSAlex Williamson __u32 resamplefd; 996716b8e4dSAlex Williamson __u8 pad[16]; 99751b24e34SJan Kiszka }; 99851b24e34SJan Kiszka 999bc204035SMarcelo Tosatti /* For KVM_CAP_ADJUST_CLOCK */ 1000bc204035SMarcelo Tosatti 1001bc204035SMarcelo Tosatti /* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags. */ 1002bc204035SMarcelo Tosatti #define KVM_CLOCK_TSC_STABLE 2 100343709a0cSPaolo Bonzini #define KVM_CLOCK_REALTIME (1 << 2) 100443709a0cSPaolo Bonzini #define KVM_CLOCK_HOST_TSC (1 << 3) 1005bc204035SMarcelo Tosatti 100651b24e34SJan Kiszka struct kvm_clock_data { 100751b24e34SJan Kiszka __u64 clock; 100851b24e34SJan Kiszka __u32 flags; 100943709a0cSPaolo Bonzini __u32 pad0; 101043709a0cSPaolo Bonzini __u64 realtime; 101143709a0cSPaolo Bonzini __u64 host_tsc; 101243709a0cSPaolo Bonzini __u32 pad[4]; 101351b24e34SJan Kiszka }; 101451b24e34SJan Kiszka 1015bc204035SMarcelo Tosatti /* For KVM_CAP_SW_TLB */ 1016bc204035SMarcelo Tosatti 1017a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_NOHV 0 1018a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_HV 1 1019a54fc080SAlexander Graf 1020a54fc080SAlexander Graf struct kvm_config_tlb { 1021a54fc080SAlexander Graf __u64 params; 1022a54fc080SAlexander Graf __u64 array; 1023a54fc080SAlexander Graf __u32 mmu_type; 1024a54fc080SAlexander Graf __u32 array_len; 1025a54fc080SAlexander Graf }; 1026a54fc080SAlexander Graf 1027a54fc080SAlexander Graf struct kvm_dirty_tlb { 1028a54fc080SAlexander Graf __u64 bitmap; 1029a54fc080SAlexander Graf __u32 num_dirty; 1030a54fc080SAlexander Graf }; 1031a54fc080SAlexander Graf 10329d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 10339d4e4f8cSAlexander Graf 1034a31be480SAlexander Graf #define KVM_REG_ARCH_MASK 0xff00000000000000ULL 1035a31be480SAlexander Graf #define KVM_REG_GENERIC 0x0000000000000000ULL 10369d4e4f8cSAlexander Graf 10379d4e4f8cSAlexander Graf /* 10389d4e4f8cSAlexander Graf * Architecture specific registers are to be defined in arch headers and 10399d4e4f8cSAlexander Graf * ORed with the arch identifier. 10409d4e4f8cSAlexander Graf */ 1041a31be480SAlexander Graf #define KVM_REG_PPC 0x1000000000000000ULL 1042a31be480SAlexander Graf #define KVM_REG_X86 0x2000000000000000ULL 1043a31be480SAlexander Graf #define KVM_REG_IA64 0x3000000000000000ULL 1044a31be480SAlexander Graf #define KVM_REG_ARM 0x4000000000000000ULL 1045a31be480SAlexander Graf #define KVM_REG_S390 0x5000000000000000ULL 1046c5daeae1SAlexey Kardashevskiy #define KVM_REG_ARM64 0x6000000000000000ULL 1047c5daeae1SAlexey Kardashevskiy #define KVM_REG_MIPS 0x7000000000000000ULL 1048f363d039SEric Auger #define KVM_REG_RISCV 0x8000000000000000ULL 1049efb91426SDaniel Henrique Barboza #define KVM_REG_LOONGARCH 0x9000000000000000ULL 1050a31be480SAlexander Graf 1051a31be480SAlexander Graf #define KVM_REG_SIZE_SHIFT 52 1052a31be480SAlexander Graf #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL 1053a31be480SAlexander Graf #define KVM_REG_SIZE_U8 0x0000000000000000ULL 1054a31be480SAlexander Graf #define KVM_REG_SIZE_U16 0x0010000000000000ULL 1055a31be480SAlexander Graf #define KVM_REG_SIZE_U32 0x0020000000000000ULL 1056a31be480SAlexander Graf #define KVM_REG_SIZE_U64 0x0030000000000000ULL 1057a31be480SAlexander Graf #define KVM_REG_SIZE_U128 0x0040000000000000ULL 1058a31be480SAlexander Graf #define KVM_REG_SIZE_U256 0x0050000000000000ULL 1059a31be480SAlexander Graf #define KVM_REG_SIZE_U512 0x0060000000000000ULL 1060a31be480SAlexander Graf #define KVM_REG_SIZE_U1024 0x0070000000000000ULL 1061d9cb4336SCornelia Huck #define KVM_REG_SIZE_U2048 0x0080000000000000ULL 10629d4e4f8cSAlexander Graf 1063eadd0e44SPeter Maydell struct kvm_reg_list { 1064eadd0e44SPeter Maydell __u64 n; /* number of regs */ 1065d525f73fSChenyi Qiang __u64 reg[]; 1066eadd0e44SPeter Maydell }; 1067eadd0e44SPeter Maydell 10689d4e4f8cSAlexander Graf struct kvm_one_reg { 10699d4e4f8cSAlexander Graf __u64 id; 1070a31be480SAlexander Graf __u64 addr; 10719d4e4f8cSAlexander Graf }; 10729d4e4f8cSAlexander Graf 1073dbdfea92SCornelia Huck #define KVM_MSI_VALID_DEVID (1U << 0) 107480a3eb10SJan Kiszka struct kvm_msi { 107580a3eb10SJan Kiszka __u32 address_lo; 107680a3eb10SJan Kiszka __u32 address_hi; 107780a3eb10SJan Kiszka __u32 data; 107880a3eb10SJan Kiszka __u32 flags; 1079dbdfea92SCornelia Huck __u32 devid; 1080dbdfea92SCornelia Huck __u8 pad[12]; 108180a3eb10SJan Kiszka }; 108280a3eb10SJan Kiszka 1083eadd0e44SPeter Maydell struct kvm_arm_device_addr { 1084eadd0e44SPeter Maydell __u64 id; 1085eadd0e44SPeter Maydell __u64 addr; 1086eadd0e44SPeter Maydell }; 1087eadd0e44SPeter Maydell 108851b24e34SJan Kiszka /* 1089e098b453SAlexey Kardashevskiy * Device control API, available with KVM_CAP_DEVICE_CTRL 1090e098b453SAlexey Kardashevskiy */ 1091e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE_TEST 1 1092e098b453SAlexey Kardashevskiy 1093e098b453SAlexey Kardashevskiy struct kvm_create_device { 1094e098b453SAlexey Kardashevskiy __u32 type; /* in: KVM_DEV_TYPE_xxx */ 1095e098b453SAlexey Kardashevskiy __u32 fd; /* out: device handle */ 1096e098b453SAlexey Kardashevskiy __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */ 1097e098b453SAlexey Kardashevskiy }; 1098e098b453SAlexey Kardashevskiy 1099e098b453SAlexey Kardashevskiy struct kvm_device_attr { 1100e098b453SAlexey Kardashevskiy __u32 flags; /* no flags currently defined */ 1101e098b453SAlexey Kardashevskiy __u32 group; /* device-defined */ 1102e098b453SAlexey Kardashevskiy __u64 attr; /* group-defined */ 1103e098b453SAlexey Kardashevskiy __u64 addr; /* userspace address of attr data */ 1104e098b453SAlexey Kardashevskiy }; 1105e098b453SAlexey Kardashevskiy 1106da3c22c7SThomas Huth #define KVM_DEV_VFIO_FILE 1 1107da3c22c7SThomas Huth 1108da3c22c7SThomas Huth #define KVM_DEV_VFIO_FILE_ADD 1 1109da3c22c7SThomas Huth #define KVM_DEV_VFIO_FILE_DEL 2 1110da3c22c7SThomas Huth 1111da3c22c7SThomas Huth /* KVM_DEV_VFIO_GROUP aliases are for compile time uapi compatibility */ 1112da3c22c7SThomas Huth #define KVM_DEV_VFIO_GROUP KVM_DEV_VFIO_FILE 1113da3c22c7SThomas Huth 1114da3c22c7SThomas Huth #define KVM_DEV_VFIO_GROUP_ADD KVM_DEV_VFIO_FILE_ADD 1115da3c22c7SThomas Huth #define KVM_DEV_VFIO_GROUP_DEL KVM_DEV_VFIO_FILE_DEL 111674c98e20SCornelia Huck #define KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE 3 1117444b1996SArd Biesheuvel 1118444b1996SArd Biesheuvel enum kvm_device_type { 1119444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_20 = 1, 1120444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_20 KVM_DEV_TYPE_FSL_MPIC_20 1121444b1996SArd Biesheuvel KVM_DEV_TYPE_FSL_MPIC_42, 1122444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_42 KVM_DEV_TYPE_FSL_MPIC_42 1123444b1996SArd Biesheuvel KVM_DEV_TYPE_XICS, 1124444b1996SArd Biesheuvel #define KVM_DEV_TYPE_XICS KVM_DEV_TYPE_XICS 1125444b1996SArd Biesheuvel KVM_DEV_TYPE_VFIO, 1126444b1996SArd Biesheuvel #define KVM_DEV_TYPE_VFIO KVM_DEV_TYPE_VFIO 1127444b1996SArd Biesheuvel KVM_DEV_TYPE_ARM_VGIC_V2, 1128444b1996SArd Biesheuvel #define KVM_DEV_TYPE_ARM_VGIC_V2 KVM_DEV_TYPE_ARM_VGIC_V2 1129444b1996SArd Biesheuvel KVM_DEV_TYPE_FLIC, 1130444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_FLIC 113151628b18SChristian Borntraeger KVM_DEV_TYPE_ARM_VGIC_V3, 113251628b18SChristian Borntraeger #define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3 1133dbdfea92SCornelia Huck KVM_DEV_TYPE_ARM_VGIC_ITS, 1134dbdfea92SCornelia Huck #define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS 1135d9cb4336SCornelia Huck KVM_DEV_TYPE_XIVE, 1136d9cb4336SCornelia Huck #define KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_XIVE 11372a886794SGreg Kurz KVM_DEV_TYPE_ARM_PV_TIME, 11382a886794SGreg Kurz #define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME 1139d0bf492fSCédric Le Goater KVM_DEV_TYPE_RISCV_AIA, 1140d0bf492fSCédric Le Goater #define KVM_DEV_TYPE_RISCV_AIA KVM_DEV_TYPE_RISCV_AIA 1141444b1996SArd Biesheuvel KVM_DEV_TYPE_MAX, 1142444b1996SArd Biesheuvel }; 1143e098b453SAlexey Kardashevskiy 114474c98e20SCornelia Huck struct kvm_vfio_spapr_tce { 114574c98e20SCornelia Huck __s32 groupfd; 114674c98e20SCornelia Huck __s32 tablefd; 114774c98e20SCornelia Huck }; 114874c98e20SCornelia Huck 1149e098b453SAlexey Kardashevskiy /* 115051b24e34SJan Kiszka * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns 115151b24e34SJan Kiszka * a vcpu fd. 115251b24e34SJan Kiszka */ 115351b24e34SJan Kiszka #define KVM_CREATE_VCPU _IO(KVMIO, 0x41) 115451b24e34SJan Kiszka #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) 115551b24e34SJan Kiszka #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44) 1156d0bf492fSCédric Le Goater #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45) /* deprecated */ 115751b24e34SJan Kiszka #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \ 115851b24e34SJan Kiszka struct kvm_userspace_memory_region) 115951b24e34SJan Kiszka #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) 116051b24e34SJan Kiszka #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64) 11616a02465fSDaniel Henrique Barboza #define KVM_SET_USER_MEMORY_REGION2 _IOW(KVMIO, 0x49, \ 11626a02465fSDaniel Henrique Barboza struct kvm_userspace_memory_region2) 11631529ae1bSAlexander Graf 11641529ae1bSAlexander Graf /* enable ucontrol for s390 */ 11651529ae1bSAlexander Graf #define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping) 11661529ae1bSAlexander Graf #define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping) 11671529ae1bSAlexander Graf #define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long) 11681529ae1bSAlexander Graf 116951b24e34SJan Kiszka /* Device model IOC */ 117051b24e34SJan Kiszka #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) 117151b24e34SJan Kiszka #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) 117251b24e34SJan Kiszka #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) 117351b24e34SJan Kiszka #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) 117451b24e34SJan Kiszka #define KVM_CREATE_PIT _IO(KVMIO, 0x64) 117551b24e34SJan Kiszka #define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state) 117651b24e34SJan Kiszka #define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state) 117751b24e34SJan Kiszka #define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level) 117851b24e34SJan Kiszka #define KVM_REGISTER_COALESCED_MMIO \ 117951b24e34SJan Kiszka _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone) 118051b24e34SJan Kiszka #define KVM_UNREGISTER_COALESCED_MMIO \ 118151b24e34SJan Kiszka _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone) 118251b24e34SJan Kiszka #define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing) 118351b24e34SJan Kiszka #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71) 118451b24e34SJan Kiszka #define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd) 118551b24e34SJan Kiszka #define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config) 118651b24e34SJan Kiszka #define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78) 118751b24e34SJan Kiszka #define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd) 118851b24e34SJan Kiszka #define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config) 118951b24e34SJan Kiszka #define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data) 119051b24e34SJan Kiszka #define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data) 119151b24e34SJan Kiszka /* Available with KVM_CAP_PIT_STATE2 */ 119251b24e34SJan Kiszka #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) 119351b24e34SJan Kiszka #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) 119451b24e34SJan Kiszka /* Available with KVM_CAP_PPC_GET_PVINFO */ 119551b24e34SJan Kiszka #define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo) 1196d525f73fSChenyi Qiang /* Available with KVM_CAP_TSC_CONTROL for a vCPU, or with 1197d525f73fSChenyi Qiang * KVM_CAP_VM_TSC_CONTROL to set defaults for a VM */ 119851b24e34SJan Kiszka #define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2) 119951b24e34SJan Kiszka #define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3) 120080a3eb10SJan Kiszka /* Available with KVM_CAP_SIGNAL_MSI */ 120180a3eb10SJan Kiszka #define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi) 120280a3eb10SJan Kiszka /* Available with KVM_CAP_PPC_GET_SMMU_INFO */ 120380a3eb10SJan Kiszka #define KVM_PPC_GET_SMMU_INFO _IOR(KVMIO, 0xa6, struct kvm_ppc_smmu_info) 1204651682dcSMichael S. Tsirkin /* Available with KVM_CAP_PPC_ALLOC_HTAB */ 1205651682dcSMichael S. Tsirkin #define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32) 1206d4834ff9SAlexander Graf #define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce) 1207b89485a5SPaolo Bonzini #define KVM_CREATE_SPAPR_TCE_64 _IOW(KVMIO, 0xa8, \ 1208b89485a5SPaolo Bonzini struct kvm_create_spapr_tce_64) 1209d4834ff9SAlexander Graf /* Available with KVM_CAP_RMA */ 1210d4834ff9SAlexander Graf #define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma) 1211d4834ff9SAlexander Graf /* Available with KVM_CAP_PPC_HTAB_FD */ 1212d4834ff9SAlexander Graf #define KVM_PPC_GET_HTAB_FD _IOW(KVMIO, 0xaa, struct kvm_get_htab_fd) 1213eadd0e44SPeter Maydell /* Available with KVM_CAP_ARM_SET_DEVICE_ADDR */ 1214eadd0e44SPeter Maydell #define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr) 1215e098b453SAlexey Kardashevskiy /* Available with KVM_CAP_PPC_RTAS */ 1216e098b453SAlexey Kardashevskiy #define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args) 12173a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_SPAPR_RESIZE_HPT */ 12183a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt) 12193a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt) 1220*c5614ee3SThomas Weißschuh /* Available with KVM_CAP_PPC_MMU_RADIX or KVM_CAP_PPC_MMU_HASH_V3 */ 12213a5eb5b4SPaolo Bonzini #define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg) 1222*c5614ee3SThomas Weißschuh /* Available with KVM_CAP_PPC_MMU_RADIX */ 12233a5eb5b4SPaolo Bonzini #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info) 12249cbb6362SCornelia Huck /* Available with KVM_CAP_PPC_GET_CPU_CHAR */ 12259cbb6362SCornelia Huck #define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char) 1226f363d039SEric Auger /* Available with KVM_CAP_PMU_EVENT_FILTER */ 1227f363d039SEric Auger #define KVM_SET_PMU_EVENT_FILTER _IOW(KVMIO, 0xb2, struct kvm_pmu_event_filter) 122850fd0c37SBharata B Rao #define KVM_PPC_SVM_OFF _IO(KVMIO, 0xb3) 1229327d4b7fSBharata B Rao #define KVM_ARM_MTE_COPY_TAGS _IOR(KVMIO, 0xb4, struct kvm_arm_copy_mte_tags) 1230d0bf492fSCédric Le Goater /* Available with KVM_CAP_COUNTER_OFFSET */ 1231d0bf492fSCédric Le Goater #define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO, 0xb5, struct kvm_arm_counter_offset) 1232efb91426SDaniel Henrique Barboza #define KVM_ARM_GET_REG_WRITABLE_MASKS _IOR(KVMIO, 0xb6, struct reg_mask_range) 1233e098b453SAlexey Kardashevskiy 1234e098b453SAlexey Kardashevskiy /* ioctl for vm fd */ 1235e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) 1236e098b453SAlexey Kardashevskiy 1237e098b453SAlexey Kardashevskiy /* ioctls for fds returned by KVM_CREATE_DEVICE */ 1238e098b453SAlexey Kardashevskiy #define KVM_SET_DEVICE_ATTR _IOW(KVMIO, 0xe1, struct kvm_device_attr) 1239e098b453SAlexey Kardashevskiy #define KVM_GET_DEVICE_ATTR _IOW(KVMIO, 0xe2, struct kvm_device_attr) 1240e098b453SAlexey Kardashevskiy #define KVM_HAS_DEVICE_ATTR _IOW(KVMIO, 0xe3, struct kvm_device_attr) 124151b24e34SJan Kiszka 124251b24e34SJan Kiszka /* 124351b24e34SJan Kiszka * ioctls for vcpu fds 124451b24e34SJan Kiszka */ 124551b24e34SJan Kiszka #define KVM_RUN _IO(KVMIO, 0x80) 124651b24e34SJan Kiszka #define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs) 124751b24e34SJan Kiszka #define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs) 124851b24e34SJan Kiszka #define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs) 124951b24e34SJan Kiszka #define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs) 125051b24e34SJan Kiszka #define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation) 125151b24e34SJan Kiszka #define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt) 125251b24e34SJan Kiszka #define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs) 125351b24e34SJan Kiszka #define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs) 125451b24e34SJan Kiszka #define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid) 125551b24e34SJan Kiszka #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask) 125651b24e34SJan Kiszka #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu) 125751b24e34SJan Kiszka #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) 125851b24e34SJan Kiszka #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) 125951b24e34SJan Kiszka #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) 126051b24e34SJan Kiszka #define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2) 126151b24e34SJan Kiszka #define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2) 126251b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 126351b24e34SJan Kiszka #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl) 126451b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */ 126551b24e34SJan Kiszka #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) 126651b24e34SJan Kiszka /* valid for virtual machine (for floating interrupt)_and_ vcpu */ 126751b24e34SJan Kiszka #define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt) 126851b24e34SJan Kiszka /* store status for s390 */ 126951b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_NOADDR (-1ul) 127051b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_PREFIXED (-2ul) 127151b24e34SJan Kiszka #define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long) 127251b24e34SJan Kiszka /* initial ipl psw for s390 */ 127351b24e34SJan Kiszka #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw) 127451b24e34SJan Kiszka /* initial reset for s390 */ 127551b24e34SJan Kiszka #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) 127651b24e34SJan Kiszka #define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) 127751b24e34SJan Kiszka #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) 1278444b1996SArd Biesheuvel /* Available with KVM_CAP_USER_NMI */ 127951b24e34SJan Kiszka #define KVM_NMI _IO(KVMIO, 0x9a) 128051b24e34SJan Kiszka /* Available with KVM_CAP_SET_GUEST_DEBUG */ 128151b24e34SJan Kiszka #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug) 128251b24e34SJan Kiszka /* MCE for x86 */ 128351b24e34SJan Kiszka #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64) 128451b24e34SJan Kiszka #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64) 128551b24e34SJan Kiszka #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) 128651b24e34SJan Kiszka /* Available with KVM_CAP_VCPU_EVENTS */ 128751b24e34SJan Kiszka #define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events) 128851b24e34SJan Kiszka #define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events) 128951b24e34SJan Kiszka /* Available with KVM_CAP_DEBUGREGS */ 129051b24e34SJan Kiszka #define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs) 129151b24e34SJan Kiszka #define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs) 12929ffd2685SCornelia Huck /* 1293d0bf492fSCédric Le Goater * vcpu version available with KVM_CAP_ENABLE_CAP 12949ffd2685SCornelia Huck * vm version available with KVM_CAP_ENABLE_CAP_VM 12959ffd2685SCornelia Huck */ 129651b24e34SJan Kiszka #define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap) 129751b24e34SJan Kiszka /* Available with KVM_CAP_XSAVE */ 129851b24e34SJan Kiszka #define KVM_GET_XSAVE _IOR(KVMIO, 0xa4, struct kvm_xsave) 129951b24e34SJan Kiszka #define KVM_SET_XSAVE _IOW(KVMIO, 0xa5, struct kvm_xsave) 130051b24e34SJan Kiszka /* Available with KVM_CAP_XCRS */ 130151b24e34SJan Kiszka #define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs) 130251b24e34SJan Kiszka #define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs) 1303a54fc080SAlexander Graf /* Available with KVM_CAP_SW_TLB */ 1304a54fc080SAlexander Graf #define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb) 13059d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */ 1306a31be480SAlexander Graf #define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg) 13079d4e4f8cSAlexander Graf #define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg) 13089ab2195dSMarcelo Tosatti /* VM is being stopped by host */ 13099ab2195dSMarcelo Tosatti #define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad) 1310eadd0e44SPeter Maydell #define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init) 1311bf63839fSAlex Williamson #define KVM_ARM_PREFERRED_TARGET _IOR(KVMIO, 0xaf, struct kvm_vcpu_init) 1312eadd0e44SPeter Maydell #define KVM_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list) 13137a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_MEM_OP */ 13147a52ce8aSCornelia Huck #define KVM_S390_MEM_OP _IOW(KVMIO, 0xb1, struct kvm_s390_mem_op) 13157a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_SKEYS */ 13167a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS _IOW(KVMIO, 0xb2, struct kvm_s390_skeys) 13177a52ce8aSCornelia Huck #define KVM_S390_SET_SKEYS _IOW(KVMIO, 0xb3, struct kvm_s390_skeys) 13187a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_INJECT_IRQ */ 13197a52ce8aSCornelia Huck #define KVM_S390_IRQ _IOW(KVMIO, 0xb4, struct kvm_s390_irq) 13207a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_IRQ_STATE */ 13217a52ce8aSCornelia Huck #define KVM_S390_SET_IRQ_STATE _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state) 13227a52ce8aSCornelia Huck #define KVM_S390_GET_IRQ_STATE _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state) 132324a31426SPaolo Bonzini /* Available with KVM_CAP_X86_SMM */ 132424a31426SPaolo Bonzini #define KVM_SMI _IO(KVMIO, 0xb7) 13253272f0e2SChristian Borntraeger /* Available with KVM_CAP_S390_CMMA_MIGRATION */ 1326ab6e1550SChristian Borntraeger #define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log) 13273272f0e2SChristian Borntraeger #define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log) 13289f2d175dSPaolo Bonzini /* Memory Encryption Commands */ 13299f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_OP _IOWR(KVMIO, 0xba, unsigned long) 13309f2d175dSPaolo Bonzini 13319f2d175dSPaolo Bonzini struct kvm_enc_region { 13329f2d175dSPaolo Bonzini __u64 addr; 13339f2d175dSPaolo Bonzini __u64 size; 13349f2d175dSPaolo Bonzini }; 13359f2d175dSPaolo Bonzini 13369f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_REG_REGION _IOR(KVMIO, 0xbb, struct kvm_enc_region) 13379f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_UNREG_REGION _IOR(KVMIO, 0xbc, struct kvm_enc_region) 13389f2d175dSPaolo Bonzini 133965a6d8ddSPeter Maydell /* Available with KVM_CAP_HYPERV_EVENTFD */ 134065a6d8ddSPeter Maydell #define KVM_HYPERV_EVENTFD _IOW(KVMIO, 0xbd, struct kvm_hyperv_eventfd) 134165a6d8ddSPeter Maydell 1342d36f7de8SCornelia Huck /* Available with KVM_CAP_NESTED_STATE */ 1343d36f7de8SCornelia Huck #define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state) 1344d36f7de8SCornelia Huck #define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state) 134565a6d8ddSPeter Maydell 1346d9cb4336SCornelia Huck /* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT_2 */ 1347da054c64SPaolo Bonzini #define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log) 1348da054c64SPaolo Bonzini 1349b3c818a4SEric Farman /* Available with KVM_CAP_HYPERV_CPUID (vcpu) / KVM_CAP_SYS_HYPERV_CPUID (system) */ 1350da054c64SPaolo Bonzini #define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2) 1351da054c64SPaolo Bonzini 1352d9cb4336SCornelia Huck /* Available with KVM_CAP_ARM_SVE */ 1353d9cb4336SCornelia Huck #define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int) 1354d9cb4336SCornelia Huck 1355ddda3748SCornelia Huck /* Available with KVM_CAP_S390_VCPU_RESETS */ 1356ddda3748SCornelia Huck #define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3) 1357ddda3748SCornelia Huck #define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4) 1358ddda3748SCornelia Huck 1359dc6f8d45SCornelia Huck /* Available with KVM_CAP_S390_PROTECTED */ 1360dc6f8d45SCornelia Huck #define KVM_S390_PV_COMMAND _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd) 1361dc6f8d45SCornelia Huck 136253ba2eeeSMatthew Rosato /* Available with KVM_CAP_X86_MSR_FILTER */ 136353ba2eeeSMatthew Rosato #define KVM_X86_SET_MSR_FILTER _IOW(KVMIO, 0xc6, struct kvm_msr_filter) 136453ba2eeeSMatthew Rosato 1365b3c818a4SEric Farman /* Available with KVM_CAP_DIRTY_LOG_RING */ 1366b3c818a4SEric Farman #define KVM_RESET_DIRTY_RINGS _IO(KVMIO, 0xc7) 1367b3c818a4SEric Farman 1368278f064eSEduardo Habkost /* Per-VM Xen attributes */ 1369278f064eSEduardo Habkost #define KVM_XEN_HVM_GET_ATTR _IOWR(KVMIO, 0xc8, struct kvm_xen_hvm_attr) 1370278f064eSEduardo Habkost #define KVM_XEN_HVM_SET_ATTR _IOW(KVMIO, 0xc9, struct kvm_xen_hvm_attr) 1371278f064eSEduardo Habkost 1372278f064eSEduardo Habkost /* Per-vCPU Xen attributes */ 1373278f064eSEduardo Habkost #define KVM_XEN_VCPU_GET_ATTR _IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr) 1374278f064eSEduardo Habkost #define KVM_XEN_VCPU_SET_ATTR _IOW(KVMIO, 0xcb, struct kvm_xen_vcpu_attr) 1375278f064eSEduardo Habkost 1376d525f73fSChenyi Qiang /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */ 1377d525f73fSChenyi Qiang #define KVM_XEN_HVM_EVTCHN_SEND _IOW(KVMIO, 0xd0, struct kvm_irq_routing_xen_evtchn) 1378d525f73fSChenyi Qiang 1379327d4b7fSBharata B Rao #define KVM_GET_SREGS2 _IOR(KVMIO, 0xcc, struct kvm_sregs2) 1380327d4b7fSBharata B Rao #define KVM_SET_SREGS2 _IOW(KVMIO, 0xcd, struct kvm_sregs2) 1381327d4b7fSBharata B Rao 1382dc6f8d45SCornelia Huck #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0) 1383dc6f8d45SCornelia Huck #define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1) 1384dc6f8d45SCornelia Huck 1385b3c818a4SEric Farman /* 1386b3c818a4SEric Farman * Arch needs to define the macro after implementing the dirty ring 1387b3c818a4SEric Farman * feature. KVM_DIRTY_LOG_PAGE_OFFSET should be defined as the 1388b3c818a4SEric Farman * starting page offset of the dirty ring structures. 1389b3c818a4SEric Farman */ 1390b3c818a4SEric Farman #ifndef KVM_DIRTY_LOG_PAGE_OFFSET 1391b3c818a4SEric Farman #define KVM_DIRTY_LOG_PAGE_OFFSET 0 1392b3c818a4SEric Farman #endif 1393b3c818a4SEric Farman 1394b3c818a4SEric Farman /* 1395b3c818a4SEric Farman * KVM dirty GFN flags, defined as: 1396b3c818a4SEric Farman * 1397b3c818a4SEric Farman * |---------------+---------------+--------------| 1398b3c818a4SEric Farman * | bit 1 (reset) | bit 0 (dirty) | Status | 1399b3c818a4SEric Farman * |---------------+---------------+--------------| 1400b3c818a4SEric Farman * | 0 | 0 | Invalid GFN | 1401b3c818a4SEric Farman * | 0 | 1 | Dirty GFN | 1402b3c818a4SEric Farman * | 1 | X | GFN to reset | 1403b3c818a4SEric Farman * |---------------+---------------+--------------| 1404b3c818a4SEric Farman * 1405b3c818a4SEric Farman * Lifecycle of a dirty GFN goes like: 1406b3c818a4SEric Farman * 1407b3c818a4SEric Farman * dirtied harvested reset 1408b3c818a4SEric Farman * 00 -----------> 01 -------------> 1X -------+ 1409b3c818a4SEric Farman * ^ | 1410b3c818a4SEric Farman * | | 1411b3c818a4SEric Farman * +------------------------------------------+ 1412b3c818a4SEric Farman * 1413b3c818a4SEric Farman * The userspace program is only responsible for the 01->1X state 1414b3c818a4SEric Farman * conversion after harvesting an entry. Also, it must not skip any 1415b3c818a4SEric Farman * dirty bits, so that dirty bits are always harvested in sequence. 1416b3c818a4SEric Farman */ 1417278f064eSEduardo Habkost #define KVM_DIRTY_GFN_F_DIRTY _BITUL(0) 1418278f064eSEduardo Habkost #define KVM_DIRTY_GFN_F_RESET _BITUL(1) 1419b3c818a4SEric Farman #define KVM_DIRTY_GFN_F_MASK 0x3 1420b3c818a4SEric Farman 1421b3c818a4SEric Farman /* 1422b3c818a4SEric Farman * KVM dirty rings should be mapped at KVM_DIRTY_LOG_PAGE_OFFSET of 1423b3c818a4SEric Farman * per-vcpu mmaped regions as an array of struct kvm_dirty_gfn. The 1424b3c818a4SEric Farman * size of the gfn buffer is decided by the first argument when 1425b3c818a4SEric Farman * enabling KVM_CAP_DIRTY_LOG_RING. 1426b3c818a4SEric Farman */ 1427b3c818a4SEric Farman struct kvm_dirty_gfn { 1428b3c818a4SEric Farman __u32 flags; 1429b3c818a4SEric Farman __u32 slot; 1430b3c818a4SEric Farman __u64 offset; 1431b3c818a4SEric Farman }; 1432b3c818a4SEric Farman 1433278f064eSEduardo Habkost #define KVM_BUS_LOCK_DETECTION_OFF (1 << 0) 1434278f064eSEduardo Habkost #define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1) 1435278f064eSEduardo Habkost 1436e4082063SAlex Williamson #define KVM_PMU_CAP_DISABLE (1 << 0) 1437e4082063SAlex Williamson 1438327d4b7fSBharata B Rao /** 1439327d4b7fSBharata B Rao * struct kvm_stats_header - Header of per vm/vcpu binary statistics data. 1440327d4b7fSBharata B Rao * @flags: Some extra information for header, always 0 for now. 1441327d4b7fSBharata B Rao * @name_size: The size in bytes of the memory which contains statistics 1442327d4b7fSBharata B Rao * name string including trailing '\0'. The memory is allocated 1443327d4b7fSBharata B Rao * at the send of statistics descriptor. 1444327d4b7fSBharata B Rao * @num_desc: The number of statistics the vm or vcpu has. 1445327d4b7fSBharata B Rao * @id_offset: The offset of the vm/vcpu stats' id string in the file pointed 1446327d4b7fSBharata B Rao * by vm/vcpu stats fd. 1447327d4b7fSBharata B Rao * @desc_offset: The offset of the vm/vcpu stats' descriptor block in the file 1448327d4b7fSBharata B Rao * pointd by vm/vcpu stats fd. 1449327d4b7fSBharata B Rao * @data_offset: The offset of the vm/vcpu stats' data block in the file 1450327d4b7fSBharata B Rao * pointed by vm/vcpu stats fd. 1451327d4b7fSBharata B Rao * 1452327d4b7fSBharata B Rao * This is the header userspace needs to read from stats fd before any other 1453327d4b7fSBharata B Rao * readings. It is used by userspace to discover all the information about the 1454327d4b7fSBharata B Rao * vm/vcpu's binary statistics. 1455327d4b7fSBharata B Rao * Userspace reads this header from the start of the vm/vcpu's stats fd. 1456327d4b7fSBharata B Rao */ 1457327d4b7fSBharata B Rao struct kvm_stats_header { 1458327d4b7fSBharata B Rao __u32 flags; 1459327d4b7fSBharata B Rao __u32 name_size; 1460327d4b7fSBharata B Rao __u32 num_desc; 1461327d4b7fSBharata B Rao __u32 id_offset; 1462327d4b7fSBharata B Rao __u32 desc_offset; 1463327d4b7fSBharata B Rao __u32 data_offset; 1464327d4b7fSBharata B Rao }; 1465327d4b7fSBharata B Rao 1466327d4b7fSBharata B Rao #define KVM_STATS_TYPE_SHIFT 0 1467327d4b7fSBharata B Rao #define KVM_STATS_TYPE_MASK (0xF << KVM_STATS_TYPE_SHIFT) 1468327d4b7fSBharata B Rao #define KVM_STATS_TYPE_CUMULATIVE (0x0 << KVM_STATS_TYPE_SHIFT) 1469327d4b7fSBharata B Rao #define KVM_STATS_TYPE_INSTANT (0x1 << KVM_STATS_TYPE_SHIFT) 1470327d4b7fSBharata B Rao #define KVM_STATS_TYPE_PEAK (0x2 << KVM_STATS_TYPE_SHIFT) 147143709a0cSPaolo Bonzini #define KVM_STATS_TYPE_LINEAR_HIST (0x3 << KVM_STATS_TYPE_SHIFT) 147243709a0cSPaolo Bonzini #define KVM_STATS_TYPE_LOG_HIST (0x4 << KVM_STATS_TYPE_SHIFT) 147343709a0cSPaolo Bonzini #define KVM_STATS_TYPE_MAX KVM_STATS_TYPE_LOG_HIST 1474327d4b7fSBharata B Rao 1475327d4b7fSBharata B Rao #define KVM_STATS_UNIT_SHIFT 4 1476327d4b7fSBharata B Rao #define KVM_STATS_UNIT_MASK (0xF << KVM_STATS_UNIT_SHIFT) 1477327d4b7fSBharata B Rao #define KVM_STATS_UNIT_NONE (0x0 << KVM_STATS_UNIT_SHIFT) 1478327d4b7fSBharata B Rao #define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT) 1479327d4b7fSBharata B Rao #define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT) 1480327d4b7fSBharata B Rao #define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT) 1481105bb7cdSPaolo Bonzini #define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT) 1482d525f73fSChenyi Qiang #define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_BOOLEAN 1483327d4b7fSBharata B Rao 1484327d4b7fSBharata B Rao #define KVM_STATS_BASE_SHIFT 8 1485327d4b7fSBharata B Rao #define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT) 1486327d4b7fSBharata B Rao #define KVM_STATS_BASE_POW10 (0x0 << KVM_STATS_BASE_SHIFT) 1487327d4b7fSBharata B Rao #define KVM_STATS_BASE_POW2 (0x1 << KVM_STATS_BASE_SHIFT) 1488327d4b7fSBharata B Rao #define KVM_STATS_BASE_MAX KVM_STATS_BASE_POW2 1489327d4b7fSBharata B Rao 1490327d4b7fSBharata B Rao /** 1491327d4b7fSBharata B Rao * struct kvm_stats_desc - Descriptor of a KVM statistics. 1492327d4b7fSBharata B Rao * @flags: Annotations of the stats, like type, unit, etc. 1493327d4b7fSBharata B Rao * @exponent: Used together with @flags to determine the unit. 1494327d4b7fSBharata B Rao * @size: The number of data items for this stats. 1495327d4b7fSBharata B Rao * Every data item is of type __u64. 1496327d4b7fSBharata B Rao * @offset: The offset of the stats to the start of stat structure in 149743709a0cSPaolo Bonzini * structure kvm or kvm_vcpu. 149843709a0cSPaolo Bonzini * @bucket_size: A parameter value used for histogram stats. It is only used 149943709a0cSPaolo Bonzini * for linear histogram stats, specifying the size of the bucket; 1500327d4b7fSBharata B Rao * @name: The name string for the stats. Its size is indicated by the 1501327d4b7fSBharata B Rao * &kvm_stats_header->name_size. 1502327d4b7fSBharata B Rao */ 1503327d4b7fSBharata B Rao struct kvm_stats_desc { 1504327d4b7fSBharata B Rao __u32 flags; 1505327d4b7fSBharata B Rao __s16 exponent; 1506327d4b7fSBharata B Rao __u16 size; 1507327d4b7fSBharata B Rao __u32 offset; 150843709a0cSPaolo Bonzini __u32 bucket_size; 1509327d4b7fSBharata B Rao char name[]; 1510327d4b7fSBharata B Rao }; 1511327d4b7fSBharata B Rao 1512327d4b7fSBharata B Rao #define KVM_GET_STATS_FD _IO(KVMIO, 0xce) 1513327d4b7fSBharata B Rao 15141ea5208fSPaolo Bonzini /* Available with KVM_CAP_XSAVE2 */ 15151ea5208fSPaolo Bonzini #define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave) 15161ea5208fSPaolo Bonzini 1517d525f73fSChenyi Qiang /* Available with KVM_CAP_S390_PROTECTED_DUMP */ 1518d525f73fSChenyi Qiang #define KVM_S390_PV_CPU_COMMAND _IOWR(KVMIO, 0xd0, struct kvm_pv_cmd) 1519d525f73fSChenyi Qiang 1520d525f73fSChenyi Qiang /* Available with KVM_CAP_X86_NOTIFY_VMEXIT */ 1521d525f73fSChenyi Qiang #define KVM_X86_NOTIFY_VMEXIT_ENABLED (1ULL << 0) 1522d525f73fSChenyi Qiang #define KVM_X86_NOTIFY_VMEXIT_USER (1ULL << 1) 1523d525f73fSChenyi Qiang 1524d525f73fSChenyi Qiang /* Available with KVM_CAP_S390_ZPCI_OP */ 1525d525f73fSChenyi Qiang #define KVM_S390_ZPCI_OP _IOW(KVMIO, 0xd1, struct kvm_s390_zpci_op) 1526d525f73fSChenyi Qiang 15276a02465fSDaniel Henrique Barboza /* Available with KVM_CAP_MEMORY_ATTRIBUTES */ 15286a02465fSDaniel Henrique Barboza #define KVM_SET_MEMORY_ATTRIBUTES _IOW(KVMIO, 0xd2, struct kvm_memory_attributes) 15296a02465fSDaniel Henrique Barboza 15306a02465fSDaniel Henrique Barboza struct kvm_memory_attributes { 15316a02465fSDaniel Henrique Barboza __u64 address; 15326a02465fSDaniel Henrique Barboza __u64 size; 15336a02465fSDaniel Henrique Barboza __u64 attributes; 15346a02465fSDaniel Henrique Barboza __u64 flags; 15356a02465fSDaniel Henrique Barboza }; 15366a02465fSDaniel Henrique Barboza 15376a02465fSDaniel Henrique Barboza #define KVM_MEMORY_ATTRIBUTE_PRIVATE (1ULL << 3) 15386a02465fSDaniel Henrique Barboza 15396a02465fSDaniel Henrique Barboza #define KVM_CREATE_GUEST_MEMFD _IOWR(KVMIO, 0xd4, struct kvm_create_guest_memfd) 15406a02465fSDaniel Henrique Barboza 15416a02465fSDaniel Henrique Barboza struct kvm_create_guest_memfd { 15426a02465fSDaniel Henrique Barboza __u64 size; 15436a02465fSDaniel Henrique Barboza __u64 flags; 15446a02465fSDaniel Henrique Barboza __u64 reserved[6]; 15456a02465fSDaniel Henrique Barboza }; 15466a02465fSDaniel Henrique Barboza 154751b24e34SJan Kiszka #endif /* __LINUX_KVM_H */ 1548