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