VirtualBox

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

Last change on this file since 96399 was 96295, checked in by vboxsync, 2 years ago

VMM: Nested EPT: bugref:10092 Nits.

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