VirtualBox

source: vbox/trunk/include/VBox/vmm/hm_vmx.h@ 76993

Last change on this file since 76993 was 76993, checked in by vboxsync, 6 years ago

VMM: Nested VMX: bugref:9180 Allowing fetching VM-exit names from ring-0 as well. Various naming cleanups. Added HMDumpHwvirtVmxState() to be able to dump virtual VMCS state from ring-0 as well. Remove unusued HMIsVmxSupported() function.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 190.1 KB
Line 
1/** @file
2 * HM - VMX Structures and Definitions. (VMM)
3 */
4
5/*
6 * Copyright (C) 2006-2019 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_INCLUDED_vmm_hm_vmx_h
27#define VBOX_INCLUDED_vmm_hm_vmx_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <VBox/types.h>
33#include <iprt/x86.h>
34#include <iprt/assertcompile.h>
35
36/* In Visual C++ versions prior to 2012, the vmx intrinsics are only available
37 when targeting AMD64. */
38#if RT_INLINE_ASM_USES_INTRIN >= 16 && defined(RT_ARCH_AMD64)
39# pragma warning(push)
40# pragma warning(disable:4668) /* Several incorrect __cplusplus uses. */
41# pragma warning(disable:4255) /* Incorrect __slwpcb prototype. */
42# include <intrin.h>
43# pragma warning(pop)
44/* We always want them as intrinsics, no functions. */
45# pragma intrinsic(__vmx_on)
46# pragma intrinsic(__vmx_off)
47# pragma intrinsic(__vmx_vmclear)
48# pragma intrinsic(__vmx_vmptrld)
49# pragma intrinsic(__vmx_vmread)
50# pragma intrinsic(__vmx_vmwrite)
51# define VMX_USE_MSC_INTRINSICS 1
52#else
53# define VMX_USE_MSC_INTRINSICS 0
54#endif
55
56
57/** @defgroup grp_hm_vmx VMX Types and Definitions
58 * @ingroup grp_hm
59 * @{
60 */
61
62/** @name Host-state restoration flags.
63 * @note If you change these values don't forget to update the assembly
64 * defines as well!
65 * @{
66 */
67#define VMX_RESTORE_HOST_SEL_DS RT_BIT(0)
68#define VMX_RESTORE_HOST_SEL_ES RT_BIT(1)
69#define VMX_RESTORE_HOST_SEL_FS RT_BIT(2)
70#define VMX_RESTORE_HOST_SEL_GS RT_BIT(3)
71#define VMX_RESTORE_HOST_SEL_TR RT_BIT(4)
72#define VMX_RESTORE_HOST_GDTR RT_BIT(5)
73#define VMX_RESTORE_HOST_IDTR RT_BIT(6)
74#define VMX_RESTORE_HOST_GDT_READ_ONLY RT_BIT(7)
75#define VMX_RESTORE_HOST_REQUIRED RT_BIT(8)
76#define VMX_RESTORE_HOST_GDT_NEED_WRITABLE RT_BIT(9)
77/** @} */
78
79/**
80 * Host-state restoration structure.
81 * This holds host-state fields that require manual restoration.
82 * Assembly version found in hm_vmx.mac (should be automatically verified).
83 */
84typedef struct VMXRESTOREHOST
85{
86 RTSEL uHostSelDS; /* 0x00 */
87 RTSEL uHostSelES; /* 0x02 */
88 RTSEL uHostSelFS; /* 0x04 */
89 RTSEL uHostSelGS; /* 0x06 */
90 RTSEL uHostSelTR; /* 0x08 */
91 uint8_t abPadding0[4];
92 X86XDTR64 HostGdtr; /**< 0x0e - should be aligned by it's 64-bit member. */
93 uint8_t abPadding1[6];
94 X86XDTR64 HostGdtrRw; /**< 0x1e - should be aligned by it's 64-bit member. */
95 uint8_t abPadding2[6];
96 X86XDTR64 HostIdtr; /**< 0x2e - should be aligned by it's 64-bit member. */
97 uint64_t uHostFSBase; /* 0x38 */
98 uint64_t uHostGSBase; /* 0x40 */
99} VMXRESTOREHOST;
100/** Pointer to VMXRESTOREHOST. */
101typedef VMXRESTOREHOST *PVMXRESTOREHOST;
102AssertCompileSize(X86XDTR64, 10);
103AssertCompileMemberOffset(VMXRESTOREHOST, HostGdtr.uAddr, 16);
104AssertCompileMemberOffset(VMXRESTOREHOST, HostGdtrRw.uAddr, 32);
105AssertCompileMemberOffset(VMXRESTOREHOST, HostIdtr.uAddr, 48);
106AssertCompileMemberOffset(VMXRESTOREHOST, uHostFSBase, 56);
107AssertCompileSize(VMXRESTOREHOST, 72);
108AssertCompileSizeAlignment(VMXRESTOREHOST, 8);
109
110/** @name Host-state MSR lazy-restoration flags.
111 * @{
112 */
113/** The host MSRs have been saved. */
114#define VMX_LAZY_MSRS_SAVED_HOST RT_BIT(0)
115/** The guest MSRs are loaded and in effect. */
116#define VMX_LAZY_MSRS_LOADED_GUEST RT_BIT(1)
117/** @} */
118
119/** @name VMX HM-error codes for VERR_HM_UNSUPPORTED_CPU_FEATURE_COMBO.
120 * UFC = Unsupported Feature Combination.
121 * @{
122 */
123/** Unsupported pin-based VM-execution controls combo. */
124#define VMX_UFC_CTRL_PIN_EXEC 1
125/** Unsupported processor-based VM-execution controls combo. */
126#define VMX_UFC_CTRL_PROC_EXEC 2
127/** Unsupported move debug register VM-exit combo. */
128#define VMX_UFC_CTRL_PROC_MOV_DRX_EXIT 3
129/** Unsupported VM-entry controls combo. */
130#define VMX_UFC_CTRL_ENTRY 4
131/** Unsupported VM-exit controls combo. */
132#define VMX_UFC_CTRL_EXIT 5
133/** MSR storage capacity of the VMCS autoload/store area is not sufficient
134 * for storing host MSRs. */
135#define VMX_UFC_INSUFFICIENT_HOST_MSR_STORAGE 6
136/** MSR storage capacity of the VMCS autoload/store area is not sufficient
137 * for storing guest MSRs. */
138#define VMX_UFC_INSUFFICIENT_GUEST_MSR_STORAGE 7
139/** Invalid VMCS size. */
140#define VMX_UFC_INVALID_VMCS_SIZE 8
141/** Unsupported secondary processor-based VM-execution controls combo. */
142#define VMX_UFC_CTRL_PROC_EXEC2 9
143/** Invalid unrestricted-guest execution controls combo. */
144#define VMX_UFC_INVALID_UX_COMBO 10
145/** EPT flush type not supported. */
146#define VMX_UFC_EPT_FLUSH_TYPE_UNSUPPORTED 11
147/** EPT paging structure memory type is not write-back. */
148#define VMX_UFC_EPT_MEM_TYPE_NOT_WB 12
149/** EPT requires INVEPT instr. support but it's not available. */
150#define VMX_UFC_EPT_INVEPT_UNAVAILABLE 13
151/** EPT requires page-walk length of 4. */
152#define VMX_UFC_EPT_PAGE_WALK_LENGTH_UNSUPPORTED 14
153/** @} */
154
155/** @name VMX HM-error codes for VERR_VMX_VMCS_FIELD_CACHE_INVALID.
156 * VCI = VMCS-field Cache Invalid.
157 * @{
158 */
159/** Cache of VM-entry controls invalid. */
160#define VMX_VCI_CTRL_ENTRY 300
161/** Cache of VM-exit controls invalid. */
162#define VMX_VCI_CTRL_EXIT 301
163/** Cache of pin-based VM-execution controls invalid. */
164#define VMX_VCI_CTRL_PIN_EXEC 302
165/** Cache of processor-based VM-execution controls invalid. */
166#define VMX_VCI_CTRL_PROC_EXEC 303
167/** Cache of secondary processor-based VM-execution controls invalid. */
168#define VMX_VCI_CTRL_PROC_EXEC2 304
169/** Cache of exception bitmap invalid. */
170#define VMX_VCI_CTRL_XCPT_BITMAP 305
171/** Cache of TSC offset invalid. */
172#define VMX_VCI_CTRL_TSC_OFFSET 306
173/** @} */
174
175/** @name VMX HM-error codes for VERR_VMX_INVALID_GUEST_STATE.
176 * IGS = Invalid Guest State.
177 * @{
178 */
179/** An error occurred while checking invalid-guest-state. */
180#define VMX_IGS_ERROR 500
181/** The invalid guest-state checks did not find any reason why. */
182#define VMX_IGS_REASON_NOT_FOUND 501
183/** CR0 fixed1 bits invalid. */
184#define VMX_IGS_CR0_FIXED1 502
185/** CR0 fixed0 bits invalid. */
186#define VMX_IGS_CR0_FIXED0 503
187/** CR0.PE and CR0.PE invalid VT-x/host combination. */
188#define VMX_IGS_CR0_PG_PE_COMBO 504
189/** CR4 fixed1 bits invalid. */
190#define VMX_IGS_CR4_FIXED1 505
191/** CR4 fixed0 bits invalid. */
192#define VMX_IGS_CR4_FIXED0 506
193/** Reserved bits in VMCS' DEBUGCTL MSR field not set to 0 when
194 * VMX_VMCS_CTRL_ENTRY_LOAD_DEBUG is used. */
195#define VMX_IGS_DEBUGCTL_MSR_RESERVED 507
196/** CR0.PG not set for long-mode when not using unrestricted guest. */
197#define VMX_IGS_CR0_PG_LONGMODE 508
198/** CR4.PAE not set for long-mode guest when not using unrestricted guest. */
199#define VMX_IGS_CR4_PAE_LONGMODE 509
200/** CR4.PCIDE set for 32-bit guest. */
201#define VMX_IGS_CR4_PCIDE 510
202/** VMCS' DR7 reserved bits not set to 0. */
203#define VMX_IGS_DR7_RESERVED 511
204/** VMCS' PERF_GLOBAL MSR reserved bits not set to 0. */
205#define VMX_IGS_PERF_GLOBAL_MSR_RESERVED 512
206/** VMCS' EFER MSR reserved bits not set to 0. */
207#define VMX_IGS_EFER_MSR_RESERVED 513
208/** VMCS' EFER MSR.LMA does not match the IA32e mode guest control. */
209#define VMX_IGS_EFER_LMA_GUEST_MODE_MISMATCH 514
210/** VMCS' EFER MSR.LMA does not match EFER.LME of the guest when using paging
211 * without unrestricted guest. */
212#define VMX_IGS_EFER_LMA_LME_MISMATCH 515
213/** CS.Attr.P bit invalid. */
214#define VMX_IGS_CS_ATTR_P_INVALID 516
215/** CS.Attr reserved bits not set to 0. */
216#define VMX_IGS_CS_ATTR_RESERVED 517
217/** CS.Attr.G bit invalid. */
218#define VMX_IGS_CS_ATTR_G_INVALID 518
219/** CS is unusable. */
220#define VMX_IGS_CS_ATTR_UNUSABLE 519
221/** CS and SS DPL unequal. */
222#define VMX_IGS_CS_SS_ATTR_DPL_UNEQUAL 520
223/** CS and SS DPL mismatch. */
224#define VMX_IGS_CS_SS_ATTR_DPL_MISMATCH 521
225/** CS Attr.Type invalid. */
226#define VMX_IGS_CS_ATTR_TYPE_INVALID 522
227/** CS and SS RPL unequal. */
228#define VMX_IGS_SS_CS_RPL_UNEQUAL 523
229/** SS.Attr.DPL and SS RPL unequal. */
230#define VMX_IGS_SS_ATTR_DPL_RPL_UNEQUAL 524
231/** SS.Attr.DPL invalid for segment type. */
232#define VMX_IGS_SS_ATTR_DPL_INVALID 525
233/** SS.Attr.Type invalid. */
234#define VMX_IGS_SS_ATTR_TYPE_INVALID 526
235/** SS.Attr.P bit invalid. */
236#define VMX_IGS_SS_ATTR_P_INVALID 527
237/** SS.Attr reserved bits not set to 0. */
238#define VMX_IGS_SS_ATTR_RESERVED 528
239/** SS.Attr.G bit invalid. */
240#define VMX_IGS_SS_ATTR_G_INVALID 529
241/** DS.Attr.A bit invalid. */
242#define VMX_IGS_DS_ATTR_A_INVALID 530
243/** DS.Attr.P bit invalid. */
244#define VMX_IGS_DS_ATTR_P_INVALID 531
245/** DS.Attr.DPL and DS RPL unequal. */
246#define VMX_IGS_DS_ATTR_DPL_RPL_UNEQUAL 532
247/** DS.Attr reserved bits not set to 0. */
248#define VMX_IGS_DS_ATTR_RESERVED 533
249/** DS.Attr.G bit invalid. */
250#define VMX_IGS_DS_ATTR_G_INVALID 534
251/** DS.Attr.Type invalid. */
252#define VMX_IGS_DS_ATTR_TYPE_INVALID 535
253/** ES.Attr.A bit invalid. */
254#define VMX_IGS_ES_ATTR_A_INVALID 536
255/** ES.Attr.P bit invalid. */
256#define VMX_IGS_ES_ATTR_P_INVALID 537
257/** ES.Attr.DPL and DS RPL unequal. */
258#define VMX_IGS_ES_ATTR_DPL_RPL_UNEQUAL 538
259/** ES.Attr reserved bits not set to 0. */
260#define VMX_IGS_ES_ATTR_RESERVED 539
261/** ES.Attr.G bit invalid. */
262#define VMX_IGS_ES_ATTR_G_INVALID 540
263/** ES.Attr.Type invalid. */
264#define VMX_IGS_ES_ATTR_TYPE_INVALID 541
265/** FS.Attr.A bit invalid. */
266#define VMX_IGS_FS_ATTR_A_INVALID 542
267/** FS.Attr.P bit invalid. */
268#define VMX_IGS_FS_ATTR_P_INVALID 543
269/** FS.Attr.DPL and DS RPL unequal. */
270#define VMX_IGS_FS_ATTR_DPL_RPL_UNEQUAL 544
271/** FS.Attr reserved bits not set to 0. */
272#define VMX_IGS_FS_ATTR_RESERVED 545
273/** FS.Attr.G bit invalid. */
274#define VMX_IGS_FS_ATTR_G_INVALID 546
275/** FS.Attr.Type invalid. */
276#define VMX_IGS_FS_ATTR_TYPE_INVALID 547
277/** GS.Attr.A bit invalid. */
278#define VMX_IGS_GS_ATTR_A_INVALID 548
279/** GS.Attr.P bit invalid. */
280#define VMX_IGS_GS_ATTR_P_INVALID 549
281/** GS.Attr.DPL and DS RPL unequal. */
282#define VMX_IGS_GS_ATTR_DPL_RPL_UNEQUAL 550
283/** GS.Attr reserved bits not set to 0. */
284#define VMX_IGS_GS_ATTR_RESERVED 551
285/** GS.Attr.G bit invalid. */
286#define VMX_IGS_GS_ATTR_G_INVALID 552
287/** GS.Attr.Type invalid. */
288#define VMX_IGS_GS_ATTR_TYPE_INVALID 553
289/** V86 mode CS.Base invalid. */
290#define VMX_IGS_V86_CS_BASE_INVALID 554
291/** V86 mode CS.Limit invalid. */
292#define VMX_IGS_V86_CS_LIMIT_INVALID 555
293/** V86 mode CS.Attr invalid. */
294#define VMX_IGS_V86_CS_ATTR_INVALID 556
295/** V86 mode SS.Base invalid. */
296#define VMX_IGS_V86_SS_BASE_INVALID 557
297/** V86 mode SS.Limit invalid. */
298#define VMX_IGS_V86_SS_LIMIT_INVALID 558
299/** V86 mode SS.Attr invalid. */
300#define VMX_IGS_V86_SS_ATTR_INVALID 559
301/** V86 mode DS.Base invalid. */
302#define VMX_IGS_V86_DS_BASE_INVALID 560
303/** V86 mode DS.Limit invalid. */
304#define VMX_IGS_V86_DS_LIMIT_INVALID 561
305/** V86 mode DS.Attr invalid. */
306#define VMX_IGS_V86_DS_ATTR_INVALID 562
307/** V86 mode ES.Base invalid. */
308#define VMX_IGS_V86_ES_BASE_INVALID 563
309/** V86 mode ES.Limit invalid. */
310#define VMX_IGS_V86_ES_LIMIT_INVALID 564
311/** V86 mode ES.Attr invalid. */
312#define VMX_IGS_V86_ES_ATTR_INVALID 565
313/** V86 mode FS.Base invalid. */
314#define VMX_IGS_V86_FS_BASE_INVALID 566
315/** V86 mode FS.Limit invalid. */
316#define VMX_IGS_V86_FS_LIMIT_INVALID 567
317/** V86 mode FS.Attr invalid. */
318#define VMX_IGS_V86_FS_ATTR_INVALID 568
319/** V86 mode GS.Base invalid. */
320#define VMX_IGS_V86_GS_BASE_INVALID 569
321/** V86 mode GS.Limit invalid. */
322#define VMX_IGS_V86_GS_LIMIT_INVALID 570
323/** V86 mode GS.Attr invalid. */
324#define VMX_IGS_V86_GS_ATTR_INVALID 571
325/** Longmode CS.Base invalid. */
326#define VMX_IGS_LONGMODE_CS_BASE_INVALID 572
327/** Longmode SS.Base invalid. */
328#define VMX_IGS_LONGMODE_SS_BASE_INVALID 573
329/** Longmode DS.Base invalid. */
330#define VMX_IGS_LONGMODE_DS_BASE_INVALID 574
331/** Longmode ES.Base invalid. */
332#define VMX_IGS_LONGMODE_ES_BASE_INVALID 575
333/** SYSENTER ESP is not canonical. */
334#define VMX_IGS_SYSENTER_ESP_NOT_CANONICAL 576
335/** SYSENTER EIP is not canonical. */
336#define VMX_IGS_SYSENTER_EIP_NOT_CANONICAL 577
337/** PAT MSR invalid. */
338#define VMX_IGS_PAT_MSR_INVALID 578
339/** PAT MSR reserved bits not set to 0. */
340#define VMX_IGS_PAT_MSR_RESERVED 579
341/** GDTR.Base is not canonical. */
342#define VMX_IGS_GDTR_BASE_NOT_CANONICAL 580
343/** IDTR.Base is not canonical. */
344#define VMX_IGS_IDTR_BASE_NOT_CANONICAL 581
345/** GDTR.Limit invalid. */
346#define VMX_IGS_GDTR_LIMIT_INVALID 582
347/** IDTR.Limit invalid. */
348#define VMX_IGS_IDTR_LIMIT_INVALID 583
349/** Longmode RIP is invalid. */
350#define VMX_IGS_LONGMODE_RIP_INVALID 584
351/** RFLAGS reserved bits not set to 0. */
352#define VMX_IGS_RFLAGS_RESERVED 585
353/** RFLAGS RA1 reserved bits not set to 1. */
354#define VMX_IGS_RFLAGS_RESERVED1 586
355/** RFLAGS.VM (V86 mode) invalid. */
356#define VMX_IGS_RFLAGS_VM_INVALID 587
357/** RFLAGS.IF invalid. */
358#define VMX_IGS_RFLAGS_IF_INVALID 588
359/** Activity state invalid. */
360#define VMX_IGS_ACTIVITY_STATE_INVALID 589
361/** Activity state HLT invalid when SS.Attr.DPL is not zero. */
362#define VMX_IGS_ACTIVITY_STATE_HLT_INVALID 590
363/** Activity state ACTIVE invalid when block-by-STI or MOV SS. */
364#define VMX_IGS_ACTIVITY_STATE_ACTIVE_INVALID 591
365/** Activity state SIPI WAIT invalid. */
366#define VMX_IGS_ACTIVITY_STATE_SIPI_WAIT_INVALID 592
367/** Interruptibility state reserved bits not set to 0. */
368#define VMX_IGS_INTERRUPTIBILITY_STATE_RESERVED 593
369/** Interruptibility state cannot be block-by-STI -and- MOV SS. */
370#define VMX_IGS_INTERRUPTIBILITY_STATE_STI_MOVSS_INVALID 594
371/** Interruptibility state block-by-STI invalid for EFLAGS. */
372#define VMX_IGS_INTERRUPTIBILITY_STATE_STI_EFL_INVALID 595
373/** Interruptibility state invalid while trying to deliver external
374 * interrupt. */
375#define VMX_IGS_INTERRUPTIBILITY_STATE_EXT_INT_INVALID 596
376/** Interruptibility state block-by-MOVSS invalid while trying to deliver an
377 * NMI. */
378#define VMX_IGS_INTERRUPTIBILITY_STATE_MOVSS_INVALID 597
379/** Interruptibility state block-by-SMI invalid when CPU is not in SMM. */
380#define VMX_IGS_INTERRUPTIBILITY_STATE_SMI_INVALID 598
381/** Interruptibility state block-by-SMI invalid when trying to enter SMM. */
382#define VMX_IGS_INTERRUPTIBILITY_STATE_SMI_SMM_INVALID 599
383/** Interruptibility state block-by-STI (maybe) invalid when trying to
384 * deliver an NMI. */
385#define VMX_IGS_INTERRUPTIBILITY_STATE_STI_INVALID 600
386/** Interruptibility state block-by-NMI invalid when virtual-NMIs control is
387 * active. */
388#define VMX_IGS_INTERRUPTIBILITY_STATE_NMI_INVALID 601
389/** Pending debug exceptions reserved bits not set to 0. */
390#define VMX_IGS_PENDING_DEBUG_RESERVED 602
391/** Longmode pending debug exceptions reserved bits not set to 0. */
392#define VMX_IGS_LONGMODE_PENDING_DEBUG_RESERVED 603
393/** Pending debug exceptions.BS bit is not set when it should be. */
394#define VMX_IGS_PENDING_DEBUG_XCPT_BS_NOT_SET 604
395/** Pending debug exceptions.BS bit is not clear when it should be. */
396#define VMX_IGS_PENDING_DEBUG_XCPT_BS_NOT_CLEAR 605
397/** VMCS link pointer reserved bits not set to 0. */
398#define VMX_IGS_VMCS_LINK_PTR_RESERVED 606
399/** TR cannot index into LDT, TI bit MBZ. */
400#define VMX_IGS_TR_TI_INVALID 607
401/** LDTR cannot index into LDT. TI bit MBZ. */
402#define VMX_IGS_LDTR_TI_INVALID 608
403/** TR.Base is not canonical. */
404#define VMX_IGS_TR_BASE_NOT_CANONICAL 609
405/** FS.Base is not canonical. */
406#define VMX_IGS_FS_BASE_NOT_CANONICAL 610
407/** GS.Base is not canonical. */
408#define VMX_IGS_GS_BASE_NOT_CANONICAL 611
409/** LDTR.Base is not canonical. */
410#define VMX_IGS_LDTR_BASE_NOT_CANONICAL 612
411/** TR is unusable. */
412#define VMX_IGS_TR_ATTR_UNUSABLE 613
413/** TR.Attr.S bit invalid. */
414#define VMX_IGS_TR_ATTR_S_INVALID 614
415/** TR is not present. */
416#define VMX_IGS_TR_ATTR_P_INVALID 615
417/** TR.Attr reserved bits not set to 0. */
418#define VMX_IGS_TR_ATTR_RESERVED 616
419/** TR.Attr.G bit invalid. */
420#define VMX_IGS_TR_ATTR_G_INVALID 617
421/** Longmode TR.Attr.Type invalid. */
422#define VMX_IGS_LONGMODE_TR_ATTR_TYPE_INVALID 618
423/** TR.Attr.Type invalid. */
424#define VMX_IGS_TR_ATTR_TYPE_INVALID 619
425/** CS.Attr.S invalid. */
426#define VMX_IGS_CS_ATTR_S_INVALID 620
427/** CS.Attr.DPL invalid. */
428#define VMX_IGS_CS_ATTR_DPL_INVALID 621
429/** PAE PDPTE reserved bits not set to 0. */
430#define VMX_IGS_PAE_PDPTE_RESERVED 623
431/** @} */
432
433/** @name VMX VMCS-Read cache indices.
434 * @{
435 */
436#define VMX_VMCS_GUEST_ES_BASE_CACHE_IDX 0
437#define VMX_VMCS_GUEST_CS_BASE_CACHE_IDX 1
438#define VMX_VMCS_GUEST_SS_BASE_CACHE_IDX 2
439#define VMX_VMCS_GUEST_DS_BASE_CACHE_IDX 3
440#define VMX_VMCS_GUEST_FS_BASE_CACHE_IDX 4
441#define VMX_VMCS_GUEST_GS_BASE_CACHE_IDX 5
442#define VMX_VMCS_GUEST_LDTR_BASE_CACHE_IDX 6
443#define VMX_VMCS_GUEST_TR_BASE_CACHE_IDX 7
444#define VMX_VMCS_GUEST_GDTR_BASE_CACHE_IDX 8
445#define VMX_VMCS_GUEST_IDTR_BASE_CACHE_IDX 9
446#define VMX_VMCS_GUEST_RSP_CACHE_IDX 10
447#define VMX_VMCS_GUEST_RIP_CACHE_IDX 11
448#define VMX_VMCS_GUEST_SYSENTER_ESP_CACHE_IDX 12
449#define VMX_VMCS_GUEST_SYSENTER_EIP_CACHE_IDX 13
450#define VMX_VMCS_RO_EXIT_QUALIFICATION_CACHE_IDX 14
451#define VMX_VMCS_RO_GUEST_LINEAR_ADDR_CACHE_IDX 15
452#define VMX_VMCS_MAX_CACHE_IDX (VMX_VMCS_RO_GUEST_LINEAR_ADDR_CACHE_IDX + 1)
453#define VMX_VMCS_GUEST_CR3_CACHE_IDX 16
454#define VMX_VMCS_MAX_NESTED_PAGING_CACHE_IDX (VMX_VMCS_GUEST_CR3_CACHE_IDX + 1)
455/** @} */
456
457/** @name VMX EPT paging structures
458 * @{
459 */
460
461/**
462 * Number of page table entries in the EPT. (PDPTE/PDE/PTE)
463 */
464#define EPT_PG_ENTRIES X86_PG_PAE_ENTRIES
465
466/**
467 * EPT Page Directory Pointer Entry. Bit view.
468 * @todo uint64_t isn't safe for bitfields (gcc pedantic warnings, and IIRC,
469 * this did cause trouble with one compiler/version).
470 */
471typedef struct EPTPML4EBITS
472{
473 /** Present bit. */
474 RT_GCC_EXTENSION uint64_t u1Present : 1;
475 /** Writable bit. */
476 RT_GCC_EXTENSION uint64_t u1Write : 1;
477 /** Executable bit. */
478 RT_GCC_EXTENSION uint64_t u1Execute : 1;
479 /** Reserved (must be 0). */
480 RT_GCC_EXTENSION uint64_t u5Reserved : 5;
481 /** Available for software. */
482 RT_GCC_EXTENSION uint64_t u4Available : 4;
483 /** Physical address of the next level (PD). Restricted by maximum physical address width of the cpu. */
484 RT_GCC_EXTENSION uint64_t u40PhysAddr : 40;
485 /** Available for software. */
486 RT_GCC_EXTENSION uint64_t u12Available : 12;
487} EPTPML4EBITS;
488AssertCompileSize(EPTPML4EBITS, 8);
489
490/** Bits 12-51 - - EPT - Physical Page number of the next level. */
491#define EPT_PML4E_PG_MASK X86_PML4E_PG_MASK
492/** The page shift to get the PML4 index. */
493#define EPT_PML4_SHIFT X86_PML4_SHIFT
494/** The PML4 index mask (apply to a shifted page address). */
495#define EPT_PML4_MASK X86_PML4_MASK
496
497/**
498 * EPT PML4E.
499 */
500typedef union EPTPML4E
501{
502 /** Normal view. */
503 EPTPML4EBITS n;
504 /** Unsigned integer view. */
505 X86PGPAEUINT u;
506 /** 64 bit unsigned integer view. */
507 uint64_t au64[1];
508 /** 32 bit unsigned integer view. */
509 uint32_t au32[2];
510} EPTPML4E;
511AssertCompileSize(EPTPML4E, 8);
512/** Pointer to a PML4 table entry. */
513typedef EPTPML4E *PEPTPML4E;
514/** Pointer to a const PML4 table entry. */
515typedef const EPTPML4E *PCEPTPML4E;
516
517/**
518 * EPT PML4 Table.
519 */
520typedef struct EPTPML4
521{
522 EPTPML4E a[EPT_PG_ENTRIES];
523} EPTPML4;
524AssertCompileSize(EPTPML4, 0x1000);
525/** Pointer to an EPT PML4 Table. */
526typedef EPTPML4 *PEPTPML4;
527/** Pointer to a const EPT PML4 Table. */
528typedef const EPTPML4 *PCEPTPML4;
529
530/**
531 * EPT Page Directory Pointer Entry. Bit view.
532 */
533typedef struct EPTPDPTEBITS
534{
535 /** Present bit. */
536 RT_GCC_EXTENSION uint64_t u1Present : 1;
537 /** Writable bit. */
538 RT_GCC_EXTENSION uint64_t u1Write : 1;
539 /** Executable bit. */
540 RT_GCC_EXTENSION uint64_t u1Execute : 1;
541 /** Reserved (must be 0). */
542 RT_GCC_EXTENSION uint64_t u5Reserved : 5;
543 /** Available for software. */
544 RT_GCC_EXTENSION uint64_t u4Available : 4;
545 /** Physical address of the next level (PD). Restricted by maximum physical address width of the cpu. */
546 RT_GCC_EXTENSION uint64_t u40PhysAddr : 40;
547 /** Available for software. */
548 RT_GCC_EXTENSION uint64_t u12Available : 12;
549} EPTPDPTEBITS;
550AssertCompileSize(EPTPDPTEBITS, 8);
551
552/** Bits 12-51 - - EPT - Physical Page number of the next level. */
553#define EPT_PDPTE_PG_MASK X86_PDPE_PG_MASK
554/** The page shift to get the PDPT index. */
555#define EPT_PDPT_SHIFT X86_PDPT_SHIFT
556/** The PDPT index mask (apply to a shifted page address). */
557#define EPT_PDPT_MASK X86_PDPT_MASK_AMD64
558
559/**
560 * EPT Page Directory Pointer.
561 */
562typedef union EPTPDPTE
563{
564 /** Normal view. */
565 EPTPDPTEBITS n;
566 /** Unsigned integer view. */
567 X86PGPAEUINT u;
568 /** 64 bit unsigned integer view. */
569 uint64_t au64[1];
570 /** 32 bit unsigned integer view. */
571 uint32_t au32[2];
572} EPTPDPTE;
573AssertCompileSize(EPTPDPTE, 8);
574/** Pointer to an EPT Page Directory Pointer Entry. */
575typedef EPTPDPTE *PEPTPDPTE;
576/** Pointer to a const EPT Page Directory Pointer Entry. */
577typedef const EPTPDPTE *PCEPTPDPTE;
578
579/**
580 * EPT Page Directory Pointer Table.
581 */
582typedef struct EPTPDPT
583{
584 EPTPDPTE a[EPT_PG_ENTRIES];
585} EPTPDPT;
586AssertCompileSize(EPTPDPT, 0x1000);
587/** Pointer to an EPT Page Directory Pointer Table. */
588typedef EPTPDPT *PEPTPDPT;
589/** Pointer to a const EPT Page Directory Pointer Table. */
590typedef const EPTPDPT *PCEPTPDPT;
591
592/**
593 * EPT Page Directory Table Entry. Bit view.
594 */
595typedef struct EPTPDEBITS
596{
597 /** Present bit. */
598 RT_GCC_EXTENSION uint64_t u1Present : 1;
599 /** Writable bit. */
600 RT_GCC_EXTENSION uint64_t u1Write : 1;
601 /** Executable bit. */
602 RT_GCC_EXTENSION uint64_t u1Execute : 1;
603 /** Reserved (must be 0). */
604 RT_GCC_EXTENSION uint64_t u4Reserved : 4;
605 /** Big page (must be 0 here). */
606 RT_GCC_EXTENSION uint64_t u1Size : 1;
607 /** Available for software. */
608 RT_GCC_EXTENSION uint64_t u4Available : 4;
609 /** Physical address of page table. Restricted by maximum physical address width of the cpu. */
610 RT_GCC_EXTENSION uint64_t u40PhysAddr : 40;
611 /** Available for software. */
612 RT_GCC_EXTENSION uint64_t u12Available : 12;
613} EPTPDEBITS;
614AssertCompileSize(EPTPDEBITS, 8);
615
616/** Bits 12-51 - - EPT - Physical Page number of the next level. */
617#define EPT_PDE_PG_MASK X86_PDE_PAE_PG_MASK
618/** The page shift to get the PD index. */
619#define EPT_PD_SHIFT X86_PD_PAE_SHIFT
620/** The PD index mask (apply to a shifted page address). */
621#define EPT_PD_MASK X86_PD_PAE_MASK
622
623/**
624 * EPT 2MB Page Directory Table Entry. Bit view.
625 */
626typedef struct EPTPDE2MBITS
627{
628 /** Present bit. */
629 RT_GCC_EXTENSION uint64_t u1Present : 1;
630 /** Writable bit. */
631 RT_GCC_EXTENSION uint64_t u1Write : 1;
632 /** Executable bit. */
633 RT_GCC_EXTENSION uint64_t u1Execute : 1;
634 /** EPT Table Memory Type. MBZ for non-leaf nodes. */
635 RT_GCC_EXTENSION uint64_t u3EMT : 3;
636 /** Ignore PAT memory type */
637 RT_GCC_EXTENSION uint64_t u1IgnorePAT : 1;
638 /** Big page (must be 1 here). */
639 RT_GCC_EXTENSION uint64_t u1Size : 1;
640 /** Available for software. */
641 RT_GCC_EXTENSION uint64_t u4Available : 4;
642 /** Reserved (must be 0). */
643 RT_GCC_EXTENSION uint64_t u9Reserved : 9;
644 /** Physical address of the 2MB page. Restricted by maximum physical address width of the cpu. */
645 RT_GCC_EXTENSION uint64_t u31PhysAddr : 31;
646 /** Available for software. */
647 RT_GCC_EXTENSION uint64_t u12Available : 12;
648} EPTPDE2MBITS;
649AssertCompileSize(EPTPDE2MBITS, 8);
650
651/** Bits 21-51 - - EPT - Physical Page number of the next level. */
652#define EPT_PDE2M_PG_MASK X86_PDE2M_PAE_PG_MASK
653
654/**
655 * EPT Page Directory Table Entry.
656 */
657typedef union EPTPDE
658{
659 /** Normal view. */
660 EPTPDEBITS n;
661 /** 2MB view (big). */
662 EPTPDE2MBITS b;
663 /** Unsigned integer view. */
664 X86PGPAEUINT u;
665 /** 64 bit unsigned integer view. */
666 uint64_t au64[1];
667 /** 32 bit unsigned integer view. */
668 uint32_t au32[2];
669} EPTPDE;
670AssertCompileSize(EPTPDE, 8);
671/** Pointer to an EPT Page Directory Table Entry. */
672typedef EPTPDE *PEPTPDE;
673/** Pointer to a const EPT Page Directory Table Entry. */
674typedef const EPTPDE *PCEPTPDE;
675
676/**
677 * EPT Page Directory Table.
678 */
679typedef struct EPTPD
680{
681 EPTPDE a[EPT_PG_ENTRIES];
682} EPTPD;
683AssertCompileSize(EPTPD, 0x1000);
684/** Pointer to an EPT Page Directory Table. */
685typedef EPTPD *PEPTPD;
686/** Pointer to a const EPT Page Directory Table. */
687typedef const EPTPD *PCEPTPD;
688
689/**
690 * EPT Page Table Entry. Bit view.
691 */
692typedef struct EPTPTEBITS
693{
694 /** 0 - Present bit.
695 * @remarks This is a convenience "misnomer". The bit actually indicates read access
696 * and the CPU will consider an entry with any of the first three bits set
697 * as present. Since all our valid entries will have this bit set, it can
698 * be used as a present indicator and allow some code sharing. */
699 RT_GCC_EXTENSION uint64_t u1Present : 1;
700 /** 1 - Writable bit. */
701 RT_GCC_EXTENSION uint64_t u1Write : 1;
702 /** 2 - Executable bit. */
703 RT_GCC_EXTENSION uint64_t u1Execute : 1;
704 /** 5:3 - EPT Memory Type. MBZ for non-leaf nodes. */
705 RT_GCC_EXTENSION uint64_t u3EMT : 3;
706 /** 6 - Ignore PAT memory type */
707 RT_GCC_EXTENSION uint64_t u1IgnorePAT : 1;
708 /** 11:7 - Available for software. */
709 RT_GCC_EXTENSION uint64_t u5Available : 5;
710 /** 51:12 - Physical address of page. Restricted by maximum physical
711 * address width of the cpu. */
712 RT_GCC_EXTENSION uint64_t u40PhysAddr : 40;
713 /** 63:52 - Available for software. */
714 RT_GCC_EXTENSION uint64_t u12Available : 12;
715} EPTPTEBITS;
716AssertCompileSize(EPTPTEBITS, 8);
717
718/** Bits 12-51 - - EPT - Physical Page number of the next level. */
719#define EPT_PTE_PG_MASK X86_PTE_PAE_PG_MASK
720/** The page shift to get the EPT PTE index. */
721#define EPT_PT_SHIFT X86_PT_PAE_SHIFT
722/** The EPT PT index mask (apply to a shifted page address). */
723#define EPT_PT_MASK X86_PT_PAE_MASK
724
725/**
726 * EPT Page Table Entry.
727 */
728typedef union EPTPTE
729{
730 /** Normal view. */
731 EPTPTEBITS n;
732 /** Unsigned integer view. */
733 X86PGPAEUINT u;
734 /** 64 bit unsigned integer view. */
735 uint64_t au64[1];
736 /** 32 bit unsigned integer view. */
737 uint32_t au32[2];
738} EPTPTE;
739AssertCompileSize(EPTPTE, 8);
740/** Pointer to an EPT Page Directory Table Entry. */
741typedef EPTPTE *PEPTPTE;
742/** Pointer to a const EPT Page Directory Table Entry. */
743typedef const EPTPTE *PCEPTPTE;
744
745/**
746 * EPT Page Table.
747 */
748typedef struct EPTPT
749{
750 EPTPTE a[EPT_PG_ENTRIES];
751} EPTPT;
752AssertCompileSize(EPTPT, 0x1000);
753/** Pointer to an extended page table. */
754typedef EPTPT *PEPTPT;
755/** Pointer to a const extended table. */
756typedef const EPTPT *PCEPTPT;
757
758/** @} */
759
760/**
761 * VMX VPID flush types.
762 * @note Valid enum members are in accordance to the VT-x spec.
763 */
764typedef enum
765{
766 /** Invalidate a specific page. */
767 VMXTLBFLUSHVPID_INDIV_ADDR = 0,
768 /** Invalidate one context (specific VPID). */
769 VMXTLBFLUSHVPID_SINGLE_CONTEXT = 1,
770 /** Invalidate all contexts (all VPIDs). */
771 VMXTLBFLUSHVPID_ALL_CONTEXTS = 2,
772 /** Invalidate a single VPID context retaining global mappings. */
773 VMXTLBFLUSHVPID_SINGLE_CONTEXT_RETAIN_GLOBALS = 3,
774 /** Unsupported by VirtualBox. */
775 VMXTLBFLUSHVPID_NOT_SUPPORTED = 0xbad0,
776 /** Unsupported by CPU. */
777 VMXTLBFLUSHVPID_NONE = 0xbad1
778} VMXTLBFLUSHVPID;
779AssertCompileSize(VMXTLBFLUSHVPID, 4);
780
781/**
782 * VMX EPT flush types.
783 * @note Valid enums values are in accordance to the VT-x spec.
784 */
785typedef enum
786{
787 /** Invalidate one context (specific EPT). */
788 VMXTLBFLUSHEPT_SINGLE_CONTEXT = 1,
789 /* Invalidate all contexts (all EPTs) */
790 VMXTLBFLUSHEPT_ALL_CONTEXTS = 2,
791 /** Unsupported by VirtualBox. */
792 VMXTLBFLUSHEPT_NOT_SUPPORTED = 0xbad0,
793 /** Unsupported by CPU. */
794 VMXTLBFLUSHEPT_NONE = 0xbad1
795} VMXTLBFLUSHEPT;
796AssertCompileSize(VMXTLBFLUSHEPT, 4);
797
798/**
799 * VMX Posted Interrupt Descriptor.
800 * In accordance to the VT-x spec.
801 */
802typedef struct VMXPOSTEDINTRDESC
803{
804 uint32_t aVectorBitmap[8];
805 uint32_t fOutstandingNotification : 1;
806 uint32_t uReserved0 : 31;
807 uint8_t au8Reserved0[28];
808} VMXPOSTEDINTRDESC;
809AssertCompileMemberSize(VMXPOSTEDINTRDESC, aVectorBitmap, 32);
810AssertCompileSize(VMXPOSTEDINTRDESC, 64);
811/** Pointer to a posted interrupt descriptor. */
812typedef VMXPOSTEDINTRDESC *PVMXPOSTEDINTRDESC;
813/** Pointer to a const posted interrupt descriptor. */
814typedef const VMXPOSTEDINTRDESC *PCVMXPOSTEDINTRDESC;
815
816/**
817 * VMX VMCS revision identifier.
818 */
819typedef union
820{
821 struct
822 {
823 /** Revision identifier. */
824 uint32_t u31RevisionId : 31;
825 /** Whether this is a shadow VMCS. */
826 uint32_t fIsShadowVmcs : 1;
827 } n;
828 /* The unsigned integer view. */
829 uint32_t u;
830} VMXVMCSREVID;
831AssertCompileSize(VMXVMCSREVID, 4);
832/** Pointer to the VMXVMCSREVID union. */
833typedef VMXVMCSREVID *PVMXVMCSREVID;
834/** Pointer to a const VMXVMCSREVID union. */
835typedef const VMXVMCSREVID *PCVMXVMCSREVID;
836
837/**
838 * VMX VM-exit instruction information.
839 */
840typedef union
841{
842 /** Plain unsigned int representation. */
843 uint32_t u;
844
845 /** INS and OUTS information. */
846 struct
847 {
848 uint32_t u7Reserved0 : 7;
849 /** The address size; 0=16-bit, 1=32-bit, 2=64-bit, rest undefined. */
850 uint32_t u3AddrSize : 3;
851 uint32_t u5Reserved1 : 5;
852 /** The segment register (X86_SREG_XXX). */
853 uint32_t iSegReg : 3;
854 uint32_t uReserved2 : 14;
855 } StrIo;
856
857 struct
858 {
859 /** Scaling; 0=no scaling, 1=scale-by-2, 2=scale-by-4, 3=scale-by-8. */
860 uint32_t u2Scaling : 2;
861 uint32_t u5Undef0 : 5;
862 /** The address size; 0=16-bit, 1=32-bit, 2=64-bit, rest undefined. */
863 uint32_t u3AddrSize : 3;
864 /** Cleared to 0. */
865 uint32_t u1Cleared0 : 1;
866 uint32_t u4Undef0 : 4;
867 /** The segment register (X86_SREG_XXX). */
868 uint32_t iSegReg : 3;
869 /** The index register (X86_GREG_XXX). */
870 uint32_t iIdxReg : 4;
871 /** Set if index register is invalid. */
872 uint32_t fIdxRegInvalid : 1;
873 /** The base register (X86_GREG_XXX). */
874 uint32_t iBaseReg : 4;
875 /** Set if base register is invalid. */
876 uint32_t fBaseRegInvalid : 1;
877 /** Register 2 (X86_GREG_XXX). */
878 uint32_t iReg2 : 4;
879 } Inv;
880
881 /** VMCLEAR, VMPTRLD, VMPTRST, VMXON, XRSTORS, XSAVES information. */
882 struct
883 {
884 /** Scaling; 0=no scaling, 1=scale-by-2, 2=scale-by-4, 3=scale-by-8. */
885 uint32_t u2Scaling : 2;
886 uint32_t u5Reserved0 : 5;
887 /** The address size; 0=16-bit, 1=32-bit, 2=64-bit, rest undefined. */
888 uint32_t u3AddrSize : 3;
889 /** Cleared to 0. */
890 uint32_t u1Cleared0 : 1;
891 uint32_t u4Reserved0 : 4;
892 /** The segment register (X86_SREG_XXX). */
893 uint32_t iSegReg : 3;
894 /** The index register (X86_GREG_XXX). */
895 uint32_t iIdxReg : 4;
896 /** Set if index register is invalid. */
897 uint32_t fIdxRegInvalid : 1;
898 /** The base register (X86_GREG_XXX). */
899 uint32_t iBaseReg : 4;
900 /** Set if base register is invalid. */
901 uint32_t fBaseRegInvalid : 1;
902 /** Register 2 (X86_GREG_XXX). */
903 uint32_t iReg2 : 4;
904 } VmxXsave;
905
906 /** LIDT, LGDT, SIDT, SGDT information. */
907 struct
908 {
909 /** Scaling; 0=no scaling, 1=scale-by-2, 2=scale-by-4, 3=scale-by-8. */
910 uint32_t u2Scaling : 2;
911 uint32_t u5Undef0 : 5;
912 /** The address size; 0=16-bit, 1=32-bit, 2=64-bit, rest undefined. */
913 uint32_t u3AddrSize : 3;
914 /** Always cleared to 0. */
915 uint32_t u1Cleared0 : 1;
916 /** Operand size; 0=16-bit, 1=32-bit, undefined for 64-bit. */
917 uint32_t uOperandSize : 1;
918 uint32_t u3Undef0 : 3;
919 /** The segment register (X86_SREG_XXX). */
920 uint32_t iSegReg : 3;
921 /** The index register (X86_GREG_XXX). */
922 uint32_t iIdxReg : 4;
923 /** Set if index register is invalid. */
924 uint32_t fIdxRegInvalid : 1;
925 /** The base register (X86_GREG_XXX). */
926 uint32_t iBaseReg : 4;
927 /** Set if base register is invalid. */
928 uint32_t fBaseRegInvalid : 1;
929 /** Instruction identity (VMX_INSTR_ID_XXX). */
930 uint32_t u2InstrId : 2;
931 uint32_t u2Undef0 : 2;
932 } GdtIdt;
933
934 /** LLDT, LTR, SLDT, STR information. */
935 struct
936 {
937 /** Scaling; 0=no scaling, 1=scale-by-2, 2=scale-by-4, 3=scale-by-8. */
938 uint32_t u2Scaling : 2;
939 uint32_t u1Undef0 : 1;
940 /** Register 1 (X86_GREG_XXX). */
941 uint32_t iReg1 : 4;
942 /** The address size; 0=16-bit, 1=32-bit, 2=64-bit, rest undefined. */
943 uint32_t u3AddrSize : 3;
944 /** Memory/Register - Always cleared to 0 to indicate memory operand. */
945 uint32_t fIsRegOperand : 1;
946 uint32_t u4Undef0 : 4;
947 /** The segment register (X86_SREG_XXX). */
948 uint32_t iSegReg : 3;
949 /** The index register (X86_GREG_XXX). */
950 uint32_t iIdxReg : 4;
951 /** Set if index register is invalid. */
952 uint32_t fIdxRegInvalid : 1;
953 /** The base register (X86_GREG_XXX). */
954 uint32_t iBaseReg : 4;
955 /** Set if base register is invalid. */
956 uint32_t fBaseRegInvalid : 1;
957 /** Instruction identity (VMX_INSTR_ID_XXX). */
958 uint32_t u2InstrId : 2;
959 uint32_t u2Undef0 : 2;
960 } LdtTr;
961
962 /** RDRAND, RDSEED information. */
963 struct
964 {
965 /** Scaling; 0=no scaling, 1=scale-by-2, 2=scale-by-4, 3=scale-by-8. */
966 uint32_t u2Undef0 : 2;
967 /** Destination register (X86_GREG_XXX). */
968 uint32_t iReg1 : 4;
969 uint32_t u4Undef0 : 4;
970 /** Operand size; 0=16-bit, 1=32-bit, 2=64-bit, 3=unused. */
971 uint32_t u2OperandSize : 2;
972 uint32_t u19Def0 : 20;
973 } RdrandRdseed;
974
975 struct
976 {
977 /** Scaling; 0=no scaling, 1=scale-by-2, 2=scale-by-4, 3=scale-by-8. */
978 uint32_t u2Scaling : 2;
979 uint32_t u1Undef0 : 1;
980 /** Register 1 (X86_GREG_XXX). */
981 uint32_t iReg1 : 4;
982 /** The address size; 0=16-bit, 1=32-bit, 2=64-bit, rest undefined. */
983 uint32_t u3AddrSize : 3;
984 /** Memory or register operand. */
985 uint32_t fIsRegOperand : 1;
986 /** Operand size; 0=16-bit, 1=32-bit, 2=64-bit, 3=unused. */
987 uint32_t u4Undef0 : 4;
988 /** The segment register (X86_SREG_XXX). */
989 uint32_t iSegReg : 3;
990 /** The index register (X86_GREG_XXX). */
991 uint32_t iIdxReg : 4;
992 /** Set if index register is invalid. */
993 uint32_t fIdxRegInvalid : 1;
994 /** The base register (X86_GREG_XXX). */
995 uint32_t iBaseReg : 4;
996 /** Set if base register is invalid. */
997 uint32_t fBaseRegInvalid : 1;
998 /** Register 2 (X86_GREG_XXX). */
999 uint32_t iReg2 : 4;
1000 } VmreadVmwrite;
1001
1002 /** This is a combination field of all instruction information. Note! Not all field
1003 * combinations are valid (e.g., iReg1 is undefined for memory operands) and
1004 * specialized fields are overwritten by their generic counterparts (e.g. no
1005 * instruction identity field). */
1006 struct
1007 {
1008 /** Scaling; 0=no scaling, 1=scale-by-2, 2=scale-by-4, 3=scale-by-8. */
1009 uint32_t u2Scaling : 2;
1010 uint32_t u1Undef0 : 1;
1011 /** Register 1 (X86_GREG_XXX). */
1012 uint32_t iReg1 : 4;
1013 /** The address size; 0=16-bit, 1=32-bit, 2=64-bit, rest undefined. */
1014 uint32_t u3AddrSize : 3;
1015 /** Memory/Register - Always cleared to 0 to indicate memory operand. */
1016 uint32_t fIsRegOperand : 1;
1017 /** Operand size; 0=16-bit, 1=32-bit, 2=64-bit, 3=unused. */
1018 uint32_t uOperandSize : 2;
1019 uint32_t u2Undef0 : 2;
1020 /** The segment register (X86_SREG_XXX). */
1021 uint32_t iSegReg : 3;
1022 /** The index register (X86_GREG_XXX). */
1023 uint32_t iIdxReg : 4;
1024 /** Set if index register is invalid. */
1025 uint32_t fIdxRegInvalid : 1;
1026 /** The base register (X86_GREG_XXX). */
1027 uint32_t iBaseReg : 4;
1028 /** Set if base register is invalid. */
1029 uint32_t fBaseRegInvalid : 1;
1030 /** Register 2 (X86_GREG_XXX) or instruction identity. */
1031 uint32_t iReg2 : 4;
1032 } All;
1033} VMXEXITINSTRINFO;
1034AssertCompileSize(VMXEXITINSTRINFO, 4);
1035/** Pointer to a VMX VM-exit instruction info. struct. */
1036typedef VMXEXITINSTRINFO *PVMXEXITINSTRINFO;
1037/** Pointer to a const VMX VM-exit instruction info. struct. */
1038typedef const VMXEXITINSTRINFO *PCVMXEXITINSTRINFO;
1039
1040
1041/** @name VM-entry failure reported in VM-exit qualification.
1042 * See Intel spec. 26.7 "VM-entry failures during or after loading guest-state".
1043 * @{
1044 */
1045/** No errors during VM-entry. */
1046#define VMX_ENTRY_FAIL_QUAL_NO_ERROR (0)
1047/** Not used. */
1048#define VMX_ENTRY_FAIL_QUAL_NOT_USED (1)
1049/** Error while loading PDPTEs. */
1050#define VMX_ENTRY_FAIL_QUAL_PDPTE (2)
1051/** NMI injection when blocking-by-STI is set. */
1052#define VMX_ENTRY_FAIL_QUAL_NMI_INJECT (3)
1053/** Invalid VMCS link pointer. */
1054#define VMX_ENTRY_FAIL_QUAL_VMCS_LINK_PTR (4)
1055/** @} */
1056
1057/**
1058 * VMX MSR-bitmap read permissions.
1059 */
1060typedef enum VMXMSREXITREAD
1061{
1062 /** Reading this MSR causes a VM-exit. */
1063 VMXMSREXIT_INTERCEPT_READ = 1,
1064 /** Reading this MSR doesn't cause a VM-exit. */
1065 VMXMSREXIT_PASSTHRU_READ
1066} VMXMSREXITREAD;
1067/** Pointer to MSR-bitmap read permissions. */
1068typedef VMXMSREXITREAD* PVMXMSREXITREAD;
1069
1070/**
1071 * VMX MSR-bitmap write permissions.
1072 */
1073typedef enum VMXMSREXITWRITE
1074{
1075 /** Writing to this MSR causes a VM-exit. */
1076 VMXMSREXIT_INTERCEPT_WRITE = 3,
1077 /** Writing to this MSR does not cause a VM-exit. */
1078 VMXMSREXIT_PASSTHRU_WRITE
1079} VMXMSREXITWRITE;
1080/** Pointer to MSR-bitmap write permissions. */
1081typedef VMXMSREXITWRITE* PVMXMSREXITWRITE;
1082
1083/**
1084 * VMX MSR autoload/store element.
1085 * In accordance to the VT-x spec.
1086 */
1087typedef struct VMXAUTOMSR
1088{
1089 /** The MSR Id. */
1090 uint32_t u32Msr;
1091 /** Reserved (MBZ). */
1092 uint32_t u32Reserved;
1093 /** The MSR value. */
1094 uint64_t u64Value;
1095} VMXAUTOMSR;
1096AssertCompileSize(VMXAUTOMSR, 16);
1097/** Pointer to an MSR load/store element. */
1098typedef VMXAUTOMSR *PVMXAUTOMSR;
1099/** Pointer to a const MSR load/store element. */
1100typedef const VMXAUTOMSR *PCVMXAUTOMSR;
1101
1102/** VMX auto load-store MSR (VMXAUTOMSR) offset mask. */
1103#define VMX_AUTOMSR_OFFSET_MASK 0xf
1104
1105/**
1106 * VMX tagged-TLB flush types.
1107 */
1108typedef enum
1109{
1110 VMXTLBFLUSHTYPE_EPT,
1111 VMXTLBFLUSHTYPE_VPID,
1112 VMXTLBFLUSHTYPE_EPT_VPID,
1113 VMXTLBFLUSHTYPE_NONE
1114} VMXTLBFLUSHTYPE;
1115/** Pointer to a VMXTLBFLUSHTYPE enum. */
1116typedef VMXTLBFLUSHTYPE *PVMXTLBFLUSHTYPE;
1117/** Pointer to a const VMXTLBFLUSHTYPE enum. */
1118typedef const VMXTLBFLUSHTYPE *PCVMXTLBFLUSHTYPE;
1119
1120/**
1121 * VMX controls MSR.
1122 */
1123typedef union
1124{
1125 struct
1126 {
1127 /** Bits set here -must- be set in the corresponding VM-execution controls. */
1128 uint32_t allowed0;
1129 /** Bits cleared here -must- be cleared in the corresponding VM-execution
1130 * controls. */
1131 uint32_t allowed1;
1132 } n;
1133 uint64_t u;
1134} VMXCTLSMSR;
1135AssertCompileSize(VMXCTLSMSR, 8);
1136/** Pointer to a VMXCTLSMSR union. */
1137typedef VMXCTLSMSR *PVMXCTLSMSR;
1138/** Pointer to a const VMXCTLSMSR union. */
1139typedef const VMXCTLSMSR *PCVMXCTLSMSR;
1140
1141/**
1142 * VMX MSRs.
1143 */
1144typedef struct VMXMSRS
1145{
1146 /** VMX/SMX Feature control. */
1147 uint64_t u64FeatCtrl;
1148 /** Basic information. */
1149 uint64_t u64Basic;
1150 /** Pin-based VM-execution controls. */
1151 VMXCTLSMSR PinCtls;
1152 /** Processor-based VM-execution controls. */
1153 VMXCTLSMSR ProcCtls;
1154 /** Secondary processor-based VM-execution controls. */
1155 VMXCTLSMSR ProcCtls2;
1156 /** VM-exit controls. */
1157 VMXCTLSMSR ExitCtls;
1158 /** VM-entry controls. */
1159 VMXCTLSMSR EntryCtls;
1160 /** True pin-based VM-execution controls. */
1161 VMXCTLSMSR TruePinCtls;
1162 /** True processor-based VM-execution controls. */
1163 VMXCTLSMSR TrueProcCtls;
1164 /** True VM-entry controls. */
1165 VMXCTLSMSR TrueEntryCtls;
1166 /** True VM-exit controls. */
1167 VMXCTLSMSR TrueExitCtls;
1168 /** Miscellaneous data. */
1169 uint64_t u64Misc;
1170 /** CR0 fixed-0 - bits set here must be set in VMX operation. */
1171 uint64_t u64Cr0Fixed0;
1172 /** CR0 fixed-1 - bits clear here must be clear in VMX operation. */
1173 uint64_t u64Cr0Fixed1;
1174 /** CR4 fixed-0 - bits set here must be set in VMX operation. */
1175 uint64_t u64Cr4Fixed0;
1176 /** CR4 fixed-1 - bits clear here must be clear in VMX operation. */
1177 uint64_t u64Cr4Fixed1;
1178 /** VMCS enumeration. */
1179 uint64_t u64VmcsEnum;
1180 /** VM Functions. */
1181 uint64_t u64VmFunc;
1182 /** EPT, VPID capabilities. */
1183 uint64_t u64EptVpidCaps;
1184 /** Reserved for future. */
1185 uint64_t a_u64Reserved[9];
1186} VMXMSRS;
1187AssertCompileSizeAlignment(VMXMSRS, 8);
1188AssertCompileSize(VMXMSRS, 224);
1189/** Pointer to a VMXMSRS struct. */
1190typedef VMXMSRS *PVMXMSRS;
1191/** Pointer to a const VMXMSRS struct. */
1192typedef const VMXMSRS *PCVMXMSRS;
1193
1194
1195/** @name VMX Basic Exit Reasons.
1196 * @{
1197 */
1198/** -1 Invalid exit code */
1199#define VMX_EXIT_INVALID (-1)
1200/** 0 Exception or non-maskable interrupt (NMI). */
1201#define VMX_EXIT_XCPT_OR_NMI 0
1202/** 1 External interrupt. */
1203#define VMX_EXIT_EXT_INT 1
1204/** 2 Triple fault. */
1205#define VMX_EXIT_TRIPLE_FAULT 2
1206/** 3 INIT signal. */
1207#define VMX_EXIT_INIT_SIGNAL 3
1208/** 4 Start-up IPI (SIPI). */
1209#define VMX_EXIT_SIPI 4
1210/** 5 I/O system-management interrupt (SMI). */
1211#define VMX_EXIT_IO_SMI 5
1212/** 6 Other SMI. */
1213#define VMX_EXIT_SMI 6
1214/** 7 Interrupt window exiting. */
1215#define VMX_EXIT_INT_WINDOW 7
1216/** 8 NMI window exiting. */
1217#define VMX_EXIT_NMI_WINDOW 8
1218/** 9 Task switch. */
1219#define VMX_EXIT_TASK_SWITCH 9
1220/** 10 Guest software attempted to execute CPUID. */
1221#define VMX_EXIT_CPUID 10
1222/** 11 Guest software attempted to execute GETSEC. */
1223#define VMX_EXIT_GETSEC 11
1224/** 12 Guest software attempted to execute HLT. */
1225#define VMX_EXIT_HLT 12
1226/** 13 Guest software attempted to execute INVD. */
1227#define VMX_EXIT_INVD 13
1228/** 14 Guest software attempted to execute INVLPG. */
1229#define VMX_EXIT_INVLPG 14
1230/** 15 Guest software attempted to execute RDPMC. */
1231#define VMX_EXIT_RDPMC 15
1232/** 16 Guest software attempted to execute RDTSC. */
1233#define VMX_EXIT_RDTSC 16
1234/** 17 Guest software attempted to execute RSM in SMM. */
1235#define VMX_EXIT_RSM 17
1236/** 18 Guest software executed VMCALL. */
1237#define VMX_EXIT_VMCALL 18
1238/** 19 Guest software executed VMCLEAR. */
1239#define VMX_EXIT_VMCLEAR 19
1240/** 20 Guest software executed VMLAUNCH. */
1241#define VMX_EXIT_VMLAUNCH 20
1242/** 21 Guest software executed VMPTRLD. */
1243#define VMX_EXIT_VMPTRLD 21
1244/** 22 Guest software executed VMPTRST. */
1245#define VMX_EXIT_VMPTRST 22
1246/** 23 Guest software executed VMREAD. */
1247#define VMX_EXIT_VMREAD 23
1248/** 24 Guest software executed VMRESUME. */
1249#define VMX_EXIT_VMRESUME 24
1250/** 25 Guest software executed VMWRITE. */
1251#define VMX_EXIT_VMWRITE 25
1252/** 26 Guest software executed VMXOFF. */
1253#define VMX_EXIT_VMXOFF 26
1254/** 27 Guest software executed VMXON. */
1255#define VMX_EXIT_VMXON 27
1256/** 28 Control-register accesses. */
1257#define VMX_EXIT_MOV_CRX 28
1258/** 29 Debug-register accesses. */
1259#define VMX_EXIT_MOV_DRX 29
1260/** 30 I/O instruction. */
1261#define VMX_EXIT_IO_INSTR 30
1262/** 31 RDMSR. Guest software attempted to execute RDMSR. */
1263#define VMX_EXIT_RDMSR 31
1264/** 32 WRMSR. Guest software attempted to execute WRMSR. */
1265#define VMX_EXIT_WRMSR 32
1266/** 33 VM-entry failure due to invalid guest state. */
1267#define VMX_EXIT_ERR_INVALID_GUEST_STATE 33
1268/** 34 VM-entry failure due to MSR loading. */
1269#define VMX_EXIT_ERR_MSR_LOAD 34
1270/** 36 Guest software executed MWAIT. */
1271#define VMX_EXIT_MWAIT 36
1272/** 37 VM-exit due to monitor trap flag. */
1273#define VMX_EXIT_MTF 37
1274/** 39 Guest software attempted to execute MONITOR. */
1275#define VMX_EXIT_MONITOR 39
1276/** 40 Guest software attempted to execute PAUSE. */
1277#define VMX_EXIT_PAUSE 40
1278/** 41 VM-entry failure due to machine-check. */
1279#define VMX_EXIT_ERR_MACHINE_CHECK 41
1280/** 43 TPR below threshold. Guest software executed MOV to CR8. */
1281#define VMX_EXIT_TPR_BELOW_THRESHOLD 43
1282/** 44 APIC access. Guest software attempted to access memory at a physical
1283 * address on the APIC-access page. */
1284#define VMX_EXIT_APIC_ACCESS 44
1285/** 45 Virtualized EOI. EOI virtualization was performed for a virtual
1286 * interrupt whose vector indexed a bit set in the EOI-exit bitmap. */
1287#define VMX_EXIT_VIRTUALIZED_EOI 45
1288/** 46 Access to GDTR or IDTR. Guest software attempted to execute LGDT, LIDT,
1289 * SGDT, or SIDT. */
1290#define VMX_EXIT_GDTR_IDTR_ACCESS 46
1291/** 47 Access to LDTR or TR. Guest software attempted to execute LLDT, LTR,
1292 * SLDT, or STR. */
1293#define VMX_EXIT_LDTR_TR_ACCESS 47
1294/** 48 EPT violation. An attempt to access memory with a guest-physical address
1295 * was disallowed by the configuration of the EPT paging structures. */
1296#define VMX_EXIT_EPT_VIOLATION 48
1297/** 49 EPT misconfiguration. An attempt to access memory with a guest-physical
1298 * address encountered a misconfigured EPT paging-structure entry. */
1299#define VMX_EXIT_EPT_MISCONFIG 49
1300/** 50 INVEPT. Guest software attempted to execute INVEPT. */
1301#define VMX_EXIT_INVEPT 50
1302/** 51 RDTSCP. Guest software attempted to execute RDTSCP. */
1303#define VMX_EXIT_RDTSCP 51
1304/** 52 VMX-preemption timer expired. The preemption timer counted down to zero. */
1305#define VMX_EXIT_PREEMPT_TIMER 52
1306/** 53 INVVPID. Guest software attempted to execute INVVPID. */
1307#define VMX_EXIT_INVVPID 53
1308/** 54 WBINVD. Guest software attempted to execute WBINVD. */
1309#define VMX_EXIT_WBINVD 54
1310/** 55 XSETBV. Guest software attempted to execute XSETBV. */
1311#define VMX_EXIT_XSETBV 55
1312/** 56 APIC write. Guest completed write to virtual-APIC. */
1313#define VMX_EXIT_APIC_WRITE 56
1314/** 57 RDRAND. Guest software attempted to execute RDRAND. */
1315#define VMX_EXIT_RDRAND 57
1316/** 58 INVPCID. Guest software attempted to execute INVPCID. */
1317#define VMX_EXIT_INVPCID 58
1318/** 59 VMFUNC. Guest software attempted to execute VMFUNC. */
1319#define VMX_EXIT_VMFUNC 59
1320/** 60 ENCLS. Guest software attempted to execute ENCLS. */
1321#define VMX_EXIT_ENCLS 60
1322/** 61 - RDSEED - Guest software attempted to executed RDSEED and exiting was
1323 * enabled. */
1324#define VMX_EXIT_RDSEED 61
1325/** 62 - Page-modification log full. */
1326#define VMX_EXIT_PML_FULL 62
1327/** 63 - XSAVES - Guest software attempted to executed XSAVES and exiting was
1328 * enabled (XSAVES/XRSTORS was enabled too, of course). */
1329#define VMX_EXIT_XSAVES 63
1330/** 63 - XRSTORS - Guest software attempted to executed XRSTORS and exiting
1331 * was enabled (XSAVES/XRSTORS was enabled too, of course). */
1332#define VMX_EXIT_XRSTORS 64
1333/** The maximum exit value (inclusive). */
1334#define VMX_EXIT_MAX (VMX_EXIT_XRSTORS)
1335/** @} */
1336
1337
1338/** @name VM Instruction Errors.
1339 * See Intel spec. "30.4 VM Instruction Error Numbers"
1340 * @{
1341 */
1342typedef enum
1343{
1344 /** VMCALL executed in VMX root operation. */
1345 VMXINSTRERR_VMCALL_VMXROOTMODE = 1,
1346 /** VMCLEAR with invalid physical address. */
1347 VMXINSTRERR_VMCLEAR_INVALID_PHYSADDR = 2,
1348 /** VMCLEAR with VMXON pointer. */
1349 VMXINSTRERR_VMCLEAR_VMXON_PTR = 3,
1350 /** VMLAUNCH with non-clear VMCS. */
1351 VMXINSTRERR_VMLAUNCH_NON_CLEAR_VMCS = 4,
1352 /** VMRESUME with non-launched VMCS. */
1353 VMXINSTRERR_VMRESUME_NON_LAUNCHED_VMCS = 5,
1354 /** VMRESUME after VMXOFF (VMXOFF and VMXON between VMLAUNCH and VMRESUME). */
1355 VMXINSTRERR_VMRESUME_AFTER_VMXOFF = 6,
1356 /** VM-entry with invalid control field(s). */
1357 VMXINSTRERR_VMENTRY_INVALID_CTLS = 7,
1358 /** VM-entry with invalid host-state field(s). */
1359 VMXINSTRERR_VMENTRY_INVALID_HOST_STATE = 8,
1360 /** VMPTRLD with invalid physical address. */
1361 VMXINSTRERR_VMPTRLD_INVALID_PHYSADDR = 9,
1362 /** VMPTRLD with VMXON pointer. */
1363 VMXINSTRERR_VMPTRLD_VMXON_PTR = 10,
1364 /** VMPTRLD with incorrect VMCS revision identifier. */
1365 VMXINSTRERR_VMPTRLD_INCORRECT_VMCS_REV = 11,
1366 /** VMREAD from unsupported VMCS component. */
1367 VMXINSTRERR_VMREAD_INVALID_COMPONENT = 12,
1368 /** VMWRITE to unsupported VMCS component. */
1369 VMXINSTRERR_VMWRITE_INVALID_COMPONENT = 12,
1370 /** VMWRITE to read-only VMCS component. */
1371 VMXINSTRERR_VMWRITE_RO_COMPONENT = 13,
1372 /** VMXON executed in VMX root operation. */
1373 VMXINSTRERR_VMXON_IN_VMXROOTMODE = 15,
1374 /** VM-entry with invalid executive-VMCS pointer. */
1375 VMXINSTRERR_VMENTRY_EXEC_VMCS_INVALID_PTR = 16,
1376 /** VM-entry with non-launched executive VMCS. */
1377 VMXINSTRERR_VMENTRY_EXEC_VMCS_NON_LAUNCHED = 17,
1378 /** VM-entry with executive-VMCS pointer not VMXON pointer. */
1379 VMXINSTRERR_VMENTRY_EXEC_VMCS_PTR = 18,
1380 /** VMCALL with non-clear VMCS. */
1381 VMXINSTRERR_VMCALL_NON_CLEAR_VMCS = 19,
1382 /** VMCALL with invalid VM-exit control fields. */
1383 VMXINSTRERR_VMCALL_INVALID_EXITCTLS = 20,
1384 /** VMCALL with incorrect MSEG revision identifier. */
1385 VMXINSTRERR_VMCALL_INVALID_MSEG_ID = 22,
1386 /** VMXOFF under dual-monitor treatment of SMIs and SMM. */
1387 VMXINSTRERR_VMXOFF_DUAL_MON = 23,
1388 /** VMCALL with invalid SMM-monitor features. */
1389 VMXINSTRERR_VMCALL_INVALID_SMMCTLS = 24,
1390 /** VM-entry with invalid VM-execution control fields in executive VMCS. */
1391 VMXINSTRERR_VMENTRY_EXEC_VMCS_INVALID_CTLS = 25,
1392 /** VM-entry with events blocked by MOV SS. */
1393 VMXINSTRERR_VMENTRY_BLOCK_MOVSS = 26,
1394 /** Invalid operand to INVEPT/INVVPID. */
1395 VMXINSTRERR_INVEPT_INVVPID_INVALID_OPERAND = 28
1396} VMXINSTRERR;
1397/** @} */
1398
1399
1400/** @name VMX abort reasons.
1401 * See Intel spec. "27.7 VMX Aborts".
1402 * Update HMGetVmxAbortDesc() if new reasons are added. @{
1403 */
1404typedef enum
1405{
1406 /** None - don't use this / uninitialized value. */
1407 VMXABORT_NONE = 0,
1408 /** VMX abort caused during saving of guest MSRs. */
1409 VMXABORT_SAVE_GUEST_MSRS = 1,
1410 /** VMX abort caused during host PDPTE checks. */
1411 VMXBOART_HOST_PDPTE = 2,
1412 /** VMX abort caused due to current VMCS being corrupted. */
1413 VMXABORT_CURRENT_VMCS_CORRUPT = 3,
1414 /** VMX abort caused during loading of host MSRs. */
1415 VMXABORT_LOAD_HOST_MSR = 4,
1416 /** VMX abort caused due to a machine-check exception during VM-exit. */
1417 VMXABORT_MACHINE_CHECK_XCPT = 5,
1418 /** VMX abort caused due to invalid return from long mode. */
1419 VMXABORT_HOST_NOT_IN_LONG_MODE = 6,
1420 /* Type size hack. */
1421 VMXABORT_32BIT_HACK = 0x7fffffff
1422} VMXABORT;
1423AssertCompileSize(VMXABORT, 4);
1424/** @} */
1425
1426
1427/** @name VMX MSR - Basic VMX information.
1428 * @{
1429 */
1430/** VMCS (and related regions) memory type - Uncacheable. */
1431#define VMX_BASIC_MEM_TYPE_UC 0
1432/** VMCS (and related regions) memory type - Write back. */
1433#define VMX_BASIC_MEM_TYPE_WB 6
1434
1435/** Bit fields for MSR_IA32_VMX_BASIC. */
1436/** VMCS revision identifier used by the processor. */
1437#define VMX_BF_BASIC_VMCS_ID_SHIFT 0
1438#define VMX_BF_BASIC_VMCS_ID_MASK UINT64_C(0x000000007fffffff)
1439/** Bit 31 is reserved and RAZ. */
1440#define VMX_BF_BASIC_RSVD_32_SHIFT 31
1441#define VMX_BF_BASIC_RSVD_32_MASK UINT64_C(0x0000000080000000)
1442/** VMCS size in bytes. */
1443#define VMX_BF_BASIC_VMCS_SIZE_SHIFT 32
1444#define VMX_BF_BASIC_VMCS_SIZE_MASK UINT64_C(0x00001fff00000000)
1445/** Bits 45:47 are reserved. */
1446#define VMX_BF_BASIC_RSVD_45_47_SHIFT 45
1447#define VMX_BF_BASIC_RSVD_45_47_MASK UINT64_C(0x0000e00000000000)
1448/** Width of physical addresses used for the VMCS and associated memory regions
1449 * (always 0 on CPUs that support Intel 64 architecture). */
1450#define VMX_BF_BASIC_PHYSADDR_WIDTH_SHIFT 48
1451#define VMX_BF_BASIC_PHYSADDR_WIDTH_MASK UINT64_C(0x0001000000000000)
1452/** Dual-monitor treatment of SMI and SMM supported. */
1453#define VMX_BF_BASIC_DUAL_MON_SHIFT 49
1454#define VMX_BF_BASIC_DUAL_MON_MASK UINT64_C(0x0002000000000000)
1455/** Memory type that must be used for the VMCS and associated memory regions. */
1456#define VMX_BF_BASIC_VMCS_MEM_TYPE_SHIFT 50
1457#define VMX_BF_BASIC_VMCS_MEM_TYPE_MASK UINT64_C(0x003c000000000000)
1458/** VM-exit instruction information for INS/OUTS. */
1459#define VMX_BF_BASIC_VMCS_INS_OUTS_SHIFT 54
1460#define VMX_BF_BASIC_VMCS_INS_OUTS_MASK UINT64_C(0x0040000000000000)
1461/** Whether 'true' VMX controls MSRs are supported for handling of default1 class
1462 * bits in VMX control MSRs. */
1463#define VMX_BF_BASIC_TRUE_CTLS_SHIFT 55
1464#define VMX_BF_BASIC_TRUE_CTLS_MASK UINT64_C(0x0080000000000000)
1465/** Bits 56:63 are reserved and RAZ. */
1466#define VMX_BF_BASIC_RSVD_56_63_SHIFT 56
1467#define VMX_BF_BASIC_RSVD_56_63_MASK UINT64_C(0xff00000000000000)
1468RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_BASIC_, UINT64_C(0), UINT64_MAX,
1469 (VMCS_ID, RSVD_32, VMCS_SIZE, RSVD_45_47, PHYSADDR_WIDTH, DUAL_MON, VMCS_MEM_TYPE,
1470 VMCS_INS_OUTS, TRUE_CTLS, RSVD_56_63));
1471/** @} */
1472
1473
1474/** @name VMX MSR - Miscellaneous data.
1475 * Bit fields for MSR_IA32_VMX_MISC.
1476 * @{
1477 */
1478/** Whether VM-exit stores EFER.LMA into the "IA32e mode guest" field. */
1479#define VMX_MISC_EXIT_SAVE_EFER_LMA RT_BIT(5)
1480/** Whether Intel PT is supported in VMX operation. */
1481#define VMX_MISC_INTEL_PT RT_BIT(14)
1482/** Whether VMWRITE to any valid VMCS field incl. read-only fields, otherwise
1483 * VMWRITE cannot modify read-only VM-exit information fields. */
1484#define VMX_MISC_VMWRITE_ALL RT_BIT(29)
1485/** Whether VM-entry can inject software interrupts, INT1 (ICEBP) with 0-length
1486 * instructions. */
1487#define VMX_MISC_ENTRY_INJECT_SOFT_INT RT_BIT(30)
1488/** Maximum number of MSRs in the auto-load/store MSR areas, (n+1) * 512. */
1489#define VMX_MISC_MAX_MSRS(a_MiscMsr) (512 * (RT_BF_GET((a_MiscMsr), VMX_BF_MISC_MAX_MSRS) + 1))
1490/** Maximum CR3-target count supported by the CPU. */
1491#define VMX_MISC_CR3_TARGET_COUNT(a_MiscMsr) (((a) >> 16) & 0xff)
1492/** Relationship between the preemption timer and tsc. */
1493#define VMX_BF_MISC_PREEMPT_TIMER_TSC_SHIFT 0
1494#define VMX_BF_MISC_PREEMPT_TIMER_TSC_MASK UINT64_C(0x000000000000001f)
1495/** Whether VM-exit stores EFER.LMA into the "IA32e mode guest" field. */
1496#define VMX_BF_MISC_EXIT_SAVE_EFER_LMA_SHIFT 5
1497#define VMX_BF_MISC_EXIT_SAVE_EFER_LMA_MASK UINT64_C(0x0000000000000020)
1498/** Activity states supported by the implementation. */
1499#define VMX_BF_MISC_ACTIVITY_STATES_SHIFT 6
1500#define VMX_BF_MISC_ACTIVITY_STATES_MASK UINT64_C(0x00000000000001c0)
1501/** Bits 9:13 is reserved and RAZ. */
1502#define VMX_BF_MISC_RSVD_9_13_SHIFT 9
1503#define VMX_BF_MISC_RSVD_9_13_MASK UINT64_C(0x0000000000003e00)
1504/** Whether Intel PT (Processor Trace) can be used in VMX operation. */
1505#define VMX_BF_MISC_INTEL_PT_SHIFT 14
1506#define VMX_BF_MISC_INTEL_PT_MASK UINT64_C(0x0000000000004000)
1507/** Whether RDMSR can be used to read IA32_SMBASE MSR in SMM. */
1508#define VMX_BF_MISC_SMM_READ_SMBASE_MSR_SHIFT 15
1509#define VMX_BF_MISC_SMM_READ_SMBASE_MSR_MASK UINT64_C(0x0000000000008000)
1510/** Number of CR3 target values supported by the processor. (0-256) */
1511#define VMX_BF_MISC_CR3_TARGET_SHIFT 16
1512#define VMX_BF_MISC_CR3_TARGET_MASK UINT64_C(0x0000000001ff0000)
1513/** Maximum number of MSRs in the VMCS. */
1514#define VMX_BF_MISC_MAX_MSRS_SHIFT 25
1515#define VMX_BF_MISC_MAX_MSRS_MASK UINT64_C(0x000000000e000000)
1516/** Whether IA32_SMM_MONITOR_CTL MSR can be modified to allow VMXOFF to block
1517 * SMIs. */
1518#define VMX_BF_MISC_VMXOFF_BLOCK_SMI_SHIFT 28
1519#define VMX_BF_MISC_VMXOFF_BLOCK_SMI_MASK UINT64_C(0x0000000010000000)
1520/** Whether VMWRITE to any valid VMCS field incl. read-only fields, otherwise
1521 * VMWRITE cannot modify read-only VM-exit information fields. */
1522#define VMX_BF_MISC_VMWRITE_ALL_SHIFT 29
1523#define VMX_BF_MISC_VMWRITE_ALL_MASK UINT64_C(0x0000000020000000)
1524/** Whether VM-entry can inject software interrupts, INT1 (ICEBP) with 0-length
1525 * instructions. */
1526#define VMX_BF_MISC_ENTRY_INJECT_SOFT_INT_SHIFT 30
1527#define VMX_BF_MISC_ENTRY_INJECT_SOFT_INT_MASK UINT64_C(0x0000000040000000)
1528/** Bit 31 is reserved and RAZ. */
1529#define VMX_BF_MISC_RSVD_31_SHIFT 31
1530#define VMX_BF_MISC_RSVD_31_MASK UINT64_C(0x0000000080000000)
1531/** 32-bit MSEG revision ID used by the processor. */
1532#define VMX_BF_MISC_MSEG_ID_SHIFT 32
1533#define VMX_BF_MISC_MSEG_ID_MASK UINT64_C(0xffffffff00000000)
1534RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_MISC_, UINT64_C(0), UINT64_MAX,
1535 (PREEMPT_TIMER_TSC, EXIT_SAVE_EFER_LMA, ACTIVITY_STATES, RSVD_9_13, INTEL_PT, SMM_READ_SMBASE_MSR,
1536 CR3_TARGET, MAX_MSRS, VMXOFF_BLOCK_SMI, VMWRITE_ALL, ENTRY_INJECT_SOFT_INT, RSVD_31, MSEG_ID));
1537/** @} */
1538
1539/** @name VMX MSR - VMCS enumeration.
1540 * Bit fields for MSR_IA32_VMX_VMCS_ENUM.
1541 * @{
1542 */
1543/** Bit 0 is reserved and RAZ. */
1544#define VMX_BF_VMCS_ENUM_RSVD_0_SHIFT 0
1545#define VMX_BF_VMCS_ENUM_RSVD_0_MASK UINT64_C(0x0000000000000001)
1546/** Highest index value used in VMCS field encoding. */
1547#define VMX_BF_VMCS_ENUM_HIGHEST_IDX_SHIFT 1
1548#define VMX_BF_VMCS_ENUM_HIGHEST_IDX_MASK UINT64_C(0x00000000000003fe)
1549/** Bit 10:63 is reserved and RAZ. */
1550#define VMX_BF_VMCS_ENUM_RSVD_10_63_SHIFT 10
1551#define VMX_BF_VMCS_ENUM_RSVD_10_63_MASK UINT64_C(0xfffffffffffffc00)
1552RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_VMCS_ENUM_, UINT64_C(0), UINT64_MAX,
1553 (RSVD_0, HIGHEST_IDX, RSVD_10_63));
1554/** @} */
1555
1556
1557/** @name VMX MSR - VM Functions.
1558 * Bit fields for MSR_IA32_VMX_VMFUNC.
1559 * @{
1560 */
1561/** EPTP-switching function changes the value of the EPTP to one chosen from the EPTP list. */
1562#define VMX_BF_VMFUNC_EPTP_SWITCHING_SHIFT 0
1563#define VMX_BF_VMFUNC_EPTP_SWITCHING_MASK UINT64_C(0x0000000000000001)
1564/** Bits 1:63 are reserved and RAZ. */
1565#define VMX_BF_VMFUNC_RSVD_1_63_SHIFT 1
1566#define VMX_BF_VMFUNC_RSVD_1_63_MASK UINT64_C(0xfffffffffffffffe)
1567RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_VMFUNC_, UINT64_C(0), UINT64_MAX,
1568 (EPTP_SWITCHING, RSVD_1_63));
1569/** @} */
1570
1571
1572/** @name VMX MSR - EPT/VPID capabilities.
1573 * @{
1574 */
1575#define MSR_IA32_VMX_EPT_VPID_CAP_RWX_X_ONLY RT_BIT_64(0)
1576#define MSR_IA32_VMX_EPT_VPID_CAP_PAGE_WALK_LENGTH_4 RT_BIT_64(6)
1577#define MSR_IA32_VMX_EPT_VPID_CAP_EMT_UC RT_BIT_64(8)
1578#define MSR_IA32_VMX_EPT_VPID_CAP_EMT_WB RT_BIT_64(14)
1579#define MSR_IA32_VMX_EPT_VPID_CAP_PDE_2M RT_BIT_64(16)
1580#define MSR_IA32_VMX_EPT_VPID_CAP_PDPTE_1G RT_BIT_64(17)
1581#define MSR_IA32_VMX_EPT_VPID_CAP_INVEPT RT_BIT_64(20)
1582#define MSR_IA32_VMX_EPT_VPID_CAP_EPT_ACCESS_DIRTY RT_BIT_64(21)
1583#define MSR_IA32_VMX_EPT_VPID_CAP_INVEPT_SINGLE_CONTEXT RT_BIT_64(25)
1584#define MSR_IA32_VMX_EPT_VPID_CAP_INVEPT_ALL_CONTEXTS RT_BIT_64(26)
1585#define MSR_IA32_VMX_EPT_VPID_CAP_INVVPID RT_BIT_64(32)
1586#define MSR_IA32_VMX_EPT_VPID_CAP_INVVPID_INDIV_ADDR RT_BIT_64(40)
1587#define MSR_IA32_VMX_EPT_VPID_CAP_INVVPID_SINGLE_CONTEXT RT_BIT_64(41)
1588#define MSR_IA32_VMX_EPT_VPID_CAP_INVVPID_ALL_CONTEXTS RT_BIT_64(42)
1589#define MSR_IA32_VMX_EPT_VPID_CAP_INVVPID_SINGLE_CONTEXT_RETAIN_GLOBALS RT_BIT_64(43)
1590/** @} */
1591
1592
1593/** @name Extended Page Table Pointer (EPTP)
1594 * @{
1595 */
1596/** Uncachable EPT paging structure memory type. */
1597#define VMX_EPT_MEMTYPE_UC 0
1598/** Write-back EPT paging structure memory type. */
1599#define VMX_EPT_MEMTYPE_WB 6
1600/** Shift value to get the EPT page walk length (bits 5-3) */
1601#define VMX_EPT_PAGE_WALK_LENGTH_SHIFT 3
1602/** Mask value to get the EPT page walk length (bits 5-3) */
1603#define VMX_EPT_PAGE_WALK_LENGTH_MASK 7
1604/** Default EPT page-walk length (1 less than the actual EPT page-walk
1605 * length) */
1606#define VMX_EPT_PAGE_WALK_LENGTH_DEFAULT 3
1607/** @} */
1608
1609
1610/** @name VMCS field encoding: 16-bit guest fields.
1611 * @{
1612 */
1613#define VMX_VMCS16_VPID 0x0000
1614#define VMX_VMCS16_POSTED_INT_NOTIFY_VECTOR 0x0002
1615#define VMX_VMCS16_EPTP_INDEX 0x0004
1616#define VMX_VMCS16_GUEST_ES_SEL 0x0800
1617#define VMX_VMCS16_GUEST_CS_SEL 0x0802
1618#define VMX_VMCS16_GUEST_SS_SEL 0x0804
1619#define VMX_VMCS16_GUEST_DS_SEL 0x0806
1620#define VMX_VMCS16_GUEST_FS_SEL 0x0808
1621#define VMX_VMCS16_GUEST_GS_SEL 0x080a
1622#define VMX_VMCS16_GUEST_LDTR_SEL 0x080c
1623#define VMX_VMCS16_GUEST_TR_SEL 0x080e
1624#define VMX_VMCS16_GUEST_INTR_STATUS 0x0810
1625#define VMX_VMCS16_GUEST_PML_INDEX 0x0812
1626/** @} */
1627
1628
1629/** @name VMCS field encoding: 16-bits host fields.
1630 * @{
1631 */
1632#define VMX_VMCS16_HOST_ES_SEL 0x0c00
1633#define VMX_VMCS16_HOST_CS_SEL 0x0c02
1634#define VMX_VMCS16_HOST_SS_SEL 0x0c04
1635#define VMX_VMCS16_HOST_DS_SEL 0x0c06
1636#define VMX_VMCS16_HOST_FS_SEL 0x0c08
1637#define VMX_VMCS16_HOST_GS_SEL 0x0c0a
1638#define VMX_VMCS16_HOST_TR_SEL 0x0c0c
1639/** @} */
1640
1641
1642/** @name VMCS field encoding: 64-bit control fields.
1643 * @{
1644 */
1645#define VMX_VMCS64_CTRL_IO_BITMAP_A_FULL 0x2000
1646#define VMX_VMCS64_CTRL_IO_BITMAP_A_HIGH 0x2001
1647#define VMX_VMCS64_CTRL_IO_BITMAP_B_FULL 0x2002
1648#define VMX_VMCS64_CTRL_IO_BITMAP_B_HIGH 0x2003
1649#define VMX_VMCS64_CTRL_MSR_BITMAP_FULL 0x2004
1650#define VMX_VMCS64_CTRL_MSR_BITMAP_HIGH 0x2005
1651#define VMX_VMCS64_CTRL_EXIT_MSR_STORE_FULL 0x2006
1652#define VMX_VMCS64_CTRL_EXIT_MSR_STORE_HIGH 0x2007
1653#define VMX_VMCS64_CTRL_EXIT_MSR_LOAD_FULL 0x2008
1654#define VMX_VMCS64_CTRL_EXIT_MSR_LOAD_HIGH 0x2009
1655#define VMX_VMCS64_CTRL_ENTRY_MSR_LOAD_FULL 0x200a
1656#define VMX_VMCS64_CTRL_ENTRY_MSR_LOAD_HIGH 0x200b
1657#define VMX_VMCS64_CTRL_EXEC_VMCS_PTR_FULL 0x200c
1658#define VMX_VMCS64_CTRL_EXEC_VMCS_PTR_HIGH 0x200d
1659#define VMX_VMCS64_CTRL_EXEC_PML_ADDR_FULL 0x200e
1660#define VMX_VMCS64_CTRL_EXEC_PML_ADDR_HIGH 0x200f
1661#define VMX_VMCS64_CTRL_TSC_OFFSET_FULL 0x2010
1662#define VMX_VMCS64_CTRL_TSC_OFFSET_HIGH 0x2011
1663#define VMX_VMCS64_CTRL_VIRT_APIC_PAGEADDR_FULL 0x2012
1664#define VMX_VMCS64_CTRL_VIRT_APIC_PAGEADDR_HIGH 0x2013
1665#define VMX_VMCS64_CTRL_APIC_ACCESSADDR_FULL 0x2014
1666#define VMX_VMCS64_CTRL_APIC_ACCESSADDR_HIGH 0x2015
1667#define VMX_VMCS64_CTRL_POSTED_INTR_DESC_FULL 0x2016
1668#define VMX_VMCS64_CTRL_POSTED_INTR_DESC_HIGH 0x2017
1669#define VMX_VMCS64_CTRL_VMFUNC_CTRLS_FULL 0x2018
1670#define VMX_VMCS64_CTRL_VMFUNC_CTRLS_HIGH 0x2019
1671#define VMX_VMCS64_CTRL_EPTP_FULL 0x201a
1672#define VMX_VMCS64_CTRL_EPTP_HIGH 0x201b
1673#define VMX_VMCS64_CTRL_EOI_BITMAP_0_FULL 0x201c
1674#define VMX_VMCS64_CTRL_EOI_BITMAP_0_HIGH 0x201d
1675#define VMX_VMCS64_CTRL_EOI_BITMAP_1_FULL 0x201e
1676#define VMX_VMCS64_CTRL_EOI_BITMAP_1_HIGH 0x201f
1677#define VMX_VMCS64_CTRL_EOI_BITMAP_2_FULL 0x2020
1678#define VMX_VMCS64_CTRL_EOI_BITMAP_2_HIGH 0x2021
1679#define VMX_VMCS64_CTRL_EOI_BITMAP_3_FULL 0x2022
1680#define VMX_VMCS64_CTRL_EOI_BITMAP_3_HIGH 0x2023
1681#define VMX_VMCS64_CTRL_EPTP_LIST_FULL 0x2024
1682#define VMX_VMCS64_CTRL_EPTP_LIST_HIGH 0x2025
1683#define VMX_VMCS64_CTRL_VMREAD_BITMAP_FULL 0x2026
1684#define VMX_VMCS64_CTRL_VMREAD_BITMAP_HIGH 0x2027
1685#define VMX_VMCS64_CTRL_VMWRITE_BITMAP_FULL 0x2028
1686#define VMX_VMCS64_CTRL_VMWRITE_BITMAP_HIGH 0x2029
1687#define VMX_VMCS64_CTRL_VIRTXCPT_INFO_ADDR_FULL 0x202a
1688#define VMX_VMCS64_CTRL_VIRTXCPT_INFO_ADDR_HIGH 0x202b
1689#define VMX_VMCS64_CTRL_XSS_EXITING_BITMAP_FULL 0x202c
1690#define VMX_VMCS64_CTRL_XSS_EXITING_BITMAP_HIGH 0x202d
1691#define VMX_VMCS64_CTRL_ENCLS_EXITING_BITMAP_FULL 0x202e
1692#define VMX_VMCS64_CTRL_ENCLS_EXITING_BITMAP_HIGH 0x202f
1693#define VMX_VMCS64_CTRL_TSC_MULTIPLIER_FULL 0x2032
1694#define VMX_VMCS64_CTRL_TSC_MULTIPLIER_HIGH 0x2033
1695/** @} */
1696
1697
1698/** @name VMCS field encoding: 64-bit read-only data fields.
1699 * @{
1700 */
1701#define VMX_VMCS64_RO_GUEST_PHYS_ADDR_FULL 0x2400
1702#define VMX_VMCS64_RO_GUEST_PHYS_ADDR_HIGH 0x2401
1703/** @} */
1704
1705
1706/** @name VMCS field encoding: 64-bit guest fields.
1707 * @{
1708 */
1709#define VMX_VMCS64_GUEST_VMCS_LINK_PTR_FULL 0x2800
1710#define VMX_VMCS64_GUEST_VMCS_LINK_PTR_HIGH 0x2801
1711#define VMX_VMCS64_GUEST_DEBUGCTL_FULL 0x2802
1712#define VMX_VMCS64_GUEST_DEBUGCTL_HIGH 0x2803
1713#define VMX_VMCS64_GUEST_PAT_FULL 0x2804
1714#define VMX_VMCS64_GUEST_PAT_HIGH 0x2805
1715#define VMX_VMCS64_GUEST_EFER_FULL 0x2806
1716#define VMX_VMCS64_GUEST_EFER_HIGH 0x2807
1717#define VMX_VMCS64_GUEST_PERF_GLOBAL_CTRL_FULL 0x2808
1718#define VMX_VMCS64_GUEST_PERF_GLOBAL_CTRL_HIGH 0x2809
1719#define VMX_VMCS64_GUEST_PDPTE0_FULL 0x280a
1720#define VMX_VMCS64_GUEST_PDPTE0_HIGH 0x280b
1721#define VMX_VMCS64_GUEST_PDPTE1_FULL 0x280c
1722#define VMX_VMCS64_GUEST_PDPTE1_HIGH 0x280d
1723#define VMX_VMCS64_GUEST_PDPTE2_FULL 0x280e
1724#define VMX_VMCS64_GUEST_PDPTE2_HIGH 0x280f
1725#define VMX_VMCS64_GUEST_PDPTE3_FULL 0x2810
1726#define VMX_VMCS64_GUEST_PDPTE3_HIGH 0x2811
1727#define VMX_VMCS64_GUEST_BNDCFGS_FULL 0x2812
1728#define VMX_VMCS64_GUEST_BNDCFGS_HIGH 0x2813
1729/** @} */
1730
1731
1732/** @name VMCS field encoding: 64-bit host fields.
1733 * @{
1734 */
1735#define VMX_VMCS64_HOST_PAT_FULL 0x2c00
1736#define VMX_VMCS64_HOST_PAT_HIGH 0x2c01
1737#define VMX_VMCS64_HOST_EFER_FULL 0x2c02
1738#define VMX_VMCS64_HOST_EFER_HIGH 0x2c03
1739#define VMX_VMCS64_HOST_PERF_GLOBAL_CTRL_FULL 0x2c04
1740#define VMX_VMCS64_HOST_PERF_GLOBAL_CTRL_HIGH 0x2c05
1741/** @} */
1742
1743
1744/** @name VMCS field encoding: 32-bit control fields.
1745 * @{
1746 */
1747#define VMX_VMCS32_CTRL_PIN_EXEC 0x4000
1748#define VMX_VMCS32_CTRL_PROC_EXEC 0x4002
1749#define VMX_VMCS32_CTRL_EXCEPTION_BITMAP 0x4004
1750#define VMX_VMCS32_CTRL_PAGEFAULT_ERROR_MASK 0x4006
1751#define VMX_VMCS32_CTRL_PAGEFAULT_ERROR_MATCH 0x4008
1752#define VMX_VMCS32_CTRL_CR3_TARGET_COUNT 0x400a
1753#define VMX_VMCS32_CTRL_EXIT 0x400c
1754#define VMX_VMCS32_CTRL_EXIT_MSR_STORE_COUNT 0x400e
1755#define VMX_VMCS32_CTRL_EXIT_MSR_LOAD_COUNT 0x4010
1756#define VMX_VMCS32_CTRL_ENTRY 0x4012
1757#define VMX_VMCS32_CTRL_ENTRY_MSR_LOAD_COUNT 0x4014
1758#define VMX_VMCS32_CTRL_ENTRY_INTERRUPTION_INFO 0x4016
1759#define VMX_VMCS32_CTRL_ENTRY_EXCEPTION_ERRCODE 0x4018
1760#define VMX_VMCS32_CTRL_ENTRY_INSTR_LENGTH 0x401a
1761#define VMX_VMCS32_CTRL_TPR_THRESHOLD 0x401c
1762#define VMX_VMCS32_CTRL_PROC_EXEC2 0x401e
1763#define VMX_VMCS32_CTRL_PLE_GAP 0x4020
1764#define VMX_VMCS32_CTRL_PLE_WINDOW 0x4022
1765/** @} */
1766
1767
1768/** @name VMCS field encoding: 32-bits read-only fields.
1769 * @{
1770 */
1771#define VMX_VMCS32_RO_VM_INSTR_ERROR 0x4400
1772#define VMX_VMCS32_RO_EXIT_REASON 0x4402
1773#define VMX_VMCS32_RO_EXIT_INTERRUPTION_INFO 0x4404
1774#define VMX_VMCS32_RO_EXIT_INTERRUPTION_ERROR_CODE 0x4406
1775#define VMX_VMCS32_RO_IDT_VECTORING_INFO 0x4408
1776#define VMX_VMCS32_RO_IDT_VECTORING_ERROR_CODE 0x440a
1777#define VMX_VMCS32_RO_EXIT_INSTR_LENGTH 0x440c
1778#define VMX_VMCS32_RO_EXIT_INSTR_INFO 0x440e
1779/** @} */
1780
1781
1782/** @name VMCS field encoding: 32-bit guest-state fields.
1783 * @{
1784 */
1785#define VMX_VMCS32_GUEST_ES_LIMIT 0x4800
1786#define VMX_VMCS32_GUEST_CS_LIMIT 0x4802
1787#define VMX_VMCS32_GUEST_SS_LIMIT 0x4804
1788#define VMX_VMCS32_GUEST_DS_LIMIT 0x4806
1789#define VMX_VMCS32_GUEST_FS_LIMIT 0x4808
1790#define VMX_VMCS32_GUEST_GS_LIMIT 0x480a
1791#define VMX_VMCS32_GUEST_LDTR_LIMIT 0x480c
1792#define VMX_VMCS32_GUEST_TR_LIMIT 0x480e
1793#define VMX_VMCS32_GUEST_GDTR_LIMIT 0x4810
1794#define VMX_VMCS32_GUEST_IDTR_LIMIT 0x4812
1795#define VMX_VMCS32_GUEST_ES_ACCESS_RIGHTS 0x4814
1796#define VMX_VMCS32_GUEST_CS_ACCESS_RIGHTS 0x4816
1797#define VMX_VMCS32_GUEST_SS_ACCESS_RIGHTS 0x4818
1798#define VMX_VMCS32_GUEST_DS_ACCESS_RIGHTS 0x481a
1799#define VMX_VMCS32_GUEST_FS_ACCESS_RIGHTS 0x481c
1800#define VMX_VMCS32_GUEST_GS_ACCESS_RIGHTS 0x481e
1801#define VMX_VMCS32_GUEST_LDTR_ACCESS_RIGHTS 0x4820
1802#define VMX_VMCS32_GUEST_TR_ACCESS_RIGHTS 0x4822
1803#define VMX_VMCS32_GUEST_INT_STATE 0x4824
1804#define VMX_VMCS32_GUEST_ACTIVITY_STATE 0x4826
1805#define VMX_VMCS32_GUEST_SMBASE 0x4828
1806#define VMX_VMCS32_GUEST_SYSENTER_CS 0x482a
1807#define VMX_VMCS32_PREEMPT_TIMER_VALUE 0x482e
1808/** @} */
1809
1810
1811/** @name VMCS field encoding: 32-bit host-state fields.
1812 * @{
1813 */
1814#define VMX_VMCS32_HOST_SYSENTER_CS 0x4C00
1815/** @} */
1816
1817
1818/** @name Natural width control fields.
1819 * @{
1820 */
1821#define VMX_VMCS_CTRL_CR0_MASK 0x6000
1822#define VMX_VMCS_CTRL_CR4_MASK 0x6002
1823#define VMX_VMCS_CTRL_CR0_READ_SHADOW 0x6004
1824#define VMX_VMCS_CTRL_CR4_READ_SHADOW 0x6006
1825#define VMX_VMCS_CTRL_CR3_TARGET_VAL0 0x6008
1826#define VMX_VMCS_CTRL_CR3_TARGET_VAL1 0x600a
1827#define VMX_VMCS_CTRL_CR3_TARGET_VAL2 0x600c
1828#define VMX_VMCS_CTRL_CR3_TARGET_VAL3 0x600e
1829/** @} */
1830
1831
1832/** @name Natural width read-only data fields.
1833 * @{
1834 */
1835#define VMX_VMCS_RO_EXIT_QUALIFICATION 0x6400
1836#define VMX_VMCS_RO_IO_RCX 0x6402
1837#define VMX_VMCS_RO_IO_RSX 0x6404
1838#define VMX_VMCS_RO_IO_RDI 0x6406
1839#define VMX_VMCS_RO_IO_RIP 0x6408
1840#define VMX_VMCS_RO_GUEST_LINEAR_ADDR 0x640a
1841/** @} */
1842
1843
1844/** @name VMCS field encoding: Natural width guest-state fields.
1845 * @{
1846 */
1847#define VMX_VMCS_GUEST_CR0 0x6800
1848#define VMX_VMCS_GUEST_CR3 0x6802
1849#define VMX_VMCS_GUEST_CR4 0x6804
1850#define VMX_VMCS_GUEST_ES_BASE 0x6806
1851#define VMX_VMCS_GUEST_CS_BASE 0x6808
1852#define VMX_VMCS_GUEST_SS_BASE 0x680a
1853#define VMX_VMCS_GUEST_DS_BASE 0x680c
1854#define VMX_VMCS_GUEST_FS_BASE 0x680e
1855#define VMX_VMCS_GUEST_GS_BASE 0x6810
1856#define VMX_VMCS_GUEST_LDTR_BASE 0x6812
1857#define VMX_VMCS_GUEST_TR_BASE 0x6814
1858#define VMX_VMCS_GUEST_GDTR_BASE 0x6816
1859#define VMX_VMCS_GUEST_IDTR_BASE 0x6818
1860#define VMX_VMCS_GUEST_DR7 0x681a
1861#define VMX_VMCS_GUEST_RSP 0x681c
1862#define VMX_VMCS_GUEST_RIP 0x681e
1863#define VMX_VMCS_GUEST_RFLAGS 0x6820
1864#define VMX_VMCS_GUEST_PENDING_DEBUG_XCPTS 0x6822
1865#define VMX_VMCS_GUEST_SYSENTER_ESP 0x6824
1866#define VMX_VMCS_GUEST_SYSENTER_EIP 0x6826
1867/** @} */
1868
1869
1870/** @name VMCS field encoding: Natural width host-state fields.
1871 * @{
1872 */
1873#define VMX_VMCS_HOST_CR0 0x6c00
1874#define VMX_VMCS_HOST_CR3 0x6c02
1875#define VMX_VMCS_HOST_CR4 0x6c04
1876#define VMX_VMCS_HOST_FS_BASE 0x6c06
1877#define VMX_VMCS_HOST_GS_BASE 0x6c08
1878#define VMX_VMCS_HOST_TR_BASE 0x6c0a
1879#define VMX_VMCS_HOST_GDTR_BASE 0x6c0c
1880#define VMX_VMCS_HOST_IDTR_BASE 0x6c0e
1881#define VMX_VMCS_HOST_SYSENTER_ESP 0x6c10
1882#define VMX_VMCS_HOST_SYSENTER_EIP 0x6c12
1883#define VMX_VMCS_HOST_RSP 0x6c14
1884#define VMX_VMCS_HOST_RIP 0x6c16
1885/** @} */
1886
1887
1888/** @name VMCS field encoding: Access.
1889 * @{ */
1890typedef enum
1891{
1892 VMXVMCSFIELDACCESS_FULL = 0,
1893 VMXVMCSFIELDACCESS_HIGH
1894} VMXVMCSFIELDACCESS;
1895AssertCompileSize(VMXVMCSFIELDACCESS, 4);
1896/** @} */
1897
1898
1899/** @name VMCS field encoding: Type.
1900 * @{ */
1901typedef enum
1902{
1903 VMXVMCSFIELDTYPE_CONTROL = 0,
1904 VMXVMCSFIELDTYPE_VMEXIT_INFO,
1905 VMXVMCSFIELDTYPE_GUEST_STATE,
1906 VMXVMCSFIELDTYPE_HOST_STATE
1907} VMXVMCSFIELDTYPE;
1908AssertCompileSize(VMXVMCSFIELDTYPE, 4);
1909/** @} */
1910
1911
1912/** @name VMCS field encoding: Width.
1913 * @{ */
1914typedef enum
1915{
1916 VMXVMCSFIELDWIDTH_16BIT = 0,
1917 VMXVMCSFIELDWIDTH_64BIT,
1918 VMXVMCSFIELDWIDTH_32BIT,
1919 VMXVMCSFIELDWIDTH_NATURAL
1920} VMXVMCSFIELDWIDTH;
1921AssertCompileSize(VMXVMCSFIELDWIDTH, 4);
1922/** @} */
1923
1924/** @name VM-entry instruction length.
1925 * @{ */
1926/** The maximum valid value for VM-entry instruction length while injecting a
1927 * software interrupt, software exception or privileged software exception. */
1928#define VMX_ENTRY_INSTR_LEN_MAX 15
1929/** @} */
1930
1931
1932/** @name VM-entry register masks.
1933 * @{ */
1934/** CR0 bits ignored on VM-entry (ET, NW, CD and reserved bits bits 6:15, bit 17,
1935 * bits 19:28). */
1936#define VMX_ENTRY_CR0_IGNORE_MASK UINT64_C(0x7ffaffc0)
1937/** DR7 bits set here are always cleared on VM-entry (bit 12, bits 14:15). */
1938#define VMX_ENTRY_DR7_MBZ_MASK UINT64_C(0xd000)
1939/** DR7 bits set here are always set on VM-entry (bit 10). */
1940#define VMX_ENTRY_DR7_MB1_MASK UINT64_C(0x400)
1941/** @} */
1942
1943
1944/** @name Pin-based VM-execution controls.
1945 * @{
1946 */
1947/** External interrupt exiting. */
1948#define VMX_PIN_CTLS_EXT_INT_EXIT RT_BIT(0)
1949/** NMI exiting. */
1950#define VMX_PIN_CTLS_NMI_EXIT RT_BIT(3)
1951/** Virtual NMIs. */
1952#define VMX_PIN_CTLS_VIRT_NMI RT_BIT(5)
1953/** Activate VMX preemption timer. */
1954#define VMX_PIN_CTLS_PREEMPT_TIMER RT_BIT(6)
1955/** Process interrupts with the posted-interrupt notification vector. */
1956#define VMX_PIN_CTLS_POSTED_INT RT_BIT(7)
1957/** Default1 class when true capability MSRs are not supported. */
1958#define VMX_PIN_CTLS_DEFAULT1 UINT32_C(0x00000016)
1959
1960/** Bit fields for MSR_IA32_VMX_PINBASED_CTLS and Pin-based VM-execution
1961 * controls field in the VMCS. */
1962#define VMX_BF_PIN_CTLS_EXT_INT_EXIT_SHIFT 0
1963#define VMX_BF_PIN_CTLS_EXT_INT_EXIT_MASK UINT32_C(0x00000001)
1964#define VMX_BF_PIN_CTLS_UNDEF_1_2_SHIFT 1
1965#define VMX_BF_PIN_CTLS_UNDEF_1_2_MASK UINT32_C(0x00000006)
1966#define VMX_BF_PIN_CTLS_NMI_EXIT_SHIFT 3
1967#define VMX_BF_PIN_CTLS_NMI_EXIT_MASK UINT32_C(0x00000008)
1968#define VMX_BF_PIN_CTLS_UNDEF_4_SHIFT 4
1969#define VMX_BF_PIN_CTLS_UNDEF_4_MASK UINT32_C(0x00000010)
1970#define VMX_BF_PIN_CTLS_VIRT_NMI_SHIFT 5
1971#define VMX_BF_PIN_CTLS_VIRT_NMI_MASK UINT32_C(0x00000020)
1972#define VMX_BF_PIN_CTLS_PREEMPT_TIMER_SHIFT 6
1973#define VMX_BF_PIN_CTLS_PREEMPT_TIMER_MASK UINT32_C(0x00000040)
1974#define VMX_BF_PIN_CTLS_POSTED_INT_SHIFT 7
1975#define VMX_BF_PIN_CTLS_POSTED_INT_MASK UINT32_C(0x00000080)
1976#define VMX_BF_PIN_CTLS_UNDEF_8_31_SHIFT 8
1977#define VMX_BF_PIN_CTLS_UNDEF_8_31_MASK UINT32_C(0xffffff00)
1978RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_PIN_CTLS_, UINT32_C(0), UINT32_MAX,
1979 (EXT_INT_EXIT, UNDEF_1_2, NMI_EXIT, UNDEF_4, VIRT_NMI, PREEMPT_TIMER, POSTED_INT, UNDEF_8_31));
1980/** @} */
1981
1982
1983/** @name Processor-based VM-execution controls.
1984 * @{
1985 */
1986/** VM-exit as soon as RFLAGS.IF=1 and no blocking is active. */
1987#define VMX_PROC_CTLS_INT_WINDOW_EXIT RT_BIT(2)
1988/** Use timestamp counter offset. */
1989#define VMX_PROC_CTLS_USE_TSC_OFFSETTING RT_BIT(3)
1990/** VM-exit when executing the HLT instruction. */
1991#define VMX_PROC_CTLS_HLT_EXIT RT_BIT(7)
1992/** VM-exit when executing the INVLPG instruction. */
1993#define VMX_PROC_CTLS_INVLPG_EXIT RT_BIT(9)
1994/** VM-exit when executing the MWAIT instruction. */
1995#define VMX_PROC_CTLS_MWAIT_EXIT RT_BIT(10)
1996/** VM-exit when executing the RDPMC instruction. */
1997#define VMX_PROC_CTLS_RDPMC_EXIT RT_BIT(11)
1998/** VM-exit when executing the RDTSC/RDTSCP instruction. */
1999#define VMX_PROC_CTLS_RDTSC_EXIT RT_BIT(12)
2000/** VM-exit when executing the MOV to CR3 instruction. (forced to 1 on the
2001 * 'first' VT-x capable CPUs; this actually includes the newest Nehalem CPUs) */
2002#define VMX_PROC_CTLS_CR3_LOAD_EXIT RT_BIT(15)
2003/** VM-exit when executing the MOV from CR3 instruction. (forced to 1 on the
2004 * 'first' VT-x capable CPUs; this actually includes the newest Nehalem CPUs) */
2005#define VMX_PROC_CTLS_CR3_STORE_EXIT RT_BIT(16)
2006/** VM-exit on CR8 loads. */
2007#define VMX_PROC_CTLS_CR8_LOAD_EXIT RT_BIT(19)
2008/** VM-exit on CR8 stores. */
2009#define VMX_PROC_CTLS_CR8_STORE_EXIT RT_BIT(20)
2010/** Use TPR shadow. */
2011#define VMX_PROC_CTLS_USE_TPR_SHADOW RT_BIT(21)
2012/** VM-exit when virtual NMI blocking is disabled. */
2013#define VMX_PROC_CTLS_NMI_WINDOW_EXIT RT_BIT(22)
2014/** VM-exit when executing a MOV DRx instruction. */
2015#define VMX_PROC_CTLS_MOV_DR_EXIT RT_BIT(23)
2016/** VM-exit when executing IO instructions. */
2017#define VMX_PROC_CTLS_UNCOND_IO_EXIT RT_BIT(24)
2018/** Use IO bitmaps. */
2019#define VMX_PROC_CTLS_USE_IO_BITMAPS RT_BIT(25)
2020/** Monitor trap flag. */
2021#define VMX_PROC_CTLS_MONITOR_TRAP_FLAG RT_BIT(27)
2022/** Use MSR bitmaps. */
2023#define VMX_PROC_CTLS_USE_MSR_BITMAPS RT_BIT(28)
2024/** VM-exit when executing the MONITOR instruction. */
2025#define VMX_PROC_CTLS_MONITOR_EXIT RT_BIT(29)
2026/** VM-exit when executing the PAUSE instruction. */
2027#define VMX_PROC_CTLS_PAUSE_EXIT RT_BIT(30)
2028/** Whether the secondary processor based VM-execution controls are used. */
2029#define VMX_PROC_CTLS_USE_SECONDARY_CTLS RT_BIT(31)
2030/** Default1 class when true-capability MSRs are not supported. */
2031#define VMX_PROC_CTLS_DEFAULT1 UINT32_C(0x0401e172)
2032
2033/** Bit fields for MSR_IA32_VMX_PROCBASED_CTLS and Processor-based VM-execution
2034 * controls field in the VMCS. */
2035#define VMX_BF_PROC_CTLS_UNDEF_0_1_SHIFT 0
2036#define VMX_BF_PROC_CTLS_UNDEF_0_1_MASK UINT32_C(0x00000003)
2037#define VMX_BF_PROC_CTLS_INT_WINDOW_EXIT_SHIFT 2
2038#define VMX_BF_PROC_CTLS_INT_WINDOW_EXIT_MASK UINT32_C(0x00000004)
2039#define VMX_BF_PROC_CTLS_USE_TSC_OFFSETTING_SHIFT 3
2040#define VMX_BF_PROC_CTLS_USE_TSC_OFFSETTING_MASK UINT32_C(0x00000008)
2041#define VMX_BF_PROC_CTLS_UNDEF_4_6_SHIFT 4
2042#define VMX_BF_PROC_CTLS_UNDEF_4_6_MASK UINT32_C(0x00000070)
2043#define VMX_BF_PROC_CTLS_HLT_EXIT_SHIFT 7
2044#define VMX_BF_PROC_CTLS_HLT_EXIT_MASK UINT32_C(0x00000080)
2045#define VMX_BF_PROC_CTLS_UNDEF_8_SHIFT 8
2046#define VMX_BF_PROC_CTLS_UNDEF_8_MASK UINT32_C(0x00000100)
2047#define VMX_BF_PROC_CTLS_INVLPG_EXIT_SHIFT 9
2048#define VMX_BF_PROC_CTLS_INVLPG_EXIT_MASK UINT32_C(0x00000200)
2049#define VMX_BF_PROC_CTLS_MWAIT_EXIT_SHIFT 10
2050#define VMX_BF_PROC_CTLS_MWAIT_EXIT_MASK UINT32_C(0x00000400)
2051#define VMX_BF_PROC_CTLS_RDPMC_EXIT_SHIFT 11
2052#define VMX_BF_PROC_CTLS_RDPMC_EXIT_MASK UINT32_C(0x00000800)
2053#define VMX_BF_PROC_CTLS_RDTSC_EXIT_SHIFT 12
2054#define VMX_BF_PROC_CTLS_RDTSC_EXIT_MASK UINT32_C(0x00001000)
2055#define VMX_BF_PROC_CTLS_UNDEF_13_14_SHIFT 13
2056#define VMX_BF_PROC_CTLS_UNDEF_13_14_MASK UINT32_C(0x00006000)
2057#define VMX_BF_PROC_CTLS_CR3_LOAD_EXIT_SHIFT 15
2058#define VMX_BF_PROC_CTLS_CR3_LOAD_EXIT_MASK UINT32_C(0x00008000)
2059#define VMX_BF_PROC_CTLS_CR3_STORE_EXIT_SHIFT 16
2060#define VMX_BF_PROC_CTLS_CR3_STORE_EXIT_MASK UINT32_C(0x00010000)
2061#define VMX_BF_PROC_CTLS_UNDEF_17_18_SHIFT 17
2062#define VMX_BF_PROC_CTLS_UNDEF_17_18_MASK UINT32_C(0x00060000)
2063#define VMX_BF_PROC_CTLS_CR8_LOAD_EXIT_SHIFT 19
2064#define VMX_BF_PROC_CTLS_CR8_LOAD_EXIT_MASK UINT32_C(0x00080000)
2065#define VMX_BF_PROC_CTLS_CR8_STORE_EXIT_SHIFT 20
2066#define VMX_BF_PROC_CTLS_CR8_STORE_EXIT_MASK UINT32_C(0x00100000)
2067#define VMX_BF_PROC_CTLS_USE_TPR_SHADOW_SHIFT 21
2068#define VMX_BF_PROC_CTLS_USE_TPR_SHADOW_MASK UINT32_C(0x00200000)
2069#define VMX_BF_PROC_CTLS_NMI_WINDOW_EXIT_SHIFT 22
2070#define VMX_BF_PROC_CTLS_NMI_WINDOW_EXIT_MASK UINT32_C(0x00400000)
2071#define VMX_BF_PROC_CTLS_MOV_DR_EXIT_SHIFT 23
2072#define VMX_BF_PROC_CTLS_MOV_DR_EXIT_MASK UINT32_C(0x00800000)
2073#define VMX_BF_PROC_CTLS_UNCOND_IO_EXIT_SHIFT 24
2074#define VMX_BF_PROC_CTLS_UNCOND_IO_EXIT_MASK UINT32_C(0x01000000)
2075#define VMX_BF_PROC_CTLS_USE_IO_BITMAPS_SHIFT 25
2076#define VMX_BF_PROC_CTLS_USE_IO_BITMAPS_MASK UINT32_C(0x02000000)
2077#define VMX_BF_PROC_CTLS_UNDEF_26_SHIFT 26
2078#define VMX_BF_PROC_CTLS_UNDEF_26_MASK UINT32_C(0x4000000)
2079#define VMX_BF_PROC_CTLS_MONITOR_TRAP_FLAG_SHIFT 27
2080#define VMX_BF_PROC_CTLS_MONITOR_TRAP_FLAG_MASK UINT32_C(0x08000000)
2081#define VMX_BF_PROC_CTLS_USE_MSR_BITMAPS_SHIFT 28
2082#define VMX_BF_PROC_CTLS_USE_MSR_BITMAPS_MASK UINT32_C(0x10000000)
2083#define VMX_BF_PROC_CTLS_MONITOR_EXIT_SHIFT 29
2084#define VMX_BF_PROC_CTLS_MONITOR_EXIT_MASK UINT32_C(0x20000000)
2085#define VMX_BF_PROC_CTLS_PAUSE_EXIT_SHIFT 30
2086#define VMX_BF_PROC_CTLS_PAUSE_EXIT_MASK UINT32_C(0x40000000)
2087#define VMX_BF_PROC_CTLS_USE_SECONDARY_CTLS_SHIFT 31
2088#define VMX_BF_PROC_CTLS_USE_SECONDARY_CTLS_MASK UINT32_C(0x80000000)
2089RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_PROC_CTLS_, UINT32_C(0), UINT32_MAX,
2090 (UNDEF_0_1, INT_WINDOW_EXIT, USE_TSC_OFFSETTING, UNDEF_4_6, HLT_EXIT, UNDEF_8, INVLPG_EXIT,
2091 MWAIT_EXIT, RDPMC_EXIT, RDTSC_EXIT, UNDEF_13_14, CR3_LOAD_EXIT, CR3_STORE_EXIT, UNDEF_17_18,
2092 CR8_LOAD_EXIT, CR8_STORE_EXIT, USE_TPR_SHADOW, NMI_WINDOW_EXIT, MOV_DR_EXIT, UNCOND_IO_EXIT,
2093 USE_IO_BITMAPS, UNDEF_26, MONITOR_TRAP_FLAG, USE_MSR_BITMAPS, MONITOR_EXIT, PAUSE_EXIT,
2094 USE_SECONDARY_CTLS));
2095/** @} */
2096
2097
2098/** @name Secondary Processor-based VM-execution controls.
2099 * @{
2100 */
2101/** Virtualize APIC accesses. */
2102#define VMX_PROC_CTLS2_VIRT_APIC_ACCESS RT_BIT(0)
2103/** EPT supported/enabled. */
2104#define VMX_PROC_CTLS2_EPT RT_BIT(1)
2105/** Descriptor table instructions cause VM-exits. */
2106#define VMX_PROC_CTLS2_DESC_TABLE_EXIT RT_BIT(2)
2107/** RDTSCP supported/enabled. */
2108#define VMX_PROC_CTLS2_RDTSCP RT_BIT(3)
2109/** Virtualize x2APIC mode. */
2110#define VMX_PROC_CTLS2_VIRT_X2APIC_MODE RT_BIT(4)
2111/** VPID supported/enabled. */
2112#define VMX_PROC_CTLS2_VPID RT_BIT(5)
2113/** VM-exit when executing the WBINVD instruction. */
2114#define VMX_PROC_CTLS2_WBINVD_EXIT RT_BIT(6)
2115/** Unrestricted guest execution. */
2116#define VMX_PROC_CTLS2_UNRESTRICTED_GUEST RT_BIT(7)
2117/** APIC register virtualization. */
2118#define VMX_PROC_CTLS2_APIC_REG_VIRT RT_BIT(8)
2119/** Virtual-interrupt delivery. */
2120#define VMX_PROC_CTLS2_VIRT_INT_DELIVERY RT_BIT(9)
2121/** A specified number of pause loops cause a VM-exit. */
2122#define VMX_PROC_CTLS2_PAUSE_LOOP_EXIT RT_BIT(10)
2123/** VM-exit when executing RDRAND instructions. */
2124#define VMX_PROC_CTLS2_RDRAND_EXIT RT_BIT(11)
2125/** Enables INVPCID instructions. */
2126#define VMX_PROC_CTLS2_INVPCID RT_BIT(12)
2127/** Enables VMFUNC instructions. */
2128#define VMX_PROC_CTLS2_VMFUNC RT_BIT(13)
2129/** Enables VMCS shadowing. */
2130#define VMX_PROC_CTLS2_VMCS_SHADOWING RT_BIT(14)
2131/** Enables ENCLS VM-exits. */
2132#define VMX_PROC_CTLS2_ENCLS_EXIT RT_BIT(15)
2133/** VM-exit when executing RDSEED. */
2134#define VMX_PROC_CTLS2_RDSEED_EXIT RT_BIT(16)
2135/** Enables page-modification logging. */
2136#define VMX_PROC_CTLS2_PML RT_BIT(17)
2137/** Controls whether EPT-violations may cause \#VE instead of exits. */
2138#define VMX_PROC_CTLS2_EPT_VE RT_BIT(18)
2139/** Conceal VMX non-root operation from Intel processor trace (PT). */
2140#define VMX_PROC_CTLS2_CONCEAL_FROM_PT RT_BIT(19)
2141/** Enables XSAVES/XRSTORS instructions. */
2142#define VMX_PROC_CTLS2_XSAVES_XRSTORS RT_BIT(20)
2143/** Use TSC scaling. */
2144#define VMX_PROC_CTLS2_TSC_SCALING RT_BIT(25)
2145
2146/** Bit fields for MSR_IA32_VMX_PROCBASED_CTLS2 and Secondary processor-based
2147 * VM-execution controls field in the VMCS. */
2148#define VMX_BF_PROC_CTLS2_VIRT_APIC_ACCESS_SHIFT 0
2149#define VMX_BF_PROC_CTLS2_VIRT_APIC_ACCESS_MASK UINT32_C(0x00000001)
2150#define VMX_BF_PROC_CTLS2_EPT_SHIFT 1
2151#define VMX_BF_PROC_CTLS2_EPT_MASK UINT32_C(0x00000002)
2152#define VMX_BF_PROC_CTLS2_DESC_TABLE_EXIT_SHIFT 2
2153#define VMX_BF_PROC_CTLS2_DESC_TABLE_EXIT_MASK UINT32_C(0x00000004)
2154#define VMX_BF_PROC_CTLS2_RDTSCP_SHIFT 3
2155#define VMX_BF_PROC_CTLS2_RDTSCP_MASK UINT32_C(0x00000008)
2156#define VMX_BF_PROC_CTLS2_VIRT_X2APIC_MODE_SHIFT 4
2157#define VMX_BF_PROC_CTLS2_VIRT_X2APIC_MODE_MASK UINT32_C(0x00000010)
2158#define VMX_BF_PROC_CTLS2_VPID_SHIFT 5
2159#define VMX_BF_PROC_CTLS2_VPID_MASK UINT32_C(0x00000020)
2160#define VMX_BF_PROC_CTLS2_WBINVD_EXIT_SHIFT 6
2161#define VMX_BF_PROC_CTLS2_WBINVD_EXIT_MASK UINT32_C(0x00000040)
2162#define VMX_BF_PROC_CTLS2_UNRESTRICTED_GUEST_SHIFT 7
2163#define VMX_BF_PROC_CTLS2_UNRESTRICTED_GUEST_MASK UINT32_C(0x00000080)
2164#define VMX_BF_PROC_CTLS2_APIC_REG_VIRT_SHIFT 8
2165#define VMX_BF_PROC_CTLS2_APIC_REG_VIRT_MASK UINT32_C(0x00000100)
2166#define VMX_BF_PROC_CTLS2_VIRT_INT_DELIVERY_SHIFT 9
2167#define VMX_BF_PROC_CTLS2_VIRT_INT_DELIVERY_MASK UINT32_C(0x00000200)
2168#define VMX_BF_PROC_CTLS2_PAUSE_LOOP_EXIT_SHIFT 10
2169#define VMX_BF_PROC_CTLS2_PAUSE_LOOP_EXIT_MASK UINT32_C(0x00000400)
2170#define VMX_BF_PROC_CTLS2_RDRAND_EXIT_SHIFT 11
2171#define VMX_BF_PROC_CTLS2_RDRAND_EXIT_MASK UINT32_C(0x00000800)
2172#define VMX_BF_PROC_CTLS2_INVPCID_SHIFT 12
2173#define VMX_BF_PROC_CTLS2_INVPCID_MASK UINT32_C(0x00001000)
2174#define VMX_BF_PROC_CTLS2_VMFUNC_SHIFT 13
2175#define VMX_BF_PROC_CTLS2_VMFUNC_MASK UINT32_C(0x00002000)
2176#define VMX_BF_PROC_CTLS2_VMCS_SHADOWING_SHIFT 14
2177#define VMX_BF_PROC_CTLS2_VMCS_SHADOWING_MASK UINT32_C(0x00004000)
2178#define VMX_BF_PROC_CTLS2_ENCLS_EXIT_SHIFT 15
2179#define VMX_BF_PROC_CTLS2_ENCLS_EXIT_MASK UINT32_C(0x00008000)
2180#define VMX_BF_PROC_CTLS2_RDSEED_EXIT_SHIFT 16
2181#define VMX_BF_PROC_CTLS2_RDSEED_EXIT_MASK UINT32_C(0x00010000)
2182#define VMX_BF_PROC_CTLS2_PML_SHIFT 17
2183#define VMX_BF_PROC_CTLS2_PML_MASK UINT32_C(0x00020000)
2184#define VMX_BF_PROC_CTLS2_EPT_VE_SHIFT 18
2185#define VMX_BF_PROC_CTLS2_EPT_VE_MASK UINT32_C(0x00040000)
2186#define VMX_BF_PROC_CTLS2_CONCEAL_FROM_PT_SHIFT 19
2187#define VMX_BF_PROC_CTLS2_CONCEAL_FROM_PT_MASK UINT32_C(0x00080000)
2188#define VMX_BF_PROC_CTLS2_XSAVES_XRSTORS_SHIFT 20
2189#define VMX_BF_PROC_CTLS2_XSAVES_XRSTORS_MASK UINT32_C(0x00100000)
2190#define VMX_BF_PROC_CTLS2_UNDEF_21_24_SHIFT 21
2191#define VMX_BF_PROC_CTLS2_UNDEF_21_24_MASK UINT32_C(0x01e00000)
2192#define VMX_BF_PROC_CTLS2_TSC_SCALING_SHIFT 25
2193#define VMX_BF_PROC_CTLS2_TSC_SCALING_MASK UINT32_C(0x02000000)
2194#define VMX_BF_PROC_CTLS2_UNDEF_26_31_SHIFT 26
2195#define VMX_BF_PROC_CTLS2_UNDEF_26_31_MASK UINT32_C(0xfc000000)
2196RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_PROC_CTLS2_, UINT32_C(0), UINT32_MAX,
2197 (VIRT_APIC_ACCESS, EPT, DESC_TABLE_EXIT, RDTSCP, VIRT_X2APIC_MODE, VPID, WBINVD_EXIT,
2198 UNRESTRICTED_GUEST, APIC_REG_VIRT, VIRT_INT_DELIVERY, PAUSE_LOOP_EXIT, RDRAND_EXIT, INVPCID, VMFUNC,
2199 VMCS_SHADOWING, ENCLS_EXIT, RDSEED_EXIT, PML, EPT_VE, CONCEAL_FROM_PT, XSAVES_XRSTORS, UNDEF_21_24,
2200 TSC_SCALING, UNDEF_26_31));
2201/** @} */
2202
2203
2204/** @name VM-entry controls.
2205 * @{
2206 */
2207/** Load guest debug controls (dr7 & IA32_DEBUGCTL_MSR) (forced to 1 on the
2208 * 'first' VT-x capable CPUs; this actually includes the newest Nehalem CPUs) */
2209#define VMX_ENTRY_CTLS_LOAD_DEBUG RT_BIT(2)
2210/** 64-bit guest mode. Must be 0 for CPUs that don't support AMD64. */
2211#define VMX_ENTRY_CTLS_IA32E_MODE_GUEST RT_BIT(9)
2212/** In SMM mode after VM-entry. */
2213#define VMX_ENTRY_CTLS_ENTRY_TO_SMM RT_BIT(10)
2214/** Disable dual treatment of SMI and SMM; must be zero for VM-entry outside of SMM. */
2215#define VMX_ENTRY_CTLS_DEACTIVATE_DUAL_MON RT_BIT(11)
2216/** Whether the guest IA32_PERF_GLOBAL_CTRL MSR is loaded on VM-entry. */
2217#define VMX_ENTRY_CTLS_LOAD_PERF_MSR RT_BIT(13)
2218/** Whether the guest IA32_PAT MSR is loaded on VM-entry. */
2219#define VMX_ENTRY_CTLS_LOAD_PAT_MSR RT_BIT(14)
2220/** Whether the guest IA32_EFER MSR is loaded on VM-entry. */
2221#define VMX_ENTRY_CTLS_LOAD_EFER_MSR RT_BIT(15)
2222/** Whether the guest IA32_BNDCFGS MSR is loaded on VM-entry. */
2223#define VMX_ENTRY_CTLS_LOAD_BNDCFGS_MSR RT_BIT(16)
2224/** Whether to conceal VMX from Intel PT (Processor Trace). */
2225#define VMX_ENTRY_CTLS_CONCEAL_VMX_PT RT_BIT(17)
2226/** Default1 class when true-capability MSRs are not supported. */
2227#define VMX_ENTRY_CTLS_DEFAULT1 UINT32_C(0x000011ff)
2228
2229/** Bit fields for MSR_IA32_VMX_ENTRY_CTLS and VM-entry controls field in the
2230 * VMCS. */
2231#define VMX_BF_ENTRY_CTLS_UNDEF_0_1_SHIFT 0
2232#define VMX_BF_ENTRY_CTLS_UNDEF_0_1_MASK UINT32_C(0x00000003)
2233#define VMX_BF_ENTRY_CTLS_LOAD_DEBUG_SHIFT 2
2234#define VMX_BF_ENTRY_CTLS_LOAD_DEBUG_MASK UINT32_C(0x00000004)
2235#define VMX_BF_ENTRY_CTLS_UNDEF_3_8_SHIFT 3
2236#define VMX_BF_ENTRY_CTLS_UNDEF_3_8_MASK UINT32_C(0x000001f8)
2237#define VMX_BF_ENTRY_CTLS_IA32E_MODE_GUEST_SHIFT 9
2238#define VMX_BF_ENTRY_CTLS_IA32E_MODE_GUEST_MASK UINT32_C(0x00000200)
2239#define VMX_BF_ENTRY_CTLS_ENTRY_SMM_SHIFT 10
2240#define VMX_BF_ENTRY_CTLS_ENTRY_SMM_MASK UINT32_C(0x00000400)
2241#define VMX_BF_ENTRY_CTLS_DEACTIVATE_DUAL_MON_SHIFT 11
2242#define VMX_BF_ENTRY_CTLS_DEACTIVATE_DUAL_MON_MASK UINT32_C(0x00000800)
2243#define VMX_BF_ENTRY_CTLS_UNDEF_12_SHIFT 12
2244#define VMX_BF_ENTRY_CTLS_UNDEF_12_MASK UINT32_C(0x00001000)
2245#define VMX_BF_ENTRY_CTLS_LOAD_PERF_MSR_SHIFT 13
2246#define VMX_BF_ENTRY_CTLS_LOAD_PERF_MSR_MASK UINT32_C(0x00002000)
2247#define VMX_BF_ENTRY_CTLS_LOAD_PAT_MSR_SHIFT 14
2248#define VMX_BF_ENTRY_CTLS_LOAD_PAT_MSR_MASK UINT32_C(0x00004000)
2249#define VMX_BF_ENTRY_CTLS_LOAD_EFER_MSR_SHIFT 15
2250#define VMX_BF_ENTRY_CTLS_LOAD_EFER_MSR_MASK UINT32_C(0x00008000)
2251#define VMX_BF_ENTRY_CTLS_LOAD_BNDCFGS_MSR_SHIFT 16
2252#define VMX_BF_ENTRY_CTLS_LOAD_BNDCFGS_MSR_MASK UINT32_C(0x00010000)
2253#define VMX_BF_ENTRY_CTLS_CONCEAL_VMX_PT_SHIFT 17
2254#define VMX_BF_ENTRY_CTLS_CONCEAL_VMX_PT_MASK UINT32_C(0x00020000)
2255#define VMX_BF_ENTRY_CTLS_UNDEF_18_31_SHIFT 18
2256#define VMX_BF_ENTRY_CTLS_UNDEF_18_31_MASK UINT32_C(0xfffc0000)
2257RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_ENTRY_CTLS_, UINT32_C(0), UINT32_MAX,
2258 (UNDEF_0_1, LOAD_DEBUG, UNDEF_3_8, IA32E_MODE_GUEST, ENTRY_SMM, DEACTIVATE_DUAL_MON, UNDEF_12,
2259 LOAD_PERF_MSR, LOAD_PAT_MSR, LOAD_EFER_MSR, LOAD_BNDCFGS_MSR, CONCEAL_VMX_PT, UNDEF_18_31));
2260/** @} */
2261
2262
2263/** @name VM-exit controls.
2264 * @{
2265 */
2266/** Save guest debug controls (dr7 & IA32_DEBUGCTL_MSR) (forced to 1 on the
2267 * 'first' VT-x capable CPUs; this actually includes the newest Nehalem CPUs) */
2268#define VMX_EXIT_CTLS_SAVE_DEBUG RT_BIT(2)
2269/** Return to long mode after a VM-exit. */
2270#define VMX_EXIT_CTLS_HOST_ADDR_SPACE_SIZE RT_BIT(9)
2271/** Whether the host IA32_PERF_GLOBAL_CTRL MSR is loaded on VM-exit. */
2272#define VMX_EXIT_CTLS_LOAD_PERF_MSR RT_BIT(12)
2273/** Acknowledge external interrupts with the irq controller if one caused a VM-exit. */
2274#define VMX_EXIT_CTLS_ACK_EXT_INT RT_BIT(15)
2275/** Whether the guest IA32_PAT MSR is saved on VM-exit. */
2276#define VMX_EXIT_CTLS_SAVE_PAT_MSR RT_BIT(18)
2277/** Whether the host IA32_PAT MSR is loaded on VM-exit. */
2278#define VMX_EXIT_CTLS_LOAD_PAT_MSR RT_BIT(19)
2279/** Whether the guest IA32_EFER MSR is saved on VM-exit. */
2280#define VMX_EXIT_CTLS_SAVE_EFER_MSR RT_BIT(20)
2281/** Whether the host IA32_EFER MSR is loaded on VM-exit. */
2282#define VMX_EXIT_CTLS_LOAD_EFER_MSR RT_BIT(21)
2283/** Whether the value of the VMX preemption timer is saved on every VM-exit. */
2284#define VMX_EXIT_CTLS_SAVE_PREEMPT_TIMER RT_BIT(22)
2285/** Whether IA32_BNDCFGS MSR is cleared on VM-exit. */
2286#define VMX_EXIT_CTLS_CLEAR_BNDCFGS_MSR RT_BIT(23)
2287/** Default1 class when true-capability MSRs are not supported. */
2288#define VMX_EXIT_CTLS_DEFAULT1 UINT32_C(0x00036dff)
2289
2290/** Bit fields for MSR_IA32_VMX_EXIT_CTLS and VM-exit controls field in the
2291 * VMCS. */
2292#define VMX_BF_EXIT_CTLS_UNDEF_0_1_SHIFT 0
2293#define VMX_BF_EXIT_CTLS_UNDEF_0_1_MASK UINT32_C(0x00000003)
2294#define VMX_BF_EXIT_CTLS_SAVE_DEBUG_SHIFT 2
2295#define VMX_BF_EXIT_CTLS_SAVE_DEBUG_MASK UINT32_C(0x00000004)
2296#define VMX_BF_EXIT_CTLS_UNDEF_3_8_SHIFT 3
2297#define VMX_BF_EXIT_CTLS_UNDEF_3_8_MASK UINT32_C(0x000001f8)
2298#define VMX_BF_EXIT_CTLS_HOST_ADDR_SPACE_SIZE_SHIFT 9
2299#define VMX_BF_EXIT_CTLS_HOST_ADDR_SPACE_SIZE_MASK UINT32_C(0x00000200)
2300#define VMX_BF_EXIT_CTLS_UNDEF_10_11_SHIFT 10
2301#define VMX_BF_EXIT_CTLS_UNDEF_10_11_MASK UINT32_C(0x00000c00)
2302#define VMX_BF_EXIT_CTLS_LOAD_PERF_MSR_SHIFT 12
2303#define VMX_BF_EXIT_CTLS_LOAD_PERF_MSR_MASK UINT32_C(0x00001000)
2304#define VMX_BF_EXIT_CTLS_UNDEF_13_14_SHIFT 13
2305#define VMX_BF_EXIT_CTLS_UNDEF_13_14_MASK UINT32_C(0x00006000)
2306#define VMX_BF_EXIT_CTLS_ACK_EXT_INT_SHIFT 15
2307#define VMX_BF_EXIT_CTLS_ACK_EXT_INT_MASK UINT32_C(0x00008000)
2308#define VMX_BF_EXIT_CTLS_UNDEF_16_17_SHIFT 16
2309#define VMX_BF_EXIT_CTLS_UNDEF_16_17_MASK UINT32_C(0x00030000)
2310#define VMX_BF_EXIT_CTLS_SAVE_PAT_MSR_SHIFT 18
2311#define VMX_BF_EXIT_CTLS_SAVE_PAT_MSR_MASK UINT32_C(0x00040000)
2312#define VMX_BF_EXIT_CTLS_LOAD_PAT_MSR_SHIFT 19
2313#define VMX_BF_EXIT_CTLS_LOAD_PAT_MSR_MASK UINT32_C(0x00080000)
2314#define VMX_BF_EXIT_CTLS_SAVE_EFER_MSR_SHIFT 20
2315#define VMX_BF_EXIT_CTLS_SAVE_EFER_MSR_MASK UINT32_C(0x00100000)
2316#define VMX_BF_EXIT_CTLS_LOAD_EFER_MSR_SHIFT 21
2317#define VMX_BF_EXIT_CTLS_LOAD_EFER_MSR_MASK UINT32_C(0x00200000)
2318#define VMX_BF_EXIT_CTLS_SAVE_PREEMPT_TIMER_SHIFT 22
2319#define VMX_BF_EXIT_CTLS_SAVE_PREEMPT_TIMER_MASK UINT32_C(0x00400000)
2320#define VMX_BF_EXIT_CTLS_UNDEF_23_31_SHIFT 23
2321#define VMX_BF_EXIT_CTLS_UNDEF_23_31_MASK UINT32_C(0xff800000)
2322RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_EXIT_CTLS_, UINT32_C(0), UINT32_MAX,
2323 (UNDEF_0_1, SAVE_DEBUG, UNDEF_3_8, HOST_ADDR_SPACE_SIZE, UNDEF_10_11, LOAD_PERF_MSR, UNDEF_13_14,
2324 ACK_EXT_INT, UNDEF_16_17, SAVE_PAT_MSR, LOAD_PAT_MSR, SAVE_EFER_MSR, LOAD_EFER_MSR,
2325 SAVE_PREEMPT_TIMER, UNDEF_23_31));
2326/** @} */
2327
2328
2329/** @name VM-exit reason.
2330 * @{
2331 */
2332#define VMX_EXIT_REASON_BASIC(a) ((a) & 0xffff)
2333#define VMX_EXIT_REASON_HAS_ENTRY_FAILED(a) (((a) >> 31) & 1)
2334#define VMX_EXIT_REASON_ENTRY_FAILED RT_BIT(31)
2335
2336/** Bit fields for VM-exit reason. */
2337/** The exit reason. */
2338#define VMX_BF_EXIT_REASON_BASIC_SHIFT 0
2339#define VMX_BF_EXIT_REASON_BASIC_MASK UINT32_C(0x0000ffff)
2340/** Bits 16:26 are reseved and MBZ. */
2341#define VMX_BF_EXIT_REASON_RSVD_16_26_SHIFT 16
2342#define VMX_BF_EXIT_REASON_RSVD_16_26_MASK UINT32_C(0x07ff0000)
2343/** Whether the VM-exit was incident to enclave mode. */
2344#define VMX_BF_EXIT_REASON_ENCLAVE_MODE_SHIFT 27
2345#define VMX_BF_EXIT_REASON_ENCLAVE_MODE_MASK UINT32_C(0x08000000)
2346/** Pending MTF (Monitor Trap Flag) during VM-exit (only applicable in SMM mode). */
2347#define VMX_BF_EXIT_REASON_SMM_PENDING_MTF_SHIFT 28
2348#define VMX_BF_EXIT_REASON_SMM_PENDING_MTF_MASK UINT32_C(0x10000000)
2349/** VM-exit from VMX root operation (only possible with SMM). */
2350#define VMX_BF_EXIT_REASON_VMX_ROOT_MODE_SHIFT 29
2351#define VMX_BF_EXIT_REASON_VMX_ROOT_MODE_MASK UINT32_C(0x20000000)
2352/** Bit 30 is reserved and MBZ. */
2353#define VMX_BF_EXIT_REASON_RSVD_30_SHIFT 30
2354#define VMX_BF_EXIT_REASON_RSVD_30_MASK UINT32_C(0x40000000)
2355/** Whether VM-entry failed (currently only happens during loading guest-state
2356 * or MSRs or machine check exceptions). */
2357#define VMX_BF_EXIT_REASON_ENTRY_FAILED_SHIFT 31
2358#define VMX_BF_EXIT_REASON_ENTRY_FAILED_MASK UINT32_C(0x80000000)
2359RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_EXIT_REASON_, UINT32_C(0), UINT32_MAX,
2360 (BASIC, RSVD_16_26, ENCLAVE_MODE, SMM_PENDING_MTF, VMX_ROOT_MODE, RSVD_30, ENTRY_FAILED));
2361/** @} */
2362
2363
2364/** @name VM-entry interruption information.
2365 * @{
2366 */
2367#define VMX_ENTRY_INT_INFO_IS_VALID(a) (((a) >> 31) & 1)
2368#define VMX_ENTRY_INT_INFO_VECTOR(a) ((a) & 0xff)
2369#define VMX_ENTRY_INT_INFO_TYPE_SHIFT 8
2370#define VMX_ENTRY_INT_INFO_TYPE(a) (((a) >> 8) & 7)
2371#define VMX_ENTRY_INT_INFO_ERROR_CODE_VALID RT_BIT(11)
2372#define VMX_ENTRY_INT_INFO_IS_ERROR_CODE_VALID(a) (((a) >> 11) & 1)
2373#define VMX_ENTRY_INT_INFO_NMI_UNBLOCK_IRET 12
2374#define VMX_ENTRY_INT_INFO_IS_NMI_UNBLOCK_IRET(a) (((a) >> 12) & 1)
2375#define VMX_ENTRY_INT_INFO_VALID RT_BIT(31)
2376#define VMX_ENTRY_INT_INFO_IS_VALID(a) (((a) >> 31) & 1)
2377/** Construct an VM-entry interruption information field from a VM-exit interruption
2378 * info value (same except that bit 12 is reserved). */
2379#define VMX_ENTRY_INT_INFO_FROM_EXIT_INT_INFO(a) ((a) & ~RT_BIT(12))
2380/** Construct a VM-entry interruption information field from an IDT-vectoring
2381 * information field (same except that bit 12 is reserved). */
2382#define VMX_ENTRY_INT_INFO_FROM_EXIT_IDT_INFO(a) ((a) & ~RT_BIT(12))
2383
2384/** Bit fields for VM-entry interruption information. */
2385/** The VM-entry interruption vector. */
2386#define VMX_BF_ENTRY_INT_INFO_VECTOR_SHIFT 0
2387#define VMX_BF_ENTRY_INT_INFO_VECTOR_MASK UINT32_C(0x000000ff)
2388/** The VM-entry interruption type (see VMX_ENTRY_INT_INFO_TYPE_XXX). */
2389#define VMX_BF_ENTRY_INT_INFO_TYPE_SHIFT 8
2390#define VMX_BF_ENTRY_INT_INFO_TYPE_MASK UINT32_C(0x00000700)
2391/** Whether this event has an error code. */
2392#define VMX_BF_ENTRY_INT_INFO_ERR_CODE_VALID_SHIFT 11
2393#define VMX_BF_ENTRY_INT_INFO_ERR_CODE_VALID_MASK UINT32_C(0x00000800)
2394/** Bits 12:30 are reserved and MBZ. */
2395#define VMX_BF_ENTRY_INT_INFO_RSVD_12_30_SHIFT 12
2396#define VMX_BF_ENTRY_INT_INFO_RSVD_12_30_MASK UINT32_C(0x7ffff000)
2397/** Whether this VM-entry interruption info is valid. */
2398#define VMX_BF_ENTRY_INT_INFO_VALID_SHIFT 31
2399#define VMX_BF_ENTRY_INT_INFO_VALID_MASK UINT32_C(0x80000000)
2400RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_ENTRY_INT_INFO_, UINT32_C(0), UINT32_MAX,
2401 (VECTOR, TYPE, ERR_CODE_VALID, RSVD_12_30, VALID));
2402/** @} */
2403
2404/** @name VM-entry exception error code.
2405 * @{ */
2406/** Error code valid mask. */
2407/** @todo r=ramshankar: Intel spec. 26.2.1.3 "VM-Entry Control Fields" states that
2408 * bits 31:15 MBZ. However, Intel spec. 6.13 "Error Code" states "To keep the
2409 * stack aligned for doubleword pushes, the upper half of the error code is
2410 * reserved" which implies bits 31:16 MBZ (and not 31:15) which is what we
2411 * use below. */
2412#define VMX_ENTRY_INT_XCPT_ERR_CODE_VALID_MASK UINT32_C(0xffff)
2413/** @} */
2414
2415/** @name VM-entry interruption information types.
2416 * @{
2417 */
2418#define VMX_ENTRY_INT_INFO_TYPE_EXT_INT 0
2419#define VMX_ENTRY_INT_INFO_TYPE_RSVD 1
2420#define VMX_ENTRY_INT_INFO_TYPE_NMI 2
2421#define VMX_ENTRY_INT_INFO_TYPE_HW_XCPT 3
2422#define VMX_ENTRY_INT_INFO_TYPE_SW_INT 4
2423#define VMX_ENTRY_INT_INFO_TYPE_PRIV_SW_XCPT 5
2424#define VMX_ENTRY_INT_INFO_TYPE_SW_XCPT 6
2425#define VMX_ENTRY_INT_INFO_TYPE_OTHER_EVENT 7
2426/** @} */
2427
2428
2429/** @name VM-entry interruption information vector types for
2430 * VMX_ENTRY_INT_INFO_TYPE_OTHER_EVENT.
2431 * @{ */
2432#define VMX_ENTRY_INT_INFO_VECTOR_MTF 0
2433/** @} */
2434
2435
2436/** @name VM-exit interruption information.
2437 * @{
2438 */
2439#define VMX_EXIT_INT_INFO_VECTOR(a) ((a) & 0xff)
2440#define VMX_EXIT_INT_INFO_TYPE_SHIFT 8
2441#define VMX_EXIT_INT_INFO_TYPE(a) (((a) >> 8) & 7)
2442#define VMX_EXIT_INT_INFO_ERROR_CODE_VALID RT_BIT(11)
2443#define VMX_EXIT_INT_INFO_IS_ERROR_CODE_VALID(a) (((a) >> 11) & 1)
2444#define VMX_EXIT_INT_INFO_NMI_UNBLOCK_IRET 12
2445#define VMX_EXIT_INT_INFO_IS_NMI_UNBLOCK_IRET(a) (((a) >> 12) & 1)
2446#define VMX_EXIT_INT_INFO_VALID RT_BIT(31)
2447#define VMX_EXIT_INT_INFO_IS_VALID(a) (((a) >> 31) & 1)
2448
2449/** Bit fields for VM-exit interruption infomration. */
2450/** The VM-exit interruption vector. */
2451#define VMX_BF_EXIT_INT_INFO_VECTOR_SHIFT 0
2452#define VMX_BF_EXIT_INT_INFO_VECTOR_MASK UINT32_C(0x000000ff)
2453/** The VM-exit interruption type (see VMX_EXIT_INT_INFO_TYPE_XXX). */
2454#define VMX_BF_EXIT_INT_INFO_TYPE_SHIFT 8
2455#define VMX_BF_EXIT_INT_INFO_TYPE_MASK UINT32_C(0x00000700)
2456/** Whether this event has an error code. */
2457#define VMX_BF_EXIT_INT_INFO_ERR_CODE_VALID_SHIFT 11
2458#define VMX_BF_EXIT_INT_INFO_ERR_CODE_VALID_MASK UINT32_C(0x00000800)
2459/** Whether NMI-unblocking due to IRET is active. */
2460#define VMX_BF_EXIT_INT_INFO_NMI_UNBLOCK_IRET_SHIFT 12
2461#define VMX_BF_EXIT_INT_INFO_NMI_UNBLOCK_IRET_MASK UINT32_C(0x00001000)
2462/** Bits 13:30 is reserved (MBZ). */
2463#define VMX_BF_EXIT_INT_INFO_RSVD_13_30_SHIFT 13
2464#define VMX_BF_EXIT_INT_INFO_RSVD_13_30_MASK UINT32_C(0x7fffe000)
2465/** Whether this VM-exit interruption info is valid. */
2466#define VMX_BF_EXIT_INT_INFO_VALID_SHIFT 31
2467#define VMX_BF_EXIT_INT_INFO_VALID_MASK UINT32_C(0x80000000)
2468RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_EXIT_INT_INFO_, UINT32_C(0), UINT32_MAX,
2469 (VECTOR, TYPE, ERR_CODE_VALID, NMI_UNBLOCK_IRET, RSVD_13_30, VALID));
2470/** @} */
2471
2472
2473/** @name VM-exit interruption information types.
2474 * @{
2475 */
2476#define VMX_EXIT_INT_INFO_TYPE_EXT_INT 0
2477#define VMX_EXIT_INT_INFO_TYPE_NMI 2
2478#define VMX_EXIT_INT_INFO_TYPE_HW_XCPT 3
2479#define VMX_EXIT_INT_INFO_TYPE_SW_INT 4
2480#define VMX_EXIT_INT_INFO_TYPE_PRIV_SW_XCPT 5
2481#define VMX_EXIT_INT_INFO_TYPE_SW_XCPT 6
2482#define VMX_EXIT_INT_INFO_TYPE_UNUSED 7
2483/** @} */
2484
2485
2486/** @name VM-exit instruction identity.
2487 *
2488 * These are found in VM-exit instruction information fields for certain
2489 * instructions.
2490 * @{ */
2491typedef uint32_t VMXINSTRID;
2492/** Whether the instruction ID field is valid. */
2493#define VMXINSTRID_VALID RT_BIT_32(31)
2494/** Whether the instruction's primary operand in the Mod R/M byte (bits 0:3) is a
2495 * read or write. */
2496#define VMXINSTRID_MODRM_PRIMARY_OP_W RT_BIT_32(30)
2497/** Gets whether the instruction ID is valid or not. */
2498#define VMXINSTRID_IS_VALID(a) (((a) >> 31) & 1)
2499#define VMXINSTRID_IS_MODRM_PRIMARY_OP_W(a) (((a) >> 30) & 1)
2500/** Gets the instruction ID. */
2501#define VMXINSTRID_GET_ID(a) ((a) & ~(VMXINSTRID_VALID | VMXINSTRID_MODRM_PRIMARY_OP_W))
2502/** No instruction ID info. */
2503#define VMXINSTRID_NONE 0
2504
2505/** The OR'd rvalues are from the VT-x spec (valid bit is VBox specific): */
2506#define VMXINSTRID_SGDT (0x0 | VMXINSTRID_VALID | VMXINSTRID_MODRM_PRIMARY_OP_W)
2507#define VMXINSTRID_SIDT (0x1 | VMXINSTRID_VALID | VMXINSTRID_MODRM_PRIMARY_OP_W)
2508#define VMXINSTRID_LGDT (0x2 | VMXINSTRID_VALID)
2509#define VMXINSTRID_LIDT (0x3 | VMXINSTRID_VALID)
2510
2511#define VMXINSTRID_SLDT (0x0 | VMXINSTRID_VALID | VMXINSTRID_MODRM_PRIMARY_OP_W)
2512#define VMXINSTRID_STR (0x1 | VMXINSTRID_VALID | VMXINSTRID_MODRM_PRIMARY_OP_W)
2513#define VMXINSTRID_LLDT (0x2 | VMXINSTRID_VALID)
2514#define VMXINSTRID_LTR (0x3 | VMXINSTRID_VALID)
2515
2516/** The following IDs are used internally (some for logging, others for conveying
2517 * the ModR/M primary operand write bit): */
2518#define VMXINSTRID_VMLAUNCH (0x10 | VMXINSTRID_VALID)
2519#define VMXINSTRID_VMRESUME (0x11 | VMXINSTRID_VALID)
2520#define VMXINSTRID_VMREAD (0x12 | VMXINSTRID_VALID)
2521#define VMXINSTRID_VMWRITE (0x13 | VMXINSTRID_VALID | VMXINSTRID_MODRM_PRIMARY_OP_W)
2522#define VMXINSTRID_IO_IN (0x14 | VMXINSTRID_VALID)
2523#define VMXINSTRID_IO_INS (0x15 | VMXINSTRID_VALID)
2524#define VMXINSTRID_IO_OUT (0x16 | VMXINSTRID_VALID)
2525#define VMXINSTRID_IO_OUTS (0x17 | VMXINSTRID_VALID)
2526#define VMXINSTRID_MOV_TO_DRX (0x18 | VMXINSTRID_VALID)
2527#define VMXINSTRID_MOV_FROM_DRX (0x19 | VMXINSTRID_VALID)
2528/** @} */
2529
2530
2531/** @name IDT-vectoring information.
2532 * @{
2533 */
2534#define VMX_IDT_VECTORING_INFO_VECTOR(a) ((a) & 0xff)
2535#define VMX_IDT_VECTORING_INFO_TYPE(a) (((a) >> 8) & 7)
2536#define VMX_IDT_VECTORING_INFO_IS_ERROR_CODE_VALID(a) (((a) >> 11) & 1)
2537#define VMX_IDT_VECTORING_INFO_IS_VALID(a) (((a) >> 31) & 1)
2538
2539/** Construct an IDT-vectoring information field from an VM-entry interruption
2540 * information field (same except that bit 12 is reserved). */
2541#define VMX_EXIT_IDT_INFO_FROM_ENTRY_INT_INFO(a) ((a) & ~RT_BIT(12))
2542
2543/** Bit fields for IDT-vectoring information. */
2544/** The IDT-vectoring info vector. */
2545#define VMX_BF_IDT_VECTORING_INFO_VECTOR_SHIFT 0
2546#define VMX_BF_IDT_VECTORING_INFO_VECTOR_MASK UINT32_C(0x000000ff)
2547/** The IDT-vectoring info type (see VMX_IDT_VECTORING_INFO_TYPE_XXX). */
2548#define VMX_BF_IDT_VECTORING_INFO_TYPE_SHIFT 8
2549#define VMX_BF_IDT_VECTORING_INFO_TYPE_MASK UINT32_C(0x00000700)
2550/** Whether the event has an error code. */
2551#define VMX_BF_IDT_VECTORING_INFO_ERR_CODE_VALID_SHIFT 11
2552#define VMX_BF_IDT_VECTORING_INFO_ERR_CODE_VALID_MASK UINT32_C(0x00000800)
2553/** Bit 12 is undefined. */
2554#define VMX_BF_IDT_VECTORING_INFO_UNDEF_12_SHIFT 12
2555#define VMX_BF_IDT_VECTORING_INFO_UNDEF_12_MASK UINT32_C(0x00001000)
2556/** Bits 13:30 is reserved (MBZ). */
2557#define VMX_BF_IDT_VECTORING_INFO_RSVD_13_30_SHIFT 13
2558#define VMX_BF_IDT_VECTORING_INFO_RSVD_13_30_MASK UINT32_C(0x7fffe000)
2559/** Whether this IDT-vectoring info is valid. */
2560#define VMX_BF_IDT_VECTORING_INFO_VALID_SHIFT 31
2561#define VMX_BF_IDT_VECTORING_INFO_VALID_MASK UINT32_C(0x80000000)
2562RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_IDT_VECTORING_INFO_, UINT32_C(0), UINT32_MAX,
2563 (VECTOR, TYPE, ERR_CODE_VALID, UNDEF_12, RSVD_13_30, VALID));
2564/** @} */
2565
2566
2567/** @name IDT-vectoring information vector types.
2568 * @{
2569 */
2570#define VMX_IDT_VECTORING_INFO_TYPE_EXT_INT 0
2571#define VMX_IDT_VECTORING_INFO_TYPE_NMI 2
2572#define VMX_IDT_VECTORING_INFO_TYPE_HW_XCPT 3
2573#define VMX_IDT_VECTORING_INFO_TYPE_SW_INT 4
2574#define VMX_IDT_VECTORING_INFO_TYPE_PRIV_SW_XCPT 5
2575#define VMX_IDT_VECTORING_INFO_TYPE_SW_XCPT 6
2576#define VMX_IDT_VECTORING_INFO_TYPE_UNUSED 7
2577/** @} */
2578
2579
2580/** @name TPR threshold.
2581 * @{ */
2582/** Mask of the TPR threshold field (bits 31:4 MBZ). */
2583#define VMX_TPR_THRESHOLD_MASK UINT32_C(0xf)
2584
2585/** Bit fields for TPR threshold. */
2586#define VMX_BF_TPR_THRESHOLD_TPR_SHIFT 0
2587#define VMX_BF_TPR_THRESHOLD_TPR_MASK UINT32_C(0x0000000f)
2588#define VMX_BF_TPR_THRESHOLD_RSVD_4_31_SHIFT 4
2589#define VMX_BF_TPR_THRESHOLD_RSVD_4_31_MASK UINT32_C(0xfffffff0)
2590RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_TPR_THRESHOLD_, UINT32_C(0), UINT32_MAX,
2591 (TPR, RSVD_4_31));
2592/** @} */
2593
2594
2595/** @name Guest-activity states.
2596 * @{
2597 */
2598/** The logical processor is active. */
2599#define VMX_VMCS_GUEST_ACTIVITY_ACTIVE 0x0
2600/** The logical processor is inactive, because it executed a HLT instruction. */
2601#define VMX_VMCS_GUEST_ACTIVITY_HLT 0x1
2602/** The logical processor is inactive, because of a triple fault or other serious error. */
2603#define VMX_VMCS_GUEST_ACTIVITY_SHUTDOWN 0x2
2604/** The logical processor is inactive, because it's waiting for a startup-IPI */
2605#define VMX_VMCS_GUEST_ACTIVITY_SIPI_WAIT 0x3
2606/** @} */
2607
2608
2609/** @name Guest-interruptibility states.
2610 * @{
2611 */
2612#define VMX_VMCS_GUEST_INT_STATE_BLOCK_STI RT_BIT(0)
2613#define VMX_VMCS_GUEST_INT_STATE_BLOCK_MOVSS RT_BIT(1)
2614#define VMX_VMCS_GUEST_INT_STATE_BLOCK_SMI RT_BIT(2)
2615#define VMX_VMCS_GUEST_INT_STATE_BLOCK_NMI RT_BIT(3)
2616#define VMX_VMCS_GUEST_INT_STATE_ENCLAVE RT_BIT(4)
2617
2618/** Mask of the guest-interruptibility state field (bits 31:5 MBZ). */
2619#define VMX_VMCS_GUEST_INT_STATE_MASK UINT32_C(0x1f)
2620/** @} */
2621
2622
2623/** @name Exit qualification for debug exceptions.
2624 * @{
2625 */
2626/** Hardware breakpoint 0 was met. */
2627#define VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BP0 RT_BIT_64(0)
2628/** Hardware breakpoint 1 was met. */
2629#define VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BP1 RT_BIT_64(1)
2630/** Hardware breakpoint 2 was met. */
2631#define VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BP2 RT_BIT_64(2)
2632/** Hardware breakpoint 3 was met. */
2633#define VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BP3 RT_BIT_64(3)
2634/** Debug register access detected. */
2635#define VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BD RT_BIT_64(13)
2636/** A debug exception would have been triggered by single-step execution mode. */
2637#define VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BS RT_BIT_64(14)
2638/** Mask of all valid bits. */
2639#define VMX_VMCS_EXIT_QUAL_VALID_MASK ( VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BP0 \
2640 | VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BP1 \
2641 | VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BP2 \
2642 | VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BP3 \
2643 | VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BD \
2644 | VMX_VMCS_EXIT_QUAL_DEBUG_XCPT_BS)
2645
2646/** Bit fields for Exit qualifications due to debug exceptions. */
2647#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BP0_SHIFT 0
2648#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BP0_MASK UINT64_C(0x0000000000000001)
2649#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BP1_SHIFT 1
2650#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BP1_MASK UINT64_C(0x0000000000000002)
2651#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BP2_SHIFT 2
2652#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BP2_MASK UINT64_C(0x0000000000000004)
2653#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BP3_SHIFT 3
2654#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BP3_MASK UINT64_C(0x0000000000000008)
2655#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_RSVD_4_12_SHIFT 4
2656#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_RSVD_4_12_MASK UINT64_C(0x0000000000001ff0)
2657#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BD_SHIFT 13
2658#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BD_MASK UINT64_C(0x0000000000002000)
2659#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BS_SHIFT 14
2660#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_BS_MASK UINT64_C(0x0000000000004000)
2661#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_RSVD_15_63_SHIFT 15
2662#define VMX_BF_EXIT_QUAL_DEBUG_XCPT_RSVD_15_63_MASK UINT64_C(0xffffffffffff8000)
2663RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_EXIT_QUAL_DEBUG_XCPT_, UINT64_C(0), UINT64_MAX,
2664 (BP0, BP1, BP2, BP3, RSVD_4_12, BD, BS, RSVD_15_63));
2665/** @} */
2666
2667/** @name Exit qualification for Mov DRx.
2668 * @{
2669 */
2670/** 0-2: Debug register number */
2671#define VMX_EXIT_QUAL_DRX_REGISTER(a) ((a) & 7)
2672/** 3: Reserved; cleared to 0. */
2673#define VMX_EXIT_QUAL_DRX_RES1(a) (((a) >> 3) & 1)
2674/** 4: Direction of move (0 = write, 1 = read) */
2675#define VMX_EXIT_QUAL_DRX_DIRECTION(a) (((a) >> 4) & 1)
2676/** 5-7: Reserved; cleared to 0. */
2677#define VMX_EXIT_QUAL_DRX_RES2(a) (((a) >> 5) & 7)
2678/** 8-11: General purpose register number. */
2679#define VMX_EXIT_QUAL_DRX_GENREG(a) (((a) >> 8) & 0xf)
2680
2681/** Bit fields for Exit qualification due to Mov DRx. */
2682#define VMX_BF_EXIT_QUAL_DRX_REGISTER_SHIFT 0
2683#define VMX_BF_EXIT_QUAL_DRX_REGISTER_MASK UINT64_C(0x0000000000000007)
2684#define VMX_BF_EXIT_QUAL_DRX_RSVD_1_SHIFT 3
2685#define VMX_BF_EXIT_QUAL_DRX_RSVD_1_MASK UINT64_C(0x0000000000000008)
2686#define VMX_BF_EXIT_QUAL_DRX_DIRECTION_SHIFT 4
2687#define VMX_BF_EXIT_QUAL_DRX_DIRECTION_MASK UINT64_C(0x0000000000000010)
2688#define VMX_BF_EXIT_QUAL_DRX_RSVD_5_7_SHIFT 5
2689#define VMX_BF_EXIT_QUAL_DRX_RSVD_5_7_MASK UINT64_C(0x00000000000000e0)
2690#define VMX_BF_EXIT_QUAL_DRX_GENREG_SHIFT 8
2691#define VMX_BF_EXIT_QUAL_DRX_GENREG_MASK UINT64_C(0x0000000000000f00)
2692#define VMX_BF_EXIT_QUAL_DRX_RSVD_12_63_SHIFT 12
2693#define VMX_BF_EXIT_QUAL_DRX_RSVD_12_63_MASK UINT64_C(0xfffffffffffff000)
2694RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_EXIT_QUAL_DRX_, UINT64_C(0), UINT64_MAX,
2695 (REGISTER, RSVD_1, DIRECTION, RSVD_5_7, GENREG, RSVD_12_63));
2696/** @} */
2697
2698
2699/** @name Exit qualification for debug exceptions types.
2700 * @{
2701 */
2702#define VMX_EXIT_QUAL_DRX_DIRECTION_WRITE 0
2703#define VMX_EXIT_QUAL_DRX_DIRECTION_READ 1
2704/** @} */
2705
2706
2707/** @name Exit qualification for control-register accesses.
2708 * @{
2709 */
2710/** 0-3: Control register number (0 for CLTS & LMSW) */
2711#define VMX_EXIT_QUAL_CRX_REGISTER(a) ((a) & 0xf)
2712/** 4-5: Access type. */
2713#define VMX_EXIT_QUAL_CRX_ACCESS(a) (((a) >> 4) & 3)
2714/** 6: LMSW operand type */
2715#define VMX_EXIT_QUAL_CRX_LMSW_OP(a) (((a) >> 6) & 1)
2716/** 7: Reserved; cleared to 0. */
2717#define VMX_EXIT_QUAL_CRX_RES1(a) (((a) >> 7) & 1)
2718/** 8-11: General purpose register number (0 for CLTS & LMSW). */
2719#define VMX_EXIT_QUAL_CRX_GENREG(a) (((a) >> 8) & 0xf)
2720/** 12-15: Reserved; cleared to 0. */
2721#define VMX_EXIT_QUAL_CRX_RES2(a) (((a) >> 12) & 0xf)
2722/** 16-31: LMSW source data (else 0). */
2723#define VMX_EXIT_QUAL_CRX_LMSW_DATA(a) (((a) >> 16) & 0xffff)
2724
2725/** Bit fields for Exit qualification for control-register accesses. */
2726#define VMX_BF_EXIT_QUAL_CRX_REGISTER_SHIFT 0
2727#define VMX_BF_EXIT_QUAL_CRX_REGISTER_MASK UINT64_C(0x000000000000000f)
2728#define VMX_BF_EXIT_QUAL_CRX_ACCESS_SHIFT 4
2729#define VMX_BF_EXIT_QUAL_CRX_ACCESS_MASK UINT64_C(0x0000000000000030)
2730#define VMX_BF_EXIT_QUAL_CRX_LMSW_OP_SHIFT 6
2731#define VMX_BF_EXIT_QUAL_CRX_LMSW_OP_MASK UINT64_C(0x0000000000000040)
2732#define VMX_BF_EXIT_QUAL_CRX_RSVD_7_SHIFT 7
2733#define VMX_BF_EXIT_QUAL_CRX_RSVD_7_MASK UINT64_C(0x0000000000000080)
2734#define VMX_BF_EXIT_QUAL_CRX_GENREG_SHIFT 8
2735#define VMX_BF_EXIT_QUAL_CRX_GENREG_MASK UINT64_C(0x0000000000000f00)
2736#define VMX_BF_EXIT_QUAL_CRX_RSVD_12_15_SHIFT 12
2737#define VMX_BF_EXIT_QUAL_CRX_RSVD_12_15_MASK UINT64_C(0x000000000000f000)
2738#define VMX_BF_EXIT_QUAL_CRX_LMSW_DATA_SHIFT 16
2739#define VMX_BF_EXIT_QUAL_CRX_LMSW_DATA_MASK UINT64_C(0x00000000ffff0000)
2740#define VMX_BF_EXIT_QUAL_CRX_RSVD_32_63_SHIFT 32
2741#define VMX_BF_EXIT_QUAL_CRX_RSVD_32_63_MASK UINT64_C(0xffffffff00000000)
2742RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_EXIT_QUAL_CRX_, UINT64_C(0), UINT64_MAX,
2743 (REGISTER, ACCESS, LMSW_OP, RSVD_7, GENREG, RSVD_12_15, LMSW_DATA, RSVD_32_63));
2744/** @} */
2745
2746
2747/** @name Exit qualification for control-register access types.
2748 * @{
2749 */
2750#define VMX_EXIT_QUAL_CRX_ACCESS_WRITE 0
2751#define VMX_EXIT_QUAL_CRX_ACCESS_READ 1
2752#define VMX_EXIT_QUAL_CRX_ACCESS_CLTS 2
2753#define VMX_EXIT_QUAL_CRX_ACCESS_LMSW 3
2754/** @} */
2755
2756
2757/** @name Exit qualification for task switch.
2758 * @{
2759 */
2760#define VMX_EXIT_QUAL_TASK_SWITCH_SELECTOR(a) ((a) & 0xffff)
2761#define VMX_EXIT_QUAL_TASK_SWITCH_TYPE(a) (((a) >> 30) & 0x3)
2762/** Task switch caused by a call instruction. */
2763#define VMX_EXIT_QUAL_TASK_SWITCH_TYPE_CALL 0
2764/** Task switch caused by an iret instruction. */
2765#define VMX_EXIT_QUAL_TASK_SWITCH_TYPE_IRET 1
2766/** Task switch caused by a jmp instruction. */
2767#define VMX_EXIT_QUAL_TASK_SWITCH_TYPE_JMP 2
2768/** Task switch caused by an interrupt gate. */
2769#define VMX_EXIT_QUAL_TASK_SWITCH_TYPE_IDT 3
2770
2771/** Bit fields for Exit qualification for task switches. */
2772#define VMX_BF_EXIT_QUAL_TASK_SWITCH_NEW_TSS_SHIFT 0
2773#define VMX_BF_EXIT_QUAL_TASK_SWITCH_NEW_TSS_MASK UINT64_C(0x000000000000ffff)
2774#define VMX_BF_EXIT_QUAL_TASK_SWITCH_RSVD_16_29_SHIFT 16
2775#define VMX_BF_EXIT_QUAL_TASK_SWITCH_RSVD_16_29_MASK UINT64_C(0x000000003fff0000)
2776#define VMX_BF_EXIT_QUAL_TASK_SWITCH_SOURCE_SHIFT 30
2777#define VMX_BF_EXIT_QUAL_TASK_SWITCH_SOURCE_MASK UINT64_C(0x00000000c0000000)
2778#define VMX_BF_EXIT_QUAL_TASK_SWITCH_RSVD_32_63_SHIFT 32
2779#define VMX_BF_EXIT_QUAL_TASK_SWITCH_RSVD_32_63_MASK UINT64_C(0xffffffff00000000)
2780RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_EXIT_QUAL_TASK_SWITCH_, UINT64_C(0), UINT64_MAX,
2781 (NEW_TSS, RSVD_16_29, SOURCE, RSVD_32_63));
2782/** @} */
2783
2784
2785/** @name Exit qualification for EPT violations.
2786 * @{
2787 */
2788/** Set if the violation was caused by a data read. */
2789#define VMX_EXIT_QUAL_EPT_DATA_READ RT_BIT(0)
2790/** Set if the violation was caused by a data write. */
2791#define VMX_EXIT_QUAL_EPT_DATA_WRITE RT_BIT(1)
2792/** Set if the violation was caused by an instruction fetch. */
2793#define VMX_EXIT_QUAL_EPT_INSTR_FETCH RT_BIT(2)
2794/** AND of the present bit of all EPT structures. */
2795#define VMX_EXIT_QUAL_EPT_ENTRY_PRESENT RT_BIT(3)
2796/** AND of the write bit of all EPT structures. */
2797#define VMX_EXIT_QUAL_EPT_ENTRY_WRITE RT_BIT(4)
2798/** AND of the execute bit of all EPT structures. */
2799#define VMX_EXIT_QUAL_EPT_ENTRY_EXECUTE RT_BIT(5)
2800/** Set if the guest linear address field contains the faulting address. */
2801#define VMX_EXIT_QUAL_EPT_GUEST_ADDR_VALID RT_BIT(7)
2802/** If bit 7 is one: (reserved otherwise)
2803 * 1 - violation due to physical address access.
2804 * 0 - violation caused by page walk or access/dirty bit updates
2805 */
2806#define VMX_EXIT_QUAL_EPT_TRANSLATED_ACCESS RT_BIT(8)
2807/** @} */
2808
2809
2810/** @name Exit qualification for I/O instructions.
2811 * @{
2812 */
2813/** 0-2: IO operation width. */
2814#define VMX_EXIT_QUAL_IO_WIDTH(a) ((a) & 7)
2815/** 3: IO operation direction. */
2816#define VMX_EXIT_QUAL_IO_DIRECTION(a) (((a) >> 3) & 1)
2817/** 4: String IO operation (INS / OUTS). */
2818#define VMX_EXIT_QUAL_IO_IS_STRING(a) (((a) >> 4) & 1)
2819/** 5: Repeated IO operation. */
2820#define VMX_EXIT_QUAL_IO_IS_REP(a) (((a) >> 5) & 1)
2821/** 6: Operand encoding. */
2822#define VMX_EXIT_QUAL_IO_ENCODING(a) (((a) >> 6) & 1)
2823/** 16-31: IO Port (0-0xffff). */
2824#define VMX_EXIT_QUAL_IO_PORT(a) (((a) >> 16) & 0xffff)
2825
2826/** Bit fields for Exit qualification for I/O instructions. */
2827#define VMX_BF_EXIT_QUAL_IO_WIDTH_SHIFT 0
2828#define VMX_BF_EXIT_QUAL_IO_WIDTH_MASK UINT64_C(0x0000000000000007)
2829#define VMX_BF_EXIT_QUAL_IO_DIRECTION_SHIFT 3
2830#define VMX_BF_EXIT_QUAL_IO_DIRECTION_MASK UINT64_C(0x0000000000000008)
2831#define VMX_BF_EXIT_QUAL_IO_IS_STRING_SHIFT 4
2832#define VMX_BF_EXIT_QUAL_IO_IS_STRING_MASK UINT64_C(0x0000000000000010)
2833#define VMX_BF_EXIT_QUAL_IO_IS_REP_SHIFT 5
2834#define VMX_BF_EXIT_QUAL_IO_IS_REP_MASK UINT64_C(0x0000000000000020)
2835#define VMX_BF_EXIT_QUAL_IO_ENCODING_SHIFT 6
2836#define VMX_BF_EXIT_QUAL_IO_ENCODING_MASK UINT64_C(0x0000000000000040)
2837#define VMX_BF_EXIT_QUAL_IO_RSVD_7_15_SHIFT 7
2838#define VMX_BF_EXIT_QUAL_IO_RSVD_7_15_MASK UINT64_C(0x000000000000ff80)
2839#define VMX_BF_EXIT_QUAL_IO_PORT_SHIFT 16
2840#define VMX_BF_EXIT_QUAL_IO_PORT_MASK UINT64_C(0x00000000ffff0000)
2841#define VMX_BF_EXIT_QUAL_IO_RSVD_32_63_SHIFT 32
2842#define VMX_BF_EXIT_QUAL_IO_RSVD_32_63_MASK UINT64_C(0xffffffff00000000)
2843RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_EXIT_QUAL_IO_, UINT64_C(0), UINT64_MAX,
2844 (WIDTH, DIRECTION, IS_STRING, IS_REP, ENCODING, RSVD_7_15, PORT, RSVD_32_63));
2845/** @} */
2846
2847
2848/** @name Exit qualification for I/O instruction types.
2849 * @{
2850 */
2851#define VMX_EXIT_QUAL_IO_DIRECTION_OUT 0
2852#define VMX_EXIT_QUAL_IO_DIRECTION_IN 1
2853/** @} */
2854
2855
2856/** @name Exit qualification for I/O instruction encoding.
2857 * @{
2858 */
2859#define VMX_EXIT_QUAL_IO_ENCODING_DX 0
2860#define VMX_EXIT_QUAL_IO_ENCODING_IMM 1
2861/** @} */
2862
2863
2864/** @name Exit qualification for APIC-access VM-exits from linear and
2865 * guest-physical accesses.
2866 * @{
2867 */
2868/** 0-11: If the APIC-access VM-exit is due to a linear access, the offset of
2869 * access within the APIC page. */
2870#define VMX_EXIT_QUAL_APIC_ACCESS_OFFSET(a) ((a) & 0xfff)
2871/** 12-15: Access type. */
2872#define VMX_EXIT_QUAL_APIC_ACCESS_TYPE(a) (((a) & 0xf000) >> 12)
2873/* Rest reserved. */
2874
2875/** Bit fields for Exit qualification for APIC-access VM-exits. */
2876#define VMX_BF_EXIT_QUAL_APIC_ACCESS_OFFSET_SHIFT 0
2877#define VMX_BF_EXIT_QUAL_APIC_ACCESS_OFFSET_MASK UINT64_C(0x0000000000000fff)
2878#define VMX_BF_EXIT_QUAL_APIC_ACCESS_TYPE_SHIFT 12
2879#define VMX_BF_EXIT_QUAL_APIC_ACCESS_TYPE_MASK UINT64_C(0x000000000000f000)
2880#define VMX_BF_EXIT_QUAL_APIC_ACCESS_RSVD_16_63_SHIFT 16
2881#define VMX_BF_EXIT_QUAL_APIC_ACCESS_RSVD_16_63_MASK UINT64_C(0xffffffffffff0000)
2882RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_EXIT_QUAL_APIC_ACCESS_, UINT64_C(0), UINT64_MAX,
2883 (OFFSET, TYPE, RSVD_16_63));
2884/** @} */
2885
2886
2887/** @name Exit qualification for linear address APIC-access types.
2888 * @{
2889 */
2890/** Linear access for a data read during instruction execution. */
2891#define VMX_APIC_ACCESS_TYPE_LINEAR_READ 0
2892/** Linear access for a data write during instruction execution. */
2893#define VMX_APIC_ACCESS_TYPE_LINEAR_WRITE 1
2894/** Linear access for an instruction fetch. */
2895#define VMX_APIC_ACCESS_TYPE_LINEAR_INSTR_FETCH 2
2896/** Linear read/write access during event delivery. */
2897#define VMX_APIC_ACCESS_TYPE_LINEAR_EVENT_DELIVERY 3
2898/** Physical read/write access during event delivery. */
2899#define VMX_APIC_ACCESS_TYPE_PHYSICAL_EVENT_DELIVERY 10
2900/** Physical access for an instruction fetch or during instruction execution. */
2901#define VMX_APIC_ACCESS_TYPE_PHYSICAL_INSTR 15
2902
2903/**
2904 * APIC-access type.
2905 */
2906typedef enum
2907{
2908 VMXAPICACCESS_LINEAR_READ = VMX_APIC_ACCESS_TYPE_LINEAR_READ,
2909 VMXAPICACCESS_LINEAR_WRITE = VMX_APIC_ACCESS_TYPE_LINEAR_WRITE,
2910 VMXAPICACCESS_LINEAR_INSTR_FETCH = VMX_APIC_ACCESS_TYPE_LINEAR_INSTR_FETCH,
2911 VMXAPICACCESS_LINEAR_EVENT_DELIVERY = VMX_APIC_ACCESS_TYPE_LINEAR_EVENT_DELIVERY,
2912 VMXAPICACCESS_PHYSICAL_EVENT_DELIVERY = VMX_APIC_ACCESS_TYPE_PHYSICAL_EVENT_DELIVERY,
2913 VMXAPICACCESS_PHYSICAL_INSTR = VMX_APIC_ACCESS_TYPE_PHYSICAL_INSTR
2914} VMXAPICACCESS;
2915AssertCompileSize(VMXAPICACCESS, 4);
2916/** @} */
2917
2918
2919/** @name VMX_BF_XXTR_INSINFO_XXX - VMX_EXIT_XDTR_ACCESS instruction information.
2920 * Found in VMX_VMCS32_RO_EXIT_INSTR_INFO.
2921 * @{
2922 */
2923/** Address calculation scaling field (powers of two). */
2924#define VMX_BF_XDTR_INSINFO_SCALE_SHIFT 0
2925#define VMX_BF_XDTR_INSINFO_SCALE_MASK UINT32_C(0x00000003)
2926/** Bits 2 thru 6 are undefined. */
2927#define VMX_BF_XDTR_INSINFO_UNDEF_2_6_SHIFT 2
2928#define VMX_BF_XDTR_INSINFO_UNDEF_2_6_MASK UINT32_C(0x0000007c)
2929/** Address size, only 0(=16), 1(=32) and 2(=64) are defined.
2930 * @remarks anyone's guess why this is a 3 bit field... */
2931#define VMX_BF_XDTR_INSINFO_ADDR_SIZE_SHIFT 7
2932#define VMX_BF_XDTR_INSINFO_ADDR_SIZE_MASK UINT32_C(0x00000380)
2933/** Bit 10 is defined as zero. */
2934#define VMX_BF_XDTR_INSINFO_ZERO_10_SHIFT 10
2935#define VMX_BF_XDTR_INSINFO_ZERO_10_MASK UINT32_C(0x00000400)
2936/** Operand size, either (1=)32-bit or (0=)16-bit, but get this, it's undefined
2937 * for exits from 64-bit code as the operand size there is fixed. */
2938#define VMX_BF_XDTR_INSINFO_OP_SIZE_SHIFT 11
2939#define VMX_BF_XDTR_INSINFO_OP_SIZE_MASK UINT32_C(0x00000800)
2940/** Bits 12 thru 14 are undefined. */
2941#define VMX_BF_XDTR_INSINFO_UNDEF_12_14_SHIFT 12
2942#define VMX_BF_XDTR_INSINFO_UNDEF_12_14_MASK UINT32_C(0x00007000)
2943/** Applicable segment register (X86_SREG_XXX values). */
2944#define VMX_BF_XDTR_INSINFO_SREG_SHIFT 15
2945#define VMX_BF_XDTR_INSINFO_SREG_MASK UINT32_C(0x00038000)
2946/** Index register (X86_GREG_XXX values). Undefined if HAS_INDEX_REG is clear. */
2947#define VMX_BF_XDTR_INSINFO_INDEX_REG_SHIFT 18
2948#define VMX_BF_XDTR_INSINFO_INDEX_REG_MASK UINT32_C(0x003c0000)
2949/** Is VMX_BF_XDTR_INSINFO_INDEX_REG_XXX valid (=1) or not (=0). */
2950#define VMX_BF_XDTR_INSINFO_HAS_INDEX_REG_SHIFT 22
2951#define VMX_BF_XDTR_INSINFO_HAS_INDEX_REG_MASK UINT32_C(0x00400000)
2952/** Base register (X86_GREG_XXX values). Undefined if HAS_BASE_REG is clear. */
2953#define VMX_BF_XDTR_INSINFO_BASE_REG_SHIFT 23
2954#define VMX_BF_XDTR_INSINFO_BASE_REG_MASK UINT32_C(0x07800000)
2955/** Is VMX_XDTR_INSINFO_BASE_REG_XXX valid (=1) or not (=0). */
2956#define VMX_BF_XDTR_INSINFO_HAS_BASE_REG_SHIFT 27
2957#define VMX_BF_XDTR_INSINFO_HAS_BASE_REG_MASK UINT32_C(0x08000000)
2958/** The instruction identity (VMX_XDTR_INSINFO_II_XXX values). */
2959#define VMX_BF_XDTR_INSINFO_INSTR_ID_SHIFT 28
2960#define VMX_BF_XDTR_INSINFO_INSTR_ID_MASK UINT32_C(0x30000000)
2961#define VMX_XDTR_INSINFO_II_SGDT 0 /**< Instruction ID: SGDT */
2962#define VMX_XDTR_INSINFO_II_SIDT 1 /**< Instruction ID: SIDT */
2963#define VMX_XDTR_INSINFO_II_LGDT 2 /**< Instruction ID: LGDT */
2964#define VMX_XDTR_INSINFO_II_LIDT 3 /**< Instruction ID: LIDT */
2965/** Bits 30 & 31 are undefined. */
2966#define VMX_BF_XDTR_INSINFO_UNDEF_30_31_SHIFT 30
2967#define VMX_BF_XDTR_INSINFO_UNDEF_30_31_MASK UINT32_C(0xc0000000)
2968RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_XDTR_INSINFO_, UINT32_C(0), UINT32_MAX,
2969 (SCALE, UNDEF_2_6, ADDR_SIZE, ZERO_10, OP_SIZE, UNDEF_12_14, SREG, INDEX_REG, HAS_INDEX_REG,
2970 BASE_REG, HAS_BASE_REG, INSTR_ID, UNDEF_30_31));
2971/** @} */
2972
2973
2974/** @name VMX_BF_YYTR_INSINFO_XXX - VMX_EXIT_TR_ACCESS instruction information.
2975 * Found in VMX_VMCS32_RO_EXIT_INSTR_INFO.
2976 * This is similar to VMX_BF_XDTR_INSINFO_XXX.
2977 * @{
2978 */
2979/** Address calculation scaling field (powers of two). */
2980#define VMX_BF_YYTR_INSINFO_SCALE_SHIFT 0
2981#define VMX_BF_YYTR_INSINFO_SCALE_MASK UINT32_C(0x00000003)
2982/** Bit 2 is undefined. */
2983#define VMX_BF_YYTR_INSINFO_UNDEF_2_SHIFT 2
2984#define VMX_BF_YYTR_INSINFO_UNDEF_2_MASK UINT32_C(0x00000004)
2985/** Register operand 1. Undefined if VMX_YYTR_INSINFO_HAS_REG1 is clear. */
2986#define VMX_BF_YYTR_INSINFO_REG1_SHIFT 3
2987#define VMX_BF_YYTR_INSINFO_REG1_MASK UINT32_C(0x00000078)
2988/** Address size, only 0(=16), 1(=32) and 2(=64) are defined.
2989 * @remarks anyone's guess why this is a 3 bit field... */
2990#define VMX_BF_YYTR_INSINFO_ADDR_SIZE_SHIFT 7
2991#define VMX_BF_YYTR_INSINFO_ADDR_SIZE_MASK UINT32_C(0x00000380)
2992/** Is VMX_YYTR_INSINFO_REG1_XXX valid (=1) or not (=0). */
2993#define VMX_BF_YYTR_INSINFO_HAS_REG1_SHIFT 10
2994#define VMX_BF_YYTR_INSINFO_HAS_REG1_MASK UINT32_C(0x00000400)
2995/** Bits 11 thru 14 are undefined. */
2996#define VMX_BF_YYTR_INSINFO_UNDEF_11_14_SHIFT 11
2997#define VMX_BF_YYTR_INSINFO_UNDEF_11_14_MASK UINT32_C(0x00007800)
2998/** Applicable segment register (X86_SREG_XXX values). */
2999#define VMX_BF_YYTR_INSINFO_SREG_SHIFT 15
3000#define VMX_BF_YYTR_INSINFO_SREG_MASK UINT32_C(0x00038000)
3001/** Index register (X86_GREG_XXX values). Undefined if HAS_INDEX_REG is clear. */
3002#define VMX_BF_YYTR_INSINFO_INDEX_REG_SHIFT 18
3003#define VMX_BF_YYTR_INSINFO_INDEX_REG_MASK UINT32_C(0x003c0000)
3004/** Is VMX_YYTR_INSINFO_INDEX_REG_XXX valid (=1) or not (=0). */
3005#define VMX_BF_YYTR_INSINFO_HAS_INDEX_REG_SHIFT 22
3006#define VMX_BF_YYTR_INSINFO_HAS_INDEX_REG_MASK UINT32_C(0x00400000)
3007/** Base register (X86_GREG_XXX values). Undefined if HAS_BASE_REG is clear. */
3008#define VMX_BF_YYTR_INSINFO_BASE_REG_SHIFT 23
3009#define VMX_BF_YYTR_INSINFO_BASE_REG_MASK UINT32_C(0x07800000)
3010/** Is VMX_YYTR_INSINFO_BASE_REG_XXX valid (=1) or not (=0). */
3011#define VMX_BF_YYTR_INSINFO_HAS_BASE_REG_SHIFT 27
3012#define VMX_BF_YYTR_INSINFO_HAS_BASE_REG_MASK UINT32_C(0x08000000)
3013/** The instruction identity (VMX_YYTR_INSINFO_II_XXX values) */
3014#define VMX_BF_YYTR_INSINFO_INSTR_ID_SHIFT 28
3015#define VMX_BF_YYTR_INSINFO_INSTR_ID_MASK UINT32_C(0x30000000)
3016#define VMX_YYTR_INSINFO_II_SLDT 0 /**< Instruction ID: SLDT */
3017#define VMX_YYTR_INSINFO_II_STR 1 /**< Instruction ID: STR */
3018#define VMX_YYTR_INSINFO_II_LLDT 2 /**< Instruction ID: LLDT */
3019#define VMX_YYTR_INSINFO_II_LTR 3 /**< Instruction ID: LTR */
3020/** Bits 30 & 31 are undefined. */
3021#define VMX_BF_YYTR_INSINFO_UNDEF_30_31_SHIFT 30
3022#define VMX_BF_YYTR_INSINFO_UNDEF_30_31_MASK UINT32_C(0xc0000000)
3023RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_YYTR_INSINFO_, UINT32_C(0), UINT32_MAX,
3024 (SCALE, UNDEF_2, REG1, ADDR_SIZE, HAS_REG1, UNDEF_11_14, SREG, INDEX_REG, HAS_INDEX_REG,
3025 BASE_REG, HAS_BASE_REG, INSTR_ID, UNDEF_30_31));
3026/** @} */
3027
3028
3029/** @name Format of Pending-Debug-Exceptions.
3030 * Bits 4-11, 13, 15 and 17-63 are reserved.
3031 * Similar to DR6 except bit 12 (breakpoint enabled) and bit 16 (RTM) are both
3032 * possibly valid here but not in DR6.
3033 * @{
3034 */
3035/** Hardware breakpoint 0 was met. */
3036#define VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BP0 RT_BIT_64(0)
3037/** Hardware breakpoint 1 was met. */
3038#define VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BP1 RT_BIT_64(1)
3039/** Hardware breakpoint 2 was met. */
3040#define VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BP2 RT_BIT_64(2)
3041/** Hardware breakpoint 3 was met. */
3042#define VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BP3 RT_BIT_64(3)
3043/** At least one data or IO breakpoint was hit. */
3044#define VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_EN_BP RT_BIT_64(12)
3045/** A debug exception would have been triggered by single-step execution mode. */
3046#define VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BS RT_BIT_64(14)
3047/** A debug exception occurred inside an RTM region. */
3048#define VMX_VMCS_GUEST_PENDING_DEBUG_RTM RT_BIT_64(16)
3049/** Mask of valid bits. */
3050#define VMX_VMCS_GUEST_PENDING_DEBUG_VALID_MASK ( VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BP0 \
3051 | VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BP1 \
3052 | VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BP2 \
3053 | VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BP3 \
3054 | VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_EN_BP \
3055 | VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BS \
3056 | VMX_VMCS_GUEST_PENDING_DEBUG_RTM)
3057#define VMX_VMCS_GUEST_PENDING_DEBUG_RTM_MASK ( VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_EN_BP \
3058 | VMX_VMCS_GUEST_PENDING_DEBUG_XCPT_BS \
3059 | VMX_VMCS_GUEST_PENDING_DEBUG_RTM)
3060/** Bit fields for Pending debug exceptions. */
3061#define VMX_BF_VMCS_PENDING_DBG_XCPT_BP0_SHIFT 0
3062#define VMX_BF_VMCS_PENDING_DBG_XCPT_BP0_MASK UINT64_C(0x0000000000000001)
3063#define VMX_BF_VMCS_PENDING_DBG_XCPT_BP1_SHIFT 1
3064#define VMX_BF_VMCS_PENDING_DBG_XCPT_BP1_MASK UINT64_C(0x0000000000000002)
3065#define VMX_BF_VMCS_PENDING_DBG_XCPT_BP2_SHIFT 2
3066#define VMX_BF_VMCS_PENDING_DBG_XCPT_BP2_MASK UINT64_C(0x0000000000000004)
3067#define VMX_BF_VMCS_PENDING_DBG_XCPT_BP3_SHIFT 3
3068#define VMX_BF_VMCS_PENDING_DBG_XCPT_BP3_MASK UINT64_C(0x0000000000000008)
3069#define VMX_BF_VMCS_PENDING_DBG_XCPT_RSVD_4_11_SHIFT 4
3070#define VMX_BF_VMCS_PENDING_DBG_XCPT_RSVD_4_11_MASK UINT64_C(0x0000000000000ff0)
3071#define VMX_BF_VMCS_PENDING_DBG_XCPT_EN_BP_SHIFT 12
3072#define VMX_BF_VMCS_PENDING_DBG_XCPT_EN_BP_MASK UINT64_C(0x0000000000001000)
3073#define VMX_BF_VMCS_PENDING_DBG_XCPT_RSVD_13_SHIFT 13
3074#define VMX_BF_VMCS_PENDING_DBG_XCPT_RSVD_13_MASK UINT64_C(0x0000000000002000)
3075#define VMX_BF_VMCS_PENDING_DBG_XCPT_BS_SHIFT 14
3076#define VMX_BF_VMCS_PENDING_DBG_XCPT_BS_MASK UINT64_C(0x0000000000004000)
3077#define VMX_BF_VMCS_PENDING_DBG_XCPT_RSVD_15_SHIFT 15
3078#define VMX_BF_VMCS_PENDING_DBG_XCPT_RSVD_15_MASK UINT64_C(0x0000000000008000)
3079#define VMX_BF_VMCS_PENDING_DBG_XCPT_RTM_SHIFT 16
3080#define VMX_BF_VMCS_PENDING_DBG_XCPT_RTM_MASK UINT64_C(0x0000000000010000)
3081#define VMX_BF_VMCS_PENDING_DBG_XCPT_RSVD_17_63_SHIFT 17
3082#define VMX_BF_VMCS_PENDING_DBG_XCPT_RSVD_17_63_MASK UINT64_C(0xfffffffffffe0000)
3083RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_VMCS_PENDING_DBG_XCPT_, UINT64_C(0), UINT64_MAX,
3084 (BP0, BP1, BP2, BP3, RSVD_4_11, EN_BP, RSVD_13, BS, RSVD_15, RTM, RSVD_17_63));
3085/** @} */
3086
3087
3088/** @name VMCS field encoding.
3089 * @{ */
3090typedef union
3091{
3092 struct
3093 {
3094 /** The access type; 0=full, 1=high of 64-bit fields. */
3095 uint32_t fAccessType : 1;
3096 /** The index. */
3097 uint32_t u8Index : 8;
3098 /** The type; 0=control, 1=VM-exit info, 2=guest-state, 3=host-state. */
3099 uint32_t u2Type : 2;
3100 /** Reserved (MBZ). */
3101 uint32_t u1Reserved0 : 1;
3102 /** The width; 0=16-bit, 1=64-bit, 2=32-bit, 3=natural-width. */
3103 uint32_t u2Width : 2;
3104 /** Reserved (MBZ). */
3105 uint32_t u18Reserved0 : 18;
3106 } n;
3107 /* The unsigned integer view. */
3108 uint32_t u;
3109} VMXVMCSFIELDENC;
3110AssertCompileSize(VMXVMCSFIELDENC, 4);
3111/** Pointer to a VMCS field encoding. */
3112typedef VMXVMCSFIELDENC *PVMXVMCSFIELDENC;
3113/** Pointer to a const VMCS field encoding. */
3114typedef const VMXVMCSFIELDENC *PCVMXVMCSFIELDENC;
3115
3116/** VMCS field encoding type: Full. */
3117#define VMX_VMCS_ENC_ACCESS_TYPE_FULL 0
3118/** VMCS field encoding type: High. */
3119#define VMX_VMCS_ENC_ACCESS_TYPE_HIGH 1
3120
3121/** VMCS field encoding type: Control. */
3122#define VMX_VMCS_ENC_TYPE_CONTROL 0
3123/** VMCS field encoding type: VM-exit information / read-only fields. */
3124#define VMX_VMCS_ENC_TYPE_VMEXIT_INFO 1
3125/** VMCS field encoding type: Guest-state. */
3126#define VMX_VMCS_ENC_TYPE_GUEST_STATE 2
3127/** VMCS field encoding type: Host-state. */
3128#define VMX_VMCS_ENC_TYPE_HOST_STATE 3
3129
3130/** VMCS field encoding width: 16-bit. */
3131#define VMX_VMCS_ENC_WIDTH_16BIT 0
3132/** VMCS field encoding width: 64-bit. */
3133#define VMX_VMCS_ENC_WIDTH_64BIT 1
3134/** VMCS field encoding width: 32-bit. */
3135#define VMX_VMCS_ENC_WIDTH_32BIT 2
3136/** VMCS field encoding width: Natural width. */
3137#define VMX_VMCS_ENC_WIDTH_NATURAL 3
3138
3139/** VMCS field encoding: Mask of reserved bits (bits 63:15 MBZ), bit 12 is
3140 * not included! */
3141#define VMX_VMCS_ENC_RSVD_MASK UINT64_C(0xffffffffffff8000)
3142
3143/** Bits fields for VMCS field encoding. */
3144#define VMX_BF_VMCS_ENC_ACCESS_TYPE_SHIFT 0
3145#define VMX_BF_VMCS_ENC_ACCESS_TYPE_MASK UINT32_C(0x00000001)
3146#define VMX_BF_VMCS_ENC_INDEX_SHIFT 1
3147#define VMX_BF_VMCS_ENC_INDEX_MASK UINT32_C(0x000003fe)
3148#define VMX_BF_VMCS_ENC_TYPE_SHIFT 10
3149#define VMX_BF_VMCS_ENC_TYPE_MASK UINT32_C(0x00000c00)
3150#define VMX_BF_VMCS_ENC_RSVD_12_SHIFT 12
3151#define VMX_BF_VMCS_ENC_RSVD_12_MASK UINT32_C(0x00001000)
3152#define VMX_BF_VMCS_ENC_WIDTH_SHIFT 13
3153#define VMX_BF_VMCS_ENC_WIDTH_MASK UINT32_C(0x00006000)
3154#define VMX_BF_VMCS_ENC_RSVD_15_31_SHIFT 15
3155#define VMX_BF_VMCS_ENC_RSVD_15_31_MASK UINT32_C(0xffff8000)
3156RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_VMCS_ENC_, UINT32_C(0), UINT32_MAX,
3157 (ACCESS_TYPE, INDEX, TYPE, RSVD_12, WIDTH, RSVD_15_31));
3158/** @} */
3159
3160
3161/** @defgroup grp_hm_vmx_virt VMX virtualization.
3162 * @{
3163 */
3164
3165/** @name Virtual VMX MSR - Miscellaneous data.
3166 * @{ */
3167/** Number of CR3-target values supported. */
3168#define VMX_V_CR3_TARGET_COUNT 4
3169/** Activity states supported. */
3170#define VMX_V_GUEST_ACTIVITY_STATE_MASK (VMX_VMCS_GUEST_ACTIVITY_HLT | VMX_VMCS_GUEST_ACTIVITY_SHUTDOWN)
3171/** VMX preemption-timer shift (Core i7-2600 taken as reference). */
3172#define VMX_V_PREEMPT_TIMER_SHIFT 5
3173/** Maximum number of MSRs in the auto-load/store MSR areas, (n+1) * 512. */
3174#define VMX_V_AUTOMSR_COUNT_MAX 0
3175/** SMM MSEG revision ID. */
3176#define VMX_V_MSEG_REV_ID 0
3177/** @} */
3178
3179/** @name VMX_V_VMCS_STATE_XXX - Virtual VMCS state.
3180 * @{ */
3181/** VMCS state clear. */
3182#define VMX_V_VMCS_STATE_CLEAR RT_BIT(1)
3183/** VMCS state launched. */
3184#define VMX_V_VMCS_STATE_LAUNCHED RT_BIT(2)
3185/** @} */
3186
3187/** CR0 bits set here must always be set when in VMX operation. */
3188#define VMX_V_CR0_FIXED0 (X86_CR0_PE | X86_CR0_NE | X86_CR0_PG)
3189/** VMX_V_CR0_FIXED0 when unrestricted-guest execution is supported for the guest. */
3190#define VMX_V_CR0_FIXED0_UX (VMX_V_CR0_FIXED0 & ~(X86_CR0_PE | X86_CR0_PG))
3191/** CR4 bits set here must always be set when in VMX operation. */
3192#define VMX_V_CR4_FIXED0 (X86_CR4_VMXE)
3193
3194/** Virtual VMCS revision ID. Bump this arbitarily chosen identifier if incompatible
3195 * changes to the layout of VMXVVMCS is done. Bit 31 MBZ. */
3196#define VMX_V_VMCS_REVISION_ID UINT32_C(0x40000001)
3197AssertCompile(!(VMX_V_VMCS_REVISION_ID & RT_BIT(31)));
3198
3199/** The size of the virtual VMCS region (we use the maximum allowed size to avoid
3200 * complications when teleporation may be implemented). */
3201#define VMX_V_VMCS_SIZE X86_PAGE_4K_SIZE
3202/** The size of the virtual VMCS region (in pages). */
3203#define VMX_V_VMCS_PAGES 1
3204
3205/** The size of the Virtual-APIC page (in bytes). */
3206#define VMX_V_VIRT_APIC_SIZE X86_PAGE_4K_SIZE
3207/** The size of the Virtual-APIC page (in pages). */
3208#define VMX_V_VIRT_APIC_PAGES 1
3209
3210/** Virtual X2APIC MSR range start. */
3211#define VMX_V_VIRT_APIC_MSR_START 0x800
3212/** Virtual X2APIC MSR range end. */
3213#define VMX_V_VIRT_APIC_MSR_END 0x8ff
3214
3215/** The size of the VMREAD/VMWRITE bitmap (in bytes). */
3216#define VMX_V_VMREAD_VMWRITE_BITMAP_SIZE X86_PAGE_4K_SIZE
3217/** The size of the VMREAD/VMWRITE-bitmap (in pages). */
3218#define VMX_V_VMREAD_VMWRITE_BITMAP_PAGES 1
3219
3220/** The size of the MSR bitmap (in bytes). */
3221#define VMX_V_MSR_BITMAP_SIZE X86_PAGE_4K_SIZE
3222/** The size of the MSR bitmap (in pages). */
3223#define VMX_V_MSR_BITMAP_PAGES 1
3224
3225/** The size of I/O bitmap A (in bytes). */
3226#define VMX_V_IO_BITMAP_A_SIZE X86_PAGE_4K_SIZE
3227/** The size of I/O bitmap A (in pages). */
3228#define VMX_V_IO_BITMAP_A_PAGES 1
3229
3230/** The size of I/O bitmap B (in bytes). */
3231#define VMX_V_IO_BITMAP_B_SIZE X86_PAGE_4K_SIZE
3232/** The size of I/O bitmap B (in pages). */
3233#define VMX_V_IO_BITMAP_B_PAGES 1
3234
3235/** The size of the auto-load/store MSR area (in bytes). */
3236#define VMX_V_AUTOMSR_AREA_SIZE ((512 * (VMX_V_AUTOMSR_COUNT_MAX + 1)) * sizeof(VMXAUTOMSR))
3237/* Assert that the size is page aligned or adjust the VMX_V_AUTOMSR_AREA_PAGES macro below. */
3238AssertCompile(RT_ALIGN_Z(VMX_V_AUTOMSR_AREA_SIZE, X86_PAGE_4K_SIZE) == VMX_V_AUTOMSR_AREA_SIZE);
3239/** The size of the auto-load/store MSR area (in pages). */
3240#define VMX_V_AUTOMSR_AREA_PAGES ((VMX_V_AUTOMSR_AREA_SIZE) >> X86_PAGE_4K_SHIFT)
3241
3242/** The highest index value used for supported virtual VMCS field encoding. */
3243#define VMX_V_VMCS_MAX_INDEX RT_BF_GET(VMX_VMCS64_CTRL_TSC_MULTIPLIER_HIGH, VMX_BF_VMCS_ENC_INDEX)
3244
3245/**
3246 * Virtual VM-Exit information.
3247 *
3248 * This is a convenience structure that bundles some VM-exit information related
3249 * fields together.
3250 */
3251typedef struct
3252{
3253 /** The VM-exit reason. */
3254 uint32_t uReason;
3255 /** The VM-exit instruction length. */
3256 uint32_t cbInstr;
3257 /** The VM-exit instruction information. */
3258 VMXEXITINSTRINFO InstrInfo;
3259 /** The VM-exit instruction ID. */
3260 VMXINSTRID uInstrId;
3261
3262 /** The VM-exit qualification field. */
3263 uint64_t u64Qual;
3264 /** The guest-linear address field. */
3265 uint64_t u64GuestLinearAddr;
3266 /** The guest-physical address field. */
3267 uint64_t u64GuestPhysAddr;
3268 /** The effective guest-linear address if @a InstrInfo indicates a memory-based
3269 * instruction VM-exit. */
3270 RTGCPTR GCPtrEffAddr;
3271} VMXVEXITINFO;
3272/** Pointer to the VMXVEXITINFO struct. */
3273typedef VMXVEXITINFO *PVMXVEXITINFO;
3274/** Pointer to a const VMXVEXITINFO struct. */
3275typedef const VMXVEXITINFO *PCVMXVEXITINFO;
3276AssertCompileMemberAlignment(VMXVEXITINFO, u64Qual, 8);
3277
3278/**
3279 * Virtual VMCS.
3280 * This is our custom format and merged into the actual VMCS (/shadow) when we
3281 * execute nested-guest code using hardware-assisted VMX.
3282 *
3283 * The first 8 bytes are as per Intel spec. 24.2 "Format of the VMCS Region".
3284 *
3285 * The offset and size of the VMCS state field (fVmcsState) is also fixed (not by
3286 * Intel but for our own requirements) as we use it to offset into guest memory.
3287 *
3288 * Although the guest is supposed to access the VMCS only through the execution of
3289 * VMX instructions (VMREAD, VMWRITE etc.), since the VMCS may reside in guest
3290 * memory (e.g, active but not current VMCS), for saved-states compatibility, and
3291 * for teleportation purposes, any newly added fields should be added to the
3292 * appropriate reserved sections or at the end of the structure.
3293 *
3294 * We always treat natural-width fields as 64-bit in our implementation since
3295 * it's easier, allows for teleporation in the future and does not affect guest
3296 * software.
3297 */
3298#pragma pack(1)
3299typedef struct
3300{
3301 /** 0x0 - VMX VMCS revision identifier. */
3302 VMXVMCSREVID u32VmcsRevId;
3303 /** 0x4 - VMX-abort indicator. */
3304 VMXABORT enmVmxAbort;
3305 /** 0x8 - VMCS state, see VMX_V_VMCS_STATE_XXX. */
3306 uint8_t fVmcsState;
3307 /** 0x9 - Reserved for future. */
3308 uint8_t au8Padding0[3];
3309 /** 0xc - Reserved for future. */
3310 uint32_t au32Reserved0[7];
3311
3312 /** @name 16-bit control fields.
3313 * @{ */
3314 /** 0x28 - Virtual processor ID. */
3315 uint16_t u16Vpid;
3316 /** 0x2a - Posted interrupt notify vector. */
3317 uint16_t u16PostIntNotifyVector;
3318 /** 0x2c - EPTP index. */
3319 uint16_t u16EptpIndex;
3320 /** 0x2e - Reserved for future. */
3321 uint16_t au16Reserved0[8];
3322 /** @} */
3323
3324 /** @name 16-bit Guest-state fields.
3325 * Order of [ES..GS] is important, must match X86_SREG_XXX.
3326 * @{ */
3327 /** 0x3e - Guest ES selector. */
3328 RTSEL GuestEs;
3329 /** 0x40 - Guest ES selector. */
3330 RTSEL GuestCs;
3331 /** 0x42 - Guest ES selector. */
3332 RTSEL GuestSs;
3333 /** 0x44 - Guest ES selector. */
3334 RTSEL GuestDs;
3335 /** 0x46 - Guest ES selector. */
3336 RTSEL GuestFs;
3337 /** 0x48 - Guest ES selector. */
3338 RTSEL GuestGs;
3339 /** 0x4a - Guest LDTR selector. */
3340 RTSEL GuestLdtr;
3341 /** 0x4c - Guest TR selector. */
3342 RTSEL GuestTr;
3343 /** 0x4e - Guest interrupt status (virtual-interrupt delivery). */
3344 uint16_t u16GuestIntStatus;
3345 /** 0x50 - PML index. */
3346 uint16_t u16PmlIndex;
3347 /** 0x52 - Reserved for future. */
3348 uint16_t au16Reserved1[8];
3349 /** @} */
3350
3351 /** @name 16-bit Host-state fields.
3352 * @{ */
3353 /** 0x62 - Host ES selector. */
3354 RTSEL HostEs;
3355 /** 0x64 - Host CS selector. */
3356 RTSEL HostCs;
3357 /** 0x66 - Host SS selector. */
3358 RTSEL HostSs;
3359 /** 0x68 - Host DS selector. */
3360 RTSEL HostDs;
3361 /** 0x6a - Host FS selector. */
3362 RTSEL HostFs;
3363 /** 0x6c - Host GS selector. */
3364 RTSEL HostGs;
3365 /** 0x6e - Host TR selector. */
3366 RTSEL HostTr;
3367 /** 0x70 - Reserved for future. */
3368 uint16_t au16Reserved2[10];
3369 /** @} */
3370
3371 /** @name 32-bit Control fields.
3372 * @{ */
3373 /** 0x84 - Pin-based VM-execution controls. */
3374 uint32_t u32PinCtls;
3375 /** 0x88 - Processor-based VM-execution controls. */
3376 uint32_t u32ProcCtls;
3377 /** 0x8c - Exception bitmap. */
3378 uint32_t u32XcptBitmap;
3379 /** 0x90 - Page-fault exception error mask. */
3380 uint32_t u32XcptPFMask;
3381 /** 0x94 - Page-fault exception error match. */
3382 uint32_t u32XcptPFMatch;
3383 /** 0x98 - CR3-target count. */
3384 uint32_t u32Cr3TargetCount;
3385 /** 0x9c - VM-exit controls. */
3386 uint32_t u32ExitCtls;
3387 /** 0xa0 - VM-exit MSR store count. */
3388 uint32_t u32ExitMsrStoreCount;
3389 /** 0xa4 - VM-exit MSR load count. */
3390 uint32_t u32ExitMsrLoadCount;
3391 /** 0xa8 - VM-entry controls. */
3392 uint32_t u32EntryCtls;
3393 /** 0xac - VM-entry MSR load count. */
3394 uint32_t u32EntryMsrLoadCount;
3395 /** 0xb0 - VM-entry interruption information. */
3396 uint32_t u32EntryIntInfo;
3397 /** 0xb4 - VM-entry exception error code. */
3398 uint32_t u32EntryXcptErrCode;
3399 /** 0xb8 - VM-entry instruction length. */
3400 uint32_t u32EntryInstrLen;
3401 /** 0xbc - TPR-threshold. */
3402 uint32_t u32TprThreshold;
3403 /** 0xc0 - Secondary-processor based VM-execution controls. */
3404 uint32_t u32ProcCtls2;
3405 /** 0xc4 - Pause-loop exiting Gap. */
3406 uint32_t u32PleGap;
3407 /** 0xc8 - Pause-loop exiting Window. */
3408 uint32_t u32PleWindow;
3409 /** 0xcc - Reserved for future. */
3410 uint32_t au32Reserved1[8];
3411 /** @} */
3412
3413 /** @name 32-bit Read-only Data fields.
3414 * @{ */
3415 /** 0xec - VM-instruction error. */
3416 uint32_t u32RoVmInstrError;
3417 /** 0xf0 - VM-exit reason. */
3418 uint32_t u32RoExitReason;
3419 /** 0xf4 - VM-exit interruption information. */
3420 uint32_t u32RoExitIntInfo;
3421 /** 0xf8 - VM-exit interruption error code. */
3422 uint32_t u32RoExitIntErrCode;
3423 /** 0xfc - IDT-vectoring information. */
3424 uint32_t u32RoIdtVectoringInfo;
3425 /** 0x100 - IDT-vectoring error code. */
3426 uint32_t u32RoIdtVectoringErrCode;
3427 /** 0x104 - VM-exit instruction length. */
3428 uint32_t u32RoExitInstrLen;
3429 /** 0x108 - VM-exit instruction information. */
3430 uint32_t u32RoExitInstrInfo;
3431 /** 0x10c - Reserved for future. */
3432 uint32_t au32RoReserved2[8];
3433 /** @} */
3434
3435 /** @name 32-bit Guest-state fields.
3436 * Order of [ES..GS] limit and attributes are important, must match X86_SREG_XXX.
3437 * @{ */
3438 /** 0x12c - Guest ES limit. */
3439 uint32_t u32GuestEsLimit;
3440 /** 0x130 - Guest CS limit. */
3441 uint32_t u32GuestCsLimit;
3442 /** 0x134 - Guest SS limit. */
3443 uint32_t u32GuestSsLimit;
3444 /** 0x138 - Guest DS limit. */
3445 uint32_t u32GuestDsLimit;
3446 /** 0x13c - Guest FS limit. */
3447 uint32_t u32GuestFsLimit;
3448 /** 0x140 - Guest GS limit. */
3449 uint32_t u32GuestGsLimit;
3450 /** 0x144 - Guest LDTR limit. */
3451 uint32_t u32GuestLdtrLimit;
3452 /** 0x148 - Guest TR limit. */
3453 uint32_t u32GuestTrLimit;
3454 /** 0x14c - Guest GDTR limit. */
3455 uint32_t u32GuestGdtrLimit;
3456 /** 0x150 - Guest IDTR limit. */
3457 uint32_t u32GuestIdtrLimit;
3458 /** 0x154 - Guest ES attributes. */
3459 uint32_t u32GuestEsAttr;
3460 /** 0x158 - Guest CS attributes. */
3461 uint32_t u32GuestCsAttr;
3462 /** 0x15c - Guest SS attributes. */
3463 uint32_t u32GuestSsAttr;
3464 /** 0x160 - Guest DS attributes. */
3465 uint32_t u32GuestDsAttr;
3466 /** 0x164 - Guest FS attributes. */
3467 uint32_t u32GuestFsAttr;
3468 /** 0x168 - Guest GS attributes. */
3469 uint32_t u32GuestGsAttr;
3470 /** 0x16c - Guest LDTR attributes. */
3471 uint32_t u32GuestLdtrAttr;
3472 /** 0x170 - Guest TR attributes. */
3473 uint32_t u32GuestTrAttr;
3474 /** 0x174 - Guest interruptibility state. */
3475 uint32_t u32GuestIntrState;
3476 /** 0x178 - Guest activity state. */
3477 uint32_t u32GuestActivityState;
3478 /** 0x17c - Guest SMBASE. */
3479 uint32_t u32GuestSmBase;
3480 /** 0x180 - Guest SYSENTER CS. */
3481 uint32_t u32GuestSysenterCS;
3482 /** 0x184 - Preemption timer value. */
3483 uint32_t u32PreemptTimer;
3484 /** 0x188 - Reserved for future. */
3485 uint32_t au32Reserved3[8];
3486 /** @} */
3487
3488 /** @name 32-bit Host-state fields.
3489 * @{ */
3490 /** 0x1a8 - Host SYSENTER CS. */
3491 uint32_t u32HostSysenterCs;
3492 /** 0x1ac - Reserved for future. */
3493 uint32_t au32Reserved4[11];
3494 /** @} */
3495
3496 /** @name 64-bit Control fields.
3497 * @{ */
3498 /** 0x1d8 - I/O bitmap A address. */
3499 RTUINT64U u64AddrIoBitmapA;
3500 /** 0x1e0 - I/O bitmap B address. */
3501 RTUINT64U u64AddrIoBitmapB;
3502 /** 0x1e8 - MSR bitmap address. */
3503 RTUINT64U u64AddrMsrBitmap;
3504 /** 0x1f0 - VM-exit MSR-store area address. */
3505 RTUINT64U u64AddrExitMsrStore;
3506 /** 0x1f8 - VM-exit MSR-load area address. */
3507 RTUINT64U u64AddrExitMsrLoad;
3508 /** 0x200 - VM-entry MSR-load area address. */
3509 RTUINT64U u64AddrEntryMsrLoad;
3510 /** 0x208 - Executive-VMCS pointer. */
3511 RTUINT64U u64ExecVmcsPtr;
3512 /** 0x210 - PML address. */
3513 RTUINT64U u64AddrPml;
3514 /** 0x218 - TSC offset. */
3515 RTUINT64U u64TscOffset;
3516 /** 0x220 - Virtual-APIC address. */
3517 RTUINT64U u64AddrVirtApic;
3518 /** 0x228 - APIC-access address. */
3519 RTUINT64U u64AddrApicAccess;
3520 /** 0x230 - Posted-interrupt descriptor address. */
3521 RTUINT64U u64AddrPostedIntDesc;
3522 /** 0x238 - VM-functions control. */
3523 RTUINT64U u64VmFuncCtls;
3524 /** 0x240 - EPTP pointer. */
3525 RTUINT64U u64EptpPtr;
3526 /** 0x248 - EOI-exit bitmap 0. */
3527 RTUINT64U u64EoiExitBitmap0;
3528 /** 0x250 - EOI-exit bitmap 1. */
3529 RTUINT64U u64EoiExitBitmap1;
3530 /** 0x258 - EOI-exit bitmap 2. */
3531 RTUINT64U u64EoiExitBitmap2;
3532 /** 0x260 - EOI-exit bitmap 3. */
3533 RTUINT64U u64EoiExitBitmap3;
3534 /** 0x268 - EPTP-list address. */
3535 RTUINT64U u64AddrEptpList;
3536 /** 0x270 - VMREAD-bitmap address. */
3537 RTUINT64U u64AddrVmreadBitmap;
3538 /** 0x278 - VMWRITE-bitmap address. */
3539 RTUINT64U u64AddrVmwriteBitmap;
3540 /** 0x280 - Virtualization-exception information address. */
3541 RTUINT64U u64AddrXcptVeInfo;
3542 /** 0x288 - XSS-exiting bitmap. */
3543 RTUINT64U u64XssBitmap;
3544 /** 0x290 - ENCLS-exiting bitmap address. */
3545 RTUINT64U u64AddrEnclsBitmap;
3546 /** 0x298 - TSC multiplier. */
3547 RTUINT64U u64TscMultiplier;
3548 /** 0x2a0 - Reserved for future. */
3549 RTUINT64U au64Reserved0[16];
3550 /** @} */
3551
3552 /** @name 64-bit Read-only Data fields.
3553 * @{ */
3554 /** 0x320 - Guest-physical address. */
3555 RTUINT64U u64RoGuestPhysAddr;
3556 /** 0x328 - Reserved for future. */
3557 RTUINT64U au64Reserved1[8];
3558 /** @} */
3559
3560 /** @name 64-bit Guest-state fields.
3561 * @{ */
3562 /** 0x368 - VMCS link pointer. */
3563 RTUINT64U u64VmcsLinkPtr;
3564 /** 0x370 - Guest debug-control MSR. */
3565 RTUINT64U u64GuestDebugCtlMsr;
3566 /** 0x378 - Guest PAT MSR. */
3567 RTUINT64U u64GuestPatMsr;
3568 /** 0x380 - Guest EFER MSR. */
3569 RTUINT64U u64GuestEferMsr;
3570 /** 0x388 - Guest global performance-control MSR. */
3571 RTUINT64U u64GuestPerfGlobalCtlMsr;
3572 /** 0x390 - Guest PDPTE 0. */
3573 RTUINT64U u64GuestPdpte0;
3574 /** 0x398 - Guest PDPTE 0. */
3575 RTUINT64U u64GuestPdpte1;
3576 /** 0x3a0 - Guest PDPTE 1. */
3577 RTUINT64U u64GuestPdpte2;
3578 /** 0x3a8 - Guest PDPTE 2. */
3579 RTUINT64U u64GuestPdpte3;
3580 /** 0x3b0 - Guest Bounds-config MSR (Intel MPX - Memory Protection Extensions). */
3581 RTUINT64U u64GuestBndcfgsMsr;
3582 /** 0x3b8 - Reserved for future. */
3583 RTUINT64U au64Reserved2[16];
3584 /** @} */
3585
3586 /** @name 64-bit Host-state Fields.
3587 * @{ */
3588 /** 0x438 - Host PAT MSR. */
3589 RTUINT64U u64HostPatMsr;
3590 /** 0x440 - Host EFER MSR. */
3591 RTUINT64U u64HostEferMsr;
3592 /** 0x448 - Host global performance-control MSR. */
3593 RTUINT64U u64HostPerfGlobalCtlMsr;
3594 /** 0x450 - Reserved for future. */
3595 RTUINT64U au64Reserved3[16];
3596 /** @} */
3597
3598 /** @name Natural-width Control fields.
3599 * @{ */
3600 /** 0x4d0 - CR0 guest/host Mask. */
3601 RTUINT64U u64Cr0Mask;
3602 /** 0x4d8 - CR4 guest/host Mask. */
3603 RTUINT64U u64Cr4Mask;
3604 /** 0x4e0 - CR0 read shadow. */
3605 RTUINT64U u64Cr0ReadShadow;
3606 /** 0x4e8 - CR4 read shadow. */
3607 RTUINT64U u64Cr4ReadShadow;
3608 /** 0x4f0 - CR3-target value 0. */
3609 RTUINT64U u64Cr3Target0;
3610 /** 0x4f8 - CR3-target value 1. */
3611 RTUINT64U u64Cr3Target1;
3612 /** 0x500 - CR3-target value 2. */
3613 RTUINT64U u64Cr3Target2;
3614 /** 0x508 - CR3-target value 3. */
3615 RTUINT64U u64Cr3Target3;
3616 /** 0x510 - Reserved for future. */
3617 RTUINT64U au64Reserved4[32];
3618 /** @} */
3619
3620 /** @name Natural-width Read-only Data fields.
3621 * @{ */
3622 /** 0x610 - Exit qualification. */
3623 RTUINT64U u64RoExitQual;
3624 /** 0x618 - I/O RCX. */
3625 RTUINT64U u64RoIoRcx;
3626 /** 0x620 - I/O RSI. */
3627 RTUINT64U u64RoIoRsi;
3628 /** 0x628 - I/O RDI. */
3629 RTUINT64U u64RoIoRdi;
3630 /** 0x630 - I/O RIP. */
3631 RTUINT64U u64RoIoRip;
3632 /** 0x638 - Guest-linear address. */
3633 RTUINT64U u64RoGuestLinearAddr;
3634 /** 0x640 - Reserved for future. */
3635 RTUINT64U au64Reserved5[16];
3636 /** @} */
3637
3638 /** @name Natural-width Guest-state Fields.
3639 * Order of [ES..GS] base is important, must match X86_SREG_XXX.
3640 * @{ */
3641 /** 0x6c0 - Guest CR0. */
3642 RTUINT64U u64GuestCr0;
3643 /** 0x6c8 - Guest CR3. */
3644 RTUINT64U u64GuestCr3;
3645 /** 0x6d0 - Guest CR4. */
3646 RTUINT64U u64GuestCr4;
3647 /** 0x6d8 - Guest ES base. */
3648 RTUINT64U u64GuestEsBase;
3649 /** 0x6e0 - Guest CS base. */
3650 RTUINT64U u64GuestCsBase;
3651 /** 0x6e8 - Guest SS base. */
3652 RTUINT64U u64GuestSsBase;
3653 /** 0x6f0 - Guest DS base. */
3654 RTUINT64U u64GuestDsBase;
3655 /** 0x6f8 - Guest FS base. */
3656 RTUINT64U u64GuestFsBase;
3657 /** 0x700 - Guest GS base. */
3658 RTUINT64U u64GuestGsBase;
3659 /** 0x708 - Guest LDTR base. */
3660 RTUINT64U u64GuestLdtrBase;
3661 /** 0x710 - Guest TR base. */
3662 RTUINT64U u64GuestTrBase;
3663 /** 0x718 - Guest GDTR base. */
3664 RTUINT64U u64GuestGdtrBase;
3665 /** 0x720 - Guest IDTR base. */
3666 RTUINT64U u64GuestIdtrBase;
3667 /** 0x728 - Guest DR7. */
3668 RTUINT64U u64GuestDr7;
3669 /** 0x730 - Guest RSP. */
3670 RTUINT64U u64GuestRsp;
3671 /** 0x738 - Guest RIP. */
3672 RTUINT64U u64GuestRip;
3673 /** 0x740 - Guest RFLAGS. */
3674 RTUINT64U u64GuestRFlags;
3675 /** 0x748 - Guest pending debug exception. */
3676 RTUINT64U u64GuestPendingDbgXcpt;
3677 /** 0x750 - Guest SYSENTER ESP. */
3678 RTUINT64U u64GuestSysenterEsp;
3679 /** 0x758 - Guest SYSENTER EIP. */
3680 RTUINT64U u64GuestSysenterEip;
3681 /** 0x760 - Reserved for future. */
3682 RTUINT64U au64Reserved6[32];
3683 /** @} */
3684
3685 /** @name Natural-width Host-state fields.
3686 * @{ */
3687 /** 0x860 - Host CR0. */
3688 RTUINT64U u64HostCr0;
3689 /** 0x868 - Host CR3. */
3690 RTUINT64U u64HostCr3;
3691 /** 0x870 - Host CR4. */
3692 RTUINT64U u64HostCr4;
3693 /** 0x878 - Host FS base. */
3694 RTUINT64U u64HostFsBase;
3695 /** 0x880 - Host GS base. */
3696 RTUINT64U u64HostGsBase;
3697 /** 0x888 - Host TR base. */
3698 RTUINT64U u64HostTrBase;
3699 /** 0x890 - Host GDTR base. */
3700 RTUINT64U u64HostGdtrBase;
3701 /** 0x898 - Host IDTR base. */
3702 RTUINT64U u64HostIdtrBase;
3703 /** 0x8a0 - Host SYSENTER ESP base. */
3704 RTUINT64U u64HostSysenterEsp;
3705 /** 0x8a8 - Host SYSENTER ESP base. */
3706 RTUINT64U u64HostSysenterEip;
3707 /** 0x8b0 - Host RSP. */
3708 RTUINT64U u64HostRsp;
3709 /** 0x8b8 - Host RIP. */
3710 RTUINT64U u64HostRip;
3711 /** 0x8c0 - Reserved for future. */
3712 RTUINT64U au64Reserved7[32];
3713 /** @} */
3714
3715 /** 0x9c0 - Padding. */
3716 uint8_t abPadding[X86_PAGE_4K_SIZE - 0x9c0];
3717} VMXVVMCS;
3718#pragma pack()
3719/** Pointer to the VMXVVMCS struct. */
3720typedef VMXVVMCS *PVMXVVMCS;
3721/** Pointer to a const VMXVVMCS struct. */
3722typedef const VMXVVMCS *PCVMXVVMCS;
3723AssertCompileSize(VMXVVMCS, X86_PAGE_4K_SIZE);
3724AssertCompileMemberSize(VMXVVMCS, fVmcsState, sizeof(uint8_t));
3725AssertCompileMemberOffset(VMXVVMCS, enmVmxAbort, 0x004);
3726AssertCompileMemberOffset(VMXVVMCS, fVmcsState, 0x008);
3727AssertCompileMemberOffset(VMXVVMCS, u16Vpid, 0x028);
3728AssertCompileMemberOffset(VMXVVMCS, GuestEs, 0x03e);
3729AssertCompileMemberOffset(VMXVVMCS, HostEs, 0x062);
3730AssertCompileMemberOffset(VMXVVMCS, u32PinCtls, 0x084);
3731AssertCompileMemberOffset(VMXVVMCS, u32RoVmInstrError, 0x0ec);
3732AssertCompileMemberOffset(VMXVVMCS, u32GuestEsLimit, 0x12c);
3733AssertCompileMemberOffset(VMXVVMCS, u32HostSysenterCs, 0x1a8);
3734AssertCompileMemberOffset(VMXVVMCS, u64AddrIoBitmapA, 0x1d8);
3735AssertCompileMemberOffset(VMXVVMCS, u64RoGuestPhysAddr, 0x320);
3736AssertCompileMemberOffset(VMXVVMCS, u64VmcsLinkPtr, 0x368);
3737AssertCompileMemberOffset(VMXVVMCS, u64HostPatMsr, 0x438);
3738AssertCompileMemberOffset(VMXVVMCS, u64Cr0Mask, 0x4d0);
3739AssertCompileMemberOffset(VMXVVMCS, u64RoExitQual, 0x610);
3740AssertCompileMemberOffset(VMXVVMCS, u64GuestCr0, 0x6c0);
3741AssertCompileMemberOffset(VMXVVMCS, u64HostCr0, 0x860);
3742
3743/**
3744 * Virtual VMX-instruction and VM-exit diagnostics.
3745 *
3746 * These are not the same as VM instruction errors that are enumerated in the Intel
3747 * spec. These are purely internal, fine-grained definitions used for diagnostic
3748 * purposes and are not reported to guest software under the VM-instruction error
3749 * field in its VMCS.
3750 *
3751 * @note Members of this enum are used as array indices, so no gaps are allowed.
3752 * Please update g_apszVmxVDiagDesc when you add new fields to this enum.
3753 */
3754typedef enum
3755{
3756 /* Internal processing errors. */
3757 kVmxVDiag_None = 0,
3758 kVmxVDiag_Ipe_1,
3759 kVmxVDiag_Ipe_2,
3760 kVmxVDiag_Ipe_3,
3761 kVmxVDiag_Ipe_4,
3762 kVmxVDiag_Ipe_5,
3763 kVmxVDiag_Ipe_6,
3764 kVmxVDiag_Ipe_7,
3765 kVmxVDiag_Ipe_8,
3766 kVmxVDiag_Ipe_9,
3767 kVmxVDiag_Ipe_10,
3768 kVmxVDiag_Ipe_11,
3769 kVmxVDiag_Ipe_12,
3770 kVmxVDiag_Ipe_13,
3771 kVmxVDiag_Ipe_14,
3772 kVmxVDiag_Ipe_15,
3773 kVmxVDiag_Ipe_16,
3774 /* VMXON. */
3775 kVmxVDiag_Vmxon_A20M,
3776 kVmxVDiag_Vmxon_Cpl,
3777 kVmxVDiag_Vmxon_Cr0Fixed0,
3778 kVmxVDiag_Vmxon_Cr0Fixed1,
3779 kVmxVDiag_Vmxon_Cr4Fixed0,
3780 kVmxVDiag_Vmxon_Cr4Fixed1,
3781 kVmxVDiag_Vmxon_Intercept,
3782 kVmxVDiag_Vmxon_LongModeCS,
3783 kVmxVDiag_Vmxon_MsrFeatCtl,
3784 kVmxVDiag_Vmxon_PtrAbnormal,
3785 kVmxVDiag_Vmxon_PtrAlign,
3786 kVmxVDiag_Vmxon_PtrMap,
3787 kVmxVDiag_Vmxon_PtrReadPhys,
3788 kVmxVDiag_Vmxon_PtrWidth,
3789 kVmxVDiag_Vmxon_RealOrV86Mode,
3790 kVmxVDiag_Vmxon_ShadowVmcs,
3791 kVmxVDiag_Vmxon_VmxAlreadyRoot,
3792 kVmxVDiag_Vmxon_Vmxe,
3793 kVmxVDiag_Vmxon_VmcsRevId,
3794 kVmxVDiag_Vmxon_VmxRootCpl,
3795 /* VMXOFF. */
3796 kVmxVDiag_Vmxoff_Cpl,
3797 kVmxVDiag_Vmxoff_Intercept,
3798 kVmxVDiag_Vmxoff_LongModeCS,
3799 kVmxVDiag_Vmxoff_RealOrV86Mode,
3800 kVmxVDiag_Vmxoff_Vmxe,
3801 kVmxVDiag_Vmxoff_VmxRoot,
3802 /* VMPTRLD. */
3803 kVmxVDiag_Vmptrld_Cpl,
3804 kVmxVDiag_Vmptrld_LongModeCS,
3805 kVmxVDiag_Vmptrld_PtrAbnormal,
3806 kVmxVDiag_Vmptrld_PtrAlign,
3807 kVmxVDiag_Vmptrld_PtrMap,
3808 kVmxVDiag_Vmptrld_PtrReadPhys,
3809 kVmxVDiag_Vmptrld_PtrVmxon,
3810 kVmxVDiag_Vmptrld_PtrWidth,
3811 kVmxVDiag_Vmptrld_RealOrV86Mode,
3812 kVmxVDiag_Vmptrld_RevPtrReadPhys,
3813 kVmxVDiag_Vmptrld_ShadowVmcs,
3814 kVmxVDiag_Vmptrld_VmcsRevId,
3815 kVmxVDiag_Vmptrld_VmxRoot,
3816 /* VMPTRST. */
3817 kVmxVDiag_Vmptrst_Cpl,
3818 kVmxVDiag_Vmptrst_LongModeCS,
3819 kVmxVDiag_Vmptrst_PtrMap,
3820 kVmxVDiag_Vmptrst_RealOrV86Mode,
3821 kVmxVDiag_Vmptrst_VmxRoot,
3822 /* VMCLEAR. */
3823 kVmxVDiag_Vmclear_Cpl,
3824 kVmxVDiag_Vmclear_LongModeCS,
3825 kVmxVDiag_Vmclear_PtrAbnormal,
3826 kVmxVDiag_Vmclear_PtrAlign,
3827 kVmxVDiag_Vmclear_PtrMap,
3828 kVmxVDiag_Vmclear_PtrReadPhys,
3829 kVmxVDiag_Vmclear_PtrVmxon,
3830 kVmxVDiag_Vmclear_PtrWidth,
3831 kVmxVDiag_Vmclear_RealOrV86Mode,
3832 kVmxVDiag_Vmclear_VmxRoot,
3833 /* VMWRITE. */
3834 kVmxVDiag_Vmwrite_Cpl,
3835 kVmxVDiag_Vmwrite_FieldInvalid,
3836 kVmxVDiag_Vmwrite_FieldRo,
3837 kVmxVDiag_Vmwrite_LinkPtrInvalid,
3838 kVmxVDiag_Vmwrite_LongModeCS,
3839 kVmxVDiag_Vmwrite_PtrInvalid,
3840 kVmxVDiag_Vmwrite_PtrMap,
3841 kVmxVDiag_Vmwrite_RealOrV86Mode,
3842 kVmxVDiag_Vmwrite_VmxRoot,
3843 /* VMREAD. */
3844 kVmxVDiag_Vmread_Cpl,
3845 kVmxVDiag_Vmread_FieldInvalid,
3846 kVmxVDiag_Vmread_LinkPtrInvalid,
3847 kVmxVDiag_Vmread_LongModeCS,
3848 kVmxVDiag_Vmread_PtrInvalid,
3849 kVmxVDiag_Vmread_PtrMap,
3850 kVmxVDiag_Vmread_RealOrV86Mode,
3851 kVmxVDiag_Vmread_VmxRoot,
3852 /* VMLAUNCH/VMRESUME. */
3853 kVmxVDiag_Vmentry_AddrApicAccess,
3854 kVmxVDiag_Vmentry_AddrApicAccessEqVirtApic,
3855 kVmxVDiag_Vmentry_AddrApicAccessHandlerReg,
3856 kVmxVDiag_Vmentry_AddrEntryMsrLoad,
3857 kVmxVDiag_Vmentry_AddrExitMsrLoad,
3858 kVmxVDiag_Vmentry_AddrExitMsrStore,
3859 kVmxVDiag_Vmentry_AddrIoBitmapA,
3860 kVmxVDiag_Vmentry_AddrIoBitmapB,
3861 kVmxVDiag_Vmentry_AddrMsrBitmap,
3862 kVmxVDiag_Vmentry_AddrVirtApicPage,
3863 kVmxVDiag_Vmentry_AddrVmcsLinkPtr,
3864 kVmxVDiag_Vmentry_AddrVmreadBitmap,
3865 kVmxVDiag_Vmentry_AddrVmwriteBitmap,
3866 kVmxVDiag_Vmentry_ApicRegVirt,
3867 kVmxVDiag_Vmentry_BlocKMovSS,
3868 kVmxVDiag_Vmentry_Cpl,
3869 kVmxVDiag_Vmentry_Cr3TargetCount,
3870 kVmxVDiag_Vmentry_EntryCtlsAllowed1,
3871 kVmxVDiag_Vmentry_EntryCtlsDisallowed0,
3872 kVmxVDiag_Vmentry_EntryInstrLen,
3873 kVmxVDiag_Vmentry_EntryInstrLenZero,
3874 kVmxVDiag_Vmentry_EntryIntInfoErrCodePe,
3875 kVmxVDiag_Vmentry_EntryIntInfoErrCodeVec,
3876 kVmxVDiag_Vmentry_EntryIntInfoTypeVecRsvd,
3877 kVmxVDiag_Vmentry_EntryXcptErrCodeRsvd,
3878 kVmxVDiag_Vmentry_ExitCtlsAllowed1,
3879 kVmxVDiag_Vmentry_ExitCtlsDisallowed0,
3880 kVmxVDiag_Vmentry_GuestActStateHlt,
3881 kVmxVDiag_Vmentry_GuestActStateRsvd,
3882 kVmxVDiag_Vmentry_GuestActStateShutdown,
3883 kVmxVDiag_Vmentry_GuestActStateSsDpl,
3884 kVmxVDiag_Vmentry_GuestActStateStiMovSs,
3885 kVmxVDiag_Vmentry_GuestCr0Fixed0,
3886 kVmxVDiag_Vmentry_GuestCr0Fixed1,
3887 kVmxVDiag_Vmentry_GuestCr0PgPe,
3888 kVmxVDiag_Vmentry_GuestCr3,
3889 kVmxVDiag_Vmentry_GuestCr4Fixed0,
3890 kVmxVDiag_Vmentry_GuestCr4Fixed1,
3891 kVmxVDiag_Vmentry_GuestDebugCtl,
3892 kVmxVDiag_Vmentry_GuestDr7,
3893 kVmxVDiag_Vmentry_GuestEferMsr,
3894 kVmxVDiag_Vmentry_GuestEferMsrRsvd,
3895 kVmxVDiag_Vmentry_GuestGdtrBase,
3896 kVmxVDiag_Vmentry_GuestGdtrLimit,
3897 kVmxVDiag_Vmentry_GuestIdtrBase,
3898 kVmxVDiag_Vmentry_GuestIdtrLimit,
3899 kVmxVDiag_Vmentry_GuestIntStateEnclave,
3900 kVmxVDiag_Vmentry_GuestIntStateExtInt,
3901 kVmxVDiag_Vmentry_GuestIntStateNmi,
3902 kVmxVDiag_Vmentry_GuestIntStateRFlagsSti,
3903 kVmxVDiag_Vmentry_GuestIntStateRsvd,
3904 kVmxVDiag_Vmentry_GuestIntStateSmi,
3905 kVmxVDiag_Vmentry_GuestIntStateStiMovSs,
3906 kVmxVDiag_Vmentry_GuestIntStateVirtNmi,
3907 kVmxVDiag_Vmentry_GuestPae,
3908 kVmxVDiag_Vmentry_GuestPatMsr,
3909 kVmxVDiag_Vmentry_GuestPcide,
3910 kVmxVDiag_Vmentry_GuestPdpteCr3ReadPhys,
3911 kVmxVDiag_Vmentry_GuestPdpte0Rsvd,
3912 kVmxVDiag_Vmentry_GuestPdpte1Rsvd,
3913 kVmxVDiag_Vmentry_GuestPdpte2Rsvd,
3914 kVmxVDiag_Vmentry_GuestPdpte3Rsvd,
3915 kVmxVDiag_Vmentry_GuestPndDbgXcptBsNoTf,
3916 kVmxVDiag_Vmentry_GuestPndDbgXcptBsTf,
3917 kVmxVDiag_Vmentry_GuestPndDbgXcptRsvd,
3918 kVmxVDiag_Vmentry_GuestPndDbgXcptRtm,
3919 kVmxVDiag_Vmentry_GuestRip,
3920 kVmxVDiag_Vmentry_GuestRipRsvd,
3921 kVmxVDiag_Vmentry_GuestRFlagsIf,
3922 kVmxVDiag_Vmentry_GuestRFlagsRsvd,
3923 kVmxVDiag_Vmentry_GuestRFlagsVm,
3924 kVmxVDiag_Vmentry_GuestSegAttrCsDefBig,
3925 kVmxVDiag_Vmentry_GuestSegAttrCsDplEqSs,
3926 kVmxVDiag_Vmentry_GuestSegAttrCsDplLtSs,
3927 kVmxVDiag_Vmentry_GuestSegAttrCsDplZero,
3928 kVmxVDiag_Vmentry_GuestSegAttrCsType,
3929 kVmxVDiag_Vmentry_GuestSegAttrCsTypeRead,
3930 kVmxVDiag_Vmentry_GuestSegAttrDescTypeCs,
3931 kVmxVDiag_Vmentry_GuestSegAttrDescTypeDs,
3932 kVmxVDiag_Vmentry_GuestSegAttrDescTypeEs,
3933 kVmxVDiag_Vmentry_GuestSegAttrDescTypeFs,
3934 kVmxVDiag_Vmentry_GuestSegAttrDescTypeGs,
3935 kVmxVDiag_Vmentry_GuestSegAttrDescTypeSs,
3936 kVmxVDiag_Vmentry_GuestSegAttrDplRplCs,
3937 kVmxVDiag_Vmentry_GuestSegAttrDplRplDs,
3938 kVmxVDiag_Vmentry_GuestSegAttrDplRplEs,
3939 kVmxVDiag_Vmentry_GuestSegAttrDplRplFs,
3940 kVmxVDiag_Vmentry_GuestSegAttrDplRplGs,
3941 kVmxVDiag_Vmentry_GuestSegAttrDplRplSs,
3942 kVmxVDiag_Vmentry_GuestSegAttrGranCs,
3943 kVmxVDiag_Vmentry_GuestSegAttrGranDs,
3944 kVmxVDiag_Vmentry_GuestSegAttrGranEs,
3945 kVmxVDiag_Vmentry_GuestSegAttrGranFs,
3946 kVmxVDiag_Vmentry_GuestSegAttrGranGs,
3947 kVmxVDiag_Vmentry_GuestSegAttrGranSs,
3948 kVmxVDiag_Vmentry_GuestSegAttrLdtrDescType,
3949 kVmxVDiag_Vmentry_GuestSegAttrLdtrGran,
3950 kVmxVDiag_Vmentry_GuestSegAttrLdtrPresent,
3951 kVmxVDiag_Vmentry_GuestSegAttrLdtrRsvd,
3952 kVmxVDiag_Vmentry_GuestSegAttrLdtrType,
3953 kVmxVDiag_Vmentry_GuestSegAttrPresentCs,
3954 kVmxVDiag_Vmentry_GuestSegAttrPresentDs,
3955 kVmxVDiag_Vmentry_GuestSegAttrPresentEs,
3956 kVmxVDiag_Vmentry_GuestSegAttrPresentFs,
3957 kVmxVDiag_Vmentry_GuestSegAttrPresentGs,
3958 kVmxVDiag_Vmentry_GuestSegAttrPresentSs,
3959 kVmxVDiag_Vmentry_GuestSegAttrRsvdCs,
3960 kVmxVDiag_Vmentry_GuestSegAttrRsvdDs,
3961 kVmxVDiag_Vmentry_GuestSegAttrRsvdEs,
3962 kVmxVDiag_Vmentry_GuestSegAttrRsvdFs,
3963 kVmxVDiag_Vmentry_GuestSegAttrRsvdGs,
3964 kVmxVDiag_Vmentry_GuestSegAttrRsvdSs,
3965 kVmxVDiag_Vmentry_GuestSegAttrSsDplEqRpl,
3966 kVmxVDiag_Vmentry_GuestSegAttrSsDplZero,
3967 kVmxVDiag_Vmentry_GuestSegAttrSsType,
3968 kVmxVDiag_Vmentry_GuestSegAttrTrDescType,
3969 kVmxVDiag_Vmentry_GuestSegAttrTrGran,
3970 kVmxVDiag_Vmentry_GuestSegAttrTrPresent,
3971 kVmxVDiag_Vmentry_GuestSegAttrTrRsvd,
3972 kVmxVDiag_Vmentry_GuestSegAttrTrType,
3973 kVmxVDiag_Vmentry_GuestSegAttrTrUnusable,
3974 kVmxVDiag_Vmentry_GuestSegAttrTypeAccCs,
3975 kVmxVDiag_Vmentry_GuestSegAttrTypeAccDs,
3976 kVmxVDiag_Vmentry_GuestSegAttrTypeAccEs,
3977 kVmxVDiag_Vmentry_GuestSegAttrTypeAccFs,
3978 kVmxVDiag_Vmentry_GuestSegAttrTypeAccGs,
3979 kVmxVDiag_Vmentry_GuestSegAttrTypeAccSs,
3980 kVmxVDiag_Vmentry_GuestSegAttrV86Cs,
3981 kVmxVDiag_Vmentry_GuestSegAttrV86Ds,
3982 kVmxVDiag_Vmentry_GuestSegAttrV86Es,
3983 kVmxVDiag_Vmentry_GuestSegAttrV86Fs,
3984 kVmxVDiag_Vmentry_GuestSegAttrV86Gs,
3985 kVmxVDiag_Vmentry_GuestSegAttrV86Ss,
3986 kVmxVDiag_Vmentry_GuestSegBaseCs,
3987 kVmxVDiag_Vmentry_GuestSegBaseDs,
3988 kVmxVDiag_Vmentry_GuestSegBaseEs,
3989 kVmxVDiag_Vmentry_GuestSegBaseFs,
3990 kVmxVDiag_Vmentry_GuestSegBaseGs,
3991 kVmxVDiag_Vmentry_GuestSegBaseLdtr,
3992 kVmxVDiag_Vmentry_GuestSegBaseSs,
3993 kVmxVDiag_Vmentry_GuestSegBaseTr,
3994 kVmxVDiag_Vmentry_GuestSegBaseV86Cs,
3995 kVmxVDiag_Vmentry_GuestSegBaseV86Ds,
3996 kVmxVDiag_Vmentry_GuestSegBaseV86Es,
3997 kVmxVDiag_Vmentry_GuestSegBaseV86Fs,
3998 kVmxVDiag_Vmentry_GuestSegBaseV86Gs,
3999 kVmxVDiag_Vmentry_GuestSegBaseV86Ss,
4000 kVmxVDiag_Vmentry_GuestSegLimitV86Cs,
4001 kVmxVDiag_Vmentry_GuestSegLimitV86Ds,
4002 kVmxVDiag_Vmentry_GuestSegLimitV86Es,
4003 kVmxVDiag_Vmentry_GuestSegLimitV86Fs,
4004 kVmxVDiag_Vmentry_GuestSegLimitV86Gs,
4005 kVmxVDiag_Vmentry_GuestSegLimitV86Ss,
4006 kVmxVDiag_Vmentry_GuestSegSelCsSsRpl,
4007 kVmxVDiag_Vmentry_GuestSegSelLdtr,
4008 kVmxVDiag_Vmentry_GuestSegSelTr,
4009 kVmxVDiag_Vmentry_GuestSysenterEspEip,
4010 kVmxVDiag_Vmentry_VmcsLinkPtrCurVmcs,
4011 kVmxVDiag_Vmentry_VmcsLinkPtrReadPhys,
4012 kVmxVDiag_Vmentry_VmcsLinkPtrRevId,
4013 kVmxVDiag_Vmentry_VmcsLinkPtrShadow,
4014 kVmxVDiag_Vmentry_HostCr0Fixed0,
4015 kVmxVDiag_Vmentry_HostCr0Fixed1,
4016 kVmxVDiag_Vmentry_HostCr3,
4017 kVmxVDiag_Vmentry_HostCr4Fixed0,
4018 kVmxVDiag_Vmentry_HostCr4Fixed1,
4019 kVmxVDiag_Vmentry_HostCr4Pae,
4020 kVmxVDiag_Vmentry_HostCr4Pcide,
4021 kVmxVDiag_Vmentry_HostCsTr,
4022 kVmxVDiag_Vmentry_HostEferMsr,
4023 kVmxVDiag_Vmentry_HostEferMsrRsvd,
4024 kVmxVDiag_Vmentry_HostGuestLongMode,
4025 kVmxVDiag_Vmentry_HostGuestLongModeNoCpu,
4026 kVmxVDiag_Vmentry_HostLongMode,
4027 kVmxVDiag_Vmentry_HostPatMsr,
4028 kVmxVDiag_Vmentry_HostRip,
4029 kVmxVDiag_Vmentry_HostRipRsvd,
4030 kVmxVDiag_Vmentry_HostSel,
4031 kVmxVDiag_Vmentry_HostSegBase,
4032 kVmxVDiag_Vmentry_HostSs,
4033 kVmxVDiag_Vmentry_HostSysenterEspEip,
4034 kVmxVDiag_Vmentry_LongModeCS,
4035 kVmxVDiag_Vmentry_MsrBitmapPtrReadPhys,
4036 kVmxVDiag_Vmentry_MsrLoad,
4037 kVmxVDiag_Vmentry_MsrLoadCount,
4038 kVmxVDiag_Vmentry_MsrLoadPtrReadPhys,
4039 kVmxVDiag_Vmentry_MsrLoadRing3,
4040 kVmxVDiag_Vmentry_MsrLoadRsvd,
4041 kVmxVDiag_Vmentry_NmiWindowExit,
4042 kVmxVDiag_Vmentry_PinCtlsAllowed1,
4043 kVmxVDiag_Vmentry_PinCtlsDisallowed0,
4044 kVmxVDiag_Vmentry_ProcCtlsAllowed1,
4045 kVmxVDiag_Vmentry_ProcCtlsDisallowed0,
4046 kVmxVDiag_Vmentry_ProcCtls2Allowed1,
4047 kVmxVDiag_Vmentry_ProcCtls2Disallowed0,
4048 kVmxVDiag_Vmentry_PtrInvalid,
4049 kVmxVDiag_Vmentry_RealOrV86Mode,
4050 kVmxVDiag_Vmentry_SavePreemptTimer,
4051 kVmxVDiag_Vmentry_TprThresholdRsvd,
4052 kVmxVDiag_Vmentry_TprThresholdVTpr,
4053 kVmxVDiag_Vmentry_VirtApicPagePtrReadPhys,
4054 kVmxVDiag_Vmentry_VirtIntDelivery,
4055 kVmxVDiag_Vmentry_VirtNmi,
4056 kVmxVDiag_Vmentry_VirtX2ApicTprShadow,
4057 kVmxVDiag_Vmentry_VirtX2ApicVirtApic,
4058 kVmxVDiag_Vmentry_VmcsClear,
4059 kVmxVDiag_Vmentry_VmcsLaunch,
4060 kVmxVDiag_Vmentry_VmreadBitmapPtrReadPhys,
4061 kVmxVDiag_Vmentry_VmwriteBitmapPtrReadPhys,
4062 kVmxVDiag_Vmentry_VmxRoot,
4063 kVmxVDiag_Vmentry_Vpid,
4064 kVmxVDiag_Vmexit_HostPdpteCr3ReadPhys,
4065 kVmxVDiag_Vmexit_HostPdpte0Rsvd,
4066 kVmxVDiag_Vmexit_HostPdpte1Rsvd,
4067 kVmxVDiag_Vmexit_HostPdpte2Rsvd,
4068 kVmxVDiag_Vmexit_HostPdpte3Rsvd,
4069 kVmxVDiag_Vmexit_MsrLoad,
4070 kVmxVDiag_Vmexit_MsrLoadCount,
4071 kVmxVDiag_Vmexit_MsrLoadPtrReadPhys,
4072 kVmxVDiag_Vmexit_MsrLoadRing3,
4073 kVmxVDiag_Vmexit_MsrLoadRsvd,
4074 kVmxVDiag_Vmexit_MsrStore,
4075 kVmxVDiag_Vmexit_MsrStoreCount,
4076 kVmxVDiag_Vmexit_MsrStorePtrWritePhys,
4077 kVmxVDiag_Vmexit_MsrStoreRing3,
4078 kVmxVDiag_Vmexit_MsrStoreRsvd,
4079 /* Last member for determining array index limit. */
4080 kVmxVDiag_End
4081} VMXVDIAG;
4082AssertCompileSize(VMXVDIAG, 4);
4083
4084/** @} */
4085
4086
4087/** @defgroup grp_hm_vmx_c VMX C Helpers
4088 *
4089 * These are functions that strictly only implement VT-x functionality that is in
4090 * accordance to the VT-X spec. and thus fit to use by IEM/REM/HM.
4091 *
4092 * These are not HM all-context API functions, those are to be placed in hm.h.
4093 * @{
4094 */
4095VMM_INT_DECL(int) HMGetVmxMsrPermission(void const *pvMsrBitmap, uint32_t idMsr, PVMXMSREXITREAD penmRead,
4096 PVMXMSREXITWRITE penmWrite);
4097VMM_INT_DECL(bool) HMGetVmxIoBitmapPermission(void const *pvIoBitmapA, void const *pvIoBitmapB, uint16_t uPort,
4098 uint8_t cbAccess);
4099/** @} */
4100
4101
4102/** @} */
4103
4104#endif /* !VBOX_INCLUDED_vmm_hm_vmx_h */
4105
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette