Greg Kroah-Hartman | 6f52b16 | 2017-11-01 15:08:43 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 2 | #ifndef _ASM_X86_KVM_H |
| 3 | #define _ASM_X86_KVM_H |
Jerone Young | f6a40e3 | 2007-11-19 17:06:31 -0600 | [diff] [blame] | 4 | |
| 5 | /* |
| 6 | * KVM x86 specific structures and definitions |
| 7 | * |
| 8 | */ |
| 9 | |
Jaswinder Singh Rajput | cef3767 | 2009-01-30 22:46:08 +0530 | [diff] [blame] | 10 | #include <linux/types.h> |
Jerone Young | f6a40e3 | 2007-11-19 17:06:31 -0600 | [diff] [blame] | 11 | #include <linux/ioctl.h> |
| 12 | |
Paolo Bonzini | 4b4357e | 2017-03-31 13:53:23 +0200 | [diff] [blame] | 13 | #define KVM_PIO_PAGE_OFFSET 1 |
| 14 | #define KVM_COALESCED_MMIO_PAGE_OFFSET 2 |
| 15 | |
Xiao Guangrong | 26bf264 | 2012-09-17 16:31:13 +0800 | [diff] [blame] | 16 | #define DE_VECTOR 0 |
| 17 | #define DB_VECTOR 1 |
| 18 | #define BP_VECTOR 3 |
| 19 | #define OF_VECTOR 4 |
| 20 | #define BR_VECTOR 5 |
| 21 | #define UD_VECTOR 6 |
| 22 | #define NM_VECTOR 7 |
| 23 | #define DF_VECTOR 8 |
| 24 | #define TS_VECTOR 10 |
| 25 | #define NP_VECTOR 11 |
| 26 | #define SS_VECTOR 12 |
| 27 | #define GP_VECTOR 13 |
| 28 | #define PF_VECTOR 14 |
| 29 | #define MF_VECTOR 16 |
Nadav Amit | c9cdd08 | 2014-07-21 14:37:24 +0300 | [diff] [blame] | 30 | #define AC_VECTOR 17 |
Xiao Guangrong | 26bf264 | 2012-09-17 16:31:13 +0800 | [diff] [blame] | 31 | #define MC_VECTOR 18 |
Nadav Amit | c9cdd08 | 2014-07-21 14:37:24 +0300 | [diff] [blame] | 32 | #define XM_VECTOR 19 |
| 33 | #define VE_VECTOR 20 |
Xiao Guangrong | 26bf264 | 2012-09-17 16:31:13 +0800 | [diff] [blame] | 34 | |
Avi Kivity | 7a0eb19 | 2009-01-19 14:57:52 +0200 | [diff] [blame] | 35 | /* Select x86 specific features in <linux/kvm.h> */ |
| 36 | #define __KVM_HAVE_PIT |
| 37 | #define __KVM_HAVE_IOAPIC |
Christoffer Dall | a1e4ccb | 2012-06-15 15:07:13 -0400 | [diff] [blame] | 38 | #define __KVM_HAVE_IRQ_LINE |
Avi Kivity | 7a0eb19 | 2009-01-19 14:57:52 +0200 | [diff] [blame] | 39 | #define __KVM_HAVE_MSI |
| 40 | #define __KVM_HAVE_USER_NMI |
Avi Kivity | 91b2ae7 | 2009-01-19 14:57:52 +0200 | [diff] [blame] | 41 | #define __KVM_HAVE_GUEST_DEBUG |
Sheng Yang | d510d6c | 2009-02-25 17:22:28 +0800 | [diff] [blame] | 42 | #define __KVM_HAVE_MSIX |
Huang Ying | 890ca9a | 2009-05-11 16:48:15 +0800 | [diff] [blame] | 43 | #define __KVM_HAVE_MCE |
Beth Kon | e9f4275 | 2009-07-07 11:50:38 -0400 | [diff] [blame] | 44 | #define __KVM_HAVE_PIT_STATE2 |
Ed Swierk | ffde22a | 2009-10-15 15:21:43 -0700 | [diff] [blame] | 45 | #define __KVM_HAVE_XEN_HVM |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 46 | #define __KVM_HAVE_VCPU_EVENTS |
Jan Kiszka | a1efbe7 | 2010-02-15 10:45:43 +0100 | [diff] [blame] | 47 | #define __KVM_HAVE_DEBUGREGS |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 48 | #define __KVM_HAVE_XSAVE |
| 49 | #define __KVM_HAVE_XCRS |
Xiao Guangrong | 4d8b81a | 2012-08-21 11:02:51 +0800 | [diff] [blame] | 50 | #define __KVM_HAVE_READONLY_MEM |
Avi Kivity | 7a0eb19 | 2009-01-19 14:57:52 +0200 | [diff] [blame] | 51 | |
Jerone Young | 244d57e | 2007-11-19 17:06:36 -0600 | [diff] [blame] | 52 | /* Architectural interrupt line count. */ |
| 53 | #define KVM_NR_INTERRUPTS 256 |
| 54 | |
Jerone Young | f6a40e3 | 2007-11-19 17:06:31 -0600 | [diff] [blame] | 55 | struct kvm_memory_alias { |
| 56 | __u32 slot; /* this has a different namespace than memory slots */ |
| 57 | __u32 flags; |
| 58 | __u64 guest_phys_addr; |
| 59 | __u64 memory_size; |
| 60 | __u64 target_phys_addr; |
| 61 | }; |
| 62 | |
Jerone Young | da1386a | 2007-11-19 17:06:32 -0600 | [diff] [blame] | 63 | /* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */ |
| 64 | struct kvm_pic_state { |
| 65 | __u8 last_irr; /* edge detection */ |
| 66 | __u8 irr; /* interrupt request register */ |
| 67 | __u8 imr; /* interrupt mask register */ |
| 68 | __u8 isr; /* interrupt service register */ |
| 69 | __u8 priority_add; /* highest irq priority */ |
| 70 | __u8 irq_base; |
| 71 | __u8 read_reg_select; |
| 72 | __u8 poll; |
| 73 | __u8 special_mask; |
| 74 | __u8 init_state; |
| 75 | __u8 auto_eoi; |
| 76 | __u8 rotate_on_auto_eoi; |
| 77 | __u8 special_fully_nested_mode; |
| 78 | __u8 init4; /* true if 4 byte init */ |
| 79 | __u8 elcr; /* PIIX edge/trigger selection */ |
| 80 | __u8 elcr_mask; |
| 81 | }; |
| 82 | |
| 83 | #define KVM_IOAPIC_NUM_PINS 24 |
| 84 | struct kvm_ioapic_state { |
| 85 | __u64 base_address; |
| 86 | __u32 ioregsel; |
| 87 | __u32 id; |
| 88 | __u32 irr; |
| 89 | __u32 pad; |
| 90 | union { |
| 91 | __u64 bits; |
| 92 | struct { |
| 93 | __u8 vector; |
| 94 | __u8 delivery_mode:3; |
| 95 | __u8 dest_mode:1; |
| 96 | __u8 delivery_status:1; |
| 97 | __u8 polarity:1; |
| 98 | __u8 remote_irr:1; |
| 99 | __u8 trig_mode:1; |
| 100 | __u8 mask:1; |
| 101 | __u8 reserve:7; |
| 102 | __u8 reserved[4]; |
| 103 | __u8 dest_id; |
| 104 | } fields; |
| 105 | } redirtbl[KVM_IOAPIC_NUM_PINS]; |
| 106 | }; |
| 107 | |
| 108 | #define KVM_IRQCHIP_PIC_MASTER 0 |
| 109 | #define KVM_IRQCHIP_PIC_SLAVE 1 |
| 110 | #define KVM_IRQCHIP_IOAPIC 2 |
Gleb Natapov | 3e71f88 | 2009-08-24 11:54:21 +0300 | [diff] [blame] | 111 | #define KVM_NR_IRQCHIPS 3 |
Jerone Young | da1386a | 2007-11-19 17:06:32 -0600 | [diff] [blame] | 112 | |
Paolo Bonzini | f077825 | 2015-04-01 15:06:40 +0200 | [diff] [blame] | 113 | #define KVM_RUN_X86_SMM (1 << 0) |
| 114 | |
Jerone Young | 19d30b1 | 2007-11-19 17:06:33 -0600 | [diff] [blame] | 115 | /* for KVM_GET_REGS and KVM_SET_REGS */ |
| 116 | struct kvm_regs { |
| 117 | /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ |
| 118 | __u64 rax, rbx, rcx, rdx; |
| 119 | __u64 rsi, rdi, rsp, rbp; |
| 120 | __u64 r8, r9, r10, r11; |
| 121 | __u64 r12, r13, r14, r15; |
| 122 | __u64 rip, rflags; |
| 123 | }; |
| 124 | |
Jerone Young | d9ecf92 | 2007-11-19 17:06:34 -0600 | [diff] [blame] | 125 | /* for KVM_GET_LAPIC and KVM_SET_LAPIC */ |
| 126 | #define KVM_APIC_REG_SIZE 0x400 |
| 127 | struct kvm_lapic_state { |
| 128 | char regs[KVM_APIC_REG_SIZE]; |
| 129 | }; |
| 130 | |
Jerone Young | 3a56b20 | 2007-11-19 17:06:35 -0600 | [diff] [blame] | 131 | struct kvm_segment { |
| 132 | __u64 base; |
| 133 | __u32 limit; |
| 134 | __u16 selector; |
| 135 | __u8 type; |
| 136 | __u8 present, dpl, db, s, l, g, avl; |
| 137 | __u8 unusable; |
| 138 | __u8 padding; |
| 139 | }; |
| 140 | |
| 141 | struct kvm_dtable { |
| 142 | __u64 base; |
| 143 | __u16 limit; |
| 144 | __u16 padding[3]; |
| 145 | }; |
| 146 | |
| 147 | |
Jerone Young | 244d57e | 2007-11-19 17:06:36 -0600 | [diff] [blame] | 148 | /* for KVM_GET_SREGS and KVM_SET_SREGS */ |
| 149 | struct kvm_sregs { |
| 150 | /* out (KVM_GET_SREGS) / in (KVM_SET_SREGS) */ |
| 151 | struct kvm_segment cs, ds, es, fs, gs, ss; |
| 152 | struct kvm_segment tr, ldt; |
| 153 | struct kvm_dtable gdt, idt; |
| 154 | __u64 cr0, cr2, cr3, cr4, cr8; |
| 155 | __u64 efer; |
| 156 | __u64 apic_base; |
| 157 | __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64]; |
| 158 | }; |
| 159 | |
Christian Ehrhardt | 6f723c7 | 2008-01-08 08:04:50 +0100 | [diff] [blame] | 160 | /* for KVM_GET_FPU and KVM_SET_FPU */ |
| 161 | struct kvm_fpu { |
| 162 | __u8 fpr[8][16]; |
| 163 | __u16 fcw; |
| 164 | __u16 fsw; |
| 165 | __u8 ftwx; /* in fxsave format */ |
| 166 | __u8 pad1; |
| 167 | __u16 last_opcode; |
| 168 | __u64 last_ip; |
| 169 | __u64 last_dp; |
| 170 | __u8 xmm[16][16]; |
| 171 | __u32 mxcsr; |
| 172 | __u32 pad2; |
| 173 | }; |
| 174 | |
Jerone Young | 244d57e | 2007-11-19 17:06:36 -0600 | [diff] [blame] | 175 | struct kvm_msr_entry { |
| 176 | __u32 index; |
| 177 | __u32 reserved; |
| 178 | __u64 data; |
| 179 | }; |
| 180 | |
| 181 | /* for KVM_GET_MSRS and KVM_SET_MSRS */ |
| 182 | struct kvm_msrs { |
| 183 | __u32 nmsrs; /* number of msrs in entries */ |
| 184 | __u32 pad; |
| 185 | |
| 186 | struct kvm_msr_entry entries[0]; |
| 187 | }; |
| 188 | |
| 189 | /* for KVM_GET_MSR_INDEX_LIST */ |
| 190 | struct kvm_msr_list { |
| 191 | __u32 nmsrs; /* number of msrs in entries */ |
| 192 | __u32 indices[0]; |
| 193 | }; |
| 194 | |
| 195 | |
Jerone Young | a162dd5 | 2007-11-19 17:06:37 -0600 | [diff] [blame] | 196 | struct kvm_cpuid_entry { |
| 197 | __u32 function; |
| 198 | __u32 eax; |
| 199 | __u32 ebx; |
| 200 | __u32 ecx; |
| 201 | __u32 edx; |
| 202 | __u32 padding; |
| 203 | }; |
| 204 | |
| 205 | /* for KVM_SET_CPUID */ |
| 206 | struct kvm_cpuid { |
| 207 | __u32 nent; |
| 208 | __u32 padding; |
| 209 | struct kvm_cpuid_entry entries[0]; |
| 210 | }; |
| 211 | |
Dan Kenigsberg | 0771671 | 2007-11-21 17:10:04 +0200 | [diff] [blame] | 212 | struct kvm_cpuid_entry2 { |
| 213 | __u32 function; |
| 214 | __u32 index; |
| 215 | __u32 flags; |
| 216 | __u32 eax; |
| 217 | __u32 ebx; |
| 218 | __u32 ecx; |
| 219 | __u32 edx; |
| 220 | __u32 padding[3]; |
| 221 | }; |
| 222 | |
Borislav Petkov | 3dbe345 | 2016-05-05 10:18:23 +0200 | [diff] [blame] | 223 | #define KVM_CPUID_FLAG_SIGNIFCANT_INDEX (1 << 0) |
| 224 | #define KVM_CPUID_FLAG_STATEFUL_FUNC (1 << 1) |
| 225 | #define KVM_CPUID_FLAG_STATE_READ_NEXT (1 << 2) |
Dan Kenigsberg | 0771671 | 2007-11-21 17:10:04 +0200 | [diff] [blame] | 226 | |
| 227 | /* for KVM_SET_CPUID2 */ |
| 228 | struct kvm_cpuid2 { |
| 229 | __u32 nent; |
| 230 | __u32 padding; |
| 231 | struct kvm_cpuid_entry2 entries[0]; |
| 232 | }; |
Jerone Young | a162dd5 | 2007-11-19 17:06:37 -0600 | [diff] [blame] | 233 | |
Sheng Yang | e0f63cb | 2008-03-04 00:50:59 +0800 | [diff] [blame] | 234 | /* for KVM_GET_PIT and KVM_SET_PIT */ |
| 235 | struct kvm_pit_channel_state { |
| 236 | __u32 count; /* can be 65536 */ |
| 237 | __u16 latched_count; |
| 238 | __u8 count_latched; |
| 239 | __u8 status_latched; |
| 240 | __u8 status; |
| 241 | __u8 read_state; |
| 242 | __u8 write_state; |
| 243 | __u8 write_latch; |
| 244 | __u8 rw_mode; |
| 245 | __u8 mode; |
| 246 | __u8 bcd; |
| 247 | __u8 gate; |
| 248 | __s64 count_load_time; |
| 249 | }; |
| 250 | |
Jan Kiszka | d0bfb94 | 2008-12-15 13:52:10 +0100 | [diff] [blame] | 251 | struct kvm_debug_exit_arch { |
| 252 | __u32 exception; |
| 253 | __u32 pad; |
| 254 | __u64 pc; |
| 255 | __u64 dr6; |
| 256 | __u64 dr7; |
| 257 | }; |
| 258 | |
| 259 | #define KVM_GUESTDBG_USE_SW_BP 0x00010000 |
| 260 | #define KVM_GUESTDBG_USE_HW_BP 0x00020000 |
| 261 | #define KVM_GUESTDBG_INJECT_DB 0x00040000 |
| 262 | #define KVM_GUESTDBG_INJECT_BP 0x00080000 |
| 263 | |
| 264 | /* for KVM_SET_GUEST_DEBUG */ |
| 265 | struct kvm_guest_debug_arch { |
| 266 | __u64 debugreg[8]; |
| 267 | }; |
| 268 | |
Sheng Yang | e0f63cb | 2008-03-04 00:50:59 +0800 | [diff] [blame] | 269 | struct kvm_pit_state { |
| 270 | struct kvm_pit_channel_state channels[3]; |
| 271 | }; |
Marcelo Tosatti | 52d939a | 2008-12-30 15:55:06 -0200 | [diff] [blame] | 272 | |
Beth Kon | e9f4275 | 2009-07-07 11:50:38 -0400 | [diff] [blame] | 273 | #define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001 |
| 274 | |
| 275 | struct kvm_pit_state2 { |
| 276 | struct kvm_pit_channel_state channels[3]; |
| 277 | __u32 flags; |
| 278 | __u32 reserved[9]; |
| 279 | }; |
| 280 | |
Marcelo Tosatti | 52d939a | 2008-12-30 15:55:06 -0200 | [diff] [blame] | 281 | struct kvm_reinject_control { |
| 282 | __u8 pit_reinject; |
| 283 | __u8 reserved[31]; |
| 284 | }; |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 285 | |
Jan Kiszka | dab4b91 | 2009-12-06 18:24:15 +0100 | [diff] [blame] | 286 | /* When set in flags, include corresponding fields on KVM_SET_VCPU_EVENTS */ |
| 287 | #define KVM_VCPUEVENT_VALID_NMI_PENDING 0x00000001 |
| 288 | #define KVM_VCPUEVENT_VALID_SIPI_VECTOR 0x00000002 |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 289 | #define KVM_VCPUEVENT_VALID_SHADOW 0x00000004 |
Paolo Bonzini | f077825 | 2015-04-01 15:06:40 +0200 | [diff] [blame] | 290 | #define KVM_VCPUEVENT_VALID_SMM 0x00000008 |
Jim Mattson | 59073aa | 2018-10-16 14:29:20 -0700 | [diff] [blame] | 291 | #define KVM_VCPUEVENT_VALID_PAYLOAD 0x00000010 |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 292 | |
| 293 | /* Interrupt shadow states */ |
| 294 | #define KVM_X86_SHADOW_INT_MOV_SS 0x01 |
| 295 | #define KVM_X86_SHADOW_INT_STI 0x02 |
Jan Kiszka | dab4b91 | 2009-12-06 18:24:15 +0100 | [diff] [blame] | 296 | |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 297 | /* for KVM_GET/SET_VCPU_EVENTS */ |
| 298 | struct kvm_vcpu_events { |
| 299 | struct { |
| 300 | __u8 injected; |
| 301 | __u8 nr; |
| 302 | __u8 has_error_code; |
Jim Mattson | 59073aa | 2018-10-16 14:29:20 -0700 | [diff] [blame] | 303 | __u8 pending; |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 304 | __u32 error_code; |
| 305 | } exception; |
| 306 | struct { |
| 307 | __u8 injected; |
| 308 | __u8 nr; |
| 309 | __u8 soft; |
Jan Kiszka | 48005f6 | 2010-02-19 19:38:07 +0100 | [diff] [blame] | 310 | __u8 shadow; |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 311 | } interrupt; |
| 312 | struct { |
| 313 | __u8 injected; |
| 314 | __u8 pending; |
| 315 | __u8 masked; |
| 316 | __u8 pad; |
| 317 | } nmi; |
| 318 | __u32 sipi_vector; |
| 319 | __u32 flags; |
Paolo Bonzini | f077825 | 2015-04-01 15:06:40 +0200 | [diff] [blame] | 320 | struct { |
| 321 | __u8 smm; |
| 322 | __u8 pending; |
| 323 | __u8 smm_inside_nmi; |
| 324 | __u8 latched_init; |
| 325 | } smi; |
Jim Mattson | 59073aa | 2018-10-16 14:29:20 -0700 | [diff] [blame] | 326 | __u8 reserved[27]; |
| 327 | __u8 exception_has_payload; |
| 328 | __u64 exception_payload; |
Jan Kiszka | 3cfc309 | 2009-11-12 01:04:25 +0100 | [diff] [blame] | 329 | }; |
| 330 | |
Jan Kiszka | a1efbe7 | 2010-02-15 10:45:43 +0100 | [diff] [blame] | 331 | /* for KVM_GET/SET_DEBUGREGS */ |
| 332 | struct kvm_debugregs { |
| 333 | __u64 db[4]; |
| 334 | __u64 dr6; |
| 335 | __u64 dr7; |
| 336 | __u64 flags; |
| 337 | __u64 reserved[9]; |
| 338 | }; |
| 339 | |
Sheng Yang | 2d5b5a6 | 2010-06-13 17:29:39 +0800 | [diff] [blame] | 340 | /* for KVM_CAP_XSAVE */ |
| 341 | struct kvm_xsave { |
| 342 | __u32 region[1024]; |
| 343 | }; |
| 344 | |
| 345 | #define KVM_MAX_XCRS 16 |
| 346 | |
| 347 | struct kvm_xcr { |
| 348 | __u32 xcr; |
| 349 | __u32 reserved; |
| 350 | __u64 value; |
| 351 | }; |
| 352 | |
| 353 | struct kvm_xcrs { |
| 354 | __u32 nr_xcrs; |
| 355 | __u32 flags; |
| 356 | struct kvm_xcr xcrs[KVM_MAX_XCRS]; |
| 357 | __u64 padding[16]; |
| 358 | }; |
| 359 | |
Ken Hofsass | 01643c5 | 2018-01-31 16:03:36 -0800 | [diff] [blame] | 360 | #define KVM_SYNC_X86_REGS (1UL << 0) |
| 361 | #define KVM_SYNC_X86_SREGS (1UL << 1) |
| 362 | #define KVM_SYNC_X86_EVENTS (1UL << 2) |
| 363 | |
| 364 | #define KVM_SYNC_X86_VALID_FIELDS \ |
| 365 | (KVM_SYNC_X86_REGS| \ |
| 366 | KVM_SYNC_X86_SREGS| \ |
| 367 | KVM_SYNC_X86_EVENTS) |
| 368 | |
| 369 | /* kvm_sync_regs struct included by kvm_run struct */ |
Christian Borntraeger | b9e5dc8 | 2012-01-11 11:20:30 +0100 | [diff] [blame] | 370 | struct kvm_sync_regs { |
Ken Hofsass | 01643c5 | 2018-01-31 16:03:36 -0800 | [diff] [blame] | 371 | /* Members of this structure are potentially malicious. |
| 372 | * Care must be taken by code reading, esp. interpreting, |
| 373 | * data fields from them inside KVM to prevent TOCTOU and |
| 374 | * double-fetch types of vulnerabilities. |
| 375 | */ |
| 376 | struct kvm_regs regs; |
| 377 | struct kvm_sregs sregs; |
| 378 | struct kvm_vcpu_events events; |
Christian Borntraeger | b9e5dc8 | 2012-01-11 11:20:30 +0100 | [diff] [blame] | 379 | }; |
| 380 | |
Wanpeng Li | 511a8556 | 2019-05-21 14:06:54 +0800 | [diff] [blame] | 381 | #define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0) |
| 382 | #define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1) |
| 383 | #define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2) |
| 384 | #define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3) |
| 385 | #define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4) |
Nadav Amit | 90de4a1 | 2015-04-13 01:53:41 +0300 | [diff] [blame] | 386 | |
Liran Alon | 6ca00df | 2019-06-16 15:03:10 +0300 | [diff] [blame] | 387 | #define KVM_STATE_NESTED_FORMAT_VMX 0 |
Paolo Bonzini | cc440cd | 2020-05-13 13:36:32 -0400 | [diff] [blame] | 388 | #define KVM_STATE_NESTED_FORMAT_SVM 1 |
Liran Alon | 6ca00df | 2019-06-16 15:03:10 +0300 | [diff] [blame] | 389 | |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 390 | #define KVM_STATE_NESTED_GUEST_MODE 0x00000001 |
| 391 | #define KVM_STATE_NESTED_RUN_PENDING 0x00000002 |
Vitaly Kuznetsov | 8cab650 | 2018-10-16 18:50:09 +0200 | [diff] [blame] | 392 | #define KVM_STATE_NESTED_EVMCS 0x00000004 |
Oliver Upton | 5ef8acb | 2020-02-07 02:36:07 -0800 | [diff] [blame] | 393 | #define KVM_STATE_NESTED_MTF_PENDING 0x00000008 |
Paolo Bonzini | cc440cd | 2020-05-13 13:36:32 -0400 | [diff] [blame] | 394 | #define KVM_STATE_NESTED_GIF_SET 0x00000100 |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 395 | |
| 396 | #define KVM_STATE_NESTED_SMM_GUEST_MODE 0x00000001 |
| 397 | #define KVM_STATE_NESTED_SMM_VMXON 0x00000002 |
| 398 | |
Liran Alon | 6ca00df | 2019-06-16 15:03:10 +0300 | [diff] [blame] | 399 | #define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000 |
| 400 | |
Paolo Bonzini | cc440cd | 2020-05-13 13:36:32 -0400 | [diff] [blame] | 401 | #define KVM_STATE_NESTED_SVM_VMCB_SIZE 0x1000 |
| 402 | |
Peter Shier | 850448f | 2020-05-26 14:51:06 -0700 | [diff] [blame] | 403 | #define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001 |
Paolo Bonzini | cc440cd | 2020-05-13 13:36:32 -0400 | [diff] [blame] | 404 | |
Liran Alon | 6ca00df | 2019-06-16 15:03:10 +0300 | [diff] [blame] | 405 | struct kvm_vmx_nested_state_data { |
| 406 | __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; |
| 407 | __u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; |
| 408 | }; |
| 409 | |
| 410 | struct kvm_vmx_nested_state_hdr { |
Peter Shier | 850448f | 2020-05-26 14:51:06 -0700 | [diff] [blame] | 411 | __u32 flags; |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 412 | __u64 vmxon_pa; |
Liran Alon | 6ca00df | 2019-06-16 15:03:10 +0300 | [diff] [blame] | 413 | __u64 vmcs12_pa; |
Peter Shier | 850448f | 2020-05-26 14:51:06 -0700 | [diff] [blame] | 414 | __u64 preemption_timer_deadline; |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 415 | |
| 416 | struct { |
| 417 | __u16 flags; |
| 418 | } smm; |
| 419 | }; |
| 420 | |
Paolo Bonzini | cc440cd | 2020-05-13 13:36:32 -0400 | [diff] [blame] | 421 | struct kvm_svm_nested_state_data { |
| 422 | /* Save area only used if KVM_STATE_NESTED_RUN_PENDING. */ |
| 423 | __u8 vmcb12[KVM_STATE_NESTED_SVM_VMCB_SIZE]; |
| 424 | }; |
| 425 | |
| 426 | struct kvm_svm_nested_state_hdr { |
| 427 | __u64 vmcb_pa; |
| 428 | }; |
| 429 | |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 430 | /* for KVM_CAP_NESTED_STATE */ |
| 431 | struct kvm_nested_state { |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 432 | __u16 flags; |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 433 | __u16 format; |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 434 | __u32 size; |
| 435 | |
| 436 | union { |
Liran Alon | 6ca00df | 2019-06-16 15:03:10 +0300 | [diff] [blame] | 437 | struct kvm_vmx_nested_state_hdr vmx; |
Paolo Bonzini | cc440cd | 2020-05-13 13:36:32 -0400 | [diff] [blame] | 438 | struct kvm_svm_nested_state_hdr svm; |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 439 | |
| 440 | /* Pad the header to 128 bytes. */ |
| 441 | __u8 pad[120]; |
Liran Alon | 6ca00df | 2019-06-16 15:03:10 +0300 | [diff] [blame] | 442 | } hdr; |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 443 | |
Liran Alon | 6ca00df | 2019-06-16 15:03:10 +0300 | [diff] [blame] | 444 | /* |
| 445 | * Define data region as 0 bytes to preserve backwards-compatability |
| 446 | * to old definition of kvm_nested_state in order to avoid changing |
| 447 | * KVM_{GET,PUT}_NESTED_STATE ioctl values. |
| 448 | */ |
| 449 | union { |
| 450 | struct kvm_vmx_nested_state_data vmx[0]; |
Paolo Bonzini | cc440cd | 2020-05-13 13:36:32 -0400 | [diff] [blame] | 451 | struct kvm_svm_nested_state_data svm[0]; |
Liran Alon | 6ca00df | 2019-06-16 15:03:10 +0300 | [diff] [blame] | 452 | } data; |
Jim Mattson | 8fcc4b5 | 2018-07-10 11:27:20 +0200 | [diff] [blame] | 453 | }; |
| 454 | |
Eric Hankland | 66bb8a0 | 2019-07-10 18:25:15 -0700 | [diff] [blame] | 455 | /* for KVM_CAP_PMU_EVENT_FILTER */ |
| 456 | struct kvm_pmu_event_filter { |
Eric Hankland | 30cd860 | 2019-07-18 11:38:18 -0700 | [diff] [blame] | 457 | __u32 action; |
| 458 | __u32 nevents; |
| 459 | __u32 fixed_counter_bitmap; |
| 460 | __u32 flags; |
| 461 | __u32 pad[4]; |
| 462 | __u64 events[0]; |
Eric Hankland | 66bb8a0 | 2019-07-10 18:25:15 -0700 | [diff] [blame] | 463 | }; |
| 464 | |
| 465 | #define KVM_PMU_EVENT_ALLOW 0 |
| 466 | #define KVM_PMU_EVENT_DENY 1 |
| 467 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 468 | #endif /* _ASM_X86_KVM_H */ |