VirtualBox

Changeset 90348 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Jul 26, 2021 9:01:38 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145912
Message:

VMM: Removed the VM pointers from the internal critsect structures. bugref:9218 bugref:10074

Location:
trunk/src/VBox/VMM
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp

    r90346 r90348  
    146146     * The wait loop.
    147147     */
    148     PSUPDRVSESSION  pSession    = pCritSect->s.CTX_SUFF(pVM)->pSession;
     148    PSUPDRVSESSION  pSession    = pVM->pSession;
    149149    SUPSEMEVENT     hEvent      = (SUPSEMEVENT)pCritSect->s.Core.EventSem;
    150150# ifdef IN_RING3
     
    248248        return VINF_SUCCESS;
    249249
    250     Assert(pCritSect->s.CTX_SUFF(pVM) == pVM); RT_NOREF(pVM);
    251250    RTNATIVETHREAD hNativeSelf = pdmCritSectGetNativeSelf(pVM, pCritSect);
    252251    /* ... not owned ... */
     
    460459        return VINF_SUCCESS;
    461460
    462     Assert(pCritSect->s.CTX_SUFF(pVM) == pVM);
    463461    RTNATIVETHREAD hNativeSelf = pdmCritSectGetNativeSelf(pVM, pCritSect);
    464462    /* ... not owned ... */
     
    596594     * Always check that the caller is the owner (screw performance).
    597595     */
    598     Assert(pCritSect->s.CTX_SUFF(pVM) == pVM); RT_NOREF(pVM);
    599596    RTNATIVETHREAD const hNativeSelf = pdmCritSectGetNativeSelf(pVM, pCritSect);
    600597    AssertReleaseMsgReturn(pCritSect->s.Core.NativeThreadOwner == hNativeSelf,
  • trunk/src/VBox/VMM/VMMAll/PDMAllCritSectRw.cpp

    r90347 r90348  
    127127 * Go back to ring-3 so the kernel can do signals, APCs and other fun things.
    128128 *
    129  * @param   pThis       Pointer to the read/write critical section.
    130  */
    131 static void pdmR0CritSectRwYieldToRing3(PPDMCRITSECTRW pThis)
    132 {
    133     PVMCC     pVM   = pThis->s.CTX_SUFF(pVM);     AssertPtr(pVM);
    134     PVMCPUCC  pVCpu = VMMGetCpu(pVM);             AssertPtr(pVCpu);
     129 * @param   pVM         The cross context VM structure.
     130 */
     131static void pdmR0CritSectRwYieldToRing3(PVMCC pVM)
     132{
     133    PVMCPUCC pVCpu = VMMGetCpu(pVM);
     134    AssertPtrReturnVoid(pVCpu);
    135135    int rc = VMMRZCallRing3(pVM, pVCpu, VMMCALLRING3_VM_R0_PREEMPT, NULL);
    136136    AssertRC(rc);
     
    158158    AssertPtr(pThis);
    159159    AssertReturn(pThis->s.Core.u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED);
    160     Assert(pThis->s.CTX_SUFF(pVM) == pVM);
    161160
    162161#if !defined(PDMCRITSECTRW_STRICT) || !defined(IN_RING3)
     
    302301                                    break;
    303302# ifdef IN_RING0
    304                                 pdmR0CritSectRwYieldToRing3(pThis);
     303                                pdmR0CritSectRwYieldToRing3(pVM);
    305304# endif
    306305                            }
     
    567566    AssertPtr(pThis);
    568567    AssertReturn(pThis->s.Core.u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED);
    569     Assert(pThis->s.CTX_SUFF(pVM) == pVM);
    570568
    571569#if !defined(PDMCRITSECTRW_STRICT) || !defined(IN_RING3)
     
    721719    AssertPtr(pThis);
    722720    AssertReturn(pThis->s.Core.u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED);
    723     Assert(pThis->s.CTX_SUFF(pVM) == pVM);
    724721
    725722#if !defined(PDMCRITSECTRW_STRICT) || !defined(IN_RING3)
     
    873870                            break;
    874871# ifdef IN_RING0
    875                         pdmR0CritSectRwYieldToRing3(pThis);
     872                        pdmR0CritSectRwYieldToRing3(pVM);
    876873# endif
    877874                    }
     
    11221119    AssertPtr(pThis);
    11231120    AssertReturn(pThis->s.Core.u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED);
    1124     Assert(pThis->s.CTX_SUFF(pVM) == pVM);
    11251121
    11261122#if !defined(PDMCRITSECTRW_STRICT) || !defined(IN_RING3)
  • trunk/src/VBox/VMM/VMMR0/PDMR0DevHlp.cpp

    r90346 r90348  
    845845    AssertReturn(PDMCritSectIsInitialized(pCritSect), VERR_INVALID_PARAMETER);
    846846    PGVM pGVM = pDevIns->Internal.s.pGVM;
    847     AssertReturn(pCritSect->s.pVMR0 == pGVM, VERR_INVALID_PARAMETER);
    848847
    849848    VM_ASSERT_EMT(pGVM);
  • trunk/src/VBox/VMM/VMMR3/MMHyper.cpp

    r90346 r90348  
    215215{
    216216    if (pVM->mm.s.pHyperHeapR3)
    217         PDMR3CritSectDelete(&pVM->mm.s.pHyperHeapR3->Lock);
     217        PDMR3CritSectDelete(pVM, &pVM->mm.s.pHyperHeapR3->Lock);
    218218
    219219    return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMR3/PDM.cpp

    r90346 r90348  
    585585
    586586    /*
    587      * Critical sections.
    588      */
    589     pdmR3CritSectBothRelocate(pVM);
    590 
    591     /*
    592587     * The registered PIC.
    593588     */
     
    894889     * Destroy the PDM lock.
    895890     */
    896     PDMR3CritSectDelete(&pVM->pdm.s.CritSect);
     891    PDMR3CritSectDelete(pVM, &pVM->pdm.s.CritSect);
    897892    /* The MiscCritSect is deleted by PDMR3CritSectBothTerm later. */
    898893
  • trunk/src/VBox/VMM/VMMR3/PDMCritSect.cpp

    r90347 r90348  
    5858             "Number of times a critical section leave request needed to be queued for ring-3 execution.");
    5959    return VINF_SUCCESS;
    60 }
    61 
    62 
    63 /**
    64  * Relocates all the critical sections.
    65  *
    66  * @param   pVM         The cross context VM structure.
    67  */
    68 void pdmR3CritSectBothRelocate(PVM pVM)
    69 {
    70     PUVM pUVM = pVM->pUVM;
    71     RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
    72 
    73     for (PPDMCRITSECTINT pCur = pUVM->pdm.s.pCritSects;
    74          pCur;
    75          pCur = pCur->pNext)
    76         pCur->pVMRC = pVM->pVMRC;
    77 
    78     for (PPDMCRITSECTRWINT pCur = pUVM->pdm.s.pRwCritSects;
    79          pCur;
    80          pCur = pCur->pNext)
    81         pCur->pVMRC = pVM->pVMRC;
    82 
    83     RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    8460}
    8561
     
    182158                pCritSect->Core.cLockers             = -1;
    183159                pCritSect->Core.NativeThreadOwner    = NIL_RTNATIVETHREAD;
    184                 pCritSect->pVMR3                     = pVM;
    185                 pCritSect->pVMR0                     = pVM->pVMR0ForCall;
    186                 pCritSect->pVMRC                     = pVM->pVMRC;
    187160                pCritSect->pvKey                     = pvKey;
    188161                pCritSect->fAutomaticDefaultCritsect = false;
     
    279252                    pCritSect->Core.HCPtrPadding         = NIL_RTHCPTR;
    280253#endif
    281                     pCritSect->pVMR3                     = pVM;
    282                     pCritSect->pVMR0                     = pVM->pVMR0ForCall;
    283                     pCritSect->pVMRC                     = pVM->pVMRC;
    284254                    pCritSect->pvKey                     = pvKey;
    285255                    pCritSect->pszName                   = pszName;
     
    534504    pCritSect->pNext   = NULL;
    535505    pCritSect->pvKey   = NULL;
    536     pCritSect->pVMR3   = NULL;
    537     pCritSect->pVMR0   = NIL_RTR0PTR;
    538     pCritSect->pVMRC   = NIL_RTRCPTR;
    539506    if (!fFinal)
    540507        STAMR3DeregisterF(pVM->pUVM, "/PDM/CritSects/%s/*", pCritSect->pszName);
     
    605572    pCritSect->pNext   = NULL;
    606573    pCritSect->pvKey   = NULL;
    607     pCritSect->pVMR3   = NULL;
    608     pCritSect->pVMR0   = NIL_RTR0PTR;
    609     pCritSect->pVMRC   = NIL_RTRCPTR;
    610574    if (!fFinal)
    611575        STAMR3DeregisterF(pVM->pUVM, "/PDM/CritSectsRw/%s/*", pCritSect->pszName);
     
    731695 *
    732696 * @returns VBox status code.
    733  * @param   pCritSect           The PDM critical section to destroy.
    734  */
    735 VMMR3DECL(int) PDMR3CritSectDelete(PPDMCRITSECT pCritSect)
     697 * @param   pVM         The cross context VM structure.
     698 * @param   pCritSect   The PDM critical section to destroy.
     699 */
     700VMMR3DECL(int) PDMR3CritSectDelete(PVM pVM, PPDMCRITSECT pCritSect)
    736701{
    737702    if (!RTCritSectIsInitialized(&pCritSect->s.Core))
     
    741706     * Find and unlink it.
    742707     */
    743     PVM             pVM   = pCritSect->s.pVMR3;
    744708    PUVM            pUVM  = pVM->pUVM;
    745709    AssertReleaseReturn(pVM, VERR_PDM_CRITSECT_IPE);
     
    781745     * Find and unlink it.
    782746     */
    783     Assert(pCritSect->s.pVMR3 == pVM);
    784747    PUVM                pUVM  = pVM->pUVM;
    785748    AssertReleaseReturn(pVM, VERR_PDM_CRITSECT_IPE);
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r90346 r90348  
    27372737    AssertReturn(PDMCritSectIsInitialized(pCritSect), VERR_INVALID_PARAMETER);
    27382738    PVM pVM = pDevIns->Internal.s.pVMR3;
    2739     AssertReturn(pCritSect->s.pVMR3 == pVM, VERR_INVALID_PARAMETER);
    27402739
    27412740    VM_ASSERT_EMT(pVM);
     
    27682767    }
    27692768
    2770     PDMR3CritSectDelete(pOldCritSect);
     2769    PDMR3CritSectDelete(pVM, pOldCritSect);
    27712770    Assert((uintptr_t)pOldCritSect - (uintptr_t)pDevIns < pDevIns->cbRing3);
    27722771
     
    28722871{
    28732872    PDMDEV_ASSERT_DEVINS(pDevIns);
    2874     RT_NOREF(pDevIns);
    2875     return PDMR3CritSectDelete(pCritSect);
     2873    return PDMR3CritSectDelete(pDevIns->Internal.s.pVMR3, pCritSect);
    28762874}
    28772875
  • trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp

    r90346 r90348  
    19091909{
    19101910    PDMDRV_ASSERT_DRVINS(pDrvIns);
    1911     RT_NOREF(pDrvIns);
    1912     return PDMR3CritSectDelete(pCritSect);
     1911    return PDMR3CritSectDelete(pDrvIns->Internal.s.pVMR3, pCritSect);
    19131912}
    19141913
  • trunk/src/VBox/VMM/VMMR3/PDMNetShaper.cpp

    r90346 r90348  
    153153    if (!pBwGroup)
    154154    {
    155         rc = MMHyperAlloc(pShaper->pVM, sizeof(PDMNSBWGROUP), 64,
    156                           MM_TAG_PDM_NET_SHAPER, (void **)&pBwGroup);
     155        PVM const pVM = pShaper->pVM;
     156        rc = MMHyperAlloc(pVM, sizeof(PDMNSBWGROUP), 64, MM_TAG_PDM_NET_SHAPER, (void **)&pBwGroup);
    157157        if (RT_SUCCESS(rc))
    158158        {
    159             rc = PDMR3CritSectInit(pShaper->pVM, &pBwGroup->Lock, RT_SRC_POS, "BWGRP-%s", pszBwGroup);
     159            rc = PDMR3CritSectInit(pVM, &pBwGroup->Lock, RT_SRC_POS, "BWGRP-%s", pszBwGroup);
    160160            if (RT_SUCCESS(rc))
    161161            {
    162                 pBwGroup->pszNameR3 = MMR3HeapStrDup(pShaper->pVM, MM_TAG_PDM_NET_SHAPER, pszBwGroup);
     162                pBwGroup->pszNameR3 = MMR3HeapStrDup(pVM, MM_TAG_PDM_NET_SHAPER, pszBwGroup);
    163163                if (pBwGroup->pszNameR3)
    164164                {
     
    176176                    return VINF_SUCCESS;
    177177                }
    178                 PDMR3CritSectDelete(&pBwGroup->Lock);
     178                PDMR3CritSectDelete(pVM, &pBwGroup->Lock);
    179179            }
    180             MMHyperFree(pShaper->pVM, pBwGroup);
     180            MMHyperFree(pVM, pBwGroup);
    181181        }
    182182        else
     
    191191
    192192
    193 static void pdmNsBwGroupTerminate(PPDMNSBWGROUP pBwGroup)
     193static void pdmNsBwGroupTerminate(PVM pVM, PPDMNSBWGROUP pBwGroup)
    194194{
    195195    Assert(pBwGroup->cRefs == 0);
    196196    if (PDMCritSectIsInitialized(&pBwGroup->Lock))
    197         PDMR3CritSectDelete(&pBwGroup->Lock);
     197        PDMR3CritSectDelete(pVM, &pBwGroup->Lock);
    198198}
    199199
     
    469469        PPDMNSBWGROUP pFree = pBwGroup;
    470470        pBwGroup = pBwGroup->pNextR3;
    471         pdmNsBwGroupTerminate(pFree);
     471        pdmNsBwGroupTerminate(pVM, pFree);
    472472        MMR3HeapFree(pFree->pszNameR3);
    473473        MMHyperFree(pVM, pFree);
  • trunk/src/VBox/VMM/VMMR3/PGM.cpp

    r90346 r90348  
    10641064
    10651065    /* Almost no cleanup necessary, MM frees all memory. */
    1066     PDMR3CritSectDelete(&pVM->pgm.s.CritSectX);
     1066    PDMR3CritSectDelete(pVM, &pVM->pgm.s.CritSectX);
    10671067
    10681068    return rc;
     
    21392139
    21402140    PGMDeregisterStringFormatTypes();
    2141     return PDMR3CritSectDelete(&pVM->pgm.s.CritSectX);
     2141    return PDMR3CritSectDelete(pVM, &pVM->pgm.s.CritSectX);
    21422142}
    21432143
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r90347 r90348  
    423423     * PDMR3CritSectInit() sets this to point to the critsect itself. */
    424424    RTR3PTR                         pvKey;
    425     /** Pointer to the VM - R3Ptr. */
    426     PVMR3                           pVMR3;
    427     /** Pointer to the VM - R0Ptr. */
    428     R0PTRTYPE(PVMCC)                pVMR0;
    429     /** Pointer to the VM - GCPtr. */
    430     PVMRC                           pVMRC;
    431425    /** Set if this critical section is the automatically created default
    432426     * section of a device. */
     
    436430    bool                            fUsedByTimerOrSimilar;
    437431    /** Alignment padding. */
    438     bool                            afPadding[2];
     432    bool                            afPadding[2+4];
    439433    /** Support driver event semaphore that is scheduled to be signaled upon leaving
    440434     * the critical section. This is only for Ring-3 and Ring-0. */
     
    476470     * PDMR3CritSectInit() sets this to point to the critsect itself. */
    477471    RTR3PTR                             pvKey;
    478     /** Pointer to the VM - R3Ptr. */
    479     PVMR3                               pVMR3;
    480     /** Pointer to the VM - R0Ptr. */
    481     R0PTRTYPE(PVMCC)                    pVMR0;
    482     /** Pointer to the VM - GCPtr. */
    483     PVMRC                               pVMRC;
    484 #if HC_ARCH_BITS == 64
    485     /** Alignment padding. */
    486     RTRCPTR                             RCPtrPadding;
    487 #endif
    488472    /** The lock name. */
    489473    R3PTRTYPE(const char *)             pszName;
     
    16151599
    16161600int         pdmR3CritSectBothInitStats(PVM pVM);
    1617 void        pdmR3CritSectBothRelocate(PVM pVM);
    16181601int         pdmR3CritSectBothDeleteDevice(PVM pVM, PPDMDEVINS pDevIns);
    16191602int         pdmR3CritSectBothDeleteDriver(PVM pVM, PPDMDRVINS pDrvIns);
Note: See TracChangeset for help on using the changeset viewer.

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