VirtualBox

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

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

hm_vmx.h: Nested VMX: bugref:9180 comment nit.

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

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