1 /****************************************************************************
2  ****************************************************************************
3  ***
4  ***   This header was automatically generated from a Linux kernel header
5  ***   of the same name, to make information necessary for userspace to
6  ***   call into the kernel available to libc.  It contains only constants,
7  ***   structures, and macros generated from the original header, and thus,
8  ***   contains no copyrightable information.
9  ***
10  ***   To edit the content of this header, modify the corresponding
11  ***   source file (e.g. under external/kernel-headers/original/) then
12  ***   run bionic/libc/kernel/tools/update_all.py
13  ***
14  ***   Any manual change here will be lost the next time this script will
15  ***   be run. You've been warned!
16  ***
17  ****************************************************************************
18  ****************************************************************************/
19 #ifndef __LINUX_KVM_H
20 #define __LINUX_KVM_H
21 #include <linux/types.h>
22 #include <linux/compiler.h>
23 #include <linux/ioctl.h>
24 #include <asm/kvm.h>
25 #define KVM_API_VERSION 12
26 #define KVM_TRC_SHIFT 16
27 #define KVM_TRC_ENTRYEXIT (1 << KVM_TRC_SHIFT)
28 #define KVM_TRC_HANDLER (1 << (KVM_TRC_SHIFT + 1))
29 #define KVM_TRC_VMENTRY (KVM_TRC_ENTRYEXIT + 0x01)
30 #define KVM_TRC_VMEXIT (KVM_TRC_ENTRYEXIT + 0x02)
31 #define KVM_TRC_PAGE_FAULT (KVM_TRC_HANDLER + 0x01)
32 #define KVM_TRC_HEAD_SIZE 12
33 #define KVM_TRC_CYCLE_SIZE 8
34 #define KVM_TRC_EXTRA_MAX 7
35 #define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02)
36 #define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03)
37 #define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04)
38 #define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05)
39 #define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06)
40 #define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07)
41 #define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08)
42 #define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09)
43 #define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A)
44 #define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B)
45 #define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C)
46 #define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D)
47 #define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E)
48 #define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F)
49 #define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10)
50 #define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11)
51 #define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12)
52 #define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13)
53 #define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14)
54 #define KVM_TRC_TDP_FAULT (KVM_TRC_HANDLER + 0x15)
55 #define KVM_TRC_GTLB_WRITE (KVM_TRC_HANDLER + 0x16)
56 #define KVM_TRC_STLB_WRITE (KVM_TRC_HANDLER + 0x17)
57 #define KVM_TRC_STLB_INVAL (KVM_TRC_HANDLER + 0x18)
58 #define KVM_TRC_PPC_INSTR (KVM_TRC_HANDLER + 0x19)
59 struct kvm_user_trace_setup {
60   __u32 buf_size;
61   __u32 buf_nr;
62 };
63 #define __KVM_DEPRECATED_MAIN_W_0x06 _IOW(KVMIO, 0x06, struct kvm_user_trace_setup)
64 #define __KVM_DEPRECATED_MAIN_0x07 _IO(KVMIO, 0x07)
65 #define __KVM_DEPRECATED_MAIN_0x08 _IO(KVMIO, 0x08)
66 #define __KVM_DEPRECATED_VM_R_0x70 _IOR(KVMIO, 0x70, struct kvm_assigned_irq)
67 struct kvm_breakpoint {
68   __u32 enabled;
69   __u32 padding;
70   __u64 address;
71 };
72 struct kvm_debug_guest {
73   __u32 enabled;
74   __u32 pad;
75   struct kvm_breakpoint breakpoints[4];
76   __u32 singlestep;
77 };
78 #define __KVM_DEPRECATED_VCPU_W_0x87 _IOW(KVMIO, 0x87, struct kvm_debug_guest)
79 struct kvm_memory_region {
80   __u32 slot;
81   __u32 flags;
82   __u64 guest_phys_addr;
83   __u64 memory_size;
84 };
85 struct kvm_userspace_memory_region {
86   __u32 slot;
87   __u32 flags;
88   __u64 guest_phys_addr;
89   __u64 memory_size;
90   __u64 userspace_addr;
91 };
92 #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0)
93 #define KVM_MEM_READONLY (1UL << 1)
94 struct kvm_irq_level {
95   union {
96     __u32 irq;
97     __s32 status;
98   };
99   __u32 level;
100 };
101 struct kvm_irqchip {
102   __u32 chip_id;
103   __u32 pad;
104   union {
105     char dummy[512];
106 #ifdef __KVM_HAVE_PIT
107     struct kvm_pic_state pic;
108 #endif
109 #ifdef __KVM_HAVE_IOAPIC
110     struct kvm_ioapic_state ioapic;
111 #endif
112   } chip;
113 };
114 struct kvm_pit_config {
115   __u32 flags;
116   __u32 pad[15];
117 };
118 #define KVM_PIT_SPEAKER_DUMMY 1
119 struct kvm_s390_skeys {
120   __u64 start_gfn;
121   __u64 count;
122   __u64 skeydata_addr;
123   __u32 flags;
124   __u32 reserved[9];
125 };
126 #define KVM_S390_CMMA_PEEK (1 << 0)
127 struct kvm_s390_cmma_log {
128   __u64 start_gfn;
129   __u32 count;
130   __u32 flags;
131   union {
132     __u64 remaining;
133     __u64 mask;
134   };
135   __u64 values;
136 };
137 struct kvm_hyperv_exit {
138 #define KVM_EXIT_HYPERV_SYNIC 1
139 #define KVM_EXIT_HYPERV_HCALL 2
140 #define KVM_EXIT_HYPERV_SYNDBG 3
141   __u32 type;
142   __u32 pad1;
143   union {
144     struct {
145       __u32 msr;
146       __u32 pad2;
147       __u64 control;
148       __u64 evt_page;
149       __u64 msg_page;
150     } synic;
151     struct {
152       __u64 input;
153       __u64 result;
154       __u64 params[2];
155     } hcall;
156     struct {
157       __u32 msr;
158       __u32 pad2;
159       __u64 control;
160       __u64 status;
161       __u64 send_page;
162       __u64 recv_page;
163       __u64 pending_page;
164     } syndbg;
165   } u;
166 };
167 struct kvm_xen_exit {
168 #define KVM_EXIT_XEN_HCALL 1
169   __u32 type;
170   union {
171     struct {
172       __u32 longmode;
173       __u32 cpl;
174       __u64 input;
175       __u64 result;
176       __u64 params[6];
177     } hcall;
178   } u;
179 };
180 #define KVM_S390_GET_SKEYS_NONE 1
181 #define KVM_S390_SKEYS_MAX 1048576
182 #define KVM_EXIT_UNKNOWN 0
183 #define KVM_EXIT_EXCEPTION 1
184 #define KVM_EXIT_IO 2
185 #define KVM_EXIT_HYPERCALL 3
186 #define KVM_EXIT_DEBUG 4
187 #define KVM_EXIT_HLT 5
188 #define KVM_EXIT_MMIO 6
189 #define KVM_EXIT_IRQ_WINDOW_OPEN 7
190 #define KVM_EXIT_SHUTDOWN 8
191 #define KVM_EXIT_FAIL_ENTRY 9
192 #define KVM_EXIT_INTR 10
193 #define KVM_EXIT_SET_TPR 11
194 #define KVM_EXIT_TPR_ACCESS 12
195 #define KVM_EXIT_S390_SIEIC 13
196 #define KVM_EXIT_S390_RESET 14
197 #define KVM_EXIT_DCR 15
198 #define KVM_EXIT_NMI 16
199 #define KVM_EXIT_INTERNAL_ERROR 17
200 #define KVM_EXIT_OSI 18
201 #define KVM_EXIT_PAPR_HCALL 19
202 #define KVM_EXIT_S390_UCONTROL 20
203 #define KVM_EXIT_WATCHDOG 21
204 #define KVM_EXIT_S390_TSCH 22
205 #define KVM_EXIT_EPR 23
206 #define KVM_EXIT_SYSTEM_EVENT 24
207 #define KVM_EXIT_S390_STSI 25
208 #define KVM_EXIT_IOAPIC_EOI 26
209 #define KVM_EXIT_HYPERV 27
210 #define KVM_EXIT_ARM_NISV 28
211 #define KVM_EXIT_X86_RDMSR 29
212 #define KVM_EXIT_X86_WRMSR 30
213 #define KVM_EXIT_DIRTY_RING_FULL 31
214 #define KVM_EXIT_AP_RESET_HOLD 32
215 #define KVM_EXIT_X86_BUS_LOCK 33
216 #define KVM_EXIT_XEN 34
217 #define KVM_INTERNAL_ERROR_EMULATION 1
218 #define KVM_INTERNAL_ERROR_SIMUL_EX 2
219 #define KVM_INTERNAL_ERROR_DELIVERY_EV 3
220 #define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON 4
221 struct kvm_run {
222   __u8 request_interrupt_window;
223   __u8 immediate_exit;
224   __u8 padding1[6];
225   __u32 exit_reason;
226   __u8 ready_for_interrupt_injection;
227   __u8 if_flag;
228   __u16 flags;
229   __u64 cr8;
230   __u64 apic_base;
231 #ifdef __KVM_S390
232   __u64 psw_mask;
233   __u64 psw_addr;
234 #endif
235   union {
236     struct {
237       __u64 hardware_exit_reason;
238     } hw;
239     struct {
240       __u64 hardware_entry_failure_reason;
241       __u32 cpu;
242     } fail_entry;
243     struct {
244       __u32 exception;
245       __u32 error_code;
246     } ex;
247     struct {
248 #define KVM_EXIT_IO_IN 0
249 #define KVM_EXIT_IO_OUT 1
250       __u8 direction;
251       __u8 size;
252       __u16 port;
253       __u32 count;
254       __u64 data_offset;
255     } io;
256     struct {
257       struct kvm_debug_exit_arch arch;
258     } debug;
259     struct {
260       __u64 phys_addr;
261       __u8 data[8];
262       __u32 len;
263       __u8 is_write;
264     } mmio;
265     struct {
266       __u64 nr;
267       __u64 args[6];
268       __u64 ret;
269       __u32 longmode;
270       __u32 pad;
271     } hypercall;
272     struct {
273       __u64 rip;
274       __u32 is_write;
275       __u32 pad;
276     } tpr_access;
277     struct {
278       __u8 icptcode;
279       __u16 ipa;
280       __u32 ipb;
281     } s390_sieic;
282 #define KVM_S390_RESET_POR 1
283 #define KVM_S390_RESET_CLEAR 2
284 #define KVM_S390_RESET_SUBSYSTEM 4
285 #define KVM_S390_RESET_CPU_INIT 8
286 #define KVM_S390_RESET_IPL 16
287     __u64 s390_reset_flags;
288     struct {
289       __u64 trans_exc_code;
290       __u32 pgm_code;
291     } s390_ucontrol;
292     struct {
293       __u32 dcrn;
294       __u32 data;
295       __u8 is_write;
296     } dcr;
297     struct {
298       __u32 suberror;
299       __u32 ndata;
300       __u64 data[16];
301     } internal;
302     struct {
303       __u64 gprs[32];
304     } osi;
305     struct {
306       __u64 nr;
307       __u64 ret;
308       __u64 args[9];
309     } papr_hcall;
310     struct {
311       __u16 subchannel_id;
312       __u16 subchannel_nr;
313       __u32 io_int_parm;
314       __u32 io_int_word;
315       __u32 ipb;
316       __u8 dequeued;
317     } s390_tsch;
318     struct {
319       __u32 epr;
320     } epr;
321     struct {
322 #define KVM_SYSTEM_EVENT_SHUTDOWN 1
323 #define KVM_SYSTEM_EVENT_RESET 2
324 #define KVM_SYSTEM_EVENT_CRASH 3
325       __u32 type;
326       __u64 flags;
327     } system_event;
328     struct {
329       __u64 addr;
330       __u8 ar;
331       __u8 reserved;
332       __u8 fc;
333       __u8 sel1;
334       __u16 sel2;
335     } s390_stsi;
336     struct {
337       __u8 vector;
338     } eoi;
339     struct kvm_hyperv_exit hyperv;
340     struct {
341       __u64 esr_iss;
342       __u64 fault_ipa;
343     } arm_nisv;
344     struct {
345       __u8 error;
346       __u8 pad[7];
347 #define KVM_MSR_EXIT_REASON_INVAL (1 << 0)
348 #define KVM_MSR_EXIT_REASON_UNKNOWN (1 << 1)
349 #define KVM_MSR_EXIT_REASON_FILTER (1 << 2)
350       __u32 reason;
351       __u32 index;
352       __u64 data;
353     } msr;
354     struct kvm_xen_exit xen;
355     char padding[256];
356   };
357 #define SYNC_REGS_SIZE_BYTES 2048
358   __u64 kvm_valid_regs;
359   __u64 kvm_dirty_regs;
360   union {
361     struct kvm_sync_regs regs;
362     char padding[SYNC_REGS_SIZE_BYTES];
363   } s;
364 };
365 struct kvm_coalesced_mmio_zone {
366   __u64 addr;
367   __u32 size;
368   union {
369     __u32 pad;
370     __u32 pio;
371   };
372 };
373 struct kvm_coalesced_mmio {
374   __u64 phys_addr;
375   __u32 len;
376   union {
377     __u32 pad;
378     __u32 pio;
379   };
380   __u8 data[8];
381 };
382 struct kvm_coalesced_mmio_ring {
383   __u32 first, last;
384   struct kvm_coalesced_mmio coalesced_mmio[0];
385 };
386 #define KVM_COALESCED_MMIO_MAX ((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / sizeof(struct kvm_coalesced_mmio))
387 struct kvm_translation {
388   __u64 linear_address;
389   __u64 physical_address;
390   __u8 valid;
391   __u8 writeable;
392   __u8 usermode;
393   __u8 pad[5];
394 };
395 struct kvm_s390_mem_op {
396   __u64 gaddr;
397   __u64 flags;
398   __u32 size;
399   __u32 op;
400   __u64 buf;
401   union {
402     __u8 ar;
403     __u32 sida_offset;
404     __u8 reserved[32];
405   };
406 };
407 #define KVM_S390_MEMOP_LOGICAL_READ 0
408 #define KVM_S390_MEMOP_LOGICAL_WRITE 1
409 #define KVM_S390_MEMOP_SIDA_READ 2
410 #define KVM_S390_MEMOP_SIDA_WRITE 3
411 #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0)
412 #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1)
413 struct kvm_interrupt {
414   __u32 irq;
415 };
416 struct kvm_dirty_log {
417   __u32 slot;
418   __u32 padding1;
419   union {
420     void __user * dirty_bitmap;
421     __u64 padding2;
422   };
423 };
424 struct kvm_clear_dirty_log {
425   __u32 slot;
426   __u32 num_pages;
427   __u64 first_page;
428   union {
429     void __user * dirty_bitmap;
430     __u64 padding2;
431   };
432 };
433 struct kvm_signal_mask {
434   __u32 len;
435   __u8 sigset[0];
436 };
437 struct kvm_tpr_access_ctl {
438   __u32 enabled;
439   __u32 flags;
440   __u32 reserved[8];
441 };
442 struct kvm_vapic_addr {
443   __u64 vapic_addr;
444 };
445 #define KVM_MP_STATE_RUNNABLE 0
446 #define KVM_MP_STATE_UNINITIALIZED 1
447 #define KVM_MP_STATE_INIT_RECEIVED 2
448 #define KVM_MP_STATE_HALTED 3
449 #define KVM_MP_STATE_SIPI_RECEIVED 4
450 #define KVM_MP_STATE_STOPPED 5
451 #define KVM_MP_STATE_CHECK_STOP 6
452 #define KVM_MP_STATE_OPERATING 7
453 #define KVM_MP_STATE_LOAD 8
454 #define KVM_MP_STATE_AP_RESET_HOLD 9
455 struct kvm_mp_state {
456   __u32 mp_state;
457 };
458 struct kvm_s390_psw {
459   __u64 mask;
460   __u64 addr;
461 };
462 #define KVM_S390_SIGP_STOP 0xfffe0000u
463 #define KVM_S390_PROGRAM_INT 0xfffe0001u
464 #define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u
465 #define KVM_S390_RESTART 0xfffe0003u
466 #define KVM_S390_INT_PFAULT_INIT 0xfffe0004u
467 #define KVM_S390_INT_PFAULT_DONE 0xfffe0005u
468 #define KVM_S390_MCHK 0xfffe1000u
469 #define KVM_S390_INT_CLOCK_COMP 0xffff1004u
470 #define KVM_S390_INT_CPU_TIMER 0xffff1005u
471 #define KVM_S390_INT_VIRTIO 0xffff2603u
472 #define KVM_S390_INT_SERVICE 0xffff2401u
473 #define KVM_S390_INT_EMERGENCY 0xffff1201u
474 #define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u
475 #define KVM_S390_INT_IO(ai,cssid,ssid,schid) (((schid)) | ((ssid) << 16) | ((cssid) << 18) | ((ai) << 26))
476 #define KVM_S390_INT_IO_MIN 0x00000000u
477 #define KVM_S390_INT_IO_MAX 0xfffdffffu
478 #define KVM_S390_INT_IO_AI_MASK 0x04000000u
479 struct kvm_s390_interrupt {
480   __u32 type;
481   __u32 parm;
482   __u64 parm64;
483 };
484 struct kvm_s390_io_info {
485   __u16 subchannel_id;
486   __u16 subchannel_nr;
487   __u32 io_int_parm;
488   __u32 io_int_word;
489 };
490 struct kvm_s390_ext_info {
491   __u32 ext_params;
492   __u32 pad;
493   __u64 ext_params2;
494 };
495 struct kvm_s390_pgm_info {
496   __u64 trans_exc_code;
497   __u64 mon_code;
498   __u64 per_address;
499   __u32 data_exc_code;
500   __u16 code;
501   __u16 mon_class_nr;
502   __u8 per_code;
503   __u8 per_atmid;
504   __u8 exc_access_id;
505   __u8 per_access_id;
506   __u8 op_access_id;
507 #define KVM_S390_PGM_FLAGS_ILC_VALID 0x01
508 #define KVM_S390_PGM_FLAGS_ILC_0 0x02
509 #define KVM_S390_PGM_FLAGS_ILC_1 0x04
510 #define KVM_S390_PGM_FLAGS_ILC_MASK 0x06
511 #define KVM_S390_PGM_FLAGS_NO_REWIND 0x08
512   __u8 flags;
513   __u8 pad[2];
514 };
515 struct kvm_s390_prefix_info {
516   __u32 address;
517 };
518 struct kvm_s390_extcall_info {
519   __u16 code;
520 };
521 struct kvm_s390_emerg_info {
522   __u16 code;
523 };
524 #define KVM_S390_STOP_FLAG_STORE_STATUS 0x01
525 struct kvm_s390_stop_info {
526   __u32 flags;
527 };
528 struct kvm_s390_mchk_info {
529   __u64 cr14;
530   __u64 mcic;
531   __u64 failing_storage_address;
532   __u32 ext_damage_code;
533   __u32 pad;
534   __u8 fixed_logout[16];
535 };
536 struct kvm_s390_irq {
537   __u64 type;
538   union {
539     struct kvm_s390_io_info io;
540     struct kvm_s390_ext_info ext;
541     struct kvm_s390_pgm_info pgm;
542     struct kvm_s390_emerg_info emerg;
543     struct kvm_s390_extcall_info extcall;
544     struct kvm_s390_prefix_info prefix;
545     struct kvm_s390_stop_info stop;
546     struct kvm_s390_mchk_info mchk;
547     char reserved[64];
548   } u;
549 };
550 struct kvm_s390_irq_state {
551   __u64 buf;
552   __u32 flags;
553   __u32 len;
554   __u32 reserved[4];
555 };
556 #define KVM_GUESTDBG_ENABLE 0x00000001
557 #define KVM_GUESTDBG_SINGLESTEP 0x00000002
558 struct kvm_guest_debug {
559   __u32 control;
560   __u32 pad;
561   struct kvm_guest_debug_arch arch;
562 };
563 enum {
564   kvm_ioeventfd_flag_nr_datamatch,
565   kvm_ioeventfd_flag_nr_pio,
566   kvm_ioeventfd_flag_nr_deassign,
567   kvm_ioeventfd_flag_nr_virtio_ccw_notify,
568   kvm_ioeventfd_flag_nr_fast_mmio,
569   kvm_ioeventfd_flag_nr_max,
570 };
571 #define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
572 #define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
573 #define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
574 #define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify)
575 #define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1)
576 struct kvm_ioeventfd {
577   __u64 datamatch;
578   __u64 addr;
579   __u32 len;
580   __s32 fd;
581   __u32 flags;
582   __u8 pad[36];
583 };
584 #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0)
585 #define KVM_X86_DISABLE_EXITS_HLT (1 << 1)
586 #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2)
587 #define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3)
588 #define KVM_X86_DISABLE_VALID_EXITS (KVM_X86_DISABLE_EXITS_MWAIT | KVM_X86_DISABLE_EXITS_HLT | KVM_X86_DISABLE_EXITS_PAUSE | KVM_X86_DISABLE_EXITS_CSTATE)
589 struct kvm_enable_cap {
590   __u32 cap;
591   __u32 flags;
592   __u64 args[4];
593   __u8 pad[64];
594 };
595 #define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1 << 0)
596 struct kvm_ppc_pvinfo {
597   __u32 flags;
598   __u32 hcall[4];
599   __u8 pad[108];
600 };
601 #define KVM_PPC_PAGE_SIZES_MAX_SZ 8
602 struct kvm_ppc_one_page_size {
603   __u32 page_shift;
604   __u32 pte_enc;
605 };
606 struct kvm_ppc_one_seg_page_size {
607   __u32 page_shift;
608   __u32 slb_enc;
609   struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ];
610 };
611 #define KVM_PPC_PAGE_SIZES_REAL 0x00000001
612 #define KVM_PPC_1T_SEGMENTS 0x00000002
613 #define KVM_PPC_NO_HASH 0x00000004
614 struct kvm_ppc_smmu_info {
615   __u64 flags;
616   __u32 slb_size;
617   __u16 data_keys;
618   __u16 instr_keys;
619   struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
620 };
621 struct kvm_ppc_resize_hpt {
622   __u64 flags;
623   __u32 shift;
624   __u32 pad;
625 };
626 #define KVMIO 0xAE
627 #define KVM_VM_S390_UCONTROL 1
628 #define KVM_VM_PPC_HV 1
629 #define KVM_VM_PPC_PR 2
630 #define KVM_VM_MIPS_AUTO 0
631 #define KVM_VM_MIPS_VZ 1
632 #define KVM_VM_MIPS_TE 2
633 #define KVM_S390_SIE_PAGE_OFFSET 1
634 #define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL
635 #define KVM_VM_TYPE_ARM_IPA_SIZE(x) ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK)
636 #define KVM_GET_API_VERSION _IO(KVMIO, 0x00)
637 #define KVM_CREATE_VM _IO(KVMIO, 0x01)
638 #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list)
639 #define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06)
640 #define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03)
641 #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04)
642 #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2)
643 #define KVM_TRACE_ENABLE __KVM_DEPRECATED_MAIN_W_0x06
644 #define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07
645 #define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08
646 #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2)
647 #define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_msr_list)
648 #define KVM_CAP_IRQCHIP 0
649 #define KVM_CAP_HLT 1
650 #define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2
651 #define KVM_CAP_USER_MEMORY 3
652 #define KVM_CAP_SET_TSS_ADDR 4
653 #define KVM_CAP_VAPIC 6
654 #define KVM_CAP_EXT_CPUID 7
655 #define KVM_CAP_CLOCKSOURCE 8
656 #define KVM_CAP_NR_VCPUS 9
657 #define KVM_CAP_NR_MEMSLOTS 10
658 #define KVM_CAP_PIT 11
659 #define KVM_CAP_NOP_IO_DELAY 12
660 #define KVM_CAP_PV_MMU 13
661 #define KVM_CAP_MP_STATE 14
662 #define KVM_CAP_COALESCED_MMIO 15
663 #define KVM_CAP_SYNC_MMU 16
664 #define KVM_CAP_IOMMU 18
665 #define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21
666 #define KVM_CAP_USER_NMI 22
667 #ifdef __KVM_HAVE_GUEST_DEBUG
668 #define KVM_CAP_SET_GUEST_DEBUG 23
669 #endif
670 #ifdef __KVM_HAVE_PIT
671 #define KVM_CAP_REINJECT_CONTROL 24
672 #endif
673 #define KVM_CAP_IRQ_ROUTING 25
674 #define KVM_CAP_IRQ_INJECT_STATUS 26
675 #define KVM_CAP_ASSIGN_DEV_IRQ 29
676 #define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30
677 #ifdef __KVM_HAVE_MCE
678 #define KVM_CAP_MCE 31
679 #endif
680 #define KVM_CAP_IRQFD 32
681 #ifdef __KVM_HAVE_PIT
682 #define KVM_CAP_PIT2 33
683 #endif
684 #define KVM_CAP_SET_BOOT_CPU_ID 34
685 #ifdef __KVM_HAVE_PIT_STATE2
686 #define KVM_CAP_PIT_STATE2 35
687 #endif
688 #define KVM_CAP_IOEVENTFD 36
689 #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37
690 #ifdef __KVM_HAVE_XEN_HVM
691 #define KVM_CAP_XEN_HVM 38
692 #endif
693 #define KVM_CAP_ADJUST_CLOCK 39
694 #define KVM_CAP_INTERNAL_ERROR_DATA 40
695 #ifdef __KVM_HAVE_VCPU_EVENTS
696 #define KVM_CAP_VCPU_EVENTS 41
697 #endif
698 #define KVM_CAP_S390_PSW 42
699 #define KVM_CAP_PPC_SEGSTATE 43
700 #define KVM_CAP_HYPERV 44
701 #define KVM_CAP_HYPERV_VAPIC 45
702 #define KVM_CAP_HYPERV_SPIN 46
703 #define KVM_CAP_PCI_SEGMENT 47
704 #define KVM_CAP_PPC_PAIRED_SINGLES 48
705 #define KVM_CAP_INTR_SHADOW 49
706 #ifdef __KVM_HAVE_DEBUGREGS
707 #define KVM_CAP_DEBUGREGS 50
708 #endif
709 #define KVM_CAP_X86_ROBUST_SINGLESTEP 51
710 #define KVM_CAP_PPC_OSI 52
711 #define KVM_CAP_PPC_UNSET_IRQ 53
712 #define KVM_CAP_ENABLE_CAP 54
713 #ifdef __KVM_HAVE_XSAVE
714 #define KVM_CAP_XSAVE 55
715 #endif
716 #ifdef __KVM_HAVE_XCRS
717 #define KVM_CAP_XCRS 56
718 #endif
719 #define KVM_CAP_PPC_GET_PVINFO 57
720 #define KVM_CAP_PPC_IRQ_LEVEL 58
721 #define KVM_CAP_ASYNC_PF 59
722 #define KVM_CAP_TSC_CONTROL 60
723 #define KVM_CAP_GET_TSC_KHZ 61
724 #define KVM_CAP_PPC_BOOKE_SREGS 62
725 #define KVM_CAP_SPAPR_TCE 63
726 #define KVM_CAP_PPC_SMT 64
727 #define KVM_CAP_PPC_RMA 65
728 #define KVM_CAP_MAX_VCPUS 66
729 #define KVM_CAP_PPC_HIOR 67
730 #define KVM_CAP_PPC_PAPR 68
731 #define KVM_CAP_SW_TLB 69
732 #define KVM_CAP_ONE_REG 70
733 #define KVM_CAP_S390_GMAP 71
734 #define KVM_CAP_TSC_DEADLINE_TIMER 72
735 #define KVM_CAP_S390_UCONTROL 73
736 #define KVM_CAP_SYNC_REGS 74
737 #define KVM_CAP_PCI_2_3 75
738 #define KVM_CAP_KVMCLOCK_CTRL 76
739 #define KVM_CAP_SIGNAL_MSI 77
740 #define KVM_CAP_PPC_GET_SMMU_INFO 78
741 #define KVM_CAP_S390_COW 79
742 #define KVM_CAP_PPC_ALLOC_HTAB 80
743 #define KVM_CAP_READONLY_MEM 81
744 #define KVM_CAP_IRQFD_RESAMPLE 82
745 #define KVM_CAP_PPC_BOOKE_WATCHDOG 83
746 #define KVM_CAP_PPC_HTAB_FD 84
747 #define KVM_CAP_S390_CSS_SUPPORT 85
748 #define KVM_CAP_PPC_EPR 86
749 #define KVM_CAP_ARM_PSCI 87
750 #define KVM_CAP_ARM_SET_DEVICE_ADDR 88
751 #define KVM_CAP_DEVICE_CTRL 89
752 #define KVM_CAP_IRQ_MPIC 90
753 #define KVM_CAP_PPC_RTAS 91
754 #define KVM_CAP_IRQ_XICS 92
755 #define KVM_CAP_ARM_EL1_32BIT 93
756 #define KVM_CAP_SPAPR_MULTITCE 94
757 #define KVM_CAP_EXT_EMUL_CPUID 95
758 #define KVM_CAP_HYPERV_TIME 96
759 #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97
760 #define KVM_CAP_ENABLE_CAP_VM 98
761 #define KVM_CAP_S390_IRQCHIP 99
762 #define KVM_CAP_IOEVENTFD_NO_LENGTH 100
763 #define KVM_CAP_VM_ATTRIBUTES 101
764 #define KVM_CAP_ARM_PSCI_0_2 102
765 #define KVM_CAP_PPC_FIXUP_HCALL 103
766 #define KVM_CAP_PPC_ENABLE_HCALL 104
767 #define KVM_CAP_CHECK_EXTENSION_VM 105
768 #define KVM_CAP_S390_USER_SIGP 106
769 #define KVM_CAP_S390_VECTOR_REGISTERS 107
770 #define KVM_CAP_S390_MEM_OP 108
771 #define KVM_CAP_S390_USER_STSI 109
772 #define KVM_CAP_S390_SKEYS 110
773 #define KVM_CAP_MIPS_FPU 111
774 #define KVM_CAP_MIPS_MSA 112
775 #define KVM_CAP_S390_INJECT_IRQ 113
776 #define KVM_CAP_S390_IRQ_STATE 114
777 #define KVM_CAP_PPC_HWRNG 115
778 #define KVM_CAP_DISABLE_QUIRKS 116
779 #define KVM_CAP_X86_SMM 117
780 #define KVM_CAP_MULTI_ADDRESS_SPACE 118
781 #define KVM_CAP_GUEST_DEBUG_HW_BPS 119
782 #define KVM_CAP_GUEST_DEBUG_HW_WPS 120
783 #define KVM_CAP_SPLIT_IRQCHIP 121
784 #define KVM_CAP_IOEVENTFD_ANY_LENGTH 122
785 #define KVM_CAP_HYPERV_SYNIC 123
786 #define KVM_CAP_S390_RI 124
787 #define KVM_CAP_SPAPR_TCE_64 125
788 #define KVM_CAP_ARM_PMU_V3 126
789 #define KVM_CAP_VCPU_ATTRIBUTES 127
790 #define KVM_CAP_MAX_VCPU_ID 128
791 #define KVM_CAP_X2APIC_API 129
792 #define KVM_CAP_S390_USER_INSTR0 130
793 #define KVM_CAP_MSI_DEVID 131
794 #define KVM_CAP_PPC_HTM 132
795 #define KVM_CAP_SPAPR_RESIZE_HPT 133
796 #define KVM_CAP_PPC_MMU_RADIX 134
797 #define KVM_CAP_PPC_MMU_HASH_V3 135
798 #define KVM_CAP_IMMEDIATE_EXIT 136
799 #define KVM_CAP_MIPS_VZ 137
800 #define KVM_CAP_MIPS_TE 138
801 #define KVM_CAP_MIPS_64BIT 139
802 #define KVM_CAP_S390_GS 140
803 #define KVM_CAP_S390_AIS 141
804 #define KVM_CAP_SPAPR_TCE_VFIO 142
805 #define KVM_CAP_X86_DISABLE_EXITS 143
806 #define KVM_CAP_ARM_USER_IRQ 144
807 #define KVM_CAP_S390_CMMA_MIGRATION 145
808 #define KVM_CAP_PPC_FWNMI 146
809 #define KVM_CAP_PPC_SMT_POSSIBLE 147
810 #define KVM_CAP_HYPERV_SYNIC2 148
811 #define KVM_CAP_HYPERV_VP_INDEX 149
812 #define KVM_CAP_S390_AIS_MIGRATION 150
813 #define KVM_CAP_PPC_GET_CPU_CHAR 151
814 #define KVM_CAP_S390_BPB 152
815 #define KVM_CAP_GET_MSR_FEATURES 153
816 #define KVM_CAP_HYPERV_EVENTFD 154
817 #define KVM_CAP_HYPERV_TLBFLUSH 155
818 #define KVM_CAP_S390_HPAGE_1M 156
819 #define KVM_CAP_NESTED_STATE 157
820 #define KVM_CAP_ARM_INJECT_SERROR_ESR 158
821 #define KVM_CAP_MSR_PLATFORM_INFO 159
822 #define KVM_CAP_PPC_NESTED_HV 160
823 #define KVM_CAP_HYPERV_SEND_IPI 161
824 #define KVM_CAP_COALESCED_PIO 162
825 #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163
826 #define KVM_CAP_EXCEPTION_PAYLOAD 164
827 #define KVM_CAP_ARM_VM_IPA_SIZE 165
828 #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166
829 #define KVM_CAP_HYPERV_CPUID 167
830 #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 168
831 #define KVM_CAP_PPC_IRQ_XIVE 169
832 #define KVM_CAP_ARM_SVE 170
833 #define KVM_CAP_ARM_PTRAUTH_ADDRESS 171
834 #define KVM_CAP_ARM_PTRAUTH_GENERIC 172
835 #define KVM_CAP_PMU_EVENT_FILTER 173
836 #define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174
837 #define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175
838 #define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 176
839 #define KVM_CAP_ARM_NISV_TO_USER 177
840 #define KVM_CAP_ARM_INJECT_EXT_DABT 178
841 #define KVM_CAP_S390_VCPU_RESETS 179
842 #define KVM_CAP_S390_PROTECTED 180
843 #define KVM_CAP_PPC_SECURE_GUEST 181
844 #define KVM_CAP_HALT_POLL 182
845 #define KVM_CAP_ASYNC_PF_INT 183
846 #define KVM_CAP_LAST_CPU 184
847 #define KVM_CAP_SMALLER_MAXPHYADDR 185
848 #define KVM_CAP_S390_DIAG318 186
849 #define KVM_CAP_STEAL_TIME 187
850 #define KVM_CAP_X86_USER_SPACE_MSR 188
851 #define KVM_CAP_X86_MSR_FILTER 189
852 #define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190
853 #define KVM_CAP_SYS_HYPERV_CPUID 191
854 #define KVM_CAP_DIRTY_LOG_RING 192
855 #define KVM_CAP_X86_BUS_LOCK_EXIT 193
856 #define KVM_CAP_PPC_DAWR1 194
857 #ifdef KVM_CAP_IRQ_ROUTING
858 struct kvm_irq_routing_irqchip {
859   __u32 irqchip;
860   __u32 pin;
861 };
862 struct kvm_irq_routing_msi {
863   __u32 address_lo;
864   __u32 address_hi;
865   __u32 data;
866   union {
867     __u32 pad;
868     __u32 devid;
869   };
870 };
871 struct kvm_irq_routing_s390_adapter {
872   __u64 ind_addr;
873   __u64 summary_addr;
874   __u64 ind_offset;
875   __u32 summary_offset;
876   __u32 adapter_id;
877 };
878 struct kvm_irq_routing_hv_sint {
879   __u32 vcpu;
880   __u32 sint;
881 };
882 #define KVM_IRQ_ROUTING_IRQCHIP 1
883 #define KVM_IRQ_ROUTING_MSI 2
884 #define KVM_IRQ_ROUTING_S390_ADAPTER 3
885 #define KVM_IRQ_ROUTING_HV_SINT 4
886 struct kvm_irq_routing_entry {
887   __u32 gsi;
888   __u32 type;
889   __u32 flags;
890   __u32 pad;
891   union {
892     struct kvm_irq_routing_irqchip irqchip;
893     struct kvm_irq_routing_msi msi;
894     struct kvm_irq_routing_s390_adapter adapter;
895     struct kvm_irq_routing_hv_sint hv_sint;
896     __u32 pad[8];
897   } u;
898 };
899 struct kvm_irq_routing {
900   __u32 nr;
901   __u32 flags;
902   struct kvm_irq_routing_entry entries[0];
903 };
904 #endif
905 #ifdef KVM_CAP_MCE
906 struct kvm_x86_mce {
907   __u64 status;
908   __u64 addr;
909   __u64 misc;
910   __u64 mcg_status;
911   __u8 bank;
912   __u8 pad1[7];
913   __u64 pad2[3];
914 };
915 #endif
916 #ifdef KVM_CAP_XEN_HVM
917 #define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR (1 << 0)
918 #define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL (1 << 1)
919 #define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2)
920 #define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3)
921 struct kvm_xen_hvm_config {
922   __u32 flags;
923   __u32 msr;
924   __u64 blob_addr_32;
925   __u64 blob_addr_64;
926   __u8 blob_size_32;
927   __u8 blob_size_64;
928   __u8 pad2[30];
929 };
930 #endif
931 #define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)
932 #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
933 struct kvm_irqfd {
934   __u32 fd;
935   __u32 gsi;
936   __u32 flags;
937   __u32 resamplefd;
938   __u8 pad[16];
939 };
940 #define KVM_CLOCK_TSC_STABLE 2
941 struct kvm_clock_data {
942   __u64 clock;
943   __u32 flags;
944   __u32 pad[9];
945 };
946 #define KVM_MMU_FSL_BOOKE_NOHV 0
947 #define KVM_MMU_FSL_BOOKE_HV 1
948 struct kvm_config_tlb {
949   __u64 params;
950   __u64 array;
951   __u32 mmu_type;
952   __u32 array_len;
953 };
954 struct kvm_dirty_tlb {
955   __u64 bitmap;
956   __u32 num_dirty;
957 };
958 #define KVM_REG_ARCH_MASK 0xff00000000000000ULL
959 #define KVM_REG_GENERIC 0x0000000000000000ULL
960 #define KVM_REG_PPC 0x1000000000000000ULL
961 #define KVM_REG_X86 0x2000000000000000ULL
962 #define KVM_REG_IA64 0x3000000000000000ULL
963 #define KVM_REG_ARM 0x4000000000000000ULL
964 #define KVM_REG_S390 0x5000000000000000ULL
965 #define KVM_REG_ARM64 0x6000000000000000ULL
966 #define KVM_REG_MIPS 0x7000000000000000ULL
967 #define KVM_REG_RISCV 0x8000000000000000ULL
968 #define KVM_REG_SIZE_SHIFT 52
969 #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL
970 #define KVM_REG_SIZE_U8 0x0000000000000000ULL
971 #define KVM_REG_SIZE_U16 0x0010000000000000ULL
972 #define KVM_REG_SIZE_U32 0x0020000000000000ULL
973 #define KVM_REG_SIZE_U64 0x0030000000000000ULL
974 #define KVM_REG_SIZE_U128 0x0040000000000000ULL
975 #define KVM_REG_SIZE_U256 0x0050000000000000ULL
976 #define KVM_REG_SIZE_U512 0x0060000000000000ULL
977 #define KVM_REG_SIZE_U1024 0x0070000000000000ULL
978 #define KVM_REG_SIZE_U2048 0x0080000000000000ULL
979 struct kvm_reg_list {
980   __u64 n;
981   __u64 reg[0];
982 };
983 struct kvm_one_reg {
984   __u64 id;
985   __u64 addr;
986 };
987 #define KVM_MSI_VALID_DEVID (1U << 0)
988 struct kvm_msi {
989   __u32 address_lo;
990   __u32 address_hi;
991   __u32 data;
992   __u32 flags;
993   __u32 devid;
994   __u8 pad[12];
995 };
996 struct kvm_arm_device_addr {
997   __u64 id;
998   __u64 addr;
999 };
1000 #define KVM_CREATE_DEVICE_TEST 1
1001 struct kvm_create_device {
1002   __u32 type;
1003   __u32 fd;
1004   __u32 flags;
1005 };
1006 struct kvm_device_attr {
1007   __u32 flags;
1008   __u32 group;
1009   __u64 attr;
1010   __u64 addr;
1011 };
1012 #define KVM_DEV_VFIO_GROUP 1
1013 #define KVM_DEV_VFIO_GROUP_ADD 1
1014 #define KVM_DEV_VFIO_GROUP_DEL 2
1015 #define KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE 3
1016 enum kvm_device_type {
1017   KVM_DEV_TYPE_FSL_MPIC_20 = 1,
1018 #define KVM_DEV_TYPE_FSL_MPIC_20 KVM_DEV_TYPE_FSL_MPIC_20
1019   KVM_DEV_TYPE_FSL_MPIC_42,
1020 #define KVM_DEV_TYPE_FSL_MPIC_42 KVM_DEV_TYPE_FSL_MPIC_42
1021   KVM_DEV_TYPE_XICS,
1022 #define KVM_DEV_TYPE_XICS KVM_DEV_TYPE_XICS
1023   KVM_DEV_TYPE_VFIO,
1024 #define KVM_DEV_TYPE_VFIO KVM_DEV_TYPE_VFIO
1025   KVM_DEV_TYPE_ARM_VGIC_V2,
1026 #define KVM_DEV_TYPE_ARM_VGIC_V2 KVM_DEV_TYPE_ARM_VGIC_V2
1027   KVM_DEV_TYPE_FLIC,
1028 #define KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_FLIC
1029   KVM_DEV_TYPE_ARM_VGIC_V3,
1030 #define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3
1031   KVM_DEV_TYPE_ARM_VGIC_ITS,
1032 #define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS
1033   KVM_DEV_TYPE_XIVE,
1034 #define KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_XIVE
1035   KVM_DEV_TYPE_ARM_PV_TIME,
1036 #define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME
1037   KVM_DEV_TYPE_MAX,
1038 };
1039 struct kvm_vfio_spapr_tce {
1040   __s32 groupfd;
1041   __s32 tablefd;
1042 };
1043 #define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region)
1044 #define KVM_CREATE_VCPU _IO(KVMIO, 0x41)
1045 #define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log)
1046 #define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias)
1047 #define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44)
1048 #define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45)
1049 #define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, struct kvm_userspace_memory_region)
1050 #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47)
1051 #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64)
1052 struct kvm_s390_ucas_mapping {
1053   __u64 user_addr;
1054   __u64 vcpu_addr;
1055   __u64 length;
1056 };
1057 #define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping)
1058 #define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping)
1059 #define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long)
1060 #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60)
1061 #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level)
1062 #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip)
1063 #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip)
1064 #define KVM_CREATE_PIT _IO(KVMIO, 0x64)
1065 #define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state)
1066 #define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state)
1067 #define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level)
1068 #define KVM_REGISTER_COALESCED_MMIO _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone)
1069 #define KVM_UNREGISTER_COALESCED_MMIO _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone)
1070 #define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, struct kvm_assigned_pci_dev)
1071 #define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing)
1072 #define KVM_ASSIGN_IRQ __KVM_DEPRECATED_VM_R_0x70
1073 #define KVM_ASSIGN_DEV_IRQ _IOW(KVMIO, 0x70, struct kvm_assigned_irq)
1074 #define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71)
1075 #define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, struct kvm_assigned_pci_dev)
1076 #define KVM_ASSIGN_SET_MSIX_NR _IOW(KVMIO, 0x73, struct kvm_assigned_msix_nr)
1077 #define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO, 0x74, struct kvm_assigned_msix_entry)
1078 #define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq)
1079 #define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd)
1080 #define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config)
1081 #define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78)
1082 #define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd)
1083 #define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config)
1084 #define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data)
1085 #define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data)
1086 #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2)
1087 #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2)
1088 #define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo)
1089 #define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2)
1090 #define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3)
1091 #define KVM_ASSIGN_SET_INTX_MASK _IOW(KVMIO, 0xa4, struct kvm_assigned_pci_dev)
1092 #define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi)
1093 #define KVM_PPC_GET_SMMU_INFO _IOR(KVMIO, 0xa6, struct kvm_ppc_smmu_info)
1094 #define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32)
1095 #define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce)
1096 #define KVM_CREATE_SPAPR_TCE_64 _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce_64)
1097 #define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma)
1098 #define KVM_PPC_GET_HTAB_FD _IOW(KVMIO, 0xaa, struct kvm_get_htab_fd)
1099 #define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr)
1100 #define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args)
1101 #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt)
1102 #define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt)
1103 #define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg)
1104 #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info)
1105 #define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char)
1106 #define KVM_SET_PMU_EVENT_FILTER _IOW(KVMIO, 0xb2, struct kvm_pmu_event_filter)
1107 #define KVM_PPC_SVM_OFF _IO(KVMIO, 0xb3)
1108 #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device)
1109 #define KVM_SET_DEVICE_ATTR _IOW(KVMIO, 0xe1, struct kvm_device_attr)
1110 #define KVM_GET_DEVICE_ATTR _IOW(KVMIO, 0xe2, struct kvm_device_attr)
1111 #define KVM_HAS_DEVICE_ATTR _IOW(KVMIO, 0xe3, struct kvm_device_attr)
1112 #define KVM_RUN _IO(KVMIO, 0x80)
1113 #define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs)
1114 #define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs)
1115 #define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs)
1116 #define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs)
1117 #define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation)
1118 #define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt)
1119 #define KVM_DEBUG_GUEST __KVM_DEPRECATED_VCPU_W_0x87
1120 #define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs)
1121 #define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs)
1122 #define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid)
1123 #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask)
1124 #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu)
1125 #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu)
1126 #define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state)
1127 #define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state)
1128 #define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2)
1129 #define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2)
1130 #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)
1131 #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr)
1132 #define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt)
1133 #define KVM_S390_STORE_STATUS_NOADDR (- 1ul)
1134 #define KVM_S390_STORE_STATUS_PREFIXED (- 2ul)
1135 #define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long)
1136 #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw)
1137 #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97)
1138 #define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state)
1139 #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state)
1140 #define KVM_NMI _IO(KVMIO, 0x9a)
1141 #define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug)
1142 #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64)
1143 #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64)
1144 #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce)
1145 #define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events)
1146 #define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events)
1147 #define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs)
1148 #define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs)
1149 #define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap)
1150 #define KVM_GET_XSAVE _IOR(KVMIO, 0xa4, struct kvm_xsave)
1151 #define KVM_SET_XSAVE _IOW(KVMIO, 0xa5, struct kvm_xsave)
1152 #define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs)
1153 #define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs)
1154 #define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb)
1155 #define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg)
1156 #define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg)
1157 #define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad)
1158 #define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init)
1159 #define KVM_ARM_PREFERRED_TARGET _IOR(KVMIO, 0xaf, struct kvm_vcpu_init)
1160 #define KVM_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list)
1161 #define KVM_S390_MEM_OP _IOW(KVMIO, 0xb1, struct kvm_s390_mem_op)
1162 #define KVM_S390_GET_SKEYS _IOW(KVMIO, 0xb2, struct kvm_s390_skeys)
1163 #define KVM_S390_SET_SKEYS _IOW(KVMIO, 0xb3, struct kvm_s390_skeys)
1164 #define KVM_S390_IRQ _IOW(KVMIO, 0xb4, struct kvm_s390_irq)
1165 #define KVM_S390_SET_IRQ_STATE _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state)
1166 #define KVM_S390_GET_IRQ_STATE _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state)
1167 #define KVM_SMI _IO(KVMIO, 0xb7)
1168 #define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log)
1169 #define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log)
1170 #define KVM_MEMORY_ENCRYPT_OP _IOWR(KVMIO, 0xba, unsigned long)
1171 struct kvm_enc_region {
1172   __u64 addr;
1173   __u64 size;
1174 };
1175 #define KVM_MEMORY_ENCRYPT_REG_REGION _IOR(KVMIO, 0xbb, struct kvm_enc_region)
1176 #define KVM_MEMORY_ENCRYPT_UNREG_REGION _IOR(KVMIO, 0xbc, struct kvm_enc_region)
1177 #define KVM_HYPERV_EVENTFD _IOW(KVMIO, 0xbd, struct kvm_hyperv_eventfd)
1178 #define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state)
1179 #define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state)
1180 #define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log)
1181 #define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2)
1182 #define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int)
1183 #define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3)
1184 #define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4)
1185 struct kvm_s390_pv_sec_parm {
1186   __u64 origin;
1187   __u64 length;
1188 };
1189 struct kvm_s390_pv_unp {
1190   __u64 addr;
1191   __u64 size;
1192   __u64 tweak;
1193 };
1194 enum pv_cmd_id {
1195   KVM_PV_ENABLE,
1196   KVM_PV_DISABLE,
1197   KVM_PV_SET_SEC_PARMS,
1198   KVM_PV_UNPACK,
1199   KVM_PV_VERIFY,
1200   KVM_PV_PREP_RESET,
1201   KVM_PV_UNSHARE_ALL,
1202 };
1203 struct kvm_pv_cmd {
1204   __u32 cmd;
1205   __u16 rc;
1206   __u16 rrc;
1207   __u64 data;
1208   __u32 flags;
1209   __u32 reserved[3];
1210 };
1211 #define KVM_S390_PV_COMMAND _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd)
1212 #define KVM_X86_SET_MSR_FILTER _IOW(KVMIO, 0xc6, struct kvm_msr_filter)
1213 #define KVM_RESET_DIRTY_RINGS _IO(KVMIO, 0xc7)
1214 #define KVM_XEN_HVM_GET_ATTR _IOWR(KVMIO, 0xc8, struct kvm_xen_hvm_attr)
1215 #define KVM_XEN_HVM_SET_ATTR _IOW(KVMIO, 0xc9, struct kvm_xen_hvm_attr)
1216 struct kvm_xen_hvm_attr {
1217   __u16 type;
1218   __u16 pad[3];
1219   union {
1220     __u8 long_mode;
1221     __u8 vector;
1222     struct {
1223       __u64 gfn;
1224     } shared_info;
1225     __u64 pad[8];
1226   } u;
1227 };
1228 #define KVM_XEN_ATTR_TYPE_LONG_MODE 0x0
1229 #define KVM_XEN_ATTR_TYPE_SHARED_INFO 0x1
1230 #define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR 0x2
1231 #define KVM_XEN_VCPU_GET_ATTR _IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr)
1232 #define KVM_XEN_VCPU_SET_ATTR _IOW(KVMIO, 0xcb, struct kvm_xen_vcpu_attr)
1233 struct kvm_xen_vcpu_attr {
1234   __u16 type;
1235   __u16 pad[3];
1236   union {
1237     __u64 gpa;
1238     __u64 pad[8];
1239     struct {
1240       __u64 state;
1241       __u64 state_entry_time;
1242       __u64 time_running;
1243       __u64 time_runnable;
1244       __u64 time_blocked;
1245       __u64 time_offline;
1246     } runstate;
1247   } u;
1248 };
1249 #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO 0x0
1250 #define KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO 0x1
1251 #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR 0x2
1252 #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT 0x3
1253 #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 0x4
1254 #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 0x5
1255 enum sev_cmd_id {
1256   KVM_SEV_INIT = 0,
1257   KVM_SEV_ES_INIT,
1258   KVM_SEV_LAUNCH_START,
1259   KVM_SEV_LAUNCH_UPDATE_DATA,
1260   KVM_SEV_LAUNCH_UPDATE_VMSA,
1261   KVM_SEV_LAUNCH_SECRET,
1262   KVM_SEV_LAUNCH_MEASURE,
1263   KVM_SEV_LAUNCH_FINISH,
1264   KVM_SEV_SEND_START,
1265   KVM_SEV_SEND_UPDATE_DATA,
1266   KVM_SEV_SEND_UPDATE_VMSA,
1267   KVM_SEV_SEND_FINISH,
1268   KVM_SEV_RECEIVE_START,
1269   KVM_SEV_RECEIVE_UPDATE_DATA,
1270   KVM_SEV_RECEIVE_UPDATE_VMSA,
1271   KVM_SEV_RECEIVE_FINISH,
1272   KVM_SEV_GUEST_STATUS,
1273   KVM_SEV_DBG_DECRYPT,
1274   KVM_SEV_DBG_ENCRYPT,
1275   KVM_SEV_CERT_EXPORT,
1276   KVM_SEV_GET_ATTESTATION_REPORT,
1277   KVM_SEV_NR_MAX,
1278 };
1279 struct kvm_sev_cmd {
1280   __u32 id;
1281   __u64 data;
1282   __u32 error;
1283   __u32 sev_fd;
1284 };
1285 struct kvm_sev_launch_start {
1286   __u32 handle;
1287   __u32 policy;
1288   __u64 dh_uaddr;
1289   __u32 dh_len;
1290   __u64 session_uaddr;
1291   __u32 session_len;
1292 };
1293 struct kvm_sev_launch_update_data {
1294   __u64 uaddr;
1295   __u32 len;
1296 };
1297 struct kvm_sev_launch_secret {
1298   __u64 hdr_uaddr;
1299   __u32 hdr_len;
1300   __u64 guest_uaddr;
1301   __u32 guest_len;
1302   __u64 trans_uaddr;
1303   __u32 trans_len;
1304 };
1305 struct kvm_sev_launch_measure {
1306   __u64 uaddr;
1307   __u32 len;
1308 };
1309 struct kvm_sev_guest_status {
1310   __u32 handle;
1311   __u32 policy;
1312   __u32 state;
1313 };
1314 struct kvm_sev_dbg {
1315   __u64 src_uaddr;
1316   __u64 dst_uaddr;
1317   __u32 len;
1318 };
1319 struct kvm_sev_attestation_report {
1320   __u8 mnonce[16];
1321   __u64 uaddr;
1322   __u32 len;
1323 };
1324 #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
1325 #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)
1326 #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2)
1327 struct kvm_assigned_pci_dev {
1328   __u32 assigned_dev_id;
1329   __u32 busnr;
1330   __u32 devfn;
1331   __u32 flags;
1332   __u32 segnr;
1333   union {
1334     __u32 reserved[11];
1335   };
1336 };
1337 #define KVM_DEV_IRQ_HOST_INTX (1 << 0)
1338 #define KVM_DEV_IRQ_HOST_MSI (1 << 1)
1339 #define KVM_DEV_IRQ_HOST_MSIX (1 << 2)
1340 #define KVM_DEV_IRQ_GUEST_INTX (1 << 8)
1341 #define KVM_DEV_IRQ_GUEST_MSI (1 << 9)
1342 #define KVM_DEV_IRQ_GUEST_MSIX (1 << 10)
1343 #define KVM_DEV_IRQ_HOST_MASK 0x00ff
1344 #define KVM_DEV_IRQ_GUEST_MASK 0xff00
1345 struct kvm_assigned_irq {
1346   __u32 assigned_dev_id;
1347   __u32 host_irq;
1348   __u32 guest_irq;
1349   __u32 flags;
1350   union {
1351     __u32 reserved[12];
1352   };
1353 };
1354 struct kvm_assigned_msix_nr {
1355   __u32 assigned_dev_id;
1356   __u16 entry_nr;
1357   __u16 padding;
1358 };
1359 #define KVM_MAX_MSIX_PER_DEV 256
1360 struct kvm_assigned_msix_entry {
1361   __u32 assigned_dev_id;
1362   __u32 gsi;
1363   __u16 entry;
1364   __u16 padding[3];
1365 };
1366 #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)
1367 #define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1)
1368 #define KVM_ARM_DEV_EL1_VTIMER (1 << 0)
1369 #define KVM_ARM_DEV_EL1_PTIMER (1 << 1)
1370 #define KVM_ARM_DEV_PMU (1 << 2)
1371 struct kvm_hyperv_eventfd {
1372   __u32 conn_id;
1373   __s32 fd;
1374   __u32 flags;
1375   __u32 padding[3];
1376 };
1377 #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
1378 #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
1379 #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
1380 #define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
1381 #ifndef KVM_DIRTY_LOG_PAGE_OFFSET
1382 #define KVM_DIRTY_LOG_PAGE_OFFSET 0
1383 #endif
1384 #define KVM_DIRTY_GFN_F_DIRTY BIT(0)
1385 #define KVM_DIRTY_GFN_F_RESET BIT(1)
1386 #define KVM_DIRTY_GFN_F_MASK 0x3
1387 struct kvm_dirty_gfn {
1388   __u32 flags;
1389   __u32 slot;
1390   __u64 offset;
1391 };
1392 #define KVM_BUS_LOCK_DETECTION_OFF (1 << 0)
1393 #define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1)
1394 #endif
1395