Changeset 81305 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Oct 17, 2019 10:23:39 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/HostImpl.cpp
r80797 r81305 374 374 if (m->fVTSupported) 375 375 { 376 int rc = SUPR3InitEx(false /*fUnrestricted*/, NULL); 377 if (RT_SUCCESS(rc)) 378 { 379 uint32_t fVTCaps; 380 rc = SUPR3QueryVTCaps(&fVTCaps); 381 if (RT_SUCCESS(rc)) 382 { 383 Assert(fVTCaps & (SUPVTCAPS_AMD_V | SUPVTCAPS_VT_X)); 384 if (fVTCaps & SUPVTCAPS_NESTED_PAGING) 385 m->fNestedPagingSupported = true; 386 else 387 Assert(m->fNestedPagingSupported == false); 388 if ( (fVTCaps & SUPVTCAPS_AMD_V) 389 || (fVTCaps & SUPVTCAPS_VTX_UNRESTRICTED_GUEST)) 390 m->fUnrestrictedGuestSupported = true; 391 else 392 Assert(m->fUnrestrictedGuestSupported == false); 393 /** @todo r=klaus put accurate condition here, it's still approximate. */ 394 if ( ( (fVTCaps & SUPVTCAPS_AMD_V) 395 && m->fNestedPagingSupported) 396 || (fVTCaps & SUPVTCAPS_VTX_UNRESTRICTED_GUEST)) 397 m->fNestedHWVirtSupported = true; 398 } 399 else 400 { 401 LogRel(("SUPR0QueryVTCaps -> %Rrc\n", rc)); 402 m->fVTSupported = m->fNestedPagingSupported = m->fUnrestrictedGuestSupported 403 = m->fNestedHWVirtSupported = false; 404 } 405 rc = SUPR3Term(false); 406 AssertRC(rc); 407 } 408 else 409 m->fRecheckVTSupported = true; /* Try again later when the driver is loaded. */ 376 m->fRecheckVTSupported = true; /* Try again later when the driver is loaded; cleared by i_updateProcessorFeatures on success. */ 377 i_updateProcessorFeatures(); 410 378 } 411 379 … … 1169 1137 1170 1138 /** 1139 * Updates fVTSupported, fNestedPagingSupported, fUnrestrictedGuestSupported and 1140 * fNestedHWVirtSupported with info from SUPR3QueryVTCaps(). 1141 * 1142 * This is repeated till we successfully open the support driver, in case it 1143 * is loaded after VBoxSVC starts. 1144 */ 1145 void Host::i_updateProcessorFeatures() 1146 { 1147 /* Perhaps the driver is available now... */ 1148 int rc = SUPR3InitEx(false /*fUnrestricted*/, NULL); 1149 if (RT_SUCCESS(rc)) 1150 { 1151 uint32_t fVTCaps; 1152 rc = SUPR3QueryVTCaps(&fVTCaps); 1153 AssertRC(rc); 1154 1155 SUPR3Term(false); 1156 1157 AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS); 1158 if (RT_FAILURE(rc)) 1159 { 1160 LogRel(("SUPR0QueryVTCaps -> %Rrc\n", rc)); 1161 fVTCaps = 0; 1162 } 1163 m->fVTSupported = (fVTCaps & (SUPVTCAPS_AMD_V | SUPVTCAPS_VT_X)) != 0; 1164 m->fNestedPagingSupported = (fVTCaps & SUPVTCAPS_NESTED_PAGING) != 0; 1165 m->fUnrestrictedGuestSupported = (fVTCaps & (SUPVTCAPS_AMD_V | SUPVTCAPS_VTX_UNRESTRICTED_GUEST)) != 0; 1166 m->fNestedHWVirtSupported = (fVTCaps & (SUPVTCAPS_AMD_V | SUPVTCAPS_NESTED_PAGING)) 1167 == (SUPVTCAPS_AMD_V | SUPVTCAPS_NESTED_PAGING) 1168 || (fVTCaps & ( SUPVTCAPS_VT_X | SUPVTCAPS_NESTED_PAGING 1169 | SUPVTCAPS_VTX_UNRESTRICTED_GUEST | SUPVTCAPS_VTX_VMCS_SHADOWING)) 1170 == ( SUPVTCAPS_VT_X | SUPVTCAPS_NESTED_PAGING 1171 | SUPVTCAPS_VTX_UNRESTRICTED_GUEST | SUPVTCAPS_VTX_VMCS_SHADOWING); 1172 m->fRecheckVTSupported = false; /* No need to try again, we cached everything. */ 1173 } 1174 } 1175 1176 /** 1171 1177 * Returns whether a host processor feature is supported or not 1172 1178 * … … 1206 1212 { 1207 1213 alock.release(); 1208 1209 /* Perhaps the driver is available now... */ 1210 int rc = SUPR3InitEx(false /*fUnrestricted*/, NULL); 1211 if (RT_SUCCESS(rc)) 1212 { 1213 uint32_t fVTCaps; 1214 rc = SUPR3QueryVTCaps(&fVTCaps); 1215 1216 AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS); 1217 if (RT_SUCCESS(rc)) 1218 { 1219 Assert(fVTCaps & (SUPVTCAPS_AMD_V | SUPVTCAPS_VT_X)); 1220 if (fVTCaps & SUPVTCAPS_NESTED_PAGING) 1221 m->fNestedPagingSupported = true; 1222 else 1223 Assert(m->fNestedPagingSupported == false); 1224 if ( (fVTCaps & SUPVTCAPS_AMD_V) 1225 || (fVTCaps & SUPVTCAPS_VTX_UNRESTRICTED_GUEST)) 1226 m->fUnrestrictedGuestSupported = true; 1227 else 1228 Assert(m->fUnrestrictedGuestSupported == false); 1229 /** @todo r=klaus put accurate condition here and update it as 1230 * the feature becomes available with VT-x. */ 1231 if ( (fVTCaps & SUPVTCAPS_AMD_V) 1232 && m->fNestedPagingSupported) 1233 m->fNestedHWVirtSupported = true; 1234 } 1235 else 1236 { 1237 LogRel(("SUPR0QueryVTCaps -> %Rrc\n", rc)); 1238 m->fVTSupported = m->fNestedPagingSupported = m->fUnrestrictedGuestSupported 1239 = m->fNestedHWVirtSupported = false; 1240 } 1241 rc = SUPR3Term(false); 1242 AssertRC(rc); 1243 m->fRecheckVTSupported = false; /* No need to try again, we cached everything. */ 1244 } 1245 1214 i_updateProcessorFeatures(); 1246 1215 alock.acquire(); 1247 1216 }
Note:
See TracChangeset
for help on using the changeset viewer.