blob: 334fb25b2973ff9262d41b55b9bb1cbf4b744b16 [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 */
Elliott Hughesabd62612013-11-08 11:45:48 -08007#ifndef _ASM_X86_KVM_H
8#define _ASM_X86_KVM_H
9#include <linux/types.h>
10#include <linux/ioctl.h>
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +000011#include <linux/stddef.h>
Christopher Ferris525ce912017-07-26 13:12:53 -070012#define KVM_PIO_PAGE_OFFSET 1
13#define KVM_COALESCED_MMIO_PAGE_OFFSET 2
Christopher Ferris05667cd2021-02-16 16:01:34 -080014#define KVM_DIRTY_LOG_PAGE_OFFSET 64
Elliott Hughesabd62612013-11-08 11:45:48 -080015#define DE_VECTOR 0
16#define DB_VECTOR 1
17#define BP_VECTOR 3
18#define OF_VECTOR 4
Elliott Hughesabd62612013-11-08 11:45:48 -080019#define BR_VECTOR 5
20#define UD_VECTOR 6
21#define NM_VECTOR 7
22#define DF_VECTOR 8
Elliott Hughesabd62612013-11-08 11:45:48 -080023#define TS_VECTOR 10
24#define NP_VECTOR 11
25#define SS_VECTOR 12
26#define GP_VECTOR 13
Elliott Hughesabd62612013-11-08 11:45:48 -080027#define PF_VECTOR 14
28#define MF_VECTOR 16
Christopher Ferris82d75042015-01-26 10:57:07 -080029#define AC_VECTOR 17
Elliott Hughesabd62612013-11-08 11:45:48 -080030#define MC_VECTOR 18
Christopher Ferris82d75042015-01-26 10:57:07 -080031#define XM_VECTOR 19
32#define VE_VECTOR 20
33#define __KVM_HAVE_PIT
Elliott Hughesabd62612013-11-08 11:45:48 -080034#define __KVM_HAVE_IOAPIC
35#define __KVM_HAVE_IRQ_LINE
36#define __KVM_HAVE_MSI
37#define __KVM_HAVE_USER_NMI
Elliott Hughesabd62612013-11-08 11:45:48 -080038#define __KVM_HAVE_GUEST_DEBUG
39#define __KVM_HAVE_MSIX
40#define __KVM_HAVE_MCE
41#define __KVM_HAVE_PIT_STATE2
Elliott Hughesabd62612013-11-08 11:45:48 -080042#define __KVM_HAVE_XEN_HVM
43#define __KVM_HAVE_VCPU_EVENTS
44#define __KVM_HAVE_DEBUGREGS
45#define __KVM_HAVE_XSAVE
Elliott Hughesabd62612013-11-08 11:45:48 -080046#define __KVM_HAVE_XCRS
47#define __KVM_HAVE_READONLY_MEM
48#define KVM_NR_INTERRUPTS 256
Elliott Hughesabd62612013-11-08 11:45:48 -080049struct kvm_pic_state {
Tao Baod7db5942015-01-28 10:07:51 -080050 __u8 last_irr;
51 __u8 irr;
Tao Baod7db5942015-01-28 10:07:51 -080052 __u8 imr;
53 __u8 isr;
54 __u8 priority_add;
55 __u8 irq_base;
Tao Baod7db5942015-01-28 10:07:51 -080056 __u8 read_reg_select;
57 __u8 poll;
58 __u8 special_mask;
59 __u8 init_state;
Tao Baod7db5942015-01-28 10:07:51 -080060 __u8 auto_eoi;
61 __u8 rotate_on_auto_eoi;
62 __u8 special_fully_nested_mode;
63 __u8 init4;
Tao Baod7db5942015-01-28 10:07:51 -080064 __u8 elcr;
65 __u8 elcr_mask;
Elliott Hughesabd62612013-11-08 11:45:48 -080066};
Elliott Hughesabd62612013-11-08 11:45:48 -080067#define KVM_IOAPIC_NUM_PINS 24
68struct kvm_ioapic_state {
Tao Baod7db5942015-01-28 10:07:51 -080069 __u64 base_address;
70 __u32 ioregsel;
71 __u32 id;
Tao Baod7db5942015-01-28 10:07:51 -080072 __u32 irr;
73 __u32 pad;
74 union {
75 __u64 bits;
Tao Baod7db5942015-01-28 10:07:51 -080076 struct {
77 __u8 vector;
78 __u8 delivery_mode : 3;
79 __u8 dest_mode : 1;
Tao Baod7db5942015-01-28 10:07:51 -080080 __u8 delivery_status : 1;
81 __u8 polarity : 1;
82 __u8 remote_irr : 1;
83 __u8 trig_mode : 1;
Tao Baod7db5942015-01-28 10:07:51 -080084 __u8 mask : 1;
85 __u8 reserve : 7;
86 __u8 reserved[4];
87 __u8 dest_id;
Tao Baod7db5942015-01-28 10:07:51 -080088 } fields;
89 } redirtbl[KVM_IOAPIC_NUM_PINS];
Elliott Hughesabd62612013-11-08 11:45:48 -080090};
Elliott Hughesabd62612013-11-08 11:45:48 -080091#define KVM_IRQCHIP_PIC_MASTER 0
92#define KVM_IRQCHIP_PIC_SLAVE 1
93#define KVM_IRQCHIP_IOAPIC 2
94#define KVM_NR_IRQCHIPS 3
Christopher Ferris05d08e92016-02-04 13:16:38 -080095#define KVM_RUN_X86_SMM (1 << 0)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -070096#define KVM_RUN_X86_BUS_LOCK (1 << 1)
Christopher Ferris05d08e92016-02-04 13:16:38 -080097struct kvm_regs {
Tao Baod7db5942015-01-28 10:07:51 -080098 __u64 rax, rbx, rcx, rdx;
99 __u64 rsi, rdi, rsp, rbp;
100 __u64 r8, r9, r10, r11;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800101 __u64 r12, r13, r14, r15;
Tao Baod7db5942015-01-28 10:07:51 -0800102 __u64 rip, rflags;
Elliott Hughesabd62612013-11-08 11:45:48 -0800103};
104#define KVM_APIC_REG_SIZE 0x400
Christopher Ferris05d08e92016-02-04 13:16:38 -0800105struct kvm_lapic_state {
Tao Baod7db5942015-01-28 10:07:51 -0800106 char regs[KVM_APIC_REG_SIZE];
Elliott Hughesabd62612013-11-08 11:45:48 -0800107};
108struct kvm_segment {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800109 __u64 base;
Tao Baod7db5942015-01-28 10:07:51 -0800110 __u32 limit;
111 __u16 selector;
112 __u8 type;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800113 __u8 present, dpl, db, s, l, g, avl;
Tao Baod7db5942015-01-28 10:07:51 -0800114 __u8 unusable;
115 __u8 padding;
Elliott Hughesabd62612013-11-08 11:45:48 -0800116};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800117struct kvm_dtable {
Tao Baod7db5942015-01-28 10:07:51 -0800118 __u64 base;
119 __u16 limit;
120 __u16 padding[3];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800121};
Elliott Hughesabd62612013-11-08 11:45:48 -0800122struct kvm_sregs {
Tao Baod7db5942015-01-28 10:07:51 -0800123 struct kvm_segment cs, ds, es, fs, gs, ss;
124 struct kvm_segment tr, ldt;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800125 struct kvm_dtable gdt, idt;
Tao Baod7db5942015-01-28 10:07:51 -0800126 __u64 cr0, cr2, cr3, cr4, cr8;
127 __u64 efer;
128 __u64 apic_base;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800129 __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
Elliott Hughesabd62612013-11-08 11:45:48 -0800130};
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000131struct kvm_sregs2 {
132 struct kvm_segment cs, ds, es, fs, gs, ss;
133 struct kvm_segment tr, ldt;
134 struct kvm_dtable gdt, idt;
135 __u64 cr0, cr2, cr3, cr4, cr8;
136 __u64 efer;
137 __u64 apic_base;
138 __u64 flags;
139 __u64 pdptrs[4];
140};
141#define KVM_SREGS2_FLAGS_PDPTRS_VALID 1
Elliott Hughesabd62612013-11-08 11:45:48 -0800142struct kvm_fpu {
Tao Baod7db5942015-01-28 10:07:51 -0800143 __u8 fpr[8][16];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800144 __u16 fcw;
Tao Baod7db5942015-01-28 10:07:51 -0800145 __u16 fsw;
146 __u8 ftwx;
147 __u8 pad1;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800148 __u16 last_opcode;
Tao Baod7db5942015-01-28 10:07:51 -0800149 __u64 last_ip;
150 __u64 last_dp;
151 __u8 xmm[16][16];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800152 __u32 mxcsr;
Tao Baod7db5942015-01-28 10:07:51 -0800153 __u32 pad2;
Elliott Hughesabd62612013-11-08 11:45:48 -0800154};
155struct kvm_msr_entry {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800156 __u32 index;
Tao Baod7db5942015-01-28 10:07:51 -0800157 __u32 reserved;
158 __u64 data;
Elliott Hughesabd62612013-11-08 11:45:48 -0800159};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800160struct kvm_msrs {
Tao Baod7db5942015-01-28 10:07:51 -0800161 __u32 nmsrs;
162 __u32 pad;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700163 struct kvm_msr_entry entries[];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800164};
Elliott Hughesabd62612013-11-08 11:45:48 -0800165struct kvm_msr_list {
Tao Baod7db5942015-01-28 10:07:51 -0800166 __u32 nmsrs;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700167 __u32 indices[];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800168};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800169#define KVM_MSR_FILTER_MAX_BITMAP_SIZE 0x600
170struct kvm_msr_filter_range {
171#define KVM_MSR_FILTER_READ (1 << 0)
172#define KVM_MSR_FILTER_WRITE (1 << 1)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800173#define KVM_MSR_FILTER_RANGE_VALID_MASK (KVM_MSR_FILTER_READ | KVM_MSR_FILTER_WRITE)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800174 __u32 flags;
175 __u32 nmsrs;
176 __u32 base;
177 __u8 * bitmap;
178};
179#define KVM_MSR_FILTER_MAX_RANGES 16
180struct kvm_msr_filter {
181#define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0)
182#define KVM_MSR_FILTER_DEFAULT_DENY (1 << 0)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800183#define KVM_MSR_FILTER_VALID_MASK (KVM_MSR_FILTER_DEFAULT_DENY)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800184 __u32 flags;
185 struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES];
186};
Elliott Hughesabd62612013-11-08 11:45:48 -0800187struct kvm_cpuid_entry {
Tao Baod7db5942015-01-28 10:07:51 -0800188 __u32 function;
189 __u32 eax;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800190 __u32 ebx;
Tao Baod7db5942015-01-28 10:07:51 -0800191 __u32 ecx;
192 __u32 edx;
193 __u32 padding;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800194};
Elliott Hughesabd62612013-11-08 11:45:48 -0800195struct kvm_cpuid {
Tao Baod7db5942015-01-28 10:07:51 -0800196 __u32 nent;
197 __u32 padding;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700198 struct kvm_cpuid_entry entries[];
Elliott Hughesabd62612013-11-08 11:45:48 -0800199};
200struct kvm_cpuid_entry2 {
Tao Baod7db5942015-01-28 10:07:51 -0800201 __u32 function;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800202 __u32 index;
Tao Baod7db5942015-01-28 10:07:51 -0800203 __u32 flags;
204 __u32 eax;
205 __u32 ebx;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800206 __u32 ecx;
Tao Baod7db5942015-01-28 10:07:51 -0800207 __u32 edx;
208 __u32 padding[3];
Elliott Hughesabd62612013-11-08 11:45:48 -0800209};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700210#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX (1 << 0)
211#define KVM_CPUID_FLAG_STATEFUL_FUNC (1 << 1)
212#define KVM_CPUID_FLAG_STATE_READ_NEXT (1 << 2)
Elliott Hughesabd62612013-11-08 11:45:48 -0800213struct kvm_cpuid2 {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800214 __u32 nent;
Tao Baod7db5942015-01-28 10:07:51 -0800215 __u32 padding;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700216 struct kvm_cpuid_entry2 entries[];
Elliott Hughesabd62612013-11-08 11:45:48 -0800217};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800218struct kvm_pit_channel_state {
Tao Baod7db5942015-01-28 10:07:51 -0800219 __u32 count;
220 __u16 latched_count;
221 __u8 count_latched;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800222 __u8 status_latched;
Tao Baod7db5942015-01-28 10:07:51 -0800223 __u8 status;
224 __u8 read_state;
225 __u8 write_state;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800226 __u8 write_latch;
Tao Baod7db5942015-01-28 10:07:51 -0800227 __u8 rw_mode;
228 __u8 mode;
229 __u8 bcd;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800230 __u8 gate;
Tao Baod7db5942015-01-28 10:07:51 -0800231 __s64 count_load_time;
Elliott Hughesabd62612013-11-08 11:45:48 -0800232};
233struct kvm_debug_exit_arch {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800234 __u32 exception;
Tao Baod7db5942015-01-28 10:07:51 -0800235 __u32 pad;
236 __u64 pc;
237 __u64 dr6;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800238 __u64 dr7;
Elliott Hughesabd62612013-11-08 11:45:48 -0800239};
240#define KVM_GUESTDBG_USE_SW_BP 0x00010000
241#define KVM_GUESTDBG_USE_HW_BP 0x00020000
Christopher Ferris05d08e92016-02-04 13:16:38 -0800242#define KVM_GUESTDBG_INJECT_DB 0x00040000
Elliott Hughesabd62612013-11-08 11:45:48 -0800243#define KVM_GUESTDBG_INJECT_BP 0x00080000
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700244#define KVM_GUESTDBG_BLOCKIRQ 0x00100000
Elliott Hughesabd62612013-11-08 11:45:48 -0800245struct kvm_guest_debug_arch {
Tao Baod7db5942015-01-28 10:07:51 -0800246 __u64 debugreg[8];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800247};
Elliott Hughesabd62612013-11-08 11:45:48 -0800248struct kvm_pit_state {
Tao Baod7db5942015-01-28 10:07:51 -0800249 struct kvm_pit_channel_state channels[3];
Elliott Hughesabd62612013-11-08 11:45:48 -0800250};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800251#define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700252#define KVM_PIT_FLAGS_SPEAKER_DATA_ON 0x00000002
Elliott Hughesabd62612013-11-08 11:45:48 -0800253struct kvm_pit_state2 {
Tao Baod7db5942015-01-28 10:07:51 -0800254 struct kvm_pit_channel_state channels[3];
255 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800256 __u32 reserved[9];
Elliott Hughesabd62612013-11-08 11:45:48 -0800257};
258struct kvm_reinject_control {
Tao Baod7db5942015-01-28 10:07:51 -0800259 __u8 pit_reinject;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800260 __u8 reserved[31];
Elliott Hughesabd62612013-11-08 11:45:48 -0800261};
262#define KVM_VCPUEVENT_VALID_NMI_PENDING 0x00000001
263#define KVM_VCPUEVENT_VALID_SIPI_VECTOR 0x00000002
Christopher Ferris05d08e92016-02-04 13:16:38 -0800264#define KVM_VCPUEVENT_VALID_SHADOW 0x00000004
265#define KVM_VCPUEVENT_VALID_SMM 0x00000008
Christopher Ferris86a48372019-01-10 14:14:59 -0800266#define KVM_VCPUEVENT_VALID_PAYLOAD 0x00000010
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700267#define KVM_VCPUEVENT_VALID_TRIPLE_FAULT 0x00000020
Elliott Hughesabd62612013-11-08 11:45:48 -0800268#define KVM_X86_SHADOW_INT_MOV_SS 0x01
269#define KVM_X86_SHADOW_INT_STI 0x02
270struct kvm_vcpu_events {
Tao Baod7db5942015-01-28 10:07:51 -0800271 struct {
Tao Baod7db5942015-01-28 10:07:51 -0800272 __u8 injected;
273 __u8 nr;
274 __u8 has_error_code;
Christopher Ferris86a48372019-01-10 14:14:59 -0800275 __u8 pending;
Tao Baod7db5942015-01-28 10:07:51 -0800276 __u32 error_code;
277 } exception;
278 struct {
279 __u8 injected;
Tao Baod7db5942015-01-28 10:07:51 -0800280 __u8 nr;
281 __u8 soft;
282 __u8 shadow;
283 } interrupt;
Tao Baod7db5942015-01-28 10:07:51 -0800284 struct {
285 __u8 injected;
286 __u8 pending;
287 __u8 masked;
Tao Baod7db5942015-01-28 10:07:51 -0800288 __u8 pad;
289 } nmi;
290 __u32 sipi_vector;
291 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800292 struct {
293 __u8 smm;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800294 __u8 pending;
295 __u8 smm_inside_nmi;
296 __u8 latched_init;
297 } smi;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700298 struct {
299 __u8 pending;
300 } triple_fault;
301 __u8 reserved[26];
Christopher Ferris86a48372019-01-10 14:14:59 -0800302 __u8 exception_has_payload;
303 __u64 exception_payload;
Elliott Hughesabd62612013-11-08 11:45:48 -0800304};
305struct kvm_debugregs {
Tao Baod7db5942015-01-28 10:07:51 -0800306 __u64 db[4];
Tao Baod7db5942015-01-28 10:07:51 -0800307 __u64 dr6;
308 __u64 dr7;
309 __u64 flags;
310 __u64 reserved[9];
Elliott Hughesabd62612013-11-08 11:45:48 -0800311};
312struct kvm_xsave {
Tao Baod7db5942015-01-28 10:07:51 -0800313 __u32 region[1024];
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700314 __u32 extra[];
Elliott Hughesabd62612013-11-08 11:45:48 -0800315};
316#define KVM_MAX_XCRS 16
317struct kvm_xcr {
Tao Baod7db5942015-01-28 10:07:51 -0800318 __u32 xcr;
319 __u32 reserved;
Tao Baod7db5942015-01-28 10:07:51 -0800320 __u64 value;
Elliott Hughesabd62612013-11-08 11:45:48 -0800321};
322struct kvm_xcrs {
Tao Baod7db5942015-01-28 10:07:51 -0800323 __u32 nr_xcrs;
Tao Baod7db5942015-01-28 10:07:51 -0800324 __u32 flags;
325 struct kvm_xcr xcrs[KVM_MAX_XCRS];
326 __u64 padding[16];
Elliott Hughesabd62612013-11-08 11:45:48 -0800327};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700328#define KVM_SYNC_X86_REGS (1UL << 0)
329#define KVM_SYNC_X86_SREGS (1UL << 1)
330#define KVM_SYNC_X86_EVENTS (1UL << 2)
331#define KVM_SYNC_X86_VALID_FIELDS (KVM_SYNC_X86_REGS | KVM_SYNC_X86_SREGS | KVM_SYNC_X86_EVENTS)
Elliott Hughesabd62612013-11-08 11:45:48 -0800332struct kvm_sync_regs {
Christopher Ferris76a1d452018-06-27 14:12:29 -0700333 struct kvm_regs regs;
334 struct kvm_sregs sregs;
335 struct kvm_vcpu_events events;
Elliott Hughesabd62612013-11-08 11:45:48 -0800336};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800337#define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0)
338#define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1)
Christopher Ferris9ce28842018-10-25 12:11:39 -0700339#define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2)
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700340#define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700341#define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4)
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700342#define KVM_X86_QUIRK_FIX_HYPERCALL_INSN (1 << 5)
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700343#define KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS (1 << 6)
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700344#define KVM_STATE_NESTED_FORMAT_VMX 0
345#define KVM_STATE_NESTED_FORMAT_SVM 1
Christopher Ferris9ce28842018-10-25 12:11:39 -0700346#define KVM_STATE_NESTED_GUEST_MODE 0x00000001
347#define KVM_STATE_NESTED_RUN_PENDING 0x00000002
Christopher Ferris86a48372019-01-10 14:14:59 -0800348#define KVM_STATE_NESTED_EVMCS 0x00000004
Christopher Ferrisbb9fcb42020-04-06 11:38:04 -0700349#define KVM_STATE_NESTED_MTF_PENDING 0x00000008
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700350#define KVM_STATE_NESTED_GIF_SET 0x00000100
Christopher Ferris9ce28842018-10-25 12:11:39 -0700351#define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001
352#define KVM_STATE_NESTED_SMM_VMXON 0x00000002
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700353#define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700354#define KVM_STATE_NESTED_SVM_VMCB_SIZE 0x1000
355#define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001
Christopher Ferris1ed55342022-03-22 16:06:25 -0700356#define KVM_X86_XCOMP_GUEST_SUPP 0
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700357struct kvm_vmx_nested_state_data {
358 __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
359 __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
360};
361struct kvm_vmx_nested_state_hdr {
Christopher Ferris9ce28842018-10-25 12:11:39 -0700362 __u64 vmxon_pa;
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700363 __u64 vmcs12_pa;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700364 struct {
365 __u16 flags;
366 } smm;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000367 __u16 pad;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700368 __u32 flags;
369 __u64 preemption_timer_deadline;
370};
371struct kvm_svm_nested_state_data {
372 __u8 vmcb12[KVM_STATE_NESTED_SVM_VMCB_SIZE];
373};
374struct kvm_svm_nested_state_hdr {
375 __u64 vmcb_pa;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700376};
377struct kvm_nested_state {
378 __u16 flags;
379 __u16 format;
380 __u32 size;
381 union {
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700382 struct kvm_vmx_nested_state_hdr vmx;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700383 struct kvm_svm_nested_state_hdr svm;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700384 __u8 pad[120];
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700385 } hdr;
386 union {
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000387 __DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, vmx);
388 __DECLARE_FLEX_ARRAY(struct kvm_svm_nested_state_data, svm);
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700389 } data;
Christopher Ferris9ce28842018-10-25 12:11:39 -0700390};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700391struct kvm_pmu_event_filter {
392 __u32 action;
393 __u32 nevents;
394 __u32 fixed_counter_bitmap;
395 __u32 flags;
396 __u32 pad[4];
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700397 __u64 events[];
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700398};
399#define KVM_PMU_EVENT_ALLOW 0
400#define KVM_PMU_EVENT_DENY 1
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000401#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0)
402#define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS)
403#define KVM_PMU_ENCODE_MASKED_ENTRY(event_select,mask,match,exclude) (((event_select) & 0xFFULL) | (((event_select) & 0XF00ULL) << 24) | (((mask) & 0xFFULL) << 56) | (((match) & 0xFFULL) << 8) | ((__u64) (! ! (exclude)) << 55))
404#define KVM_PMU_MASKED_ENTRY_EVENT_SELECT (GENMASK_ULL(7, 0) | GENMASK_ULL(35, 32))
405#define KVM_PMU_MASKED_ENTRY_UMASK_MASK (GENMASK_ULL(63, 56))
406#define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (GENMASK_ULL(15, 8))
407#define KVM_PMU_MASKED_ENTRY_EXCLUDE (BIT_ULL(55))
408#define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT (56)
Christopher Ferrisa4792612022-01-10 13:51:15 -0800409#define KVM_VCPU_TSC_CTRL 0
410#define KVM_VCPU_TSC_OFFSET 0
Christopher Ferris37c3f3c2023-07-10 10:59:05 -0700411#define KVM_EXIT_HYPERCALL_LONG_MODE BIT(0)
Elliott Hughesabd62612013-11-08 11:45:48 -0800412#endif