diff options
author | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2021-07-26 21:01:38 +0000 |
---|---|---|
committer | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2021-07-26 21:01:38 +0000 |
commit | a3b3d3d11f3f9ccdc41d277636373e0dd927694c (patch) | |
tree | 0b5020aa1ebdd45f34e0318f30d15dc68a7d37c1 /src/VBox/VMM/VMMR3 | |
parent | 1349c936d68945772c531a79ff8a6ea1e8723edd (diff) | |
download | VirtualBox-svn-a3b3d3d11f3f9ccdc41d277636373e0dd927694c.tar.gz |
VMM: Removed the VM pointers from the internal critsect structures. bugref:9218 bugref:10074
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@90348 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/VMM/VMMR3')
-rw-r--r-- | src/VBox/VMM/VMMR3/MMHyper.cpp | 2 | ||||
-rw-r--r-- | src/VBox/VMM/VMMR3/PDM.cpp | 7 | ||||
-rw-r--r-- | src/VBox/VMM/VMMR3/PDMCritSect.cpp | 43 | ||||
-rw-r--r-- | src/VBox/VMM/VMMR3/PDMDevHlp.cpp | 6 | ||||
-rw-r--r-- | src/VBox/VMM/VMMR3/PDMDriver.cpp | 3 | ||||
-rw-r--r-- | src/VBox/VMM/VMMR3/PDMNetShaper.cpp | 18 | ||||
-rw-r--r-- | src/VBox/VMM/VMMR3/PGM.cpp | 4 |
7 files changed, 19 insertions, 64 deletions
diff --git a/src/VBox/VMM/VMMR3/MMHyper.cpp b/src/VBox/VMM/VMMR3/MMHyper.cpp index 8e8251d42f4..205478aa67d 100644 --- a/src/VBox/VMM/VMMR3/MMHyper.cpp +++ b/src/VBox/VMM/VMMR3/MMHyper.cpp @@ -214,7 +214,7 @@ int mmR3HyperInit(PVM pVM) int mmR3HyperTerm(PVM pVM) { if (pVM->mm.s.pHyperHeapR3) - PDMR3CritSectDelete(&pVM->mm.s.pHyperHeapR3->Lock); + PDMR3CritSectDelete(pVM, &pVM->mm.s.pHyperHeapR3->Lock); return VINF_SUCCESS; } diff --git a/src/VBox/VMM/VMMR3/PDM.cpp b/src/VBox/VMM/VMMR3/PDM.cpp index a0387f8c369..81918f3e0e3 100644 --- a/src/VBox/VMM/VMMR3/PDM.cpp +++ b/src/VBox/VMM/VMMR3/PDM.cpp @@ -584,11 +584,6 @@ VMMR3_INT_DECL(void) PDMR3Relocate(PVM pVM, RTGCINTPTR offDelta) pVM->pdm.s.pDevHlpQueueRC = PDMQueueRCPtr(pVM->pdm.s.pDevHlpQueueR3); /* - * Critical sections. - */ - pdmR3CritSectBothRelocate(pVM); - - /* * The registered PIC. */ if (pVM->pdm.s.Pic.pDevInsRC) @@ -893,7 +888,7 @@ VMMR3_INT_DECL(int) PDMR3Term(PVM pVM) /* * Destroy the PDM lock. */ - PDMR3CritSectDelete(&pVM->pdm.s.CritSect); + PDMR3CritSectDelete(pVM, &pVM->pdm.s.CritSect); /* The MiscCritSect is deleted by PDMR3CritSectBothTerm later. */ LogFlow(("PDMR3Term: returns %Rrc\n", VINF_SUCCESS)); diff --git a/src/VBox/VMM/VMMR3/PDMCritSect.cpp b/src/VBox/VMM/VMMR3/PDMCritSect.cpp index 5b8b3d57d92..6ca86837f2c 100644 --- a/src/VBox/VMM/VMMR3/PDMCritSect.cpp +++ b/src/VBox/VMM/VMMR3/PDMCritSect.cpp @@ -61,30 +61,6 @@ int pdmR3CritSectBothInitStats(PVM pVM) /** - * Relocates all the critical sections. - * - * @param pVM The cross context VM structure. - */ -void pdmR3CritSectBothRelocate(PVM pVM) -{ - PUVM pUVM = pVM->pUVM; - RTCritSectEnter(&pUVM->pdm.s.ListCritSect); - - for (PPDMCRITSECTINT pCur = pUVM->pdm.s.pCritSects; - pCur; - pCur = pCur->pNext) - pCur->pVMRC = pVM->pVMRC; - - for (PPDMCRITSECTRWINT pCur = pUVM->pdm.s.pRwCritSects; - pCur; - pCur = pCur->pNext) - pCur->pVMRC = pVM->pVMRC; - - RTCritSectLeave(&pUVM->pdm.s.ListCritSect); -} - - -/** * Deletes all remaining critical sections. * * This is called at the very end of the termination process. It is also called @@ -181,9 +157,6 @@ static int pdmR3CritSectInitOne(PVM pVM, PPDMCRITSECTINT pCritSect, void *pvKey, pCritSect->Core.cNestings = 0; pCritSect->Core.cLockers = -1; pCritSect->Core.NativeThreadOwner = NIL_RTNATIVETHREAD; - pCritSect->pVMR3 = pVM; - pCritSect->pVMR0 = pVM->pVMR0ForCall; - pCritSect->pVMRC = pVM->pVMRC; pCritSect->pvKey = pvKey; pCritSect->fAutomaticDefaultCritsect = false; pCritSect->fUsedByTimerOrSimilar = false; @@ -278,9 +251,6 @@ static int pdmR3CritSectRwInitOne(PVM pVM, PPDMCRITSECTRWINT pCritSect, void *pv #if HC_ARCH_BITS == 32 pCritSect->Core.HCPtrPadding = NIL_RTHCPTR; #endif - pCritSect->pVMR3 = pVM; - pCritSect->pVMR0 = pVM->pVMR0ForCall; - pCritSect->pVMRC = pVM->pVMRC; pCritSect->pvKey = pvKey; pCritSect->pszName = pszName; @@ -533,9 +503,6 @@ static int pdmR3CritSectDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTINT pCritSect, RTLockValidatorRecExclDestroy(&pCritSect->Core.pValidatorRec); pCritSect->pNext = NULL; pCritSect->pvKey = NULL; - pCritSect->pVMR3 = NULL; - pCritSect->pVMR0 = NIL_RTR0PTR; - pCritSect->pVMRC = NIL_RTRCPTR; if (!fFinal) STAMR3DeregisterF(pVM->pUVM, "/PDM/CritSects/%s/*", pCritSect->pszName); RTStrFree((char *)pCritSect->pszName); @@ -604,9 +571,6 @@ static int pdmR3CritSectRwDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTRWINT pCritS pCritSect->pNext = NULL; pCritSect->pvKey = NULL; - pCritSect->pVMR3 = NULL; - pCritSect->pVMR0 = NIL_RTR0PTR; - pCritSect->pVMRC = NIL_RTRCPTR; if (!fFinal) STAMR3DeregisterF(pVM->pUVM, "/PDM/CritSectsRw/%s/*", pCritSect->pszName); RTStrFree((char *)pCritSect->pszName); @@ -730,9 +694,10 @@ int pdmR3CritSectBothDeleteDriver(PVM pVM, PPDMDRVINS pDrvIns) * Deletes the critical section. * * @returns VBox status code. - * @param pCritSect The PDM critical section to destroy. + * @param pVM The cross context VM structure. + * @param pCritSect The PDM critical section to destroy. */ -VMMR3DECL(int) PDMR3CritSectDelete(PPDMCRITSECT pCritSect) +VMMR3DECL(int) PDMR3CritSectDelete(PVM pVM, PPDMCRITSECT pCritSect) { if (!RTCritSectIsInitialized(&pCritSect->s.Core)) return VINF_SUCCESS; @@ -740,7 +705,6 @@ VMMR3DECL(int) PDMR3CritSectDelete(PPDMCRITSECT pCritSect) /* * Find and unlink it. */ - PVM pVM = pCritSect->s.pVMR3; PUVM pUVM = pVM->pUVM; AssertReleaseReturn(pVM, VERR_PDM_CRITSECT_IPE); PPDMCRITSECTINT pPrev = NULL; @@ -780,7 +744,6 @@ VMMR3DECL(int) PDMR3CritSectRwDelete(PVM pVM, PPDMCRITSECTRW pCritSect) /* * Find and unlink it. */ - Assert(pCritSect->s.pVMR3 == pVM); PUVM pUVM = pVM->pUVM; AssertReleaseReturn(pVM, VERR_PDM_CRITSECT_IPE); PPDMCRITSECTRWINT pPrev = NULL; diff --git a/src/VBox/VMM/VMMR3/PDMDevHlp.cpp b/src/VBox/VMM/VMMR3/PDMDevHlp.cpp index 39f24a44c01..ef6811e97ae 100644 --- a/src/VBox/VMM/VMMR3/PDMDevHlp.cpp +++ b/src/VBox/VMM/VMMR3/PDMDevHlp.cpp @@ -2736,7 +2736,6 @@ static DECLCALLBACK(int) pdmR3DevHlp_SetDeviceCritSect(PPDMDEVINS pDevIns, PPDMC pDevIns->pReg->szName, pDevIns->iInstance, pCritSect, pCritSect->s.pszName)); AssertReturn(PDMCritSectIsInitialized(pCritSect), VERR_INVALID_PARAMETER); PVM pVM = pDevIns->Internal.s.pVMR3; - AssertReturn(pCritSect->s.pVMR3 == pVM, VERR_INVALID_PARAMETER); VM_ASSERT_EMT(pVM); VM_ASSERT_STATE_RETURN(pVM, VMSTATE_CREATING, VERR_WRONG_ORDER); @@ -2767,7 +2766,7 @@ static DECLCALLBACK(int) pdmR3DevHlp_SetDeviceCritSect(PPDMDEVINS pDevIns, PPDMC AssertLogRelRCReturn(rc, rc); } - PDMR3CritSectDelete(pOldCritSect); + PDMR3CritSectDelete(pVM, pOldCritSect); Assert((uintptr_t)pOldCritSect - (uintptr_t)pDevIns < pDevIns->cbRing3); LogFlow(("pdmR3DevHlp_SetDeviceCritSect: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, VINF_SUCCESS)); @@ -2871,8 +2870,7 @@ static DECLCALLBACK(int) pdmR3DevHlp_CritSectScheduleExitEvent(PPDMDEVINS pDevIn static DECLCALLBACK(int) pdmR3DevHlp_CritSectDelete(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect) { PDMDEV_ASSERT_DEVINS(pDevIns); - RT_NOREF(pDevIns); - return PDMR3CritSectDelete(pCritSect); + return PDMR3CritSectDelete(pDevIns->Internal.s.pVMR3, pCritSect); } diff --git a/src/VBox/VMM/VMMR3/PDMDriver.cpp b/src/VBox/VMM/VMMR3/PDMDriver.cpp index ac528485bfe..09e40347135 100644 --- a/src/VBox/VMM/VMMR3/PDMDriver.cpp +++ b/src/VBox/VMM/VMMR3/PDMDriver.cpp @@ -1908,8 +1908,7 @@ static DECLCALLBACK(int) pdmR3DrvHlp_CritSectScheduleExitEvent(PPDMDRVINS p static DECLCALLBACK(int) pdmR3DrvHlp_CritSectDelete(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect) { PDMDRV_ASSERT_DRVINS(pDrvIns); - RT_NOREF(pDrvIns); - return PDMR3CritSectDelete(pCritSect); + return PDMR3CritSectDelete(pDrvIns->Internal.s.pVMR3, pCritSect); } diff --git a/src/VBox/VMM/VMMR3/PDMNetShaper.cpp b/src/VBox/VMM/VMMR3/PDMNetShaper.cpp index 6f991ebf080..dc46189be1a 100644 --- a/src/VBox/VMM/VMMR3/PDMNetShaper.cpp +++ b/src/VBox/VMM/VMMR3/PDMNetShaper.cpp @@ -152,14 +152,14 @@ static int pdmNsBwGroupCreate(PPDMNETSHAPER pShaper, const char *pszBwGroup, uin PPDMNSBWGROUP pBwGroup = pdmNsBwGroupFindById(pShaper, pszBwGroup); if (!pBwGroup) { - rc = MMHyperAlloc(pShaper->pVM, sizeof(PDMNSBWGROUP), 64, - MM_TAG_PDM_NET_SHAPER, (void **)&pBwGroup); + PVM const pVM = pShaper->pVM; + rc = MMHyperAlloc(pVM, sizeof(PDMNSBWGROUP), 64, MM_TAG_PDM_NET_SHAPER, (void **)&pBwGroup); if (RT_SUCCESS(rc)) { - rc = PDMR3CritSectInit(pShaper->pVM, &pBwGroup->Lock, RT_SRC_POS, "BWGRP-%s", pszBwGroup); + rc = PDMR3CritSectInit(pVM, &pBwGroup->Lock, RT_SRC_POS, "BWGRP-%s", pszBwGroup); if (RT_SUCCESS(rc)) { - pBwGroup->pszNameR3 = MMR3HeapStrDup(pShaper->pVM, MM_TAG_PDM_NET_SHAPER, pszBwGroup); + pBwGroup->pszNameR3 = MMR3HeapStrDup(pVM, MM_TAG_PDM_NET_SHAPER, pszBwGroup); if (pBwGroup->pszNameR3) { pBwGroup->pShaperR3 = pShaper; @@ -175,9 +175,9 @@ static int pdmNsBwGroupCreate(PPDMNETSHAPER pShaper, const char *pszBwGroup, uin pdmNsBwGroupLink(pBwGroup); return VINF_SUCCESS; } - PDMR3CritSectDelete(&pBwGroup->Lock); + PDMR3CritSectDelete(pVM, &pBwGroup->Lock); } - MMHyperFree(pShaper->pVM, pBwGroup); + MMHyperFree(pVM, pBwGroup); } else rc = VERR_NO_MEMORY; @@ -190,11 +190,11 @@ static int pdmNsBwGroupCreate(PPDMNETSHAPER pShaper, const char *pszBwGroup, uin } -static void pdmNsBwGroupTerminate(PPDMNSBWGROUP pBwGroup) +static void pdmNsBwGroupTerminate(PVM pVM, PPDMNSBWGROUP pBwGroup) { Assert(pBwGroup->cRefs == 0); if (PDMCritSectIsInitialized(&pBwGroup->Lock)) - PDMR3CritSectDelete(&pBwGroup->Lock); + PDMR3CritSectDelete(pVM, &pBwGroup->Lock); } @@ -468,7 +468,7 @@ int pdmR3NetShaperTerm(PVM pVM) { PPDMNSBWGROUP pFree = pBwGroup; pBwGroup = pBwGroup->pNextR3; - pdmNsBwGroupTerminate(pFree); + pdmNsBwGroupTerminate(pVM, pFree); MMR3HeapFree(pFree->pszNameR3); MMHyperFree(pVM, pFree); } diff --git a/src/VBox/VMM/VMMR3/PGM.cpp b/src/VBox/VMM/VMMR3/PGM.cpp index aaaf2b51ec4..e658a8090d1 100644 --- a/src/VBox/VMM/VMMR3/PGM.cpp +++ b/src/VBox/VMM/VMMR3/PGM.cpp @@ -1063,7 +1063,7 @@ VMMR3DECL(int) PGMR3Init(PVM pVM) } /* Almost no cleanup necessary, MM frees all memory. */ - PDMR3CritSectDelete(&pVM->pgm.s.CritSectX); + PDMR3CritSectDelete(pVM, &pVM->pgm.s.CritSectX); return rc; } @@ -2138,7 +2138,7 @@ VMMR3DECL(int) PGMR3Term(PVM pVM) pgmUnlock(pVM); PGMDeregisterStringFormatTypes(); - return PDMR3CritSectDelete(&pVM->pgm.s.CritSectX); + return PDMR3CritSectDelete(pVM, &pVM->pgm.s.CritSectX); } |