VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/HMVMXAll.cpp@ 78003

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

VMM/HM: Nested VMX: bugref:9180 Renamed VMX_V_VMCS_STATE_XXX to VMX_V_VMCS_LAUNCH_STATE_XXX.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 73.3 KB
Line 
1/* $Id: HMVMXAll.cpp 77745 2019-03-18 09:17:37Z vboxsync $ */
2/** @file
3 * HM VMX (VT-x) - All contexts.
4 */
5
6/*
7 * Copyright (C) 2018-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_HM
23#define VMCPU_INCL_CPUM_GST_CTX
24#include "HMInternal.h"
25#include <VBox/vmm/vm.h>
26#include <VBox/vmm/pdmapi.h>
27#include <iprt/errcore.h>
28
29
30/*********************************************************************************************************************************
31* Global Variables *
32*********************************************************************************************************************************/
33#define VMXV_DIAG_DESC(a_Def, a_Desc) #a_Def " - " #a_Desc
34/** VMX virtual-instructions and VM-exit diagnostics. */
35static const char * const g_apszVmxVDiagDesc[] =
36{
37 /* Internal processing errors. */
38 VMXV_DIAG_DESC(kVmxVDiag_None , "None" ),
39 VMXV_DIAG_DESC(kVmxVDiag_Ipe_1 , "Ipe_1" ),
40 VMXV_DIAG_DESC(kVmxVDiag_Ipe_2 , "Ipe_2" ),
41 VMXV_DIAG_DESC(kVmxVDiag_Ipe_3 , "Ipe_3" ),
42 VMXV_DIAG_DESC(kVmxVDiag_Ipe_4 , "Ipe_4" ),
43 VMXV_DIAG_DESC(kVmxVDiag_Ipe_5 , "Ipe_5" ),
44 VMXV_DIAG_DESC(kVmxVDiag_Ipe_6 , "Ipe_6" ),
45 VMXV_DIAG_DESC(kVmxVDiag_Ipe_7 , "Ipe_7" ),
46 VMXV_DIAG_DESC(kVmxVDiag_Ipe_8 , "Ipe_8" ),
47 VMXV_DIAG_DESC(kVmxVDiag_Ipe_9 , "Ipe_9" ),
48 VMXV_DIAG_DESC(kVmxVDiag_Ipe_10 , "Ipe_10" ),
49 VMXV_DIAG_DESC(kVmxVDiag_Ipe_11 , "Ipe_11" ),
50 VMXV_DIAG_DESC(kVmxVDiag_Ipe_12 , "Ipe_12" ),
51 VMXV_DIAG_DESC(kVmxVDiag_Ipe_13 , "Ipe_13" ),
52 VMXV_DIAG_DESC(kVmxVDiag_Ipe_14 , "Ipe_14" ),
53 VMXV_DIAG_DESC(kVmxVDiag_Ipe_15 , "Ipe_15" ),
54 VMXV_DIAG_DESC(kVmxVDiag_Ipe_16 , "Ipe_16" ),
55 /* VMXON. */
56 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_A20M , "A20M" ),
57 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_Cpl , "Cpl" ),
58 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_Cr0Fixed0 , "Cr0Fixed0" ),
59 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_Cr0Fixed1 , "Cr0Fixed1" ),
60 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_Cr4Fixed0 , "Cr4Fixed0" ),
61 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_Cr4Fixed1 , "Cr4Fixed1" ),
62 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_Intercept , "Intercept" ),
63 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_LongModeCS , "LongModeCS" ),
64 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_MsrFeatCtl , "MsrFeatCtl" ),
65 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_PtrAbnormal , "PtrAbnormal" ),
66 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_PtrAlign , "PtrAlign" ),
67 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_PtrMap , "PtrMap" ),
68 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_PtrReadPhys , "PtrReadPhys" ),
69 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_PtrWidth , "PtrWidth" ),
70 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_RealOrV86Mode , "RealOrV86Mode" ),
71 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_ShadowVmcs , "ShadowVmcs" ),
72 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_VmxAlreadyRoot , "VmxAlreadyRoot" ),
73 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_Vmxe , "Vmxe" ),
74 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_VmcsRevId , "VmcsRevId" ),
75 VMXV_DIAG_DESC(kVmxVDiag_Vmxon_VmxRootCpl , "VmxRootCpl" ),
76 /* VMXOFF. */
77 VMXV_DIAG_DESC(kVmxVDiag_Vmxoff_Cpl , "Cpl" ),
78 VMXV_DIAG_DESC(kVmxVDiag_Vmxoff_Intercept , "Intercept" ),
79 VMXV_DIAG_DESC(kVmxVDiag_Vmxoff_LongModeCS , "LongModeCS" ),
80 VMXV_DIAG_DESC(kVmxVDiag_Vmxoff_RealOrV86Mode , "RealOrV86Mode" ),
81 VMXV_DIAG_DESC(kVmxVDiag_Vmxoff_Vmxe , "Vmxe" ),
82 VMXV_DIAG_DESC(kVmxVDiag_Vmxoff_VmxRoot , "VmxRoot" ),
83 /* VMPTRLD. */
84 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_Cpl , "Cpl" ),
85 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_LongModeCS , "LongModeCS" ),
86 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_PtrAbnormal , "PtrAbnormal" ),
87 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_PtrAlign , "PtrAlign" ),
88 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_PtrMap , "PtrMap" ),
89 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_PtrReadPhys , "PtrReadPhys" ),
90 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_PtrVmxon , "PtrVmxon" ),
91 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_PtrWidth , "PtrWidth" ),
92 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_RealOrV86Mode , "RealOrV86Mode" ),
93 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_RevPtrReadPhys , "RevPtrReadPhys" ),
94 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_ShadowVmcs , "ShadowVmcs" ),
95 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_VmcsRevId , "VmcsRevId" ),
96 VMXV_DIAG_DESC(kVmxVDiag_Vmptrld_VmxRoot , "VmxRoot" ),
97 /* VMPTRST. */
98 VMXV_DIAG_DESC(kVmxVDiag_Vmptrst_Cpl , "Cpl" ),
99 VMXV_DIAG_DESC(kVmxVDiag_Vmptrst_LongModeCS , "LongModeCS" ),
100 VMXV_DIAG_DESC(kVmxVDiag_Vmptrst_PtrMap , "PtrMap" ),
101 VMXV_DIAG_DESC(kVmxVDiag_Vmptrst_RealOrV86Mode , "RealOrV86Mode" ),
102 VMXV_DIAG_DESC(kVmxVDiag_Vmptrst_VmxRoot , "VmxRoot" ),
103 /* VMCLEAR. */
104 VMXV_DIAG_DESC(kVmxVDiag_Vmclear_Cpl , "Cpl" ),
105 VMXV_DIAG_DESC(kVmxVDiag_Vmclear_LongModeCS , "LongModeCS" ),
106 VMXV_DIAG_DESC(kVmxVDiag_Vmclear_PtrAbnormal , "PtrAbnormal" ),
107 VMXV_DIAG_DESC(kVmxVDiag_Vmclear_PtrAlign , "PtrAlign" ),
108 VMXV_DIAG_DESC(kVmxVDiag_Vmclear_PtrMap , "PtrMap" ),
109 VMXV_DIAG_DESC(kVmxVDiag_Vmclear_PtrReadPhys , "PtrReadPhys" ),
110 VMXV_DIAG_DESC(kVmxVDiag_Vmclear_PtrVmxon , "PtrVmxon" ),
111 VMXV_DIAG_DESC(kVmxVDiag_Vmclear_PtrWidth , "PtrWidth" ),
112 VMXV_DIAG_DESC(kVmxVDiag_Vmclear_RealOrV86Mode , "RealOrV86Mode" ),
113 VMXV_DIAG_DESC(kVmxVDiag_Vmclear_VmxRoot , "VmxRoot" ),
114 /* VMWRITE. */
115 VMXV_DIAG_DESC(kVmxVDiag_Vmwrite_Cpl , "Cpl" ),
116 VMXV_DIAG_DESC(kVmxVDiag_Vmwrite_FieldInvalid , "FieldInvalid" ),
117 VMXV_DIAG_DESC(kVmxVDiag_Vmwrite_FieldRo , "FieldRo" ),
118 VMXV_DIAG_DESC(kVmxVDiag_Vmwrite_LinkPtrInvalid , "LinkPtrInvalid" ),
119 VMXV_DIAG_DESC(kVmxVDiag_Vmwrite_LongModeCS , "LongModeCS" ),
120 VMXV_DIAG_DESC(kVmxVDiag_Vmwrite_PtrInvalid , "PtrInvalid" ),
121 VMXV_DIAG_DESC(kVmxVDiag_Vmwrite_PtrMap , "PtrMap" ),
122 VMXV_DIAG_DESC(kVmxVDiag_Vmwrite_RealOrV86Mode , "RealOrV86Mode" ),
123 VMXV_DIAG_DESC(kVmxVDiag_Vmwrite_VmxRoot , "VmxRoot" ),
124 /* VMREAD. */
125 VMXV_DIAG_DESC(kVmxVDiag_Vmread_Cpl , "Cpl" ),
126 VMXV_DIAG_DESC(kVmxVDiag_Vmread_FieldInvalid , "FieldInvalid" ),
127 VMXV_DIAG_DESC(kVmxVDiag_Vmread_LinkPtrInvalid , "LinkPtrInvalid" ),
128 VMXV_DIAG_DESC(kVmxVDiag_Vmread_LongModeCS , "LongModeCS" ),
129 VMXV_DIAG_DESC(kVmxVDiag_Vmread_PtrInvalid , "PtrInvalid" ),
130 VMXV_DIAG_DESC(kVmxVDiag_Vmread_PtrMap , "PtrMap" ),
131 VMXV_DIAG_DESC(kVmxVDiag_Vmread_RealOrV86Mode , "RealOrV86Mode" ),
132 VMXV_DIAG_DESC(kVmxVDiag_Vmread_VmxRoot , "VmxRoot" ),
133 /* VMLAUNCH/VMRESUME. */
134 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrApicAccess , "AddrApicAccess" ),
135 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrApicAccessEqVirtApic , "AddrApicAccessEqVirtApic" ),
136 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrApicAccessHandlerReg , "AddrApicAccessHandlerReg" ),
137 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrEntryMsrLoad , "AddrEntryMsrLoad" ),
138 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrExitMsrLoad , "AddrExitMsrLoad" ),
139 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrExitMsrStore , "AddrExitMsrStore" ),
140 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrIoBitmapA , "AddrIoBitmapA" ),
141 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrIoBitmapB , "AddrIoBitmapB" ),
142 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrMsrBitmap , "AddrMsrBitmap" ),
143 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrVirtApicPage , "AddrVirtApicPage" ),
144 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrVmcsLinkPtr , "AddrVmcsLinkPtr" ),
145 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrVmreadBitmap , "AddrVmreadBitmap" ),
146 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_AddrVmwriteBitmap , "AddrVmwriteBitmap" ),
147 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_ApicRegVirt , "ApicRegVirt" ),
148 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_BlocKMovSS , "BlockMovSS" ),
149 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_Cpl , "Cpl" ),
150 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_Cr3TargetCount , "Cr3TargetCount" ),
151 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_EntryCtlsAllowed1 , "EntryCtlsAllowed1" ),
152 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_EntryCtlsDisallowed0 , "EntryCtlsDisallowed0" ),
153 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_EntryInstrLen , "EntryInstrLen" ),
154 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_EntryInstrLenZero , "EntryInstrLenZero" ),
155 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_EntryIntInfoErrCodePe , "EntryIntInfoErrCodePe" ),
156 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_EntryIntInfoErrCodeVec , "EntryIntInfoErrCodeVec" ),
157 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_EntryIntInfoTypeVecRsvd , "EntryIntInfoTypeVecRsvd" ),
158 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_EntryXcptErrCodeRsvd , "EntryXcptErrCodeRsvd" ),
159 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_ExitCtlsAllowed1 , "ExitCtlsAllowed1" ),
160 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_ExitCtlsDisallowed0 , "ExitCtlsDisallowed0" ),
161 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestActStateHlt , "GuestActStateHlt" ),
162 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestActStateRsvd , "GuestActStateRsvd" ),
163 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestActStateShutdown , "GuestActStateShutdown" ),
164 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestActStateSsDpl , "GuestActStateSsDpl" ),
165 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestActStateStiMovSs , "GuestActStateStiMovSs" ),
166 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestCr0Fixed0 , "GuestCr0Fixed0" ),
167 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestCr0Fixed1 , "GuestCr0Fixed1" ),
168 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestCr0PgPe , "GuestCr0PgPe" ),
169 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestCr3 , "GuestCr3" ),
170 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestCr4Fixed0 , "GuestCr4Fixed0" ),
171 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestCr4Fixed1 , "GuestCr4Fixed1" ),
172 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestDebugCtl , "GuestDebugCtl" ),
173 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestDr7 , "GuestDr7" ),
174 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestEferMsr , "GuestEferMsr" ),
175 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestEferMsrRsvd , "GuestEferMsrRsvd" ),
176 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestGdtrBase , "GuestGdtrBase" ),
177 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestGdtrLimit , "GuestGdtrLimit" ),
178 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestIdtrBase , "GuestIdtrBase" ),
179 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestIdtrLimit , "GuestIdtrLimit" ),
180 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestIntStateEnclave , "GuestIntStateEnclave" ),
181 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestIntStateExtInt , "GuestIntStateExtInt" ),
182 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestIntStateNmi , "GuestIntStateNmi" ),
183 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestIntStateRFlagsSti , "GuestIntStateRFlagsSti" ),
184 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestIntStateRsvd , "GuestIntStateRsvd" ),
185 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestIntStateSmi , "GuestIntStateSmi" ),
186 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestIntStateStiMovSs , "GuestIntStateStiMovSs" ),
187 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestIntStateVirtNmi , "GuestIntStateVirtNmi" ),
188 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPae , "GuestPae" ),
189 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPatMsr , "GuestPatMsr" ),
190 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPcide , "GuestPcide" ),
191 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPdpteCr3ReadPhys , "GuestPdpteCr3ReadPhys" ),
192 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPdpte0Rsvd , "GuestPdpte0Rsvd" ),
193 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPdpte1Rsvd , "GuestPdpte1Rsvd" ),
194 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPdpte2Rsvd , "GuestPdpte2Rsvd" ),
195 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPdpte3Rsvd , "GuestPdpte3Rsvd" ),
196 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPndDbgXcptBsNoTf , "GuestPndDbgXcptBsNoTf" ),
197 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPndDbgXcptBsTf , "GuestPndDbgXcptBsTf" ),
198 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPndDbgXcptRsvd , "GuestPndDbgXcptRsvd" ),
199 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestPndDbgXcptRtm , "GuestPndDbgXcptRtm" ),
200 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestRip , "GuestRip" ),
201 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestRipRsvd , "GuestRipRsvd" ),
202 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestRFlagsIf , "GuestRFlagsIf" ),
203 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestRFlagsRsvd , "GuestRFlagsRsvd" ),
204 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestRFlagsVm , "GuestRFlagsVm" ),
205 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrCsDefBig , "GuestSegAttrCsDefBig" ),
206 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrCsDplEqSs , "GuestSegAttrCsDplEqSs" ),
207 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrCsDplLtSs , "GuestSegAttrCsDplLtSs" ),
208 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrCsDplZero , "GuestSegAttrCsDplZero" ),
209 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrCsType , "GuestSegAttrCsType" ),
210 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrCsTypeRead , "GuestSegAttrCsTypeRead" ),
211 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDescTypeCs , "GuestSegAttrDescTypeCs" ),
212 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDescTypeDs , "GuestSegAttrDescTypeDs" ),
213 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDescTypeEs , "GuestSegAttrDescTypeEs" ),
214 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDescTypeFs , "GuestSegAttrDescTypeFs" ),
215 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDescTypeGs , "GuestSegAttrDescTypeGs" ),
216 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDescTypeSs , "GuestSegAttrDescTypeSs" ),
217 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDplRplCs , "GuestSegAttrDplRplCs" ),
218 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDplRplDs , "GuestSegAttrDplRplDs" ),
219 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDplRplEs , "GuestSegAttrDplRplEs" ),
220 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDplRplFs , "GuestSegAttrDplRplFs" ),
221 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDplRplGs , "GuestSegAttrDplRplGs" ),
222 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrDplRplSs , "GuestSegAttrDplRplSs" ),
223 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrGranCs , "GuestSegAttrGranCs" ),
224 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrGranDs , "GuestSegAttrGranDs" ),
225 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrGranEs , "GuestSegAttrGranEs" ),
226 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrGranFs , "GuestSegAttrGranFs" ),
227 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrGranGs , "GuestSegAttrGranGs" ),
228 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrGranSs , "GuestSegAttrGranSs" ),
229 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrLdtrDescType , "GuestSegAttrLdtrDescType" ),
230 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrLdtrGran , "GuestSegAttrLdtrGran" ),
231 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrLdtrPresent , "GuestSegAttrLdtrPresent" ),
232 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrLdtrRsvd , "GuestSegAttrLdtrRsvd" ),
233 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrLdtrType , "GuestSegAttrLdtrType" ),
234 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrPresentCs , "GuestSegAttrPresentCs" ),
235 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrPresentDs , "GuestSegAttrPresentDs" ),
236 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrPresentEs , "GuestSegAttrPresentEs" ),
237 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrPresentFs , "GuestSegAttrPresentFs" ),
238 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrPresentGs , "GuestSegAttrPresentGs" ),
239 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrPresentSs , "GuestSegAttrPresentSs" ),
240 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrRsvdCs , "GuestSegAttrRsvdCs" ),
241 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrRsvdDs , "GuestSegAttrRsvdDs" ),
242 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrRsvdEs , "GuestSegAttrRsvdEs" ),
243 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrRsvdFs , "GuestSegAttrRsvdFs" ),
244 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrRsvdGs , "GuestSegAttrRsvdGs" ),
245 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrRsvdSs , "GuestSegAttrRsvdSs" ),
246 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrSsDplEqRpl , "GuestSegAttrSsDplEqRpl" ),
247 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrSsDplZero , "GuestSegAttrSsDplZero " ),
248 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrSsType , "GuestSegAttrSsType" ),
249 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTrDescType , "GuestSegAttrTrDescType" ),
250 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTrGran , "GuestSegAttrTrGran" ),
251 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTrPresent , "GuestSegAttrTrPresent" ),
252 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTrRsvd , "GuestSegAttrTrRsvd" ),
253 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTrType , "GuestSegAttrTrType" ),
254 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTrUnusable , "GuestSegAttrTrUnusable" ),
255 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTypeAccCs , "GuestSegAttrTypeAccCs" ),
256 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTypeAccDs , "GuestSegAttrTypeAccDs" ),
257 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTypeAccEs , "GuestSegAttrTypeAccEs" ),
258 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTypeAccFs , "GuestSegAttrTypeAccFs" ),
259 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTypeAccGs , "GuestSegAttrTypeAccGs" ),
260 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrTypeAccSs , "GuestSegAttrTypeAccSs" ),
261 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrV86Cs , "GuestSegAttrV86Cs" ),
262 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrV86Ds , "GuestSegAttrV86Ds" ),
263 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrV86Es , "GuestSegAttrV86Es" ),
264 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrV86Fs , "GuestSegAttrV86Fs" ),
265 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrV86Gs , "GuestSegAttrV86Gs" ),
266 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegAttrV86Ss , "GuestSegAttrV86Ss" ),
267 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseCs , "GuestSegBaseCs" ),
268 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseDs , "GuestSegBaseDs" ),
269 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseEs , "GuestSegBaseEs" ),
270 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseFs , "GuestSegBaseFs" ),
271 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseGs , "GuestSegBaseGs" ),
272 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseLdtr , "GuestSegBaseLdtr" ),
273 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseSs , "GuestSegBaseSs" ),
274 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseTr , "GuestSegBaseTr" ),
275 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseV86Cs , "GuestSegBaseV86Cs" ),
276 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseV86Ds , "GuestSegBaseV86Ds" ),
277 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseV86Es , "GuestSegBaseV86Es" ),
278 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseV86Fs , "GuestSegBaseV86Fs" ),
279 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseV86Gs , "GuestSegBaseV86Gs" ),
280 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegBaseV86Ss , "GuestSegBaseV86Ss" ),
281 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegLimitV86Cs , "GuestSegLimitV86Cs" ),
282 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegLimitV86Ds , "GuestSegLimitV86Ds" ),
283 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegLimitV86Es , "GuestSegLimitV86Es" ),
284 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegLimitV86Fs , "GuestSegLimitV86Fs" ),
285 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegLimitV86Gs , "GuestSegLimitV86Gs" ),
286 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegLimitV86Ss , "GuestSegLimitV86Ss" ),
287 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegSelCsSsRpl , "GuestSegSelCsSsRpl" ),
288 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegSelLdtr , "GuestSegSelLdtr" ),
289 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSegSelTr , "GuestSegSelTr" ),
290 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_GuestSysenterEspEip , "GuestSysenterEspEip" ),
291 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VmcsLinkPtrCurVmcs , "VmcsLinkPtrCurVmcs" ),
292 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VmcsLinkPtrReadPhys , "VmcsLinkPtrReadPhys" ),
293 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VmcsLinkPtrRevId , "VmcsLinkPtrRevId" ),
294 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VmcsLinkPtrShadow , "VmcsLinkPtrShadow" ),
295 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostCr0Fixed0 , "HostCr0Fixed0" ),
296 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostCr0Fixed1 , "HostCr0Fixed1" ),
297 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostCr3 , "HostCr3" ),
298 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostCr4Fixed0 , "HostCr4Fixed0" ),
299 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostCr4Fixed1 , "HostCr4Fixed1" ),
300 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostCr4Pae , "HostCr4Pae" ),
301 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostCr4Pcide , "HostCr4Pcide" ),
302 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostCsTr , "HostCsTr" ),
303 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostEferMsr , "HostEferMsr" ),
304 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostEferMsrRsvd , "HostEferMsrRsvd" ),
305 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostGuestLongMode , "HostGuestLongMode" ),
306 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostGuestLongModeNoCpu , "HostGuestLongModeNoCpu" ),
307 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostLongMode , "HostLongMode" ),
308 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostPatMsr , "HostPatMsr" ),
309 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostRip , "HostRip" ),
310 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostRipRsvd , "HostRipRsvd" ),
311 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostSel , "HostSel" ),
312 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostSegBase , "HostSegBase" ),
313 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostSs , "HostSs" ),
314 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_HostSysenterEspEip , "HostSysenterEspEip" ),
315 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_LongModeCS , "LongModeCS" ),
316 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_MsrBitmapPtrReadPhys , "MsrBitmapPtrReadPhys" ),
317 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_MsrLoad , "MsrLoad" ),
318 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_MsrLoadCount , "MsrLoadCount" ),
319 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_MsrLoadPtrReadPhys , "MsrLoadPtrReadPhys" ),
320 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_MsrLoadRing3 , "MsrLoadRing3" ),
321 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_MsrLoadRsvd , "MsrLoadRsvd" ),
322 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_NmiWindowExit , "NmiWindowExit" ),
323 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_PinCtlsAllowed1 , "PinCtlsAllowed1" ),
324 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_PinCtlsDisallowed0 , "PinCtlsDisallowed0" ),
325 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_ProcCtlsAllowed1 , "ProcCtlsAllowed1" ),
326 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_ProcCtlsDisallowed0 , "ProcCtlsDisallowed0" ),
327 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_ProcCtls2Allowed1 , "ProcCtls2Allowed1" ),
328 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_ProcCtls2Disallowed0 , "ProcCtls2Disallowed0" ),
329 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_PtrInvalid , "PtrInvalid" ),
330 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_PtrShadowVmcs , "PtrShadowVmcs" ),
331 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_RealOrV86Mode , "RealOrV86Mode" ),
332 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_SavePreemptTimer , "SavePreemptTimer" ),
333 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_TprThresholdRsvd , "TprThresholdRsvd" ),
334 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_TprThresholdVTpr , "TprThresholdVTpr" ),
335 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VirtApicPagePtrReadPhys , "VirtApicPageReadPhys" ),
336 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VirtIntDelivery , "VirtIntDelivery" ),
337 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VirtNmi , "VirtNmi" ),
338 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VirtX2ApicTprShadow , "VirtX2ApicTprShadow" ),
339 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VirtX2ApicVirtApic , "VirtX2ApicVirtApic" ),
340 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VmcsClear , "VmcsClear" ),
341 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VmcsLaunch , "VmcsLaunch" ),
342 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VmreadBitmapPtrReadPhys , "VmreadBitmapPtrReadPhys" ),
343 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VmwriteBitmapPtrReadPhys , "VmwriteBitmapPtrReadPhys" ),
344 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_VmxRoot , "VmxRoot" ),
345 VMXV_DIAG_DESC(kVmxVDiag_Vmentry_Vpid , "Vpid" ),
346 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_HostPdpteCr3ReadPhys , "HostPdpteCr3ReadPhys" ),
347 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_HostPdpte0Rsvd , "HostPdpte0Rsvd" ),
348 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_HostPdpte1Rsvd , "HostPdpte1Rsvd" ),
349 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_HostPdpte2Rsvd , "HostPdpte2Rsvd" ),
350 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_HostPdpte3Rsvd , "HostPdpte3Rsvd" ),
351 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_MsrLoad , "MsrLoad" ),
352 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_MsrLoadCount , "MsrLoadCount" ),
353 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_MsrLoadPtrReadPhys , "MsrLoadPtrReadPhys" ),
354 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_MsrLoadRing3 , "MsrLoadRing3" ),
355 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_MsrLoadRsvd , "MsrLoadRsvd" ),
356 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_MsrStore , "MsrStore" ),
357 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_MsrStoreCount , "MsrStoreCount" ),
358 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_MsrStorePtrWritePhys , "MsrStorePtrWritePhys" ),
359 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_MsrStoreRing3 , "MsrStoreRing3" ),
360 VMXV_DIAG_DESC(kVmxVDiag_Vmexit_MsrStoreRsvd , "MsrStoreRsvd" )
361 /* kVmxVDiag_End */
362};
363AssertCompile(RT_ELEMENTS(g_apszVmxVDiagDesc) == kVmxVDiag_End);
364#undef VMXV_DIAG_DESC
365
366
367/**
368 * Gets the descriptive name of a VMX instruction/VM-exit diagnostic code.
369 *
370 * @returns The descriptive string.
371 * @param enmDiag The VMX diagnostic.
372 */
373VMM_INT_DECL(const char *) HMGetVmxDiagDesc(VMXVDIAG enmDiag)
374{
375 if (RT_LIKELY((unsigned)enmDiag < RT_ELEMENTS(g_apszVmxVDiagDesc)))
376 return g_apszVmxVDiagDesc[enmDiag];
377 return "Unknown/invalid";
378}
379
380
381/**
382 * Gets the description for a VMX abort reason.
383 *
384 * @returns The descriptive string.
385 * @param enmAbort The VMX abort reason.
386 */
387VMM_INT_DECL(const char *) HMGetVmxAbortDesc(VMXABORT enmAbort)
388{
389 switch (enmAbort)
390 {
391 case VMXABORT_NONE: return "VMXABORT_NONE";
392 case VMXABORT_SAVE_GUEST_MSRS: return "VMXABORT_SAVE_GUEST_MSRS";
393 case VMXBOART_HOST_PDPTE: return "VMXBOART_HOST_PDPTE";
394 case VMXABORT_CURRENT_VMCS_CORRUPT: return "VMXABORT_CURRENT_VMCS_CORRUPT";
395 case VMXABORT_LOAD_HOST_MSR: return "VMXABORT_LOAD_HOST_MSR";
396 case VMXABORT_MACHINE_CHECK_XCPT: return "VMXABORT_MACHINE_CHECK_XCPT";
397 case VMXABORT_HOST_NOT_IN_LONG_MODE: return "VMXABORT_HOST_NOT_IN_LONG_MODE";
398 default:
399 break;
400 }
401 return "Unknown/invalid";
402}
403
404
405/**
406 * Gets the description for a virtual VMCS state.
407 *
408 * @returns The descriptive string.
409 * @param fVmcsState The virtual-VMCS state.
410 */
411VMM_INT_DECL(const char *) HMGetVmxVmcsStateDesc(uint8_t fVmcsState)
412{
413 switch (fVmcsState)
414 {
415 case VMX_V_VMCS_LAUNCH_STATE_CLEAR: return "Clear";
416 case VMX_V_VMCS_LAUNCH_STATE_LAUNCHED: return "Launched";
417 default: return "Unknown";
418 }
419}
420
421
422/**
423 * Gets the description for a VM-entry interruption information event type.
424 *
425 * @returns The descriptive string.
426 * @param uType The event type.
427 */
428VMM_INT_DECL(const char *) HMGetVmxEntryIntInfoTypeDesc(uint8_t uType)
429{
430 switch (uType)
431 {
432 case VMX_ENTRY_INT_INFO_TYPE_EXT_INT: return "External Interrupt";
433 case VMX_ENTRY_INT_INFO_TYPE_NMI: return "NMI";
434 case VMX_ENTRY_INT_INFO_TYPE_HW_XCPT: return "Hardware Exception";
435 case VMX_ENTRY_INT_INFO_TYPE_SW_INT: return "Software Interrupt";
436 case VMX_ENTRY_INT_INFO_TYPE_PRIV_SW_XCPT: return "Priv. Software Exception";
437 case VMX_ENTRY_INT_INFO_TYPE_SW_XCPT: return "Software Exception";
438 case VMX_ENTRY_INT_INFO_TYPE_OTHER_EVENT: return "Other Event";
439 default:
440 break;
441 }
442 return "Unknown/invalid";
443}
444
445
446/**
447 * Gets the description for a VM-exit interruption information event type.
448 *
449 * @returns The descriptive string.
450 * @param uType The event type.
451 */
452VMM_INT_DECL(const char *) HMGetVmxExitIntInfoTypeDesc(uint8_t uType)
453{
454 switch (uType)
455 {
456 case VMX_EXIT_INT_INFO_TYPE_EXT_INT: return "External Interrupt";
457 case VMX_EXIT_INT_INFO_TYPE_NMI: return "NMI";
458 case VMX_EXIT_INT_INFO_TYPE_HW_XCPT: return "Hardware Exception";
459 case VMX_EXIT_INT_INFO_TYPE_SW_INT: return "Software Interrupt";
460 case VMX_EXIT_INT_INFO_TYPE_PRIV_SW_XCPT: return "Priv. Software Exception";
461 case VMX_EXIT_INT_INFO_TYPE_SW_XCPT: return "Software Exception";
462 default:
463 break;
464 }
465 return "Unknown/invalid";
466}
467
468
469/**
470 * Gets the description for an IDT-vectoring information event type.
471 *
472 * @returns The descriptive string.
473 * @param uType The event type.
474 */
475VMM_INT_DECL(const char *) HMGetVmxIdtVectoringInfoTypeDesc(uint8_t uType)
476{
477 switch (uType)
478 {
479 case VMX_IDT_VECTORING_INFO_TYPE_EXT_INT: return "External Interrupt";
480 case VMX_IDT_VECTORING_INFO_TYPE_NMI: return "NMI";
481 case VMX_IDT_VECTORING_INFO_TYPE_HW_XCPT: return "Hardware Exception";
482 case VMX_IDT_VECTORING_INFO_TYPE_SW_INT: return "Software Interrupt";
483 case VMX_IDT_VECTORING_INFO_TYPE_PRIV_SW_XCPT: return "Priv. Software Exception";
484 case VMX_IDT_VECTORING_INFO_TYPE_SW_XCPT: return "Software Exception";
485 default:
486 break;
487 }
488 return "Unknown/invalid";
489}
490
491
492/**
493 * Checks if a code selector (CS) is suitable for execution using hardware-assisted
494 * VMX when unrestricted execution isn't available.
495 *
496 * @returns true if selector is suitable for VMX, otherwise
497 * false.
498 * @param pSel Pointer to the selector to check (CS).
499 * @param uStackDpl The CPL, aka the DPL of the stack segment.
500 */
501static bool hmVmxIsCodeSelectorOk(PCCPUMSELREG pSel, unsigned uStackDpl)
502{
503 /*
504 * Segment must be an accessed code segment, it must be present and it must
505 * be usable.
506 * Note! These are all standard requirements and if CS holds anything else
507 * we've got buggy code somewhere!
508 */
509 AssertCompile(X86DESCATTR_TYPE == 0xf);
510 AssertMsgReturn( (pSel->Attr.u & (X86_SEL_TYPE_ACCESSED | X86_SEL_TYPE_CODE | X86DESCATTR_DT | X86DESCATTR_P | X86DESCATTR_UNUSABLE))
511 == (X86_SEL_TYPE_ACCESSED | X86_SEL_TYPE_CODE | X86DESCATTR_DT | X86DESCATTR_P),
512 ("%#x\n", pSel->Attr.u),
513 false);
514
515 /* For conforming segments, CS.DPL must be <= SS.DPL, while CS.DPL
516 must equal SS.DPL for non-confroming segments.
517 Note! This is also a hard requirement like above. */
518 AssertMsgReturn( pSel->Attr.n.u4Type & X86_SEL_TYPE_CONF
519 ? pSel->Attr.n.u2Dpl <= uStackDpl
520 : pSel->Attr.n.u2Dpl == uStackDpl,
521 ("u4Type=%#x u2Dpl=%u uStackDpl=%u\n", pSel->Attr.n.u4Type, pSel->Attr.n.u2Dpl, uStackDpl),
522 false);
523
524 /*
525 * The following two requirements are VT-x specific:
526 * - G bit must be set if any high limit bits are set.
527 * - G bit must be clear if any low limit bits are clear.
528 */
529 if ( ((pSel->u32Limit & 0xfff00000) == 0x00000000 || pSel->Attr.n.u1Granularity)
530 && ((pSel->u32Limit & 0x00000fff) == 0x00000fff || !pSel->Attr.n.u1Granularity))
531 return true;
532 return false;
533}
534
535
536/**
537 * Checks if a data selector (DS/ES/FS/GS) is suitable for execution using
538 * hardware-assisted VMX when unrestricted execution isn't available.
539 *
540 * @returns true if selector is suitable for VMX, otherwise
541 * false.
542 * @param pSel Pointer to the selector to check
543 * (DS/ES/FS/GS).
544 */
545static bool hmVmxIsDataSelectorOk(PCCPUMSELREG pSel)
546{
547 /*
548 * Unusable segments are OK. These days they should be marked as such, as
549 * but as an alternative we for old saved states and AMD<->VT-x migration
550 * we also treat segments with all the attributes cleared as unusable.
551 */
552 if (pSel->Attr.n.u1Unusable || !pSel->Attr.u)
553 return true;
554
555 /** @todo tighten these checks. Will require CPUM load adjusting. */
556
557 /* Segment must be accessed. */
558 if (pSel->Attr.u & X86_SEL_TYPE_ACCESSED)
559 {
560 /* Code segments must also be readable. */
561 if ( !(pSel->Attr.u & X86_SEL_TYPE_CODE)
562 || (pSel->Attr.u & X86_SEL_TYPE_READ))
563 {
564 /* The S bit must be set. */
565 if (pSel->Attr.n.u1DescType)
566 {
567 /* Except for conforming segments, DPL >= RPL. */
568 if ( pSel->Attr.n.u2Dpl >= (pSel->Sel & X86_SEL_RPL)
569 || pSel->Attr.n.u4Type >= X86_SEL_TYPE_ER_ACC)
570 {
571 /* Segment must be present. */
572 if (pSel->Attr.n.u1Present)
573 {
574 /*
575 * The following two requirements are VT-x specific:
576 * - G bit must be set if any high limit bits are set.
577 * - G bit must be clear if any low limit bits are clear.
578 */
579 if ( ((pSel->u32Limit & 0xfff00000) == 0x00000000 || pSel->Attr.n.u1Granularity)
580 && ((pSel->u32Limit & 0x00000fff) == 0x00000fff || !pSel->Attr.n.u1Granularity))
581 return true;
582 }
583 }
584 }
585 }
586 }
587
588 return false;
589}
590
591
592/**
593 * Checks if the stack selector (SS) is suitable for execution using
594 * hardware-assisted VMX when unrestricted execution isn't available.
595 *
596 * @returns true if selector is suitable for VMX, otherwise
597 * false.
598 * @param pSel Pointer to the selector to check (SS).
599 */
600static bool hmVmxIsStackSelectorOk(PCCPUMSELREG pSel)
601{
602 /*
603 * Unusable segments are OK. These days they should be marked as such, as
604 * but as an alternative we for old saved states and AMD<->VT-x migration
605 * we also treat segments with all the attributes cleared as unusable.
606 */
607 /** @todo r=bird: actually all zeroes isn't gonna cut it... SS.DPL == CPL. */
608 if (pSel->Attr.n.u1Unusable || !pSel->Attr.u)
609 return true;
610
611 /*
612 * Segment must be an accessed writable segment, it must be present.
613 * Note! These are all standard requirements and if SS holds anything else
614 * we've got buggy code somewhere!
615 */
616 AssertCompile(X86DESCATTR_TYPE == 0xf);
617 AssertMsgReturn( (pSel->Attr.u & (X86_SEL_TYPE_ACCESSED | X86_SEL_TYPE_WRITE | X86DESCATTR_DT | X86DESCATTR_P | X86_SEL_TYPE_CODE))
618 == (X86_SEL_TYPE_ACCESSED | X86_SEL_TYPE_WRITE | X86DESCATTR_DT | X86DESCATTR_P),
619 ("%#x\n", pSel->Attr.u), false);
620
621 /*
622 * DPL must equal RPL. But in real mode or soon after enabling protected
623 * mode, it might not be.
624 */
625 if (pSel->Attr.n.u2Dpl == (pSel->Sel & X86_SEL_RPL))
626 {
627 /*
628 * The following two requirements are VT-x specific:
629 * - G bit must be set if any high limit bits are set.
630 * - G bit must be clear if any low limit bits are clear.
631 */
632 if ( ((pSel->u32Limit & 0xfff00000) == 0x00000000 || pSel->Attr.n.u1Granularity)
633 && ((pSel->u32Limit & 0x00000fff) == 0x00000fff || !pSel->Attr.n.u1Granularity))
634 return true;
635 }
636 return false;
637}
638
639
640/**
641 * Checks if the guest is in a suitable state for hardware-assisted VMX execution.
642 *
643 * @returns @c true if it is suitable, @c false otherwise.
644 * @param pVCpu The cross context virtual CPU structure.
645 * @param pCtx Pointer to the guest CPU context.
646 *
647 * @remarks @a pCtx can be a partial context and thus may not be necessarily the
648 * same as pVCpu->cpum.GstCtx! Thus don't eliminate the @a pCtx parameter.
649 * Secondly, if additional checks are added that require more of the CPU
650 * state, make sure REM (which supplies a partial state) is updated.
651 */
652VMM_INT_DECL(bool) HMCanExecuteVmxGuest(PVMCPU pVCpu, PCCPUMCTX pCtx)
653{
654 PVM pVM = pVCpu->CTX_SUFF(pVM);
655 Assert(HMIsEnabled(pVM));
656 Assert( ( pVM->hm.s.vmx.fUnrestrictedGuest && !pVM->hm.s.vmx.pRealModeTSS)
657 || (!pVM->hm.s.vmx.fUnrestrictedGuest && pVM->hm.s.vmx.pRealModeTSS));
658
659 pVCpu->hm.s.fActive = false;
660
661 bool const fSupportsRealMode = pVM->hm.s.vmx.fUnrestrictedGuest || PDMVmmDevHeapIsEnabled(pVM);
662 if (!pVM->hm.s.vmx.fUnrestrictedGuest)
663 {
664 /*
665 * The VMM device heap is a requirement for emulating real mode or protected mode without paging with the unrestricted
666 * guest execution feature is missing (VT-x only).
667 */
668 if (fSupportsRealMode)
669 {
670 if (CPUMIsGuestInRealModeEx(pCtx))
671 {
672 /*
673 * In V86 mode (VT-x or not), the CPU enforces real-mode compatible selector
674 * bases, limits, and attributes, i.e. limit must be 64K, base must be selector * 16,
675 * and attributes must be 0x9b for code and 0x93 for code segments.
676 * If this is not true, we cannot execute real mode as V86 and have to fall
677 * back to emulation.
678 */
679 if ( pCtx->cs.Sel != (pCtx->cs.u64Base >> 4)
680 || pCtx->ds.Sel != (pCtx->ds.u64Base >> 4)
681 || pCtx->es.Sel != (pCtx->es.u64Base >> 4)
682 || pCtx->ss.Sel != (pCtx->ss.u64Base >> 4)
683 || pCtx->fs.Sel != (pCtx->fs.u64Base >> 4)
684 || pCtx->gs.Sel != (pCtx->gs.u64Base >> 4))
685 {
686 STAM_COUNTER_INC(&pVCpu->hm.s.StatVmxCheckBadRmSelBase);
687 return false;
688 }
689 if ( (pCtx->cs.u32Limit != 0xffff)
690 || (pCtx->ds.u32Limit != 0xffff)
691 || (pCtx->es.u32Limit != 0xffff)
692 || (pCtx->ss.u32Limit != 0xffff)
693 || (pCtx->fs.u32Limit != 0xffff)
694 || (pCtx->gs.u32Limit != 0xffff))
695 {
696 STAM_COUNTER_INC(&pVCpu->hm.s.StatVmxCheckBadRmSelLimit);
697 return false;
698 }
699 if ( (pCtx->cs.Attr.u != 0x9b)
700 || (pCtx->ds.Attr.u != 0x93)
701 || (pCtx->es.Attr.u != 0x93)
702 || (pCtx->ss.Attr.u != 0x93)
703 || (pCtx->fs.Attr.u != 0x93)
704 || (pCtx->gs.Attr.u != 0x93))
705 {
706 STAM_COUNTER_INC(&pVCpu->hm.s.StatVmxCheckBadRmSelAttr);
707 return false;
708 }
709 STAM_COUNTER_INC(&pVCpu->hm.s.StatVmxCheckRmOk);
710 }
711 else
712 {
713 /*
714 * Verify the requirements for executing code in protected mode. VT-x can't
715 * handle the CPU state right after a switch from real to protected mode
716 * (all sorts of RPL & DPL assumptions).
717 */
718 if (pVCpu->hm.s.vmx.fWasInRealMode)
719 {
720 if (!CPUMIsGuestInV86ModeEx(pCtx))
721 {
722 /* The guest switched to protected mode, check if the state is suitable for VT-x. */
723 if ((pCtx->cs.Sel & X86_SEL_RPL) != (pCtx->ss.Sel & X86_SEL_RPL))
724 {
725 STAM_COUNTER_INC(&pVCpu->hm.s.StatVmxCheckBadRpl);
726 return false;
727 }
728 if ( !hmVmxIsCodeSelectorOk(&pCtx->cs, pCtx->ss.Attr.n.u2Dpl)
729 || !hmVmxIsDataSelectorOk(&pCtx->ds)
730 || !hmVmxIsDataSelectorOk(&pCtx->es)
731 || !hmVmxIsDataSelectorOk(&pCtx->fs)
732 || !hmVmxIsDataSelectorOk(&pCtx->gs)
733 || !hmVmxIsStackSelectorOk(&pCtx->ss))
734 {
735 STAM_COUNTER_INC(&pVCpu->hm.s.StatVmxCheckBadSel);
736 return false;
737 }
738 }
739 else
740 {
741 /* The guest switched to V86 mode, check if the state is suitable for VT-x. */
742 if ( pCtx->cs.Sel != (pCtx->cs.u64Base >> 4)
743 || pCtx->ds.Sel != (pCtx->ds.u64Base >> 4)
744 || pCtx->es.Sel != (pCtx->es.u64Base >> 4)
745 || pCtx->ss.Sel != (pCtx->ss.u64Base >> 4)
746 || pCtx->fs.Sel != (pCtx->fs.u64Base >> 4)
747 || pCtx->gs.Sel != (pCtx->gs.u64Base >> 4))
748 {
749 STAM_COUNTER_INC(&pVCpu->hm.s.StatVmxCheckBadV86SelBase);
750 return false;
751 }
752 if ( (pCtx->cs.u32Limit != 0xffff)
753 || (pCtx->ds.u32Limit != 0xffff)
754 || (pCtx->es.u32Limit != 0xffff)
755 || (pCtx->ss.u32Limit != 0xffff)
756 || (pCtx->fs.u32Limit != 0xffff)
757 || (pCtx->gs.u32Limit != 0xffff))
758 {
759 STAM_COUNTER_INC(&pVCpu->hm.s.StatVmxCheckBadV86SelLimit);
760 return false;
761 }
762 if ( (pCtx->cs.Attr.u != 0xf3)
763 || (pCtx->ds.Attr.u != 0xf3)
764 || (pCtx->es.Attr.u != 0xf3)
765 || (pCtx->ss.Attr.u != 0xf3)
766 || (pCtx->fs.Attr.u != 0xf3)
767 || (pCtx->gs.Attr.u != 0xf3))
768 {
769 STAM_COUNTER_INC(&pVCpu->hm.s.StatVmxCheckBadV86SelAttr);
770 return false;
771 }
772 }
773 }
774 }
775 }
776 else
777 {
778 if (!CPUMIsGuestInLongModeEx(pCtx))
779 {
780 if ( !pVM->hm.s.fNestedPaging /* Requires a fake PD for real *and* protected mode without paging - stored in the VMM device heap */
781 || CPUMIsGuestInRealModeEx(pCtx)) /* Requires a fake TSS for real mode - stored in the VMM device heap */
782 return false;
783
784 /* Too early for VT-x; Solaris guests will fail with a guru meditation otherwise; same for XP. */
785 if (pCtx->idtr.pIdt == 0 || pCtx->idtr.cbIdt == 0 || pCtx->tr.Sel == 0)
786 return false;
787
788 /*
789 * The guest is about to complete the switch to protected mode. Wait a bit longer.
790 * Windows XP; switch to protected mode; all selectors are marked not present
791 * in the hidden registers (possible recompiler bug; see load_seg_vm).
792 */
793 /** @todo Is this supposed recompiler bug still relevant with IEM? */
794 if (pCtx->cs.Attr.n.u1Present == 0)
795 return false;
796 if (pCtx->ss.Attr.n.u1Present == 0)
797 return false;
798
799 /*
800 * Windows XP: possible same as above, but new recompiler requires new
801 * heuristics? VT-x doesn't seem to like something about the guest state and
802 * this stuff avoids it.
803 */
804 /** @todo This check is actually wrong, it doesn't take the direction of the
805 * stack segment into account. But, it does the job for now. */
806 if (pCtx->rsp >= pCtx->ss.u32Limit)
807 return false;
808 }
809 }
810 }
811
812 if (pVM->hm.s.vmx.fEnabled)
813 {
814 uint32_t uCr0Mask;
815
816 /* If bit N is set in cr0_fixed0, then it must be set in the guest's cr0. */
817 uCr0Mask = (uint32_t)pVM->hm.s.vmx.Msrs.u64Cr0Fixed0;
818
819 /* We ignore the NE bit here on purpose; see HMR0.cpp for details. */
820 uCr0Mask &= ~X86_CR0_NE;
821
822 if (fSupportsRealMode)
823 {
824 /* We ignore the PE & PG bits here on purpose; we emulate real and protected mode without paging. */
825 uCr0Mask &= ~(X86_CR0_PG | X86_CR0_PE);
826 }
827 else
828 {
829 /* We support protected mode without paging using identity mapping. */
830 uCr0Mask &= ~X86_CR0_PG;
831 }
832 if ((pCtx->cr0 & uCr0Mask) != uCr0Mask)
833 return false;
834
835 /* If bit N is cleared in cr0_fixed1, then it must be zero in the guest's cr0. */
836 uCr0Mask = (uint32_t)~pVM->hm.s.vmx.Msrs.u64Cr0Fixed1;
837 if ((pCtx->cr0 & uCr0Mask) != 0)
838 return false;
839
840 /* If bit N is set in cr4_fixed0, then it must be set in the guest's cr4. */
841 uCr0Mask = (uint32_t)pVM->hm.s.vmx.Msrs.u64Cr4Fixed0;
842 uCr0Mask &= ~X86_CR4_VMXE;
843 if ((pCtx->cr4 & uCr0Mask) != uCr0Mask)
844 return false;
845
846 /* If bit N is cleared in cr4_fixed1, then it must be zero in the guest's cr4. */
847 uCr0Mask = (uint32_t)~pVM->hm.s.vmx.Msrs.u64Cr4Fixed1;
848 if ((pCtx->cr4 & uCr0Mask) != 0)
849 return false;
850
851 pVCpu->hm.s.fActive = true;
852 return true;
853 }
854
855 return false;
856}
857
858
859/**
860 * Gets the permission bits for the specified MSR in the specified MSR bitmap.
861 *
862 * @returns VBox status code.
863 * @param pvMsrBitmap Pointer to the MSR bitmap.
864 * @param idMsr The MSR.
865 * @param penmRead Where to store the read permissions. Optional, can be
866 * NULL.
867 * @param penmWrite Where to store the write permissions. Optional, can be
868 * NULL.
869 */
870VMM_INT_DECL(int) HMGetVmxMsrPermission(void const *pvMsrBitmap, uint32_t idMsr, PVMXMSREXITREAD penmRead,
871 PVMXMSREXITWRITE penmWrite)
872{
873 AssertPtrReturn(pvMsrBitmap, VERR_INVALID_PARAMETER);
874
875 int32_t iBit;
876 uint8_t const *pbMsrBitmap = (uint8_t *)pvMsrBitmap;
877
878 /*
879 * MSR Layout:
880 * Byte index MSR range Interpreted as
881 * 0x000 - 0x3ff 0x00000000 - 0x00001fff Low MSR read bits.
882 * 0x400 - 0x7ff 0xc0000000 - 0xc0001fff High MSR read bits.
883 * 0x800 - 0xbff 0x00000000 - 0x00001fff Low MSR write bits.
884 * 0xc00 - 0xfff 0xc0000000 - 0xc0001fff High MSR write bits.
885 *
886 * A bit corresponding to an MSR within the above range causes a VM-exit
887 * if the bit is 1 on executions of RDMSR/WRMSR.
888 *
889 * If an MSR falls out of the MSR range, it always cause a VM-exit.
890 *
891 * See Intel spec. 24.6.9 "MSR-Bitmap Address".
892 */
893 if (idMsr <= 0x00001fff)
894 iBit = idMsr;
895 else if ( idMsr >= 0xc0000000
896 && idMsr <= 0xc0001fff)
897 {
898 iBit = (idMsr - 0xc0000000);
899 pbMsrBitmap += 0x400;
900 }
901 else
902 {
903 if (penmRead)
904 *penmRead = VMXMSREXIT_INTERCEPT_READ;
905 if (penmWrite)
906 *penmWrite = VMXMSREXIT_INTERCEPT_WRITE;
907 Log(("CPUMVmxGetMsrPermission: Warning! Out of range MSR %#RX32\n", idMsr));
908 return VINF_SUCCESS;
909 }
910
911 /* Validate the MSR bit position. */
912 Assert(iBit <= 0x1fff);
913
914 /* Get the MSR read permissions. */
915 if (penmRead)
916 {
917 if (ASMBitTest(pbMsrBitmap, iBit))
918 *penmRead = VMXMSREXIT_INTERCEPT_READ;
919 else
920 *penmRead = VMXMSREXIT_PASSTHRU_READ;
921 }
922
923 /* Get the MSR write permissions. */
924 if (penmWrite)
925 {
926 if (ASMBitTest(pbMsrBitmap + 0x800, iBit))
927 *penmWrite = VMXMSREXIT_INTERCEPT_WRITE;
928 else
929 *penmWrite = VMXMSREXIT_PASSTHRU_WRITE;
930 }
931
932 return VINF_SUCCESS;
933}
934
935
936/**
937 * Gets the permission bits for the specified I/O port from the given I/O bitmaps.
938 *
939 * @returns @c true if the I/O port access must cause a VM-exit, @c false otherwise.
940 * @param pvIoBitmapA Pointer to I/O bitmap A.
941 * @param pvIoBitmapB Pointer to I/O bitmap B.
942 * @param uPort The I/O port being accessed.
943 * @param cbAccess The size of the I/O access in bytes (1, 2 or 4 bytes).
944 */
945VMM_INT_DECL(bool) HMGetVmxIoBitmapPermission(void const *pvIoBitmapA, void const *pvIoBitmapB, uint16_t uPort,
946 uint8_t cbAccess)
947{
948 Assert(cbAccess == 1 || cbAccess == 2 || cbAccess == 4);
949
950 /*
951 * If the I/O port access wraps around the 16-bit port I/O space,
952 * we must cause a VM-exit.
953 *
954 * See Intel spec. 25.1.3 "Instructions That Cause VM Exits Conditionally".
955 */
956 /** @todo r=ramshankar: Reading 1, 2, 4 bytes at ports 0xffff, 0xfffe and 0xfffc
957 * respectively are valid and do not constitute a wrap around from what I
958 * understand. Verify this later. */
959 uint32_t const uPortLast = uPort + cbAccess;
960 if (uPortLast > 0x10000)
961 return true;
962
963 /* Read the appropriate bit from the corresponding IO bitmap. */
964 void const *pvIoBitmap = uPort < 0x8000 ? pvIoBitmapA : pvIoBitmapB;
965 return ASMBitTest(pvIoBitmap, uPort);
966}
967
968
969/**
970 * Dumps the virtual VMCS state to the release log.
971 *
972 * @param pVCpu The cross context virtual CPU structure.
973 */
974VMM_INT_DECL(void) HMDumpHwvirtVmxState(PVMCPU pVCpu)
975{
976#ifndef IN_RC
977 /* The string width of -4 used in the macros below to cover 'LDTR', 'GDTR', 'IDTR. */
978# define HMVMX_DUMP_HOST_XDTR(a_pVmcs, a_Seg, a_SegName, a_pszPrefix) \
979 do { \
980 LogRel((" %s%-4s = {base=%016RX64}\n", \
981 (a_pszPrefix), (a_SegName), (a_pVmcs)->u64Host##a_Seg##Base.u)); \
982 } while (0)
983# define HMVMX_DUMP_HOST_FS_GS_TR(a_pVmcs, a_Seg, a_SegName, a_pszPrefix) \
984 do { \
985 LogRel((" %s%-4s = {%04x base=%016RX64}\n", \
986 (a_pszPrefix), (a_SegName), (a_pVmcs)->Host##a_Seg, (a_pVmcs)->u64Host##a_Seg##Base.u)); \
987 } while (0)
988# define HMVMX_DUMP_GUEST_SEGREG(a_pVmcs, a_Seg, a_SegName, a_pszPrefix) \
989 do { \
990 LogRel((" %s%-4s = {%04x base=%016RX64 limit=%08x flags=%04x}\n", \
991 (a_pszPrefix), (a_SegName), (a_pVmcs)->Guest##a_Seg, (a_pVmcs)->u64Guest##a_Seg##Base.u, \
992 (a_pVmcs)->u32Guest##a_Seg##Limit, (a_pVmcs)->u32Guest##a_Seg##Attr)); \
993 } while (0)
994# define HMVMX_DUMP_GUEST_XDTR(a_pVmcs, a_Seg, a_SegName, a_pszPrefix) \
995 do { \
996 LogRel((" %s%-4s = {base=%016RX64 limit=%08x}\n", \
997 (a_pszPrefix), (a_SegName), (a_pVmcs)->u64Guest##a_Seg##Base.u, (a_pVmcs)->u32Guest##a_Seg##Limit)); \
998 } while (0)
999
1000 PCCPUMCTX pCtx = &pVCpu->cpum.GstCtx;
1001 PCVMXVVMCS pVmcs = pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs);
1002 if (!pVmcs)
1003 {
1004 LogRel(("Virtual VMCS not allocated\n"));
1005 return;
1006 }
1007 LogRel(("GCPhysVmxon = %#RGp\n", pCtx->hwvirt.vmx.GCPhysVmxon));
1008 LogRel(("GCPhysVmcs = %#RGp\n", pCtx->hwvirt.vmx.GCPhysVmcs));
1009 LogRel(("GCPhysShadowVmcs = %#RGp\n", pCtx->hwvirt.vmx.GCPhysShadowVmcs));
1010 LogRel(("enmDiag = %u (%s)\n", pCtx->hwvirt.vmx.enmDiag, HMGetVmxDiagDesc(pCtx->hwvirt.vmx.enmDiag)));
1011 LogRel(("enmAbort = %u (%s)\n", pCtx->hwvirt.vmx.enmAbort, HMGetVmxAbortDesc(pCtx->hwvirt.vmx.enmAbort)));
1012 LogRel(("uAbortAux = %u (%#x)\n", pCtx->hwvirt.vmx.uAbortAux, pCtx->hwvirt.vmx.uAbortAux));
1013 LogRel(("fInVmxRootMode = %RTbool\n", pCtx->hwvirt.vmx.fInVmxRootMode));
1014 LogRel(("fInVmxNonRootMode = %RTbool\n", pCtx->hwvirt.vmx.fInVmxNonRootMode));
1015 LogRel(("fInterceptEvents = %RTbool\n", pCtx->hwvirt.vmx.fInterceptEvents));
1016 LogRel(("fNmiUnblockingIret = %RTbool\n", pCtx->hwvirt.vmx.fNmiUnblockingIret));
1017 LogRel(("uFirstPauseLoopTick = %RX64\n", pCtx->hwvirt.vmx.uFirstPauseLoopTick));
1018 LogRel(("uPrevPauseTick = %RX64\n", pCtx->hwvirt.vmx.uPrevPauseTick));
1019 LogRel(("uVmentryTick = %RX64\n", pCtx->hwvirt.vmx.uVmentryTick));
1020 LogRel(("offVirtApicWrite = %#RX16\n", pCtx->hwvirt.vmx.offVirtApicWrite));
1021 LogRel(("VMCS cache:\n"));
1022
1023 const char *pszPrefix = " ";
1024 /* Header. */
1025 {
1026 LogRel(("%sHeader:\n", pszPrefix));
1027 LogRel((" %sVMCS revision id = %#RX32\n", pszPrefix, pVmcs->u32VmcsRevId));
1028 LogRel((" %sVMX-abort id = %#RX32 (%s)\n", pszPrefix, pVmcs->enmVmxAbort, HMGetVmxAbortDesc(pVmcs->enmVmxAbort)));
1029 LogRel((" %sVMCS state = %#x (%s)\n", pszPrefix, pVmcs->fVmcsState, HMGetVmxVmcsStateDesc(pVmcs->fVmcsState)));
1030 }
1031
1032 /* Control fields. */
1033 {
1034 /* 16-bit. */
1035 LogRel(("%sControl:\n", pszPrefix));
1036 LogRel((" %sVPID = %#RX16\n", pszPrefix, pVmcs->u16Vpid));
1037 LogRel((" %sPosted intr notify vector = %#RX16\n", pszPrefix, pVmcs->u16PostIntNotifyVector));
1038 LogRel((" %sEPTP index = %#RX16\n", pszPrefix, pVmcs->u16EptpIndex));
1039
1040 /* 32-bit. */
1041 LogRel((" %sPinCtls = %#RX32\n", pszPrefix, pVmcs->u32PinCtls));
1042 LogRel((" %sProcCtls = %#RX32\n", pszPrefix, pVmcs->u32ProcCtls));
1043 LogRel((" %sProcCtls2 = %#RX32\n", pszPrefix, pVmcs->u32ProcCtls2));
1044 LogRel((" %sExitCtls = %#RX32\n", pszPrefix, pVmcs->u32ExitCtls));
1045 LogRel((" %sEntryCtls = %#RX32\n", pszPrefix, pVmcs->u32EntryCtls));
1046 LogRel((" %sException bitmap = %#RX32\n", pszPrefix, pVmcs->u32XcptBitmap));
1047 LogRel((" %sPage-fault mask = %#RX32\n", pszPrefix, pVmcs->u32XcptPFMask));
1048 LogRel((" %sPage-fault match = %#RX32\n", pszPrefix, pVmcs->u32XcptPFMatch));
1049 LogRel((" %sCR3-target count = %RU32\n", pszPrefix, pVmcs->u32Cr3TargetCount));
1050 LogRel((" %sVM-exit MSR store count = %RU32\n", pszPrefix, pVmcs->u32ExitMsrStoreCount));
1051 LogRel((" %sVM-exit MSR load count = %RU32\n", pszPrefix, pVmcs->u32ExitMsrLoadCount));
1052 LogRel((" %sVM-entry MSR load count = %RU32\n", pszPrefix, pVmcs->u32EntryMsrLoadCount));
1053 LogRel((" %sVM-entry interruption info = %#RX32\n", pszPrefix, pVmcs->u32EntryIntInfo));
1054 {
1055 uint32_t const fInfo = pVmcs->u32EntryIntInfo;
1056 uint8_t const uType = VMX_ENTRY_INT_INFO_TYPE(fInfo);
1057 LogRel((" %sValid = %RTbool\n", pszPrefix, VMX_ENTRY_INT_INFO_IS_VALID(fInfo)));
1058 LogRel((" %sType = %#x (%s)\n", pszPrefix, uType, HMGetVmxEntryIntInfoTypeDesc(uType)));
1059 LogRel((" %sVector = %#x\n", pszPrefix, VMX_ENTRY_INT_INFO_VECTOR(fInfo)));
1060 LogRel((" %sNMI-unblocking-IRET = %RTbool\n", pszPrefix, VMX_ENTRY_INT_INFO_IS_NMI_UNBLOCK_IRET(fInfo)));
1061 LogRel((" %sError-code valid = %RTbool\n", pszPrefix, VMX_ENTRY_INT_INFO_IS_ERROR_CODE_VALID(fInfo)));
1062 }
1063 LogRel((" %sVM-entry xcpt error-code = %#RX32\n", pszPrefix, pVmcs->u32EntryXcptErrCode));
1064 LogRel((" %sVM-entry instruction len = %u bytes\n", pszPrefix, pVmcs->u32EntryInstrLen));
1065 LogRel((" %sTPR threshold = %#RX32\n", pszPrefix, pVmcs->u32TprThreshold));
1066 LogRel((" %sPLE gap = %#RX32\n", pszPrefix, pVmcs->u32PleGap));
1067 LogRel((" %sPLE window = %#RX32\n", pszPrefix, pVmcs->u32PleWindow));
1068
1069 /* 64-bit. */
1070 LogRel((" %sIO-bitmap A addr = %#RX64\n", pszPrefix, pVmcs->u64AddrIoBitmapA.u));
1071 LogRel((" %sIO-bitmap B addr = %#RX64\n", pszPrefix, pVmcs->u64AddrIoBitmapB.u));
1072 LogRel((" %sMSR-bitmap addr = %#RX64\n", pszPrefix, pVmcs->u64AddrMsrBitmap.u));
1073 LogRel((" %sVM-exit MSR store addr = %#RX64\n", pszPrefix, pVmcs->u64AddrExitMsrStore.u));
1074 LogRel((" %sVM-exit MSR load addr = %#RX64\n", pszPrefix, pVmcs->u64AddrExitMsrLoad.u));
1075 LogRel((" %sVM-entry MSR load addr = %#RX64\n", pszPrefix, pVmcs->u64AddrEntryMsrLoad.u));
1076 LogRel((" %sExecutive VMCS ptr = %#RX64\n", pszPrefix, pVmcs->u64ExecVmcsPtr.u));
1077 LogRel((" %sPML addr = %#RX64\n", pszPrefix, pVmcs->u64AddrPml.u));
1078 LogRel((" %sTSC offset = %#RX64\n", pszPrefix, pVmcs->u64TscOffset.u));
1079 LogRel((" %sVirtual-APIC addr = %#RX64\n", pszPrefix, pVmcs->u64AddrVirtApic.u));
1080 LogRel((" %sAPIC-access addr = %#RX64\n", pszPrefix, pVmcs->u64AddrApicAccess.u));
1081 LogRel((" %sPosted-intr desc addr = %#RX64\n", pszPrefix, pVmcs->u64AddrPostedIntDesc.u));
1082 LogRel((" %sVM-functions control = %#RX64\n", pszPrefix, pVmcs->u64VmFuncCtls.u));
1083 LogRel((" %sEPTP ptr = %#RX64\n", pszPrefix, pVmcs->u64EptpPtr.u));
1084 LogRel((" %sEOI-exit bitmap 0 addr = %#RX64\n", pszPrefix, pVmcs->u64EoiExitBitmap0.u));
1085 LogRel((" %sEOI-exit bitmap 1 addr = %#RX64\n", pszPrefix, pVmcs->u64EoiExitBitmap1.u));
1086 LogRel((" %sEOI-exit bitmap 2 addr = %#RX64\n", pszPrefix, pVmcs->u64EoiExitBitmap2.u));
1087 LogRel((" %sEOI-exit bitmap 3 addr = %#RX64\n", pszPrefix, pVmcs->u64EoiExitBitmap3.u));
1088 LogRel((" %sEPTP-list addr = %#RX64\n", pszPrefix, pVmcs->u64AddrEptpList.u));
1089 LogRel((" %sVMREAD-bitmap addr = %#RX64\n", pszPrefix, pVmcs->u64AddrVmreadBitmap.u));
1090 LogRel((" %sVMWRITE-bitmap addr = %#RX64\n", pszPrefix, pVmcs->u64AddrVmwriteBitmap.u));
1091 LogRel((" %sVirt-Xcpt info addr = %#RX64\n", pszPrefix, pVmcs->u64AddrXcptVeInfo.u));
1092 LogRel((" %sXSS-bitmap = %#RX64\n", pszPrefix, pVmcs->u64XssBitmap.u));
1093 LogRel((" %sENCLS-exiting bitmap addr = %#RX64\n", pszPrefix, pVmcs->u64AddrEnclsBitmap.u));
1094 LogRel((" %sTSC multiplier = %#RX64\n", pszPrefix, pVmcs->u64TscMultiplier.u));
1095
1096 /* Natural width. */
1097 LogRel((" %sCR0 guest/host mask = %#RX64\n", pszPrefix, pVmcs->u64Cr0Mask.u));
1098 LogRel((" %sCR4 guest/host mask = %#RX64\n", pszPrefix, pVmcs->u64Cr4Mask.u));
1099 LogRel((" %sCR0 read shadow = %#RX64\n", pszPrefix, pVmcs->u64Cr0ReadShadow.u));
1100 LogRel((" %sCR4 read shadow = %#RX64\n", pszPrefix, pVmcs->u64Cr4ReadShadow.u));
1101 LogRel((" %sCR3-target 0 = %#RX64\n", pszPrefix, pVmcs->u64Cr3Target0.u));
1102 LogRel((" %sCR3-target 1 = %#RX64\n", pszPrefix, pVmcs->u64Cr3Target1.u));
1103 LogRel((" %sCR3-target 2 = %#RX64\n", pszPrefix, pVmcs->u64Cr3Target2.u));
1104 LogRel((" %sCR3-target 3 = %#RX64\n", pszPrefix, pVmcs->u64Cr3Target3.u));
1105 }
1106
1107 /* Guest state. */
1108 {
1109 LogRel(("%sGuest state:\n", pszPrefix));
1110
1111 /* 16-bit. */
1112 HMVMX_DUMP_GUEST_SEGREG(pVmcs, Cs, "cs", pszPrefix);
1113 HMVMX_DUMP_GUEST_SEGREG(pVmcs, Ss, "ss", pszPrefix);
1114 HMVMX_DUMP_GUEST_SEGREG(pVmcs, Es, "es", pszPrefix);
1115 HMVMX_DUMP_GUEST_SEGREG(pVmcs, Ds, "ds", pszPrefix);
1116 HMVMX_DUMP_GUEST_SEGREG(pVmcs, Fs, "fs", pszPrefix);
1117 HMVMX_DUMP_GUEST_SEGREG(pVmcs, Gs, "gs", pszPrefix);
1118 HMVMX_DUMP_GUEST_SEGREG(pVmcs, Ldtr, "ldtr", pszPrefix);
1119 HMVMX_DUMP_GUEST_SEGREG(pVmcs, Tr, "tr", pszPrefix);
1120 HMVMX_DUMP_GUEST_XDTR( pVmcs, Gdtr, "gdtr", pszPrefix);
1121 HMVMX_DUMP_GUEST_XDTR( pVmcs, Idtr, "idtr", pszPrefix);
1122 LogRel((" %sInterrupt status = %#RX16\n", pszPrefix, pVmcs->u16GuestIntStatus));
1123 LogRel((" %sPML index = %#RX16\n", pszPrefix, pVmcs->u16PmlIndex));
1124
1125 /* 32-bit. */
1126 LogRel((" %sInterruptibility state = %#RX32\n", pszPrefix, pVmcs->u32GuestIntrState));
1127 LogRel((" %sActivity state = %#RX32\n", pszPrefix, pVmcs->u32GuestActivityState));
1128 LogRel((" %sSMBASE = %#RX32\n", pszPrefix, pVmcs->u32GuestSmBase));
1129 LogRel((" %sSysEnter CS = %#RX32\n", pszPrefix, pVmcs->u32GuestSysenterCS));
1130 LogRel((" %sVMX-preemption timer value = %#RX32\n", pszPrefix, pVmcs->u32PreemptTimer));
1131
1132 /* 64-bit. */
1133 LogRel((" %sVMCS link ptr = %#RX64\n", pszPrefix, pVmcs->u64VmcsLinkPtr.u));
1134 LogRel((" %sDBGCTL = %#RX64\n", pszPrefix, pVmcs->u64GuestDebugCtlMsr.u));
1135 LogRel((" %sPAT = %#RX64\n", pszPrefix, pVmcs->u64GuestPatMsr.u));
1136 LogRel((" %sEFER = %#RX64\n", pszPrefix, pVmcs->u64GuestEferMsr.u));
1137 LogRel((" %sPERFGLOBALCTRL = %#RX64\n", pszPrefix, pVmcs->u64GuestPerfGlobalCtlMsr.u));
1138 LogRel((" %sPDPTE 0 = %#RX64\n", pszPrefix, pVmcs->u64GuestPdpte0.u));
1139 LogRel((" %sPDPTE 1 = %#RX64\n", pszPrefix, pVmcs->u64GuestPdpte1.u));
1140 LogRel((" %sPDPTE 2 = %#RX64\n", pszPrefix, pVmcs->u64GuestPdpte2.u));
1141 LogRel((" %sPDPTE 3 = %#RX64\n", pszPrefix, pVmcs->u64GuestPdpte3.u));
1142 LogRel((" %sBNDCFGS = %#RX64\n", pszPrefix, pVmcs->u64GuestBndcfgsMsr.u));
1143
1144 /* Natural width. */
1145 LogRel((" %scr0 = %#RX64\n", pszPrefix, pVmcs->u64GuestCr0.u));
1146 LogRel((" %scr3 = %#RX64\n", pszPrefix, pVmcs->u64GuestCr3.u));
1147 LogRel((" %scr4 = %#RX64\n", pszPrefix, pVmcs->u64GuestCr4.u));
1148 LogRel((" %sdr7 = %#RX64\n", pszPrefix, pVmcs->u64GuestDr7.u));
1149 LogRel((" %srsp = %#RX64\n", pszPrefix, pVmcs->u64GuestRsp.u));
1150 LogRel((" %srip = %#RX64\n", pszPrefix, pVmcs->u64GuestRip.u));
1151 LogRel((" %srflags = %#RX64\n", pszPrefix, pVmcs->u64GuestRFlags.u));
1152 LogRel((" %sPending debug xcpts = %#RX64\n", pszPrefix, pVmcs->u64GuestPendingDbgXcpt.u));
1153 LogRel((" %sSysEnter ESP = %#RX64\n", pszPrefix, pVmcs->u64GuestSysenterEsp.u));
1154 LogRel((" %sSysEnter EIP = %#RX64\n", pszPrefix, pVmcs->u64GuestSysenterEip.u));
1155 }
1156
1157 /* Host state. */
1158 {
1159 LogRel(("%sHost state:\n", pszPrefix));
1160
1161 /* 16-bit. */
1162 LogRel((" %scs = %#RX16\n", pszPrefix, pVmcs->HostCs));
1163 LogRel((" %sss = %#RX16\n", pszPrefix, pVmcs->HostSs));
1164 LogRel((" %sds = %#RX16\n", pszPrefix, pVmcs->HostDs));
1165 LogRel((" %ses = %#RX16\n", pszPrefix, pVmcs->HostEs));
1166 HMVMX_DUMP_HOST_FS_GS_TR(pVmcs, Fs, "fs", pszPrefix);
1167 HMVMX_DUMP_HOST_FS_GS_TR(pVmcs, Gs, "gs", pszPrefix);
1168 HMVMX_DUMP_HOST_FS_GS_TR(pVmcs, Tr, "tr", pszPrefix);
1169 HMVMX_DUMP_HOST_XDTR(pVmcs, Gdtr, "gdtr", pszPrefix);
1170 HMVMX_DUMP_HOST_XDTR(pVmcs, Idtr, "idtr", pszPrefix);
1171
1172 /* 32-bit. */
1173 LogRel((" %sSysEnter CS = %#RX32\n", pszPrefix, pVmcs->u32HostSysenterCs));
1174
1175 /* 64-bit. */
1176 LogRel((" %sEFER = %#RX64\n", pszPrefix, pVmcs->u64HostEferMsr.u));
1177 LogRel((" %sPAT = %#RX64\n", pszPrefix, pVmcs->u64HostPatMsr.u));
1178 LogRel((" %sPERFGLOBALCTRL = %#RX64\n", pszPrefix, pVmcs->u64HostPerfGlobalCtlMsr.u));
1179
1180 /* Natural width. */
1181 LogRel((" %scr0 = %#RX64\n", pszPrefix, pVmcs->u64HostCr0.u));
1182 LogRel((" %scr3 = %#RX64\n", pszPrefix, pVmcs->u64HostCr3.u));
1183 LogRel((" %scr4 = %#RX64\n", pszPrefix, pVmcs->u64HostCr4.u));
1184 LogRel((" %sSysEnter ESP = %#RX64\n", pszPrefix, pVmcs->u64HostSysenterEsp.u));
1185 LogRel((" %sSysEnter EIP = %#RX64\n", pszPrefix, pVmcs->u64HostSysenterEip.u));
1186 LogRel((" %srsp = %#RX64\n", pszPrefix, pVmcs->u64HostRsp.u));
1187 LogRel((" %srip = %#RX64\n", pszPrefix, pVmcs->u64HostRip.u));
1188 }
1189
1190 /* Read-only fields. */
1191 {
1192 LogRel(("%sRead-only data fields:\n", pszPrefix));
1193
1194 /* 16-bit (none currently). */
1195
1196 /* 32-bit. */
1197 uint32_t const uExitReason = pVmcs->u32RoExitReason;
1198 LogRel((" %sExit reason = %u (%s)\n", pszPrefix, uExitReason, HMGetVmxExitName(uExitReason)));
1199 LogRel((" %sExit qualification = %#RX64\n", pszPrefix, pVmcs->u64RoExitQual.u));
1200 LogRel((" %sVM-instruction error = %#RX32\n", pszPrefix, pVmcs->u32RoVmInstrError));
1201 LogRel((" %sVM-exit intr info = %#RX32\n", pszPrefix, pVmcs->u32RoExitIntInfo));
1202 {
1203 uint32_t const fInfo = pVmcs->u32RoExitIntInfo;
1204 uint8_t const uType = VMX_EXIT_INT_INFO_TYPE(fInfo);
1205 LogRel((" %sValid = %RTbool\n", pszPrefix, VMX_EXIT_INT_INFO_IS_VALID(fInfo)));
1206 LogRel((" %sType = %#x (%s)\n", pszPrefix, uType, HMGetVmxExitIntInfoTypeDesc(uType)));
1207 LogRel((" %sVector = %#x\n", pszPrefix, VMX_EXIT_INT_INFO_VECTOR(fInfo)));
1208 LogRel((" %sNMI-unblocking-IRET = %RTbool\n", pszPrefix, VMX_EXIT_INT_INFO_IS_NMI_UNBLOCK_IRET(fInfo)));
1209 LogRel((" %sError-code valid = %RTbool\n", pszPrefix, VMX_EXIT_INT_INFO_IS_ERROR_CODE_VALID(fInfo)));
1210 }
1211 LogRel((" %sVM-exit intr error-code = %#RX32\n", pszPrefix, pVmcs->u32RoExitIntErrCode));
1212 LogRel((" %sIDT-vectoring info = %#RX32\n", pszPrefix, pVmcs->u32RoIdtVectoringInfo));
1213 {
1214 uint32_t const fInfo = pVmcs->u32RoIdtVectoringInfo;
1215 uint8_t const uType = VMX_IDT_VECTORING_INFO_TYPE(fInfo);
1216 LogRel((" %sValid = %RTbool\n", pszPrefix, VMX_IDT_VECTORING_INFO_IS_VALID(fInfo)));
1217 LogRel((" %sType = %#x (%s)\n", pszPrefix, uType, HMGetVmxIdtVectoringInfoTypeDesc(uType)));
1218 LogRel((" %sVector = %#x\n", pszPrefix, VMX_IDT_VECTORING_INFO_VECTOR(fInfo)));
1219 LogRel((" %sError-code valid = %RTbool\n", pszPrefix, VMX_IDT_VECTORING_INFO_IS_ERROR_CODE_VALID(fInfo)));
1220 }
1221 LogRel((" %sIDT-vectoring error-code = %#RX32\n", pszPrefix, pVmcs->u32RoIdtVectoringErrCode));
1222 LogRel((" %sVM-exit instruction length = %u bytes\n", pszPrefix, pVmcs->u32RoExitInstrLen));
1223 LogRel((" %sVM-exit instruction info = %#RX64\n", pszPrefix, pVmcs->u32RoExitInstrInfo));
1224
1225 /* 64-bit. */
1226 LogRel((" %sGuest-physical addr = %#RX64\n", pszPrefix, pVmcs->u64RoGuestPhysAddr.u));
1227
1228 /* Natural width. */
1229 LogRel((" %sI/O RCX = %#RX64\n", pszPrefix, pVmcs->u64RoIoRcx.u));
1230 LogRel((" %sI/O RSI = %#RX64\n", pszPrefix, pVmcs->u64RoIoRsi.u));
1231 LogRel((" %sI/O RDI = %#RX64\n", pszPrefix, pVmcs->u64RoIoRdi.u));
1232 LogRel((" %sI/O RIP = %#RX64\n", pszPrefix, pVmcs->u64RoIoRip.u));
1233 LogRel((" %sGuest-linear addr = %#RX64\n", pszPrefix, pVmcs->u64RoGuestLinearAddr.u));
1234 }
1235
1236# undef HMVMX_DUMP_HOST_XDTR
1237# undef HMVMX_DUMP_HOST_FS_GS_TR
1238# undef HMVMX_DUMP_GUEST_SEGREG
1239# undef HMVMX_DUMP_GUEST_XDTR
1240#else
1241 NOREF(pVCpu);
1242#endif /* !IN_RC */
1243}
1244
Note: See TracBrowser for help on using the repository browser.

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