blob: ffaf5e65fc732e3a4e1405997afcd785e788a90f [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Ben Cheng655a7c02013-10-16 16:09:24 -07007#ifndef __LINUX_KVM_H
8#define __LINUX_KVM_H
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +00009#include <linux/const.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070010#include <linux/types.h>
11#include <linux/compiler.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070012#include <linux/ioctl.h>
13#include <asm/kvm.h>
14#define KVM_API_VERSION 12
Christopher Ferris7f4c8372024-06-03 14:22:19 -070015#define __KVM_HAVE_GUEST_DEBUG
Ben Cheng655a7c02013-10-16 16:09:24 -070016struct kvm_userspace_memory_region {
Tao Baod7db5942015-01-28 10:07:51 -080017 __u32 slot;
Tao Baod7db5942015-01-28 10:07:51 -080018 __u32 flags;
19 __u64 guest_phys_addr;
20 __u64 memory_size;
21 __u64 userspace_addr;
Ben Cheng655a7c02013-10-16 16:09:24 -070022};
Christopher Ferrisb830ddf2024-03-28 11:48:08 -070023struct kvm_userspace_memory_region2 {
24 __u32 slot;
25 __u32 flags;
26 __u64 guest_phys_addr;
27 __u64 memory_size;
28 __u64 userspace_addr;
29 __u64 guest_memfd_offset;
30 __u32 guest_memfd;
31 __u32 pad1;
32 __u64 pad2[14];
33};
Ben Cheng655a7c02013-10-16 16:09:24 -070034#define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0)
35#define KVM_MEM_READONLY (1UL << 1)
Christopher Ferrisb830ddf2024-03-28 11:48:08 -070036#define KVM_MEM_GUEST_MEMFD (1UL << 2)
Ben Cheng655a7c02013-10-16 16:09:24 -070037struct kvm_irq_level {
Tao Baod7db5942015-01-28 10:07:51 -080038 union {
39 __u32 irq;
40 __s32 status;
41 };
Tao Baod7db5942015-01-28 10:07:51 -080042 __u32 level;
Ben Cheng655a7c02013-10-16 16:09:24 -070043};
44struct kvm_irqchip {
Tao Baod7db5942015-01-28 10:07:51 -080045 __u32 chip_id;
Tao Baod7db5942015-01-28 10:07:51 -080046 __u32 pad;
47 union {
48 char dummy[512];
Ben Cheng655a7c02013-10-16 16:09:24 -070049#ifdef __KVM_HAVE_PIT
Tao Baod7db5942015-01-28 10:07:51 -080050 struct kvm_pic_state pic;
Ben Cheng655a7c02013-10-16 16:09:24 -070051#endif
52#ifdef __KVM_HAVE_IOAPIC
Tao Baod7db5942015-01-28 10:07:51 -080053 struct kvm_ioapic_state ioapic;
Ben Cheng655a7c02013-10-16 16:09:24 -070054#endif
Tao Baod7db5942015-01-28 10:07:51 -080055 } chip;
Ben Cheng655a7c02013-10-16 16:09:24 -070056};
57struct kvm_pit_config {
Tao Baod7db5942015-01-28 10:07:51 -080058 __u32 flags;
59 __u32 pad[15];
Ben Cheng655a7c02013-10-16 16:09:24 -070060};
61#define KVM_PIT_SPEAKER_DUMMY 1
Christopher Ferris106b3a82016-08-24 12:15:38 -070062struct kvm_hyperv_exit {
Christopher Ferris106b3a82016-08-24 12:15:38 -070063#define KVM_EXIT_HYPERV_SYNIC 1
64#define KVM_EXIT_HYPERV_HCALL 2
Christopher Ferris8177cdf2020-08-03 11:53:55 -070065#define KVM_EXIT_HYPERV_SYNDBG 3
Christopher Ferris106b3a82016-08-24 12:15:38 -070066 __u32 type;
Christopher Ferris8177cdf2020-08-03 11:53:55 -070067 __u32 pad1;
Christopher Ferris106b3a82016-08-24 12:15:38 -070068 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -070069 struct {
70 __u32 msr;
Christopher Ferris8177cdf2020-08-03 11:53:55 -070071 __u32 pad2;
Christopher Ferris106b3a82016-08-24 12:15:38 -070072 __u64 control;
73 __u64 evt_page;
Christopher Ferris106b3a82016-08-24 12:15:38 -070074 __u64 msg_page;
75 } synic;
76 struct {
77 __u64 input;
Christopher Ferris106b3a82016-08-24 12:15:38 -070078 __u64 result;
79 __u64 params[2];
80 } hcall;
Christopher Ferris8177cdf2020-08-03 11:53:55 -070081 struct {
82 __u32 msr;
83 __u32 pad2;
84 __u64 control;
85 __u64 status;
86 __u64 send_page;
87 __u64 recv_page;
88 __u64 pending_page;
89 } syndbg;
Christopher Ferris106b3a82016-08-24 12:15:38 -070090 } u;
Christopher Ferris106b3a82016-08-24 12:15:38 -070091};
Christopher Ferrisa9750ed2021-05-03 14:02:49 -070092struct kvm_xen_exit {
93#define KVM_EXIT_XEN_HCALL 1
94 __u32 type;
95 union {
96 struct {
97 __u32 longmode;
98 __u32 cpl;
99 __u64 input;
100 __u64 result;
101 __u64 params[6];
102 } hcall;
103 } u;
104};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700105#define KVM_S390_GET_SKEYS_NONE 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800106#define KVM_S390_SKEYS_MAX 1048576
Ben Cheng655a7c02013-10-16 16:09:24 -0700107#define KVM_EXIT_UNKNOWN 0
108#define KVM_EXIT_EXCEPTION 1
109#define KVM_EXIT_IO 2
Christopher Ferris05d08e92016-02-04 13:16:38 -0800110#define KVM_EXIT_HYPERCALL 3
Ben Cheng655a7c02013-10-16 16:09:24 -0700111#define KVM_EXIT_DEBUG 4
112#define KVM_EXIT_HLT 5
113#define KVM_EXIT_MMIO 6
Christopher Ferris05d08e92016-02-04 13:16:38 -0800114#define KVM_EXIT_IRQ_WINDOW_OPEN 7
Ben Cheng655a7c02013-10-16 16:09:24 -0700115#define KVM_EXIT_SHUTDOWN 8
116#define KVM_EXIT_FAIL_ENTRY 9
117#define KVM_EXIT_INTR 10
Christopher Ferris05d08e92016-02-04 13:16:38 -0800118#define KVM_EXIT_SET_TPR 11
Ben Cheng655a7c02013-10-16 16:09:24 -0700119#define KVM_EXIT_TPR_ACCESS 12
120#define KVM_EXIT_S390_SIEIC 13
121#define KVM_EXIT_S390_RESET 14
Christopher Ferris05d08e92016-02-04 13:16:38 -0800122#define KVM_EXIT_DCR 15
Ben Cheng655a7c02013-10-16 16:09:24 -0700123#define KVM_EXIT_NMI 16
124#define KVM_EXIT_INTERNAL_ERROR 17
125#define KVM_EXIT_OSI 18
Christopher Ferris05d08e92016-02-04 13:16:38 -0800126#define KVM_EXIT_PAPR_HCALL 19
Ben Cheng655a7c02013-10-16 16:09:24 -0700127#define KVM_EXIT_S390_UCONTROL 20
128#define KVM_EXIT_WATCHDOG 21
129#define KVM_EXIT_S390_TSCH 22
Christopher Ferris05d08e92016-02-04 13:16:38 -0800130#define KVM_EXIT_EPR 23
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700131#define KVM_EXIT_SYSTEM_EVENT 24
Christopher Ferris05d08e92016-02-04 13:16:38 -0800132#define KVM_EXIT_S390_STSI 25
133#define KVM_EXIT_IOAPIC_EOI 26
Christopher Ferris106b3a82016-08-24 12:15:38 -0700134#define KVM_EXIT_HYPERV 27
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800135#define KVM_EXIT_ARM_NISV 28
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800136#define KVM_EXIT_X86_RDMSR 29
137#define KVM_EXIT_X86_WRMSR 30
Christopher Ferris05667cd2021-02-16 16:01:34 -0800138#define KVM_EXIT_DIRTY_RING_FULL 31
139#define KVM_EXIT_AP_RESET_HOLD 32
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700140#define KVM_EXIT_X86_BUS_LOCK 33
141#define KVM_EXIT_XEN 34
Christopher Ferrisa4792612022-01-10 13:51:15 -0800142#define KVM_EXIT_RISCV_SBI 35
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700143#define KVM_EXIT_RISCV_CSR 36
144#define KVM_EXIT_NOTIFY 37
Christopher Ferris0f795212024-01-17 14:17:28 -0800145#define KVM_EXIT_LOONGARCH_IOCSR 38
Christopher Ferrisb830ddf2024-03-28 11:48:08 -0700146#define KVM_EXIT_MEMORY_FAULT 39
Ben Cheng655a7c02013-10-16 16:09:24 -0700147#define KVM_INTERNAL_ERROR_EMULATION 1
148#define KVM_INTERNAL_ERROR_SIMUL_EX 2
149#define KVM_INTERNAL_ERROR_DELIVERY_EV 3
Christopher Ferris9584fa42019-12-09 15:36:13 -0800150#define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON 4
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000151#define KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES (1ULL << 0)
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700152struct kvm_run {
Tao Baod7db5942015-01-28 10:07:51 -0800153 __u8 request_interrupt_window;
Priyanka Advani (xWF)a8050342024-09-25 19:07:32 +0000154 __u8 immediate_exit;
Christopher Ferris525ce912017-07-26 13:12:53 -0700155 __u8 padding1[6];
Tao Baod7db5942015-01-28 10:07:51 -0800156 __u32 exit_reason;
Tao Baod7db5942015-01-28 10:07:51 -0800157 __u8 ready_for_interrupt_injection;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800158 __u8 if_flag;
159 __u16 flags;
160 __u64 cr8;
Tao Baod7db5942015-01-28 10:07:51 -0800161 __u64 apic_base;
Ben Cheng655a7c02013-10-16 16:09:24 -0700162#ifdef __KVM_S390
Tao Baod7db5942015-01-28 10:07:51 -0800163 __u64 psw_mask;
164 __u64 psw_addr;
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700165#endif
Tao Baod7db5942015-01-28 10:07:51 -0800166 union {
167 struct {
168 __u64 hardware_exit_reason;
Tao Baod7db5942015-01-28 10:07:51 -0800169 } hw;
170 struct {
171 __u64 hardware_entry_failure_reason;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700172 __u32 cpu;
Tao Baod7db5942015-01-28 10:07:51 -0800173 } fail_entry;
Tao Baod7db5942015-01-28 10:07:51 -0800174 struct {
175 __u32 exception;
176 __u32 error_code;
177 } ex;
Tao Baod7db5942015-01-28 10:07:51 -0800178 struct {
Ben Cheng655a7c02013-10-16 16:09:24 -0700179#define KVM_EXIT_IO_IN 0
180#define KVM_EXIT_IO_OUT 1
Tao Baod7db5942015-01-28 10:07:51 -0800181 __u8 direction;
Tao Baod7db5942015-01-28 10:07:51 -0800182 __u8 size;
183 __u16 port;
184 __u32 count;
185 __u64 data_offset;
Tao Baod7db5942015-01-28 10:07:51 -0800186 } io;
187 struct {
188 struct kvm_debug_exit_arch arch;
189 } debug;
Tao Baod7db5942015-01-28 10:07:51 -0800190 struct {
191 __u64 phys_addr;
192 __u8 data[8];
193 __u32 len;
Tao Baod7db5942015-01-28 10:07:51 -0800194 __u8 is_write;
195 } mmio;
196 struct {
Christopher Ferris0f795212024-01-17 14:17:28 -0800197 __u64 phys_addr;
198 __u8 data[8];
199 __u32 len;
200 __u8 is_write;
201 } iocsr_io;
202 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800203 __u64 nr;
Tao Baod7db5942015-01-28 10:07:51 -0800204 __u64 args[6];
205 __u64 ret;
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700206 union {
207 __u32 longmode;
208 __u64 flags;
209 };
Tao Baod7db5942015-01-28 10:07:51 -0800210 } hypercall;
211 struct {
212 __u64 rip;
213 __u32 is_write;
Tao Baod7db5942015-01-28 10:07:51 -0800214 __u32 pad;
215 } tpr_access;
216 struct {
217 __u8 icptcode;
Tao Baod7db5942015-01-28 10:07:51 -0800218 __u16 ipa;
219 __u32 ipb;
220 } s390_sieic;
Tao Baod7db5942015-01-28 10:07:51 -0800221 __u64 s390_reset_flags;
222 struct {
223 __u64 trans_exc_code;
224 __u32 pgm_code;
Tao Baod7db5942015-01-28 10:07:51 -0800225 } s390_ucontrol;
226 struct {
227 __u32 dcrn;
228 __u32 data;
Tao Baod7db5942015-01-28 10:07:51 -0800229 __u8 is_write;
230 } dcr;
231 struct {
232 __u32 suberror;
Tao Baod7db5942015-01-28 10:07:51 -0800233 __u32 ndata;
234 __u64 data[16];
235 } internal;
236 struct {
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000237 __u32 suberror;
238 __u32 ndata;
239 __u64 flags;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800240 union {
241 struct {
242 __u8 insn_size;
243 __u8 insn_bytes[15];
244 };
245 };
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000246 } emulation_failure;
247 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800248 __u64 gprs[32];
249 } osi;
250 struct {
251 __u64 nr;
Tao Baod7db5942015-01-28 10:07:51 -0800252 __u64 ret;
253 __u64 args[9];
254 } papr_hcall;
255 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800256 __u16 subchannel_id;
257 __u16 subchannel_nr;
258 __u32 io_int_parm;
259 __u32 io_int_word;
Tao Baod7db5942015-01-28 10:07:51 -0800260 __u32 ipb;
261 __u8 dequeued;
262 } s390_tsch;
263 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800264 __u32 epr;
265 } epr;
266 struct {
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700267#define KVM_SYSTEM_EVENT_SHUTDOWN 1
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700268#define KVM_SYSTEM_EVENT_RESET 2
Christopher Ferris05d08e92016-02-04 13:16:38 -0800269#define KVM_SYSTEM_EVENT_CRASH 3
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700270#define KVM_SYSTEM_EVENT_WAKEUP 4
271#define KVM_SYSTEM_EVENT_SUSPEND 5
272#define KVM_SYSTEM_EVENT_SEV_TERM 6
Tao Baod7db5942015-01-28 10:07:51 -0800273 __u32 type;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700274 __u32 ndata;
275 union {
276 __u64 flags;
277 __u64 data[16];
278 };
Tao Baod7db5942015-01-28 10:07:51 -0800279 } system_event;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800280 struct {
281 __u64 addr;
282 __u8 ar;
283 __u8 reserved;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800284 __u8 fc;
285 __u8 sel1;
286 __u16 sel2;
287 } s390_stsi;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800288 struct {
289 __u8 vector;
290 } eoi;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700291 struct kvm_hyperv_exit hyperv;
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800292 struct {
293 __u64 esr_iss;
294 __u64 fault_ipa;
295 } arm_nisv;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800296 struct {
297 __u8 error;
298 __u8 pad[7];
299#define KVM_MSR_EXIT_REASON_INVAL (1 << 0)
300#define KVM_MSR_EXIT_REASON_UNKNOWN (1 << 1)
301#define KVM_MSR_EXIT_REASON_FILTER (1 << 2)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800302#define KVM_MSR_EXIT_REASON_VALID_MASK (KVM_MSR_EXIT_REASON_INVAL | KVM_MSR_EXIT_REASON_UNKNOWN | KVM_MSR_EXIT_REASON_FILTER)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800303 __u32 reason;
304 __u32 index;
305 __u64 data;
306 } msr;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700307 struct kvm_xen_exit xen;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800308 struct {
309 unsigned long extension_id;
310 unsigned long function_id;
311 unsigned long args[6];
312 unsigned long ret[2];
313 } riscv_sbi;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700314 struct {
315 unsigned long csr_num;
316 unsigned long new_value;
317 unsigned long write_mask;
318 unsigned long ret_value;
319 } riscv_csr;
320 struct {
321#define KVM_NOTIFY_CONTEXT_INVALID (1 << 0)
322 __u32 flags;
323 } notify;
Christopher Ferrisb830ddf2024-03-28 11:48:08 -0700324 struct {
325#define KVM_MEMORY_EXIT_FLAG_PRIVATE (1ULL << 3)
326 __u64 flags;
327 __u64 gpa;
328 __u64 size;
329 } memory_fault;
Tao Baod7db5942015-01-28 10:07:51 -0800330 char padding[256];
331 };
Christopher Ferris76a1d452018-06-27 14:12:29 -0700332#define SYNC_REGS_SIZE_BYTES 2048
Tao Baod7db5942015-01-28 10:07:51 -0800333 __u64 kvm_valid_regs;
334 __u64 kvm_dirty_regs;
Tao Baod7db5942015-01-28 10:07:51 -0800335 union {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800336 struct kvm_sync_regs regs;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700337 char padding[SYNC_REGS_SIZE_BYTES];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800338 } s;
Ben Cheng655a7c02013-10-16 16:09:24 -0700339};
340struct kvm_coalesced_mmio_zone {
Tao Baod7db5942015-01-28 10:07:51 -0800341 __u64 addr;
342 __u32 size;
Christopher Ferris86a48372019-01-10 14:14:59 -0800343 union {
344 __u32 pad;
345 __u32 pio;
346 };
Ben Cheng655a7c02013-10-16 16:09:24 -0700347};
348struct kvm_coalesced_mmio {
Tao Baod7db5942015-01-28 10:07:51 -0800349 __u64 phys_addr;
Tao Baod7db5942015-01-28 10:07:51 -0800350 __u32 len;
Christopher Ferris86a48372019-01-10 14:14:59 -0800351 union {
352 __u32 pad;
353 __u32 pio;
354 };
Tao Baod7db5942015-01-28 10:07:51 -0800355 __u8 data[8];
Ben Cheng655a7c02013-10-16 16:09:24 -0700356};
357struct kvm_coalesced_mmio_ring {
Tao Baod7db5942015-01-28 10:07:51 -0800358 __u32 first, last;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700359 struct kvm_coalesced_mmio coalesced_mmio[];
Ben Cheng655a7c02013-10-16 16:09:24 -0700360};
Tao Baod7db5942015-01-28 10:07:51 -0800361#define KVM_COALESCED_MMIO_MAX ((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / sizeof(struct kvm_coalesced_mmio))
Ben Cheng655a7c02013-10-16 16:09:24 -0700362struct kvm_translation {
Tao Baod7db5942015-01-28 10:07:51 -0800363 __u64 linear_address;
364 __u64 physical_address;
Tao Baod7db5942015-01-28 10:07:51 -0800365 __u8 valid;
366 __u8 writeable;
367 __u8 usermode;
368 __u8 pad[5];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800369};
Ben Cheng655a7c02013-10-16 16:09:24 -0700370struct kvm_interrupt {
Tao Baod7db5942015-01-28 10:07:51 -0800371 __u32 irq;
Ben Cheng655a7c02013-10-16 16:09:24 -0700372};
373struct kvm_dirty_log {
Tao Baod7db5942015-01-28 10:07:51 -0800374 __u32 slot;
375 __u32 padding1;
376 union {
Elliott Hughes0f0c18f2023-03-29 15:53:31 -0700377 void * dirty_bitmap;
Tao Baod7db5942015-01-28 10:07:51 -0800378 __u64 padding2;
379 };
Ben Cheng655a7c02013-10-16 16:09:24 -0700380};
Christopher Ferrisd842e432019-03-07 10:21:59 -0800381struct kvm_clear_dirty_log {
382 __u32 slot;
383 __u32 num_pages;
384 __u64 first_page;
385 union {
Elliott Hughes0f0c18f2023-03-29 15:53:31 -0700386 void * dirty_bitmap;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800387 __u64 padding2;
388 };
389};
Ben Cheng655a7c02013-10-16 16:09:24 -0700390struct kvm_signal_mask {
Tao Baod7db5942015-01-28 10:07:51 -0800391 __u32 len;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700392 __u8 sigset[];
Ben Cheng655a7c02013-10-16 16:09:24 -0700393};
394struct kvm_tpr_access_ctl {
Tao Baod7db5942015-01-28 10:07:51 -0800395 __u32 enabled;
396 __u32 flags;
397 __u32 reserved[8];
Ben Cheng655a7c02013-10-16 16:09:24 -0700398};
399struct kvm_vapic_addr {
Tao Baod7db5942015-01-28 10:07:51 -0800400 __u64 vapic_addr;
Ben Cheng655a7c02013-10-16 16:09:24 -0700401};
402#define KVM_MP_STATE_RUNNABLE 0
403#define KVM_MP_STATE_UNINITIALIZED 1
404#define KVM_MP_STATE_INIT_RECEIVED 2
Ben Cheng655a7c02013-10-16 16:09:24 -0700405#define KVM_MP_STATE_HALTED 3
406#define KVM_MP_STATE_SIPI_RECEIVED 4
Christopher Ferris82d75042015-01-26 10:57:07 -0800407#define KVM_MP_STATE_STOPPED 5
408#define KVM_MP_STATE_CHECK_STOP 6
409#define KVM_MP_STATE_OPERATING 7
Christopher Ferris82d75042015-01-26 10:57:07 -0800410#define KVM_MP_STATE_LOAD 8
Christopher Ferris05667cd2021-02-16 16:01:34 -0800411#define KVM_MP_STATE_AP_RESET_HOLD 9
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700412#define KVM_MP_STATE_SUSPENDED 10
Ben Cheng655a7c02013-10-16 16:09:24 -0700413struct kvm_mp_state {
Tao Baod7db5942015-01-28 10:07:51 -0800414 __u32 mp_state;
Ben Cheng655a7c02013-10-16 16:09:24 -0700415};
Ben Cheng655a7c02013-10-16 16:09:24 -0700416#define KVM_GUESTDBG_ENABLE 0x00000001
417#define KVM_GUESTDBG_SINGLESTEP 0x00000002
Ben Cheng655a7c02013-10-16 16:09:24 -0700418struct kvm_guest_debug {
Tao Baod7db5942015-01-28 10:07:51 -0800419 __u32 control;
Tao Baod7db5942015-01-28 10:07:51 -0800420 __u32 pad;
421 struct kvm_guest_debug_arch arch;
Ben Cheng655a7c02013-10-16 16:09:24 -0700422};
423enum {
Tao Baod7db5942015-01-28 10:07:51 -0800424 kvm_ioeventfd_flag_nr_datamatch,
425 kvm_ioeventfd_flag_nr_pio,
426 kvm_ioeventfd_flag_nr_deassign,
427 kvm_ioeventfd_flag_nr_virtio_ccw_notify,
Tao Baod7db5942015-01-28 10:07:51 -0800428 kvm_ioeventfd_flag_nr_fast_mmio,
429 kvm_ioeventfd_flag_nr_max,
Ben Cheng655a7c02013-10-16 16:09:24 -0700430};
Ben Cheng655a7c02013-10-16 16:09:24 -0700431#define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
432#define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
433#define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
Tao Baod7db5942015-01-28 10:07:51 -0800434#define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify)
Ben Cheng655a7c02013-10-16 16:09:24 -0700435#define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1)
436struct kvm_ioeventfd {
Tao Baod7db5942015-01-28 10:07:51 -0800437 __u64 datamatch;
438 __u64 addr;
439 __u32 len;
Tao Baod7db5942015-01-28 10:07:51 -0800440 __s32 fd;
441 __u32 flags;
442 __u8 pad[36];
Ben Cheng655a7c02013-10-16 16:09:24 -0700443};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700444#define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0)
445#define KVM_X86_DISABLE_EXITS_HLT (1 << 1)
446#define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700447#define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3)
448#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)
Ben Cheng655a7c02013-10-16 16:09:24 -0700449struct kvm_enable_cap {
Tao Baod7db5942015-01-28 10:07:51 -0800450 __u32 cap;
451 __u32 flags;
452 __u64 args[4];
Tao Baod7db5942015-01-28 10:07:51 -0800453 __u8 pad[64];
Ben Cheng655a7c02013-10-16 16:09:24 -0700454};
Ben Cheng655a7c02013-10-16 16:09:24 -0700455#define KVMIO 0xAE
Ben Cheng655a7c02013-10-16 16:09:24 -0700456#define KVM_VM_S390_UCONTROL 1
Christopher Ferris38062f92014-07-09 15:33:25 -0700457#define KVM_VM_PPC_HV 1
458#define KVM_VM_PPC_PR 2
Christopher Ferris25c18d42020-10-14 17:42:58 -0700459#define KVM_VM_MIPS_AUTO 0
Christopher Ferris525ce912017-07-26 13:12:53 -0700460#define KVM_VM_MIPS_VZ 1
Christopher Ferris25c18d42020-10-14 17:42:58 -0700461#define KVM_VM_MIPS_TE 2
Ben Cheng655a7c02013-10-16 16:09:24 -0700462#define KVM_S390_SIE_PAGE_OFFSET 1
Christopher Ferris86a48372019-01-10 14:14:59 -0800463#define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL
464#define KVM_VM_TYPE_ARM_IPA_SIZE(x) ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK)
Ben Cheng655a7c02013-10-16 16:09:24 -0700465#define KVM_GET_API_VERSION _IO(KVMIO, 0x00)
466#define KVM_CREATE_VM _IO(KVMIO, 0x01)
Ben Cheng655a7c02013-10-16 16:09:24 -0700467#define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list)
468#define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06)
469#define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03)
470#define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04)
Ben Cheng655a7c02013-10-16 16:09:24 -0700471#define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2)
Christopher Ferris38062f92014-07-09 15:33:25 -0700472#define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700473#define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_msr_list)
Ben Cheng655a7c02013-10-16 16:09:24 -0700474#define KVM_CAP_IRQCHIP 0
475#define KVM_CAP_HLT 1
476#define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2
477#define KVM_CAP_USER_MEMORY 3
Ben Cheng655a7c02013-10-16 16:09:24 -0700478#define KVM_CAP_SET_TSS_ADDR 4
479#define KVM_CAP_VAPIC 6
480#define KVM_CAP_EXT_CPUID 7
481#define KVM_CAP_CLOCKSOURCE 8
Ben Cheng655a7c02013-10-16 16:09:24 -0700482#define KVM_CAP_NR_VCPUS 9
483#define KVM_CAP_NR_MEMSLOTS 10
484#define KVM_CAP_PIT 11
485#define KVM_CAP_NOP_IO_DELAY 12
Ben Cheng655a7c02013-10-16 16:09:24 -0700486#define KVM_CAP_PV_MMU 13
487#define KVM_CAP_MP_STATE 14
488#define KVM_CAP_COALESCED_MMIO 15
489#define KVM_CAP_SYNC_MMU 16
Ben Cheng655a7c02013-10-16 16:09:24 -0700490#define KVM_CAP_IOMMU 18
Ben Cheng655a7c02013-10-16 16:09:24 -0700491#define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21
Ben Cheng655a7c02013-10-16 16:09:24 -0700492#define KVM_CAP_USER_NMI 22
Ben Cheng655a7c02013-10-16 16:09:24 -0700493#define KVM_CAP_SET_GUEST_DEBUG 23
Ben Cheng655a7c02013-10-16 16:09:24 -0700494#ifdef __KVM_HAVE_PIT
495#define KVM_CAP_REINJECT_CONTROL 24
496#endif
497#define KVM_CAP_IRQ_ROUTING 25
Ben Cheng655a7c02013-10-16 16:09:24 -0700498#define KVM_CAP_IRQ_INJECT_STATUS 26
Ben Cheng655a7c02013-10-16 16:09:24 -0700499#define KVM_CAP_ASSIGN_DEV_IRQ 29
500#define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30
501#ifdef __KVM_HAVE_MCE
Ben Cheng655a7c02013-10-16 16:09:24 -0700502#define KVM_CAP_MCE 31
503#endif
504#define KVM_CAP_IRQFD 32
505#ifdef __KVM_HAVE_PIT
Ben Cheng655a7c02013-10-16 16:09:24 -0700506#define KVM_CAP_PIT2 33
507#endif
508#define KVM_CAP_SET_BOOT_CPU_ID 34
509#ifdef __KVM_HAVE_PIT_STATE2
Ben Cheng655a7c02013-10-16 16:09:24 -0700510#define KVM_CAP_PIT_STATE2 35
511#endif
512#define KVM_CAP_IOEVENTFD 36
513#define KVM_CAP_SET_IDENTITY_MAP_ADDR 37
Ben Cheng655a7c02013-10-16 16:09:24 -0700514#ifdef __KVM_HAVE_XEN_HVM
515#define KVM_CAP_XEN_HVM 38
516#endif
517#define KVM_CAP_ADJUST_CLOCK 39
Ben Cheng655a7c02013-10-16 16:09:24 -0700518#define KVM_CAP_INTERNAL_ERROR_DATA 40
519#ifdef __KVM_HAVE_VCPU_EVENTS
520#define KVM_CAP_VCPU_EVENTS 41
521#endif
Ben Cheng655a7c02013-10-16 16:09:24 -0700522#define KVM_CAP_S390_PSW 42
523#define KVM_CAP_PPC_SEGSTATE 43
524#define KVM_CAP_HYPERV 44
525#define KVM_CAP_HYPERV_VAPIC 45
Ben Cheng655a7c02013-10-16 16:09:24 -0700526#define KVM_CAP_HYPERV_SPIN 46
527#define KVM_CAP_PCI_SEGMENT 47
528#define KVM_CAP_PPC_PAIRED_SINGLES 48
529#define KVM_CAP_INTR_SHADOW 49
Ben Cheng655a7c02013-10-16 16:09:24 -0700530#ifdef __KVM_HAVE_DEBUGREGS
531#define KVM_CAP_DEBUGREGS 50
532#endif
533#define KVM_CAP_X86_ROBUST_SINGLESTEP 51
Ben Cheng655a7c02013-10-16 16:09:24 -0700534#define KVM_CAP_PPC_OSI 52
535#define KVM_CAP_PPC_UNSET_IRQ 53
536#define KVM_CAP_ENABLE_CAP 54
537#ifdef __KVM_HAVE_XSAVE
Ben Cheng655a7c02013-10-16 16:09:24 -0700538#define KVM_CAP_XSAVE 55
539#endif
540#ifdef __KVM_HAVE_XCRS
541#define KVM_CAP_XCRS 56
Ben Cheng655a7c02013-10-16 16:09:24 -0700542#endif
543#define KVM_CAP_PPC_GET_PVINFO 57
544#define KVM_CAP_PPC_IRQ_LEVEL 58
545#define KVM_CAP_ASYNC_PF 59
Ben Cheng655a7c02013-10-16 16:09:24 -0700546#define KVM_CAP_TSC_CONTROL 60
547#define KVM_CAP_GET_TSC_KHZ 61
548#define KVM_CAP_PPC_BOOKE_SREGS 62
549#define KVM_CAP_SPAPR_TCE 63
Ben Cheng655a7c02013-10-16 16:09:24 -0700550#define KVM_CAP_PPC_SMT 64
551#define KVM_CAP_PPC_RMA 65
552#define KVM_CAP_MAX_VCPUS 66
553#define KVM_CAP_PPC_HIOR 67
Ben Cheng655a7c02013-10-16 16:09:24 -0700554#define KVM_CAP_PPC_PAPR 68
555#define KVM_CAP_SW_TLB 69
556#define KVM_CAP_ONE_REG 70
557#define KVM_CAP_S390_GMAP 71
Ben Cheng655a7c02013-10-16 16:09:24 -0700558#define KVM_CAP_TSC_DEADLINE_TIMER 72
559#define KVM_CAP_S390_UCONTROL 73
560#define KVM_CAP_SYNC_REGS 74
561#define KVM_CAP_PCI_2_3 75
Ben Cheng655a7c02013-10-16 16:09:24 -0700562#define KVM_CAP_KVMCLOCK_CTRL 76
563#define KVM_CAP_SIGNAL_MSI 77
564#define KVM_CAP_PPC_GET_SMMU_INFO 78
565#define KVM_CAP_S390_COW 79
Christopher Ferris82d75042015-01-26 10:57:07 -0800566#define KVM_CAP_PPC_ALLOC_HTAB 80
Ben Cheng655a7c02013-10-16 16:09:24 -0700567#define KVM_CAP_READONLY_MEM 81
Ben Cheng655a7c02013-10-16 16:09:24 -0700568#define KVM_CAP_IRQFD_RESAMPLE 82
569#define KVM_CAP_PPC_BOOKE_WATCHDOG 83
570#define KVM_CAP_PPC_HTAB_FD 84
571#define KVM_CAP_S390_CSS_SUPPORT 85
Ben Cheng655a7c02013-10-16 16:09:24 -0700572#define KVM_CAP_PPC_EPR 86
573#define KVM_CAP_ARM_PSCI 87
574#define KVM_CAP_ARM_SET_DEVICE_ADDR 88
575#define KVM_CAP_DEVICE_CTRL 89
Ben Cheng655a7c02013-10-16 16:09:24 -0700576#define KVM_CAP_IRQ_MPIC 90
577#define KVM_CAP_PPC_RTAS 91
578#define KVM_CAP_IRQ_XICS 92
Christopher Ferris38062f92014-07-09 15:33:25 -0700579#define KVM_CAP_ARM_EL1_32BIT 93
580#define KVM_CAP_SPAPR_MULTITCE 94
Christopher Ferris38062f92014-07-09 15:33:25 -0700581#define KVM_CAP_EXT_EMUL_CPUID 95
582#define KVM_CAP_HYPERV_TIME 96
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700583#define KVM_CAP_IOAPIC_POLARITY_IGNORED 97
584#define KVM_CAP_ENABLE_CAP_VM 98
585#define KVM_CAP_S390_IRQCHIP 99
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700586#define KVM_CAP_IOEVENTFD_NO_LENGTH 100
587#define KVM_CAP_VM_ATTRIBUTES 101
588#define KVM_CAP_ARM_PSCI_0_2 102
589#define KVM_CAP_PPC_FIXUP_HCALL 103
Christopher Ferris82d75042015-01-26 10:57:07 -0800590#define KVM_CAP_PPC_ENABLE_HCALL 104
591#define KVM_CAP_CHECK_EXTENSION_VM 105
Christopher Ferris05d08e92016-02-04 13:16:38 -0800592#define KVM_CAP_S390_USER_SIGP 106
593#define KVM_CAP_S390_VECTOR_REGISTERS 107
Christopher Ferris05d08e92016-02-04 13:16:38 -0800594#define KVM_CAP_S390_MEM_OP 108
595#define KVM_CAP_S390_USER_STSI 109
596#define KVM_CAP_S390_SKEYS 110
597#define KVM_CAP_MIPS_FPU 111
Christopher Ferris05d08e92016-02-04 13:16:38 -0800598#define KVM_CAP_MIPS_MSA 112
599#define KVM_CAP_S390_INJECT_IRQ 113
600#define KVM_CAP_S390_IRQ_STATE 114
601#define KVM_CAP_PPC_HWRNG 115
Christopher Ferris05d08e92016-02-04 13:16:38 -0800602#define KVM_CAP_DISABLE_QUIRKS 116
603#define KVM_CAP_X86_SMM 117
604#define KVM_CAP_MULTI_ADDRESS_SPACE 118
605#define KVM_CAP_GUEST_DEBUG_HW_BPS 119
Christopher Ferris05d08e92016-02-04 13:16:38 -0800606#define KVM_CAP_GUEST_DEBUG_HW_WPS 120
607#define KVM_CAP_SPLIT_IRQCHIP 121
608#define KVM_CAP_IOEVENTFD_ANY_LENGTH 122
Christopher Ferris106b3a82016-08-24 12:15:38 -0700609#define KVM_CAP_HYPERV_SYNIC 123
610#define KVM_CAP_S390_RI 124
611#define KVM_CAP_SPAPR_TCE_64 125
Christopher Ferris106b3a82016-08-24 12:15:38 -0700612#define KVM_CAP_ARM_PMU_V3 126
613#define KVM_CAP_VCPU_ATTRIBUTES 127
614#define KVM_CAP_MAX_VCPU_ID 128
Christopher Ferris49f525c2016-12-12 14:55:36 -0800615#define KVM_CAP_X2APIC_API 129
Christopher Ferris49f525c2016-12-12 14:55:36 -0800616#define KVM_CAP_S390_USER_INSTR0 130
617#define KVM_CAP_MSI_DEVID 131
618#define KVM_CAP_PPC_HTM 132
Christopher Ferris525ce912017-07-26 13:12:53 -0700619#define KVM_CAP_SPAPR_RESIZE_HPT 133
620#define KVM_CAP_PPC_MMU_RADIX 134
621#define KVM_CAP_PPC_MMU_HASH_V3 135
622#define KVM_CAP_IMMEDIATE_EXIT 136
623#define KVM_CAP_MIPS_VZ 137
624#define KVM_CAP_MIPS_TE 138
625#define KVM_CAP_MIPS_64BIT 139
626#define KVM_CAP_S390_GS 140
627#define KVM_CAP_S390_AIS 141
628#define KVM_CAP_SPAPR_TCE_VFIO 142
Christopher Ferris76a1d452018-06-27 14:12:29 -0700629#define KVM_CAP_X86_DISABLE_EXITS 143
Christopher Ferris525ce912017-07-26 13:12:53 -0700630#define KVM_CAP_ARM_USER_IRQ 144
Christopher Ferris1308ad32017-11-14 17:32:13 -0800631#define KVM_CAP_S390_CMMA_MIGRATION 145
632#define KVM_CAP_PPC_FWNMI 146
633#define KVM_CAP_PPC_SMT_POSSIBLE 147
634#define KVM_CAP_HYPERV_SYNIC2 148
635#define KVM_CAP_HYPERV_VP_INDEX 149
Christopher Ferris934ec942018-01-31 15:29:16 -0800636#define KVM_CAP_S390_AIS_MIGRATION 150
637#define KVM_CAP_PPC_GET_CPU_CHAR 151
638#define KVM_CAP_S390_BPB 152
Christopher Ferris76a1d452018-06-27 14:12:29 -0700639#define KVM_CAP_GET_MSR_FEATURES 153
640#define KVM_CAP_HYPERV_EVENTFD 154
Christopher Ferris9ce28842018-10-25 12:11:39 -0700641#define KVM_CAP_HYPERV_TLBFLUSH 155
642#define KVM_CAP_S390_HPAGE_1M 156
643#define KVM_CAP_NESTED_STATE 157
644#define KVM_CAP_ARM_INJECT_SERROR_ESR 158
645#define KVM_CAP_MSR_PLATFORM_INFO 159
Christopher Ferris86a48372019-01-10 14:14:59 -0800646#define KVM_CAP_PPC_NESTED_HV 160
647#define KVM_CAP_HYPERV_SEND_IPI 161
648#define KVM_CAP_COALESCED_PIO 162
649#define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163
650#define KVM_CAP_EXCEPTION_PAYLOAD 164
651#define KVM_CAP_ARM_VM_IPA_SIZE 165
Christopher Ferrisd842e432019-03-07 10:21:59 -0800652#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166
653#define KVM_CAP_HYPERV_CPUID 167
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700654#define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 168
655#define KVM_CAP_PPC_IRQ_XIVE 169
656#define KVM_CAP_ARM_SVE 170
657#define KVM_CAP_ARM_PTRAUTH_ADDRESS 171
658#define KVM_CAP_ARM_PTRAUTH_GENERIC 172
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700659#define KVM_CAP_PMU_EVENT_FILTER 173
Christopher Ferris9584fa42019-12-09 15:36:13 -0800660#define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174
661#define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800662#define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 176
663#define KVM_CAP_ARM_NISV_TO_USER 177
664#define KVM_CAP_ARM_INJECT_EXT_DABT 178
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700665#define KVM_CAP_S390_VCPU_RESETS 179
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700666#define KVM_CAP_S390_PROTECTED 180
667#define KVM_CAP_PPC_SECURE_GUEST 181
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700668#define KVM_CAP_HALT_POLL 182
669#define KVM_CAP_ASYNC_PF_INT 183
Christopher Ferris25c18d42020-10-14 17:42:58 -0700670#define KVM_CAP_LAST_CPU 184
671#define KVM_CAP_SMALLER_MAXPHYADDR 185
672#define KVM_CAP_S390_DIAG318 186
673#define KVM_CAP_STEAL_TIME 187
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800674#define KVM_CAP_X86_USER_SPACE_MSR 188
675#define KVM_CAP_X86_MSR_FILTER 189
676#define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190
Christopher Ferris05667cd2021-02-16 16:01:34 -0800677#define KVM_CAP_SYS_HYPERV_CPUID 191
678#define KVM_CAP_DIRTY_LOG_RING 192
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700679#define KVM_CAP_X86_BUS_LOCK_EXIT 193
680#define KVM_CAP_PPC_DAWR1 194
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000681#define KVM_CAP_SET_GUEST_DEBUG2 195
682#define KVM_CAP_SGX_ATTRIBUTE 196
683#define KVM_CAP_VM_COPY_ENC_CONTEXT_FROM 197
684#define KVM_CAP_PTP_KVM 198
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000685#define KVM_CAP_HYPERV_ENFORCE_CPUID 199
686#define KVM_CAP_SREGS2 200
687#define KVM_CAP_EXIT_HYPERCALL 201
688#define KVM_CAP_PPC_RPT_INVALIDATE 202
689#define KVM_CAP_BINARY_STATS_FD 203
690#define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204
691#define KVM_CAP_ARM_MTE 205
Christopher Ferrisa4792612022-01-10 13:51:15 -0800692#define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206
Christopher Ferris1ed55342022-03-22 16:06:25 -0700693#define KVM_CAP_VM_GPA_BITS 207
694#define KVM_CAP_XSAVE2 208
695#define KVM_CAP_SYS_ATTRIBUTES 209
696#define KVM_CAP_PPC_AIL_MODE_3 210
Christopher Ferris10a76e62022-06-08 13:31:52 -0700697#define KVM_CAP_S390_MEM_OP_EXTENSION 211
698#define KVM_CAP_PMU_CAPABILITY 212
699#define KVM_CAP_DISABLE_QUIRKS2 213
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700700#define KVM_CAP_VM_TSC_CONTROL 214
Christopher Ferris10a76e62022-06-08 13:31:52 -0700701#define KVM_CAP_SYSTEM_EVENT_DATA 215
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700702#define KVM_CAP_ARM_SYSTEM_SUSPEND 216
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700703#define KVM_CAP_S390_PROTECTED_DUMP 217
704#define KVM_CAP_X86_TRIPLE_FAULT_EVENT 218
705#define KVM_CAP_X86_NOTIFY_VMEXIT 219
706#define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220
707#define KVM_CAP_S390_ZPCI_OP 221
708#define KVM_CAP_S390_CPU_TOPOLOGY 222
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000709#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800710#define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224
711#define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000712#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700713#define KVM_CAP_COUNTER_OFFSET 227
Christopher Ferris8666d042023-09-06 14:55:31 -0700714#define KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 228
715#define KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES 229
Christopher Ferris0f795212024-01-17 14:17:28 -0800716#define KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES 230
Christopher Ferrisb830ddf2024-03-28 11:48:08 -0700717#define KVM_CAP_USER_MEMORY2 231
718#define KVM_CAP_MEMORY_FAULT_INFO 232
719#define KVM_CAP_MEMORY_ATTRIBUTES 233
720#define KVM_CAP_GUEST_MEMFD 234
721#define KVM_CAP_VM_TYPES 235
Christopher Ferris05d08e92016-02-04 13:16:38 -0800722struct kvm_irq_routing_irqchip {
Tao Baod7db5942015-01-28 10:07:51 -0800723 __u32 irqchip;
724 __u32 pin;
Ben Cheng655a7c02013-10-16 16:09:24 -0700725};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800726struct kvm_irq_routing_msi {
Tao Baod7db5942015-01-28 10:07:51 -0800727 __u32 address_lo;
728 __u32 address_hi;
729 __u32 data;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800730 union {
731 __u32 pad;
732 __u32 devid;
733 };
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700734};
735struct kvm_irq_routing_s390_adapter {
Tao Baod7db5942015-01-28 10:07:51 -0800736 __u64 ind_addr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800737 __u64 summary_addr;
Tao Baod7db5942015-01-28 10:07:51 -0800738 __u64 ind_offset;
739 __u32 summary_offset;
740 __u32 adapter_id;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800741};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700742struct kvm_irq_routing_hv_sint {
743 __u32 vcpu;
744 __u32 sint;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700745};
Christopher Ferris1ed55342022-03-22 16:06:25 -0700746struct kvm_irq_routing_xen_evtchn {
747 __u32 port;
748 __u32 vcpu;
749 __u32 priority;
750};
751#define KVM_IRQ_ROUTING_XEN_EVTCHN_PRIO_2LEVEL ((__u32) (- 1))
Ben Cheng655a7c02013-10-16 16:09:24 -0700752#define KVM_IRQ_ROUTING_IRQCHIP 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700753#define KVM_IRQ_ROUTING_MSI 2
Christopher Ferrisba8d4f42014-09-03 19:56:49 -0700754#define KVM_IRQ_ROUTING_S390_ADAPTER 3
Christopher Ferris106b3a82016-08-24 12:15:38 -0700755#define KVM_IRQ_ROUTING_HV_SINT 4
Christopher Ferris1ed55342022-03-22 16:06:25 -0700756#define KVM_IRQ_ROUTING_XEN_EVTCHN 5
Christopher Ferris05d08e92016-02-04 13:16:38 -0800757struct kvm_irq_routing_entry {
Tao Baod7db5942015-01-28 10:07:51 -0800758 __u32 gsi;
759 __u32 type;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700760 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800761 __u32 pad;
Tao Baod7db5942015-01-28 10:07:51 -0800762 union {
763 struct kvm_irq_routing_irqchip irqchip;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700764 struct kvm_irq_routing_msi msi;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800765 struct kvm_irq_routing_s390_adapter adapter;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700766 struct kvm_irq_routing_hv_sint hv_sint;
Christopher Ferris1ed55342022-03-22 16:06:25 -0700767 struct kvm_irq_routing_xen_evtchn xen_evtchn;
Tao Baod7db5942015-01-28 10:07:51 -0800768 __u32 pad[8];
769 } u;
Ben Cheng655a7c02013-10-16 16:09:24 -0700770};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800771struct kvm_irq_routing {
Tao Baod7db5942015-01-28 10:07:51 -0800772 __u32 nr;
773 __u32 flags;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700774 struct kvm_irq_routing_entry entries[];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800775};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800776#define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)
Ben Cheng655a7c02013-10-16 16:09:24 -0700777#define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
778struct kvm_irqfd {
Tao Baod7db5942015-01-28 10:07:51 -0800779 __u32 fd;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800780 __u32 gsi;
Tao Baod7db5942015-01-28 10:07:51 -0800781 __u32 flags;
782 __u32 resamplefd;
783 __u8 pad[16];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800784};
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800785#define KVM_CLOCK_TSC_STABLE 2
Christopher Ferrisa4792612022-01-10 13:51:15 -0800786#define KVM_CLOCK_REALTIME (1 << 2)
787#define KVM_CLOCK_HOST_TSC (1 << 3)
Ben Cheng655a7c02013-10-16 16:09:24 -0700788struct kvm_clock_data {
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800789 __u64 clock;
Tao Baod7db5942015-01-28 10:07:51 -0800790 __u32 flags;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800791 __u32 pad0;
792 __u64 realtime;
793 __u64 host_tsc;
794 __u32 pad[4];
Ben Cheng655a7c02013-10-16 16:09:24 -0700795};
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800796#define KVM_MMU_FSL_BOOKE_NOHV 0
Ben Cheng655a7c02013-10-16 16:09:24 -0700797#define KVM_MMU_FSL_BOOKE_HV 1
Christopher Ferris05d08e92016-02-04 13:16:38 -0800798struct kvm_config_tlb {
Tao Baod7db5942015-01-28 10:07:51 -0800799 __u64 params;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800800 __u64 array;
Tao Baod7db5942015-01-28 10:07:51 -0800801 __u32 mmu_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800802 __u32 array_len;
Ben Cheng655a7c02013-10-16 16:09:24 -0700803};
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800804struct kvm_dirty_tlb {
Tao Baod7db5942015-01-28 10:07:51 -0800805 __u64 bitmap;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800806 __u32 num_dirty;
Ben Cheng655a7c02013-10-16 16:09:24 -0700807};
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800808#define KVM_REG_ARCH_MASK 0xff00000000000000ULL
Ben Cheng655a7c02013-10-16 16:09:24 -0700809#define KVM_REG_GENERIC 0x0000000000000000ULL
Christopher Ferris05d08e92016-02-04 13:16:38 -0800810#define KVM_REG_PPC 0x1000000000000000ULL
Ben Cheng655a7c02013-10-16 16:09:24 -0700811#define KVM_REG_X86 0x2000000000000000ULL
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800812#define KVM_REG_IA64 0x3000000000000000ULL
Ben Cheng655a7c02013-10-16 16:09:24 -0700813#define KVM_REG_ARM 0x4000000000000000ULL
Christopher Ferris05d08e92016-02-04 13:16:38 -0800814#define KVM_REG_S390 0x5000000000000000ULL
Christopher Ferris38062f92014-07-09 15:33:25 -0700815#define KVM_REG_ARM64 0x6000000000000000ULL
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800816#define KVM_REG_MIPS 0x7000000000000000ULL
Christopher Ferris9584fa42019-12-09 15:36:13 -0800817#define KVM_REG_RISCV 0x8000000000000000ULL
Christopher Ferris0f795212024-01-17 14:17:28 -0800818#define KVM_REG_LOONGARCH 0x9000000000000000ULL
Ben Cheng655a7c02013-10-16 16:09:24 -0700819#define KVM_REG_SIZE_SHIFT 52
Christopher Ferris05d08e92016-02-04 13:16:38 -0800820#define KVM_REG_SIZE_MASK 0x00f0000000000000ULL
Ben Cheng655a7c02013-10-16 16:09:24 -0700821#define KVM_REG_SIZE_U8 0x0000000000000000ULL
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800822#define KVM_REG_SIZE_U16 0x0010000000000000ULL
Ben Cheng655a7c02013-10-16 16:09:24 -0700823#define KVM_REG_SIZE_U32 0x0020000000000000ULL
Christopher Ferris05d08e92016-02-04 13:16:38 -0800824#define KVM_REG_SIZE_U64 0x0030000000000000ULL
Ben Cheng655a7c02013-10-16 16:09:24 -0700825#define KVM_REG_SIZE_U128 0x0040000000000000ULL
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800826#define KVM_REG_SIZE_U256 0x0050000000000000ULL
Ben Cheng655a7c02013-10-16 16:09:24 -0700827#define KVM_REG_SIZE_U512 0x0060000000000000ULL
Christopher Ferris05d08e92016-02-04 13:16:38 -0800828#define KVM_REG_SIZE_U1024 0x0070000000000000ULL
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700829#define KVM_REG_SIZE_U2048 0x0080000000000000ULL
Ben Cheng655a7c02013-10-16 16:09:24 -0700830struct kvm_reg_list {
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800831 __u64 n;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700832 __u64 reg[];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800833};
Ben Cheng655a7c02013-10-16 16:09:24 -0700834struct kvm_one_reg {
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800835 __u64 id;
Tao Baod7db5942015-01-28 10:07:51 -0800836 __u64 addr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800837};
Christopher Ferris49f525c2016-12-12 14:55:36 -0800838#define KVM_MSI_VALID_DEVID (1U << 0)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800839struct kvm_msi {
Tao Baod7db5942015-01-28 10:07:51 -0800840 __u32 address_lo;
841 __u32 address_hi;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800842 __u32 data;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800843 __u32 flags;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800844 __u32 devid;
845 __u8 pad[12];
Ben Cheng655a7c02013-10-16 16:09:24 -0700846};
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800847struct kvm_arm_device_addr {
Christopher Ferris49f525c2016-12-12 14:55:36 -0800848 __u64 id;
Tao Baod7db5942015-01-28 10:07:51 -0800849 __u64 addr;
Ben Cheng655a7c02013-10-16 16:09:24 -0700850};
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800851#define KVM_CREATE_DEVICE_TEST 1
Christopher Ferris49f525c2016-12-12 14:55:36 -0800852struct kvm_create_device {
Tao Baod7db5942015-01-28 10:07:51 -0800853 __u32 type;
854 __u32 fd;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800855 __u32 flags;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800856};
Ben Cheng655a7c02013-10-16 16:09:24 -0700857struct kvm_device_attr {
Tao Baod7db5942015-01-28 10:07:51 -0800858 __u32 flags;
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800859 __u32 group;
Christopher Ferris49f525c2016-12-12 14:55:36 -0800860 __u64 attr;
Tao Baod7db5942015-01-28 10:07:51 -0800861 __u64 addr;
Ben Cheng655a7c02013-10-16 16:09:24 -0700862};
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700863#define KVM_DEV_VFIO_FILE 1
864#define KVM_DEV_VFIO_FILE_ADD 1
865#define KVM_DEV_VFIO_FILE_DEL 2
866#define KVM_DEV_VFIO_GROUP KVM_DEV_VFIO_FILE
867#define KVM_DEV_VFIO_GROUP_ADD KVM_DEV_VFIO_FILE_ADD
868#define KVM_DEV_VFIO_GROUP_DEL KVM_DEV_VFIO_FILE_DEL
Christopher Ferris525ce912017-07-26 13:12:53 -0700869#define KVM_DEV_VFIO_GROUP_SET_SPAPR_TCE 3
Christopher Ferris82d75042015-01-26 10:57:07 -0800870enum kvm_device_type {
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800871 KVM_DEV_TYPE_FSL_MPIC_20 = 1,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800872#define KVM_DEV_TYPE_FSL_MPIC_20 KVM_DEV_TYPE_FSL_MPIC_20
Tao Baod7db5942015-01-28 10:07:51 -0800873 KVM_DEV_TYPE_FSL_MPIC_42,
Christopher Ferris82d75042015-01-26 10:57:07 -0800874#define KVM_DEV_TYPE_FSL_MPIC_42 KVM_DEV_TYPE_FSL_MPIC_42
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800875 KVM_DEV_TYPE_XICS,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800876#define KVM_DEV_TYPE_XICS KVM_DEV_TYPE_XICS
Tao Baod7db5942015-01-28 10:07:51 -0800877 KVM_DEV_TYPE_VFIO,
Christopher Ferris82d75042015-01-26 10:57:07 -0800878#define KVM_DEV_TYPE_VFIO KVM_DEV_TYPE_VFIO
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800879 KVM_DEV_TYPE_ARM_VGIC_V2,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800880#define KVM_DEV_TYPE_ARM_VGIC_V2 KVM_DEV_TYPE_ARM_VGIC_V2
Tao Baod7db5942015-01-28 10:07:51 -0800881 KVM_DEV_TYPE_FLIC,
Christopher Ferris82d75042015-01-26 10:57:07 -0800882#define KVM_DEV_TYPE_FLIC KVM_DEV_TYPE_FLIC
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800883 KVM_DEV_TYPE_ARM_VGIC_V3,
Christopher Ferris49f525c2016-12-12 14:55:36 -0800884#define KVM_DEV_TYPE_ARM_VGIC_V3 KVM_DEV_TYPE_ARM_VGIC_V3
885 KVM_DEV_TYPE_ARM_VGIC_ITS,
886#define KVM_DEV_TYPE_ARM_VGIC_ITS KVM_DEV_TYPE_ARM_VGIC_ITS
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700887 KVM_DEV_TYPE_XIVE,
888#define KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_XIVE
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800889 KVM_DEV_TYPE_ARM_PV_TIME,
890#define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME
Christopher Ferris8666d042023-09-06 14:55:31 -0700891 KVM_DEV_TYPE_RISCV_AIA,
892#define KVM_DEV_TYPE_RISCV_AIA KVM_DEV_TYPE_RISCV_AIA
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800893 KVM_DEV_TYPE_MAX,
Christopher Ferris82d75042015-01-26 10:57:07 -0800894};
Christopher Ferris525ce912017-07-26 13:12:53 -0700895struct kvm_vfio_spapr_tce {
896 __s32 groupfd;
897 __s32 tablefd;
898};
Ben Cheng655a7c02013-10-16 16:09:24 -0700899#define KVM_CREATE_VCPU _IO(KVMIO, 0x41)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800900#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log)
Ben Cheng655a7c02013-10-16 16:09:24 -0700901#define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44)
Ben Cheng655a7c02013-10-16 16:09:24 -0700902#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800903#define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, struct kvm_userspace_memory_region)
Ben Cheng655a7c02013-10-16 16:09:24 -0700904#define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47)
905#define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64)
Christopher Ferrisb830ddf2024-03-28 11:48:08 -0700906#define KVM_SET_USER_MEMORY_REGION2 _IOW(KVMIO, 0x49, struct kvm_userspace_memory_region2)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800907#define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping)
Ben Cheng655a7c02013-10-16 16:09:24 -0700908#define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping)
909#define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long)
Ben Cheng655a7c02013-10-16 16:09:24 -0700910#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800911#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level)
Ben Cheng655a7c02013-10-16 16:09:24 -0700912#define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip)
913#define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip)
Ben Cheng655a7c02013-10-16 16:09:24 -0700914#define KVM_CREATE_PIT _IO(KVMIO, 0x64)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800915#define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state)
Ben Cheng655a7c02013-10-16 16:09:24 -0700916#define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state)
917#define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level)
Tao Baod7db5942015-01-28 10:07:51 -0800918#define KVM_REGISTER_COALESCED_MMIO _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800919#define KVM_UNREGISTER_COALESCED_MMIO _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone)
Ben Cheng655a7c02013-10-16 16:09:24 -0700920#define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing)
Ben Cheng655a7c02013-10-16 16:09:24 -0700921#define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71)
Ben Cheng655a7c02013-10-16 16:09:24 -0700922#define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd)
Ben Cheng655a7c02013-10-16 16:09:24 -0700923#define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800924#define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78)
Ben Cheng655a7c02013-10-16 16:09:24 -0700925#define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd)
926#define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config)
Ben Cheng655a7c02013-10-16 16:09:24 -0700927#define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800928#define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data)
Ben Cheng655a7c02013-10-16 16:09:24 -0700929#define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2)
930#define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700931#define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800932#define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700933#define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3)
Ben Cheng655a7c02013-10-16 16:09:24 -0700934#define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800935#define KVM_PPC_GET_SMMU_INFO _IOR(KVMIO, 0xa6, struct kvm_ppc_smmu_info)
Ben Cheng655a7c02013-10-16 16:09:24 -0700936#define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32)
937#define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700938#define KVM_CREATE_SPAPR_TCE_64 _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce_64)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800939#define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma)
Christopher Ferris38062f92014-07-09 15:33:25 -0700940#define KVM_PPC_GET_HTAB_FD _IOW(KVMIO, 0xaa, struct kvm_get_htab_fd)
Ben Cheng655a7c02013-10-16 16:09:24 -0700941#define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr)
942#define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO, 0xac, struct kvm_rtas_token_args)
Christopher Ferris525ce912017-07-26 13:12:53 -0700943#define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt)
944#define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt)
945#define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg)
946#define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info)
Christopher Ferris934ec942018-01-31 15:29:16 -0800947#define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700948#define KVM_SET_PMU_EVENT_FILTER _IOW(KVMIO, 0xb2, struct kvm_pmu_event_filter)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800949#define KVM_PPC_SVM_OFF _IO(KVMIO, 0xb3)
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000950#define KVM_ARM_MTE_COPY_TAGS _IOR(KVMIO, 0xb4, struct kvm_arm_copy_mte_tags)
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700951#define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO, 0xb5, struct kvm_arm_counter_offset)
Christopher Ferris0f795212024-01-17 14:17:28 -0800952#define KVM_ARM_GET_REG_WRITABLE_MASKS _IOR(KVMIO, 0xb6, struct reg_mask_range)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800953#define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device)
Christopher Ferris38062f92014-07-09 15:33:25 -0700954#define KVM_SET_DEVICE_ATTR _IOW(KVMIO, 0xe1, struct kvm_device_attr)
Ben Cheng655a7c02013-10-16 16:09:24 -0700955#define KVM_GET_DEVICE_ATTR _IOW(KVMIO, 0xe2, struct kvm_device_attr)
956#define KVM_HAS_DEVICE_ATTR _IOW(KVMIO, 0xe3, struct kvm_device_attr)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800957#define KVM_RUN _IO(KVMIO, 0x80)
Christopher Ferris38062f92014-07-09 15:33:25 -0700958#define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs)
Ben Cheng655a7c02013-10-16 16:09:24 -0700959#define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs)
960#define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800961#define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs)
Christopher Ferris38062f92014-07-09 15:33:25 -0700962#define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation)
Ben Cheng655a7c02013-10-16 16:09:24 -0700963#define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800964#define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs)
Christopher Ferris38062f92014-07-09 15:33:25 -0700965#define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs)
Ben Cheng655a7c02013-10-16 16:09:24 -0700966#define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid)
967#define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800968#define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu)
Christopher Ferris38062f92014-07-09 15:33:25 -0700969#define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu)
Ben Cheng655a7c02013-10-16 16:09:24 -0700970#define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state)
971#define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800972#define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2)
Christopher Ferris38062f92014-07-09 15:33:25 -0700973#define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700974#define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)
975#define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800976#define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt)
Tao Baod7db5942015-01-28 10:07:51 -0800977#define KVM_S390_STORE_STATUS_NOADDR (- 1ul)
Tao Baod7db5942015-01-28 10:07:51 -0800978#define KVM_S390_STORE_STATUS_PREFIXED (- 2ul)
Ben Cheng655a7c02013-10-16 16:09:24 -0700979#define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800980#define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw)
Christopher Ferris38062f92014-07-09 15:33:25 -0700981#define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97)
Ben Cheng655a7c02013-10-16 16:09:24 -0700982#define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state)
983#define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800984#define KVM_NMI _IO(KVMIO, 0x9a)
Christopher Ferris38062f92014-07-09 15:33:25 -0700985#define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug)
Ben Cheng655a7c02013-10-16 16:09:24 -0700986#define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64)
987#define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800988#define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce)
Ben Cheng655a7c02013-10-16 16:09:24 -0700989#define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events)
Ben Cheng655a7c02013-10-16 16:09:24 -0700990#define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800991#define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800992#define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs)
Ben Cheng655a7c02013-10-16 16:09:24 -0700993#define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap)
Ben Cheng655a7c02013-10-16 16:09:24 -0700994#define KVM_GET_XSAVE _IOR(KVMIO, 0xa4, struct kvm_xsave)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800995#define KVM_SET_XSAVE _IOW(KVMIO, 0xa5, struct kvm_xsave)
Christopher Ferris6a9755d2017-01-13 14:09:31 -0800996#define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs)
Ben Cheng655a7c02013-10-16 16:09:24 -0700997#define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs)
Ben Cheng655a7c02013-10-16 16:09:24 -0700998#define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800999#define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg)
Christopher Ferris6a9755d2017-01-13 14:09:31 -08001000#define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg)
Ben Cheng655a7c02013-10-16 16:09:24 -07001001#define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad)
Ben Cheng655a7c02013-10-16 16:09:24 -07001002#define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init)
Christopher Ferris05d08e92016-02-04 13:16:38 -08001003#define KVM_ARM_PREFERRED_TARGET _IOR(KVMIO, 0xaf, struct kvm_vcpu_init)
Christopher Ferris6a9755d2017-01-13 14:09:31 -08001004#define KVM_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list)
Christopher Ferris05d08e92016-02-04 13:16:38 -08001005#define KVM_S390_MEM_OP _IOW(KVMIO, 0xb1, struct kvm_s390_mem_op)
1006#define KVM_S390_GET_SKEYS _IOW(KVMIO, 0xb2, struct kvm_s390_skeys)
Christopher Ferris05d08e92016-02-04 13:16:38 -08001007#define KVM_S390_SET_SKEYS _IOW(KVMIO, 0xb3, struct kvm_s390_skeys)
Christopher Ferris6a9755d2017-01-13 14:09:31 -08001008#define KVM_S390_IRQ _IOW(KVMIO, 0xb4, struct kvm_s390_irq)
Christopher Ferris05d08e92016-02-04 13:16:38 -08001009#define KVM_S390_SET_IRQ_STATE _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state)
1010#define KVM_S390_GET_IRQ_STATE _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state)
Christopher Ferris05d08e92016-02-04 13:16:38 -08001011#define KVM_SMI _IO(KVMIO, 0xb7)
Christopher Ferris1308ad32017-11-14 17:32:13 -08001012#define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log)
1013#define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log)
Christopher Ferris76a1d452018-06-27 14:12:29 -07001014#define KVM_MEMORY_ENCRYPT_OP _IOWR(KVMIO, 0xba, unsigned long)
1015struct kvm_enc_region {
1016 __u64 addr;
1017 __u64 size;
1018};
1019#define KVM_MEMORY_ENCRYPT_REG_REGION _IOR(KVMIO, 0xbb, struct kvm_enc_region)
1020#define KVM_MEMORY_ENCRYPT_UNREG_REGION _IOR(KVMIO, 0xbc, struct kvm_enc_region)
1021#define KVM_HYPERV_EVENTFD _IOW(KVMIO, 0xbd, struct kvm_hyperv_eventfd)
Christopher Ferris9ce28842018-10-25 12:11:39 -07001022#define KVM_GET_NESTED_STATE _IOWR(KVMIO, 0xbe, struct kvm_nested_state)
1023#define KVM_SET_NESTED_STATE _IOW(KVMIO, 0xbf, struct kvm_nested_state)
Christopher Ferrisd842e432019-03-07 10:21:59 -08001024#define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_dirty_log)
1025#define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2)
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -07001026#define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int)
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -07001027#define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3)
1028#define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4)
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001029#define KVM_S390_PV_COMMAND _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd)
Christopher Ferris32ff3f82020-12-14 13:10:04 -08001030#define KVM_X86_SET_MSR_FILTER _IOW(KVMIO, 0xc6, struct kvm_msr_filter)
Christopher Ferris05667cd2021-02-16 16:01:34 -08001031#define KVM_RESET_DIRTY_RINGS _IO(KVMIO, 0xc7)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -07001032#define KVM_XEN_HVM_GET_ATTR _IOWR(KVMIO, 0xc8, struct kvm_xen_hvm_attr)
1033#define KVM_XEN_HVM_SET_ATTR _IOW(KVMIO, 0xc9, struct kvm_xen_hvm_attr)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -07001034#define KVM_XEN_VCPU_GET_ATTR _IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr)
1035#define KVM_XEN_VCPU_SET_ATTR _IOW(KVMIO, 0xcb, struct kvm_xen_vcpu_attr)
Christopher Ferris80ae69d2022-08-02 16:32:21 -07001036#define KVM_XEN_HVM_EVTCHN_SEND _IOW(KVMIO, 0xd0, struct kvm_irq_routing_xen_evtchn)
Christopher Ferris3a39c0b2021-09-02 00:03:38 +00001037#define KVM_GET_SREGS2 _IOR(KVMIO, 0xcc, struct kvm_sregs2)
1038#define KVM_SET_SREGS2 _IOW(KVMIO, 0xcd, struct kvm_sregs2)
Christopher Ferrisaf09c702020-06-01 20:29:29 -07001039#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
1040#define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
Christopher Ferris05667cd2021-02-16 16:01:34 -08001041#ifndef KVM_DIRTY_LOG_PAGE_OFFSET
1042#define KVM_DIRTY_LOG_PAGE_OFFSET 0
1043#endif
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +00001044#define KVM_DIRTY_GFN_F_DIRTY _BITUL(0)
1045#define KVM_DIRTY_GFN_F_RESET _BITUL(1)
Christopher Ferris05667cd2021-02-16 16:01:34 -08001046#define KVM_DIRTY_GFN_F_MASK 0x3
1047struct kvm_dirty_gfn {
1048 __u32 flags;
1049 __u32 slot;
1050 __u64 offset;
1051};
Christopher Ferrisa9750ed2021-05-03 14:02:49 -07001052#define KVM_BUS_LOCK_DETECTION_OFF (1 << 0)
1053#define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1)
Christopher Ferris10a76e62022-06-08 13:31:52 -07001054#define KVM_PMU_CAP_DISABLE (1 << 0)
Christopher Ferris3a39c0b2021-09-02 00:03:38 +00001055struct kvm_stats_header {
1056 __u32 flags;
1057 __u32 name_size;
1058 __u32 num_desc;
1059 __u32 id_offset;
1060 __u32 desc_offset;
1061 __u32 data_offset;
1062};
1063#define KVM_STATS_TYPE_SHIFT 0
1064#define KVM_STATS_TYPE_MASK (0xF << KVM_STATS_TYPE_SHIFT)
1065#define KVM_STATS_TYPE_CUMULATIVE (0x0 << KVM_STATS_TYPE_SHIFT)
1066#define KVM_STATS_TYPE_INSTANT (0x1 << KVM_STATS_TYPE_SHIFT)
1067#define KVM_STATS_TYPE_PEAK (0x2 << KVM_STATS_TYPE_SHIFT)
Christopher Ferris2abfa9e2021-11-01 16:26:06 -07001068#define KVM_STATS_TYPE_LINEAR_HIST (0x3 << KVM_STATS_TYPE_SHIFT)
1069#define KVM_STATS_TYPE_LOG_HIST (0x4 << KVM_STATS_TYPE_SHIFT)
1070#define KVM_STATS_TYPE_MAX KVM_STATS_TYPE_LOG_HIST
Christopher Ferris3a39c0b2021-09-02 00:03:38 +00001071#define KVM_STATS_UNIT_SHIFT 4
1072#define KVM_STATS_UNIT_MASK (0xF << KVM_STATS_UNIT_SHIFT)
1073#define KVM_STATS_UNIT_NONE (0x0 << KVM_STATS_UNIT_SHIFT)
1074#define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT)
1075#define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT)
1076#define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT)
Christopher Ferris80ae69d2022-08-02 16:32:21 -07001077#define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT)
1078#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_BOOLEAN
Christopher Ferris3a39c0b2021-09-02 00:03:38 +00001079#define KVM_STATS_BASE_SHIFT 8
1080#define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT)
1081#define KVM_STATS_BASE_POW10 (0x0 << KVM_STATS_BASE_SHIFT)
1082#define KVM_STATS_BASE_POW2 (0x1 << KVM_STATS_BASE_SHIFT)
1083#define KVM_STATS_BASE_MAX KVM_STATS_BASE_POW2
1084struct kvm_stats_desc {
1085 __u32 flags;
1086 __s16 exponent;
1087 __u16 size;
1088 __u32 offset;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -07001089 __u32 bucket_size;
Christopher Ferris3a39c0b2021-09-02 00:03:38 +00001090 char name[];
1091};
1092#define KVM_GET_STATS_FD _IO(KVMIO, 0xce)
Christopher Ferris1ed55342022-03-22 16:06:25 -07001093#define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave)
Christopher Ferris7447a1c2022-10-04 18:24:44 -07001094#define KVM_S390_PV_CPU_COMMAND _IOWR(KVMIO, 0xd0, struct kvm_pv_cmd)
1095#define KVM_X86_NOTIFY_VMEXIT_ENABLED (1ULL << 0)
1096#define KVM_X86_NOTIFY_VMEXIT_USER (1ULL << 1)
1097#define KVM_S390_ZPCI_OP _IOW(KVMIO, 0xd1, struct kvm_s390_zpci_op)
Christopher Ferrisb830ddf2024-03-28 11:48:08 -07001098#define KVM_SET_MEMORY_ATTRIBUTES _IOW(KVMIO, 0xd2, struct kvm_memory_attributes)
1099struct kvm_memory_attributes {
1100 __u64 address;
1101 __u64 size;
1102 __u64 attributes;
1103 __u64 flags;
1104};
1105#define KVM_MEMORY_ATTRIBUTE_PRIVATE (1ULL << 3)
1106#define KVM_CREATE_GUEST_MEMFD _IOWR(KVMIO, 0xd4, struct kvm_create_guest_memfd)
1107struct kvm_create_guest_memfd {
1108 __u64 size;
1109 __u64 flags;
1110 __u64 reserved[6];
1111};
Christopher Ferris6a9755d2017-01-13 14:09:31 -08001112#endif