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 
11*278f064eSEduardo Habkost #include <linux/const.h>
1251b24e34SJan Kiszka #include <linux/types.h>
1351b24e34SJan Kiszka 
1451b24e34SJan Kiszka #include <linux/ioctl.h>
1551b24e34SJan Kiszka #include <asm/kvm.h>
1651b24e34SJan Kiszka 
1751b24e34SJan Kiszka #define KVM_API_VERSION 12
1851b24e34SJan Kiszka 
1951b24e34SJan Kiszka /* *** Deprecated interfaces *** */
2051b24e34SJan Kiszka 
2151b24e34SJan Kiszka #define KVM_TRC_SHIFT           16
2251b24e34SJan Kiszka 
2351b24e34SJan Kiszka #define KVM_TRC_ENTRYEXIT       (1 << KVM_TRC_SHIFT)
2451b24e34SJan Kiszka #define KVM_TRC_HANDLER         (1 << (KVM_TRC_SHIFT + 1))
2551b24e34SJan Kiszka 
2651b24e34SJan Kiszka #define KVM_TRC_VMENTRY         (KVM_TRC_ENTRYEXIT + 0x01)
2751b24e34SJan Kiszka #define KVM_TRC_VMEXIT          (KVM_TRC_ENTRYEXIT + 0x02)
2851b24e34SJan Kiszka #define KVM_TRC_PAGE_FAULT      (KVM_TRC_HANDLER + 0x01)
2951b24e34SJan Kiszka 
3051b24e34SJan Kiszka #define KVM_TRC_HEAD_SIZE       12
3151b24e34SJan Kiszka #define KVM_TRC_CYCLE_SIZE      8
3251b24e34SJan Kiszka #define KVM_TRC_EXTRA_MAX       7
3351b24e34SJan Kiszka 
3451b24e34SJan Kiszka #define KVM_TRC_INJ_VIRQ         (KVM_TRC_HANDLER + 0x02)
3551b24e34SJan Kiszka #define KVM_TRC_REDELIVER_EVT    (KVM_TRC_HANDLER + 0x03)
3651b24e34SJan Kiszka #define KVM_TRC_PEND_INTR        (KVM_TRC_HANDLER + 0x04)
3751b24e34SJan Kiszka #define KVM_TRC_IO_READ          (KVM_TRC_HANDLER + 0x05)
3851b24e34SJan Kiszka #define KVM_TRC_IO_WRITE         (KVM_TRC_HANDLER + 0x06)
3951b24e34SJan Kiszka #define KVM_TRC_CR_READ          (KVM_TRC_HANDLER + 0x07)
4051b24e34SJan Kiszka #define KVM_TRC_CR_WRITE         (KVM_TRC_HANDLER + 0x08)
4151b24e34SJan Kiszka #define KVM_TRC_DR_READ          (KVM_TRC_HANDLER + 0x09)
4251b24e34SJan Kiszka #define KVM_TRC_DR_WRITE         (KVM_TRC_HANDLER + 0x0A)
4351b24e34SJan Kiszka #define KVM_TRC_MSR_READ         (KVM_TRC_HANDLER + 0x0B)
4451b24e34SJan Kiszka #define KVM_TRC_MSR_WRITE        (KVM_TRC_HANDLER + 0x0C)
4551b24e34SJan Kiszka #define KVM_TRC_CPUID            (KVM_TRC_HANDLER + 0x0D)
4651b24e34SJan Kiszka #define KVM_TRC_INTR             (KVM_TRC_HANDLER + 0x0E)
4751b24e34SJan Kiszka #define KVM_TRC_NMI              (KVM_TRC_HANDLER + 0x0F)
4851b24e34SJan Kiszka #define KVM_TRC_VMMCALL          (KVM_TRC_HANDLER + 0x10)
4951b24e34SJan Kiszka #define KVM_TRC_HLT              (KVM_TRC_HANDLER + 0x11)
5051b24e34SJan Kiszka #define KVM_TRC_CLTS             (KVM_TRC_HANDLER + 0x12)
5151b24e34SJan Kiszka #define KVM_TRC_LMSW             (KVM_TRC_HANDLER + 0x13)
5251b24e34SJan Kiszka #define KVM_TRC_APIC_ACCESS      (KVM_TRC_HANDLER + 0x14)
5351b24e34SJan Kiszka #define KVM_TRC_TDP_FAULT        (KVM_TRC_HANDLER + 0x15)
5451b24e34SJan Kiszka #define KVM_TRC_GTLB_WRITE       (KVM_TRC_HANDLER + 0x16)
5551b24e34SJan Kiszka #define KVM_TRC_STLB_WRITE       (KVM_TRC_HANDLER + 0x17)
5651b24e34SJan Kiszka #define KVM_TRC_STLB_INVAL       (KVM_TRC_HANDLER + 0x18)
5751b24e34SJan Kiszka #define KVM_TRC_PPC_INSTR        (KVM_TRC_HANDLER + 0x19)
5851b24e34SJan Kiszka 
5951b24e34SJan Kiszka struct kvm_user_trace_setup {
6051b24e34SJan Kiszka 	__u32 buf_size;
6151b24e34SJan Kiszka 	__u32 buf_nr;
6251b24e34SJan Kiszka };
6351b24e34SJan Kiszka 
6451b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_W_0x06 \
6551b24e34SJan Kiszka 	_IOW(KVMIO, 0x06, struct kvm_user_trace_setup)
6651b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_0x07 _IO(KVMIO, 0x07)
6751b24e34SJan Kiszka #define __KVM_DEPRECATED_MAIN_0x08 _IO(KVMIO, 0x08)
6851b24e34SJan Kiszka 
6951b24e34SJan Kiszka #define __KVM_DEPRECATED_VM_R_0x70 _IOR(KVMIO, 0x70, struct kvm_assigned_irq)
7051b24e34SJan Kiszka 
7151b24e34SJan Kiszka struct kvm_breakpoint {
7251b24e34SJan Kiszka 	__u32 enabled;
7351b24e34SJan Kiszka 	__u32 padding;
7451b24e34SJan Kiszka 	__u64 address;
7551b24e34SJan Kiszka };
7651b24e34SJan Kiszka 
7751b24e34SJan Kiszka struct kvm_debug_guest {
7851b24e34SJan Kiszka 	__u32 enabled;
7951b24e34SJan Kiszka 	__u32 pad;
8051b24e34SJan Kiszka 	struct kvm_breakpoint breakpoints[4];
8151b24e34SJan Kiszka 	__u32 singlestep;
8251b24e34SJan Kiszka };
8351b24e34SJan Kiszka 
8451b24e34SJan Kiszka #define __KVM_DEPRECATED_VCPU_W_0x87 _IOW(KVMIO, 0x87, struct kvm_debug_guest)
8551b24e34SJan Kiszka 
8651b24e34SJan Kiszka /* *** End of deprecated interfaces *** */
8751b24e34SJan Kiszka 
8851b24e34SJan Kiszka 
8951b24e34SJan Kiszka /* for KVM_CREATE_MEMORY_REGION */
9051b24e34SJan Kiszka struct kvm_memory_region {
9151b24e34SJan Kiszka 	__u32 slot;
9251b24e34SJan Kiszka 	__u32 flags;
9351b24e34SJan Kiszka 	__u64 guest_phys_addr;
9451b24e34SJan Kiszka 	__u64 memory_size; /* bytes */
9551b24e34SJan Kiszka };
9651b24e34SJan Kiszka 
9751b24e34SJan Kiszka /* for KVM_SET_USER_MEMORY_REGION */
9851b24e34SJan Kiszka struct kvm_userspace_memory_region {
9951b24e34SJan Kiszka 	__u32 slot;
10051b24e34SJan Kiszka 	__u32 flags;
10151b24e34SJan Kiszka 	__u64 guest_phys_addr;
10251b24e34SJan Kiszka 	__u64 memory_size; /* bytes */
10351b24e34SJan Kiszka 	__u64 userspace_addr; /* start of the userspace allocated memory */
10451b24e34SJan Kiszka };
10551b24e34SJan Kiszka 
106716b8e4dSAlex Williamson /*
107716b8e4dSAlex Williamson  * The bit 0 ~ bit 15 of kvm_memory_region::flags are visible for userspace,
108716b8e4dSAlex Williamson  * other bits are reserved for kvm internal use which are defined in
109716b8e4dSAlex Williamson  * include/linux/kvm_host.h.
110716b8e4dSAlex Williamson  */
111716b8e4dSAlex Williamson #define KVM_MEM_LOG_DIRTY_PAGES	(1UL << 0)
112716b8e4dSAlex Williamson #define KVM_MEM_READONLY	(1UL << 1)
11351b24e34SJan Kiszka 
11451b24e34SJan Kiszka /* for KVM_IRQ_LINE */
11551b24e34SJan Kiszka struct kvm_irq_level {
11651b24e34SJan Kiszka 	/*
11751b24e34SJan Kiszka 	 * ACPI gsi notion of irq.
11851b24e34SJan Kiszka 	 * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47..
11951b24e34SJan Kiszka 	 * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23..
120f76b348eSCornelia Huck 	 * For ARM: See Documentation/virt/kvm/api.rst
12151b24e34SJan Kiszka 	 */
12251b24e34SJan Kiszka 	union {
12351b24e34SJan Kiszka 		__u32 irq;
12451b24e34SJan Kiszka 		__s32 status;
12551b24e34SJan Kiszka 	};
12651b24e34SJan Kiszka 	__u32 level;
12751b24e34SJan Kiszka };
12851b24e34SJan Kiszka 
12951b24e34SJan Kiszka 
13051b24e34SJan Kiszka struct kvm_irqchip {
13151b24e34SJan Kiszka 	__u32 chip_id;
13251b24e34SJan Kiszka 	__u32 pad;
13351b24e34SJan Kiszka         union {
13451b24e34SJan Kiszka 		char dummy[512];  /* reserving space */
13551b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT
13651b24e34SJan Kiszka 		struct kvm_pic_state pic;
13751b24e34SJan Kiszka #endif
13851b24e34SJan Kiszka #ifdef __KVM_HAVE_IOAPIC
13951b24e34SJan Kiszka 		struct kvm_ioapic_state ioapic;
14051b24e34SJan Kiszka #endif
14151b24e34SJan Kiszka 	} chip;
14251b24e34SJan Kiszka };
14351b24e34SJan Kiszka 
14451b24e34SJan Kiszka /* for KVM_CREATE_PIT2 */
14551b24e34SJan Kiszka struct kvm_pit_config {
14651b24e34SJan Kiszka 	__u32 flags;
14751b24e34SJan Kiszka 	__u32 pad[15];
14851b24e34SJan Kiszka };
14951b24e34SJan Kiszka 
15051b24e34SJan Kiszka #define KVM_PIT_SPEAKER_DUMMY     1
15151b24e34SJan Kiszka 
1527a52ce8aSCornelia Huck struct kvm_s390_skeys {
1537a52ce8aSCornelia Huck 	__u64 start_gfn;
1547a52ce8aSCornelia Huck 	__u64 count;
1557a52ce8aSCornelia Huck 	__u64 skeydata_addr;
1567a52ce8aSCornelia Huck 	__u32 flags;
1577a52ce8aSCornelia Huck 	__u32 reserved[9];
1587a52ce8aSCornelia Huck };
159fff02bc0SPaolo Bonzini 
1603272f0e2SChristian Borntraeger #define KVM_S390_CMMA_PEEK (1 << 0)
1613272f0e2SChristian Borntraeger 
1623272f0e2SChristian Borntraeger /**
1633272f0e2SChristian Borntraeger  * kvm_s390_cmma_log - Used for CMMA migration.
1643272f0e2SChristian Borntraeger  *
1653272f0e2SChristian Borntraeger  * Used both for input and output.
1663272f0e2SChristian Borntraeger  *
1673272f0e2SChristian Borntraeger  * @start_gfn: Guest page number to start from.
1683272f0e2SChristian Borntraeger  * @count: Size of the result buffer.
1693272f0e2SChristian Borntraeger  * @flags: Control operation mode via KVM_S390_CMMA_* flags
1703272f0e2SChristian Borntraeger  * @remaining: Used with KVM_S390_GET_CMMA_BITS. Indicates how many dirty
1713272f0e2SChristian Borntraeger  *             pages are still remaining.
1723272f0e2SChristian Borntraeger  * @mask: Used with KVM_S390_SET_CMMA_BITS. Bitmap of bits to actually set
1733272f0e2SChristian Borntraeger  *        in the PGSTE.
1743272f0e2SChristian Borntraeger  * @values: Pointer to the values buffer.
1753272f0e2SChristian Borntraeger  *
1763272f0e2SChristian Borntraeger  * Used in KVM_S390_{G,S}ET_CMMA_BITS ioctls.
1773272f0e2SChristian Borntraeger  */
1783272f0e2SChristian Borntraeger struct kvm_s390_cmma_log {
1793272f0e2SChristian Borntraeger 	__u64 start_gfn;
1803272f0e2SChristian Borntraeger 	__u32 count;
1813272f0e2SChristian Borntraeger 	__u32 flags;
1823272f0e2SChristian Borntraeger 	union {
1833272f0e2SChristian Borntraeger 		__u64 remaining;
1843272f0e2SChristian Borntraeger 		__u64 mask;
1853272f0e2SChristian Borntraeger 	};
1863272f0e2SChristian Borntraeger 	__u64 values;
1873272f0e2SChristian Borntraeger };
1883272f0e2SChristian Borntraeger 
189fff02bc0SPaolo Bonzini struct kvm_hyperv_exit {
190fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV_SYNIC          1
191b89485a5SPaolo Bonzini #define KVM_EXIT_HYPERV_HCALL          2
192f76b348eSCornelia Huck #define KVM_EXIT_HYPERV_SYNDBG         3
193fff02bc0SPaolo Bonzini 	__u32 type;
194f76b348eSCornelia Huck 	__u32 pad1;
195fff02bc0SPaolo Bonzini 	union {
196fff02bc0SPaolo Bonzini 		struct {
197fff02bc0SPaolo Bonzini 			__u32 msr;
198f76b348eSCornelia Huck 			__u32 pad2;
199fff02bc0SPaolo Bonzini 			__u64 control;
200fff02bc0SPaolo Bonzini 			__u64 evt_page;
201fff02bc0SPaolo Bonzini 			__u64 msg_page;
202fff02bc0SPaolo Bonzini 		} synic;
203b89485a5SPaolo Bonzini 		struct {
204b89485a5SPaolo Bonzini 			__u64 input;
205b89485a5SPaolo Bonzini 			__u64 result;
206b89485a5SPaolo Bonzini 			__u64 params[2];
207b89485a5SPaolo Bonzini 		} hcall;
208f76b348eSCornelia Huck 		struct {
209f76b348eSCornelia Huck 			__u32 msr;
210f76b348eSCornelia Huck 			__u32 pad2;
211f76b348eSCornelia Huck 			__u64 control;
212f76b348eSCornelia Huck 			__u64 status;
213f76b348eSCornelia Huck 			__u64 send_page;
214f76b348eSCornelia Huck 			__u64 recv_page;
215f76b348eSCornelia Huck 			__u64 pending_page;
216f76b348eSCornelia Huck 		} syndbg;
217fff02bc0SPaolo Bonzini 	} u;
218fff02bc0SPaolo Bonzini };
219fff02bc0SPaolo Bonzini 
220*278f064eSEduardo Habkost struct kvm_xen_exit {
221*278f064eSEduardo Habkost #define KVM_EXIT_XEN_HCALL          1
222*278f064eSEduardo Habkost 	__u32 type;
223*278f064eSEduardo Habkost 	union {
224*278f064eSEduardo Habkost 		struct {
225*278f064eSEduardo Habkost 			__u32 longmode;
226*278f064eSEduardo Habkost 			__u32 cpl;
227*278f064eSEduardo Habkost 			__u64 input;
228*278f064eSEduardo Habkost 			__u64 result;
229*278f064eSEduardo Habkost 			__u64 params[6];
230*278f064eSEduardo Habkost 		} hcall;
231*278f064eSEduardo Habkost 	} u;
232*278f064eSEduardo Habkost };
233*278f064eSEduardo Habkost 
2347a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS_NONE   1
2357a52ce8aSCornelia Huck #define KVM_S390_SKEYS_MAX        1048576
2367a52ce8aSCornelia Huck 
23751b24e34SJan Kiszka #define KVM_EXIT_UNKNOWN          0
23851b24e34SJan Kiszka #define KVM_EXIT_EXCEPTION        1
23951b24e34SJan Kiszka #define KVM_EXIT_IO               2
24051b24e34SJan Kiszka #define KVM_EXIT_HYPERCALL        3
24151b24e34SJan Kiszka #define KVM_EXIT_DEBUG            4
24251b24e34SJan Kiszka #define KVM_EXIT_HLT              5
24351b24e34SJan Kiszka #define KVM_EXIT_MMIO             6
24451b24e34SJan Kiszka #define KVM_EXIT_IRQ_WINDOW_OPEN  7
24551b24e34SJan Kiszka #define KVM_EXIT_SHUTDOWN         8
24651b24e34SJan Kiszka #define KVM_EXIT_FAIL_ENTRY       9
24751b24e34SJan Kiszka #define KVM_EXIT_INTR             10
24851b24e34SJan Kiszka #define KVM_EXIT_SET_TPR          11
24951b24e34SJan Kiszka #define KVM_EXIT_TPR_ACCESS       12
25051b24e34SJan Kiszka #define KVM_EXIT_S390_SIEIC       13
25151b24e34SJan Kiszka #define KVM_EXIT_S390_RESET       14
252a9fd1654SJens Freimann #define KVM_EXIT_DCR              15 /* deprecated */
25351b24e34SJan Kiszka #define KVM_EXIT_NMI              16
25451b24e34SJan Kiszka #define KVM_EXIT_INTERNAL_ERROR   17
25551b24e34SJan Kiszka #define KVM_EXIT_OSI              18
2567c6da3deSAlexander Graf #define KVM_EXIT_PAPR_HCALL	  19
2571529ae1bSAlexander Graf #define KVM_EXIT_S390_UCONTROL	  20
258d4834ff9SAlexander Graf #define KVM_EXIT_WATCHDOG         21
259d3dccee1SAlexander Graf #define KVM_EXIT_S390_TSCH        22
260d3dccee1SAlexander Graf #define KVM_EXIT_EPR              23
261b061808dSAlexander Graf #define KVM_EXIT_SYSTEM_EVENT     24
2627a52ce8aSCornelia Huck #define KVM_EXIT_S390_STSI        25
2633a824b15SPaolo Bonzini #define KVM_EXIT_IOAPIC_EOI       26
264fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV           27
2652a886794SGreg Kurz #define KVM_EXIT_ARM_NISV         28
26653ba2eeeSMatthew Rosato #define KVM_EXIT_X86_RDMSR        29
26753ba2eeeSMatthew Rosato #define KVM_EXIT_X86_WRMSR        30
268b3c818a4SEric Farman #define KVM_EXIT_DIRTY_RING_FULL  31
269*278f064eSEduardo Habkost #define KVM_EXIT_AP_RESET_HOLD    32
270*278f064eSEduardo Habkost #define KVM_EXIT_X86_BUS_LOCK     33
271*278f064eSEduardo Habkost #define KVM_EXIT_XEN              34
27251b24e34SJan Kiszka 
27351b24e34SJan Kiszka /* For KVM_EXIT_INTERNAL_ERROR */
274d4834ff9SAlexander Graf /* Emulate instruction failed. */
27551b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_EMULATION	1
276d4834ff9SAlexander Graf /* Encounter unexpected simultaneous exceptions. */
27751b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_SIMUL_EX	2
278d4834ff9SAlexander Graf /* Encounter unexpected vm-exit due to delivery event. */
279d4834ff9SAlexander Graf #define KVM_INTERNAL_ERROR_DELIVERY_EV	3
280f363d039SEric Auger /* Encounter unexpected vm-exit reason */
281f363d039SEric Auger #define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON	4
28251b24e34SJan Kiszka 
28351b24e34SJan Kiszka /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
28451b24e34SJan Kiszka struct kvm_run {
28551b24e34SJan Kiszka 	/* in */
28651b24e34SJan Kiszka 	__u8 request_interrupt_window;
2873a5eb5b4SPaolo Bonzini 	__u8 immediate_exit;
2883a5eb5b4SPaolo Bonzini 	__u8 padding1[6];
28951b24e34SJan Kiszka 
29051b24e34SJan Kiszka 	/* out */
29151b24e34SJan Kiszka 	__u32 exit_reason;
29251b24e34SJan Kiszka 	__u8 ready_for_interrupt_injection;
29351b24e34SJan Kiszka 	__u8 if_flag;
29424a31426SPaolo Bonzini 	__u16 flags;
29551b24e34SJan Kiszka 
29651b24e34SJan Kiszka 	/* in (pre_kvm_run), out (post_kvm_run) */
29751b24e34SJan Kiszka 	__u64 cr8;
29851b24e34SJan Kiszka 	__u64 apic_base;
29951b24e34SJan Kiszka 
30051b24e34SJan Kiszka #ifdef __KVM_S390
30151b24e34SJan Kiszka 	/* the processor status word for s390 */
30251b24e34SJan Kiszka 	__u64 psw_mask; /* psw upper half */
30351b24e34SJan Kiszka 	__u64 psw_addr; /* psw lower half */
30451b24e34SJan Kiszka #endif
30551b24e34SJan Kiszka 	union {
30651b24e34SJan Kiszka 		/* KVM_EXIT_UNKNOWN */
30751b24e34SJan Kiszka 		struct {
30851b24e34SJan Kiszka 			__u64 hardware_exit_reason;
30951b24e34SJan Kiszka 		} hw;
31051b24e34SJan Kiszka 		/* KVM_EXIT_FAIL_ENTRY */
31151b24e34SJan Kiszka 		struct {
31251b24e34SJan Kiszka 			__u64 hardware_entry_failure_reason;
313e6546342SJason Wang 			__u32 cpu;
31451b24e34SJan Kiszka 		} fail_entry;
31551b24e34SJan Kiszka 		/* KVM_EXIT_EXCEPTION */
31651b24e34SJan Kiszka 		struct {
31751b24e34SJan Kiszka 			__u32 exception;
31851b24e34SJan Kiszka 			__u32 error_code;
31951b24e34SJan Kiszka 		} ex;
32051b24e34SJan Kiszka 		/* KVM_EXIT_IO */
32151b24e34SJan Kiszka 		struct {
32251b24e34SJan Kiszka #define KVM_EXIT_IO_IN  0
32351b24e34SJan Kiszka #define KVM_EXIT_IO_OUT 1
32451b24e34SJan Kiszka 			__u8 direction;
32551b24e34SJan Kiszka 			__u8 size; /* bytes */
32651b24e34SJan Kiszka 			__u16 port;
32751b24e34SJan Kiszka 			__u32 count;
32851b24e34SJan Kiszka 			__u64 data_offset; /* relative to kvm_run start */
32951b24e34SJan Kiszka 		} io;
3303a824b15SPaolo Bonzini 		/* KVM_EXIT_DEBUG */
33151b24e34SJan Kiszka 		struct {
33251b24e34SJan Kiszka 			struct kvm_debug_exit_arch arch;
33351b24e34SJan Kiszka 		} debug;
33451b24e34SJan Kiszka 		/* KVM_EXIT_MMIO */
33551b24e34SJan Kiszka 		struct {
33651b24e34SJan Kiszka 			__u64 phys_addr;
33751b24e34SJan Kiszka 			__u8  data[8];
33851b24e34SJan Kiszka 			__u32 len;
33951b24e34SJan Kiszka 			__u8  is_write;
34051b24e34SJan Kiszka 		} mmio;
34151b24e34SJan Kiszka 		/* KVM_EXIT_HYPERCALL */
34251b24e34SJan Kiszka 		struct {
34351b24e34SJan Kiszka 			__u64 nr;
34451b24e34SJan Kiszka 			__u64 args[6];
34551b24e34SJan Kiszka 			__u64 ret;
34651b24e34SJan Kiszka 			__u32 longmode;
34751b24e34SJan Kiszka 			__u32 pad;
34851b24e34SJan Kiszka 		} hypercall;
34951b24e34SJan Kiszka 		/* KVM_EXIT_TPR_ACCESS */
35051b24e34SJan Kiszka 		struct {
35151b24e34SJan Kiszka 			__u64 rip;
35251b24e34SJan Kiszka 			__u32 is_write;
35351b24e34SJan Kiszka 			__u32 pad;
35451b24e34SJan Kiszka 		} tpr_access;
35551b24e34SJan Kiszka 		/* KVM_EXIT_S390_SIEIC */
35651b24e34SJan Kiszka 		struct {
35751b24e34SJan Kiszka 			__u8 icptcode;
35851b24e34SJan Kiszka 			__u16 ipa;
35951b24e34SJan Kiszka 			__u32 ipb;
36051b24e34SJan Kiszka 		} s390_sieic;
36151b24e34SJan Kiszka 		/* KVM_EXIT_S390_RESET */
36251b24e34SJan Kiszka #define KVM_S390_RESET_POR       1
36351b24e34SJan Kiszka #define KVM_S390_RESET_CLEAR     2
36451b24e34SJan Kiszka #define KVM_S390_RESET_SUBSYSTEM 4
36551b24e34SJan Kiszka #define KVM_S390_RESET_CPU_INIT  8
36651b24e34SJan Kiszka #define KVM_S390_RESET_IPL       16
36751b24e34SJan Kiszka 		__u64 s390_reset_flags;
3681529ae1bSAlexander Graf 		/* KVM_EXIT_S390_UCONTROL */
3691529ae1bSAlexander Graf 		struct {
3701529ae1bSAlexander Graf 			__u64 trans_exc_code;
3711529ae1bSAlexander Graf 			__u32 pgm_code;
3721529ae1bSAlexander Graf 		} s390_ucontrol;
373a9fd1654SJens Freimann 		/* KVM_EXIT_DCR (deprecated) */
37451b24e34SJan Kiszka 		struct {
37551b24e34SJan Kiszka 			__u32 dcrn;
37651b24e34SJan Kiszka 			__u32 data;
37751b24e34SJan Kiszka 			__u8  is_write;
37851b24e34SJan Kiszka 		} dcr;
3793a824b15SPaolo Bonzini 		/* KVM_EXIT_INTERNAL_ERROR */
38051b24e34SJan Kiszka 		struct {
38151b24e34SJan Kiszka 			__u32 suberror;
38251b24e34SJan Kiszka 			/* Available with KVM_CAP_INTERNAL_ERROR_DATA: */
38351b24e34SJan Kiszka 			__u32 ndata;
38451b24e34SJan Kiszka 			__u64 data[16];
38551b24e34SJan Kiszka 		} internal;
38651b24e34SJan Kiszka 		/* KVM_EXIT_OSI */
38751b24e34SJan Kiszka 		struct {
38851b24e34SJan Kiszka 			__u64 gprs[32];
38951b24e34SJan Kiszka 		} osi;
3903a824b15SPaolo Bonzini 		/* KVM_EXIT_PAPR_HCALL */
3917c6da3deSAlexander Graf 		struct {
3927c6da3deSAlexander Graf 			__u64 nr;
3937c6da3deSAlexander Graf 			__u64 ret;
3947c6da3deSAlexander Graf 			__u64 args[9];
3957c6da3deSAlexander Graf 		} papr_hcall;
396d3dccee1SAlexander Graf 		/* KVM_EXIT_S390_TSCH */
397d3dccee1SAlexander Graf 		struct {
398d3dccee1SAlexander Graf 			__u16 subchannel_id;
399d3dccee1SAlexander Graf 			__u16 subchannel_nr;
400d3dccee1SAlexander Graf 			__u32 io_int_parm;
401d3dccee1SAlexander Graf 			__u32 io_int_word;
402d3dccee1SAlexander Graf 			__u32 ipb;
403d3dccee1SAlexander Graf 			__u8 dequeued;
404d3dccee1SAlexander Graf 		} s390_tsch;
405d3dccee1SAlexander Graf 		/* KVM_EXIT_EPR */
406d3dccee1SAlexander Graf 		struct {
407d3dccee1SAlexander Graf 			__u32 epr;
408d3dccee1SAlexander Graf 		} epr;
409b061808dSAlexander Graf 		/* KVM_EXIT_SYSTEM_EVENT */
410b061808dSAlexander Graf 		struct {
411b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_SHUTDOWN       1
412b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_RESET          2
413120758fbSPaolo Bonzini #define KVM_SYSTEM_EVENT_CRASH          3
414b061808dSAlexander Graf 			__u32 type;
415b061808dSAlexander Graf 			__u64 flags;
416b061808dSAlexander Graf 		} system_event;
4177a52ce8aSCornelia Huck 		/* KVM_EXIT_S390_STSI */
4187a52ce8aSCornelia Huck 		struct {
4197a52ce8aSCornelia Huck 			__u64 addr;
4207a52ce8aSCornelia Huck 			__u8 ar;
4217a52ce8aSCornelia Huck 			__u8 reserved;
4227a52ce8aSCornelia Huck 			__u8 fc;
4237a52ce8aSCornelia Huck 			__u8 sel1;
4247a52ce8aSCornelia Huck 			__u16 sel2;
4257a52ce8aSCornelia Huck 		} s390_stsi;
4263a824b15SPaolo Bonzini 		/* KVM_EXIT_IOAPIC_EOI */
4273a824b15SPaolo Bonzini 		struct {
4283a824b15SPaolo Bonzini 			__u8 vector;
4293a824b15SPaolo Bonzini 		} eoi;
430fff02bc0SPaolo Bonzini 		/* KVM_EXIT_HYPERV */
431fff02bc0SPaolo Bonzini 		struct kvm_hyperv_exit hyperv;
4322a886794SGreg Kurz 		/* KVM_EXIT_ARM_NISV */
4332a886794SGreg Kurz 		struct {
4342a886794SGreg Kurz 			__u64 esr_iss;
4352a886794SGreg Kurz 			__u64 fault_ipa;
4362a886794SGreg Kurz 		} arm_nisv;
43753ba2eeeSMatthew Rosato 		/* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */
43853ba2eeeSMatthew Rosato 		struct {
43953ba2eeeSMatthew Rosato 			__u8 error; /* user -> kernel */
44053ba2eeeSMatthew Rosato 			__u8 pad[7];
44153ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_INVAL	(1 << 0)
44253ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_UNKNOWN	(1 << 1)
44353ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_FILTER	(1 << 2)
44453ba2eeeSMatthew Rosato 			__u32 reason; /* kernel -> user */
44553ba2eeeSMatthew Rosato 			__u32 index; /* kernel -> user */
44653ba2eeeSMatthew Rosato 			__u64 data; /* kernel <-> user */
44753ba2eeeSMatthew Rosato 		} msr;
448*278f064eSEduardo Habkost 		/* KVM_EXIT_XEN */
449*278f064eSEduardo Habkost 		struct kvm_xen_exit xen;
45051b24e34SJan Kiszka 		/* Fix the size of the union. */
45151b24e34SJan Kiszka 		char padding[256];
45251b24e34SJan Kiszka 	};
4531529ae1bSAlexander Graf 
45465a6d8ddSPeter Maydell 	/* 2048 is the size of the char array used to bound/pad the size
45565a6d8ddSPeter Maydell 	 * of the union that holds sync regs.
45665a6d8ddSPeter Maydell 	 */
45765a6d8ddSPeter Maydell 	#define SYNC_REGS_SIZE_BYTES 2048
4581529ae1bSAlexander Graf 	/*
4591529ae1bSAlexander Graf 	 * shared registers between kvm and userspace.
4601529ae1bSAlexander Graf 	 * kvm_valid_regs specifies the register classes set by the host
4611529ae1bSAlexander Graf 	 * kvm_dirty_regs specified the register classes dirtied by userspace
4621529ae1bSAlexander Graf 	 * struct kvm_sync_regs is architecture specific, as well as the
4631529ae1bSAlexander Graf 	 * bits for kvm_valid_regs and kvm_dirty_regs
4641529ae1bSAlexander Graf 	 */
4651529ae1bSAlexander Graf 	__u64 kvm_valid_regs;
4661529ae1bSAlexander Graf 	__u64 kvm_dirty_regs;
4671529ae1bSAlexander Graf 	union {
4681529ae1bSAlexander Graf 		struct kvm_sync_regs regs;
46965a6d8ddSPeter Maydell 		char padding[SYNC_REGS_SIZE_BYTES];
4701529ae1bSAlexander Graf 	} s;
47151b24e34SJan Kiszka };
47251b24e34SJan Kiszka 
47351b24e34SJan Kiszka /* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */
47451b24e34SJan Kiszka 
47551b24e34SJan Kiszka struct kvm_coalesced_mmio_zone {
47651b24e34SJan Kiszka 	__u64 addr;
47751b24e34SJan Kiszka 	__u32 size;
478966f2ec3SPaolo Bonzini 	union {
47951b24e34SJan Kiszka 		__u32 pad;
480966f2ec3SPaolo Bonzini 		__u32 pio;
481966f2ec3SPaolo Bonzini 	};
48251b24e34SJan Kiszka };
48351b24e34SJan Kiszka 
48451b24e34SJan Kiszka struct kvm_coalesced_mmio {
48551b24e34SJan Kiszka 	__u64 phys_addr;
48651b24e34SJan Kiszka 	__u32 len;
487966f2ec3SPaolo Bonzini 	union {
48851b24e34SJan Kiszka 		__u32 pad;
489966f2ec3SPaolo Bonzini 		__u32 pio;
490966f2ec3SPaolo Bonzini 	};
49151b24e34SJan Kiszka 	__u8  data[8];
49251b24e34SJan Kiszka };
49351b24e34SJan Kiszka 
49451b24e34SJan Kiszka struct kvm_coalesced_mmio_ring {
49551b24e34SJan Kiszka 	__u32 first, last;
49651b24e34SJan Kiszka 	struct kvm_coalesced_mmio coalesced_mmio[0];
49751b24e34SJan Kiszka };
49851b24e34SJan Kiszka 
49951b24e34SJan Kiszka #define KVM_COALESCED_MMIO_MAX \
50051b24e34SJan Kiszka 	((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \
50151b24e34SJan Kiszka 	 sizeof(struct kvm_coalesced_mmio))
50251b24e34SJan Kiszka 
50351b24e34SJan Kiszka /* for KVM_TRANSLATE */
50451b24e34SJan Kiszka struct kvm_translation {
50551b24e34SJan Kiszka 	/* in */
50651b24e34SJan Kiszka 	__u64 linear_address;
50751b24e34SJan Kiszka 
50851b24e34SJan Kiszka 	/* out */
50951b24e34SJan Kiszka 	__u64 physical_address;
51051b24e34SJan Kiszka 	__u8  valid;
51151b24e34SJan Kiszka 	__u8  writeable;
51251b24e34SJan Kiszka 	__u8  usermode;
51351b24e34SJan Kiszka 	__u8  pad[5];
51451b24e34SJan Kiszka };
51551b24e34SJan Kiszka 
5167a52ce8aSCornelia Huck /* for KVM_S390_MEM_OP */
5177a52ce8aSCornelia Huck struct kvm_s390_mem_op {
5187a52ce8aSCornelia Huck 	/* in */
5197a52ce8aSCornelia Huck 	__u64 gaddr;		/* the guest address */
5207a52ce8aSCornelia Huck 	__u64 flags;		/* flags */
5217a52ce8aSCornelia Huck 	__u32 size;		/* amount of bytes */
5227a52ce8aSCornelia Huck 	__u32 op;		/* type of operation */
5237a52ce8aSCornelia Huck 	__u64 buf;		/* buffer in userspace */
524dc6f8d45SCornelia Huck 	union {
5257a52ce8aSCornelia Huck 		__u8 ar;	/* the access register number */
526dc6f8d45SCornelia Huck 		__u32 sida_offset; /* offset into the sida */
527dc6f8d45SCornelia Huck 		__u8 reserved[32]; /* should be set to 0 */
528dc6f8d45SCornelia Huck 	};
5297a52ce8aSCornelia Huck };
5307a52ce8aSCornelia Huck /* types for kvm_s390_mem_op->op */
5317a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_READ	0
5327a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_WRITE	1
533dc6f8d45SCornelia Huck #define KVM_S390_MEMOP_SIDA_READ	2
534dc6f8d45SCornelia Huck #define KVM_S390_MEMOP_SIDA_WRITE	3
5357a52ce8aSCornelia Huck /* flags for kvm_s390_mem_op->flags */
5367a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_CHECK_ONLY		(1ULL << 0)
5377a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_INJECT_EXCEPTION	(1ULL << 1)
5387a52ce8aSCornelia Huck 
53951b24e34SJan Kiszka /* for KVM_INTERRUPT */
54051b24e34SJan Kiszka struct kvm_interrupt {
54151b24e34SJan Kiszka 	/* in */
54251b24e34SJan Kiszka 	__u32 irq;
54351b24e34SJan Kiszka };
54451b24e34SJan Kiszka 
54551b24e34SJan Kiszka /* for KVM_GET_DIRTY_LOG */
54651b24e34SJan Kiszka struct kvm_dirty_log {
54751b24e34SJan Kiszka 	__u32 slot;
54851b24e34SJan Kiszka 	__u32 padding1;
54951b24e34SJan Kiszka 	union {
55051b24e34SJan Kiszka 		void *dirty_bitmap; /* one bit per page */
55151b24e34SJan Kiszka 		__u64 padding2;
55251b24e34SJan Kiszka 	};
55351b24e34SJan Kiszka };
55451b24e34SJan Kiszka 
555da054c64SPaolo Bonzini /* for KVM_CLEAR_DIRTY_LOG */
556da054c64SPaolo Bonzini struct kvm_clear_dirty_log {
557da054c64SPaolo Bonzini 	__u32 slot;
558da054c64SPaolo Bonzini 	__u32 num_pages;
559da054c64SPaolo Bonzini 	__u64 first_page;
560da054c64SPaolo Bonzini 	union {
561da054c64SPaolo Bonzini 		void *dirty_bitmap; /* one bit per page */
562da054c64SPaolo Bonzini 		__u64 padding2;
563da054c64SPaolo Bonzini 	};
564da054c64SPaolo Bonzini };
565da054c64SPaolo Bonzini 
56651b24e34SJan Kiszka /* for KVM_SET_SIGNAL_MASK */
56751b24e34SJan Kiszka struct kvm_signal_mask {
56851b24e34SJan Kiszka 	__u32 len;
56951b24e34SJan Kiszka 	__u8  sigset[0];
57051b24e34SJan Kiszka };
57151b24e34SJan Kiszka 
57251b24e34SJan Kiszka /* for KVM_TPR_ACCESS_REPORTING */
57351b24e34SJan Kiszka struct kvm_tpr_access_ctl {
57451b24e34SJan Kiszka 	__u32 enabled;
57551b24e34SJan Kiszka 	__u32 flags;
57651b24e34SJan Kiszka 	__u32 reserved[8];
57751b24e34SJan Kiszka };
57851b24e34SJan Kiszka 
57951b24e34SJan Kiszka /* for KVM_SET_VAPIC_ADDR */
58051b24e34SJan Kiszka struct kvm_vapic_addr {
58151b24e34SJan Kiszka 	__u64 vapic_addr;
58251b24e34SJan Kiszka };
58351b24e34SJan Kiszka 
584a9fd1654SJens Freimann /* for KVM_SET_MP_STATE */
58551b24e34SJan Kiszka 
586a9fd1654SJens Freimann /* not all states are valid on all architectures */
58751b24e34SJan Kiszka #define KVM_MP_STATE_RUNNABLE          0
58851b24e34SJan Kiszka #define KVM_MP_STATE_UNINITIALIZED     1
58951b24e34SJan Kiszka #define KVM_MP_STATE_INIT_RECEIVED     2
59051b24e34SJan Kiszka #define KVM_MP_STATE_HALTED            3
59151b24e34SJan Kiszka #define KVM_MP_STATE_SIPI_RECEIVED     4
592a9fd1654SJens Freimann #define KVM_MP_STATE_STOPPED           5
593a9fd1654SJens Freimann #define KVM_MP_STATE_CHECK_STOP        6
594a9fd1654SJens Freimann #define KVM_MP_STATE_OPERATING         7
595a9fd1654SJens Freimann #define KVM_MP_STATE_LOAD              8
596*278f064eSEduardo Habkost #define KVM_MP_STATE_AP_RESET_HOLD     9
59751b24e34SJan Kiszka 
59851b24e34SJan Kiszka struct kvm_mp_state {
59951b24e34SJan Kiszka 	__u32 mp_state;
60051b24e34SJan Kiszka };
60151b24e34SJan Kiszka 
60251b24e34SJan Kiszka struct kvm_s390_psw {
60351b24e34SJan Kiszka 	__u64 mask;
60451b24e34SJan Kiszka 	__u64 addr;
60551b24e34SJan Kiszka };
60651b24e34SJan Kiszka 
60751b24e34SJan Kiszka /* valid values for type in kvm_s390_interrupt */
60851b24e34SJan Kiszka #define KVM_S390_SIGP_STOP		0xfffe0000u
60951b24e34SJan Kiszka #define KVM_S390_PROGRAM_INT		0xfffe0001u
61051b24e34SJan Kiszka #define KVM_S390_SIGP_SET_PREFIX	0xfffe0002u
61151b24e34SJan Kiszka #define KVM_S390_RESTART		0xfffe0003u
612216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_INIT	0xfffe0004u
613216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_DONE	0xfffe0005u
614d3dccee1SAlexander Graf #define KVM_S390_MCHK			0xfffe1000u
61576eb98d5SJens Freimann #define KVM_S390_INT_CLOCK_COMP		0xffff1004u
61676eb98d5SJens Freimann #define KVM_S390_INT_CPU_TIMER		0xffff1005u
61751b24e34SJan Kiszka #define KVM_S390_INT_VIRTIO		0xffff2603u
61851b24e34SJan Kiszka #define KVM_S390_INT_SERVICE		0xffff2401u
61951b24e34SJan Kiszka #define KVM_S390_INT_EMERGENCY		0xffff1201u
6201529ae1bSAlexander Graf #define KVM_S390_INT_EXTERNAL_CALL	0xffff1202u
621d3dccee1SAlexander Graf /* Anything below 0xfffe0000u is taken by INT_IO */
622d3dccee1SAlexander Graf #define KVM_S390_INT_IO(ai,cssid,ssid,schid)   \
623d3dccee1SAlexander Graf 	(((schid)) |			       \
624d3dccee1SAlexander Graf 	 ((ssid) << 16) |		       \
625d3dccee1SAlexander Graf 	 ((cssid) << 18) |		       \
626d3dccee1SAlexander Graf 	 ((ai) << 26))
627d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MIN		0x00000000u
628d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MAX		0xfffdffffu
629120758fbSPaolo Bonzini #define KVM_S390_INT_IO_AI_MASK		0x04000000u
630d3dccee1SAlexander Graf 
63151b24e34SJan Kiszka 
63251b24e34SJan Kiszka struct kvm_s390_interrupt {
63351b24e34SJan Kiszka 	__u32 type;
63451b24e34SJan Kiszka 	__u32 parm;
63551b24e34SJan Kiszka 	__u64 parm64;
63651b24e34SJan Kiszka };
63751b24e34SJan Kiszka 
638216db403SChristian Borntraeger struct kvm_s390_io_info {
639216db403SChristian Borntraeger 	__u16 subchannel_id;
640216db403SChristian Borntraeger 	__u16 subchannel_nr;
641216db403SChristian Borntraeger 	__u32 io_int_parm;
642216db403SChristian Borntraeger 	__u32 io_int_word;
643216db403SChristian Borntraeger };
644216db403SChristian Borntraeger 
645216db403SChristian Borntraeger struct kvm_s390_ext_info {
646216db403SChristian Borntraeger 	__u32 ext_params;
647216db403SChristian Borntraeger 	__u32 pad;
648216db403SChristian Borntraeger 	__u64 ext_params2;
649216db403SChristian Borntraeger };
650216db403SChristian Borntraeger 
651216db403SChristian Borntraeger struct kvm_s390_pgm_info {
652216db403SChristian Borntraeger 	__u64 trans_exc_code;
653216db403SChristian Borntraeger 	__u64 mon_code;
654216db403SChristian Borntraeger 	__u64 per_address;
655216db403SChristian Borntraeger 	__u32 data_exc_code;
656216db403SChristian Borntraeger 	__u16 code;
657216db403SChristian Borntraeger 	__u16 mon_class_nr;
658216db403SChristian Borntraeger 	__u8 per_code;
659216db403SChristian Borntraeger 	__u8 per_atmid;
660216db403SChristian Borntraeger 	__u8 exc_access_id;
661216db403SChristian Borntraeger 	__u8 per_access_id;
662216db403SChristian Borntraeger 	__u8 op_access_id;
66366fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_VALID	0x01
66466fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_0	0x02
66566fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_1	0x04
66666fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_MASK	0x06
66766fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_NO_REWIND	0x08
66866fb2d54SCornelia Huck 	__u8 flags;
66966fb2d54SCornelia Huck 	__u8 pad[2];
670216db403SChristian Borntraeger };
671216db403SChristian Borntraeger 
672216db403SChristian Borntraeger struct kvm_s390_prefix_info {
673216db403SChristian Borntraeger 	__u32 address;
674216db403SChristian Borntraeger };
675216db403SChristian Borntraeger 
676216db403SChristian Borntraeger struct kvm_s390_extcall_info {
677216db403SChristian Borntraeger 	__u16 code;
678216db403SChristian Borntraeger };
679216db403SChristian Borntraeger 
680216db403SChristian Borntraeger struct kvm_s390_emerg_info {
681216db403SChristian Borntraeger 	__u16 code;
682216db403SChristian Borntraeger };
683216db403SChristian Borntraeger 
68451628b18SChristian Borntraeger #define KVM_S390_STOP_FLAG_STORE_STATUS	0x01
68551628b18SChristian Borntraeger struct kvm_s390_stop_info {
68651628b18SChristian Borntraeger 	__u32 flags;
68751628b18SChristian Borntraeger };
68851628b18SChristian Borntraeger 
689216db403SChristian Borntraeger struct kvm_s390_mchk_info {
690216db403SChristian Borntraeger 	__u64 cr14;
691216db403SChristian Borntraeger 	__u64 mcic;
692216db403SChristian Borntraeger 	__u64 failing_storage_address;
693216db403SChristian Borntraeger 	__u32 ext_damage_code;
694216db403SChristian Borntraeger 	__u32 pad;
695216db403SChristian Borntraeger 	__u8 fixed_logout[16];
696216db403SChristian Borntraeger };
697216db403SChristian Borntraeger 
698216db403SChristian Borntraeger struct kvm_s390_irq {
699216db403SChristian Borntraeger 	__u64 type;
700216db403SChristian Borntraeger 	union {
701216db403SChristian Borntraeger 		struct kvm_s390_io_info io;
702216db403SChristian Borntraeger 		struct kvm_s390_ext_info ext;
703216db403SChristian Borntraeger 		struct kvm_s390_pgm_info pgm;
704216db403SChristian Borntraeger 		struct kvm_s390_emerg_info emerg;
705216db403SChristian Borntraeger 		struct kvm_s390_extcall_info extcall;
706216db403SChristian Borntraeger 		struct kvm_s390_prefix_info prefix;
70751628b18SChristian Borntraeger 		struct kvm_s390_stop_info stop;
708216db403SChristian Borntraeger 		struct kvm_s390_mchk_info mchk;
709216db403SChristian Borntraeger 		char reserved[64];
710216db403SChristian Borntraeger 	} u;
711216db403SChristian Borntraeger };
712216db403SChristian Borntraeger 
7137a52ce8aSCornelia Huck struct kvm_s390_irq_state {
7147a52ce8aSCornelia Huck 	__u64 buf;
7159cbb6362SCornelia Huck 	__u32 flags;        /* will stay unused for compatibility reasons */
7167a52ce8aSCornelia Huck 	__u32 len;
7179cbb6362SCornelia Huck 	__u32 reserved[4];  /* will stay unused for compatibility reasons */
7187a52ce8aSCornelia Huck };
7197a52ce8aSCornelia Huck 
72051b24e34SJan Kiszka /* for KVM_SET_GUEST_DEBUG */
72151b24e34SJan Kiszka 
72251b24e34SJan Kiszka #define KVM_GUESTDBG_ENABLE		0x00000001
72351b24e34SJan Kiszka #define KVM_GUESTDBG_SINGLESTEP		0x00000002
72451b24e34SJan Kiszka 
72551b24e34SJan Kiszka struct kvm_guest_debug {
72651b24e34SJan Kiszka 	__u32 control;
72751b24e34SJan Kiszka 	__u32 pad;
72851b24e34SJan Kiszka 	struct kvm_guest_debug_arch arch;
72951b24e34SJan Kiszka };
73051b24e34SJan Kiszka 
73151b24e34SJan Kiszka enum {
73251b24e34SJan Kiszka 	kvm_ioeventfd_flag_nr_datamatch,
73351b24e34SJan Kiszka 	kvm_ioeventfd_flag_nr_pio,
73451b24e34SJan Kiszka 	kvm_ioeventfd_flag_nr_deassign,
735cae7f586SAlexander Graf 	kvm_ioeventfd_flag_nr_virtio_ccw_notify,
73676eb98d5SJens Freimann 	kvm_ioeventfd_flag_nr_fast_mmio,
73751b24e34SJan Kiszka 	kvm_ioeventfd_flag_nr_max,
73851b24e34SJan Kiszka };
73951b24e34SJan Kiszka 
74051b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
74151b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_PIO       (1 << kvm_ioeventfd_flag_nr_pio)
74251b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DEASSIGN  (1 << kvm_ioeventfd_flag_nr_deassign)
743cae7f586SAlexander Graf #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \
744cae7f586SAlexander Graf 	(1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify)
74551b24e34SJan Kiszka 
74651b24e34SJan Kiszka #define KVM_IOEVENTFD_VALID_FLAG_MASK  ((1 << kvm_ioeventfd_flag_nr_max) - 1)
74751b24e34SJan Kiszka 
74851b24e34SJan Kiszka struct kvm_ioeventfd {
74951b24e34SJan Kiszka 	__u64 datamatch;
75051b24e34SJan Kiszka 	__u64 addr;        /* legal pio/mmio address */
75176eb98d5SJens Freimann 	__u32 len;         /* 1, 2, 4, or 8 bytes; or 0 to ignore length */
75251b24e34SJan Kiszka 	__s32 fd;
75351b24e34SJan Kiszka 	__u32 flags;
75451b24e34SJan Kiszka 	__u8  pad[36];
75551b24e34SJan Kiszka };
75651b24e34SJan Kiszka 
75765a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_MWAIT          (1 << 0)
75877d361b1SEric Auger #define KVM_X86_DISABLE_EXITS_HLT            (1 << 1)
75965a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_PAUSE          (1 << 2)
760d38d201fSWanpeng Li #define KVM_X86_DISABLE_EXITS_CSTATE         (1 << 3)
76165a6d8ddSPeter Maydell #define KVM_X86_DISABLE_VALID_EXITS          (KVM_X86_DISABLE_EXITS_MWAIT | \
76277d361b1SEric Auger                                               KVM_X86_DISABLE_EXITS_HLT | \
763d38d201fSWanpeng Li                                               KVM_X86_DISABLE_EXITS_PAUSE | \
764d38d201fSWanpeng Li                                               KVM_X86_DISABLE_EXITS_CSTATE)
76565a6d8ddSPeter Maydell 
76651b24e34SJan Kiszka /* for KVM_ENABLE_CAP */
76751b24e34SJan Kiszka struct kvm_enable_cap {
76851b24e34SJan Kiszka 	/* in */
76951b24e34SJan Kiszka 	__u32 cap;
77051b24e34SJan Kiszka 	__u32 flags;
77151b24e34SJan Kiszka 	__u64 args[4];
77251b24e34SJan Kiszka 	__u8  pad[64];
77351b24e34SJan Kiszka };
77451b24e34SJan Kiszka 
77551b24e34SJan Kiszka /* for KVM_PPC_GET_PVINFO */
7763a5eb5b4SPaolo Bonzini 
7773a5eb5b4SPaolo Bonzini #define KVM_PPC_PVINFO_FLAGS_EV_IDLE   (1<<0)
7783a5eb5b4SPaolo Bonzini 
77951b24e34SJan Kiszka struct kvm_ppc_pvinfo {
78051b24e34SJan Kiszka 	/* out */
78151b24e34SJan Kiszka 	__u32 flags;
78251b24e34SJan Kiszka 	__u32 hcall[4];
78351b24e34SJan Kiszka 	__u8  pad[108];
78451b24e34SJan Kiszka };
78551b24e34SJan Kiszka 
78680a3eb10SJan Kiszka /* for KVM_PPC_GET_SMMU_INFO */
78780a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_MAX_SZ	8
78880a3eb10SJan Kiszka 
78980a3eb10SJan Kiszka struct kvm_ppc_one_page_size {
79080a3eb10SJan Kiszka 	__u32 page_shift;	/* Page shift (or 0) */
79180a3eb10SJan Kiszka 	__u32 pte_enc;		/* Encoding in the HPTE (>>12) */
79280a3eb10SJan Kiszka };
79380a3eb10SJan Kiszka 
79480a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size {
79580a3eb10SJan Kiszka 	__u32 page_shift;	/* Base page shift of segment (or 0) */
79680a3eb10SJan Kiszka 	__u32 slb_enc;		/* SLB encoding for BookS */
79780a3eb10SJan Kiszka 	struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ];
79880a3eb10SJan Kiszka };
79980a3eb10SJan Kiszka 
80080a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_REAL		0x00000001
80180a3eb10SJan Kiszka #define KVM_PPC_1T_SEGMENTS		0x00000002
802966f2ec3SPaolo Bonzini #define KVM_PPC_NO_HASH			0x00000004
80380a3eb10SJan Kiszka 
80480a3eb10SJan Kiszka struct kvm_ppc_smmu_info {
80580a3eb10SJan Kiszka 	__u64 flags;
80680a3eb10SJan Kiszka 	__u32 slb_size;
807d4083f50SAlexey Perevalov 	__u16 data_keys;	/* # storage keys supported for data */
808d4083f50SAlexey Perevalov 	__u16 instr_keys;	/* # storage keys supported for instructions */
80980a3eb10SJan Kiszka 	struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
81080a3eb10SJan Kiszka };
81180a3eb10SJan Kiszka 
8123a5eb5b4SPaolo Bonzini /* for KVM_PPC_RESIZE_HPT_{PREPARE,COMMIT} */
8133a5eb5b4SPaolo Bonzini struct kvm_ppc_resize_hpt {
8143a5eb5b4SPaolo Bonzini 	__u64 flags;
8153a5eb5b4SPaolo Bonzini 	__u32 shift;
8163a5eb5b4SPaolo Bonzini 	__u32 pad;
8173a5eb5b4SPaolo Bonzini };
818d4834ff9SAlexander Graf 
81951b24e34SJan Kiszka #define KVMIO 0xAE
82051b24e34SJan Kiszka 
8211529ae1bSAlexander Graf /* machine type bits, to be used as argument to KVM_CREATE_VM */
8221529ae1bSAlexander Graf #define KVM_VM_S390_UCONTROL	1
8231529ae1bSAlexander Graf 
824bf63839fSAlex Williamson /* on ppc, 0 indicate default, 1 should force HV and 2 PR */
825bf63839fSAlex Williamson #define KVM_VM_PPC_HV 1
826bf63839fSAlex Williamson #define KVM_VM_PPC_PR 2
827bf63839fSAlex Williamson 
82894c7fefcSAndrew Jones /* on MIPS, 0 indicates auto, 1 forces VZ ASE, 2 forces trap & emulate */
82994c7fefcSAndrew Jones #define KVM_VM_MIPS_AUTO	0
83074c98e20SCornelia Huck #define KVM_VM_MIPS_VZ		1
83194c7fefcSAndrew Jones #define KVM_VM_MIPS_TE		2
83274c98e20SCornelia Huck 
8331529ae1bSAlexander Graf #define KVM_S390_SIE_PAGE_OFFSET 1
8341529ae1bSAlexander Graf 
83551b24e34SJan Kiszka /*
836da054c64SPaolo Bonzini  * On arm64, machine type can be used to request the physical
837da054c64SPaolo Bonzini  * address size for the VM. Bits[7-0] are reserved for the guest
838da054c64SPaolo Bonzini  * PA size shift (i.e, log2(PA_Size)). For backward compatibility,
839da054c64SPaolo Bonzini  * value 0 implies the default IPA size, 40bits.
840da054c64SPaolo Bonzini  */
841da054c64SPaolo Bonzini #define KVM_VM_TYPE_ARM_IPA_SIZE_MASK	0xffULL
842da054c64SPaolo Bonzini #define KVM_VM_TYPE_ARM_IPA_SIZE(x)		\
843da054c64SPaolo Bonzini 	((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK)
844da054c64SPaolo Bonzini /*
84551b24e34SJan Kiszka  * ioctls for /dev/kvm fds:
84651b24e34SJan Kiszka  */
84751b24e34SJan Kiszka #define KVM_GET_API_VERSION       _IO(KVMIO,   0x00)
84851b24e34SJan Kiszka #define KVM_CREATE_VM             _IO(KVMIO,   0x01) /* returns a VM fd */
84951b24e34SJan Kiszka #define KVM_GET_MSR_INDEX_LIST    _IOWR(KVMIO, 0x02, struct kvm_msr_list)
85051b24e34SJan Kiszka 
85151b24e34SJan Kiszka #define KVM_S390_ENABLE_SIE       _IO(KVMIO,   0x06)
85251b24e34SJan Kiszka /*
85351b24e34SJan Kiszka  * Check if a kvm extension is available.  Argument is extension number,
85451b24e34SJan Kiszka  * return is 1 (yes) or 0 (no, sorry).
85551b24e34SJan Kiszka  */
85651b24e34SJan Kiszka #define KVM_CHECK_EXTENSION       _IO(KVMIO,   0x03)
85751b24e34SJan Kiszka /*
85851b24e34SJan Kiszka  * Get size for mmap(vcpu_fd)
85951b24e34SJan Kiszka  */
86051b24e34SJan Kiszka #define KVM_GET_VCPU_MMAP_SIZE    _IO(KVMIO,   0x04) /* in bytes */
86151b24e34SJan Kiszka #define KVM_GET_SUPPORTED_CPUID   _IOWR(KVMIO, 0x05, struct kvm_cpuid2)
86251b24e34SJan Kiszka #define KVM_TRACE_ENABLE          __KVM_DEPRECATED_MAIN_W_0x06
86351b24e34SJan Kiszka #define KVM_TRACE_PAUSE           __KVM_DEPRECATED_MAIN_0x07
86451b24e34SJan Kiszka #define KVM_TRACE_DISABLE         __KVM_DEPRECATED_MAIN_0x08
865bf63839fSAlex Williamson #define KVM_GET_EMULATED_CPUID	  _IOWR(KVMIO, 0x09, struct kvm_cpuid2)
8669f2d175dSPaolo Bonzini #define KVM_GET_MSR_FEATURE_INDEX_LIST    _IOWR(KVMIO, 0x0a, struct kvm_msr_list)
86751b24e34SJan Kiszka 
86851b24e34SJan Kiszka /*
86951b24e34SJan Kiszka  * Extension capability list.
87051b24e34SJan Kiszka  */
87151b24e34SJan Kiszka #define KVM_CAP_IRQCHIP	  0
87251b24e34SJan Kiszka #define KVM_CAP_HLT	  1
87351b24e34SJan Kiszka #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2
87451b24e34SJan Kiszka #define KVM_CAP_USER_MEMORY 3
87551b24e34SJan Kiszka #define KVM_CAP_SET_TSS_ADDR 4
87651b24e34SJan Kiszka #define KVM_CAP_VAPIC 6
87751b24e34SJan Kiszka #define KVM_CAP_EXT_CPUID 7
87851b24e34SJan Kiszka #define KVM_CAP_CLOCKSOURCE 8
8797c6da3deSAlexander Graf #define KVM_CAP_NR_VCPUS 9       /* returns recommended max vcpus per vm */
88051b24e34SJan Kiszka #define KVM_CAP_NR_MEMSLOTS 10   /* returns max memory slots per vm */
88151b24e34SJan Kiszka #define KVM_CAP_PIT 11
88251b24e34SJan Kiszka #define KVM_CAP_NOP_IO_DELAY 12
88351b24e34SJan Kiszka #define KVM_CAP_PV_MMU 13
88451b24e34SJan Kiszka #define KVM_CAP_MP_STATE 14
88551b24e34SJan Kiszka #define KVM_CAP_COALESCED_MMIO 15
88651b24e34SJan Kiszka #define KVM_CAP_SYNC_MMU 16  /* Changes to host mmap are reflected in guest */
88751b24e34SJan Kiszka #define KVM_CAP_IOMMU 18
88851b24e34SJan Kiszka /* Bug in KVM_SET_USER_MEMORY_REGION fixed: */
88951b24e34SJan Kiszka #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21
89051b24e34SJan Kiszka #define KVM_CAP_USER_NMI 22
89151b24e34SJan Kiszka #ifdef __KVM_HAVE_GUEST_DEBUG
89251b24e34SJan Kiszka #define KVM_CAP_SET_GUEST_DEBUG 23
89351b24e34SJan Kiszka #endif
89451b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT
89551b24e34SJan Kiszka #define KVM_CAP_REINJECT_CONTROL 24
89651b24e34SJan Kiszka #endif
89751b24e34SJan Kiszka #define KVM_CAP_IRQ_ROUTING 25
89851b24e34SJan Kiszka #define KVM_CAP_IRQ_INJECT_STATUS 26
89951b24e34SJan Kiszka #define KVM_CAP_ASSIGN_DEV_IRQ 29
90051b24e34SJan Kiszka /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */
90151b24e34SJan Kiszka #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30
90251b24e34SJan Kiszka #ifdef __KVM_HAVE_MCE
90351b24e34SJan Kiszka #define KVM_CAP_MCE 31
90451b24e34SJan Kiszka #endif
90551b24e34SJan Kiszka #define KVM_CAP_IRQFD 32
90651b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT
90751b24e34SJan Kiszka #define KVM_CAP_PIT2 33
90851b24e34SJan Kiszka #endif
90951b24e34SJan Kiszka #define KVM_CAP_SET_BOOT_CPU_ID 34
91051b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT_STATE2
91151b24e34SJan Kiszka #define KVM_CAP_PIT_STATE2 35
91251b24e34SJan Kiszka #endif
91351b24e34SJan Kiszka #define KVM_CAP_IOEVENTFD 36
91451b24e34SJan Kiszka #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37
91551b24e34SJan Kiszka #ifdef __KVM_HAVE_XEN_HVM
91651b24e34SJan Kiszka #define KVM_CAP_XEN_HVM 38
91751b24e34SJan Kiszka #endif
91851b24e34SJan Kiszka #define KVM_CAP_ADJUST_CLOCK 39
91951b24e34SJan Kiszka #define KVM_CAP_INTERNAL_ERROR_DATA 40
92051b24e34SJan Kiszka #ifdef __KVM_HAVE_VCPU_EVENTS
92151b24e34SJan Kiszka #define KVM_CAP_VCPU_EVENTS 41
92251b24e34SJan Kiszka #endif
92351b24e34SJan Kiszka #define KVM_CAP_S390_PSW 42
92451b24e34SJan Kiszka #define KVM_CAP_PPC_SEGSTATE 43
92551b24e34SJan Kiszka #define KVM_CAP_HYPERV 44
92651b24e34SJan Kiszka #define KVM_CAP_HYPERV_VAPIC 45
92751b24e34SJan Kiszka #define KVM_CAP_HYPERV_SPIN 46
92851b24e34SJan Kiszka #define KVM_CAP_PCI_SEGMENT 47
92951b24e34SJan Kiszka #define KVM_CAP_PPC_PAIRED_SINGLES 48
93051b24e34SJan Kiszka #define KVM_CAP_INTR_SHADOW 49
93151b24e34SJan Kiszka #ifdef __KVM_HAVE_DEBUGREGS
93251b24e34SJan Kiszka #define KVM_CAP_DEBUGREGS 50
93351b24e34SJan Kiszka #endif
93451b24e34SJan Kiszka #define KVM_CAP_X86_ROBUST_SINGLESTEP 51
93551b24e34SJan Kiszka #define KVM_CAP_PPC_OSI 52
93651b24e34SJan Kiszka #define KVM_CAP_PPC_UNSET_IRQ 53
93751b24e34SJan Kiszka #define KVM_CAP_ENABLE_CAP 54
93851b24e34SJan Kiszka #ifdef __KVM_HAVE_XSAVE
93951b24e34SJan Kiszka #define KVM_CAP_XSAVE 55
94051b24e34SJan Kiszka #endif
94151b24e34SJan Kiszka #ifdef __KVM_HAVE_XCRS
94251b24e34SJan Kiszka #define KVM_CAP_XCRS 56
94351b24e34SJan Kiszka #endif
94451b24e34SJan Kiszka #define KVM_CAP_PPC_GET_PVINFO 57
94551b24e34SJan Kiszka #define KVM_CAP_PPC_IRQ_LEVEL 58
94651b24e34SJan Kiszka #define KVM_CAP_ASYNC_PF 59
94751b24e34SJan Kiszka #define KVM_CAP_TSC_CONTROL 60
94851b24e34SJan Kiszka #define KVM_CAP_GET_TSC_KHZ 61
94951b24e34SJan Kiszka #define KVM_CAP_PPC_BOOKE_SREGS 62
9507c6da3deSAlexander Graf #define KVM_CAP_SPAPR_TCE 63
9517c6da3deSAlexander Graf #define KVM_CAP_PPC_SMT 64
9527c6da3deSAlexander Graf #define KVM_CAP_PPC_RMA	65
9537c6da3deSAlexander Graf #define KVM_CAP_MAX_VCPUS 66       /* returns max vcpus per vm */
9549d4e4f8cSAlexander Graf #define KVM_CAP_PPC_HIOR 67
9557c6da3deSAlexander Graf #define KVM_CAP_PPC_PAPR 68
956a54fc080SAlexander Graf #define KVM_CAP_SW_TLB 69
9579d4e4f8cSAlexander Graf #define KVM_CAP_ONE_REG 70
9581529ae1bSAlexander Graf #define KVM_CAP_S390_GMAP 71
9591529ae1bSAlexander Graf #define KVM_CAP_TSC_DEADLINE_TIMER 72
9601529ae1bSAlexander Graf #define KVM_CAP_S390_UCONTROL 73
9611529ae1bSAlexander Graf #define KVM_CAP_SYNC_REGS 74
9629ab2195dSMarcelo Tosatti #define KVM_CAP_PCI_2_3 75
9639ab2195dSMarcelo Tosatti #define KVM_CAP_KVMCLOCK_CTRL 76
96480a3eb10SJan Kiszka #define KVM_CAP_SIGNAL_MSI 77
96580a3eb10SJan Kiszka #define KVM_CAP_PPC_GET_SMMU_INFO 78
9662a60dba4SAlexander Graf #define KVM_CAP_S390_COW 79
967651682dcSMichael S. Tsirkin #define KVM_CAP_PPC_ALLOC_HTAB 80
968716b8e4dSAlex Williamson #define KVM_CAP_READONLY_MEM 81
969716b8e4dSAlex Williamson #define KVM_CAP_IRQFD_RESAMPLE 82
970d4834ff9SAlexander Graf #define KVM_CAP_PPC_BOOKE_WATCHDOG 83
971d4834ff9SAlexander Graf #define KVM_CAP_PPC_HTAB_FD 84
972d3dccee1SAlexander Graf #define KVM_CAP_S390_CSS_SUPPORT 85
973d3dccee1SAlexander Graf #define KVM_CAP_PPC_EPR 86
974eadd0e44SPeter Maydell #define KVM_CAP_ARM_PSCI 87
975eadd0e44SPeter Maydell #define KVM_CAP_ARM_SET_DEVICE_ADDR 88
976e098b453SAlexey Kardashevskiy #define KVM_CAP_DEVICE_CTRL 89
977e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_MPIC 90
978e098b453SAlexey Kardashevskiy #define KVM_CAP_PPC_RTAS 91
979e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_XICS 92
980c5daeae1SAlexey Kardashevskiy #define KVM_CAP_ARM_EL1_32BIT 93
9814f265607SAndrew Jones #define KVM_CAP_SPAPR_MULTITCE 94
982bf63839fSAlex Williamson #define KVM_CAP_EXT_EMUL_CPUID 95
98348a5f3bcSVadim Rozenfeld #define KVM_CAP_HYPERV_TIME 96
9849ffd2685SCornelia Huck #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97
9859ffd2685SCornelia Huck #define KVM_CAP_ENABLE_CAP_VM 98
9869ffd2685SCornelia Huck #define KVM_CAP_S390_IRQCHIP 99
98776eb98d5SJens Freimann #define KVM_CAP_IOEVENTFD_NO_LENGTH 100
98876eb98d5SJens Freimann #define KVM_CAP_VM_ATTRIBUTES 101
989b061808dSAlexander Graf #define KVM_CAP_ARM_PSCI_0_2 102
990b061808dSAlexander Graf #define KVM_CAP_PPC_FIXUP_HCALL 103
991a9fd1654SJens Freimann #define KVM_CAP_PPC_ENABLE_HCALL 104
992a9fd1654SJens Freimann #define KVM_CAP_CHECK_EXTENSION_VM 105
99351628b18SChristian Borntraeger #define KVM_CAP_S390_USER_SIGP 106
9947a52ce8aSCornelia Huck #define KVM_CAP_S390_VECTOR_REGISTERS 107
9957a52ce8aSCornelia Huck #define KVM_CAP_S390_MEM_OP 108
9967a52ce8aSCornelia Huck #define KVM_CAP_S390_USER_STSI 109
9977a52ce8aSCornelia Huck #define KVM_CAP_S390_SKEYS 110
9987a52ce8aSCornelia Huck #define KVM_CAP_MIPS_FPU 111
9997a52ce8aSCornelia Huck #define KVM_CAP_MIPS_MSA 112
10007a52ce8aSCornelia Huck #define KVM_CAP_S390_INJECT_IRQ 113
10017a52ce8aSCornelia Huck #define KVM_CAP_S390_IRQ_STATE 114
10027a52ce8aSCornelia Huck #define KVM_CAP_PPC_HWRNG 115
100324a31426SPaolo Bonzini #define KVM_CAP_DISABLE_QUIRKS 116
100424a31426SPaolo Bonzini #define KVM_CAP_X86_SMM 117
100524a31426SPaolo Bonzini #define KVM_CAP_MULTI_ADDRESS_SPACE 118
10063a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_BPS 119
10073a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_WPS 120
10083a824b15SPaolo Bonzini #define KVM_CAP_SPLIT_IRQCHIP 121
10093a824b15SPaolo Bonzini #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122
1010fff02bc0SPaolo Bonzini #define KVM_CAP_HYPERV_SYNIC 123
101166fb2d54SCornelia Huck #define KVM_CAP_S390_RI 124
1012b89485a5SPaolo Bonzini #define KVM_CAP_SPAPR_TCE_64 125
1013b89485a5SPaolo Bonzini #define KVM_CAP_ARM_PMU_V3 126
1014b89485a5SPaolo Bonzini #define KVM_CAP_VCPU_ATTRIBUTES 127
1015ff804f15SCornelia Huck #define KVM_CAP_MAX_VCPU_ID 128
1016dbdfea92SCornelia Huck #define KVM_CAP_X2APIC_API 129
1017dbdfea92SCornelia Huck #define KVM_CAP_S390_USER_INSTR0 130
1018dbdfea92SCornelia Huck #define KVM_CAP_MSI_DEVID 131
1019dbdfea92SCornelia Huck #define KVM_CAP_PPC_HTM 132
10203a5eb5b4SPaolo Bonzini #define KVM_CAP_SPAPR_RESIZE_HPT 133
10213a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_RADIX 134
10223a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_HASH_V3 135
10233a5eb5b4SPaolo Bonzini #define KVM_CAP_IMMEDIATE_EXIT 136
102474c98e20SCornelia Huck #define KVM_CAP_MIPS_VZ 137
102574c98e20SCornelia Huck #define KVM_CAP_MIPS_TE 138
102674c98e20SCornelia Huck #define KVM_CAP_MIPS_64BIT 139
102774c98e20SCornelia Huck #define KVM_CAP_S390_GS 140
102874c98e20SCornelia Huck #define KVM_CAP_S390_AIS 141
102974c98e20SCornelia Huck #define KVM_CAP_SPAPR_TCE_VFIO 142
103065a6d8ddSPeter Maydell #define KVM_CAP_X86_DISABLE_EXITS 143
103174c98e20SCornelia Huck #define KVM_CAP_ARM_USER_IRQ 144
10323272f0e2SChristian Borntraeger #define KVM_CAP_S390_CMMA_MIGRATION 145
10333272f0e2SChristian Borntraeger #define KVM_CAP_PPC_FWNMI 146
10343272f0e2SChristian Borntraeger #define KVM_CAP_PPC_SMT_POSSIBLE 147
1035ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_SYNIC2 148
1036ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_VP_INDEX 149
1037dd873966SEric Auger #define KVM_CAP_S390_AIS_MIGRATION 150
10389cbb6362SCornelia Huck #define KVM_CAP_PPC_GET_CPU_CHAR 151
10399cbb6362SCornelia Huck #define KVM_CAP_S390_BPB 152
10409f2d175dSPaolo Bonzini #define KVM_CAP_GET_MSR_FEATURES 153
104165a6d8ddSPeter Maydell #define KVM_CAP_HYPERV_EVENTFD 154
104277d361b1SEric Auger #define KVM_CAP_HYPERV_TLBFLUSH 155
1043d36f7de8SCornelia Huck #define KVM_CAP_S390_HPAGE_1M 156
1044d36f7de8SCornelia Huck #define KVM_CAP_NESTED_STATE 157
10458f3cd250SCornelia Huck #define KVM_CAP_ARM_INJECT_SERROR_ESR 158
10468f3cd250SCornelia Huck #define KVM_CAP_MSR_PLATFORM_INFO 159
1047966f2ec3SPaolo Bonzini #define KVM_CAP_PPC_NESTED_HV 160
1048966f2ec3SPaolo Bonzini #define KVM_CAP_HYPERV_SEND_IPI 161
1049966f2ec3SPaolo Bonzini #define KVM_CAP_COALESCED_PIO 162
1050966f2ec3SPaolo Bonzini #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163
1051966f2ec3SPaolo Bonzini #define KVM_CAP_EXCEPTION_PAYLOAD 164
1052da054c64SPaolo Bonzini #define KVM_CAP_ARM_VM_IPA_SIZE 165
1053d9cb4336SCornelia Huck #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166 /* Obsolete */
1054da054c64SPaolo Bonzini #define KVM_CAP_HYPERV_CPUID 167
1055d9cb4336SCornelia Huck #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 168
1056d9cb4336SCornelia Huck #define KVM_CAP_PPC_IRQ_XIVE 169
1057d9cb4336SCornelia Huck #define KVM_CAP_ARM_SVE 170
1058d9cb4336SCornelia Huck #define KVM_CAP_ARM_PTRAUTH_ADDRESS 171
1059d9cb4336SCornelia Huck #define KVM_CAP_ARM_PTRAUTH_GENERIC 172
1060f363d039SEric Auger #define KVM_CAP_PMU_EVENT_FILTER 173
1061f363d039SEric Auger #define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174
1062f363d039SEric Auger #define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175
10632a886794SGreg Kurz #define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 176
10642a886794SGreg Kurz #define KVM_CAP_ARM_NISV_TO_USER 177
10652a886794SGreg Kurz #define KVM_CAP_ARM_INJECT_EXT_DABT 178
1066ddda3748SCornelia Huck #define KVM_CAP_S390_VCPU_RESETS 179
1067dc6f8d45SCornelia Huck #define KVM_CAP_S390_PROTECTED 180
1068dc6f8d45SCornelia Huck #define KVM_CAP_PPC_SECURE_GUEST 181
1069f76b348eSCornelia Huck #define KVM_CAP_HALT_POLL 182
1070f76b348eSCornelia Huck #define KVM_CAP_ASYNC_PF_INT 183
1071e6546342SJason Wang #define KVM_CAP_LAST_CPU 184
1072e6546342SJason Wang #define KVM_CAP_SMALLER_MAXPHYADDR 185
1073e6546342SJason Wang #define KVM_CAP_S390_DIAG318 186
107494c7fefcSAndrew Jones #define KVM_CAP_STEAL_TIME 187
107553ba2eeeSMatthew Rosato #define KVM_CAP_X86_USER_SPACE_MSR 188
107653ba2eeeSMatthew Rosato #define KVM_CAP_X86_MSR_FILTER 189
107753ba2eeeSMatthew Rosato #define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190
1078b3c818a4SEric Farman #define KVM_CAP_SYS_HYPERV_CPUID 191
1079b3c818a4SEric Farman #define KVM_CAP_DIRTY_LOG_RING 192
1080*278f064eSEduardo Habkost #define KVM_CAP_X86_BUS_LOCK_EXIT 193
1081*278f064eSEduardo Habkost #define KVM_CAP_PPC_DAWR1 194
1082*278f064eSEduardo Habkost #define KVM_CAP_SET_GUEST_DEBUG2 195
1083*278f064eSEduardo Habkost #define KVM_CAP_SGX_ATTRIBUTE 196
1084*278f064eSEduardo Habkost #define KVM_CAP_VM_COPY_ENC_CONTEXT_FROM 197
1085*278f064eSEduardo Habkost #define KVM_CAP_PTP_KVM 198
108651b24e34SJan Kiszka 
108751b24e34SJan Kiszka #ifdef KVM_CAP_IRQ_ROUTING
108851b24e34SJan Kiszka 
108951b24e34SJan Kiszka struct kvm_irq_routing_irqchip {
109051b24e34SJan Kiszka 	__u32 irqchip;
109151b24e34SJan Kiszka 	__u32 pin;
109251b24e34SJan Kiszka };
109351b24e34SJan Kiszka 
109451b24e34SJan Kiszka struct kvm_irq_routing_msi {
109551b24e34SJan Kiszka 	__u32 address_lo;
109651b24e34SJan Kiszka 	__u32 address_hi;
109751b24e34SJan Kiszka 	__u32 data;
1098dbdfea92SCornelia Huck 	union {
109951b24e34SJan Kiszka 		__u32 pad;
1100dbdfea92SCornelia Huck 		__u32 devid;
1101dbdfea92SCornelia Huck 	};
110251b24e34SJan Kiszka };
110351b24e34SJan Kiszka 
11049ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter {
11059ffd2685SCornelia Huck 	__u64 ind_addr;
11069ffd2685SCornelia Huck 	__u64 summary_addr;
11079ffd2685SCornelia Huck 	__u64 ind_offset;
11089ffd2685SCornelia Huck 	__u32 summary_offset;
11099ffd2685SCornelia Huck 	__u32 adapter_id;
11109ffd2685SCornelia Huck };
11119ffd2685SCornelia Huck 
1112fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint {
1113fff02bc0SPaolo Bonzini 	__u32 vcpu;
1114fff02bc0SPaolo Bonzini 	__u32 sint;
1115fff02bc0SPaolo Bonzini };
1116fff02bc0SPaolo Bonzini 
111751b24e34SJan Kiszka /* gsi routing entry types */
111851b24e34SJan Kiszka #define KVM_IRQ_ROUTING_IRQCHIP 1
111951b24e34SJan Kiszka #define KVM_IRQ_ROUTING_MSI 2
11209ffd2685SCornelia Huck #define KVM_IRQ_ROUTING_S390_ADAPTER 3
1121fff02bc0SPaolo Bonzini #define KVM_IRQ_ROUTING_HV_SINT 4
112251b24e34SJan Kiszka 
112351b24e34SJan Kiszka struct kvm_irq_routing_entry {
112451b24e34SJan Kiszka 	__u32 gsi;
112551b24e34SJan Kiszka 	__u32 type;
112651b24e34SJan Kiszka 	__u32 flags;
112751b24e34SJan Kiszka 	__u32 pad;
112851b24e34SJan Kiszka 	union {
112951b24e34SJan Kiszka 		struct kvm_irq_routing_irqchip irqchip;
113051b24e34SJan Kiszka 		struct kvm_irq_routing_msi msi;
11319ffd2685SCornelia Huck 		struct kvm_irq_routing_s390_adapter adapter;
1132fff02bc0SPaolo Bonzini 		struct kvm_irq_routing_hv_sint hv_sint;
113351b24e34SJan Kiszka 		__u32 pad[8];
113451b24e34SJan Kiszka 	} u;
113551b24e34SJan Kiszka };
113651b24e34SJan Kiszka 
113751b24e34SJan Kiszka struct kvm_irq_routing {
113851b24e34SJan Kiszka 	__u32 nr;
113951b24e34SJan Kiszka 	__u32 flags;
114051b24e34SJan Kiszka 	struct kvm_irq_routing_entry entries[0];
114151b24e34SJan Kiszka };
114251b24e34SJan Kiszka 
114351b24e34SJan Kiszka #endif
114451b24e34SJan Kiszka 
114551b24e34SJan Kiszka #ifdef KVM_CAP_MCE
114651b24e34SJan Kiszka /* x86 MCE */
114751b24e34SJan Kiszka struct kvm_x86_mce {
114851b24e34SJan Kiszka 	__u64 status;
114951b24e34SJan Kiszka 	__u64 addr;
115051b24e34SJan Kiszka 	__u64 misc;
115151b24e34SJan Kiszka 	__u64 mcg_status;
115251b24e34SJan Kiszka 	__u8 bank;
115351b24e34SJan Kiszka 	__u8 pad1[7];
115451b24e34SJan Kiszka 	__u64 pad2[3];
115551b24e34SJan Kiszka };
115651b24e34SJan Kiszka #endif
115751b24e34SJan Kiszka 
115851b24e34SJan Kiszka #ifdef KVM_CAP_XEN_HVM
1159*278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR	(1 << 0)
1160*278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL	(1 << 1)
1161*278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_SHARED_INFO		(1 << 2)
1162*278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_RUNSTATE		(1 << 3)
1163*278f064eSEduardo Habkost 
116451b24e34SJan Kiszka struct kvm_xen_hvm_config {
116551b24e34SJan Kiszka 	__u32 flags;
116651b24e34SJan Kiszka 	__u32 msr;
116751b24e34SJan Kiszka 	__u64 blob_addr_32;
116851b24e34SJan Kiszka 	__u64 blob_addr_64;
116951b24e34SJan Kiszka 	__u8 blob_size_32;
117051b24e34SJan Kiszka 	__u8 blob_size_64;
117151b24e34SJan Kiszka 	__u8 pad2[30];
117251b24e34SJan Kiszka };
117351b24e34SJan Kiszka #endif
117451b24e34SJan Kiszka 
117551b24e34SJan Kiszka #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)
1176716b8e4dSAlex Williamson /*
1177716b8e4dSAlex Williamson  * Available with KVM_CAP_IRQFD_RESAMPLE
1178716b8e4dSAlex Williamson  *
1179716b8e4dSAlex Williamson  * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies
1180716b8e4dSAlex Williamson  * the irqfd to operate in resampling mode for level triggered interrupt
1181f76b348eSCornelia Huck  * emulation.  See Documentation/virt/kvm/api.rst.
1182716b8e4dSAlex Williamson  */
1183716b8e4dSAlex Williamson #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
118451b24e34SJan Kiszka 
118551b24e34SJan Kiszka struct kvm_irqfd {
118651b24e34SJan Kiszka 	__u32 fd;
118751b24e34SJan Kiszka 	__u32 gsi;
118851b24e34SJan Kiszka 	__u32 flags;
1189716b8e4dSAlex Williamson 	__u32 resamplefd;
1190716b8e4dSAlex Williamson 	__u8  pad[16];
119151b24e34SJan Kiszka };
119251b24e34SJan Kiszka 
1193bc204035SMarcelo Tosatti /* For KVM_CAP_ADJUST_CLOCK */
1194bc204035SMarcelo Tosatti 
1195bc204035SMarcelo Tosatti /* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags.  */
1196bc204035SMarcelo Tosatti #define KVM_CLOCK_TSC_STABLE		2
1197bc204035SMarcelo Tosatti 
119851b24e34SJan Kiszka struct kvm_clock_data {
119951b24e34SJan Kiszka 	__u64 clock;
120051b24e34SJan Kiszka 	__u32 flags;
120151b24e34SJan Kiszka 	__u32 pad[9];
120251b24e34SJan Kiszka };
120351b24e34SJan Kiszka 
1204bc204035SMarcelo Tosatti /* For KVM_CAP_SW_TLB */
1205bc204035SMarcelo Tosatti 
1206a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_NOHV		0
1207a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_HV		1
1208a54fc080SAlexander Graf 
1209a54fc080SAlexander Graf struct kvm_config_tlb {
1210a54fc080SAlexander Graf 	__u64 params;
1211a54fc080SAlexander Graf 	__u64 array;
1212a54fc080SAlexander Graf 	__u32 mmu_type;
1213a54fc080SAlexander Graf 	__u32 array_len;
1214a54fc080SAlexander Graf };
1215a54fc080SAlexander Graf 
1216a54fc080SAlexander Graf struct kvm_dirty_tlb {
1217a54fc080SAlexander Graf 	__u64 bitmap;
1218a54fc080SAlexander Graf 	__u32 num_dirty;
1219a54fc080SAlexander Graf };
1220a54fc080SAlexander Graf 
12219d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */
12229d4e4f8cSAlexander Graf 
1223a31be480SAlexander Graf #define KVM_REG_ARCH_MASK	0xff00000000000000ULL
1224a31be480SAlexander Graf #define KVM_REG_GENERIC		0x0000000000000000ULL
12259d4e4f8cSAlexander Graf 
12269d4e4f8cSAlexander Graf /*
12279d4e4f8cSAlexander Graf  * Architecture specific registers are to be defined in arch headers and
12289d4e4f8cSAlexander Graf  * ORed with the arch identifier.
12299d4e4f8cSAlexander Graf  */
1230a31be480SAlexander Graf #define KVM_REG_PPC		0x1000000000000000ULL
1231a31be480SAlexander Graf #define KVM_REG_X86		0x2000000000000000ULL
1232a31be480SAlexander Graf #define KVM_REG_IA64		0x3000000000000000ULL
1233a31be480SAlexander Graf #define KVM_REG_ARM		0x4000000000000000ULL
1234a31be480SAlexander Graf #define KVM_REG_S390		0x5000000000000000ULL
1235c5daeae1SAlexey Kardashevskiy #define KVM_REG_ARM64		0x6000000000000000ULL
1236c5daeae1SAlexey Kardashevskiy #define KVM_REG_MIPS		0x7000000000000000ULL
1237f363d039SEric Auger #define KVM_REG_RISCV		0x8000000000000000ULL
1238a31be480SAlexander Graf 
1239a31be480SAlexander Graf #define KVM_REG_SIZE_SHIFT	52
1240a31be480SAlexander Graf #define KVM_REG_SIZE_MASK	0x00f0000000000000ULL
1241a31be480SAlexander Graf #define KVM_REG_SIZE_U8		0x0000000000000000ULL
1242a31be480SAlexander Graf #define KVM_REG_SIZE_U16	0x0010000000000000ULL
1243a31be480SAlexander Graf #define KVM_REG_SIZE_U32	0x0020000000000000ULL
1244a31be480SAlexander Graf #define KVM_REG_SIZE_U64	0x0030000000000000ULL
1245a31be480SAlexander Graf #define KVM_REG_SIZE_U128	0x0040000000000000ULL
1246a31be480SAlexander Graf #define KVM_REG_SIZE_U256	0x0050000000000000ULL
1247a31be480SAlexander Graf #define KVM_REG_SIZE_U512	0x0060000000000000ULL
1248a31be480SAlexander Graf #define KVM_REG_SIZE_U1024	0x0070000000000000ULL
1249d9cb4336SCornelia Huck #define KVM_REG_SIZE_U2048	0x0080000000000000ULL
12509d4e4f8cSAlexander Graf 
1251eadd0e44SPeter Maydell struct kvm_reg_list {
1252eadd0e44SPeter Maydell 	__u64 n; /* number of regs */
1253eadd0e44SPeter Maydell 	__u64 reg[0];
1254eadd0e44SPeter Maydell };
1255eadd0e44SPeter Maydell 
12569d4e4f8cSAlexander Graf struct kvm_one_reg {
12579d4e4f8cSAlexander Graf 	__u64 id;
1258a31be480SAlexander Graf 	__u64 addr;
12599d4e4f8cSAlexander Graf };
12609d4e4f8cSAlexander Graf 
1261dbdfea92SCornelia Huck #define KVM_MSI_VALID_DEVID	(1U << 0)
126280a3eb10SJan Kiszka struct kvm_msi {
126380a3eb10SJan Kiszka 	__u32 address_lo;
126480a3eb10SJan Kiszka 	__u32 address_hi;
126580a3eb10SJan Kiszka 	__u32 data;
126680a3eb10SJan Kiszka 	__u32 flags;
1267dbdfea92SCornelia Huck 	__u32 devid;
1268dbdfea92SCornelia Huck 	__u8  pad[12];
126980a3eb10SJan Kiszka };
127080a3eb10SJan Kiszka 
1271eadd0e44SPeter Maydell struct kvm_arm_device_addr {
1272eadd0e44SPeter Maydell 	__u64 id;
1273eadd0e44SPeter Maydell 	__u64 addr;
1274eadd0e44SPeter Maydell };
1275eadd0e44SPeter Maydell 
127651b24e34SJan Kiszka /*
1277e098b453SAlexey Kardashevskiy  * Device control API, available with KVM_CAP_DEVICE_CTRL
1278e098b453SAlexey Kardashevskiy  */
1279e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE_TEST		1
1280e098b453SAlexey Kardashevskiy 
1281e098b453SAlexey Kardashevskiy struct kvm_create_device {
1282e098b453SAlexey Kardashevskiy 	__u32	type;	/* in: KVM_DEV_TYPE_xxx */
1283e098b453SAlexey Kardashevskiy 	__u32	fd;	/* out: device handle */
1284e098b453SAlexey Kardashevskiy 	__u32	flags;	/* in: KVM_CREATE_DEVICE_xxx */
1285e098b453SAlexey Kardashevskiy };
1286e098b453SAlexey Kardashevskiy 
1287e098b453SAlexey Kardashevskiy struct kvm_device_attr {
1288e098b453SAlexey Kardashevskiy 	__u32	flags;		/* no flags currently defined */
1289e098b453SAlexey Kardashevskiy 	__u32	group;		/* device-defined */
1290e098b453SAlexey Kardashevskiy 	__u64	attr;		/* group-defined */
1291e098b453SAlexey Kardashevskiy 	__u64	addr;		/* userspace address of attr data */
1292e098b453SAlexey Kardashevskiy };
1293e098b453SAlexey Kardashevskiy 
1294bf63839fSAlex Williamson #define  KVM_DEV_VFIO_GROUP			1
1295bf63839fSAlex Williamson #define   KVM_DEV_VFIO_GROUP_ADD			1
1296bf63839fSAlex Williamson #define   KVM_DEV_VFIO_GROUP_DEL			2
129774c98e20SCornelia Huck #define   KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE		3
1298444b1996SArd Biesheuvel 
1299444b1996SArd Biesheuvel enum kvm_device_type {
1300444b1996SArd Biesheuvel 	KVM_DEV_TYPE_FSL_MPIC_20	= 1,
1301444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_20	KVM_DEV_TYPE_FSL_MPIC_20
1302444b1996SArd Biesheuvel 	KVM_DEV_TYPE_FSL_MPIC_42,
1303444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_42	KVM_DEV_TYPE_FSL_MPIC_42
1304444b1996SArd Biesheuvel 	KVM_DEV_TYPE_XICS,
1305444b1996SArd Biesheuvel #define KVM_DEV_TYPE_XICS		KVM_DEV_TYPE_XICS
1306444b1996SArd Biesheuvel 	KVM_DEV_TYPE_VFIO,
1307444b1996SArd Biesheuvel #define KVM_DEV_TYPE_VFIO		KVM_DEV_TYPE_VFIO
1308444b1996SArd Biesheuvel 	KVM_DEV_TYPE_ARM_VGIC_V2,
1309444b1996SArd Biesheuvel #define KVM_DEV_TYPE_ARM_VGIC_V2	KVM_DEV_TYPE_ARM_VGIC_V2
1310444b1996SArd Biesheuvel 	KVM_DEV_TYPE_FLIC,
1311444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FLIC		KVM_DEV_TYPE_FLIC
131251628b18SChristian Borntraeger 	KVM_DEV_TYPE_ARM_VGIC_V3,
131351628b18SChristian Borntraeger #define KVM_DEV_TYPE_ARM_VGIC_V3	KVM_DEV_TYPE_ARM_VGIC_V3
1314dbdfea92SCornelia Huck 	KVM_DEV_TYPE_ARM_VGIC_ITS,
1315dbdfea92SCornelia Huck #define KVM_DEV_TYPE_ARM_VGIC_ITS	KVM_DEV_TYPE_ARM_VGIC_ITS
1316d9cb4336SCornelia Huck 	KVM_DEV_TYPE_XIVE,
1317d9cb4336SCornelia Huck #define KVM_DEV_TYPE_XIVE		KVM_DEV_TYPE_XIVE
13182a886794SGreg Kurz 	KVM_DEV_TYPE_ARM_PV_TIME,
13192a886794SGreg Kurz #define KVM_DEV_TYPE_ARM_PV_TIME	KVM_DEV_TYPE_ARM_PV_TIME
1320444b1996SArd Biesheuvel 	KVM_DEV_TYPE_MAX,
1321444b1996SArd Biesheuvel };
1322e098b453SAlexey Kardashevskiy 
132374c98e20SCornelia Huck struct kvm_vfio_spapr_tce {
132474c98e20SCornelia Huck 	__s32	groupfd;
132574c98e20SCornelia Huck 	__s32	tablefd;
132674c98e20SCornelia Huck };
132774c98e20SCornelia Huck 
1328e098b453SAlexey Kardashevskiy /*
132951b24e34SJan Kiszka  * ioctls for VM fds
133051b24e34SJan Kiszka  */
133151b24e34SJan Kiszka #define KVM_SET_MEMORY_REGION     _IOW(KVMIO,  0x40, struct kvm_memory_region)
133251b24e34SJan Kiszka /*
133351b24e34SJan Kiszka  * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns
133451b24e34SJan Kiszka  * a vcpu fd.
133551b24e34SJan Kiszka  */
133651b24e34SJan Kiszka #define KVM_CREATE_VCPU           _IO(KVMIO,   0x41)
133751b24e34SJan Kiszka #define KVM_GET_DIRTY_LOG         _IOW(KVMIO,  0x42, struct kvm_dirty_log)
133851b24e34SJan Kiszka /* KVM_SET_MEMORY_ALIAS is obsolete: */
133951b24e34SJan Kiszka #define KVM_SET_MEMORY_ALIAS      _IOW(KVMIO,  0x43, struct kvm_memory_alias)
134051b24e34SJan Kiszka #define KVM_SET_NR_MMU_PAGES      _IO(KVMIO,   0x44)
134151b24e34SJan Kiszka #define KVM_GET_NR_MMU_PAGES      _IO(KVMIO,   0x45)
134251b24e34SJan Kiszka #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \
134351b24e34SJan Kiszka 					struct kvm_userspace_memory_region)
134451b24e34SJan Kiszka #define KVM_SET_TSS_ADDR          _IO(KVMIO,   0x47)
134551b24e34SJan Kiszka #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO,  0x48, __u64)
13461529ae1bSAlexander Graf 
13471529ae1bSAlexander Graf /* enable ucontrol for s390 */
13481529ae1bSAlexander Graf struct kvm_s390_ucas_mapping {
13491529ae1bSAlexander Graf 	__u64 user_addr;
13501529ae1bSAlexander Graf 	__u64 vcpu_addr;
13511529ae1bSAlexander Graf 	__u64 length;
13521529ae1bSAlexander Graf };
13531529ae1bSAlexander Graf #define KVM_S390_UCAS_MAP        _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping)
13541529ae1bSAlexander Graf #define KVM_S390_UCAS_UNMAP      _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping)
13551529ae1bSAlexander Graf #define KVM_S390_VCPU_FAULT	 _IOW(KVMIO, 0x52, unsigned long)
13561529ae1bSAlexander Graf 
135751b24e34SJan Kiszka /* Device model IOC */
135851b24e34SJan Kiszka #define KVM_CREATE_IRQCHIP        _IO(KVMIO,   0x60)
135951b24e34SJan Kiszka #define KVM_IRQ_LINE              _IOW(KVMIO,  0x61, struct kvm_irq_level)
136051b24e34SJan Kiszka #define KVM_GET_IRQCHIP           _IOWR(KVMIO, 0x62, struct kvm_irqchip)
136151b24e34SJan Kiszka #define KVM_SET_IRQCHIP           _IOR(KVMIO,  0x63, struct kvm_irqchip)
136251b24e34SJan Kiszka #define KVM_CREATE_PIT            _IO(KVMIO,   0x64)
136351b24e34SJan Kiszka #define KVM_GET_PIT               _IOWR(KVMIO, 0x65, struct kvm_pit_state)
136451b24e34SJan Kiszka #define KVM_SET_PIT               _IOR(KVMIO,  0x66, struct kvm_pit_state)
136551b24e34SJan Kiszka #define KVM_IRQ_LINE_STATUS       _IOWR(KVMIO, 0x67, struct kvm_irq_level)
136651b24e34SJan Kiszka #define KVM_REGISTER_COALESCED_MMIO \
136751b24e34SJan Kiszka 			_IOW(KVMIO,  0x67, struct kvm_coalesced_mmio_zone)
136851b24e34SJan Kiszka #define KVM_UNREGISTER_COALESCED_MMIO \
136951b24e34SJan Kiszka 			_IOW(KVMIO,  0x68, struct kvm_coalesced_mmio_zone)
137051b24e34SJan Kiszka #define KVM_ASSIGN_PCI_DEVICE     _IOR(KVMIO,  0x69, \
137151b24e34SJan Kiszka 				       struct kvm_assigned_pci_dev)
137251b24e34SJan Kiszka #define KVM_SET_GSI_ROUTING       _IOW(KVMIO,  0x6a, struct kvm_irq_routing)
137351b24e34SJan Kiszka /* deprecated, replaced by KVM_ASSIGN_DEV_IRQ */
137451b24e34SJan Kiszka #define KVM_ASSIGN_IRQ            __KVM_DEPRECATED_VM_R_0x70
137551b24e34SJan Kiszka #define KVM_ASSIGN_DEV_IRQ        _IOW(KVMIO,  0x70, struct kvm_assigned_irq)
137651b24e34SJan Kiszka #define KVM_REINJECT_CONTROL      _IO(KVMIO,   0x71)
137751b24e34SJan Kiszka #define KVM_DEASSIGN_PCI_DEVICE   _IOW(KVMIO,  0x72, \
137851b24e34SJan Kiszka 				       struct kvm_assigned_pci_dev)
137951b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_NR    _IOW(KVMIO,  0x73, \
138051b24e34SJan Kiszka 				       struct kvm_assigned_msix_nr)
138151b24e34SJan Kiszka #define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO,  0x74, \
138251b24e34SJan Kiszka 				       struct kvm_assigned_msix_entry)
138351b24e34SJan Kiszka #define KVM_DEASSIGN_DEV_IRQ      _IOW(KVMIO,  0x75, struct kvm_assigned_irq)
138451b24e34SJan Kiszka #define KVM_IRQFD                 _IOW(KVMIO,  0x76, struct kvm_irqfd)
138551b24e34SJan Kiszka #define KVM_CREATE_PIT2		  _IOW(KVMIO,  0x77, struct kvm_pit_config)
138651b24e34SJan Kiszka #define KVM_SET_BOOT_CPU_ID       _IO(KVMIO,   0x78)
138751b24e34SJan Kiszka #define KVM_IOEVENTFD             _IOW(KVMIO,  0x79, struct kvm_ioeventfd)
138851b24e34SJan Kiszka #define KVM_XEN_HVM_CONFIG        _IOW(KVMIO,  0x7a, struct kvm_xen_hvm_config)
138951b24e34SJan Kiszka #define KVM_SET_CLOCK             _IOW(KVMIO,  0x7b, struct kvm_clock_data)
139051b24e34SJan Kiszka #define KVM_GET_CLOCK             _IOR(KVMIO,  0x7c, struct kvm_clock_data)
139151b24e34SJan Kiszka /* Available with KVM_CAP_PIT_STATE2 */
139251b24e34SJan Kiszka #define KVM_GET_PIT2              _IOR(KVMIO,  0x9f, struct kvm_pit_state2)
139351b24e34SJan Kiszka #define KVM_SET_PIT2              _IOW(KVMIO,  0xa0, struct kvm_pit_state2)
139451b24e34SJan Kiszka /* Available with KVM_CAP_PPC_GET_PVINFO */
139551b24e34SJan Kiszka #define KVM_PPC_GET_PVINFO	  _IOW(KVMIO,  0xa1, struct kvm_ppc_pvinfo)
139651b24e34SJan Kiszka /* Available with KVM_CAP_TSC_CONTROL */
139751b24e34SJan Kiszka #define KVM_SET_TSC_KHZ           _IO(KVMIO,  0xa2)
139851b24e34SJan Kiszka #define KVM_GET_TSC_KHZ           _IO(KVMIO,  0xa3)
13999ab2195dSMarcelo Tosatti /* Available with KVM_CAP_PCI_2_3 */
14009ab2195dSMarcelo Tosatti #define KVM_ASSIGN_SET_INTX_MASK  _IOW(KVMIO,  0xa4, \
14019ab2195dSMarcelo Tosatti 				       struct kvm_assigned_pci_dev)
140280a3eb10SJan Kiszka /* Available with KVM_CAP_SIGNAL_MSI */
140380a3eb10SJan Kiszka #define KVM_SIGNAL_MSI            _IOW(KVMIO,  0xa5, struct kvm_msi)
140480a3eb10SJan Kiszka /* Available with KVM_CAP_PPC_GET_SMMU_INFO */
140580a3eb10SJan Kiszka #define KVM_PPC_GET_SMMU_INFO	  _IOR(KVMIO,  0xa6, struct kvm_ppc_smmu_info)
1406651682dcSMichael S. Tsirkin /* Available with KVM_CAP_PPC_ALLOC_HTAB */
1407651682dcSMichael S. Tsirkin #define KVM_PPC_ALLOCATE_HTAB	  _IOWR(KVMIO, 0xa7, __u32)
1408d4834ff9SAlexander Graf #define KVM_CREATE_SPAPR_TCE	  _IOW(KVMIO,  0xa8, struct kvm_create_spapr_tce)
1409b89485a5SPaolo Bonzini #define KVM_CREATE_SPAPR_TCE_64	  _IOW(KVMIO,  0xa8, \
1410b89485a5SPaolo Bonzini 				       struct kvm_create_spapr_tce_64)
1411d4834ff9SAlexander Graf /* Available with KVM_CAP_RMA */
1412d4834ff9SAlexander Graf #define KVM_ALLOCATE_RMA	  _IOR(KVMIO,  0xa9, struct kvm_allocate_rma)
1413d4834ff9SAlexander Graf /* Available with KVM_CAP_PPC_HTAB_FD */
1414d4834ff9SAlexander Graf #define KVM_PPC_GET_HTAB_FD	  _IOW(KVMIO,  0xaa, struct kvm_get_htab_fd)
1415eadd0e44SPeter Maydell /* Available with KVM_CAP_ARM_SET_DEVICE_ADDR */
1416eadd0e44SPeter Maydell #define KVM_ARM_SET_DEVICE_ADDR	  _IOW(KVMIO,  0xab, struct kvm_arm_device_addr)
1417e098b453SAlexey Kardashevskiy /* Available with KVM_CAP_PPC_RTAS */
1418e098b453SAlexey Kardashevskiy #define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO,  0xac, struct kvm_rtas_token_args)
14193a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_SPAPR_RESIZE_HPT */
14203a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt)
14213a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_COMMIT  _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt)
14223a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */
14233a5eb5b4SPaolo Bonzini #define KVM_PPC_CONFIGURE_V3_MMU  _IOW(KVMIO,  0xaf, struct kvm_ppc_mmuv3_cfg)
14243a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_PPC_RADIX_MMU */
14253a5eb5b4SPaolo Bonzini #define KVM_PPC_GET_RMMU_INFO	  _IOW(KVMIO,  0xb0, struct kvm_ppc_rmmu_info)
14269cbb6362SCornelia Huck /* Available with KVM_CAP_PPC_GET_CPU_CHAR */
14279cbb6362SCornelia Huck #define KVM_PPC_GET_CPU_CHAR	  _IOR(KVMIO,  0xb1, struct kvm_ppc_cpu_char)
1428f363d039SEric Auger /* Available with KVM_CAP_PMU_EVENT_FILTER */
1429f363d039SEric Auger #define KVM_SET_PMU_EVENT_FILTER  _IOW(KVMIO,  0xb2, struct kvm_pmu_event_filter)
143050fd0c37SBharata B Rao #define KVM_PPC_SVM_OFF		  _IO(KVMIO,  0xb3)
1431e098b453SAlexey Kardashevskiy 
1432e098b453SAlexey Kardashevskiy /* ioctl for vm fd */
1433e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE	  _IOWR(KVMIO,  0xe0, struct kvm_create_device)
1434e098b453SAlexey Kardashevskiy 
1435e098b453SAlexey Kardashevskiy /* ioctls for fds returned by KVM_CREATE_DEVICE */
1436e098b453SAlexey Kardashevskiy #define KVM_SET_DEVICE_ATTR	  _IOW(KVMIO,  0xe1, struct kvm_device_attr)
1437e098b453SAlexey Kardashevskiy #define KVM_GET_DEVICE_ATTR	  _IOW(KVMIO,  0xe2, struct kvm_device_attr)
1438e098b453SAlexey Kardashevskiy #define KVM_HAS_DEVICE_ATTR	  _IOW(KVMIO,  0xe3, struct kvm_device_attr)
143951b24e34SJan Kiszka 
144051b24e34SJan Kiszka /*
144151b24e34SJan Kiszka  * ioctls for vcpu fds
144251b24e34SJan Kiszka  */
144351b24e34SJan Kiszka #define KVM_RUN                   _IO(KVMIO,   0x80)
144451b24e34SJan Kiszka #define KVM_GET_REGS              _IOR(KVMIO,  0x81, struct kvm_regs)
144551b24e34SJan Kiszka #define KVM_SET_REGS              _IOW(KVMIO,  0x82, struct kvm_regs)
144651b24e34SJan Kiszka #define KVM_GET_SREGS             _IOR(KVMIO,  0x83, struct kvm_sregs)
144751b24e34SJan Kiszka #define KVM_SET_SREGS             _IOW(KVMIO,  0x84, struct kvm_sregs)
144851b24e34SJan Kiszka #define KVM_TRANSLATE             _IOWR(KVMIO, 0x85, struct kvm_translation)
144951b24e34SJan Kiszka #define KVM_INTERRUPT             _IOW(KVMIO,  0x86, struct kvm_interrupt)
145051b24e34SJan Kiszka /* KVM_DEBUG_GUEST is no longer supported, use KVM_SET_GUEST_DEBUG instead */
145151b24e34SJan Kiszka #define KVM_DEBUG_GUEST           __KVM_DEPRECATED_VCPU_W_0x87
145251b24e34SJan Kiszka #define KVM_GET_MSRS              _IOWR(KVMIO, 0x88, struct kvm_msrs)
145351b24e34SJan Kiszka #define KVM_SET_MSRS              _IOW(KVMIO,  0x89, struct kvm_msrs)
145451b24e34SJan Kiszka #define KVM_SET_CPUID             _IOW(KVMIO,  0x8a, struct kvm_cpuid)
145551b24e34SJan Kiszka #define KVM_SET_SIGNAL_MASK       _IOW(KVMIO,  0x8b, struct kvm_signal_mask)
145651b24e34SJan Kiszka #define KVM_GET_FPU               _IOR(KVMIO,  0x8c, struct kvm_fpu)
145751b24e34SJan Kiszka #define KVM_SET_FPU               _IOW(KVMIO,  0x8d, struct kvm_fpu)
145851b24e34SJan Kiszka #define KVM_GET_LAPIC             _IOR(KVMIO,  0x8e, struct kvm_lapic_state)
145951b24e34SJan Kiszka #define KVM_SET_LAPIC             _IOW(KVMIO,  0x8f, struct kvm_lapic_state)
146051b24e34SJan Kiszka #define KVM_SET_CPUID2            _IOW(KVMIO,  0x90, struct kvm_cpuid2)
146151b24e34SJan Kiszka #define KVM_GET_CPUID2            _IOWR(KVMIO, 0x91, struct kvm_cpuid2)
146251b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */
146351b24e34SJan Kiszka #define KVM_TPR_ACCESS_REPORTING  _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)
146451b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */
146551b24e34SJan Kiszka #define KVM_SET_VAPIC_ADDR        _IOW(KVMIO,  0x93, struct kvm_vapic_addr)
146651b24e34SJan Kiszka /* valid for virtual machine (for floating interrupt)_and_ vcpu */
146751b24e34SJan Kiszka #define KVM_S390_INTERRUPT        _IOW(KVMIO,  0x94, struct kvm_s390_interrupt)
146851b24e34SJan Kiszka /* store status for s390 */
146951b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_NOADDR    (-1ul)
147051b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_PREFIXED  (-2ul)
147151b24e34SJan Kiszka #define KVM_S390_STORE_STATUS	  _IOW(KVMIO,  0x95, unsigned long)
147251b24e34SJan Kiszka /* initial ipl psw for s390 */
147351b24e34SJan Kiszka #define KVM_S390_SET_INITIAL_PSW  _IOW(KVMIO,  0x96, struct kvm_s390_psw)
147451b24e34SJan Kiszka /* initial reset for s390 */
147551b24e34SJan Kiszka #define KVM_S390_INITIAL_RESET    _IO(KVMIO,   0x97)
147651b24e34SJan Kiszka #define KVM_GET_MP_STATE          _IOR(KVMIO,  0x98, struct kvm_mp_state)
147751b24e34SJan Kiszka #define KVM_SET_MP_STATE          _IOW(KVMIO,  0x99, struct kvm_mp_state)
1478444b1996SArd Biesheuvel /* Available with KVM_CAP_USER_NMI */
147951b24e34SJan Kiszka #define KVM_NMI                   _IO(KVMIO,   0x9a)
148051b24e34SJan Kiszka /* Available with KVM_CAP_SET_GUEST_DEBUG */
148151b24e34SJan Kiszka #define KVM_SET_GUEST_DEBUG       _IOW(KVMIO,  0x9b, struct kvm_guest_debug)
148251b24e34SJan Kiszka /* MCE for x86 */
148351b24e34SJan Kiszka #define KVM_X86_SETUP_MCE         _IOW(KVMIO,  0x9c, __u64)
148451b24e34SJan Kiszka #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO,  0x9d, __u64)
148551b24e34SJan Kiszka #define KVM_X86_SET_MCE           _IOW(KVMIO,  0x9e, struct kvm_x86_mce)
148651b24e34SJan Kiszka /* Available with KVM_CAP_VCPU_EVENTS */
148751b24e34SJan Kiszka #define KVM_GET_VCPU_EVENTS       _IOR(KVMIO,  0x9f, struct kvm_vcpu_events)
148851b24e34SJan Kiszka #define KVM_SET_VCPU_EVENTS       _IOW(KVMIO,  0xa0, struct kvm_vcpu_events)
148951b24e34SJan Kiszka /* Available with KVM_CAP_DEBUGREGS */
149051b24e34SJan Kiszka #define KVM_GET_DEBUGREGS         _IOR(KVMIO,  0xa1, struct kvm_debugregs)
149151b24e34SJan Kiszka #define KVM_SET_DEBUGREGS         _IOW(KVMIO,  0xa2, struct kvm_debugregs)
14929ffd2685SCornelia Huck /*
14939ffd2685SCornelia Huck  * vcpu version available with KVM_ENABLE_CAP
14949ffd2685SCornelia Huck  * vm version available with KVM_CAP_ENABLE_CAP_VM
14959ffd2685SCornelia Huck  */
149651b24e34SJan Kiszka #define KVM_ENABLE_CAP            _IOW(KVMIO,  0xa3, struct kvm_enable_cap)
149751b24e34SJan Kiszka /* Available with KVM_CAP_XSAVE */
149851b24e34SJan Kiszka #define KVM_GET_XSAVE		  _IOR(KVMIO,  0xa4, struct kvm_xsave)
149951b24e34SJan Kiszka #define KVM_SET_XSAVE		  _IOW(KVMIO,  0xa5, struct kvm_xsave)
150051b24e34SJan Kiszka /* Available with KVM_CAP_XCRS */
150151b24e34SJan Kiszka #define KVM_GET_XCRS		  _IOR(KVMIO,  0xa6, struct kvm_xcrs)
150251b24e34SJan Kiszka #define KVM_SET_XCRS		  _IOW(KVMIO,  0xa7, struct kvm_xcrs)
1503a54fc080SAlexander Graf /* Available with KVM_CAP_SW_TLB */
1504a54fc080SAlexander Graf #define KVM_DIRTY_TLB		  _IOW(KVMIO,  0xaa, struct kvm_dirty_tlb)
15059d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */
1506a31be480SAlexander Graf #define KVM_GET_ONE_REG		  _IOW(KVMIO,  0xab, struct kvm_one_reg)
15079d4e4f8cSAlexander Graf #define KVM_SET_ONE_REG		  _IOW(KVMIO,  0xac, struct kvm_one_reg)
15089ab2195dSMarcelo Tosatti /* VM is being stopped by host */
15099ab2195dSMarcelo Tosatti #define KVM_KVMCLOCK_CTRL	  _IO(KVMIO,   0xad)
1510eadd0e44SPeter Maydell #define KVM_ARM_VCPU_INIT	  _IOW(KVMIO,  0xae, struct kvm_vcpu_init)
1511bf63839fSAlex Williamson #define KVM_ARM_PREFERRED_TARGET  _IOR(KVMIO,  0xaf, struct kvm_vcpu_init)
1512eadd0e44SPeter Maydell #define KVM_GET_REG_LIST	  _IOWR(KVMIO, 0xb0, struct kvm_reg_list)
15137a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_MEM_OP */
15147a52ce8aSCornelia Huck #define KVM_S390_MEM_OP		  _IOW(KVMIO,  0xb1, struct kvm_s390_mem_op)
15157a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_SKEYS */
15167a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS      _IOW(KVMIO, 0xb2, struct kvm_s390_skeys)
15177a52ce8aSCornelia Huck #define KVM_S390_SET_SKEYS      _IOW(KVMIO, 0xb3, struct kvm_s390_skeys)
15187a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_INJECT_IRQ */
15197a52ce8aSCornelia Huck #define KVM_S390_IRQ              _IOW(KVMIO,  0xb4, struct kvm_s390_irq)
15207a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_IRQ_STATE */
15217a52ce8aSCornelia Huck #define KVM_S390_SET_IRQ_STATE	  _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state)
15227a52ce8aSCornelia Huck #define KVM_S390_GET_IRQ_STATE	  _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state)
152324a31426SPaolo Bonzini /* Available with KVM_CAP_X86_SMM */
152424a31426SPaolo Bonzini #define KVM_SMI                   _IO(KVMIO,   0xb7)
15253272f0e2SChristian Borntraeger /* Available with KVM_CAP_S390_CMMA_MIGRATION */
1526ab6e1550SChristian Borntraeger #define KVM_S390_GET_CMMA_BITS      _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log)
15273272f0e2SChristian Borntraeger #define KVM_S390_SET_CMMA_BITS      _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log)
15289f2d175dSPaolo Bonzini /* Memory Encryption Commands */
15299f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_OP      _IOWR(KVMIO, 0xba, unsigned long)
15309f2d175dSPaolo Bonzini 
15319f2d175dSPaolo Bonzini struct kvm_enc_region {
15329f2d175dSPaolo Bonzini 	__u64 addr;
15339f2d175dSPaolo Bonzini 	__u64 size;
15349f2d175dSPaolo Bonzini };
15359f2d175dSPaolo Bonzini 
15369f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_REG_REGION    _IOR(KVMIO, 0xbb, struct kvm_enc_region)
15379f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_UNREG_REGION  _IOR(KVMIO, 0xbc, struct kvm_enc_region)
15389f2d175dSPaolo Bonzini 
153965a6d8ddSPeter Maydell /* Available with KVM_CAP_HYPERV_EVENTFD */
154065a6d8ddSPeter Maydell #define KVM_HYPERV_EVENTFD        _IOW(KVMIO,  0xbd, struct kvm_hyperv_eventfd)
154165a6d8ddSPeter Maydell 
1542d36f7de8SCornelia Huck /* Available with KVM_CAP_NESTED_STATE */
1543d36f7de8SCornelia Huck #define KVM_GET_NESTED_STATE         _IOWR(KVMIO, 0xbe, struct kvm_nested_state)
1544d36f7de8SCornelia Huck #define KVM_SET_NESTED_STATE         _IOW(KVMIO,  0xbf, struct kvm_nested_state)
154565a6d8ddSPeter Maydell 
1546d9cb4336SCornelia Huck /* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT_2 */
1547da054c64SPaolo Bonzini #define KVM_CLEAR_DIRTY_LOG          _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log)
1548da054c64SPaolo Bonzini 
1549b3c818a4SEric Farman /* Available with KVM_CAP_HYPERV_CPUID (vcpu) / KVM_CAP_SYS_HYPERV_CPUID (system) */
1550da054c64SPaolo Bonzini #define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2)
1551da054c64SPaolo Bonzini 
1552d9cb4336SCornelia Huck /* Available with KVM_CAP_ARM_SVE */
1553d9cb4336SCornelia Huck #define KVM_ARM_VCPU_FINALIZE	  _IOW(KVMIO,  0xc2, int)
1554d9cb4336SCornelia Huck 
1555ddda3748SCornelia Huck /* Available with  KVM_CAP_S390_VCPU_RESETS */
1556ddda3748SCornelia Huck #define KVM_S390_NORMAL_RESET	_IO(KVMIO,   0xc3)
1557ddda3748SCornelia Huck #define KVM_S390_CLEAR_RESET	_IO(KVMIO,   0xc4)
1558ddda3748SCornelia Huck 
1559dc6f8d45SCornelia Huck struct kvm_s390_pv_sec_parm {
1560dc6f8d45SCornelia Huck 	__u64 origin;
1561dc6f8d45SCornelia Huck 	__u64 length;
1562dc6f8d45SCornelia Huck };
1563dc6f8d45SCornelia Huck 
1564dc6f8d45SCornelia Huck struct kvm_s390_pv_unp {
1565dc6f8d45SCornelia Huck 	__u64 addr;
1566dc6f8d45SCornelia Huck 	__u64 size;
1567dc6f8d45SCornelia Huck 	__u64 tweak;
1568dc6f8d45SCornelia Huck };
1569dc6f8d45SCornelia Huck 
1570dc6f8d45SCornelia Huck enum pv_cmd_id {
1571dc6f8d45SCornelia Huck 	KVM_PV_ENABLE,
1572dc6f8d45SCornelia Huck 	KVM_PV_DISABLE,
1573dc6f8d45SCornelia Huck 	KVM_PV_SET_SEC_PARMS,
1574dc6f8d45SCornelia Huck 	KVM_PV_UNPACK,
1575dc6f8d45SCornelia Huck 	KVM_PV_VERIFY,
1576dc6f8d45SCornelia Huck 	KVM_PV_PREP_RESET,
1577dc6f8d45SCornelia Huck 	KVM_PV_UNSHARE_ALL,
1578dc6f8d45SCornelia Huck };
1579dc6f8d45SCornelia Huck 
1580dc6f8d45SCornelia Huck struct kvm_pv_cmd {
1581dc6f8d45SCornelia Huck 	__u32 cmd;	/* Command to be executed */
1582dc6f8d45SCornelia Huck 	__u16 rc;	/* Ultravisor return code */
1583dc6f8d45SCornelia Huck 	__u16 rrc;	/* Ultravisor return reason code */
1584dc6f8d45SCornelia Huck 	__u64 data;	/* Data or address */
1585dc6f8d45SCornelia Huck 	__u32 flags;    /* flags for future extensions. Must be 0 for now */
1586dc6f8d45SCornelia Huck 	__u32 reserved[3];
1587dc6f8d45SCornelia Huck };
1588dc6f8d45SCornelia Huck 
1589dc6f8d45SCornelia Huck /* Available with KVM_CAP_S390_PROTECTED */
1590dc6f8d45SCornelia Huck #define KVM_S390_PV_COMMAND		_IOWR(KVMIO, 0xc5, struct kvm_pv_cmd)
1591dc6f8d45SCornelia Huck 
159253ba2eeeSMatthew Rosato /* Available with KVM_CAP_X86_MSR_FILTER */
159353ba2eeeSMatthew Rosato #define KVM_X86_SET_MSR_FILTER	_IOW(KVMIO,  0xc6, struct kvm_msr_filter)
159453ba2eeeSMatthew Rosato 
1595b3c818a4SEric Farman /* Available with KVM_CAP_DIRTY_LOG_RING */
1596b3c818a4SEric Farman #define KVM_RESET_DIRTY_RINGS		_IO(KVMIO, 0xc7)
1597b3c818a4SEric Farman 
1598*278f064eSEduardo Habkost /* Per-VM Xen attributes */
1599*278f064eSEduardo Habkost #define KVM_XEN_HVM_GET_ATTR	_IOWR(KVMIO, 0xc8, struct kvm_xen_hvm_attr)
1600*278f064eSEduardo Habkost #define KVM_XEN_HVM_SET_ATTR	_IOW(KVMIO,  0xc9, struct kvm_xen_hvm_attr)
1601*278f064eSEduardo Habkost 
1602*278f064eSEduardo Habkost struct kvm_xen_hvm_attr {
1603*278f064eSEduardo Habkost 	__u16 type;
1604*278f064eSEduardo Habkost 	__u16 pad[3];
1605*278f064eSEduardo Habkost 	union {
1606*278f064eSEduardo Habkost 		__u8 long_mode;
1607*278f064eSEduardo Habkost 		__u8 vector;
1608*278f064eSEduardo Habkost 		struct {
1609*278f064eSEduardo Habkost 			__u64 gfn;
1610*278f064eSEduardo Habkost 		} shared_info;
1611*278f064eSEduardo Habkost 		__u64 pad[8];
1612*278f064eSEduardo Habkost 	} u;
1613*278f064eSEduardo Habkost };
1614*278f064eSEduardo Habkost 
1615*278f064eSEduardo Habkost /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */
1616*278f064eSEduardo Habkost #define KVM_XEN_ATTR_TYPE_LONG_MODE		0x0
1617*278f064eSEduardo Habkost #define KVM_XEN_ATTR_TYPE_SHARED_INFO		0x1
1618*278f064eSEduardo Habkost #define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR		0x2
1619*278f064eSEduardo Habkost 
1620*278f064eSEduardo Habkost /* Per-vCPU Xen attributes */
1621*278f064eSEduardo Habkost #define KVM_XEN_VCPU_GET_ATTR	_IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr)
1622*278f064eSEduardo Habkost #define KVM_XEN_VCPU_SET_ATTR	_IOW(KVMIO,  0xcb, struct kvm_xen_vcpu_attr)
1623*278f064eSEduardo Habkost 
1624*278f064eSEduardo Habkost struct kvm_xen_vcpu_attr {
1625*278f064eSEduardo Habkost 	__u16 type;
1626*278f064eSEduardo Habkost 	__u16 pad[3];
1627*278f064eSEduardo Habkost 	union {
1628*278f064eSEduardo Habkost 		__u64 gpa;
1629*278f064eSEduardo Habkost 		__u64 pad[8];
1630*278f064eSEduardo Habkost 		struct {
1631*278f064eSEduardo Habkost 			__u64 state;
1632*278f064eSEduardo Habkost 			__u64 state_entry_time;
1633*278f064eSEduardo Habkost 			__u64 time_running;
1634*278f064eSEduardo Habkost 			__u64 time_runnable;
1635*278f064eSEduardo Habkost 			__u64 time_blocked;
1636*278f064eSEduardo Habkost 			__u64 time_offline;
1637*278f064eSEduardo Habkost 		} runstate;
1638*278f064eSEduardo Habkost 	} u;
1639*278f064eSEduardo Habkost };
1640*278f064eSEduardo Habkost 
1641*278f064eSEduardo Habkost /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */
1642*278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO	0x0
1643*278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO	0x1
1644*278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR	0x2
1645*278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT	0x3
1646*278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA	0x4
1647*278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST	0x5
1648*278f064eSEduardo Habkost 
16499f2d175dSPaolo Bonzini /* Secure Encrypted Virtualization command */
16509f2d175dSPaolo Bonzini enum sev_cmd_id {
16519f2d175dSPaolo Bonzini 	/* Guest initialization commands */
16529f2d175dSPaolo Bonzini 	KVM_SEV_INIT = 0,
16539f2d175dSPaolo Bonzini 	KVM_SEV_ES_INIT,
16549f2d175dSPaolo Bonzini 	/* Guest launch commands */
16559f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_START,
16569f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_UPDATE_DATA,
16579f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_UPDATE_VMSA,
16589f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_SECRET,
16599f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_MEASURE,
16609f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_FINISH,
16619f2d175dSPaolo Bonzini 	/* Guest migration commands (outgoing) */
16629f2d175dSPaolo Bonzini 	KVM_SEV_SEND_START,
16639f2d175dSPaolo Bonzini 	KVM_SEV_SEND_UPDATE_DATA,
16649f2d175dSPaolo Bonzini 	KVM_SEV_SEND_UPDATE_VMSA,
16659f2d175dSPaolo Bonzini 	KVM_SEV_SEND_FINISH,
16669f2d175dSPaolo Bonzini 	/* Guest migration commands (incoming) */
16679f2d175dSPaolo Bonzini 	KVM_SEV_RECEIVE_START,
16689f2d175dSPaolo Bonzini 	KVM_SEV_RECEIVE_UPDATE_DATA,
16699f2d175dSPaolo Bonzini 	KVM_SEV_RECEIVE_UPDATE_VMSA,
16709f2d175dSPaolo Bonzini 	KVM_SEV_RECEIVE_FINISH,
16719f2d175dSPaolo Bonzini 	/* Guest status and debug commands */
16729f2d175dSPaolo Bonzini 	KVM_SEV_GUEST_STATUS,
16739f2d175dSPaolo Bonzini 	KVM_SEV_DBG_DECRYPT,
16749f2d175dSPaolo Bonzini 	KVM_SEV_DBG_ENCRYPT,
16759f2d175dSPaolo Bonzini 	/* Guest certificates commands */
16769f2d175dSPaolo Bonzini 	KVM_SEV_CERT_EXPORT,
16773ea1a802SBrijesh Singh 	/* Attestation report */
16783ea1a802SBrijesh Singh 	KVM_SEV_GET_ATTESTATION_REPORT,
1679*278f064eSEduardo Habkost 	/* Guest Migration Extension */
1680*278f064eSEduardo Habkost 	KVM_SEV_SEND_CANCEL,
16819f2d175dSPaolo Bonzini 
16829f2d175dSPaolo Bonzini 	KVM_SEV_NR_MAX,
16839f2d175dSPaolo Bonzini };
16849f2d175dSPaolo Bonzini 
16859f2d175dSPaolo Bonzini struct kvm_sev_cmd {
16869f2d175dSPaolo Bonzini 	__u32 id;
16879f2d175dSPaolo Bonzini 	__u64 data;
16889f2d175dSPaolo Bonzini 	__u32 error;
16899f2d175dSPaolo Bonzini 	__u32 sev_fd;
16909f2d175dSPaolo Bonzini };
16919f2d175dSPaolo Bonzini 
16929f2d175dSPaolo Bonzini struct kvm_sev_launch_start {
16939f2d175dSPaolo Bonzini 	__u32 handle;
16949f2d175dSPaolo Bonzini 	__u32 policy;
16959f2d175dSPaolo Bonzini 	__u64 dh_uaddr;
16969f2d175dSPaolo Bonzini 	__u32 dh_len;
16979f2d175dSPaolo Bonzini 	__u64 session_uaddr;
16989f2d175dSPaolo Bonzini 	__u32 session_len;
16999f2d175dSPaolo Bonzini };
17009f2d175dSPaolo Bonzini 
17019f2d175dSPaolo Bonzini struct kvm_sev_launch_update_data {
17029f2d175dSPaolo Bonzini 	__u64 uaddr;
17039f2d175dSPaolo Bonzini 	__u32 len;
17049f2d175dSPaolo Bonzini };
17059f2d175dSPaolo Bonzini 
17069f2d175dSPaolo Bonzini 
17079f2d175dSPaolo Bonzini struct kvm_sev_launch_secret {
17089f2d175dSPaolo Bonzini 	__u64 hdr_uaddr;
17099f2d175dSPaolo Bonzini 	__u32 hdr_len;
17109f2d175dSPaolo Bonzini 	__u64 guest_uaddr;
17119f2d175dSPaolo Bonzini 	__u32 guest_len;
17129f2d175dSPaolo Bonzini 	__u64 trans_uaddr;
17139f2d175dSPaolo Bonzini 	__u32 trans_len;
17149f2d175dSPaolo Bonzini };
17159f2d175dSPaolo Bonzini 
17169f2d175dSPaolo Bonzini struct kvm_sev_launch_measure {
17179f2d175dSPaolo Bonzini 	__u64 uaddr;
17189f2d175dSPaolo Bonzini 	__u32 len;
17199f2d175dSPaolo Bonzini };
17209f2d175dSPaolo Bonzini 
17219f2d175dSPaolo Bonzini struct kvm_sev_guest_status {
17229f2d175dSPaolo Bonzini 	__u32 handle;
17239f2d175dSPaolo Bonzini 	__u32 policy;
17249f2d175dSPaolo Bonzini 	__u32 state;
17259f2d175dSPaolo Bonzini };
17269f2d175dSPaolo Bonzini 
17279f2d175dSPaolo Bonzini struct kvm_sev_dbg {
17289f2d175dSPaolo Bonzini 	__u64 src_uaddr;
17299f2d175dSPaolo Bonzini 	__u64 dst_uaddr;
17309f2d175dSPaolo Bonzini 	__u32 len;
17319f2d175dSPaolo Bonzini };
173251b24e34SJan Kiszka 
17333ea1a802SBrijesh Singh struct kvm_sev_attestation_report {
17343ea1a802SBrijesh Singh 	__u8 mnonce[16];
17353ea1a802SBrijesh Singh 	__u64 uaddr;
17363ea1a802SBrijesh Singh 	__u32 len;
17373ea1a802SBrijesh Singh };
17383ea1a802SBrijesh Singh 
1739*278f064eSEduardo Habkost struct kvm_sev_send_start {
1740*278f064eSEduardo Habkost 	__u32 policy;
1741*278f064eSEduardo Habkost 	__u64 pdh_cert_uaddr;
1742*278f064eSEduardo Habkost 	__u32 pdh_cert_len;
1743*278f064eSEduardo Habkost 	__u64 plat_certs_uaddr;
1744*278f064eSEduardo Habkost 	__u32 plat_certs_len;
1745*278f064eSEduardo Habkost 	__u64 amd_certs_uaddr;
1746*278f064eSEduardo Habkost 	__u32 amd_certs_len;
1747*278f064eSEduardo Habkost 	__u64 session_uaddr;
1748*278f064eSEduardo Habkost 	__u32 session_len;
1749*278f064eSEduardo Habkost };
1750*278f064eSEduardo Habkost 
1751*278f064eSEduardo Habkost struct kvm_sev_send_update_data {
1752*278f064eSEduardo Habkost 	__u64 hdr_uaddr;
1753*278f064eSEduardo Habkost 	__u32 hdr_len;
1754*278f064eSEduardo Habkost 	__u64 guest_uaddr;
1755*278f064eSEduardo Habkost 	__u32 guest_len;
1756*278f064eSEduardo Habkost 	__u64 trans_uaddr;
1757*278f064eSEduardo Habkost 	__u32 trans_len;
1758*278f064eSEduardo Habkost };
1759*278f064eSEduardo Habkost 
1760*278f064eSEduardo Habkost struct kvm_sev_receive_start {
1761*278f064eSEduardo Habkost 	__u32 handle;
1762*278f064eSEduardo Habkost 	__u32 policy;
1763*278f064eSEduardo Habkost 	__u64 pdh_uaddr;
1764*278f064eSEduardo Habkost 	__u32 pdh_len;
1765*278f064eSEduardo Habkost 	__u64 session_uaddr;
1766*278f064eSEduardo Habkost 	__u32 session_len;
1767*278f064eSEduardo Habkost };
1768*278f064eSEduardo Habkost 
1769*278f064eSEduardo Habkost struct kvm_sev_receive_update_data {
1770*278f064eSEduardo Habkost 	__u64 hdr_uaddr;
1771*278f064eSEduardo Habkost 	__u32 hdr_len;
1772*278f064eSEduardo Habkost 	__u64 guest_uaddr;
1773*278f064eSEduardo Habkost 	__u32 guest_len;
1774*278f064eSEduardo Habkost 	__u64 trans_uaddr;
1775*278f064eSEduardo Habkost 	__u32 trans_len;
1776*278f064eSEduardo Habkost };
1777*278f064eSEduardo Habkost 
177851b24e34SJan Kiszka #define KVM_DEV_ASSIGN_ENABLE_IOMMU	(1 << 0)
17799ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_PCI_2_3		(1 << 1)
17809ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_MASK_INTX	(1 << 2)
178151b24e34SJan Kiszka 
178251b24e34SJan Kiszka struct kvm_assigned_pci_dev {
178351b24e34SJan Kiszka 	__u32 assigned_dev_id;
178451b24e34SJan Kiszka 	__u32 busnr;
178551b24e34SJan Kiszka 	__u32 devfn;
178651b24e34SJan Kiszka 	__u32 flags;
178751b24e34SJan Kiszka 	__u32 segnr;
178851b24e34SJan Kiszka 	union {
178951b24e34SJan Kiszka 		__u32 reserved[11];
179051b24e34SJan Kiszka 	};
179151b24e34SJan Kiszka };
179251b24e34SJan Kiszka 
179351b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_INTX    (1 << 0)
179451b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSI     (1 << 1)
179551b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSIX    (1 << 2)
179651b24e34SJan Kiszka 
179751b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_INTX   (1 << 8)
179851b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSI    (1 << 9)
179951b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSIX   (1 << 10)
180051b24e34SJan Kiszka 
180151b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MASK	 0x00ff
180251b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MASK   0xff00
180351b24e34SJan Kiszka 
180451b24e34SJan Kiszka struct kvm_assigned_irq {
180551b24e34SJan Kiszka 	__u32 assigned_dev_id;
18067c6da3deSAlexander Graf 	__u32 host_irq; /* ignored (legacy field) */
180751b24e34SJan Kiszka 	__u32 guest_irq;
180851b24e34SJan Kiszka 	__u32 flags;
180951b24e34SJan Kiszka 	union {
181051b24e34SJan Kiszka 		__u32 reserved[12];
181151b24e34SJan Kiszka 	};
181251b24e34SJan Kiszka };
181351b24e34SJan Kiszka 
181451b24e34SJan Kiszka struct kvm_assigned_msix_nr {
181551b24e34SJan Kiszka 	__u32 assigned_dev_id;
181651b24e34SJan Kiszka 	__u16 entry_nr;
181751b24e34SJan Kiszka 	__u16 padding;
181851b24e34SJan Kiszka };
181951b24e34SJan Kiszka 
182051b24e34SJan Kiszka #define KVM_MAX_MSIX_PER_DEV		256
182151b24e34SJan Kiszka struct kvm_assigned_msix_entry {
182251b24e34SJan Kiszka 	__u32 assigned_dev_id;
182351b24e34SJan Kiszka 	__u32 gsi;
182451b24e34SJan Kiszka 	__u16 entry; /* The index of entry in the MSI-X table */
182551b24e34SJan Kiszka 	__u16 padding[3];
182651b24e34SJan Kiszka };
182751b24e34SJan Kiszka 
1828dbdfea92SCornelia Huck #define KVM_X2APIC_API_USE_32BIT_IDS            (1ULL << 0)
1829dbdfea92SCornelia Huck #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK  (1ULL << 1)
1830dbdfea92SCornelia Huck 
183174c98e20SCornelia Huck /* Available with KVM_CAP_ARM_USER_IRQ */
183274c98e20SCornelia Huck 
183374c98e20SCornelia Huck /* Bits for run->s.regs.device_irq_level */
183474c98e20SCornelia Huck #define KVM_ARM_DEV_EL1_VTIMER		(1 << 0)
183574c98e20SCornelia Huck #define KVM_ARM_DEV_EL1_PTIMER		(1 << 1)
183674c98e20SCornelia Huck #define KVM_ARM_DEV_PMU			(1 << 2)
183774c98e20SCornelia Huck 
183865a6d8ddSPeter Maydell struct kvm_hyperv_eventfd {
183965a6d8ddSPeter Maydell 	__u32 conn_id;
184065a6d8ddSPeter Maydell 	__s32 fd;
184165a6d8ddSPeter Maydell 	__u32 flags;
184265a6d8ddSPeter Maydell 	__u32 padding[3];
184365a6d8ddSPeter Maydell };
184465a6d8ddSPeter Maydell 
184565a6d8ddSPeter Maydell #define KVM_HYPERV_CONN_ID_MASK		0x00ffffff
184665a6d8ddSPeter Maydell #define KVM_HYPERV_EVENTFD_DEASSIGN	(1 << 0)
184765a6d8ddSPeter Maydell 
1848dc6f8d45SCornelia Huck #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE    (1 << 0)
1849dc6f8d45SCornelia Huck #define KVM_DIRTY_LOG_INITIALLY_SET            (1 << 1)
1850dc6f8d45SCornelia Huck 
1851b3c818a4SEric Farman /*
1852b3c818a4SEric Farman  * Arch needs to define the macro after implementing the dirty ring
1853b3c818a4SEric Farman  * feature.  KVM_DIRTY_LOG_PAGE_OFFSET should be defined as the
1854b3c818a4SEric Farman  * starting page offset of the dirty ring structures.
1855b3c818a4SEric Farman  */
1856b3c818a4SEric Farman #ifndef KVM_DIRTY_LOG_PAGE_OFFSET
1857b3c818a4SEric Farman #define KVM_DIRTY_LOG_PAGE_OFFSET 0
1858b3c818a4SEric Farman #endif
1859b3c818a4SEric Farman 
1860b3c818a4SEric Farman /*
1861b3c818a4SEric Farman  * KVM dirty GFN flags, defined as:
1862b3c818a4SEric Farman  *
1863b3c818a4SEric Farman  * |---------------+---------------+--------------|
1864b3c818a4SEric Farman  * | bit 1 (reset) | bit 0 (dirty) | Status       |
1865b3c818a4SEric Farman  * |---------------+---------------+--------------|
1866b3c818a4SEric Farman  * |             0 |             0 | Invalid GFN  |
1867b3c818a4SEric Farman  * |             0 |             1 | Dirty GFN    |
1868b3c818a4SEric Farman  * |             1 |             X | GFN to reset |
1869b3c818a4SEric Farman  * |---------------+---------------+--------------|
1870b3c818a4SEric Farman  *
1871b3c818a4SEric Farman  * Lifecycle of a dirty GFN goes like:
1872b3c818a4SEric Farman  *
1873b3c818a4SEric Farman  *      dirtied         harvested        reset
1874b3c818a4SEric Farman  * 00 -----------> 01 -------------> 1X -------+
1875b3c818a4SEric Farman  *  ^                                          |
1876b3c818a4SEric Farman  *  |                                          |
1877b3c818a4SEric Farman  *  +------------------------------------------+
1878b3c818a4SEric Farman  *
1879b3c818a4SEric Farman  * The userspace program is only responsible for the 01->1X state
1880b3c818a4SEric Farman  * conversion after harvesting an entry.  Also, it must not skip any
1881b3c818a4SEric Farman  * dirty bits, so that dirty bits are always harvested in sequence.
1882b3c818a4SEric Farman  */
1883*278f064eSEduardo Habkost #define KVM_DIRTY_GFN_F_DIRTY           _BITUL(0)
1884*278f064eSEduardo Habkost #define KVM_DIRTY_GFN_F_RESET           _BITUL(1)
1885b3c818a4SEric Farman #define KVM_DIRTY_GFN_F_MASK            0x3
1886b3c818a4SEric Farman 
1887b3c818a4SEric Farman /*
1888b3c818a4SEric Farman  * KVM dirty rings should be mapped at KVM_DIRTY_LOG_PAGE_OFFSET of
1889b3c818a4SEric Farman  * per-vcpu mmaped regions as an array of struct kvm_dirty_gfn.  The
1890b3c818a4SEric Farman  * size of the gfn buffer is decided by the first argument when
1891b3c818a4SEric Farman  * enabling KVM_CAP_DIRTY_LOG_RING.
1892b3c818a4SEric Farman  */
1893b3c818a4SEric Farman struct kvm_dirty_gfn {
1894b3c818a4SEric Farman 	__u32 flags;
1895b3c818a4SEric Farman 	__u32 slot;
1896b3c818a4SEric Farman 	__u64 offset;
1897b3c818a4SEric Farman };
1898b3c818a4SEric Farman 
1899*278f064eSEduardo Habkost #define KVM_BUS_LOCK_DETECTION_OFF             (1 << 0)
1900*278f064eSEduardo Habkost #define KVM_BUS_LOCK_DETECTION_EXIT            (1 << 1)
1901*278f064eSEduardo Habkost 
190251b24e34SJan Kiszka #endif /* __LINUX_KVM_H */
1903