1dd873966SEric Auger /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
251b24e34SJan Kiszka #ifndef __LINUX_KVM_H
351b24e34SJan Kiszka #define __LINUX_KVM_H
451b24e34SJan Kiszka 
551b24e34SJan Kiszka /*
651b24e34SJan Kiszka  * Userspace interface for /dev/kvm - kernel based virtual machine
751b24e34SJan Kiszka  *
851b24e34SJan Kiszka  * Note: you must update KVM_API_VERSION if you change this interface.
951b24e34SJan Kiszka  */
1051b24e34SJan Kiszka 
11278f064eSEduardo Habkost #include <linux/const.h>
1251b24e34SJan Kiszka #include <linux/types.h>
1351b24e34SJan Kiszka 
1451b24e34SJan Kiszka #include <linux/ioctl.h>
1551b24e34SJan Kiszka #include <asm/kvm.h>
1651b24e34SJan Kiszka 
1751b24e34SJan Kiszka #define KVM_API_VERSION 12
1851b24e34SJan Kiszka 
1951b24e34SJan Kiszka /* for KVM_SET_USER_MEMORY_REGION */
2051b24e34SJan Kiszka struct kvm_userspace_memory_region {
2151b24e34SJan Kiszka 	__u32 slot;
2251b24e34SJan Kiszka 	__u32 flags;
2351b24e34SJan Kiszka 	__u64 guest_phys_addr;
2451b24e34SJan Kiszka 	__u64 memory_size; /* bytes */
2551b24e34SJan Kiszka 	__u64 userspace_addr; /* start of the userspace allocated memory */
2651b24e34SJan Kiszka };
2751b24e34SJan Kiszka 
28*6a02465fSDaniel Henrique Barboza /* for KVM_SET_USER_MEMORY_REGION2 */
29*6a02465fSDaniel Henrique Barboza struct kvm_userspace_memory_region2 {
30*6a02465fSDaniel Henrique Barboza 	__u32 slot;
31*6a02465fSDaniel Henrique Barboza 	__u32 flags;
32*6a02465fSDaniel Henrique Barboza 	__u64 guest_phys_addr;
33*6a02465fSDaniel Henrique Barboza 	__u64 memory_size;
34*6a02465fSDaniel Henrique Barboza 	__u64 userspace_addr;
35*6a02465fSDaniel Henrique Barboza 	__u64 guest_memfd_offset;
36*6a02465fSDaniel Henrique Barboza 	__u32 guest_memfd;
37*6a02465fSDaniel Henrique Barboza 	__u32 pad1;
38*6a02465fSDaniel Henrique Barboza 	__u64 pad2[14];
39*6a02465fSDaniel Henrique Barboza };
40*6a02465fSDaniel Henrique Barboza 
41716b8e4dSAlex Williamson /*
4293d7620cSAvihai Horon  * The bit 0 ~ bit 15 of kvm_userspace_memory_region::flags are visible for
4393d7620cSAvihai Horon  * userspace, other bits are reserved for kvm internal use which are defined
4493d7620cSAvihai Horon  * in include/linux/kvm_host.h.
45716b8e4dSAlex Williamson  */
46716b8e4dSAlex Williamson #define KVM_MEM_LOG_DIRTY_PAGES	(1UL << 0)
47716b8e4dSAlex Williamson #define KVM_MEM_READONLY	(1UL << 1)
48*6a02465fSDaniel Henrique Barboza #define KVM_MEM_GUEST_MEMFD	(1UL << 2)
4951b24e34SJan Kiszka 
5051b24e34SJan Kiszka /* for KVM_IRQ_LINE */
5151b24e34SJan Kiszka struct kvm_irq_level {
5251b24e34SJan Kiszka 	/*
5351b24e34SJan Kiszka 	 * ACPI gsi notion of irq.
5451b24e34SJan Kiszka 	 * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47..
5551b24e34SJan Kiszka 	 * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23..
56f76b348eSCornelia Huck 	 * For ARM: See Documentation/virt/kvm/api.rst
5751b24e34SJan Kiszka 	 */
5851b24e34SJan Kiszka 	union {
5951b24e34SJan Kiszka 		__u32 irq;
6051b24e34SJan Kiszka 		__s32 status;
6151b24e34SJan Kiszka 	};
6251b24e34SJan Kiszka 	__u32 level;
6351b24e34SJan Kiszka };
6451b24e34SJan Kiszka 
6551b24e34SJan Kiszka 
6651b24e34SJan Kiszka struct kvm_irqchip {
6751b24e34SJan Kiszka 	__u32 chip_id;
6851b24e34SJan Kiszka 	__u32 pad;
6951b24e34SJan Kiszka         union {
7051b24e34SJan Kiszka 		char dummy[512];  /* reserving space */
7151b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT
7251b24e34SJan Kiszka 		struct kvm_pic_state pic;
7351b24e34SJan Kiszka #endif
7451b24e34SJan Kiszka #ifdef __KVM_HAVE_IOAPIC
7551b24e34SJan Kiszka 		struct kvm_ioapic_state ioapic;
7651b24e34SJan Kiszka #endif
7751b24e34SJan Kiszka 	} chip;
7851b24e34SJan Kiszka };
7951b24e34SJan Kiszka 
8051b24e34SJan Kiszka /* for KVM_CREATE_PIT2 */
8151b24e34SJan Kiszka struct kvm_pit_config {
8251b24e34SJan Kiszka 	__u32 flags;
8351b24e34SJan Kiszka 	__u32 pad[15];
8451b24e34SJan Kiszka };
8551b24e34SJan Kiszka 
8651b24e34SJan Kiszka #define KVM_PIT_SPEAKER_DUMMY     1
8751b24e34SJan Kiszka 
887a52ce8aSCornelia Huck struct kvm_s390_skeys {
897a52ce8aSCornelia Huck 	__u64 start_gfn;
907a52ce8aSCornelia Huck 	__u64 count;
917a52ce8aSCornelia Huck 	__u64 skeydata_addr;
927a52ce8aSCornelia Huck 	__u32 flags;
937a52ce8aSCornelia Huck 	__u32 reserved[9];
947a52ce8aSCornelia Huck };
95fff02bc0SPaolo Bonzini 
963272f0e2SChristian Borntraeger #define KVM_S390_CMMA_PEEK (1 << 0)
973272f0e2SChristian Borntraeger 
983272f0e2SChristian Borntraeger /**
993272f0e2SChristian Borntraeger  * kvm_s390_cmma_log - Used for CMMA migration.
1003272f0e2SChristian Borntraeger  *
1013272f0e2SChristian Borntraeger  * Used both for input and output.
1023272f0e2SChristian Borntraeger  *
1033272f0e2SChristian Borntraeger  * @start_gfn: Guest page number to start from.
1043272f0e2SChristian Borntraeger  * @count: Size of the result buffer.
1053272f0e2SChristian Borntraeger  * @flags: Control operation mode via KVM_S390_CMMA_* flags
1063272f0e2SChristian Borntraeger  * @remaining: Used with KVM_S390_GET_CMMA_BITS. Indicates how many dirty
1073272f0e2SChristian Borntraeger  *             pages are still remaining.
1083272f0e2SChristian Borntraeger  * @mask: Used with KVM_S390_SET_CMMA_BITS. Bitmap of bits to actually set
1093272f0e2SChristian Borntraeger  *        in the PGSTE.
1103272f0e2SChristian Borntraeger  * @values: Pointer to the values buffer.
1113272f0e2SChristian Borntraeger  *
1123272f0e2SChristian Borntraeger  * Used in KVM_S390_{G,S}ET_CMMA_BITS ioctls.
1133272f0e2SChristian Borntraeger  */
1143272f0e2SChristian Borntraeger struct kvm_s390_cmma_log {
1153272f0e2SChristian Borntraeger 	__u64 start_gfn;
1163272f0e2SChristian Borntraeger 	__u32 count;
1173272f0e2SChristian Borntraeger 	__u32 flags;
1183272f0e2SChristian Borntraeger 	union {
1193272f0e2SChristian Borntraeger 		__u64 remaining;
1203272f0e2SChristian Borntraeger 		__u64 mask;
1213272f0e2SChristian Borntraeger 	};
1223272f0e2SChristian Borntraeger 	__u64 values;
1233272f0e2SChristian Borntraeger };
1243272f0e2SChristian Borntraeger 
125fff02bc0SPaolo Bonzini struct kvm_hyperv_exit {
126fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV_SYNIC          1
127b89485a5SPaolo Bonzini #define KVM_EXIT_HYPERV_HCALL          2
128f76b348eSCornelia Huck #define KVM_EXIT_HYPERV_SYNDBG         3
129fff02bc0SPaolo Bonzini 	__u32 type;
130f76b348eSCornelia Huck 	__u32 pad1;
131fff02bc0SPaolo Bonzini 	union {
132fff02bc0SPaolo Bonzini 		struct {
133fff02bc0SPaolo Bonzini 			__u32 msr;
134f76b348eSCornelia Huck 			__u32 pad2;
135fff02bc0SPaolo Bonzini 			__u64 control;
136fff02bc0SPaolo Bonzini 			__u64 evt_page;
137fff02bc0SPaolo Bonzini 			__u64 msg_page;
138fff02bc0SPaolo Bonzini 		} synic;
139b89485a5SPaolo Bonzini 		struct {
140b89485a5SPaolo Bonzini 			__u64 input;
141b89485a5SPaolo Bonzini 			__u64 result;
142b89485a5SPaolo Bonzini 			__u64 params[2];
143b89485a5SPaolo Bonzini 		} hcall;
144f76b348eSCornelia Huck 		struct {
145f76b348eSCornelia Huck 			__u32 msr;
146f76b348eSCornelia Huck 			__u32 pad2;
147f76b348eSCornelia Huck 			__u64 control;
148f76b348eSCornelia Huck 			__u64 status;
149f76b348eSCornelia Huck 			__u64 send_page;
150f76b348eSCornelia Huck 			__u64 recv_page;
151f76b348eSCornelia Huck 			__u64 pending_page;
152f76b348eSCornelia Huck 		} syndbg;
153fff02bc0SPaolo Bonzini 	} u;
154fff02bc0SPaolo Bonzini };
155fff02bc0SPaolo Bonzini 
156278f064eSEduardo Habkost struct kvm_xen_exit {
157278f064eSEduardo Habkost #define KVM_EXIT_XEN_HCALL          1
158278f064eSEduardo Habkost 	__u32 type;
159278f064eSEduardo Habkost 	union {
160278f064eSEduardo Habkost 		struct {
161278f064eSEduardo Habkost 			__u32 longmode;
162278f064eSEduardo Habkost 			__u32 cpl;
163278f064eSEduardo Habkost 			__u64 input;
164278f064eSEduardo Habkost 			__u64 result;
165278f064eSEduardo Habkost 			__u64 params[6];
166278f064eSEduardo Habkost 		} hcall;
167278f064eSEduardo Habkost 	} u;
168278f064eSEduardo Habkost };
169278f064eSEduardo Habkost 
1707a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS_NONE   1
1717a52ce8aSCornelia Huck #define KVM_S390_SKEYS_MAX        1048576
1727a52ce8aSCornelia Huck 
17351b24e34SJan Kiszka #define KVM_EXIT_UNKNOWN          0
17451b24e34SJan Kiszka #define KVM_EXIT_EXCEPTION        1
17551b24e34SJan Kiszka #define KVM_EXIT_IO               2
17651b24e34SJan Kiszka #define KVM_EXIT_HYPERCALL        3
17751b24e34SJan Kiszka #define KVM_EXIT_DEBUG            4
17851b24e34SJan Kiszka #define KVM_EXIT_HLT              5
17951b24e34SJan Kiszka #define KVM_EXIT_MMIO             6
18051b24e34SJan Kiszka #define KVM_EXIT_IRQ_WINDOW_OPEN  7
18151b24e34SJan Kiszka #define KVM_EXIT_SHUTDOWN         8
18251b24e34SJan Kiszka #define KVM_EXIT_FAIL_ENTRY       9
18351b24e34SJan Kiszka #define KVM_EXIT_INTR             10
18451b24e34SJan Kiszka #define KVM_EXIT_SET_TPR          11
18551b24e34SJan Kiszka #define KVM_EXIT_TPR_ACCESS       12
18651b24e34SJan Kiszka #define KVM_EXIT_S390_SIEIC       13
18751b24e34SJan Kiszka #define KVM_EXIT_S390_RESET       14
188a9fd1654SJens Freimann #define KVM_EXIT_DCR              15 /* deprecated */
18951b24e34SJan Kiszka #define KVM_EXIT_NMI              16
19051b24e34SJan Kiszka #define KVM_EXIT_INTERNAL_ERROR   17
19151b24e34SJan Kiszka #define KVM_EXIT_OSI              18
1927c6da3deSAlexander Graf #define KVM_EXIT_PAPR_HCALL	  19
1931529ae1bSAlexander Graf #define KVM_EXIT_S390_UCONTROL	  20
194d4834ff9SAlexander Graf #define KVM_EXIT_WATCHDOG         21
195d3dccee1SAlexander Graf #define KVM_EXIT_S390_TSCH        22
196d3dccee1SAlexander Graf #define KVM_EXIT_EPR              23
197b061808dSAlexander Graf #define KVM_EXIT_SYSTEM_EVENT     24
1987a52ce8aSCornelia Huck #define KVM_EXIT_S390_STSI        25
1993a824b15SPaolo Bonzini #define KVM_EXIT_IOAPIC_EOI       26
200fff02bc0SPaolo Bonzini #define KVM_EXIT_HYPERV           27
2012a886794SGreg Kurz #define KVM_EXIT_ARM_NISV         28
20253ba2eeeSMatthew Rosato #define KVM_EXIT_X86_RDMSR        29
20353ba2eeeSMatthew Rosato #define KVM_EXIT_X86_WRMSR        30
204b3c818a4SEric Farman #define KVM_EXIT_DIRTY_RING_FULL  31
205278f064eSEduardo Habkost #define KVM_EXIT_AP_RESET_HOLD    32
206278f064eSEduardo Habkost #define KVM_EXIT_X86_BUS_LOCK     33
207278f064eSEduardo Habkost #define KVM_EXIT_XEN              34
20843709a0cSPaolo Bonzini #define KVM_EXIT_RISCV_SBI        35
209d525f73fSChenyi Qiang #define KVM_EXIT_RISCV_CSR        36
210d525f73fSChenyi Qiang #define KVM_EXIT_NOTIFY           37
211efb91426SDaniel Henrique Barboza #define KVM_EXIT_LOONGARCH_IOCSR  38
212*6a02465fSDaniel Henrique Barboza #define KVM_EXIT_MEMORY_FAULT     39
21351b24e34SJan Kiszka 
21451b24e34SJan Kiszka /* For KVM_EXIT_INTERNAL_ERROR */
215d4834ff9SAlexander Graf /* Emulate instruction failed. */
21651b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_EMULATION	1
217d4834ff9SAlexander Graf /* Encounter unexpected simultaneous exceptions. */
21851b24e34SJan Kiszka #define KVM_INTERNAL_ERROR_SIMUL_EX	2
219d4834ff9SAlexander Graf /* Encounter unexpected vm-exit due to delivery event. */
220d4834ff9SAlexander Graf #define KVM_INTERNAL_ERROR_DELIVERY_EV	3
221f363d039SEric Auger /* Encounter unexpected vm-exit reason */
222f363d039SEric Auger #define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON	4
22351b24e34SJan Kiszka 
224327d4b7fSBharata B Rao /* Flags that describe what fields in emulation_failure hold valid data. */
225327d4b7fSBharata B Rao #define KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES (1ULL << 0)
226327d4b7fSBharata B Rao 
22751b24e34SJan Kiszka /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
22851b24e34SJan Kiszka struct kvm_run {
22951b24e34SJan Kiszka 	/* in */
23051b24e34SJan Kiszka 	__u8 request_interrupt_window;
2313a5eb5b4SPaolo Bonzini 	__u8 immediate_exit;
2323a5eb5b4SPaolo Bonzini 	__u8 padding1[6];
23351b24e34SJan Kiszka 
23451b24e34SJan Kiszka 	/* out */
23551b24e34SJan Kiszka 	__u32 exit_reason;
23651b24e34SJan Kiszka 	__u8 ready_for_interrupt_injection;
23751b24e34SJan Kiszka 	__u8 if_flag;
23824a31426SPaolo Bonzini 	__u16 flags;
23951b24e34SJan Kiszka 
24051b24e34SJan Kiszka 	/* in (pre_kvm_run), out (post_kvm_run) */
24151b24e34SJan Kiszka 	__u64 cr8;
24251b24e34SJan Kiszka 	__u64 apic_base;
24351b24e34SJan Kiszka 
24451b24e34SJan Kiszka #ifdef __KVM_S390
24551b24e34SJan Kiszka 	/* the processor status word for s390 */
24651b24e34SJan Kiszka 	__u64 psw_mask; /* psw upper half */
24751b24e34SJan Kiszka 	__u64 psw_addr; /* psw lower half */
24851b24e34SJan Kiszka #endif
24951b24e34SJan Kiszka 	union {
25051b24e34SJan Kiszka 		/* KVM_EXIT_UNKNOWN */
25151b24e34SJan Kiszka 		struct {
25251b24e34SJan Kiszka 			__u64 hardware_exit_reason;
25351b24e34SJan Kiszka 		} hw;
25451b24e34SJan Kiszka 		/* KVM_EXIT_FAIL_ENTRY */
25551b24e34SJan Kiszka 		struct {
25651b24e34SJan Kiszka 			__u64 hardware_entry_failure_reason;
257e6546342SJason Wang 			__u32 cpu;
25851b24e34SJan Kiszka 		} fail_entry;
25951b24e34SJan Kiszka 		/* KVM_EXIT_EXCEPTION */
26051b24e34SJan Kiszka 		struct {
26151b24e34SJan Kiszka 			__u32 exception;
26251b24e34SJan Kiszka 			__u32 error_code;
26351b24e34SJan Kiszka 		} ex;
26451b24e34SJan Kiszka 		/* KVM_EXIT_IO */
26551b24e34SJan Kiszka 		struct {
26651b24e34SJan Kiszka #define KVM_EXIT_IO_IN  0
26751b24e34SJan Kiszka #define KVM_EXIT_IO_OUT 1
26851b24e34SJan Kiszka 			__u8 direction;
26951b24e34SJan Kiszka 			__u8 size; /* bytes */
27051b24e34SJan Kiszka 			__u16 port;
27151b24e34SJan Kiszka 			__u32 count;
27251b24e34SJan Kiszka 			__u64 data_offset; /* relative to kvm_run start */
27351b24e34SJan Kiszka 		} io;
2743a824b15SPaolo Bonzini 		/* KVM_EXIT_DEBUG */
27551b24e34SJan Kiszka 		struct {
27651b24e34SJan Kiszka 			struct kvm_debug_exit_arch arch;
27751b24e34SJan Kiszka 		} debug;
27851b24e34SJan Kiszka 		/* KVM_EXIT_MMIO */
27951b24e34SJan Kiszka 		struct {
28051b24e34SJan Kiszka 			__u64 phys_addr;
28151b24e34SJan Kiszka 			__u8  data[8];
28251b24e34SJan Kiszka 			__u32 len;
28351b24e34SJan Kiszka 			__u8  is_write;
28451b24e34SJan Kiszka 		} mmio;
285efb91426SDaniel Henrique Barboza 		/* KVM_EXIT_LOONGARCH_IOCSR */
286efb91426SDaniel Henrique Barboza 		struct {
287efb91426SDaniel Henrique Barboza 			__u64 phys_addr;
288efb91426SDaniel Henrique Barboza 			__u8  data[8];
289efb91426SDaniel Henrique Barboza 			__u32 len;
290efb91426SDaniel Henrique Barboza 			__u8  is_write;
291efb91426SDaniel Henrique Barboza 		} iocsr_io;
29251b24e34SJan Kiszka 		/* KVM_EXIT_HYPERCALL */
29351b24e34SJan Kiszka 		struct {
29451b24e34SJan Kiszka 			__u64 nr;
29551b24e34SJan Kiszka 			__u64 args[6];
29651b24e34SJan Kiszka 			__u64 ret;
297d0bf492fSCédric Le Goater 
298d0bf492fSCédric Le Goater 			union {
29951b24e34SJan Kiszka 				__u32 longmode;
300d0bf492fSCédric Le Goater 				__u64 flags;
301d0bf492fSCédric Le Goater 			};
30251b24e34SJan Kiszka 		} hypercall;
30351b24e34SJan Kiszka 		/* KVM_EXIT_TPR_ACCESS */
30451b24e34SJan Kiszka 		struct {
30551b24e34SJan Kiszka 			__u64 rip;
30651b24e34SJan Kiszka 			__u32 is_write;
30751b24e34SJan Kiszka 			__u32 pad;
30851b24e34SJan Kiszka 		} tpr_access;
30951b24e34SJan Kiszka 		/* KVM_EXIT_S390_SIEIC */
31051b24e34SJan Kiszka 		struct {
31151b24e34SJan Kiszka 			__u8 icptcode;
31251b24e34SJan Kiszka 			__u16 ipa;
31351b24e34SJan Kiszka 			__u32 ipb;
31451b24e34SJan Kiszka 		} s390_sieic;
31551b24e34SJan Kiszka 		/* KVM_EXIT_S390_RESET */
31651b24e34SJan Kiszka #define KVM_S390_RESET_POR       1
31751b24e34SJan Kiszka #define KVM_S390_RESET_CLEAR     2
31851b24e34SJan Kiszka #define KVM_S390_RESET_SUBSYSTEM 4
31951b24e34SJan Kiszka #define KVM_S390_RESET_CPU_INIT  8
32051b24e34SJan Kiszka #define KVM_S390_RESET_IPL       16
32151b24e34SJan Kiszka 		__u64 s390_reset_flags;
3221529ae1bSAlexander Graf 		/* KVM_EXIT_S390_UCONTROL */
3231529ae1bSAlexander Graf 		struct {
3241529ae1bSAlexander Graf 			__u64 trans_exc_code;
3251529ae1bSAlexander Graf 			__u32 pgm_code;
3261529ae1bSAlexander Graf 		} s390_ucontrol;
327a9fd1654SJens Freimann 		/* KVM_EXIT_DCR (deprecated) */
32851b24e34SJan Kiszka 		struct {
32951b24e34SJan Kiszka 			__u32 dcrn;
33051b24e34SJan Kiszka 			__u32 data;
33151b24e34SJan Kiszka 			__u8  is_write;
33251b24e34SJan Kiszka 		} dcr;
3333a824b15SPaolo Bonzini 		/* KVM_EXIT_INTERNAL_ERROR */
33451b24e34SJan Kiszka 		struct {
33551b24e34SJan Kiszka 			__u32 suberror;
33651b24e34SJan Kiszka 			/* Available with KVM_CAP_INTERNAL_ERROR_DATA: */
33751b24e34SJan Kiszka 			__u32 ndata;
33851b24e34SJan Kiszka 			__u64 data[16];
33951b24e34SJan Kiszka 		} internal;
340327d4b7fSBharata B Rao 		/*
341327d4b7fSBharata B Rao 		 * KVM_INTERNAL_ERROR_EMULATION
342327d4b7fSBharata B Rao 		 *
343327d4b7fSBharata B Rao 		 * "struct emulation_failure" is an overlay of "struct internal"
344327d4b7fSBharata B Rao 		 * that is used for the KVM_INTERNAL_ERROR_EMULATION sub-type of
345327d4b7fSBharata B Rao 		 * KVM_EXIT_INTERNAL_ERROR.  Note, unlike other internal error
346327d4b7fSBharata B Rao 		 * sub-types, this struct is ABI!  It also needs to be backwards
347327d4b7fSBharata B Rao 		 * compatible with "struct internal".  Take special care that
348327d4b7fSBharata B Rao 		 * "ndata" is correct, that new fields are enumerated in "flags",
349327d4b7fSBharata B Rao 		 * and that each flag enumerates fields that are 64-bit aligned
350327d4b7fSBharata B Rao 		 * and sized (so that ndata+internal.data[] is valid/accurate).
35143709a0cSPaolo Bonzini 		 *
35243709a0cSPaolo Bonzini 		 * Space beyond the defined fields may be used to store arbitrary
35343709a0cSPaolo Bonzini 		 * debug information relating to the emulation failure. It is
35443709a0cSPaolo Bonzini 		 * accounted for in "ndata" but the format is unspecified and is
35543709a0cSPaolo Bonzini 		 * not represented in "flags". Any such information is *not* ABI!
356327d4b7fSBharata B Rao 		 */
357327d4b7fSBharata B Rao 		struct {
358327d4b7fSBharata B Rao 			__u32 suberror;
359327d4b7fSBharata B Rao 			__u32 ndata;
360327d4b7fSBharata B Rao 			__u64 flags;
36143709a0cSPaolo Bonzini 			union {
36243709a0cSPaolo Bonzini 				struct {
363327d4b7fSBharata B Rao 					__u8  insn_size;
364327d4b7fSBharata B Rao 					__u8  insn_bytes[15];
36543709a0cSPaolo Bonzini 				};
36643709a0cSPaolo Bonzini 			};
36743709a0cSPaolo Bonzini 			/* Arbitrary debug data may follow. */
368327d4b7fSBharata B Rao 		} emulation_failure;
36951b24e34SJan Kiszka 		/* KVM_EXIT_OSI */
37051b24e34SJan Kiszka 		struct {
37151b24e34SJan Kiszka 			__u64 gprs[32];
37251b24e34SJan Kiszka 		} osi;
3733a824b15SPaolo Bonzini 		/* KVM_EXIT_PAPR_HCALL */
3747c6da3deSAlexander Graf 		struct {
3757c6da3deSAlexander Graf 			__u64 nr;
3767c6da3deSAlexander Graf 			__u64 ret;
3777c6da3deSAlexander Graf 			__u64 args[9];
3787c6da3deSAlexander Graf 		} papr_hcall;
379d3dccee1SAlexander Graf 		/* KVM_EXIT_S390_TSCH */
380d3dccee1SAlexander Graf 		struct {
381d3dccee1SAlexander Graf 			__u16 subchannel_id;
382d3dccee1SAlexander Graf 			__u16 subchannel_nr;
383d3dccee1SAlexander Graf 			__u32 io_int_parm;
384d3dccee1SAlexander Graf 			__u32 io_int_word;
385d3dccee1SAlexander Graf 			__u32 ipb;
386d3dccee1SAlexander Graf 			__u8 dequeued;
387d3dccee1SAlexander Graf 		} s390_tsch;
388d3dccee1SAlexander Graf 		/* KVM_EXIT_EPR */
389d3dccee1SAlexander Graf 		struct {
390d3dccee1SAlexander Graf 			__u32 epr;
391d3dccee1SAlexander Graf 		} epr;
392b061808dSAlexander Graf 		/* KVM_EXIT_SYSTEM_EVENT */
393b061808dSAlexander Graf 		struct {
394b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_SHUTDOWN       1
395b061808dSAlexander Graf #define KVM_SYSTEM_EVENT_RESET          2
396120758fbSPaolo Bonzini #define KVM_SYSTEM_EVENT_CRASH          3
397d525f73fSChenyi Qiang #define KVM_SYSTEM_EVENT_WAKEUP         4
398d525f73fSChenyi Qiang #define KVM_SYSTEM_EVENT_SUSPEND        5
399d525f73fSChenyi Qiang #define KVM_SYSTEM_EVENT_SEV_TERM       6
400b061808dSAlexander Graf 			__u32 type;
401e4082063SAlex Williamson 			__u32 ndata;
402e4082063SAlex Williamson 			union {
403b061808dSAlexander Graf 				__u64 flags;
404e4082063SAlex Williamson 				__u64 data[16];
405e4082063SAlex Williamson 			};
406b061808dSAlexander Graf 		} system_event;
4077a52ce8aSCornelia Huck 		/* KVM_EXIT_S390_STSI */
4087a52ce8aSCornelia Huck 		struct {
4097a52ce8aSCornelia Huck 			__u64 addr;
4107a52ce8aSCornelia Huck 			__u8 ar;
4117a52ce8aSCornelia Huck 			__u8 reserved;
4127a52ce8aSCornelia Huck 			__u8 fc;
4137a52ce8aSCornelia Huck 			__u8 sel1;
4147a52ce8aSCornelia Huck 			__u16 sel2;
4157a52ce8aSCornelia Huck 		} s390_stsi;
4163a824b15SPaolo Bonzini 		/* KVM_EXIT_IOAPIC_EOI */
4173a824b15SPaolo Bonzini 		struct {
4183a824b15SPaolo Bonzini 			__u8 vector;
4193a824b15SPaolo Bonzini 		} eoi;
420fff02bc0SPaolo Bonzini 		/* KVM_EXIT_HYPERV */
421fff02bc0SPaolo Bonzini 		struct kvm_hyperv_exit hyperv;
4222a886794SGreg Kurz 		/* KVM_EXIT_ARM_NISV */
4232a886794SGreg Kurz 		struct {
4242a886794SGreg Kurz 			__u64 esr_iss;
4252a886794SGreg Kurz 			__u64 fault_ipa;
4262a886794SGreg Kurz 		} arm_nisv;
42753ba2eeeSMatthew Rosato 		/* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */
42853ba2eeeSMatthew Rosato 		struct {
42953ba2eeeSMatthew Rosato 			__u8 error; /* user -> kernel */
43053ba2eeeSMatthew Rosato 			__u8 pad[7];
43153ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_INVAL	(1 << 0)
43253ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_UNKNOWN	(1 << 1)
43353ba2eeeSMatthew Rosato #define KVM_MSR_EXIT_REASON_FILTER	(1 << 2)
43493d7620cSAvihai Horon #define KVM_MSR_EXIT_REASON_VALID_MASK	(KVM_MSR_EXIT_REASON_INVAL   |	\
43593d7620cSAvihai Horon 					 KVM_MSR_EXIT_REASON_UNKNOWN |	\
43693d7620cSAvihai Horon 					 KVM_MSR_EXIT_REASON_FILTER)
43753ba2eeeSMatthew Rosato 			__u32 reason; /* kernel -> user */
43853ba2eeeSMatthew Rosato 			__u32 index; /* kernel -> user */
43953ba2eeeSMatthew Rosato 			__u64 data; /* kernel <-> user */
44053ba2eeeSMatthew Rosato 		} msr;
441278f064eSEduardo Habkost 		/* KVM_EXIT_XEN */
442278f064eSEduardo Habkost 		struct kvm_xen_exit xen;
44343709a0cSPaolo Bonzini 		/* KVM_EXIT_RISCV_SBI */
44443709a0cSPaolo Bonzini 		struct {
44543709a0cSPaolo Bonzini 			unsigned long extension_id;
44643709a0cSPaolo Bonzini 			unsigned long function_id;
44743709a0cSPaolo Bonzini 			unsigned long args[6];
44843709a0cSPaolo Bonzini 			unsigned long ret[2];
44943709a0cSPaolo Bonzini 		} riscv_sbi;
450d525f73fSChenyi Qiang 		/* KVM_EXIT_RISCV_CSR */
451d525f73fSChenyi Qiang 		struct {
452d525f73fSChenyi Qiang 			unsigned long csr_num;
453d525f73fSChenyi Qiang 			unsigned long new_value;
454d525f73fSChenyi Qiang 			unsigned long write_mask;
455d525f73fSChenyi Qiang 			unsigned long ret_value;
456d525f73fSChenyi Qiang 		} riscv_csr;
457d525f73fSChenyi Qiang 		/* KVM_EXIT_NOTIFY */
458d525f73fSChenyi Qiang 		struct {
459d525f73fSChenyi Qiang #define KVM_NOTIFY_CONTEXT_INVALID	(1 << 0)
460d525f73fSChenyi Qiang 			__u32 flags;
461d525f73fSChenyi Qiang 		} notify;
462*6a02465fSDaniel Henrique Barboza 		/* KVM_EXIT_MEMORY_FAULT */
463*6a02465fSDaniel Henrique Barboza 		struct {
464*6a02465fSDaniel Henrique Barboza #define KVM_MEMORY_EXIT_FLAG_PRIVATE	(1ULL << 3)
465*6a02465fSDaniel Henrique Barboza 			__u64 flags;
466*6a02465fSDaniel Henrique Barboza 			__u64 gpa;
467*6a02465fSDaniel Henrique Barboza 			__u64 size;
468*6a02465fSDaniel Henrique Barboza 		} memory_fault;
46951b24e34SJan Kiszka 		/* Fix the size of the union. */
47051b24e34SJan Kiszka 		char padding[256];
47151b24e34SJan Kiszka 	};
4721529ae1bSAlexander Graf 
47365a6d8ddSPeter Maydell 	/* 2048 is the size of the char array used to bound/pad the size
47465a6d8ddSPeter Maydell 	 * of the union that holds sync regs.
47565a6d8ddSPeter Maydell 	 */
47665a6d8ddSPeter Maydell 	#define SYNC_REGS_SIZE_BYTES 2048
4771529ae1bSAlexander Graf 	/*
4781529ae1bSAlexander Graf 	 * shared registers between kvm and userspace.
4791529ae1bSAlexander Graf 	 * kvm_valid_regs specifies the register classes set by the host
4801529ae1bSAlexander Graf 	 * kvm_dirty_regs specified the register classes dirtied by userspace
4811529ae1bSAlexander Graf 	 * struct kvm_sync_regs is architecture specific, as well as the
4821529ae1bSAlexander Graf 	 * bits for kvm_valid_regs and kvm_dirty_regs
4831529ae1bSAlexander Graf 	 */
4841529ae1bSAlexander Graf 	__u64 kvm_valid_regs;
4851529ae1bSAlexander Graf 	__u64 kvm_dirty_regs;
4861529ae1bSAlexander Graf 	union {
4871529ae1bSAlexander Graf 		struct kvm_sync_regs regs;
48865a6d8ddSPeter Maydell 		char padding[SYNC_REGS_SIZE_BYTES];
4891529ae1bSAlexander Graf 	} s;
49051b24e34SJan Kiszka };
49151b24e34SJan Kiszka 
49251b24e34SJan Kiszka /* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */
49351b24e34SJan Kiszka 
49451b24e34SJan Kiszka struct kvm_coalesced_mmio_zone {
49551b24e34SJan Kiszka 	__u64 addr;
49651b24e34SJan Kiszka 	__u32 size;
497966f2ec3SPaolo Bonzini 	union {
49851b24e34SJan Kiszka 		__u32 pad;
499966f2ec3SPaolo Bonzini 		__u32 pio;
500966f2ec3SPaolo Bonzini 	};
50151b24e34SJan Kiszka };
50251b24e34SJan Kiszka 
50351b24e34SJan Kiszka struct kvm_coalesced_mmio {
50451b24e34SJan Kiszka 	__u64 phys_addr;
50551b24e34SJan Kiszka 	__u32 len;
506966f2ec3SPaolo Bonzini 	union {
50751b24e34SJan Kiszka 		__u32 pad;
508966f2ec3SPaolo Bonzini 		__u32 pio;
509966f2ec3SPaolo Bonzini 	};
51051b24e34SJan Kiszka 	__u8  data[8];
51151b24e34SJan Kiszka };
51251b24e34SJan Kiszka 
51351b24e34SJan Kiszka struct kvm_coalesced_mmio_ring {
51451b24e34SJan Kiszka 	__u32 first, last;
515d525f73fSChenyi Qiang 	struct kvm_coalesced_mmio coalesced_mmio[];
51651b24e34SJan Kiszka };
51751b24e34SJan Kiszka 
51851b24e34SJan Kiszka #define KVM_COALESCED_MMIO_MAX \
51951b24e34SJan Kiszka 	((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \
52051b24e34SJan Kiszka 	 sizeof(struct kvm_coalesced_mmio))
52151b24e34SJan Kiszka 
52251b24e34SJan Kiszka /* for KVM_TRANSLATE */
52351b24e34SJan Kiszka struct kvm_translation {
52451b24e34SJan Kiszka 	/* in */
52551b24e34SJan Kiszka 	__u64 linear_address;
52651b24e34SJan Kiszka 
52751b24e34SJan Kiszka 	/* out */
52851b24e34SJan Kiszka 	__u64 physical_address;
52951b24e34SJan Kiszka 	__u8  valid;
53051b24e34SJan Kiszka 	__u8  writeable;
53151b24e34SJan Kiszka 	__u8  usermode;
53251b24e34SJan Kiszka 	__u8  pad[5];
53351b24e34SJan Kiszka };
53451b24e34SJan Kiszka 
5357a52ce8aSCornelia Huck /* for KVM_S390_MEM_OP */
5367a52ce8aSCornelia Huck struct kvm_s390_mem_op {
5377a52ce8aSCornelia Huck 	/* in */
5387a52ce8aSCornelia Huck 	__u64 gaddr;		/* the guest address */
5397a52ce8aSCornelia Huck 	__u64 flags;		/* flags */
5407a52ce8aSCornelia Huck 	__u32 size;		/* amount of bytes */
5417a52ce8aSCornelia Huck 	__u32 op;		/* type of operation */
5427a52ce8aSCornelia Huck 	__u64 buf;		/* buffer in userspace */
543dc6f8d45SCornelia Huck 	union {
544e4082063SAlex Williamson 		struct {
5457a52ce8aSCornelia Huck 			__u8 ar;	/* the access register number */
546e4082063SAlex Williamson 			__u8 key;	/* access key, ignored if flag unset */
547c5c0fdbeSDavid 'Digit' Turner 			__u8 pad1[6];	/* ignored */
548c5c0fdbeSDavid 'Digit' Turner 			__u64 old_addr;	/* ignored if cmpxchg flag unset */
549e4082063SAlex Williamson 		};
550dc6f8d45SCornelia Huck 		__u32 sida_offset; /* offset into the sida */
551e4082063SAlex Williamson 		__u8 reserved[32]; /* ignored */
552dc6f8d45SCornelia Huck 	};
5537a52ce8aSCornelia Huck };
5547a52ce8aSCornelia Huck /* types for kvm_s390_mem_op->op */
5557a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_READ	0
5567a52ce8aSCornelia Huck #define KVM_S390_MEMOP_LOGICAL_WRITE	1
557dc6f8d45SCornelia Huck #define KVM_S390_MEMOP_SIDA_READ	2
558dc6f8d45SCornelia Huck #define KVM_S390_MEMOP_SIDA_WRITE	3
559e4082063SAlex Williamson #define KVM_S390_MEMOP_ABSOLUTE_READ	4
560e4082063SAlex Williamson #define KVM_S390_MEMOP_ABSOLUTE_WRITE	5
561c5c0fdbeSDavid 'Digit' Turner #define KVM_S390_MEMOP_ABSOLUTE_CMPXCHG	6
562c5c0fdbeSDavid 'Digit' Turner 
5637a52ce8aSCornelia Huck /* flags for kvm_s390_mem_op->flags */
5647a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_CHECK_ONLY		(1ULL << 0)
5657a52ce8aSCornelia Huck #define KVM_S390_MEMOP_F_INJECT_EXCEPTION	(1ULL << 1)
566e4082063SAlex Williamson #define KVM_S390_MEMOP_F_SKEY_PROTECTION	(1ULL << 2)
5677a52ce8aSCornelia Huck 
568c5c0fdbeSDavid 'Digit' Turner /* flags specifying extension support via KVM_CAP_S390_MEM_OP_EXTENSION */
569c5c0fdbeSDavid 'Digit' Turner #define KVM_S390_MEMOP_EXTENSION_CAP_BASE	(1 << 0)
570c5c0fdbeSDavid 'Digit' Turner #define KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG	(1 << 1)
571c5c0fdbeSDavid 'Digit' Turner 
57251b24e34SJan Kiszka /* for KVM_INTERRUPT */
57351b24e34SJan Kiszka struct kvm_interrupt {
57451b24e34SJan Kiszka 	/* in */
57551b24e34SJan Kiszka 	__u32 irq;
57651b24e34SJan Kiszka };
57751b24e34SJan Kiszka 
57851b24e34SJan Kiszka /* for KVM_GET_DIRTY_LOG */
57951b24e34SJan Kiszka struct kvm_dirty_log {
58051b24e34SJan Kiszka 	__u32 slot;
58151b24e34SJan Kiszka 	__u32 padding1;
58251b24e34SJan Kiszka 	union {
58351b24e34SJan Kiszka 		void *dirty_bitmap; /* one bit per page */
58451b24e34SJan Kiszka 		__u64 padding2;
58551b24e34SJan Kiszka 	};
58651b24e34SJan Kiszka };
58751b24e34SJan Kiszka 
588da054c64SPaolo Bonzini /* for KVM_CLEAR_DIRTY_LOG */
589da054c64SPaolo Bonzini struct kvm_clear_dirty_log {
590da054c64SPaolo Bonzini 	__u32 slot;
591da054c64SPaolo Bonzini 	__u32 num_pages;
592da054c64SPaolo Bonzini 	__u64 first_page;
593da054c64SPaolo Bonzini 	union {
594da054c64SPaolo Bonzini 		void *dirty_bitmap; /* one bit per page */
595da054c64SPaolo Bonzini 		__u64 padding2;
596da054c64SPaolo Bonzini 	};
597da054c64SPaolo Bonzini };
598da054c64SPaolo Bonzini 
59951b24e34SJan Kiszka /* for KVM_SET_SIGNAL_MASK */
60051b24e34SJan Kiszka struct kvm_signal_mask {
60151b24e34SJan Kiszka 	__u32 len;
602d525f73fSChenyi Qiang 	__u8  sigset[];
60351b24e34SJan Kiszka };
60451b24e34SJan Kiszka 
60551b24e34SJan Kiszka /* for KVM_TPR_ACCESS_REPORTING */
60651b24e34SJan Kiszka struct kvm_tpr_access_ctl {
60751b24e34SJan Kiszka 	__u32 enabled;
60851b24e34SJan Kiszka 	__u32 flags;
60951b24e34SJan Kiszka 	__u32 reserved[8];
61051b24e34SJan Kiszka };
61151b24e34SJan Kiszka 
61251b24e34SJan Kiszka /* for KVM_SET_VAPIC_ADDR */
61351b24e34SJan Kiszka struct kvm_vapic_addr {
61451b24e34SJan Kiszka 	__u64 vapic_addr;
61551b24e34SJan Kiszka };
61651b24e34SJan Kiszka 
617a9fd1654SJens Freimann /* for KVM_SET_MP_STATE */
61851b24e34SJan Kiszka 
619a9fd1654SJens Freimann /* not all states are valid on all architectures */
62051b24e34SJan Kiszka #define KVM_MP_STATE_RUNNABLE          0
62151b24e34SJan Kiszka #define KVM_MP_STATE_UNINITIALIZED     1
62251b24e34SJan Kiszka #define KVM_MP_STATE_INIT_RECEIVED     2
62351b24e34SJan Kiszka #define KVM_MP_STATE_HALTED            3
62451b24e34SJan Kiszka #define KVM_MP_STATE_SIPI_RECEIVED     4
625a9fd1654SJens Freimann #define KVM_MP_STATE_STOPPED           5
626a9fd1654SJens Freimann #define KVM_MP_STATE_CHECK_STOP        6
627a9fd1654SJens Freimann #define KVM_MP_STATE_OPERATING         7
628a9fd1654SJens Freimann #define KVM_MP_STATE_LOAD              8
629278f064eSEduardo Habkost #define KVM_MP_STATE_AP_RESET_HOLD     9
630d525f73fSChenyi Qiang #define KVM_MP_STATE_SUSPENDED         10
63151b24e34SJan Kiszka 
63251b24e34SJan Kiszka struct kvm_mp_state {
63351b24e34SJan Kiszka 	__u32 mp_state;
63451b24e34SJan Kiszka };
63551b24e34SJan Kiszka 
63651b24e34SJan Kiszka struct kvm_s390_psw {
63751b24e34SJan Kiszka 	__u64 mask;
63851b24e34SJan Kiszka 	__u64 addr;
63951b24e34SJan Kiszka };
64051b24e34SJan Kiszka 
64151b24e34SJan Kiszka /* valid values for type in kvm_s390_interrupt */
64251b24e34SJan Kiszka #define KVM_S390_SIGP_STOP		0xfffe0000u
64351b24e34SJan Kiszka #define KVM_S390_PROGRAM_INT		0xfffe0001u
64451b24e34SJan Kiszka #define KVM_S390_SIGP_SET_PREFIX	0xfffe0002u
64551b24e34SJan Kiszka #define KVM_S390_RESTART		0xfffe0003u
646216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_INIT	0xfffe0004u
647216db403SChristian Borntraeger #define KVM_S390_INT_PFAULT_DONE	0xfffe0005u
648d3dccee1SAlexander Graf #define KVM_S390_MCHK			0xfffe1000u
64976eb98d5SJens Freimann #define KVM_S390_INT_CLOCK_COMP		0xffff1004u
65076eb98d5SJens Freimann #define KVM_S390_INT_CPU_TIMER		0xffff1005u
65151b24e34SJan Kiszka #define KVM_S390_INT_VIRTIO		0xffff2603u
65251b24e34SJan Kiszka #define KVM_S390_INT_SERVICE		0xffff2401u
65351b24e34SJan Kiszka #define KVM_S390_INT_EMERGENCY		0xffff1201u
6541529ae1bSAlexander Graf #define KVM_S390_INT_EXTERNAL_CALL	0xffff1202u
655d3dccee1SAlexander Graf /* Anything below 0xfffe0000u is taken by INT_IO */
656d3dccee1SAlexander Graf #define KVM_S390_INT_IO(ai,cssid,ssid,schid)   \
657d3dccee1SAlexander Graf 	(((schid)) |			       \
658d3dccee1SAlexander Graf 	 ((ssid) << 16) |		       \
659d3dccee1SAlexander Graf 	 ((cssid) << 18) |		       \
660d3dccee1SAlexander Graf 	 ((ai) << 26))
661d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MIN		0x00000000u
662d3dccee1SAlexander Graf #define KVM_S390_INT_IO_MAX		0xfffdffffu
663120758fbSPaolo Bonzini #define KVM_S390_INT_IO_AI_MASK		0x04000000u
664d3dccee1SAlexander Graf 
66551b24e34SJan Kiszka 
66651b24e34SJan Kiszka struct kvm_s390_interrupt {
66751b24e34SJan Kiszka 	__u32 type;
66851b24e34SJan Kiszka 	__u32 parm;
66951b24e34SJan Kiszka 	__u64 parm64;
67051b24e34SJan Kiszka };
67151b24e34SJan Kiszka 
672216db403SChristian Borntraeger struct kvm_s390_io_info {
673216db403SChristian Borntraeger 	__u16 subchannel_id;
674216db403SChristian Borntraeger 	__u16 subchannel_nr;
675216db403SChristian Borntraeger 	__u32 io_int_parm;
676216db403SChristian Borntraeger 	__u32 io_int_word;
677216db403SChristian Borntraeger };
678216db403SChristian Borntraeger 
679216db403SChristian Borntraeger struct kvm_s390_ext_info {
680216db403SChristian Borntraeger 	__u32 ext_params;
681216db403SChristian Borntraeger 	__u32 pad;
682216db403SChristian Borntraeger 	__u64 ext_params2;
683216db403SChristian Borntraeger };
684216db403SChristian Borntraeger 
685216db403SChristian Borntraeger struct kvm_s390_pgm_info {
686216db403SChristian Borntraeger 	__u64 trans_exc_code;
687216db403SChristian Borntraeger 	__u64 mon_code;
688216db403SChristian Borntraeger 	__u64 per_address;
689216db403SChristian Borntraeger 	__u32 data_exc_code;
690216db403SChristian Borntraeger 	__u16 code;
691216db403SChristian Borntraeger 	__u16 mon_class_nr;
692216db403SChristian Borntraeger 	__u8 per_code;
693216db403SChristian Borntraeger 	__u8 per_atmid;
694216db403SChristian Borntraeger 	__u8 exc_access_id;
695216db403SChristian Borntraeger 	__u8 per_access_id;
696216db403SChristian Borntraeger 	__u8 op_access_id;
69766fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_VALID	0x01
69866fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_0	0x02
69966fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_1	0x04
70066fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_ILC_MASK	0x06
70166fb2d54SCornelia Huck #define KVM_S390_PGM_FLAGS_NO_REWIND	0x08
70266fb2d54SCornelia Huck 	__u8 flags;
70366fb2d54SCornelia Huck 	__u8 pad[2];
704216db403SChristian Borntraeger };
705216db403SChristian Borntraeger 
706216db403SChristian Borntraeger struct kvm_s390_prefix_info {
707216db403SChristian Borntraeger 	__u32 address;
708216db403SChristian Borntraeger };
709216db403SChristian Borntraeger 
710216db403SChristian Borntraeger struct kvm_s390_extcall_info {
711216db403SChristian Borntraeger 	__u16 code;
712216db403SChristian Borntraeger };
713216db403SChristian Borntraeger 
714216db403SChristian Borntraeger struct kvm_s390_emerg_info {
715216db403SChristian Borntraeger 	__u16 code;
716216db403SChristian Borntraeger };
717216db403SChristian Borntraeger 
71851628b18SChristian Borntraeger #define KVM_S390_STOP_FLAG_STORE_STATUS	0x01
71951628b18SChristian Borntraeger struct kvm_s390_stop_info {
72051628b18SChristian Borntraeger 	__u32 flags;
72151628b18SChristian Borntraeger };
72251628b18SChristian Borntraeger 
723216db403SChristian Borntraeger struct kvm_s390_mchk_info {
724216db403SChristian Borntraeger 	__u64 cr14;
725216db403SChristian Borntraeger 	__u64 mcic;
726216db403SChristian Borntraeger 	__u64 failing_storage_address;
727216db403SChristian Borntraeger 	__u32 ext_damage_code;
728216db403SChristian Borntraeger 	__u32 pad;
729216db403SChristian Borntraeger 	__u8 fixed_logout[16];
730216db403SChristian Borntraeger };
731216db403SChristian Borntraeger 
732216db403SChristian Borntraeger struct kvm_s390_irq {
733216db403SChristian Borntraeger 	__u64 type;
734216db403SChristian Borntraeger 	union {
735216db403SChristian Borntraeger 		struct kvm_s390_io_info io;
736216db403SChristian Borntraeger 		struct kvm_s390_ext_info ext;
737216db403SChristian Borntraeger 		struct kvm_s390_pgm_info pgm;
738216db403SChristian Borntraeger 		struct kvm_s390_emerg_info emerg;
739216db403SChristian Borntraeger 		struct kvm_s390_extcall_info extcall;
740216db403SChristian Borntraeger 		struct kvm_s390_prefix_info prefix;
74151628b18SChristian Borntraeger 		struct kvm_s390_stop_info stop;
742216db403SChristian Borntraeger 		struct kvm_s390_mchk_info mchk;
743216db403SChristian Borntraeger 		char reserved[64];
744216db403SChristian Borntraeger 	} u;
745216db403SChristian Borntraeger };
746216db403SChristian Borntraeger 
7477a52ce8aSCornelia Huck struct kvm_s390_irq_state {
7487a52ce8aSCornelia Huck 	__u64 buf;
7499cbb6362SCornelia Huck 	__u32 flags;        /* will stay unused for compatibility reasons */
7507a52ce8aSCornelia Huck 	__u32 len;
7519cbb6362SCornelia Huck 	__u32 reserved[4];  /* will stay unused for compatibility reasons */
7527a52ce8aSCornelia Huck };
7537a52ce8aSCornelia Huck 
75451b24e34SJan Kiszka /* for KVM_SET_GUEST_DEBUG */
75551b24e34SJan Kiszka 
75651b24e34SJan Kiszka #define KVM_GUESTDBG_ENABLE		0x00000001
75751b24e34SJan Kiszka #define KVM_GUESTDBG_SINGLESTEP		0x00000002
75851b24e34SJan Kiszka 
75951b24e34SJan Kiszka struct kvm_guest_debug {
76051b24e34SJan Kiszka 	__u32 control;
76151b24e34SJan Kiszka 	__u32 pad;
76251b24e34SJan Kiszka 	struct kvm_guest_debug_arch arch;
76351b24e34SJan Kiszka };
76451b24e34SJan Kiszka 
76551b24e34SJan Kiszka enum {
76651b24e34SJan Kiszka 	kvm_ioeventfd_flag_nr_datamatch,
76751b24e34SJan Kiszka 	kvm_ioeventfd_flag_nr_pio,
76851b24e34SJan Kiszka 	kvm_ioeventfd_flag_nr_deassign,
769cae7f586SAlexander Graf 	kvm_ioeventfd_flag_nr_virtio_ccw_notify,
77076eb98d5SJens Freimann 	kvm_ioeventfd_flag_nr_fast_mmio,
77151b24e34SJan Kiszka 	kvm_ioeventfd_flag_nr_max,
77251b24e34SJan Kiszka };
77351b24e34SJan Kiszka 
77451b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
77551b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_PIO       (1 << kvm_ioeventfd_flag_nr_pio)
77651b24e34SJan Kiszka #define KVM_IOEVENTFD_FLAG_DEASSIGN  (1 << kvm_ioeventfd_flag_nr_deassign)
777cae7f586SAlexander Graf #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \
778cae7f586SAlexander Graf 	(1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify)
77951b24e34SJan Kiszka 
78051b24e34SJan Kiszka #define KVM_IOEVENTFD_VALID_FLAG_MASK  ((1 << kvm_ioeventfd_flag_nr_max) - 1)
78151b24e34SJan Kiszka 
78251b24e34SJan Kiszka struct kvm_ioeventfd {
78351b24e34SJan Kiszka 	__u64 datamatch;
78451b24e34SJan Kiszka 	__u64 addr;        /* legal pio/mmio address */
78576eb98d5SJens Freimann 	__u32 len;         /* 1, 2, 4, or 8 bytes; or 0 to ignore length */
78651b24e34SJan Kiszka 	__s32 fd;
78751b24e34SJan Kiszka 	__u32 flags;
78851b24e34SJan Kiszka 	__u8  pad[36];
78951b24e34SJan Kiszka };
79051b24e34SJan Kiszka 
79165a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_MWAIT          (1 << 0)
79277d361b1SEric Auger #define KVM_X86_DISABLE_EXITS_HLT            (1 << 1)
79365a6d8ddSPeter Maydell #define KVM_X86_DISABLE_EXITS_PAUSE          (1 << 2)
794d38d201fSWanpeng Li #define KVM_X86_DISABLE_EXITS_CSTATE         (1 << 3)
79565a6d8ddSPeter Maydell #define KVM_X86_DISABLE_VALID_EXITS          (KVM_X86_DISABLE_EXITS_MWAIT | \
79677d361b1SEric Auger                                               KVM_X86_DISABLE_EXITS_HLT | \
797d38d201fSWanpeng Li                                               KVM_X86_DISABLE_EXITS_PAUSE | \
798d38d201fSWanpeng Li                                               KVM_X86_DISABLE_EXITS_CSTATE)
79965a6d8ddSPeter Maydell 
80051b24e34SJan Kiszka /* for KVM_ENABLE_CAP */
80151b24e34SJan Kiszka struct kvm_enable_cap {
80251b24e34SJan Kiszka 	/* in */
80351b24e34SJan Kiszka 	__u32 cap;
80451b24e34SJan Kiszka 	__u32 flags;
80551b24e34SJan Kiszka 	__u64 args[4];
80651b24e34SJan Kiszka 	__u8  pad[64];
80751b24e34SJan Kiszka };
80851b24e34SJan Kiszka 
80951b24e34SJan Kiszka /* for KVM_PPC_GET_PVINFO */
8103a5eb5b4SPaolo Bonzini 
8113a5eb5b4SPaolo Bonzini #define KVM_PPC_PVINFO_FLAGS_EV_IDLE   (1<<0)
8123a5eb5b4SPaolo Bonzini 
81351b24e34SJan Kiszka struct kvm_ppc_pvinfo {
81451b24e34SJan Kiszka 	/* out */
81551b24e34SJan Kiszka 	__u32 flags;
81651b24e34SJan Kiszka 	__u32 hcall[4];
81751b24e34SJan Kiszka 	__u8  pad[108];
81851b24e34SJan Kiszka };
81951b24e34SJan Kiszka 
82080a3eb10SJan Kiszka /* for KVM_PPC_GET_SMMU_INFO */
82180a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_MAX_SZ	8
82280a3eb10SJan Kiszka 
82380a3eb10SJan Kiszka struct kvm_ppc_one_page_size {
82480a3eb10SJan Kiszka 	__u32 page_shift;	/* Page shift (or 0) */
82580a3eb10SJan Kiszka 	__u32 pte_enc;		/* Encoding in the HPTE (>>12) */
82680a3eb10SJan Kiszka };
82780a3eb10SJan Kiszka 
82880a3eb10SJan Kiszka struct kvm_ppc_one_seg_page_size {
82980a3eb10SJan Kiszka 	__u32 page_shift;	/* Base page shift of segment (or 0) */
83080a3eb10SJan Kiszka 	__u32 slb_enc;		/* SLB encoding for BookS */
83180a3eb10SJan Kiszka 	struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ];
83280a3eb10SJan Kiszka };
83380a3eb10SJan Kiszka 
83480a3eb10SJan Kiszka #define KVM_PPC_PAGE_SIZES_REAL		0x00000001
83580a3eb10SJan Kiszka #define KVM_PPC_1T_SEGMENTS		0x00000002
836966f2ec3SPaolo Bonzini #define KVM_PPC_NO_HASH			0x00000004
83780a3eb10SJan Kiszka 
83880a3eb10SJan Kiszka struct kvm_ppc_smmu_info {
83980a3eb10SJan Kiszka 	__u64 flags;
84080a3eb10SJan Kiszka 	__u32 slb_size;
841d4083f50SAlexey Perevalov 	__u16 data_keys;	/* # storage keys supported for data */
842d4083f50SAlexey Perevalov 	__u16 instr_keys;	/* # storage keys supported for instructions */
84380a3eb10SJan Kiszka 	struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
84480a3eb10SJan Kiszka };
84580a3eb10SJan Kiszka 
8463a5eb5b4SPaolo Bonzini /* for KVM_PPC_RESIZE_HPT_{PREPARE,COMMIT} */
8473a5eb5b4SPaolo Bonzini struct kvm_ppc_resize_hpt {
8483a5eb5b4SPaolo Bonzini 	__u64 flags;
8493a5eb5b4SPaolo Bonzini 	__u32 shift;
8503a5eb5b4SPaolo Bonzini 	__u32 pad;
8513a5eb5b4SPaolo Bonzini };
852d4834ff9SAlexander Graf 
85351b24e34SJan Kiszka #define KVMIO 0xAE
85451b24e34SJan Kiszka 
8551529ae1bSAlexander Graf /* machine type bits, to be used as argument to KVM_CREATE_VM */
8561529ae1bSAlexander Graf #define KVM_VM_S390_UCONTROL	1
8571529ae1bSAlexander Graf 
858bf63839fSAlex Williamson /* on ppc, 0 indicate default, 1 should force HV and 2 PR */
859bf63839fSAlex Williamson #define KVM_VM_PPC_HV 1
860bf63839fSAlex Williamson #define KVM_VM_PPC_PR 2
861bf63839fSAlex Williamson 
86294c7fefcSAndrew Jones /* on MIPS, 0 indicates auto, 1 forces VZ ASE, 2 forces trap & emulate */
86394c7fefcSAndrew Jones #define KVM_VM_MIPS_AUTO	0
86474c98e20SCornelia Huck #define KVM_VM_MIPS_VZ		1
86594c7fefcSAndrew Jones #define KVM_VM_MIPS_TE		2
86674c98e20SCornelia Huck 
8671529ae1bSAlexander Graf #define KVM_S390_SIE_PAGE_OFFSET 1
8681529ae1bSAlexander Graf 
86951b24e34SJan Kiszka /*
870da054c64SPaolo Bonzini  * On arm64, machine type can be used to request the physical
871da054c64SPaolo Bonzini  * address size for the VM. Bits[7-0] are reserved for the guest
872da054c64SPaolo Bonzini  * PA size shift (i.e, log2(PA_Size)). For backward compatibility,
873da054c64SPaolo Bonzini  * value 0 implies the default IPA size, 40bits.
874da054c64SPaolo Bonzini  */
875da054c64SPaolo Bonzini #define KVM_VM_TYPE_ARM_IPA_SIZE_MASK	0xffULL
876da054c64SPaolo Bonzini #define KVM_VM_TYPE_ARM_IPA_SIZE(x)		\
877da054c64SPaolo Bonzini 	((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK)
878da054c64SPaolo Bonzini /*
87951b24e34SJan Kiszka  * ioctls for /dev/kvm fds:
88051b24e34SJan Kiszka  */
88151b24e34SJan Kiszka #define KVM_GET_API_VERSION       _IO(KVMIO,   0x00)
88251b24e34SJan Kiszka #define KVM_CREATE_VM             _IO(KVMIO,   0x01) /* returns a VM fd */
88351b24e34SJan Kiszka #define KVM_GET_MSR_INDEX_LIST    _IOWR(KVMIO, 0x02, struct kvm_msr_list)
88451b24e34SJan Kiszka 
88551b24e34SJan Kiszka #define KVM_S390_ENABLE_SIE       _IO(KVMIO,   0x06)
88651b24e34SJan Kiszka /*
88751b24e34SJan Kiszka  * Check if a kvm extension is available.  Argument is extension number,
88851b24e34SJan Kiszka  * return is 1 (yes) or 0 (no, sorry).
88951b24e34SJan Kiszka  */
89051b24e34SJan Kiszka #define KVM_CHECK_EXTENSION       _IO(KVMIO,   0x03)
89151b24e34SJan Kiszka /*
89251b24e34SJan Kiszka  * Get size for mmap(vcpu_fd)
89351b24e34SJan Kiszka  */
89451b24e34SJan Kiszka #define KVM_GET_VCPU_MMAP_SIZE    _IO(KVMIO,   0x04) /* in bytes */
89551b24e34SJan Kiszka #define KVM_GET_SUPPORTED_CPUID   _IOWR(KVMIO, 0x05, struct kvm_cpuid2)
896bf63839fSAlex Williamson #define KVM_GET_EMULATED_CPUID	  _IOWR(KVMIO, 0x09, struct kvm_cpuid2)
8979f2d175dSPaolo Bonzini #define KVM_GET_MSR_FEATURE_INDEX_LIST    _IOWR(KVMIO, 0x0a, struct kvm_msr_list)
89851b24e34SJan Kiszka 
89951b24e34SJan Kiszka /*
90051b24e34SJan Kiszka  * Extension capability list.
90151b24e34SJan Kiszka  */
90251b24e34SJan Kiszka #define KVM_CAP_IRQCHIP	  0
90351b24e34SJan Kiszka #define KVM_CAP_HLT	  1
90451b24e34SJan Kiszka #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2
90551b24e34SJan Kiszka #define KVM_CAP_USER_MEMORY 3
90651b24e34SJan Kiszka #define KVM_CAP_SET_TSS_ADDR 4
90751b24e34SJan Kiszka #define KVM_CAP_VAPIC 6
90851b24e34SJan Kiszka #define KVM_CAP_EXT_CPUID 7
90951b24e34SJan Kiszka #define KVM_CAP_CLOCKSOURCE 8
9107c6da3deSAlexander Graf #define KVM_CAP_NR_VCPUS 9       /* returns recommended max vcpus per vm */
91151b24e34SJan Kiszka #define KVM_CAP_NR_MEMSLOTS 10   /* returns max memory slots per vm */
91251b24e34SJan Kiszka #define KVM_CAP_PIT 11
91351b24e34SJan Kiszka #define KVM_CAP_NOP_IO_DELAY 12
91451b24e34SJan Kiszka #define KVM_CAP_PV_MMU 13
91551b24e34SJan Kiszka #define KVM_CAP_MP_STATE 14
91651b24e34SJan Kiszka #define KVM_CAP_COALESCED_MMIO 15
91751b24e34SJan Kiszka #define KVM_CAP_SYNC_MMU 16  /* Changes to host mmap are reflected in guest */
91851b24e34SJan Kiszka #define KVM_CAP_IOMMU 18
91951b24e34SJan Kiszka /* Bug in KVM_SET_USER_MEMORY_REGION fixed: */
92051b24e34SJan Kiszka #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21
92151b24e34SJan Kiszka #define KVM_CAP_USER_NMI 22
92251b24e34SJan Kiszka #ifdef __KVM_HAVE_GUEST_DEBUG
92351b24e34SJan Kiszka #define KVM_CAP_SET_GUEST_DEBUG 23
92451b24e34SJan Kiszka #endif
92551b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT
92651b24e34SJan Kiszka #define KVM_CAP_REINJECT_CONTROL 24
92751b24e34SJan Kiszka #endif
92851b24e34SJan Kiszka #define KVM_CAP_IRQ_ROUTING 25
92951b24e34SJan Kiszka #define KVM_CAP_IRQ_INJECT_STATUS 26
93051b24e34SJan Kiszka #define KVM_CAP_ASSIGN_DEV_IRQ 29
93151b24e34SJan Kiszka /* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */
93251b24e34SJan Kiszka #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30
93351b24e34SJan Kiszka #ifdef __KVM_HAVE_MCE
93451b24e34SJan Kiszka #define KVM_CAP_MCE 31
93551b24e34SJan Kiszka #endif
93651b24e34SJan Kiszka #define KVM_CAP_IRQFD 32
93751b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT
93851b24e34SJan Kiszka #define KVM_CAP_PIT2 33
93951b24e34SJan Kiszka #endif
94051b24e34SJan Kiszka #define KVM_CAP_SET_BOOT_CPU_ID 34
94151b24e34SJan Kiszka #ifdef __KVM_HAVE_PIT_STATE2
94251b24e34SJan Kiszka #define KVM_CAP_PIT_STATE2 35
94351b24e34SJan Kiszka #endif
94451b24e34SJan Kiszka #define KVM_CAP_IOEVENTFD 36
94551b24e34SJan Kiszka #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37
94651b24e34SJan Kiszka #ifdef __KVM_HAVE_XEN_HVM
94751b24e34SJan Kiszka #define KVM_CAP_XEN_HVM 38
94851b24e34SJan Kiszka #endif
94951b24e34SJan Kiszka #define KVM_CAP_ADJUST_CLOCK 39
95051b24e34SJan Kiszka #define KVM_CAP_INTERNAL_ERROR_DATA 40
95151b24e34SJan Kiszka #ifdef __KVM_HAVE_VCPU_EVENTS
95251b24e34SJan Kiszka #define KVM_CAP_VCPU_EVENTS 41
95351b24e34SJan Kiszka #endif
95451b24e34SJan Kiszka #define KVM_CAP_S390_PSW 42
95551b24e34SJan Kiszka #define KVM_CAP_PPC_SEGSTATE 43
95651b24e34SJan Kiszka #define KVM_CAP_HYPERV 44
95751b24e34SJan Kiszka #define KVM_CAP_HYPERV_VAPIC 45
95851b24e34SJan Kiszka #define KVM_CAP_HYPERV_SPIN 46
95951b24e34SJan Kiszka #define KVM_CAP_PCI_SEGMENT 47
96051b24e34SJan Kiszka #define KVM_CAP_PPC_PAIRED_SINGLES 48
96151b24e34SJan Kiszka #define KVM_CAP_INTR_SHADOW 49
96251b24e34SJan Kiszka #ifdef __KVM_HAVE_DEBUGREGS
96351b24e34SJan Kiszka #define KVM_CAP_DEBUGREGS 50
96451b24e34SJan Kiszka #endif
96551b24e34SJan Kiszka #define KVM_CAP_X86_ROBUST_SINGLESTEP 51
96651b24e34SJan Kiszka #define KVM_CAP_PPC_OSI 52
96751b24e34SJan Kiszka #define KVM_CAP_PPC_UNSET_IRQ 53
96851b24e34SJan Kiszka #define KVM_CAP_ENABLE_CAP 54
96951b24e34SJan Kiszka #ifdef __KVM_HAVE_XSAVE
97051b24e34SJan Kiszka #define KVM_CAP_XSAVE 55
97151b24e34SJan Kiszka #endif
97251b24e34SJan Kiszka #ifdef __KVM_HAVE_XCRS
97351b24e34SJan Kiszka #define KVM_CAP_XCRS 56
97451b24e34SJan Kiszka #endif
97551b24e34SJan Kiszka #define KVM_CAP_PPC_GET_PVINFO 57
97651b24e34SJan Kiszka #define KVM_CAP_PPC_IRQ_LEVEL 58
97751b24e34SJan Kiszka #define KVM_CAP_ASYNC_PF 59
97851b24e34SJan Kiszka #define KVM_CAP_TSC_CONTROL 60
97951b24e34SJan Kiszka #define KVM_CAP_GET_TSC_KHZ 61
98051b24e34SJan Kiszka #define KVM_CAP_PPC_BOOKE_SREGS 62
9817c6da3deSAlexander Graf #define KVM_CAP_SPAPR_TCE 63
9827c6da3deSAlexander Graf #define KVM_CAP_PPC_SMT 64
9837c6da3deSAlexander Graf #define KVM_CAP_PPC_RMA	65
9847c6da3deSAlexander Graf #define KVM_CAP_MAX_VCPUS 66       /* returns max vcpus per vm */
9859d4e4f8cSAlexander Graf #define KVM_CAP_PPC_HIOR 67
9867c6da3deSAlexander Graf #define KVM_CAP_PPC_PAPR 68
987a54fc080SAlexander Graf #define KVM_CAP_SW_TLB 69
9889d4e4f8cSAlexander Graf #define KVM_CAP_ONE_REG 70
9891529ae1bSAlexander Graf #define KVM_CAP_S390_GMAP 71
9901529ae1bSAlexander Graf #define KVM_CAP_TSC_DEADLINE_TIMER 72
9911529ae1bSAlexander Graf #define KVM_CAP_S390_UCONTROL 73
9921529ae1bSAlexander Graf #define KVM_CAP_SYNC_REGS 74
9939ab2195dSMarcelo Tosatti #define KVM_CAP_PCI_2_3 75
9949ab2195dSMarcelo Tosatti #define KVM_CAP_KVMCLOCK_CTRL 76
99580a3eb10SJan Kiszka #define KVM_CAP_SIGNAL_MSI 77
99680a3eb10SJan Kiszka #define KVM_CAP_PPC_GET_SMMU_INFO 78
9972a60dba4SAlexander Graf #define KVM_CAP_S390_COW 79
998651682dcSMichael S. Tsirkin #define KVM_CAP_PPC_ALLOC_HTAB 80
999716b8e4dSAlex Williamson #define KVM_CAP_READONLY_MEM 81
1000716b8e4dSAlex Williamson #define KVM_CAP_IRQFD_RESAMPLE 82
1001d4834ff9SAlexander Graf #define KVM_CAP_PPC_BOOKE_WATCHDOG 83
1002d4834ff9SAlexander Graf #define KVM_CAP_PPC_HTAB_FD 84
1003d3dccee1SAlexander Graf #define KVM_CAP_S390_CSS_SUPPORT 85
1004d3dccee1SAlexander Graf #define KVM_CAP_PPC_EPR 86
1005eadd0e44SPeter Maydell #define KVM_CAP_ARM_PSCI 87
1006eadd0e44SPeter Maydell #define KVM_CAP_ARM_SET_DEVICE_ADDR 88
1007e098b453SAlexey Kardashevskiy #define KVM_CAP_DEVICE_CTRL 89
1008e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_MPIC 90
1009e098b453SAlexey Kardashevskiy #define KVM_CAP_PPC_RTAS 91
1010e098b453SAlexey Kardashevskiy #define KVM_CAP_IRQ_XICS 92
1011c5daeae1SAlexey Kardashevskiy #define KVM_CAP_ARM_EL1_32BIT 93
10124f265607SAndrew Jones #define KVM_CAP_SPAPR_MULTITCE 94
1013bf63839fSAlex Williamson #define KVM_CAP_EXT_EMUL_CPUID 95
101448a5f3bcSVadim Rozenfeld #define KVM_CAP_HYPERV_TIME 96
10159ffd2685SCornelia Huck #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97
10169ffd2685SCornelia Huck #define KVM_CAP_ENABLE_CAP_VM 98
10179ffd2685SCornelia Huck #define KVM_CAP_S390_IRQCHIP 99
101876eb98d5SJens Freimann #define KVM_CAP_IOEVENTFD_NO_LENGTH 100
101976eb98d5SJens Freimann #define KVM_CAP_VM_ATTRIBUTES 101
1020b061808dSAlexander Graf #define KVM_CAP_ARM_PSCI_0_2 102
1021b061808dSAlexander Graf #define KVM_CAP_PPC_FIXUP_HCALL 103
1022a9fd1654SJens Freimann #define KVM_CAP_PPC_ENABLE_HCALL 104
1023a9fd1654SJens Freimann #define KVM_CAP_CHECK_EXTENSION_VM 105
102451628b18SChristian Borntraeger #define KVM_CAP_S390_USER_SIGP 106
10257a52ce8aSCornelia Huck #define KVM_CAP_S390_VECTOR_REGISTERS 107
10267a52ce8aSCornelia Huck #define KVM_CAP_S390_MEM_OP 108
10277a52ce8aSCornelia Huck #define KVM_CAP_S390_USER_STSI 109
10287a52ce8aSCornelia Huck #define KVM_CAP_S390_SKEYS 110
10297a52ce8aSCornelia Huck #define KVM_CAP_MIPS_FPU 111
10307a52ce8aSCornelia Huck #define KVM_CAP_MIPS_MSA 112
10317a52ce8aSCornelia Huck #define KVM_CAP_S390_INJECT_IRQ 113
10327a52ce8aSCornelia Huck #define KVM_CAP_S390_IRQ_STATE 114
10337a52ce8aSCornelia Huck #define KVM_CAP_PPC_HWRNG 115
103424a31426SPaolo Bonzini #define KVM_CAP_DISABLE_QUIRKS 116
103524a31426SPaolo Bonzini #define KVM_CAP_X86_SMM 117
103624a31426SPaolo Bonzini #define KVM_CAP_MULTI_ADDRESS_SPACE 118
10373a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_BPS 119
10383a824b15SPaolo Bonzini #define KVM_CAP_GUEST_DEBUG_HW_WPS 120
10393a824b15SPaolo Bonzini #define KVM_CAP_SPLIT_IRQCHIP 121
10403a824b15SPaolo Bonzini #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122
1041fff02bc0SPaolo Bonzini #define KVM_CAP_HYPERV_SYNIC 123
104266fb2d54SCornelia Huck #define KVM_CAP_S390_RI 124
1043b89485a5SPaolo Bonzini #define KVM_CAP_SPAPR_TCE_64 125
1044b89485a5SPaolo Bonzini #define KVM_CAP_ARM_PMU_V3 126
1045b89485a5SPaolo Bonzini #define KVM_CAP_VCPU_ATTRIBUTES 127
1046ff804f15SCornelia Huck #define KVM_CAP_MAX_VCPU_ID 128
1047dbdfea92SCornelia Huck #define KVM_CAP_X2APIC_API 129
1048dbdfea92SCornelia Huck #define KVM_CAP_S390_USER_INSTR0 130
1049dbdfea92SCornelia Huck #define KVM_CAP_MSI_DEVID 131
1050dbdfea92SCornelia Huck #define KVM_CAP_PPC_HTM 132
10513a5eb5b4SPaolo Bonzini #define KVM_CAP_SPAPR_RESIZE_HPT 133
10523a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_RADIX 134
10533a5eb5b4SPaolo Bonzini #define KVM_CAP_PPC_MMU_HASH_V3 135
10543a5eb5b4SPaolo Bonzini #define KVM_CAP_IMMEDIATE_EXIT 136
105574c98e20SCornelia Huck #define KVM_CAP_MIPS_VZ 137
105674c98e20SCornelia Huck #define KVM_CAP_MIPS_TE 138
105774c98e20SCornelia Huck #define KVM_CAP_MIPS_64BIT 139
105874c98e20SCornelia Huck #define KVM_CAP_S390_GS 140
105974c98e20SCornelia Huck #define KVM_CAP_S390_AIS 141
106074c98e20SCornelia Huck #define KVM_CAP_SPAPR_TCE_VFIO 142
106165a6d8ddSPeter Maydell #define KVM_CAP_X86_DISABLE_EXITS 143
106274c98e20SCornelia Huck #define KVM_CAP_ARM_USER_IRQ 144
10633272f0e2SChristian Borntraeger #define KVM_CAP_S390_CMMA_MIGRATION 145
10643272f0e2SChristian Borntraeger #define KVM_CAP_PPC_FWNMI 146
10653272f0e2SChristian Borntraeger #define KVM_CAP_PPC_SMT_POSSIBLE 147
1066ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_SYNIC2 148
1067ab6e1550SChristian Borntraeger #define KVM_CAP_HYPERV_VP_INDEX 149
1068dd873966SEric Auger #define KVM_CAP_S390_AIS_MIGRATION 150
10699cbb6362SCornelia Huck #define KVM_CAP_PPC_GET_CPU_CHAR 151
10709cbb6362SCornelia Huck #define KVM_CAP_S390_BPB 152
10719f2d175dSPaolo Bonzini #define KVM_CAP_GET_MSR_FEATURES 153
107265a6d8ddSPeter Maydell #define KVM_CAP_HYPERV_EVENTFD 154
107377d361b1SEric Auger #define KVM_CAP_HYPERV_TLBFLUSH 155
1074d36f7de8SCornelia Huck #define KVM_CAP_S390_HPAGE_1M 156
1075d36f7de8SCornelia Huck #define KVM_CAP_NESTED_STATE 157
10768f3cd250SCornelia Huck #define KVM_CAP_ARM_INJECT_SERROR_ESR 158
10778f3cd250SCornelia Huck #define KVM_CAP_MSR_PLATFORM_INFO 159
1078966f2ec3SPaolo Bonzini #define KVM_CAP_PPC_NESTED_HV 160
1079966f2ec3SPaolo Bonzini #define KVM_CAP_HYPERV_SEND_IPI 161
1080966f2ec3SPaolo Bonzini #define KVM_CAP_COALESCED_PIO 162
1081966f2ec3SPaolo Bonzini #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163
1082966f2ec3SPaolo Bonzini #define KVM_CAP_EXCEPTION_PAYLOAD 164
1083da054c64SPaolo Bonzini #define KVM_CAP_ARM_VM_IPA_SIZE 165
1084d9cb4336SCornelia Huck #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166 /* Obsolete */
1085da054c64SPaolo Bonzini #define KVM_CAP_HYPERV_CPUID 167
1086d9cb4336SCornelia Huck #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 168
1087d9cb4336SCornelia Huck #define KVM_CAP_PPC_IRQ_XIVE 169
1088d9cb4336SCornelia Huck #define KVM_CAP_ARM_SVE 170
1089d9cb4336SCornelia Huck #define KVM_CAP_ARM_PTRAUTH_ADDRESS 171
1090d9cb4336SCornelia Huck #define KVM_CAP_ARM_PTRAUTH_GENERIC 172
1091f363d039SEric Auger #define KVM_CAP_PMU_EVENT_FILTER 173
1092f363d039SEric Auger #define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174
1093f363d039SEric Auger #define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175
10942a886794SGreg Kurz #define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 176
10952a886794SGreg Kurz #define KVM_CAP_ARM_NISV_TO_USER 177
10962a886794SGreg Kurz #define KVM_CAP_ARM_INJECT_EXT_DABT 178
1097ddda3748SCornelia Huck #define KVM_CAP_S390_VCPU_RESETS 179
1098dc6f8d45SCornelia Huck #define KVM_CAP_S390_PROTECTED 180
1099dc6f8d45SCornelia Huck #define KVM_CAP_PPC_SECURE_GUEST 181
1100f76b348eSCornelia Huck #define KVM_CAP_HALT_POLL 182
1101f76b348eSCornelia Huck #define KVM_CAP_ASYNC_PF_INT 183
1102e6546342SJason Wang #define KVM_CAP_LAST_CPU 184
1103e6546342SJason Wang #define KVM_CAP_SMALLER_MAXPHYADDR 185
1104e6546342SJason Wang #define KVM_CAP_S390_DIAG318 186
110594c7fefcSAndrew Jones #define KVM_CAP_STEAL_TIME 187
110653ba2eeeSMatthew Rosato #define KVM_CAP_X86_USER_SPACE_MSR 188
110753ba2eeeSMatthew Rosato #define KVM_CAP_X86_MSR_FILTER 189
110853ba2eeeSMatthew Rosato #define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190
1109b3c818a4SEric Farman #define KVM_CAP_SYS_HYPERV_CPUID 191
1110b3c818a4SEric Farman #define KVM_CAP_DIRTY_LOG_RING 192
1111278f064eSEduardo Habkost #define KVM_CAP_X86_BUS_LOCK_EXIT 193
1112278f064eSEduardo Habkost #define KVM_CAP_PPC_DAWR1 194
1113278f064eSEduardo Habkost #define KVM_CAP_SET_GUEST_DEBUG2 195
1114278f064eSEduardo Habkost #define KVM_CAP_SGX_ATTRIBUTE 196
1115278f064eSEduardo Habkost #define KVM_CAP_VM_COPY_ENC_CONTEXT_FROM 197
1116278f064eSEduardo Habkost #define KVM_CAP_PTP_KVM 198
1117327d4b7fSBharata B Rao #define KVM_CAP_HYPERV_ENFORCE_CPUID 199
1118327d4b7fSBharata B Rao #define KVM_CAP_SREGS2 200
1119327d4b7fSBharata B Rao #define KVM_CAP_EXIT_HYPERCALL 201
1120327d4b7fSBharata B Rao #define KVM_CAP_PPC_RPT_INVALIDATE 202
1121327d4b7fSBharata B Rao #define KVM_CAP_BINARY_STATS_FD 203
1122327d4b7fSBharata B Rao #define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204
1123327d4b7fSBharata B Rao #define KVM_CAP_ARM_MTE 205
1124ef17dd6aSVivek Goyal #define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206
1125ef17dd6aSVivek Goyal #define KVM_CAP_VM_GPA_BITS 207
1126ef17dd6aSVivek Goyal #define KVM_CAP_XSAVE2 208
11271ea5208fSPaolo Bonzini #define KVM_CAP_SYS_ATTRIBUTES 209
1128e4082063SAlex Williamson #define KVM_CAP_PPC_AIL_MODE_3 210
1129e4082063SAlex Williamson #define KVM_CAP_S390_MEM_OP_EXTENSION 211
1130e4082063SAlex Williamson #define KVM_CAP_PMU_CAPABILITY 212
1131e4082063SAlex Williamson #define KVM_CAP_DISABLE_QUIRKS2 213
1132d525f73fSChenyi Qiang #define KVM_CAP_VM_TSC_CONTROL 214
1133e4082063SAlex Williamson #define KVM_CAP_SYSTEM_EVENT_DATA 215
1134d525f73fSChenyi Qiang #define KVM_CAP_ARM_SYSTEM_SUSPEND 216
1135d525f73fSChenyi Qiang #define KVM_CAP_S390_PROTECTED_DUMP 217
1136d525f73fSChenyi Qiang #define KVM_CAP_X86_TRIPLE_FAULT_EVENT 218
1137d525f73fSChenyi Qiang #define KVM_CAP_X86_NOTIFY_VMEXIT 219
1138d525f73fSChenyi Qiang #define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220
1139d525f73fSChenyi Qiang #define KVM_CAP_S390_ZPCI_OP 221
1140d525f73fSChenyi Qiang #define KVM_CAP_S390_CPU_TOPOLOGY 222
114193e0932bSPeter Xu #define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223
114293d7620cSAvihai Horon #define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224
114393d7620cSAvihai Horon #define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225
1144c5c0fdbeSDavid 'Digit' Turner #define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226
1145d0bf492fSCédric Le Goater #define KVM_CAP_COUNTER_OFFSET 227
1146d0bf492fSCédric Le Goater #define KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 228
1147d0bf492fSCédric Le Goater #define KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES 229
1148efb91426SDaniel Henrique Barboza #define KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES 230
1149*6a02465fSDaniel Henrique Barboza #define KVM_CAP_USER_MEMORY2 231
1150*6a02465fSDaniel Henrique Barboza #define KVM_CAP_MEMORY_FAULT_INFO 232
1151*6a02465fSDaniel Henrique Barboza #define KVM_CAP_MEMORY_ATTRIBUTES 233
1152*6a02465fSDaniel Henrique Barboza #define KVM_CAP_GUEST_MEMFD 234
1153*6a02465fSDaniel Henrique Barboza #define KVM_CAP_VM_TYPES 235
115451b24e34SJan Kiszka 
115551b24e34SJan Kiszka #ifdef KVM_CAP_IRQ_ROUTING
115651b24e34SJan Kiszka 
115751b24e34SJan Kiszka struct kvm_irq_routing_irqchip {
115851b24e34SJan Kiszka 	__u32 irqchip;
115951b24e34SJan Kiszka 	__u32 pin;
116051b24e34SJan Kiszka };
116151b24e34SJan Kiszka 
116251b24e34SJan Kiszka struct kvm_irq_routing_msi {
116351b24e34SJan Kiszka 	__u32 address_lo;
116451b24e34SJan Kiszka 	__u32 address_hi;
116551b24e34SJan Kiszka 	__u32 data;
1166dbdfea92SCornelia Huck 	union {
116751b24e34SJan Kiszka 		__u32 pad;
1168dbdfea92SCornelia Huck 		__u32 devid;
1169dbdfea92SCornelia Huck 	};
117051b24e34SJan Kiszka };
117151b24e34SJan Kiszka 
11729ffd2685SCornelia Huck struct kvm_irq_routing_s390_adapter {
11739ffd2685SCornelia Huck 	__u64 ind_addr;
11749ffd2685SCornelia Huck 	__u64 summary_addr;
11759ffd2685SCornelia Huck 	__u64 ind_offset;
11769ffd2685SCornelia Huck 	__u32 summary_offset;
11779ffd2685SCornelia Huck 	__u32 adapter_id;
11789ffd2685SCornelia Huck };
11799ffd2685SCornelia Huck 
1180fff02bc0SPaolo Bonzini struct kvm_irq_routing_hv_sint {
1181fff02bc0SPaolo Bonzini 	__u32 vcpu;
1182fff02bc0SPaolo Bonzini 	__u32 sint;
1183fff02bc0SPaolo Bonzini };
1184fff02bc0SPaolo Bonzini 
1185ef17dd6aSVivek Goyal struct kvm_irq_routing_xen_evtchn {
1186ef17dd6aSVivek Goyal 	__u32 port;
1187ef17dd6aSVivek Goyal 	__u32 vcpu;
1188ef17dd6aSVivek Goyal 	__u32 priority;
1189ef17dd6aSVivek Goyal };
1190ef17dd6aSVivek Goyal 
1191ef17dd6aSVivek Goyal #define KVM_IRQ_ROUTING_XEN_EVTCHN_PRIO_2LEVEL ((__u32)(-1))
1192ef17dd6aSVivek Goyal 
119351b24e34SJan Kiszka /* gsi routing entry types */
119451b24e34SJan Kiszka #define KVM_IRQ_ROUTING_IRQCHIP 1
119551b24e34SJan Kiszka #define KVM_IRQ_ROUTING_MSI 2
11969ffd2685SCornelia Huck #define KVM_IRQ_ROUTING_S390_ADAPTER 3
1197fff02bc0SPaolo Bonzini #define KVM_IRQ_ROUTING_HV_SINT 4
1198ef17dd6aSVivek Goyal #define KVM_IRQ_ROUTING_XEN_EVTCHN 5
119951b24e34SJan Kiszka 
120051b24e34SJan Kiszka struct kvm_irq_routing_entry {
120151b24e34SJan Kiszka 	__u32 gsi;
120251b24e34SJan Kiszka 	__u32 type;
120351b24e34SJan Kiszka 	__u32 flags;
120451b24e34SJan Kiszka 	__u32 pad;
120551b24e34SJan Kiszka 	union {
120651b24e34SJan Kiszka 		struct kvm_irq_routing_irqchip irqchip;
120751b24e34SJan Kiszka 		struct kvm_irq_routing_msi msi;
12089ffd2685SCornelia Huck 		struct kvm_irq_routing_s390_adapter adapter;
1209fff02bc0SPaolo Bonzini 		struct kvm_irq_routing_hv_sint hv_sint;
1210ef17dd6aSVivek Goyal 		struct kvm_irq_routing_xen_evtchn xen_evtchn;
121151b24e34SJan Kiszka 		__u32 pad[8];
121251b24e34SJan Kiszka 	} u;
121351b24e34SJan Kiszka };
121451b24e34SJan Kiszka 
121551b24e34SJan Kiszka struct kvm_irq_routing {
121651b24e34SJan Kiszka 	__u32 nr;
121751b24e34SJan Kiszka 	__u32 flags;
1218d525f73fSChenyi Qiang 	struct kvm_irq_routing_entry entries[];
121951b24e34SJan Kiszka };
122051b24e34SJan Kiszka 
122151b24e34SJan Kiszka #endif
122251b24e34SJan Kiszka 
122351b24e34SJan Kiszka #ifdef KVM_CAP_MCE
122451b24e34SJan Kiszka /* x86 MCE */
122551b24e34SJan Kiszka struct kvm_x86_mce {
122651b24e34SJan Kiszka 	__u64 status;
122751b24e34SJan Kiszka 	__u64 addr;
122851b24e34SJan Kiszka 	__u64 misc;
122951b24e34SJan Kiszka 	__u64 mcg_status;
123051b24e34SJan Kiszka 	__u8 bank;
123151b24e34SJan Kiszka 	__u8 pad1[7];
123251b24e34SJan Kiszka 	__u64 pad2[3];
123351b24e34SJan Kiszka };
123451b24e34SJan Kiszka #endif
123551b24e34SJan Kiszka 
123651b24e34SJan Kiszka #ifdef KVM_CAP_XEN_HVM
1237278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR	(1 << 0)
1238278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL	(1 << 1)
1239278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_SHARED_INFO		(1 << 2)
1240278f064eSEduardo Habkost #define KVM_XEN_HVM_CONFIG_RUNSTATE		(1 << 3)
1241ef17dd6aSVivek Goyal #define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL	(1 << 4)
1242d525f73fSChenyi Qiang #define KVM_XEN_HVM_CONFIG_EVTCHN_SEND		(1 << 5)
124393d7620cSAvihai Horon #define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG	(1 << 6)
1244*6a02465fSDaniel Henrique Barboza #define KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE	(1 << 7)
1245278f064eSEduardo Habkost 
124651b24e34SJan Kiszka struct kvm_xen_hvm_config {
124751b24e34SJan Kiszka 	__u32 flags;
124851b24e34SJan Kiszka 	__u32 msr;
124951b24e34SJan Kiszka 	__u64 blob_addr_32;
125051b24e34SJan Kiszka 	__u64 blob_addr_64;
125151b24e34SJan Kiszka 	__u8 blob_size_32;
125251b24e34SJan Kiszka 	__u8 blob_size_64;
125351b24e34SJan Kiszka 	__u8 pad2[30];
125451b24e34SJan Kiszka };
125551b24e34SJan Kiszka #endif
125651b24e34SJan Kiszka 
125751b24e34SJan Kiszka #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)
1258716b8e4dSAlex Williamson /*
1259716b8e4dSAlex Williamson  * Available with KVM_CAP_IRQFD_RESAMPLE
1260716b8e4dSAlex Williamson  *
1261716b8e4dSAlex Williamson  * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies
1262716b8e4dSAlex Williamson  * the irqfd to operate in resampling mode for level triggered interrupt
1263f76b348eSCornelia Huck  * emulation.  See Documentation/virt/kvm/api.rst.
1264716b8e4dSAlex Williamson  */
1265716b8e4dSAlex Williamson #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
126651b24e34SJan Kiszka 
126751b24e34SJan Kiszka struct kvm_irqfd {
126851b24e34SJan Kiszka 	__u32 fd;
126951b24e34SJan Kiszka 	__u32 gsi;
127051b24e34SJan Kiszka 	__u32 flags;
1271716b8e4dSAlex Williamson 	__u32 resamplefd;
1272716b8e4dSAlex Williamson 	__u8  pad[16];
127351b24e34SJan Kiszka };
127451b24e34SJan Kiszka 
1275bc204035SMarcelo Tosatti /* For KVM_CAP_ADJUST_CLOCK */
1276bc204035SMarcelo Tosatti 
1277bc204035SMarcelo Tosatti /* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags.  */
1278bc204035SMarcelo Tosatti #define KVM_CLOCK_TSC_STABLE		2
127943709a0cSPaolo Bonzini #define KVM_CLOCK_REALTIME		(1 << 2)
128043709a0cSPaolo Bonzini #define KVM_CLOCK_HOST_TSC		(1 << 3)
1281bc204035SMarcelo Tosatti 
128251b24e34SJan Kiszka struct kvm_clock_data {
128351b24e34SJan Kiszka 	__u64 clock;
128451b24e34SJan Kiszka 	__u32 flags;
128543709a0cSPaolo Bonzini 	__u32 pad0;
128643709a0cSPaolo Bonzini 	__u64 realtime;
128743709a0cSPaolo Bonzini 	__u64 host_tsc;
128843709a0cSPaolo Bonzini 	__u32 pad[4];
128951b24e34SJan Kiszka };
129051b24e34SJan Kiszka 
1291bc204035SMarcelo Tosatti /* For KVM_CAP_SW_TLB */
1292bc204035SMarcelo Tosatti 
1293a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_NOHV		0
1294a54fc080SAlexander Graf #define KVM_MMU_FSL_BOOKE_HV		1
1295a54fc080SAlexander Graf 
1296a54fc080SAlexander Graf struct kvm_config_tlb {
1297a54fc080SAlexander Graf 	__u64 params;
1298a54fc080SAlexander Graf 	__u64 array;
1299a54fc080SAlexander Graf 	__u32 mmu_type;
1300a54fc080SAlexander Graf 	__u32 array_len;
1301a54fc080SAlexander Graf };
1302a54fc080SAlexander Graf 
1303a54fc080SAlexander Graf struct kvm_dirty_tlb {
1304a54fc080SAlexander Graf 	__u64 bitmap;
1305a54fc080SAlexander Graf 	__u32 num_dirty;
1306a54fc080SAlexander Graf };
1307a54fc080SAlexander Graf 
13089d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */
13099d4e4f8cSAlexander Graf 
1310a31be480SAlexander Graf #define KVM_REG_ARCH_MASK	0xff00000000000000ULL
1311a31be480SAlexander Graf #define KVM_REG_GENERIC		0x0000000000000000ULL
13129d4e4f8cSAlexander Graf 
13139d4e4f8cSAlexander Graf /*
13149d4e4f8cSAlexander Graf  * Architecture specific registers are to be defined in arch headers and
13159d4e4f8cSAlexander Graf  * ORed with the arch identifier.
13169d4e4f8cSAlexander Graf  */
1317a31be480SAlexander Graf #define KVM_REG_PPC		0x1000000000000000ULL
1318a31be480SAlexander Graf #define KVM_REG_X86		0x2000000000000000ULL
1319a31be480SAlexander Graf #define KVM_REG_IA64		0x3000000000000000ULL
1320a31be480SAlexander Graf #define KVM_REG_ARM		0x4000000000000000ULL
1321a31be480SAlexander Graf #define KVM_REG_S390		0x5000000000000000ULL
1322c5daeae1SAlexey Kardashevskiy #define KVM_REG_ARM64		0x6000000000000000ULL
1323c5daeae1SAlexey Kardashevskiy #define KVM_REG_MIPS		0x7000000000000000ULL
1324f363d039SEric Auger #define KVM_REG_RISCV		0x8000000000000000ULL
1325efb91426SDaniel Henrique Barboza #define KVM_REG_LOONGARCH	0x9000000000000000ULL
1326a31be480SAlexander Graf 
1327a31be480SAlexander Graf #define KVM_REG_SIZE_SHIFT	52
1328a31be480SAlexander Graf #define KVM_REG_SIZE_MASK	0x00f0000000000000ULL
1329a31be480SAlexander Graf #define KVM_REG_SIZE_U8		0x0000000000000000ULL
1330a31be480SAlexander Graf #define KVM_REG_SIZE_U16	0x0010000000000000ULL
1331a31be480SAlexander Graf #define KVM_REG_SIZE_U32	0x0020000000000000ULL
1332a31be480SAlexander Graf #define KVM_REG_SIZE_U64	0x0030000000000000ULL
1333a31be480SAlexander Graf #define KVM_REG_SIZE_U128	0x0040000000000000ULL
1334a31be480SAlexander Graf #define KVM_REG_SIZE_U256	0x0050000000000000ULL
1335a31be480SAlexander Graf #define KVM_REG_SIZE_U512	0x0060000000000000ULL
1336a31be480SAlexander Graf #define KVM_REG_SIZE_U1024	0x0070000000000000ULL
1337d9cb4336SCornelia Huck #define KVM_REG_SIZE_U2048	0x0080000000000000ULL
13389d4e4f8cSAlexander Graf 
1339eadd0e44SPeter Maydell struct kvm_reg_list {
1340eadd0e44SPeter Maydell 	__u64 n; /* number of regs */
1341d525f73fSChenyi Qiang 	__u64 reg[];
1342eadd0e44SPeter Maydell };
1343eadd0e44SPeter Maydell 
13449d4e4f8cSAlexander Graf struct kvm_one_reg {
13459d4e4f8cSAlexander Graf 	__u64 id;
1346a31be480SAlexander Graf 	__u64 addr;
13479d4e4f8cSAlexander Graf };
13489d4e4f8cSAlexander Graf 
1349dbdfea92SCornelia Huck #define KVM_MSI_VALID_DEVID	(1U << 0)
135080a3eb10SJan Kiszka struct kvm_msi {
135180a3eb10SJan Kiszka 	__u32 address_lo;
135280a3eb10SJan Kiszka 	__u32 address_hi;
135380a3eb10SJan Kiszka 	__u32 data;
135480a3eb10SJan Kiszka 	__u32 flags;
1355dbdfea92SCornelia Huck 	__u32 devid;
1356dbdfea92SCornelia Huck 	__u8  pad[12];
135780a3eb10SJan Kiszka };
135880a3eb10SJan Kiszka 
1359eadd0e44SPeter Maydell struct kvm_arm_device_addr {
1360eadd0e44SPeter Maydell 	__u64 id;
1361eadd0e44SPeter Maydell 	__u64 addr;
1362eadd0e44SPeter Maydell };
1363eadd0e44SPeter Maydell 
136451b24e34SJan Kiszka /*
1365e098b453SAlexey Kardashevskiy  * Device control API, available with KVM_CAP_DEVICE_CTRL
1366e098b453SAlexey Kardashevskiy  */
1367e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE_TEST		1
1368e098b453SAlexey Kardashevskiy 
1369e098b453SAlexey Kardashevskiy struct kvm_create_device {
1370e098b453SAlexey Kardashevskiy 	__u32	type;	/* in: KVM_DEV_TYPE_xxx */
1371e098b453SAlexey Kardashevskiy 	__u32	fd;	/* out: device handle */
1372e098b453SAlexey Kardashevskiy 	__u32	flags;	/* in: KVM_CREATE_DEVICE_xxx */
1373e098b453SAlexey Kardashevskiy };
1374e098b453SAlexey Kardashevskiy 
1375e098b453SAlexey Kardashevskiy struct kvm_device_attr {
1376e098b453SAlexey Kardashevskiy 	__u32	flags;		/* no flags currently defined */
1377e098b453SAlexey Kardashevskiy 	__u32	group;		/* device-defined */
1378e098b453SAlexey Kardashevskiy 	__u64	attr;		/* group-defined */
1379e098b453SAlexey Kardashevskiy 	__u64	addr;		/* userspace address of attr data */
1380e098b453SAlexey Kardashevskiy };
1381e098b453SAlexey Kardashevskiy 
1382da3c22c7SThomas Huth #define  KVM_DEV_VFIO_FILE			1
1383da3c22c7SThomas Huth 
1384da3c22c7SThomas Huth #define   KVM_DEV_VFIO_FILE_ADD			1
1385da3c22c7SThomas Huth #define   KVM_DEV_VFIO_FILE_DEL			2
1386da3c22c7SThomas Huth 
1387da3c22c7SThomas Huth /* KVM_DEV_VFIO_GROUP aliases are for compile time uapi compatibility */
1388da3c22c7SThomas Huth #define  KVM_DEV_VFIO_GROUP	KVM_DEV_VFIO_FILE
1389da3c22c7SThomas Huth 
1390da3c22c7SThomas Huth #define   KVM_DEV_VFIO_GROUP_ADD	KVM_DEV_VFIO_FILE_ADD
1391da3c22c7SThomas Huth #define   KVM_DEV_VFIO_GROUP_DEL	KVM_DEV_VFIO_FILE_DEL
139274c98e20SCornelia Huck #define   KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE		3
1393444b1996SArd Biesheuvel 
1394444b1996SArd Biesheuvel enum kvm_device_type {
1395444b1996SArd Biesheuvel 	KVM_DEV_TYPE_FSL_MPIC_20	= 1,
1396444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_20	KVM_DEV_TYPE_FSL_MPIC_20
1397444b1996SArd Biesheuvel 	KVM_DEV_TYPE_FSL_MPIC_42,
1398444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FSL_MPIC_42	KVM_DEV_TYPE_FSL_MPIC_42
1399444b1996SArd Biesheuvel 	KVM_DEV_TYPE_XICS,
1400444b1996SArd Biesheuvel #define KVM_DEV_TYPE_XICS		KVM_DEV_TYPE_XICS
1401444b1996SArd Biesheuvel 	KVM_DEV_TYPE_VFIO,
1402444b1996SArd Biesheuvel #define KVM_DEV_TYPE_VFIO		KVM_DEV_TYPE_VFIO
1403444b1996SArd Biesheuvel 	KVM_DEV_TYPE_ARM_VGIC_V2,
1404444b1996SArd Biesheuvel #define KVM_DEV_TYPE_ARM_VGIC_V2	KVM_DEV_TYPE_ARM_VGIC_V2
1405444b1996SArd Biesheuvel 	KVM_DEV_TYPE_FLIC,
1406444b1996SArd Biesheuvel #define KVM_DEV_TYPE_FLIC		KVM_DEV_TYPE_FLIC
140751628b18SChristian Borntraeger 	KVM_DEV_TYPE_ARM_VGIC_V3,
140851628b18SChristian Borntraeger #define KVM_DEV_TYPE_ARM_VGIC_V3	KVM_DEV_TYPE_ARM_VGIC_V3
1409dbdfea92SCornelia Huck 	KVM_DEV_TYPE_ARM_VGIC_ITS,
1410dbdfea92SCornelia Huck #define KVM_DEV_TYPE_ARM_VGIC_ITS	KVM_DEV_TYPE_ARM_VGIC_ITS
1411d9cb4336SCornelia Huck 	KVM_DEV_TYPE_XIVE,
1412d9cb4336SCornelia Huck #define KVM_DEV_TYPE_XIVE		KVM_DEV_TYPE_XIVE
14132a886794SGreg Kurz 	KVM_DEV_TYPE_ARM_PV_TIME,
14142a886794SGreg Kurz #define KVM_DEV_TYPE_ARM_PV_TIME	KVM_DEV_TYPE_ARM_PV_TIME
1415d0bf492fSCédric Le Goater 	KVM_DEV_TYPE_RISCV_AIA,
1416d0bf492fSCédric Le Goater #define KVM_DEV_TYPE_RISCV_AIA		KVM_DEV_TYPE_RISCV_AIA
1417444b1996SArd Biesheuvel 	KVM_DEV_TYPE_MAX,
1418444b1996SArd Biesheuvel };
1419e098b453SAlexey Kardashevskiy 
142074c98e20SCornelia Huck struct kvm_vfio_spapr_tce {
142174c98e20SCornelia Huck 	__s32	groupfd;
142274c98e20SCornelia Huck 	__s32	tablefd;
142374c98e20SCornelia Huck };
142474c98e20SCornelia Huck 
1425e098b453SAlexey Kardashevskiy /*
142651b24e34SJan Kiszka  * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns
142751b24e34SJan Kiszka  * a vcpu fd.
142851b24e34SJan Kiszka  */
142951b24e34SJan Kiszka #define KVM_CREATE_VCPU           _IO(KVMIO,   0x41)
143051b24e34SJan Kiszka #define KVM_GET_DIRTY_LOG         _IOW(KVMIO,  0x42, struct kvm_dirty_log)
143151b24e34SJan Kiszka #define KVM_SET_NR_MMU_PAGES      _IO(KVMIO,   0x44)
1432d0bf492fSCédric Le Goater #define KVM_GET_NR_MMU_PAGES      _IO(KVMIO,   0x45)  /* deprecated */
143351b24e34SJan Kiszka #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \
143451b24e34SJan Kiszka 					struct kvm_userspace_memory_region)
143551b24e34SJan Kiszka #define KVM_SET_TSS_ADDR          _IO(KVMIO,   0x47)
143651b24e34SJan Kiszka #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO,  0x48, __u64)
1437*6a02465fSDaniel Henrique Barboza #define KVM_SET_USER_MEMORY_REGION2 _IOW(KVMIO, 0x49, \
1438*6a02465fSDaniel Henrique Barboza 					 struct kvm_userspace_memory_region2)
14391529ae1bSAlexander Graf 
14401529ae1bSAlexander Graf /* enable ucontrol for s390 */
14411529ae1bSAlexander Graf struct kvm_s390_ucas_mapping {
14421529ae1bSAlexander Graf 	__u64 user_addr;
14431529ae1bSAlexander Graf 	__u64 vcpu_addr;
14441529ae1bSAlexander Graf 	__u64 length;
14451529ae1bSAlexander Graf };
14461529ae1bSAlexander Graf #define KVM_S390_UCAS_MAP        _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping)
14471529ae1bSAlexander Graf #define KVM_S390_UCAS_UNMAP      _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping)
14481529ae1bSAlexander Graf #define KVM_S390_VCPU_FAULT	 _IOW(KVMIO, 0x52, unsigned long)
14491529ae1bSAlexander Graf 
145051b24e34SJan Kiszka /* Device model IOC */
145151b24e34SJan Kiszka #define KVM_CREATE_IRQCHIP        _IO(KVMIO,   0x60)
145251b24e34SJan Kiszka #define KVM_IRQ_LINE              _IOW(KVMIO,  0x61, struct kvm_irq_level)
145351b24e34SJan Kiszka #define KVM_GET_IRQCHIP           _IOWR(KVMIO, 0x62, struct kvm_irqchip)
145451b24e34SJan Kiszka #define KVM_SET_IRQCHIP           _IOR(KVMIO,  0x63, struct kvm_irqchip)
145551b24e34SJan Kiszka #define KVM_CREATE_PIT            _IO(KVMIO,   0x64)
145651b24e34SJan Kiszka #define KVM_GET_PIT               _IOWR(KVMIO, 0x65, struct kvm_pit_state)
145751b24e34SJan Kiszka #define KVM_SET_PIT               _IOR(KVMIO,  0x66, struct kvm_pit_state)
145851b24e34SJan Kiszka #define KVM_IRQ_LINE_STATUS       _IOWR(KVMIO, 0x67, struct kvm_irq_level)
145951b24e34SJan Kiszka #define KVM_REGISTER_COALESCED_MMIO \
146051b24e34SJan Kiszka 			_IOW(KVMIO,  0x67, struct kvm_coalesced_mmio_zone)
146151b24e34SJan Kiszka #define KVM_UNREGISTER_COALESCED_MMIO \
146251b24e34SJan Kiszka 			_IOW(KVMIO,  0x68, struct kvm_coalesced_mmio_zone)
146351b24e34SJan Kiszka #define KVM_SET_GSI_ROUTING       _IOW(KVMIO,  0x6a, struct kvm_irq_routing)
146451b24e34SJan Kiszka #define KVM_REINJECT_CONTROL      _IO(KVMIO,   0x71)
146551b24e34SJan Kiszka #define KVM_IRQFD                 _IOW(KVMIO,  0x76, struct kvm_irqfd)
146651b24e34SJan Kiszka #define KVM_CREATE_PIT2		  _IOW(KVMIO,  0x77, struct kvm_pit_config)
146751b24e34SJan Kiszka #define KVM_SET_BOOT_CPU_ID       _IO(KVMIO,   0x78)
146851b24e34SJan Kiszka #define KVM_IOEVENTFD             _IOW(KVMIO,  0x79, struct kvm_ioeventfd)
146951b24e34SJan Kiszka #define KVM_XEN_HVM_CONFIG        _IOW(KVMIO,  0x7a, struct kvm_xen_hvm_config)
147051b24e34SJan Kiszka #define KVM_SET_CLOCK             _IOW(KVMIO,  0x7b, struct kvm_clock_data)
147151b24e34SJan Kiszka #define KVM_GET_CLOCK             _IOR(KVMIO,  0x7c, struct kvm_clock_data)
147251b24e34SJan Kiszka /* Available with KVM_CAP_PIT_STATE2 */
147351b24e34SJan Kiszka #define KVM_GET_PIT2              _IOR(KVMIO,  0x9f, struct kvm_pit_state2)
147451b24e34SJan Kiszka #define KVM_SET_PIT2              _IOW(KVMIO,  0xa0, struct kvm_pit_state2)
147551b24e34SJan Kiszka /* Available with KVM_CAP_PPC_GET_PVINFO */
147651b24e34SJan Kiszka #define KVM_PPC_GET_PVINFO	  _IOW(KVMIO,  0xa1, struct kvm_ppc_pvinfo)
1477d525f73fSChenyi Qiang /* Available with KVM_CAP_TSC_CONTROL for a vCPU, or with
1478d525f73fSChenyi Qiang *  KVM_CAP_VM_TSC_CONTROL to set defaults for a VM */
147951b24e34SJan Kiszka #define KVM_SET_TSC_KHZ           _IO(KVMIO,  0xa2)
148051b24e34SJan Kiszka #define KVM_GET_TSC_KHZ           _IO(KVMIO,  0xa3)
148180a3eb10SJan Kiszka /* Available with KVM_CAP_SIGNAL_MSI */
148280a3eb10SJan Kiszka #define KVM_SIGNAL_MSI            _IOW(KVMIO,  0xa5, struct kvm_msi)
148380a3eb10SJan Kiszka /* Available with KVM_CAP_PPC_GET_SMMU_INFO */
148480a3eb10SJan Kiszka #define KVM_PPC_GET_SMMU_INFO	  _IOR(KVMIO,  0xa6, struct kvm_ppc_smmu_info)
1485651682dcSMichael S. Tsirkin /* Available with KVM_CAP_PPC_ALLOC_HTAB */
1486651682dcSMichael S. Tsirkin #define KVM_PPC_ALLOCATE_HTAB	  _IOWR(KVMIO, 0xa7, __u32)
1487d4834ff9SAlexander Graf #define KVM_CREATE_SPAPR_TCE	  _IOW(KVMIO,  0xa8, struct kvm_create_spapr_tce)
1488b89485a5SPaolo Bonzini #define KVM_CREATE_SPAPR_TCE_64	  _IOW(KVMIO,  0xa8, \
1489b89485a5SPaolo Bonzini 				       struct kvm_create_spapr_tce_64)
1490d4834ff9SAlexander Graf /* Available with KVM_CAP_RMA */
1491d4834ff9SAlexander Graf #define KVM_ALLOCATE_RMA	  _IOR(KVMIO,  0xa9, struct kvm_allocate_rma)
1492d4834ff9SAlexander Graf /* Available with KVM_CAP_PPC_HTAB_FD */
1493d4834ff9SAlexander Graf #define KVM_PPC_GET_HTAB_FD	  _IOW(KVMIO,  0xaa, struct kvm_get_htab_fd)
1494eadd0e44SPeter Maydell /* Available with KVM_CAP_ARM_SET_DEVICE_ADDR */
1495eadd0e44SPeter Maydell #define KVM_ARM_SET_DEVICE_ADDR	  _IOW(KVMIO,  0xab, struct kvm_arm_device_addr)
1496e098b453SAlexey Kardashevskiy /* Available with KVM_CAP_PPC_RTAS */
1497e098b453SAlexey Kardashevskiy #define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO,  0xac, struct kvm_rtas_token_args)
14983a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_SPAPR_RESIZE_HPT */
14993a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt)
15003a5eb5b4SPaolo Bonzini #define KVM_PPC_RESIZE_HPT_COMMIT  _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt)
15013a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */
15023a5eb5b4SPaolo Bonzini #define KVM_PPC_CONFIGURE_V3_MMU  _IOW(KVMIO,  0xaf, struct kvm_ppc_mmuv3_cfg)
15033a5eb5b4SPaolo Bonzini /* Available with KVM_CAP_PPC_RADIX_MMU */
15043a5eb5b4SPaolo Bonzini #define KVM_PPC_GET_RMMU_INFO	  _IOW(KVMIO,  0xb0, struct kvm_ppc_rmmu_info)
15059cbb6362SCornelia Huck /* Available with KVM_CAP_PPC_GET_CPU_CHAR */
15069cbb6362SCornelia Huck #define KVM_PPC_GET_CPU_CHAR	  _IOR(KVMIO,  0xb1, struct kvm_ppc_cpu_char)
1507f363d039SEric Auger /* Available with KVM_CAP_PMU_EVENT_FILTER */
1508f363d039SEric Auger #define KVM_SET_PMU_EVENT_FILTER  _IOW(KVMIO,  0xb2, struct kvm_pmu_event_filter)
150950fd0c37SBharata B Rao #define KVM_PPC_SVM_OFF		  _IO(KVMIO,  0xb3)
1510327d4b7fSBharata B Rao #define KVM_ARM_MTE_COPY_TAGS	  _IOR(KVMIO,  0xb4, struct kvm_arm_copy_mte_tags)
1511d0bf492fSCédric Le Goater /* Available with KVM_CAP_COUNTER_OFFSET */
1512d0bf492fSCédric Le Goater #define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO,  0xb5, struct kvm_arm_counter_offset)
1513efb91426SDaniel Henrique Barboza #define KVM_ARM_GET_REG_WRITABLE_MASKS _IOR(KVMIO,  0xb6, struct reg_mask_range)
1514e098b453SAlexey Kardashevskiy 
1515e098b453SAlexey Kardashevskiy /* ioctl for vm fd */
1516e098b453SAlexey Kardashevskiy #define KVM_CREATE_DEVICE	  _IOWR(KVMIO,  0xe0, struct kvm_create_device)
1517e098b453SAlexey Kardashevskiy 
1518e098b453SAlexey Kardashevskiy /* ioctls for fds returned by KVM_CREATE_DEVICE */
1519e098b453SAlexey Kardashevskiy #define KVM_SET_DEVICE_ATTR	  _IOW(KVMIO,  0xe1, struct kvm_device_attr)
1520e098b453SAlexey Kardashevskiy #define KVM_GET_DEVICE_ATTR	  _IOW(KVMIO,  0xe2, struct kvm_device_attr)
1521e098b453SAlexey Kardashevskiy #define KVM_HAS_DEVICE_ATTR	  _IOW(KVMIO,  0xe3, struct kvm_device_attr)
152251b24e34SJan Kiszka 
152351b24e34SJan Kiszka /*
152451b24e34SJan Kiszka  * ioctls for vcpu fds
152551b24e34SJan Kiszka  */
152651b24e34SJan Kiszka #define KVM_RUN                   _IO(KVMIO,   0x80)
152751b24e34SJan Kiszka #define KVM_GET_REGS              _IOR(KVMIO,  0x81, struct kvm_regs)
152851b24e34SJan Kiszka #define KVM_SET_REGS              _IOW(KVMIO,  0x82, struct kvm_regs)
152951b24e34SJan Kiszka #define KVM_GET_SREGS             _IOR(KVMIO,  0x83, struct kvm_sregs)
153051b24e34SJan Kiszka #define KVM_SET_SREGS             _IOW(KVMIO,  0x84, struct kvm_sregs)
153151b24e34SJan Kiszka #define KVM_TRANSLATE             _IOWR(KVMIO, 0x85, struct kvm_translation)
153251b24e34SJan Kiszka #define KVM_INTERRUPT             _IOW(KVMIO,  0x86, struct kvm_interrupt)
153351b24e34SJan Kiszka #define KVM_GET_MSRS              _IOWR(KVMIO, 0x88, struct kvm_msrs)
153451b24e34SJan Kiszka #define KVM_SET_MSRS              _IOW(KVMIO,  0x89, struct kvm_msrs)
153551b24e34SJan Kiszka #define KVM_SET_CPUID             _IOW(KVMIO,  0x8a, struct kvm_cpuid)
153651b24e34SJan Kiszka #define KVM_SET_SIGNAL_MASK       _IOW(KVMIO,  0x8b, struct kvm_signal_mask)
153751b24e34SJan Kiszka #define KVM_GET_FPU               _IOR(KVMIO,  0x8c, struct kvm_fpu)
153851b24e34SJan Kiszka #define KVM_SET_FPU               _IOW(KVMIO,  0x8d, struct kvm_fpu)
153951b24e34SJan Kiszka #define KVM_GET_LAPIC             _IOR(KVMIO,  0x8e, struct kvm_lapic_state)
154051b24e34SJan Kiszka #define KVM_SET_LAPIC             _IOW(KVMIO,  0x8f, struct kvm_lapic_state)
154151b24e34SJan Kiszka #define KVM_SET_CPUID2            _IOW(KVMIO,  0x90, struct kvm_cpuid2)
154251b24e34SJan Kiszka #define KVM_GET_CPUID2            _IOWR(KVMIO, 0x91, struct kvm_cpuid2)
154351b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */
154451b24e34SJan Kiszka #define KVM_TPR_ACCESS_REPORTING  _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)
154551b24e34SJan Kiszka /* Available with KVM_CAP_VAPIC */
154651b24e34SJan Kiszka #define KVM_SET_VAPIC_ADDR        _IOW(KVMIO,  0x93, struct kvm_vapic_addr)
154751b24e34SJan Kiszka /* valid for virtual machine (for floating interrupt)_and_ vcpu */
154851b24e34SJan Kiszka #define KVM_S390_INTERRUPT        _IOW(KVMIO,  0x94, struct kvm_s390_interrupt)
154951b24e34SJan Kiszka /* store status for s390 */
155051b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_NOADDR    (-1ul)
155151b24e34SJan Kiszka #define KVM_S390_STORE_STATUS_PREFIXED  (-2ul)
155251b24e34SJan Kiszka #define KVM_S390_STORE_STATUS	  _IOW(KVMIO,  0x95, unsigned long)
155351b24e34SJan Kiszka /* initial ipl psw for s390 */
155451b24e34SJan Kiszka #define KVM_S390_SET_INITIAL_PSW  _IOW(KVMIO,  0x96, struct kvm_s390_psw)
155551b24e34SJan Kiszka /* initial reset for s390 */
155651b24e34SJan Kiszka #define KVM_S390_INITIAL_RESET    _IO(KVMIO,   0x97)
155751b24e34SJan Kiszka #define KVM_GET_MP_STATE          _IOR(KVMIO,  0x98, struct kvm_mp_state)
155851b24e34SJan Kiszka #define KVM_SET_MP_STATE          _IOW(KVMIO,  0x99, struct kvm_mp_state)
1559444b1996SArd Biesheuvel /* Available with KVM_CAP_USER_NMI */
156051b24e34SJan Kiszka #define KVM_NMI                   _IO(KVMIO,   0x9a)
156151b24e34SJan Kiszka /* Available with KVM_CAP_SET_GUEST_DEBUG */
156251b24e34SJan Kiszka #define KVM_SET_GUEST_DEBUG       _IOW(KVMIO,  0x9b, struct kvm_guest_debug)
156351b24e34SJan Kiszka /* MCE for x86 */
156451b24e34SJan Kiszka #define KVM_X86_SETUP_MCE         _IOW(KVMIO,  0x9c, __u64)
156551b24e34SJan Kiszka #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO,  0x9d, __u64)
156651b24e34SJan Kiszka #define KVM_X86_SET_MCE           _IOW(KVMIO,  0x9e, struct kvm_x86_mce)
156751b24e34SJan Kiszka /* Available with KVM_CAP_VCPU_EVENTS */
156851b24e34SJan Kiszka #define KVM_GET_VCPU_EVENTS       _IOR(KVMIO,  0x9f, struct kvm_vcpu_events)
156951b24e34SJan Kiszka #define KVM_SET_VCPU_EVENTS       _IOW(KVMIO,  0xa0, struct kvm_vcpu_events)
157051b24e34SJan Kiszka /* Available with KVM_CAP_DEBUGREGS */
157151b24e34SJan Kiszka #define KVM_GET_DEBUGREGS         _IOR(KVMIO,  0xa1, struct kvm_debugregs)
157251b24e34SJan Kiszka #define KVM_SET_DEBUGREGS         _IOW(KVMIO,  0xa2, struct kvm_debugregs)
15739ffd2685SCornelia Huck /*
1574d0bf492fSCédric Le Goater  * vcpu version available with KVM_CAP_ENABLE_CAP
15759ffd2685SCornelia Huck  * vm version available with KVM_CAP_ENABLE_CAP_VM
15769ffd2685SCornelia Huck  */
157751b24e34SJan Kiszka #define KVM_ENABLE_CAP            _IOW(KVMIO,  0xa3, struct kvm_enable_cap)
157851b24e34SJan Kiszka /* Available with KVM_CAP_XSAVE */
157951b24e34SJan Kiszka #define KVM_GET_XSAVE		  _IOR(KVMIO,  0xa4, struct kvm_xsave)
158051b24e34SJan Kiszka #define KVM_SET_XSAVE		  _IOW(KVMIO,  0xa5, struct kvm_xsave)
158151b24e34SJan Kiszka /* Available with KVM_CAP_XCRS */
158251b24e34SJan Kiszka #define KVM_GET_XCRS		  _IOR(KVMIO,  0xa6, struct kvm_xcrs)
158351b24e34SJan Kiszka #define KVM_SET_XCRS		  _IOW(KVMIO,  0xa7, struct kvm_xcrs)
1584a54fc080SAlexander Graf /* Available with KVM_CAP_SW_TLB */
1585a54fc080SAlexander Graf #define KVM_DIRTY_TLB		  _IOW(KVMIO,  0xaa, struct kvm_dirty_tlb)
15869d4e4f8cSAlexander Graf /* Available with KVM_CAP_ONE_REG */
1587a31be480SAlexander Graf #define KVM_GET_ONE_REG		  _IOW(KVMIO,  0xab, struct kvm_one_reg)
15889d4e4f8cSAlexander Graf #define KVM_SET_ONE_REG		  _IOW(KVMIO,  0xac, struct kvm_one_reg)
15899ab2195dSMarcelo Tosatti /* VM is being stopped by host */
15909ab2195dSMarcelo Tosatti #define KVM_KVMCLOCK_CTRL	  _IO(KVMIO,   0xad)
1591eadd0e44SPeter Maydell #define KVM_ARM_VCPU_INIT	  _IOW(KVMIO,  0xae, struct kvm_vcpu_init)
1592bf63839fSAlex Williamson #define KVM_ARM_PREFERRED_TARGET  _IOR(KVMIO,  0xaf, struct kvm_vcpu_init)
1593eadd0e44SPeter Maydell #define KVM_GET_REG_LIST	  _IOWR(KVMIO, 0xb0, struct kvm_reg_list)
15947a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_MEM_OP */
15957a52ce8aSCornelia Huck #define KVM_S390_MEM_OP		  _IOW(KVMIO,  0xb1, struct kvm_s390_mem_op)
15967a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_SKEYS */
15977a52ce8aSCornelia Huck #define KVM_S390_GET_SKEYS      _IOW(KVMIO, 0xb2, struct kvm_s390_skeys)
15987a52ce8aSCornelia Huck #define KVM_S390_SET_SKEYS      _IOW(KVMIO, 0xb3, struct kvm_s390_skeys)
15997a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_INJECT_IRQ */
16007a52ce8aSCornelia Huck #define KVM_S390_IRQ              _IOW(KVMIO,  0xb4, struct kvm_s390_irq)
16017a52ce8aSCornelia Huck /* Available with KVM_CAP_S390_IRQ_STATE */
16027a52ce8aSCornelia Huck #define KVM_S390_SET_IRQ_STATE	  _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state)
16037a52ce8aSCornelia Huck #define KVM_S390_GET_IRQ_STATE	  _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state)
160424a31426SPaolo Bonzini /* Available with KVM_CAP_X86_SMM */
160524a31426SPaolo Bonzini #define KVM_SMI                   _IO(KVMIO,   0xb7)
16063272f0e2SChristian Borntraeger /* Available with KVM_CAP_S390_CMMA_MIGRATION */
1607ab6e1550SChristian Borntraeger #define KVM_S390_GET_CMMA_BITS      _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log)
16083272f0e2SChristian Borntraeger #define KVM_S390_SET_CMMA_BITS      _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log)
16099f2d175dSPaolo Bonzini /* Memory Encryption Commands */
16109f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_OP      _IOWR(KVMIO, 0xba, unsigned long)
16119f2d175dSPaolo Bonzini 
16129f2d175dSPaolo Bonzini struct kvm_enc_region {
16139f2d175dSPaolo Bonzini 	__u64 addr;
16149f2d175dSPaolo Bonzini 	__u64 size;
16159f2d175dSPaolo Bonzini };
16169f2d175dSPaolo Bonzini 
16179f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_REG_REGION    _IOR(KVMIO, 0xbb, struct kvm_enc_region)
16189f2d175dSPaolo Bonzini #define KVM_MEMORY_ENCRYPT_UNREG_REGION  _IOR(KVMIO, 0xbc, struct kvm_enc_region)
16199f2d175dSPaolo Bonzini 
162065a6d8ddSPeter Maydell /* Available with KVM_CAP_HYPERV_EVENTFD */
162165a6d8ddSPeter Maydell #define KVM_HYPERV_EVENTFD        _IOW(KVMIO,  0xbd, struct kvm_hyperv_eventfd)
162265a6d8ddSPeter Maydell 
1623d36f7de8SCornelia Huck /* Available with KVM_CAP_NESTED_STATE */
1624d36f7de8SCornelia Huck #define KVM_GET_NESTED_STATE         _IOWR(KVMIO, 0xbe, struct kvm_nested_state)
1625d36f7de8SCornelia Huck #define KVM_SET_NESTED_STATE         _IOW(KVMIO,  0xbf, struct kvm_nested_state)
162665a6d8ddSPeter Maydell 
1627d9cb4336SCornelia Huck /* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT_2 */
1628da054c64SPaolo Bonzini #define KVM_CLEAR_DIRTY_LOG          _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log)
1629da054c64SPaolo Bonzini 
1630b3c818a4SEric Farman /* Available with KVM_CAP_HYPERV_CPUID (vcpu) / KVM_CAP_SYS_HYPERV_CPUID (system) */
1631da054c64SPaolo Bonzini #define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2)
1632da054c64SPaolo Bonzini 
1633d9cb4336SCornelia Huck /* Available with KVM_CAP_ARM_SVE */
1634d9cb4336SCornelia Huck #define KVM_ARM_VCPU_FINALIZE	  _IOW(KVMIO,  0xc2, int)
1635d9cb4336SCornelia Huck 
1636ddda3748SCornelia Huck /* Available with  KVM_CAP_S390_VCPU_RESETS */
1637ddda3748SCornelia Huck #define KVM_S390_NORMAL_RESET	_IO(KVMIO,   0xc3)
1638ddda3748SCornelia Huck #define KVM_S390_CLEAR_RESET	_IO(KVMIO,   0xc4)
1639ddda3748SCornelia Huck 
1640dc6f8d45SCornelia Huck struct kvm_s390_pv_sec_parm {
1641dc6f8d45SCornelia Huck 	__u64 origin;
1642dc6f8d45SCornelia Huck 	__u64 length;
1643dc6f8d45SCornelia Huck };
1644dc6f8d45SCornelia Huck 
1645dc6f8d45SCornelia Huck struct kvm_s390_pv_unp {
1646dc6f8d45SCornelia Huck 	__u64 addr;
1647dc6f8d45SCornelia Huck 	__u64 size;
1648dc6f8d45SCornelia Huck 	__u64 tweak;
1649dc6f8d45SCornelia Huck };
1650dc6f8d45SCornelia Huck 
1651d525f73fSChenyi Qiang enum pv_cmd_dmp_id {
1652d525f73fSChenyi Qiang 	KVM_PV_DUMP_INIT,
1653d525f73fSChenyi Qiang 	KVM_PV_DUMP_CONFIG_STOR_STATE,
1654d525f73fSChenyi Qiang 	KVM_PV_DUMP_COMPLETE,
1655d525f73fSChenyi Qiang 	KVM_PV_DUMP_CPU,
1656d525f73fSChenyi Qiang };
1657d525f73fSChenyi Qiang 
1658d525f73fSChenyi Qiang struct kvm_s390_pv_dmp {
1659d525f73fSChenyi Qiang 	__u64 subcmd;
1660d525f73fSChenyi Qiang 	__u64 buff_addr;
1661d525f73fSChenyi Qiang 	__u64 buff_len;
1662d525f73fSChenyi Qiang 	__u64 gaddr;		/* For dump storage state */
1663d525f73fSChenyi Qiang 	__u64 reserved[4];
1664d525f73fSChenyi Qiang };
1665d525f73fSChenyi Qiang 
1666d525f73fSChenyi Qiang enum pv_cmd_info_id {
1667d525f73fSChenyi Qiang 	KVM_PV_INFO_VM,
1668d525f73fSChenyi Qiang 	KVM_PV_INFO_DUMP,
1669d525f73fSChenyi Qiang };
1670d525f73fSChenyi Qiang 
1671d525f73fSChenyi Qiang struct kvm_s390_pv_info_dump {
1672d525f73fSChenyi Qiang 	__u64 dump_cpu_buffer_len;
1673d525f73fSChenyi Qiang 	__u64 dump_config_mem_buffer_per_1m;
1674d525f73fSChenyi Qiang 	__u64 dump_config_finalize_len;
1675d525f73fSChenyi Qiang };
1676d525f73fSChenyi Qiang 
1677d525f73fSChenyi Qiang struct kvm_s390_pv_info_vm {
1678d525f73fSChenyi Qiang 	__u64 inst_calls_list[4];
1679d525f73fSChenyi Qiang 	__u64 max_cpus;
1680d525f73fSChenyi Qiang 	__u64 max_guests;
1681d525f73fSChenyi Qiang 	__u64 max_guest_addr;
1682d525f73fSChenyi Qiang 	__u64 feature_indication;
1683d525f73fSChenyi Qiang };
1684d525f73fSChenyi Qiang 
1685d525f73fSChenyi Qiang struct kvm_s390_pv_info_header {
1686d525f73fSChenyi Qiang 	__u32 id;
1687d525f73fSChenyi Qiang 	__u32 len_max;
1688d525f73fSChenyi Qiang 	__u32 len_written;
1689d525f73fSChenyi Qiang 	__u32 reserved;
1690d525f73fSChenyi Qiang };
1691d525f73fSChenyi Qiang 
1692d525f73fSChenyi Qiang struct kvm_s390_pv_info {
1693d525f73fSChenyi Qiang 	struct kvm_s390_pv_info_header header;
1694d525f73fSChenyi Qiang 	union {
1695d525f73fSChenyi Qiang 		struct kvm_s390_pv_info_dump dump;
1696d525f73fSChenyi Qiang 		struct kvm_s390_pv_info_vm vm;
1697d525f73fSChenyi Qiang 	};
1698d525f73fSChenyi Qiang };
1699d525f73fSChenyi Qiang 
1700dc6f8d45SCornelia Huck enum pv_cmd_id {
1701dc6f8d45SCornelia Huck 	KVM_PV_ENABLE,
1702dc6f8d45SCornelia Huck 	KVM_PV_DISABLE,
1703dc6f8d45SCornelia Huck 	KVM_PV_SET_SEC_PARMS,
1704dc6f8d45SCornelia Huck 	KVM_PV_UNPACK,
1705dc6f8d45SCornelia Huck 	KVM_PV_VERIFY,
1706dc6f8d45SCornelia Huck 	KVM_PV_PREP_RESET,
1707dc6f8d45SCornelia Huck 	KVM_PV_UNSHARE_ALL,
1708d525f73fSChenyi Qiang 	KVM_PV_INFO,
1709d525f73fSChenyi Qiang 	KVM_PV_DUMP,
171093d7620cSAvihai Horon 	KVM_PV_ASYNC_CLEANUP_PREPARE,
171193d7620cSAvihai Horon 	KVM_PV_ASYNC_CLEANUP_PERFORM,
1712dc6f8d45SCornelia Huck };
1713dc6f8d45SCornelia Huck 
1714dc6f8d45SCornelia Huck struct kvm_pv_cmd {
1715dc6f8d45SCornelia Huck 	__u32 cmd;	/* Command to be executed */
1716dc6f8d45SCornelia Huck 	__u16 rc;	/* Ultravisor return code */
1717dc6f8d45SCornelia Huck 	__u16 rrc;	/* Ultravisor return reason code */
1718dc6f8d45SCornelia Huck 	__u64 data;	/* Data or address */
1719dc6f8d45SCornelia Huck 	__u32 flags;    /* flags for future extensions. Must be 0 for now */
1720dc6f8d45SCornelia Huck 	__u32 reserved[3];
1721dc6f8d45SCornelia Huck };
1722dc6f8d45SCornelia Huck 
1723dc6f8d45SCornelia Huck /* Available with KVM_CAP_S390_PROTECTED */
1724dc6f8d45SCornelia Huck #define KVM_S390_PV_COMMAND		_IOWR(KVMIO, 0xc5, struct kvm_pv_cmd)
1725dc6f8d45SCornelia Huck 
172653ba2eeeSMatthew Rosato /* Available with KVM_CAP_X86_MSR_FILTER */
172753ba2eeeSMatthew Rosato #define KVM_X86_SET_MSR_FILTER	_IOW(KVMIO,  0xc6, struct kvm_msr_filter)
172853ba2eeeSMatthew Rosato 
1729b3c818a4SEric Farman /* Available with KVM_CAP_DIRTY_LOG_RING */
1730b3c818a4SEric Farman #define KVM_RESET_DIRTY_RINGS		_IO(KVMIO, 0xc7)
1731b3c818a4SEric Farman 
1732278f064eSEduardo Habkost /* Per-VM Xen attributes */
1733278f064eSEduardo Habkost #define KVM_XEN_HVM_GET_ATTR	_IOWR(KVMIO, 0xc8, struct kvm_xen_hvm_attr)
1734278f064eSEduardo Habkost #define KVM_XEN_HVM_SET_ATTR	_IOW(KVMIO,  0xc9, struct kvm_xen_hvm_attr)
1735278f064eSEduardo Habkost 
1736278f064eSEduardo Habkost struct kvm_xen_hvm_attr {
1737278f064eSEduardo Habkost 	__u16 type;
1738278f064eSEduardo Habkost 	__u16 pad[3];
1739278f064eSEduardo Habkost 	union {
1740278f064eSEduardo Habkost 		__u8 long_mode;
1741278f064eSEduardo Habkost 		__u8 vector;
174293d7620cSAvihai Horon 		__u8 runstate_update_flag;
1743278f064eSEduardo Habkost 		struct {
1744278f064eSEduardo Habkost 			__u64 gfn;
174593d7620cSAvihai Horon #define KVM_XEN_INVALID_GFN ((__u64)-1)
1746278f064eSEduardo Habkost 		} shared_info;
1747d525f73fSChenyi Qiang 		struct {
1748d525f73fSChenyi Qiang 			__u32 send_port;
1749d525f73fSChenyi Qiang 			__u32 type; /* EVTCHNSTAT_ipi / EVTCHNSTAT_interdomain */
1750d525f73fSChenyi Qiang 			__u32 flags;
1751d525f73fSChenyi Qiang #define KVM_XEN_EVTCHN_DEASSIGN		(1 << 0)
1752d525f73fSChenyi Qiang #define KVM_XEN_EVTCHN_UPDATE		(1 << 1)
1753d525f73fSChenyi Qiang #define KVM_XEN_EVTCHN_RESET		(1 << 2)
1754d525f73fSChenyi Qiang 			/*
1755d525f73fSChenyi Qiang 			 * Events sent by the guest are either looped back to
1756d525f73fSChenyi Qiang 			 * the guest itself (potentially on a different port#)
1757d525f73fSChenyi Qiang 			 * or signalled via an eventfd.
1758d525f73fSChenyi Qiang 			 */
1759d525f73fSChenyi Qiang 			union {
1760d525f73fSChenyi Qiang 				struct {
1761d525f73fSChenyi Qiang 					__u32 port;
1762d525f73fSChenyi Qiang 					__u32 vcpu;
1763d525f73fSChenyi Qiang 					__u32 priority;
1764d525f73fSChenyi Qiang 				} port;
1765d525f73fSChenyi Qiang 				struct {
1766d525f73fSChenyi Qiang 					__u32 port; /* Zero for eventfd */
1767d525f73fSChenyi Qiang 					__s32 fd;
1768d525f73fSChenyi Qiang 				} eventfd;
1769d525f73fSChenyi Qiang 				__u32 padding[4];
1770d525f73fSChenyi Qiang 			} deliver;
1771d525f73fSChenyi Qiang 		} evtchn;
1772d525f73fSChenyi Qiang 		__u32 xen_version;
1773278f064eSEduardo Habkost 		__u64 pad[8];
1774278f064eSEduardo Habkost 	} u;
1775278f064eSEduardo Habkost };
1776278f064eSEduardo Habkost 
177793d7620cSAvihai Horon 
1778278f064eSEduardo Habkost /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */
1779278f064eSEduardo Habkost #define KVM_XEN_ATTR_TYPE_LONG_MODE		0x0
1780278f064eSEduardo Habkost #define KVM_XEN_ATTR_TYPE_SHARED_INFO		0x1
1781278f064eSEduardo Habkost #define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR		0x2
1782d525f73fSChenyi Qiang /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */
1783d525f73fSChenyi Qiang #define KVM_XEN_ATTR_TYPE_EVTCHN		0x3
1784d525f73fSChenyi Qiang #define KVM_XEN_ATTR_TYPE_XEN_VERSION		0x4
178593d7620cSAvihai Horon /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG */
178693d7620cSAvihai Horon #define KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG	0x5
1787278f064eSEduardo Habkost 
1788278f064eSEduardo Habkost /* Per-vCPU Xen attributes */
1789278f064eSEduardo Habkost #define KVM_XEN_VCPU_GET_ATTR	_IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr)
1790278f064eSEduardo Habkost #define KVM_XEN_VCPU_SET_ATTR	_IOW(KVMIO,  0xcb, struct kvm_xen_vcpu_attr)
1791278f064eSEduardo Habkost 
1792d525f73fSChenyi Qiang /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */
1793d525f73fSChenyi Qiang #define KVM_XEN_HVM_EVTCHN_SEND	_IOW(KVMIO,  0xd0, struct kvm_irq_routing_xen_evtchn)
1794d525f73fSChenyi Qiang 
1795327d4b7fSBharata B Rao #define KVM_GET_SREGS2             _IOR(KVMIO,  0xcc, struct kvm_sregs2)
1796327d4b7fSBharata B Rao #define KVM_SET_SREGS2             _IOW(KVMIO,  0xcd, struct kvm_sregs2)
1797327d4b7fSBharata B Rao 
1798278f064eSEduardo Habkost struct kvm_xen_vcpu_attr {
1799278f064eSEduardo Habkost 	__u16 type;
1800278f064eSEduardo Habkost 	__u16 pad[3];
1801278f064eSEduardo Habkost 	union {
1802278f064eSEduardo Habkost 		__u64 gpa;
180393d7620cSAvihai Horon #define KVM_XEN_INVALID_GPA ((__u64)-1)
1804278f064eSEduardo Habkost 		__u64 pad[8];
1805278f064eSEduardo Habkost 		struct {
1806278f064eSEduardo Habkost 			__u64 state;
1807278f064eSEduardo Habkost 			__u64 state_entry_time;
1808278f064eSEduardo Habkost 			__u64 time_running;
1809278f064eSEduardo Habkost 			__u64 time_runnable;
1810278f064eSEduardo Habkost 			__u64 time_blocked;
1811278f064eSEduardo Habkost 			__u64 time_offline;
1812278f064eSEduardo Habkost 		} runstate;
1813d525f73fSChenyi Qiang 		__u32 vcpu_id;
1814d525f73fSChenyi Qiang 		struct {
1815d525f73fSChenyi Qiang 			__u32 port;
1816d525f73fSChenyi Qiang 			__u32 priority;
1817d525f73fSChenyi Qiang 			__u64 expires_ns;
1818d525f73fSChenyi Qiang 		} timer;
1819d525f73fSChenyi Qiang 		__u8 vector;
1820278f064eSEduardo Habkost 	} u;
1821278f064eSEduardo Habkost };
1822278f064eSEduardo Habkost 
1823278f064eSEduardo Habkost /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */
1824278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO	0x0
1825278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO	0x1
1826278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR	0x2
1827278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT	0x3
1828278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA	0x4
1829278f064eSEduardo Habkost #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST	0x5
1830d525f73fSChenyi Qiang /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */
1831d525f73fSChenyi Qiang #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID		0x6
1832d525f73fSChenyi Qiang #define KVM_XEN_VCPU_ATTR_TYPE_TIMER		0x7
1833d525f73fSChenyi Qiang #define KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR	0x8
1834278f064eSEduardo Habkost 
18359f2d175dSPaolo Bonzini /* Secure Encrypted Virtualization command */
18369f2d175dSPaolo Bonzini enum sev_cmd_id {
18379f2d175dSPaolo Bonzini 	/* Guest initialization commands */
18389f2d175dSPaolo Bonzini 	KVM_SEV_INIT = 0,
18399f2d175dSPaolo Bonzini 	KVM_SEV_ES_INIT,
18409f2d175dSPaolo Bonzini 	/* Guest launch commands */
18419f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_START,
18429f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_UPDATE_DATA,
18439f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_UPDATE_VMSA,
18449f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_SECRET,
18459f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_MEASURE,
18469f2d175dSPaolo Bonzini 	KVM_SEV_LAUNCH_FINISH,
18479f2d175dSPaolo Bonzini 	/* Guest migration commands (outgoing) */
18489f2d175dSPaolo Bonzini 	KVM_SEV_SEND_START,
18499f2d175dSPaolo Bonzini 	KVM_SEV_SEND_UPDATE_DATA,
18509f2d175dSPaolo Bonzini 	KVM_SEV_SEND_UPDATE_VMSA,
18519f2d175dSPaolo Bonzini 	KVM_SEV_SEND_FINISH,
18529f2d175dSPaolo Bonzini 	/* Guest migration commands (incoming) */
18539f2d175dSPaolo Bonzini 	KVM_SEV_RECEIVE_START,
18549f2d175dSPaolo Bonzini 	KVM_SEV_RECEIVE_UPDATE_DATA,
18559f2d175dSPaolo Bonzini 	KVM_SEV_RECEIVE_UPDATE_VMSA,
18569f2d175dSPaolo Bonzini 	KVM_SEV_RECEIVE_FINISH,
18579f2d175dSPaolo Bonzini 	/* Guest status and debug commands */
18589f2d175dSPaolo Bonzini 	KVM_SEV_GUEST_STATUS,
18599f2d175dSPaolo Bonzini 	KVM_SEV_DBG_DECRYPT,
18609f2d175dSPaolo Bonzini 	KVM_SEV_DBG_ENCRYPT,
18619f2d175dSPaolo Bonzini 	/* Guest certificates commands */
18629f2d175dSPaolo Bonzini 	KVM_SEV_CERT_EXPORT,
18633ea1a802SBrijesh Singh 	/* Attestation report */
18643ea1a802SBrijesh Singh 	KVM_SEV_GET_ATTESTATION_REPORT,
1865278f064eSEduardo Habkost 	/* Guest Migration Extension */
1866278f064eSEduardo Habkost 	KVM_SEV_SEND_CANCEL,
18679f2d175dSPaolo Bonzini 
18689f2d175dSPaolo Bonzini 	KVM_SEV_NR_MAX,
18699f2d175dSPaolo Bonzini };
18709f2d175dSPaolo Bonzini 
18719f2d175dSPaolo Bonzini struct kvm_sev_cmd {
18729f2d175dSPaolo Bonzini 	__u32 id;
18739f2d175dSPaolo Bonzini 	__u64 data;
18749f2d175dSPaolo Bonzini 	__u32 error;
18759f2d175dSPaolo Bonzini 	__u32 sev_fd;
18769f2d175dSPaolo Bonzini };
18779f2d175dSPaolo Bonzini 
18789f2d175dSPaolo Bonzini struct kvm_sev_launch_start {
18799f2d175dSPaolo Bonzini 	__u32 handle;
18809f2d175dSPaolo Bonzini 	__u32 policy;
18819f2d175dSPaolo Bonzini 	__u64 dh_uaddr;
18829f2d175dSPaolo Bonzini 	__u32 dh_len;
18839f2d175dSPaolo Bonzini 	__u64 session_uaddr;
18849f2d175dSPaolo Bonzini 	__u32 session_len;
18859f2d175dSPaolo Bonzini };
18869f2d175dSPaolo Bonzini 
18879f2d175dSPaolo Bonzini struct kvm_sev_launch_update_data {
18889f2d175dSPaolo Bonzini 	__u64 uaddr;
18899f2d175dSPaolo Bonzini 	__u32 len;
18909f2d175dSPaolo Bonzini };
18919f2d175dSPaolo Bonzini 
18929f2d175dSPaolo Bonzini 
18939f2d175dSPaolo Bonzini struct kvm_sev_launch_secret {
18949f2d175dSPaolo Bonzini 	__u64 hdr_uaddr;
18959f2d175dSPaolo Bonzini 	__u32 hdr_len;
18969f2d175dSPaolo Bonzini 	__u64 guest_uaddr;
18979f2d175dSPaolo Bonzini 	__u32 guest_len;
18989f2d175dSPaolo Bonzini 	__u64 trans_uaddr;
18999f2d175dSPaolo Bonzini 	__u32 trans_len;
19009f2d175dSPaolo Bonzini };
19019f2d175dSPaolo Bonzini 
19029f2d175dSPaolo Bonzini struct kvm_sev_launch_measure {
19039f2d175dSPaolo Bonzini 	__u64 uaddr;
19049f2d175dSPaolo Bonzini 	__u32 len;
19059f2d175dSPaolo Bonzini };
19069f2d175dSPaolo Bonzini 
19079f2d175dSPaolo Bonzini struct kvm_sev_guest_status {
19089f2d175dSPaolo Bonzini 	__u32 handle;
19099f2d175dSPaolo Bonzini 	__u32 policy;
19109f2d175dSPaolo Bonzini 	__u32 state;
19119f2d175dSPaolo Bonzini };
19129f2d175dSPaolo Bonzini 
19139f2d175dSPaolo Bonzini struct kvm_sev_dbg {
19149f2d175dSPaolo Bonzini 	__u64 src_uaddr;
19159f2d175dSPaolo Bonzini 	__u64 dst_uaddr;
19169f2d175dSPaolo Bonzini 	__u32 len;
19179f2d175dSPaolo Bonzini };
191851b24e34SJan Kiszka 
19193ea1a802SBrijesh Singh struct kvm_sev_attestation_report {
19203ea1a802SBrijesh Singh 	__u8 mnonce[16];
19213ea1a802SBrijesh Singh 	__u64 uaddr;
19223ea1a802SBrijesh Singh 	__u32 len;
19233ea1a802SBrijesh Singh };
19243ea1a802SBrijesh Singh 
1925278f064eSEduardo Habkost struct kvm_sev_send_start {
1926278f064eSEduardo Habkost 	__u32 policy;
1927278f064eSEduardo Habkost 	__u64 pdh_cert_uaddr;
1928278f064eSEduardo Habkost 	__u32 pdh_cert_len;
1929278f064eSEduardo Habkost 	__u64 plat_certs_uaddr;
1930278f064eSEduardo Habkost 	__u32 plat_certs_len;
1931278f064eSEduardo Habkost 	__u64 amd_certs_uaddr;
1932278f064eSEduardo Habkost 	__u32 amd_certs_len;
1933278f064eSEduardo Habkost 	__u64 session_uaddr;
1934278f064eSEduardo Habkost 	__u32 session_len;
1935278f064eSEduardo Habkost };
1936278f064eSEduardo Habkost 
1937278f064eSEduardo Habkost struct kvm_sev_send_update_data {
1938278f064eSEduardo Habkost 	__u64 hdr_uaddr;
1939278f064eSEduardo Habkost 	__u32 hdr_len;
1940278f064eSEduardo Habkost 	__u64 guest_uaddr;
1941278f064eSEduardo Habkost 	__u32 guest_len;
1942278f064eSEduardo Habkost 	__u64 trans_uaddr;
1943278f064eSEduardo Habkost 	__u32 trans_len;
1944278f064eSEduardo Habkost };
1945278f064eSEduardo Habkost 
1946278f064eSEduardo Habkost struct kvm_sev_receive_start {
1947278f064eSEduardo Habkost 	__u32 handle;
1948278f064eSEduardo Habkost 	__u32 policy;
1949278f064eSEduardo Habkost 	__u64 pdh_uaddr;
1950278f064eSEduardo Habkost 	__u32 pdh_len;
1951278f064eSEduardo Habkost 	__u64 session_uaddr;
1952278f064eSEduardo Habkost 	__u32 session_len;
1953278f064eSEduardo Habkost };
1954278f064eSEduardo Habkost 
1955278f064eSEduardo Habkost struct kvm_sev_receive_update_data {
1956278f064eSEduardo Habkost 	__u64 hdr_uaddr;
1957278f064eSEduardo Habkost 	__u32 hdr_len;
1958278f064eSEduardo Habkost 	__u64 guest_uaddr;
1959278f064eSEduardo Habkost 	__u32 guest_len;
1960278f064eSEduardo Habkost 	__u64 trans_uaddr;
1961278f064eSEduardo Habkost 	__u32 trans_len;
1962278f064eSEduardo Habkost };
1963278f064eSEduardo Habkost 
196451b24e34SJan Kiszka #define KVM_DEV_ASSIGN_ENABLE_IOMMU	(1 << 0)
19659ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_PCI_2_3		(1 << 1)
19669ab2195dSMarcelo Tosatti #define KVM_DEV_ASSIGN_MASK_INTX	(1 << 2)
196751b24e34SJan Kiszka 
196851b24e34SJan Kiszka struct kvm_assigned_pci_dev {
196951b24e34SJan Kiszka 	__u32 assigned_dev_id;
197051b24e34SJan Kiszka 	__u32 busnr;
197151b24e34SJan Kiszka 	__u32 devfn;
197251b24e34SJan Kiszka 	__u32 flags;
197351b24e34SJan Kiszka 	__u32 segnr;
197451b24e34SJan Kiszka 	union {
197551b24e34SJan Kiszka 		__u32 reserved[11];
197651b24e34SJan Kiszka 	};
197751b24e34SJan Kiszka };
197851b24e34SJan Kiszka 
197951b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_INTX    (1 << 0)
198051b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSI     (1 << 1)
198151b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MSIX    (1 << 2)
198251b24e34SJan Kiszka 
198351b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_INTX   (1 << 8)
198451b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSI    (1 << 9)
198551b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MSIX   (1 << 10)
198651b24e34SJan Kiszka 
198751b24e34SJan Kiszka #define KVM_DEV_IRQ_HOST_MASK	 0x00ff
198851b24e34SJan Kiszka #define KVM_DEV_IRQ_GUEST_MASK   0xff00
198951b24e34SJan Kiszka 
199051b24e34SJan Kiszka struct kvm_assigned_irq {
199151b24e34SJan Kiszka 	__u32 assigned_dev_id;
19927c6da3deSAlexander Graf 	__u32 host_irq; /* ignored (legacy field) */
199351b24e34SJan Kiszka 	__u32 guest_irq;
199451b24e34SJan Kiszka 	__u32 flags;
199551b24e34SJan Kiszka 	union {
199651b24e34SJan Kiszka 		__u32 reserved[12];
199751b24e34SJan Kiszka 	};
199851b24e34SJan Kiszka };
199951b24e34SJan Kiszka 
200051b24e34SJan Kiszka struct kvm_assigned_msix_nr {
200151b24e34SJan Kiszka 	__u32 assigned_dev_id;
200251b24e34SJan Kiszka 	__u16 entry_nr;
200351b24e34SJan Kiszka 	__u16 padding;
200451b24e34SJan Kiszka };
200551b24e34SJan Kiszka 
200651b24e34SJan Kiszka #define KVM_MAX_MSIX_PER_DEV		256
200751b24e34SJan Kiszka struct kvm_assigned_msix_entry {
200851b24e34SJan Kiszka 	__u32 assigned_dev_id;
200951b24e34SJan Kiszka 	__u32 gsi;
201051b24e34SJan Kiszka 	__u16 entry; /* The index of entry in the MSI-X table */
201151b24e34SJan Kiszka 	__u16 padding[3];
201251b24e34SJan Kiszka };
201351b24e34SJan Kiszka 
2014dbdfea92SCornelia Huck #define KVM_X2APIC_API_USE_32BIT_IDS            (1ULL << 0)
2015dbdfea92SCornelia Huck #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK  (1ULL << 1)
2016dbdfea92SCornelia Huck 
201774c98e20SCornelia Huck /* Available with KVM_CAP_ARM_USER_IRQ */
201874c98e20SCornelia Huck 
201974c98e20SCornelia Huck /* Bits for run->s.regs.device_irq_level */
202074c98e20SCornelia Huck #define KVM_ARM_DEV_EL1_VTIMER		(1 << 0)
202174c98e20SCornelia Huck #define KVM_ARM_DEV_EL1_PTIMER		(1 << 1)
202274c98e20SCornelia Huck #define KVM_ARM_DEV_PMU			(1 << 2)
202374c98e20SCornelia Huck 
202465a6d8ddSPeter Maydell struct kvm_hyperv_eventfd {
202565a6d8ddSPeter Maydell 	__u32 conn_id;
202665a6d8ddSPeter Maydell 	__s32 fd;
202765a6d8ddSPeter Maydell 	__u32 flags;
202865a6d8ddSPeter Maydell 	__u32 padding[3];
202965a6d8ddSPeter Maydell };
203065a6d8ddSPeter Maydell 
203165a6d8ddSPeter Maydell #define KVM_HYPERV_CONN_ID_MASK		0x00ffffff
203265a6d8ddSPeter Maydell #define KVM_HYPERV_EVENTFD_DEASSIGN	(1 << 0)
203365a6d8ddSPeter Maydell 
2034dc6f8d45SCornelia Huck #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE    (1 << 0)
2035dc6f8d45SCornelia Huck #define KVM_DIRTY_LOG_INITIALLY_SET            (1 << 1)
2036dc6f8d45SCornelia Huck 
2037b3c818a4SEric Farman /*
2038b3c818a4SEric Farman  * Arch needs to define the macro after implementing the dirty ring
2039b3c818a4SEric Farman  * feature.  KVM_DIRTY_LOG_PAGE_OFFSET should be defined as the
2040b3c818a4SEric Farman  * starting page offset of the dirty ring structures.
2041b3c818a4SEric Farman  */
2042b3c818a4SEric Farman #ifndef KVM_DIRTY_LOG_PAGE_OFFSET
2043b3c818a4SEric Farman #define KVM_DIRTY_LOG_PAGE_OFFSET 0
2044b3c818a4SEric Farman #endif
2045b3c818a4SEric Farman 
2046b3c818a4SEric Farman /*
2047b3c818a4SEric Farman  * KVM dirty GFN flags, defined as:
2048b3c818a4SEric Farman  *
2049b3c818a4SEric Farman  * |---------------+---------------+--------------|
2050b3c818a4SEric Farman  * | bit 1 (reset) | bit 0 (dirty) | Status       |
2051b3c818a4SEric Farman  * |---------------+---------------+--------------|
2052b3c818a4SEric Farman  * |             0 |             0 | Invalid GFN  |
2053b3c818a4SEric Farman  * |             0 |             1 | Dirty GFN    |
2054b3c818a4SEric Farman  * |             1 |             X | GFN to reset |
2055b3c818a4SEric Farman  * |---------------+---------------+--------------|
2056b3c818a4SEric Farman  *
2057b3c818a4SEric Farman  * Lifecycle of a dirty GFN goes like:
2058b3c818a4SEric Farman  *
2059b3c818a4SEric Farman  *      dirtied         harvested        reset
2060b3c818a4SEric Farman  * 00 -----------> 01 -------------> 1X -------+
2061b3c818a4SEric Farman  *  ^                                          |
2062b3c818a4SEric Farman  *  |                                          |
2063b3c818a4SEric Farman  *  +------------------------------------------+
2064b3c818a4SEric Farman  *
2065b3c818a4SEric Farman  * The userspace program is only responsible for the 01->1X state
2066b3c818a4SEric Farman  * conversion after harvesting an entry.  Also, it must not skip any
2067b3c818a4SEric Farman  * dirty bits, so that dirty bits are always harvested in sequence.
2068b3c818a4SEric Farman  */
2069278f064eSEduardo Habkost #define KVM_DIRTY_GFN_F_DIRTY           _BITUL(0)
2070278f064eSEduardo Habkost #define KVM_DIRTY_GFN_F_RESET           _BITUL(1)
2071b3c818a4SEric Farman #define KVM_DIRTY_GFN_F_MASK            0x3
2072b3c818a4SEric Farman 
2073b3c818a4SEric Farman /*
2074b3c818a4SEric Farman  * KVM dirty rings should be mapped at KVM_DIRTY_LOG_PAGE_OFFSET of
2075b3c818a4SEric Farman  * per-vcpu mmaped regions as an array of struct kvm_dirty_gfn.  The
2076b3c818a4SEric Farman  * size of the gfn buffer is decided by the first argument when
2077b3c818a4SEric Farman  * enabling KVM_CAP_DIRTY_LOG_RING.
2078b3c818a4SEric Farman  */
2079b3c818a4SEric Farman struct kvm_dirty_gfn {
2080b3c818a4SEric Farman 	__u32 flags;
2081b3c818a4SEric Farman 	__u32 slot;
2082b3c818a4SEric Farman 	__u64 offset;
2083b3c818a4SEric Farman };
2084b3c818a4SEric Farman 
2085278f064eSEduardo Habkost #define KVM_BUS_LOCK_DETECTION_OFF             (1 << 0)
2086278f064eSEduardo Habkost #define KVM_BUS_LOCK_DETECTION_EXIT            (1 << 1)
2087278f064eSEduardo Habkost 
2088e4082063SAlex Williamson #define KVM_PMU_CAP_DISABLE                    (1 << 0)
2089e4082063SAlex Williamson 
2090327d4b7fSBharata B Rao /**
2091327d4b7fSBharata B Rao  * struct kvm_stats_header - Header of per vm/vcpu binary statistics data.
2092327d4b7fSBharata B Rao  * @flags: Some extra information for header, always 0 for now.
2093327d4b7fSBharata B Rao  * @name_size: The size in bytes of the memory which contains statistics
2094327d4b7fSBharata B Rao  *             name string including trailing '\0'. The memory is allocated
2095327d4b7fSBharata B Rao  *             at the send of statistics descriptor.
2096327d4b7fSBharata B Rao  * @num_desc: The number of statistics the vm or vcpu has.
2097327d4b7fSBharata B Rao  * @id_offset: The offset of the vm/vcpu stats' id string in the file pointed
2098327d4b7fSBharata B Rao  *             by vm/vcpu stats fd.
2099327d4b7fSBharata B Rao  * @desc_offset: The offset of the vm/vcpu stats' descriptor block in the file
2100327d4b7fSBharata B Rao  *               pointd by vm/vcpu stats fd.
2101327d4b7fSBharata B Rao  * @data_offset: The offset of the vm/vcpu stats' data block in the file
2102327d4b7fSBharata B Rao  *               pointed by vm/vcpu stats fd.
2103327d4b7fSBharata B Rao  *
2104327d4b7fSBharata B Rao  * This is the header userspace needs to read from stats fd before any other
2105327d4b7fSBharata B Rao  * readings. It is used by userspace to discover all the information about the
2106327d4b7fSBharata B Rao  * vm/vcpu's binary statistics.
2107327d4b7fSBharata B Rao  * Userspace reads this header from the start of the vm/vcpu's stats fd.
2108327d4b7fSBharata B Rao  */
2109327d4b7fSBharata B Rao struct kvm_stats_header {
2110327d4b7fSBharata B Rao 	__u32 flags;
2111327d4b7fSBharata B Rao 	__u32 name_size;
2112327d4b7fSBharata B Rao 	__u32 num_desc;
2113327d4b7fSBharata B Rao 	__u32 id_offset;
2114327d4b7fSBharata B Rao 	__u32 desc_offset;
2115327d4b7fSBharata B Rao 	__u32 data_offset;
2116327d4b7fSBharata B Rao };
2117327d4b7fSBharata B Rao 
2118327d4b7fSBharata B Rao #define KVM_STATS_TYPE_SHIFT		0
2119327d4b7fSBharata B Rao #define KVM_STATS_TYPE_MASK		(0xF << KVM_STATS_TYPE_SHIFT)
2120327d4b7fSBharata B Rao #define KVM_STATS_TYPE_CUMULATIVE	(0x0 << KVM_STATS_TYPE_SHIFT)
2121327d4b7fSBharata B Rao #define KVM_STATS_TYPE_INSTANT		(0x1 << KVM_STATS_TYPE_SHIFT)
2122327d4b7fSBharata B Rao #define KVM_STATS_TYPE_PEAK		(0x2 << KVM_STATS_TYPE_SHIFT)
212343709a0cSPaolo Bonzini #define KVM_STATS_TYPE_LINEAR_HIST	(0x3 << KVM_STATS_TYPE_SHIFT)
212443709a0cSPaolo Bonzini #define KVM_STATS_TYPE_LOG_HIST		(0x4 << KVM_STATS_TYPE_SHIFT)
212543709a0cSPaolo Bonzini #define KVM_STATS_TYPE_MAX		KVM_STATS_TYPE_LOG_HIST
2126327d4b7fSBharata B Rao 
2127327d4b7fSBharata B Rao #define KVM_STATS_UNIT_SHIFT		4
2128327d4b7fSBharata B Rao #define KVM_STATS_UNIT_MASK		(0xF << KVM_STATS_UNIT_SHIFT)
2129327d4b7fSBharata B Rao #define KVM_STATS_UNIT_NONE		(0x0 << KVM_STATS_UNIT_SHIFT)
2130327d4b7fSBharata B Rao #define KVM_STATS_UNIT_BYTES		(0x1 << KVM_STATS_UNIT_SHIFT)
2131327d4b7fSBharata B Rao #define KVM_STATS_UNIT_SECONDS		(0x2 << KVM_STATS_UNIT_SHIFT)
2132327d4b7fSBharata B Rao #define KVM_STATS_UNIT_CYCLES		(0x3 << KVM_STATS_UNIT_SHIFT)
2133105bb7cdSPaolo Bonzini #define KVM_STATS_UNIT_BOOLEAN		(0x4 << KVM_STATS_UNIT_SHIFT)
2134d525f73fSChenyi Qiang #define KVM_STATS_UNIT_MAX		KVM_STATS_UNIT_BOOLEAN
2135327d4b7fSBharata B Rao 
2136327d4b7fSBharata B Rao #define KVM_STATS_BASE_SHIFT		8
2137327d4b7fSBharata B Rao #define KVM_STATS_BASE_MASK		(0xF << KVM_STATS_BASE_SHIFT)
2138327d4b7fSBharata B Rao #define KVM_STATS_BASE_POW10		(0x0 << KVM_STATS_BASE_SHIFT)
2139327d4b7fSBharata B Rao #define KVM_STATS_BASE_POW2		(0x1 << KVM_STATS_BASE_SHIFT)
2140327d4b7fSBharata B Rao #define KVM_STATS_BASE_MAX		KVM_STATS_BASE_POW2
2141327d4b7fSBharata B Rao 
2142327d4b7fSBharata B Rao /**
2143327d4b7fSBharata B Rao  * struct kvm_stats_desc - Descriptor of a KVM statistics.
2144327d4b7fSBharata B Rao  * @flags: Annotations of the stats, like type, unit, etc.
2145327d4b7fSBharata B Rao  * @exponent: Used together with @flags to determine the unit.
2146327d4b7fSBharata B Rao  * @size: The number of data items for this stats.
2147327d4b7fSBharata B Rao  *        Every data item is of type __u64.
2148327d4b7fSBharata B Rao  * @offset: The offset of the stats to the start of stat structure in
214943709a0cSPaolo Bonzini  *          structure kvm or kvm_vcpu.
215043709a0cSPaolo Bonzini  * @bucket_size: A parameter value used for histogram stats. It is only used
215143709a0cSPaolo Bonzini  *		for linear histogram stats, specifying the size of the bucket;
2152327d4b7fSBharata B Rao  * @name: The name string for the stats. Its size is indicated by the
2153327d4b7fSBharata B Rao  *        &kvm_stats_header->name_size.
2154327d4b7fSBharata B Rao  */
2155327d4b7fSBharata B Rao struct kvm_stats_desc {
2156327d4b7fSBharata B Rao 	__u32 flags;
2157327d4b7fSBharata B Rao 	__s16 exponent;
2158327d4b7fSBharata B Rao 	__u16 size;
2159327d4b7fSBharata B Rao 	__u32 offset;
216043709a0cSPaolo Bonzini 	__u32 bucket_size;
2161327d4b7fSBharata B Rao 	char name[];
2162327d4b7fSBharata B Rao };
2163327d4b7fSBharata B Rao 
2164327d4b7fSBharata B Rao #define KVM_GET_STATS_FD  _IO(KVMIO,  0xce)
2165327d4b7fSBharata B Rao 
21661ea5208fSPaolo Bonzini /* Available with KVM_CAP_XSAVE2 */
21671ea5208fSPaolo Bonzini #define KVM_GET_XSAVE2		  _IOR(KVMIO,  0xcf, struct kvm_xsave)
21681ea5208fSPaolo Bonzini 
2169d525f73fSChenyi Qiang /* Available with KVM_CAP_S390_PROTECTED_DUMP */
2170d525f73fSChenyi Qiang #define KVM_S390_PV_CPU_COMMAND	_IOWR(KVMIO, 0xd0, struct kvm_pv_cmd)
2171d525f73fSChenyi Qiang 
2172d525f73fSChenyi Qiang /* Available with KVM_CAP_X86_NOTIFY_VMEXIT */
2173d525f73fSChenyi Qiang #define KVM_X86_NOTIFY_VMEXIT_ENABLED		(1ULL << 0)
2174d525f73fSChenyi Qiang #define KVM_X86_NOTIFY_VMEXIT_USER		(1ULL << 1)
2175d525f73fSChenyi Qiang 
2176d525f73fSChenyi Qiang /* Available with KVM_CAP_S390_ZPCI_OP */
2177d525f73fSChenyi Qiang #define KVM_S390_ZPCI_OP         _IOW(KVMIO,  0xd1, struct kvm_s390_zpci_op)
2178d525f73fSChenyi Qiang 
2179d525f73fSChenyi Qiang struct kvm_s390_zpci_op {
2180d525f73fSChenyi Qiang 	/* in */
2181d525f73fSChenyi Qiang 	__u32 fh;               /* target device */
2182d525f73fSChenyi Qiang 	__u8  op;               /* operation to perform */
2183d525f73fSChenyi Qiang 	__u8  pad[3];
2184d525f73fSChenyi Qiang 	union {
2185d525f73fSChenyi Qiang 		/* for KVM_S390_ZPCIOP_REG_AEN */
2186d525f73fSChenyi Qiang 		struct {
2187d525f73fSChenyi Qiang 			__u64 ibv;      /* Guest addr of interrupt bit vector */
2188d525f73fSChenyi Qiang 			__u64 sb;       /* Guest addr of summary bit */
2189d525f73fSChenyi Qiang 			__u32 flags;
2190d525f73fSChenyi Qiang 			__u32 noi;      /* Number of interrupts */
2191d525f73fSChenyi Qiang 			__u8 isc;       /* Guest interrupt subclass */
2192d525f73fSChenyi Qiang 			__u8 sbo;       /* Offset of guest summary bit vector */
2193d525f73fSChenyi Qiang 			__u16 pad;
2194d525f73fSChenyi Qiang 		} reg_aen;
2195d525f73fSChenyi Qiang 		__u64 reserved[8];
2196d525f73fSChenyi Qiang 	} u;
2197d525f73fSChenyi Qiang };
2198d525f73fSChenyi Qiang 
2199d525f73fSChenyi Qiang /* types for kvm_s390_zpci_op->op */
2200d525f73fSChenyi Qiang #define KVM_S390_ZPCIOP_REG_AEN                0
2201d525f73fSChenyi Qiang #define KVM_S390_ZPCIOP_DEREG_AEN      1
2202d525f73fSChenyi Qiang 
2203d525f73fSChenyi Qiang /* flags for kvm_s390_zpci_op->u.reg_aen.flags */
2204d525f73fSChenyi Qiang #define KVM_S390_ZPCIOP_REGAEN_HOST    (1 << 0)
2205d525f73fSChenyi Qiang 
2206*6a02465fSDaniel Henrique Barboza /* Available with KVM_CAP_MEMORY_ATTRIBUTES */
2207*6a02465fSDaniel Henrique Barboza #define KVM_SET_MEMORY_ATTRIBUTES              _IOW(KVMIO,  0xd2, struct kvm_memory_attributes)
2208*6a02465fSDaniel Henrique Barboza 
2209*6a02465fSDaniel Henrique Barboza struct kvm_memory_attributes {
2210*6a02465fSDaniel Henrique Barboza 	__u64 address;
2211*6a02465fSDaniel Henrique Barboza 	__u64 size;
2212*6a02465fSDaniel Henrique Barboza 	__u64 attributes;
2213*6a02465fSDaniel Henrique Barboza 	__u64 flags;
2214*6a02465fSDaniel Henrique Barboza };
2215*6a02465fSDaniel Henrique Barboza 
2216*6a02465fSDaniel Henrique Barboza #define KVM_MEMORY_ATTRIBUTE_PRIVATE           (1ULL << 3)
2217*6a02465fSDaniel Henrique Barboza 
2218*6a02465fSDaniel Henrique Barboza #define KVM_CREATE_GUEST_MEMFD	_IOWR(KVMIO,  0xd4, struct kvm_create_guest_memfd)
2219*6a02465fSDaniel Henrique Barboza 
2220*6a02465fSDaniel Henrique Barboza struct kvm_create_guest_memfd {
2221*6a02465fSDaniel Henrique Barboza 	__u64 size;
2222*6a02465fSDaniel Henrique Barboza 	__u64 flags;
2223*6a02465fSDaniel Henrique Barboza 	__u64 reserved[6];
2224*6a02465fSDaniel Henrique Barboza };
2225*6a02465fSDaniel Henrique Barboza 
222651b24e34SJan Kiszka #endif /* __LINUX_KVM_H */
2227