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