Changeset 76482 in vbox for trunk/src/VBox/VMM/VMMR0/HMR0.cpp
- Timestamp:
- Dec 26, 2018 3:49:56 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMR0.cpp
r76469 r76482 83 83 { 84 84 /** Per CPU globals. */ 85 HM GLOBALCPUINFOaCpuInfo[RTCPUSET_MAX_CPUS];85 HMPHYSCPU aCpuInfo[RTCPUSET_MAX_CPUS]; 86 86 87 87 /** @name Ring-0 method table for AMD-V and VT-x specific operations. 88 88 * @{ */ 89 DECLR0CALLBACKMEMBER(int, pfnEnterSession, (PVMCPU pVCpu , PHMGLOBALCPUINFO pHostCpu));89 DECLR0CALLBACKMEMBER(int, pfnEnterSession, (PVMCPU pVCpu)); 90 90 DECLR0CALLBACKMEMBER(void, pfnThreadCtxCallback, (RTTHREADCTXEVENT enmEvent, PVMCPU pVCpu, bool fGlobalInit)); 91 91 DECLR0CALLBACKMEMBER(int, pfnExportHostState, (PVMCPU pVCpu)); 92 92 DECLR0CALLBACKMEMBER(VBOXSTRICTRC, pfnRunGuestCode, (PVMCPU pVCpu)); 93 DECLR0CALLBACKMEMBER(int, pfnEnableCpu, (PHM GLOBALCPUINFOpHostCpu, PVM pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage,93 DECLR0CALLBACKMEMBER(int, pfnEnableCpu, (PHMPHYSCPU pHostCpu, PVM pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage, 94 94 bool fEnabledByHost, PCSUPHWVIRTMSRS pHwvirtMsrs)); 95 DECLR0CALLBACKMEMBER(int, pfnDisableCpu, ( PHMGLOBALCPUINFO pHostCpu,void *pvCpuPage, RTHCPHYS HCPhysCpuPage));95 DECLR0CALLBACKMEMBER(int, pfnDisableCpu, (void *pvCpuPage, RTHCPHYS HCPhysCpuPage)); 96 96 DECLR0CALLBACKMEMBER(int, pfnInitVM, (PVM pVM)); 97 97 DECLR0CALLBACKMEMBER(int, pfnTermVM, (PVM pVM)); … … 227 227 * @{ */ 228 228 229 static DECLCALLBACK(int) hmR0DummyEnter(PVMCPU pVCpu , PHMGLOBALCPUINFO pHostCpu)230 { 231 RT_NOREF 2(pVCpu, pHostCpu);229 static DECLCALLBACK(int) hmR0DummyEnter(PVMCPU pVCpu) 230 { 231 RT_NOREF1(pVCpu); 232 232 return VINF_SUCCESS; 233 233 } … … 238 238 } 239 239 240 static DECLCALLBACK(int) hmR0DummyEnableCpu(PHM GLOBALCPUINFOpHostCpu, PVM pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage,240 static DECLCALLBACK(int) hmR0DummyEnableCpu(PHMPHYSCPU pHostCpu, PVM pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage, 241 241 bool fEnabledBySystem, PCSUPHWVIRTMSRS pHwvirtMsrs) 242 242 { … … 245 245 } 246 246 247 static DECLCALLBACK(int) hmR0DummyDisableCpu( PHMGLOBALCPUINFO pHostCpu,void *pvCpuPage, RTHCPHYS HCPhysCpuPage)248 { 249 RT_NOREF 3(pHostCpu,pvCpuPage, HCPhysCpuPage);247 static DECLCALLBACK(int) hmR0DummyDisableCpu(void *pvCpuPage, RTHCPHYS HCPhysCpuPage) 248 { 249 RT_NOREF2(pvCpuPage, HCPhysCpuPage); 250 250 return VINF_SUCCESS; 251 251 } … … 789 789 static int hmR0EnableCpu(PVM pVM, RTCPUID idCpu) 790 790 { 791 PHM GLOBALCPUINFOpHostCpu = &g_HmR0.aCpuInfo[idCpu];791 PHMPHYSCPU pHostCpu = &g_HmR0.aCpuInfo[idCpu]; 792 792 793 793 Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /** @todo fix idCpu == index assumption (rainy day) */ … … 975 975 static int hmR0DisableCpu(RTCPUID idCpu) 976 976 { 977 PHM GLOBALCPUINFOpHostCpu = &g_HmR0.aCpuInfo[idCpu];977 PHMPHYSCPU pHostCpu = &g_HmR0.aCpuInfo[idCpu]; 978 978 979 979 Assert(!g_HmR0.hwvirt.u.vmx.fSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx); … … 992 992 if (pHostCpu->fConfigured) 993 993 { 994 rc = g_HmR0.pfnDisableCpu(pHostCpu , pHostCpu->pvMemObj, pHostCpu->HCPhysMemObj);994 rc = g_HmR0.pfnDisableCpu(pHostCpu->pvMemObj, pHostCpu->HCPhysMemObj); 995 995 AssertRCReturn(rc, rc); 996 996 … … 1323 1323 int rc = VINF_SUCCESS; 1324 1324 RTCPUID const idCpu = RTMpCpuId(); 1325 PHM GLOBALCPUINFOpHostCpu = &g_HmR0.aCpuInfo[idCpu];1325 PHMPHYSCPU pHostCpu = &g_HmR0.aCpuInfo[idCpu]; 1326 1326 AssertPtr(pHostCpu); 1327 1327 … … 1358 1358 /* Load the bare minimum state required for entering HM. */ 1359 1359 int rc = hmR0EnterCpu(pVCpu); 1360 AssertRCReturn(rc, rc); 1360 if (RT_SUCCESS(rc)) 1361 { 1362 if (g_HmR0.hwvirt.u.vmx.fSupported) 1363 { 1364 Assert((pVCpu->hm.s.fCtxChanged & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_HOST_GUEST_SHARED_STATE)) 1365 == (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_HOST_GUEST_SHARED_STATE)); 1366 } 1367 else 1368 { 1369 Assert((pVCpu->hm.s.fCtxChanged & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_SVM_HOST_GUEST_SHARED_STATE)) 1370 == (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_SVM_HOST_GUEST_SHARED_STATE)); 1371 } 1361 1372 1362 1373 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE 1363 AssertReturn(!VMMR0ThreadCtxHookIsEnabled(pVCpu), VERR_HM_IPE_5);1364 boolfStartedSet = PGMR0DynMapStartOrMigrateAutoSet(pVCpu);1374 AssertReturn(!VMMR0ThreadCtxHookIsEnabled(pVCpu), VERR_HM_IPE_5); 1375 bool const fStartedSet = PGMR0DynMapStartOrMigrateAutoSet(pVCpu); 1365 1376 #endif 1366 1377 1367 RTCPUID const idCpu = RTMpCpuId(); 1368 PHMGLOBALCPUINFO pHostCpu = &g_HmR0.aCpuInfo[idCpu]; 1369 Assert(pHostCpu); 1370 if (g_HmR0.hwvirt.u.vmx.fSupported) 1371 { 1372 Assert((pVCpu->hm.s.fCtxChanged & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_HOST_GUEST_SHARED_STATE)) 1373 == (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_HOST_GUEST_SHARED_STATE)); 1374 } 1375 else 1376 { 1377 Assert((pVCpu->hm.s.fCtxChanged & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_SVM_HOST_GUEST_SHARED_STATE)) 1378 == (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_SVM_HOST_GUEST_SHARED_STATE)); 1379 } 1380 1381 rc = g_HmR0.pfnEnterSession(pVCpu, pHostCpu); 1382 AssertMsgRCReturn(rc, ("rc=%Rrc pVCpu=%p HostCpuId=%u\n", rc, pVCpu, idCpu), rc); 1383 1384 /* Exports the host-state as we may be resuming code after a longjmp and quite 1385 possibly now be scheduled on a different CPU. */ 1386 rc = g_HmR0.pfnExportHostState(pVCpu); 1387 AssertMsgRCReturn(rc, ("rc=%Rrc pVCpu=%p HostCpuId=%u\n", rc, pVCpu, idCpu), rc); 1378 /* Keep track of the CPU owning the VMCS for debugging scheduling weirdness and ring-3 calls. */ 1379 rc = g_HmR0.pfnEnterSession(pVCpu); 1380 AssertMsgRCReturnStmt(rc, ("rc=%Rrc pVCpu=%p\n", rc, pVCpu), pVCpu->hm.s.idEnteredCpu = NIL_RTCPUID, rc); 1381 1382 /* Exports the host-state as we may be resuming code after a longjmp and quite 1383 possibly now be scheduled on a different CPU. */ 1384 rc = g_HmR0.pfnExportHostState(pVCpu); 1385 AssertMsgRCReturnStmt(rc, ("rc=%Rrc pVCpu=%p\n", rc, pVCpu), pVCpu->hm.s.idEnteredCpu = NIL_RTCPUID, rc); 1388 1386 1389 1387 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE 1390 if (fStartedSet)1391 PGMRZDynMapReleaseAutoSet(pVCpu);1388 if (fStartedSet) 1389 PGMRZDynMapReleaseAutoSet(pVCpu); 1392 1390 #endif 1393 1394 /* Keep track of the CPU owning the VMCS for debugging scheduling weirdness and ring-3 calls. */ 1395 if (RT_FAILURE(rc)) 1396 pVCpu->hm.s.idEnteredCpu = NIL_RTCPUID; 1391 } 1397 1392 return rc; 1398 1393 } … … 1413 1408 VMCPU_ASSERT_EMT_RETURN(pVCpu, VERR_HM_WRONG_CPU); 1414 1409 1415 RTCPUID const 1416 P HMGLOBALCPUINFOpHostCpu = &g_HmR0.aCpuInfo[idCpu];1410 RTCPUID const idCpu = RTMpCpuId(); 1411 PCHMPHYSCPU pHostCpu = &g_HmR0.aCpuInfo[idCpu]; 1417 1412 1418 1413 if ( !g_HmR0.fGlobalInit … … 1470 1465 if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD)) 1471 1466 { 1472 P HMGLOBALCPUINFOpHostCpu = &g_HmR0.aCpuInfo[RTMpCpuId()];1467 PCHMPHYSCPU pHostCpu = &g_HmR0.aCpuInfo[RTMpCpuId()]; 1473 1468 Assert(!VMCPU_FF_IS_ANY_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL)); 1474 1469 Assert(pHostCpu->fConfigured); … … 1609 1604 * @returns The cpu structure pointer. 1610 1605 */ 1611 VMMR0_INT_DECL(PHM GLOBALCPUINFO) hmR0GetCurrentCpu(void)1606 VMMR0_INT_DECL(PHMPHYSCPU) hmR0GetCurrentCpu(void) 1612 1607 { 1613 1608 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD)); … … 1692 1687 1693 1688 /* Ok, disable VT-x. */ 1694 P HMGLOBALCPUINFOpHostCpu = hmR0GetCurrentCpu();1689 PCHMPHYSCPU pHostCpu = hmR0GetCurrentCpu(); 1695 1690 AssertReturn( pHostCpu 1696 1691 && pHostCpu->hMemObj != NIL_RTR0MEMOBJ … … 1700 1695 1701 1696 *pfVTxDisabled = true; 1702 return VMXR0DisableCpu(pHostCpu , pHostCpu->pvMemObj, pHostCpu->HCPhysMemObj);1697 return VMXR0DisableCpu(pHostCpu->pvMemObj, pHostCpu->HCPhysMemObj); 1703 1698 } 1704 1699 … … 1726 1721 Assert(g_HmR0.fGlobalInit); 1727 1722 1728 PHM GLOBALCPUINFOpHostCpu = hmR0GetCurrentCpu();1723 PHMPHYSCPU pHostCpu = hmR0GetCurrentCpu(); 1729 1724 AssertReturnVoid( pHostCpu 1730 1725 && pHostCpu->hMemObj != NIL_RTR0MEMOBJ
Note:
See TracChangeset
for help on using the changeset viewer.