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