VirtualBox

Changeset 28258 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 13, 2010 2:51:16 PM (15 years ago)
Author:
vboxsync
Message:

PDM critsects for drivers. Fixed critsect cleanup in failure path. Started on new transmit locking scheme (required for intnet buffer serialization).

Location:
trunk/src/VBox
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Input/DrvKeyboardQueue.cpp

    r26173 r28258  
    307307    }
    308308
    309     rc = PDMDrvHlpPDMQueueCreate(pDrvIns, sizeof(DRVKBDQUEUEITEM), cItems, cMilliesInterval, drvKbdQueueConsumer, "Keyboard", &pDrv->pQueue);
     309    rc = PDMDrvHlpQueueCreate(pDrvIns, sizeof(DRVKBDQUEUEITEM), cItems, cMilliesInterval, drvKbdQueueConsumer, "Keyboard", &pDrv->pQueue);
    310310    if (RT_FAILURE(rc))
    311311    {
  • trunk/src/VBox/Devices/Input/DrvMouseQueue.cpp

    r26935 r28258  
    344344    }
    345345
    346     rc = PDMDrvHlpPDMQueueCreate(pDrvIns, sizeof(DRVMOUSEQUEUEITEM), cItems, cMilliesInterval, drvMouseQueueConsumer, "Mouse", &pDrv->pQueue);
     346    rc = PDMDrvHlpQueueCreate(pDrvIns, sizeof(DRVMOUSEQUEUEITEM), cItems, cMilliesInterval, drvMouseQueueConsumer, "Mouse", &pDrv->pQueue);
    347347    if (RT_FAILURE(rc))
    348348    {
  • trunk/src/VBox/Devices/Network/DevINIP.cpp

    r28213 r28258  
    305305 * @param   cMillies    Number of milliseconds to wait. 0 means return immediately.
    306306 */
    307 static DECLCALLBACK(int) devINIPWaitInputAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)
     307static DECLCALLBACK(int) devINIPNetworkDown_WaitInputAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)
    308308{
    309309    LogFlow(("%s: pInterface=%p\n", __FUNCTION__, pInterface));
     
    320320 * @param   cb          Frame size.
    321321 */
    322 static DECLCALLBACK(int) devINIPInput(PPDMINETWORKDOWN pInterface,
    323                                       const void *pvBuf, size_t cb)
     322static DECLCALLBACK(int) devINIPNetworkDown_Input(PPDMINETWORKDOWN pInterface,
     323                                                  const void *pvBuf, size_t cb)
    324324{
    325325    const uint8_t *pbBuf = (const uint8_t *)pvBuf;
     
    385385
    386386/**
     387 * @interface_method_impl{PDMINETWORKDOWN,pfnDoTransmitWork}
     388 */
     389static DECLCALLBACK(void) devINIPNetworkDown_DoTransmitWork(PPDMINETWORKDOWN pInterface)
     390{
     391    NOREF(pInterface);
     392}
     393
     394
     395/**
    387396 * Signals the end of lwIP TCPIP initialization.
    388397 *
     
    483492    pThis->IBase.pfnQueryInterface          = devINIPQueryInterface;
    484493    /* INetworkDown */
    485     pThis->INetworkDown.pfnWaitReceiveAvail = devINIPWaitInputAvail;
    486     pThis->INetworkDown.pfnReceive          = devINIPInput;
     494    pThis->INetworkDown.pfnWaitReceiveAvail = devINIPNetworkDown_WaitInputAvail;
     495    pThis->INetworkDown.pfnReceive          = devINIPNetworkDown_Input;
     496    pThis->INetworkDown.pfnDoTransmitWork   = devINIPNetworkDown_DoTransmitWork;
    487497
    488498    /*
  • trunk/src/VBox/Devices/Network/DrvIntNet.cpp

    r28213 r28258  
     1#define VBOX_WITH_R0_AND_RC_DRIVERS
    12/* $Id$ */
    23/** @file
     
    111112    /** Base interface for ring-0. */
    112113    PDMIBASERC                      IBaseRC;
     114
     115    /** The transmit lock. */
     116    PDMCRITSECT                     XmitLock;
    113117
    114118#ifdef LOG_ENABLED
     
    190194}
    191195
     196
     197
    192198/* -=-=-=-=- PDMINETWORKUP -=-=-=-=- */
     199
     200/**
     201 * @interface_method_impl{PDMINETWORKUP,pfnBeginXmit}
     202 */
     203static DECLCALLBACK(int) drvR3IntNetUp_BeginXmit(PPDMINETWORKUP pInterface)
     204{
     205    PDRVINTNET pThis = RT_FROM_MEMBER(pInterface, DRVINTNET, INetworkUpR3);
     206    int rc = PDMCritSectTryEnter(&pThis->XmitLock);
     207    if (RT_UNLIKELY(rc == VERR_SEM_BUSY))
     208        rc = VERR_TRY_AGAIN;
     209    return rc;
     210}
     211
    193212
    194213/**
     
    201220    int         rc    = VINF_SUCCESS;
    202221    Assert(cbMin < UINT32_MAX / 2);
     222//    Assert(PDMCritSectIsOwner(&pThis->XmitLock));
    203223
    204224    /*
     
    277297    Assert(   pHdr->u16Type == INTNETHDR_TYPE_FRAME
    278298           || pHdr->u16Type == INTNETHDR_TYPE_GSO);
     299//    Assert(PDMCritSectIsOwner(&pThis->XmitLock));
    279300
    280301    /** @todo LATER: try unalloc the frame. */
     
    298319    Assert(pSgBuf->fFlags == (PDMSCATTERGATHER_FLAGS_MAGIC | PDMSCATTERGATHER_FLAGS_OWNER_1));
    299320    Assert(pSgBuf->cbUsed <= pSgBuf->cbAvailable);
     321//    Assert(PDMCritSectIsOwner(&pThis->XmitLock));
    300322
    301323    if (pSgBuf->pvUser)
     
    319341    STAM_PROFILE_STOP(&pThis->StatTransmit, a);
    320342    return VINF_SUCCESS;
     343}
     344
     345
     346/**
     347 * @interface_method_impl{PDMINETWORKUP,pfnEndXmit}
     348 */
     349static DECLCALLBACK(void) drvR3IntNetUp_EndXmit(PPDMINETWORKUP pInterface)
     350{
     351    PDRVINTNET pThis = RT_FROM_MEMBER(pInterface, DRVINTNET, INetworkUpR3);
     352    PDMCritSectLeave(&pThis->XmitLock);
    321353}
    322354
     
    762794        Frame.Hdr.DstMac.au16[1] = 0xffff;
    763795        Frame.Hdr.DstMac.au16[2] = 0xffff;
    764         Frame.Hdr.EtherType      = RT_H2BE_U16(0x801e);
     796        Frame.Hdr.EtherType      = RT_H2BE_U16_C(0x801e);
    765797        int rc = pThis->pIAboveConfigR3->pfnGetMac(pThis->pIAboveConfigR3, &Frame.Hdr.SrcMac);
    766798        if (RT_SUCCESS(rc))
     
    805837        drvR3IntNetSetActive(pThis, true /* fActive */);
    806838    }
     839}
     840
     841
     842/**
     843 * @interface_method_impl{PDMDRVREG,pfnRelocate}
     844 */
     845static DECLCALLBACK(void) drvR3IntNetRelocate(PPDMDRVINS pDrvIns, RTGCINTPTR offDelta)
     846{
     847    /* nothing to do here yet */
    807848}
    808849
     
    858899
    859900    /*
    860      * Destroy the semaphore and S/G cache.
     901     * Destroy the semaphore, S/G cache and xmit lock.
    861902     */
    862903    if (hEvtSuspended != NIL_RTSEMEVENT)
     
    865906    RTMemCacheDestroy(pThis->hSgCache);
    866907    pThis->hSgCache = NIL_RTMEMCACHE;
     908
     909    if (PDMCritSectIsInitialized(&pThis->XmitLock))
     910        PDMR3CritSectDelete(&pThis->XmitLock);
    867911
    868912    if (pThis->pBufR3)
     
    917961    pThis->IBaseRC.pfnQueryInterface                = drvR3IntNetIBaseRC_QueryInterface;
    918962    /* INetworkUp */
     963    pThis->INetworkUpR3.pfnBeginXmit                = drvR3IntNetUp_BeginXmit;
    919964    pThis->INetworkUpR3.pfnAllocBuf                 = drvR3IntNetUp_AllocBuf;
    920965    pThis->INetworkUpR3.pfnFreeBuf                  = drvR3IntNetUp_FreeBuf;
    921966    pThis->INetworkUpR3.pfnSendBuf                  = drvR3IntNetUp_SendBuf;
     967    pThis->INetworkUpR3.pfnEndXmit                  = drvR3IntNetUp_EndXmit;
    922968    pThis->INetworkUpR3.pfnSetPromiscuousMode       = drvR3IntNetUp_SetPromiscuousMode;
    923969    pThis->INetworkUpR3.pfnNotifyLinkChanged        = drvR3IntNetUp_NotifyLinkChanged;
     
    11861232
    11871233    /*
    1188      * Create the event semaphore and S/G cache.
     1234     * Create the event semaphore, S/G cache and xmit critsect.
    11891235     */
    11901236    rc = RTSemEventCreate(&pThis->hEvtSuspended);
     
    11941240    if (RT_FAILURE(rc))
    11951241        return rc;
     1242    rc = PDMDrvHlpCritSectInit(pDrvIns, &pThis->XmitLock, RT_SRC_POS, "IntNetXmit");
     1243    if (RT_FAILURE(rc))
     1244        return rc;
     1245
    11961246
    11971247    /*
     
    12761326    "IntNet",
    12771327    /* szRCMod */
    1278     "VBoxDD",
     1328    "VBoxDDRC",
    12791329    /* szR0Mod */
    1280     "VBoxDD",
     1330    "VBoxDDR0",
    12811331    /* pszDescription */
    12821332    "Internal Networking Transport Driver",
     
    12981348    drvR3IntNetDestruct,
    12991349    /* pfnRelocate */
    1300     NULL,
     1350    drvR3IntNetRelocate,
    13011351    /* pfnIOCtl */
    13021352    NULL,
  • trunk/src/VBox/Devices/Network/DrvNAT.cpp

    r28216 r28258  
    151151    /** tftp server name to provide in the DHCP server response. */
    152152    char                   *pszNextServer;
    153     /* polling thread */
     153    /** Polling thread. */
    154154    PPDMTHREAD              pSlirpThread;
    155155    /** Queue for NAT-thread-external events. */
     
    193193
    194194    /** makes access to device func RecvAvail and Recv atomical. */
    195     RTCRITSECT              csDevAccess;
    196     volatile uint32_t       cUrgPkt;
    197     volatile uint32_t       cPkt;
     195    RTCRITSECT              DevAccessLock;
     196    /** Number of in-flight urgent packets. */
     197    volatile uint32_t       cUrgPkts;
     198    /** Number of in-flight regular packets. */
     199    volatile uint32_t       cPkts;
     200
     201    /** Transmit lock taken by BeginXmit and released by EndXmit. */
     202    RTCRITSECT              XmitLock;
    198203} DRVNAT;
    199204AssertCompileMemberAlignment(DRVNAT, StatNATRecvWakeups, 8);
     
    235240    {
    236241        RTReqProcess(pThis->pRecvReqQueue, 0);
    237         if (ASMAtomicReadU32(&pThis->cPkt) == 0)
     242        if (ASMAtomicReadU32(&pThis->cPkts) == 0)
    238243            RTSemEventWait(pThis->EventRecv, RT_INDEFINITE_WAIT);
    239244    }
     
    262267    {
    263268        RTReqProcess(pThis->pUrgRecvReqQueue, 0);
    264         if (ASMAtomicReadU32(&pThis->cUrgPkt) == 0)
     269        if (ASMAtomicReadU32(&pThis->cUrgPkts) == 0)
    265270        {
    266271            int rc = RTSemEventWait(pThis->EventUrgRecv, RT_INDEFINITE_WAIT);
     
    282287static DECLCALLBACK(void) drvNATUrgRecvWorker(PDRVNAT pThis, uint8_t *pu8Buf, int cb, struct mbuf *m)
    283288{
    284     int rc = RTCritSectEnter(&pThis->csDevAccess);
     289    int rc = RTCritSectEnter(&pThis->DevAccessLock);
    285290    AssertRC(rc);
    286291    rc = pThis->pIAboveNet->pfnWaitReceiveAvail(pThis->pIAboveNet, RT_INDEFINITE_WAIT);
     
    297302    }
    298303
    299     rc = RTCritSectLeave(&pThis->csDevAccess);
     304    rc = RTCritSectLeave(&pThis->DevAccessLock);
    300305    AssertRC(rc);
    301306
     
    304309    RTMemFree(pu8Buf);
    305310#endif
    306     if (ASMAtomicDecU32(&pThis->cUrgPkt) == 0)
     311    if (ASMAtomicDecU32(&pThis->cUrgPkts) == 0)
    307312    {
    308313        drvNATRecvWakeup(pThis->pDrvIns, pThis->pRecvThread);
     
    319324    STAM_PROFILE_START(&pThis->StatNATRecvWait, b);
    320325
    321     while (ASMAtomicReadU32(&pThis->cUrgPkt) != 0)
     326    while (ASMAtomicReadU32(&pThis->cUrgPkts) != 0)
    322327    {
    323328        rc = RTSemEventWait(pThis->EventRecv, RT_INDEFINITE_WAIT);
     
    328333    }
    329334
    330     rc = RTCritSectEnter(&pThis->csDevAccess);
     335    rc = RTCritSectEnter(&pThis->DevAccessLock);
    331336    AssertRC(rc);
    332337
     
    344349    }
    345350
    346     rc = RTCritSectLeave(&pThis->csDevAccess);
     351    rc = RTCritSectLeave(&pThis->DevAccessLock);
    347352    AssertRC(rc);
    348353
     
    352357    RTMemFree(pu8Buf);
    353358#endif
    354     ASMAtomicDecU32(&pThis->cPkt);
     359    ASMAtomicDecU32(&pThis->cPkts);
    355360
    356361    drvNATNotifyNATThread(pThis, "drvNATRecvWorker");
     
    451456
    452457/**
     458 * @interface_method_impl{PDMINETWORKUP,pfnBeginXmit}
     459 */
     460static DECLCALLBACK(int) drvNATNetworkUp_BeginXmit(PPDMINETWORKUP pInterface)
     461{
     462    PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkUp);
     463    int rc = RTCritSectTryEnter(&pThis->XmitLock);
     464    if (RT_FAILURE(rc))
     465    {
     466        /** @todo Kick the worker thread when we have one... */
     467        rc = VERR_TRY_AGAIN;
     468    }
     469    return rc;
     470}
     471
     472/**
    453473 * @interface_method_impl{PDMINETWORKUP,pfnAllocBuf}
    454474 */
     
    457477{
    458478    PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkUp);
     479//    Assert(RTCritSectIsOwner(&pThis->XmitLock);
    459480
    460481    /*
     
    522543{
    523544    PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkUp);
     545//    Assert(RTCritSectIsOwner(&pThis->XmitLock);
    524546    drvNATFreeSgBuf(pThis, pSgBuf);
    525547    return VINF_SUCCESS;
     
    533555    PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkUp);
    534556    Assert((pSgBuf->fFlags & PDMSCATTERGATHER_FLAGS_OWNER_MASK) == PDMSCATTERGATHER_FLAGS_OWNER_1);
     557//    Assert(RTCritSectIsOwner(&pThis->XmitLock);
    535558
    536559    int rc;
     
    556579    drvNATFreeSgBuf(pThis, pSgBuf);
    557580    return rc;
     581}
     582
     583/**
     584 * @interface_method_impl{PDMINETWORKUP,pfnEndXmit}
     585 */
     586static DECLCALLBACK(void) drvNATNetworkUp_EndXmit(PPDMINETWORKUP pInterface)
     587{
     588    PDRVNAT pThis = RT_FROM_MEMBER(pInterface, DRVNAT, INetworkUp);
     589    RTCritSectLeave(&pThis->XmitLock);
    558590}
    559591
     
    841873        return;
    842874
    843     ASMAtomicIncU32(&pThis->cUrgPkt);
     875    ASMAtomicIncU32(&pThis->cUrgPkts);
    844876    int rc = RTReqCallEx(pThis->pUrgRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,
    845877                         (PFNRT)drvNATUrgRecvWorker, 4, pThis, pu8Buf, cb, m);
     
    865897        return;
    866898
    867     ASMAtomicIncU32(&pThis->cPkt);
     899    ASMAtomicIncU32(&pThis->cPkts);
    868900    int rc = RTReqCallEx(pThis->pRecvReqQueue, NULL /*ppReq*/, 0 /*cMillies*/, RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,
    869901                         (PFNRT)drvNATRecvWorker, 4, pThis, pu8Buf, cb, m);
     
    10301062        pThis->pNATState = NULL;
    10311063    }
     1064
     1065    RTReqDestroyQueue(pThis->pSlirpReqQueue);
     1066    pThis->pSlirpReqQueue = NULL;
     1067
     1068    RTReqDestroyQueue(pThis->pUrgRecvReqQueue);
     1069    pThis->pUrgRecvReqQueue = NULL;
     1070
     1071    RTSemEventDestroy(pThis->EventRecv);
     1072    pThis->EventRecv = NIL_RTSEMEVENT;
     1073
     1074    RTSemEventDestroy(pThis->EventUrgRecv);
     1075    pThis->EventUrgRecv = NIL_RTSEMEVENT;
     1076
     1077    if (RTCritSectIsInitialized(&pThis->DevAccessLock))
     1078        RTCritSectDelete(&pThis->DevAccessLock);
     1079
     1080    if (RTCritSectIsInitialized(&pThis->XmitLock))
     1081        RTCritSectDelete(&pThis->XmitLock);
    10321082}
    10331083
     
    10641114    pThis->pszBootFile                  = NULL;
    10651115    pThis->pszNextServer                = NULL;
     1116    pThis->pSlirpReqQueue               = NULL;
     1117    pThis->pUrgRecvReqQueue             = NULL;
     1118    pThis->EventRecv                    = NIL_RTSEMEVENT;
     1119    pThis->EventUrgRecv                 = NIL_RTSEMEVENT;
     1120
    10661121    /* IBase */
    10671122    pDrvIns->IBase.pfnQueryInterface    = drvNATQueryInterface;
     1123
    10681124    /* INetwork */
     1125    pThis->INetworkUp.pfnBeginXmit          = drvNATNetworkUp_BeginXmit;
    10691126    pThis->INetworkUp.pfnAllocBuf           = drvNATNetworkUp_AllocBuf;
    10701127    pThis->INetworkUp.pfnFreeBuf            = drvNATNetworkUp_FreeBuf;
    10711128    pThis->INetworkUp.pfnSendBuf            = drvNATNetworkUp_SendBuf;
     1129    pThis->INetworkUp.pfnEndXmit            = drvNATNetworkUp_EndXmit;
    10721130    pThis->INetworkUp.pfnSetPromiscuousMode = drvNATNetworkUp_SetPromiscuousMode;
    10731131    pThis->INetworkUp.pfnNotifyLinkChanged  = drvNATNetworkUp_NotifyLinkChanged;
     
    11701228#endif
    11711229
    1172         int rc2 = drvNATConstructRedir(pDrvIns->iInstance, pThis, pCfg, Network);
    1173         if (RT_SUCCESS(rc2))
     1230        rc = drvNATConstructRedir(pDrvIns->iInstance, pThis, pCfg, Network);
     1231        if (RT_SUCCESS(rc))
    11741232        {
    11751233            /*
     
    11771235             * engine after we loaded a guest state.
    11781236             */
    1179             rc2 = PDMDrvHlpSSMRegisterLoadDone(pDrvIns, drvNATLoadDone);
    1180             AssertRC(rc2);
     1237            rc = PDMDrvHlpSSMRegisterLoadDone(pDrvIns, drvNATLoadDone);
     1238            AssertRCReturn(rc, rc);
     1239
    11811240            rc = RTReqCreateQueue(&pThis->pSlirpReqQueue);
    11821241            if (RT_FAILURE(rc))
     
    11931252                return rc;
    11941253            }
     1254
    11951255            rc = RTReqCreateQueue(&pThis->pUrgRecvReqQueue);
    11961256            if (RT_FAILURE(rc))
     
    11991259                return rc;
    12001260            }
    1201             rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pRecvThread, pThis, drvNATRecv,
    1202                                           drvNATRecvWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATRX");
    1203             AssertRC(rc);
     1261
     1262            rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pRecvThread, pThis, drvNATRecv,
     1263                                       drvNATRecvWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATRX");
     1264            AssertRCReturn(rc, rc);
     1265
    12041266            rc = RTSemEventCreate(&pThis->EventRecv);
    1205 
    1206             rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pUrgRecvThread, pThis, drvNATUrgRecv,
    1207                                           drvNATUrgRecvWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATURGRX");
    1208             AssertRC(rc);
     1267            AssertRCReturn(rc, rc);
     1268
     1269            rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pUrgRecvThread, pThis, drvNATUrgRecv,
     1270                                       drvNATUrgRecvWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATURGRX");
     1271            AssertRCReturn(rc, rc);
     1272
    12091273            rc = RTSemEventCreate(&pThis->EventRecv);
     1274            AssertRCReturn(rc, rc);
     1275
    12101276            rc = RTSemEventCreate(&pThis->EventUrgRecv);
    1211             rc = RTCritSectInit(&pThis->csDevAccess);
     1277            AssertRCReturn(rc, rc);
     1278
     1279            rc = RTCritSectInit(&pThis->DevAccessLock);
     1280            AssertRCReturn(rc, rc);
     1281
     1282            rc = RTCritSectInit(&pThis->XmitLock);
     1283            AssertRCReturn(rc, rc);
    12121284
    12131285#ifndef RT_OS_WINDOWS
     
    12301302#endif
    12311303
    1232             rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pSlirpThread, pThis, drvNATAsyncIoThread,
    1233                                           drvNATAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "NAT");
     1304            rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pSlirpThread, pThis, drvNATAsyncIoThread,
     1305                                       drvNATAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "NAT");
    12341306            AssertRC(rc);
    12351307
    12361308#ifdef VBOX_WITH_SLIRP_MT
    1237             rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pGuestThread, pThis, drvNATAsyncIoGuest,
    1238                                           drvNATAsyncIoGuestWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATGUEST");
     1309            rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pGuestThread, pThis, drvNATAsyncIoGuest,
     1310                                       drvNATAsyncIoGuestWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATGUEST");
    12391311            AssertRC(rc);
    12401312#endif
     
    12451317            return rc;
    12461318        }
     1319
    12471320        /* failure path */
    1248         rc = rc2;
    12491321        slirp_term(pThis->pNATState);
    12501322        pThis->pNATState = NULL;
  • trunk/src/VBox/Devices/Network/DrvNetSniffer.cpp

    r28213 r28258  
    7777    /** Pointer to the driver instance. */
    7878    PPDMDRVINS              pDrvIns;
     79    /** For when we're the leaf driver. */
     80    RTCRITSECT              XmitLock;
    7981
    8082} DRVNETSNIFFER, *PDRVNETSNIFFER;
    8183
     84
     85
     86/**
     87 * @interface_method_impl{PDMINETWORKUP,pfnBeginXmit}
     88 */
     89static DECLCALLBACK(int) drvNetSnifferUp_BeginXmit(PPDMINETWORKUP pInterface)
     90{
     91    PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkUp);
     92    if (RT_UNLIKELY(!pThis->pIBelowNet))
     93    {
     94        int rc = RTCritSectTryEnter(&pThis->XmitLock);
     95        if (RT_UNLIKELY(rc == VERR_SEM_BUSY))
     96            rc = VERR_TRY_AGAIN;
     97        return rc;
     98    }
     99    return pThis->pIBelowNet->pfnBeginXmit(pThis->pIBelowNet);
     100}
    82101
    83102
     
    135154
    136155/**
     156 * @interface_method_impl{PDMINETWORKUP,pfnEndXmit}
     157 */
     158static DECLCALLBACK(void) drvNetSnifferUp_EndXmit(PPDMINETWORKUP pInterface)
     159{
     160    LogFlow(("drvNetSnifferUp_EndXmit:\n"));
     161    PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkUp);
     162    if (RT_LIKELY(pThis->pIBelowNet))
     163        pThis->pIBelowNet->pfnEndXmit(pThis->pIBelowNet);
     164    else
     165        RTCritSectLeave(&pThis->XmitLock);
     166}
     167
     168
     169/**
    137170 * @interface_method_impl{PDMINETWORKUP,pfnSetPromiscuousMode}
    138171 */
     
    159192
    160193/**
    161  * @copydoc PDMINETWORKDOWN::pfnWaitReceiveAvail
     194 * @interface_method_impl{PDMINETWORKDOWN,pfnWaitReceiveAvail}
    162195 */
    163196static DECLCALLBACK(int) drvNetSnifferDown_WaitReceiveAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)
     
    169202
    170203/**
    171  * @copydoc PDMINETWORKDOWN::pfnReceive
     204 * @interface_method_impl{PDMINETWORKDOWN,pfnReceive}
    172205 */
    173206static DECLCALLBACK(int) drvNetSnifferDown_Receive(PPDMINETWORKDOWN pInterface, const void *pvBuf, size_t cb)
     
    196229
    197230/**
    198  * @copydoc PDMINETWORKDOWN::pfnNotifyBufAvailable
    199  */
    200 static DECLCALLBACK(void) drvNetSnifferDown_NotifyBufAvailable(PPDMINETWORKDOWN pInterface)
     231 * @interface_method_impl{PDMINETWORKDOWN,pfnDoTransmitWork}
     232 */
     233static DECLCALLBACK(void) drvNetSnifferDown_DoTransmitWork(PPDMINETWORKDOWN pInterface)
    201234{
    202235    PDRVNETSNIFFER pThis = RT_FROM_MEMBER(pInterface, DRVNETSNIFFER, INetworkDown);
    203     pThis->pIAboveNet->pfnNotifyBufAvailable(pThis->pIAboveNet);
     236    pThis->pIAboveNet->pfnDoTransmitWork(pThis->pIAboveNet);
    204237}
    205238
     
    263296
    264297/**
    265  * Detach a driver instance.
    266  *
    267  * @param   pDrvIns     The driver instance.
    268  * @param   fFlags      Flags, combination of the PDM_TACH_FLAGS_* \#defines.
     298 * @interface_method_impl{PDMDRVREG,pfnDetach}
    269299 */
    270300static DECLCALLBACK(void) drvNetSnifferDetach(PPDMDRVINS pDrvIns, uint32_t fFlags)
     
    273303
    274304    LogFlow(("drvNetSnifferDetach: pDrvIns: %p, fFlags: %u\n", pDrvIns, fFlags));
    275 
     305    RTCritSectEnter(&pThis->XmitLock);
    276306    pThis->pIBelowNet = NULL;
    277 }
    278 
    279 
    280 /**
    281  * Attach a driver instance.
    282  *
    283  * @returns VBox status code.
    284  * @param   pDrvIns     The driver instance.
    285  * @param   fFlags      Flags, combination of the PDM_TACH_FLAGS_* \#defines.
     307    RTCritSectLeave(&pThis->XmitLock);
     308}
     309
     310
     311/**
     312 * @interface_method_impl{PDMDRVREG,pfnAttach}
    286313 */
    287314static DECLCALLBACK(int) drvNetSnifferAttach(PPDMDRVINS pDrvIns, uint32_t fFlags)
    288315{
    289316    PDRVNETSNIFFER pThis = PDMINS_2_DATA(pDrvIns, PDRVNETSNIFFER);
    290 
    291     LogFlow(("drvNetSnifferAttach: pDrvIns: %p, fFlags: %u\n", pDrvIns, fFlags));
     317    LogFlow(("drvNetSnifferAttach/#%#x: fFlags=%#x\n", pDrvIns->iInstance, fFlags));
     318    RTCritSectEnter(&pThis->XmitLock);
    292319
    293320    /*
     
    298325    if (   rc == VERR_PDM_NO_ATTACHED_DRIVER
    299326        || rc == VERR_PDM_CFG_MISSING_DRIVER_NAME)
     327    {
    300328        pThis->pIBelowNet = NULL;
     329        rc = VINF_SUCCESS;
     330    }
    301331    else if (RT_SUCCESS(rc))
    302332    {
    303333        pThis->pIBelowNet = PDMIBASE_QUERY_INTERFACE(pBaseDown, PDMINETWORKUP);
    304         if (!pThis->pIBelowNet)
     334        if (pThis->pIBelowNet)
     335            rc = VINF_SUCCESS;
     336        else
    305337        {
    306338            AssertMsgFailed(("Configuration error: the driver below didn't export the network connector interface!\n"));
    307             return VERR_PDM_MISSING_INTERFACE_BELOW;
     339            rc = VERR_PDM_MISSING_INTERFACE_BELOW;
    308340        }
    309341    }
    310342    else
    311     {
    312343        AssertMsgFailed(("Failed to attach to driver below! rc=%Rrc\n", rc));
    313         return rc;
    314     }
    315 
     344
     345    RTCritSectLeave(&pThis->XmitLock);
    316346    return VINF_SUCCESS;
    317347}
     
    319349
    320350/**
    321  * Destruct a driver instance.
    322  *
    323  * Most VM resources are freed by the VM. This callback is provided so that any non-VM
    324  * resources can be freed correctly.
    325  *
    326  * @param   pDrvIns     The driver instance data.
     351 * @interface_method_impl{PDMDRVREG,pfnDestruct}
    327352 */
    328353static DECLCALLBACK(void) drvNetSnifferDestruct(PPDMDRVINS pDrvIns)
     
    334359        RTCritSectDelete(&pThis->Lock);
    335360
     361    if (RTCritSectIsInitialized(&pThis->XmitLock))
     362        RTCritSectDelete(&pThis->XmitLock);
     363
    336364    if (pThis->File != NIL_RTFILE)
    337365    {
     
    343371
    344372/**
    345  * Construct a NAT network transport driver instance.
    346  *
    347  * @copydoc FNPDMDRVCONSTRUCT
     373 * @interface_method_impl{Construct a NAT network transport driver instance,
     374 *                       PDMDRVREG,pfnDestruct}
    348375 */
    349376static DECLCALLBACK(int) drvNetSnifferConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
     
    352379    LogFlow(("drvNetSnifferConstruct:\n"));
    353380    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
    354 
    355     /*
    356      * Validate the config.
    357      */
    358     if (!CFGMR3AreValuesValid(pCfg, "File\0"))
    359         return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
    360 
    361     if (CFGMR3GetFirstChild(pCfg))
    362         LogRel(("NetSniffer: Found child config entries -- are you trying to redirect ports?\n"));
    363381
    364382    /*
     
    372390    pDrvIns->IBase.pfnQueryInterface                = drvNetSnifferQueryInterface;
    373391    /* INetworkUp */
     392    pThis->INetworkUp.pfnBeginXmit                  = drvNetSnifferUp_BeginXmit;
    374393    pThis->INetworkUp.pfnAllocBuf                   = drvNetSnifferUp_AllocBuf;
    375394    pThis->INetworkUp.pfnFreeBuf                    = drvNetSnifferUp_FreeBuf;
    376395    pThis->INetworkUp.pfnSendBuf                    = drvNetSnifferUp_SendBuf;
     396    pThis->INetworkUp.pfnEndXmit                    = drvNetSnifferUp_EndXmit;
    377397    pThis->INetworkUp.pfnSetPromiscuousMode         = drvNetSnifferUp_SetPromiscuousMode;
    378398    pThis->INetworkUp.pfnNotifyLinkChanged          = drvNetSnifferUp_NotifyLinkChanged;
     
    380400    pThis->INetworkDown.pfnWaitReceiveAvail         = drvNetSnifferDown_WaitReceiveAvail;
    381401    pThis->INetworkDown.pfnReceive                  = drvNetSnifferDown_Receive;
    382     pThis->INetworkDown.pfnNotifyBufAvailable       = drvNetSnifferDown_NotifyBufAvailable;
     402    pThis->INetworkDown.pfnDoTransmitWork           = drvNetSnifferDown_DoTransmitWork;
    383403    /* INetworkConfig */
    384404    pThis->INetworkConfig.pfnGetMac                 = drvNetSnifferDownCfg_GetMac;
     
    387407
    388408    /*
     409     * Create the locks.
     410     */
     411    int rc = RTCritSectInit(&pThis->Lock);
     412    AssertRCReturn(rc, rc);
     413    rc = RTCritSectInit(&pThis->XmitLock);
     414    AssertRCReturn(rc, rc);
     415
     416    /*
     417     * Validate the config.
     418     */
     419    if (!CFGMR3AreValuesValid(pCfg, "File\0"))
     420        return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
     421
     422    if (CFGMR3GetFirstChild(pCfg))
     423        LogRel(("NetSniffer: Found child config entries -- are you trying to redirect ports?\n"));
     424
     425    /*
    389426     * Get the filename.
    390427     */
    391     int rc = CFGMR3QueryString(pCfg, "File", pThis->szFilename, sizeof(pThis->szFilename));
     428    rc = CFGMR3QueryString(pCfg, "File", pThis->szFilename, sizeof(pThis->szFilename));
    392429    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    393430    {
     
    446483        return rc;
    447484    }
    448 
    449     /*
    450      * Create the lock.
    451      */
    452     rc = RTCritSectInit(&pThis->Lock);
    453     if (RT_FAILURE(rc))
    454         return rc;
    455485
    456486    /*
  • trunk/src/VBox/Devices/Network/DrvTAP.cpp

    r28213 r28258  
    11161116     * Create the async I/O thread.
    11171117     */
    1118     rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pThread, pThis, drvTAPAsyncIoThread, drvTapAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "TAP");
     1118    rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pThread, pThis, drvTAPAsyncIoThread, drvTapAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "TAP");
    11191119    AssertRCReturn(rc, rc);
    11201120
  • trunk/src/VBox/Devices/PC/DrvACPI.cpp

    r27327 r28258  
    982982     * Start the poller thread.
    983983     */
    984     rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pPollerThread, pThis, drvACPIPoller,
    985                                   drvACPIPollerWakeup, 0, RTTHREADTYPE_INFREQUENT_POLLER, "ACPI Poller");
     984    rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pPollerThread, pThis, drvACPIPoller,
     985                               drvACPIPollerWakeup, 0, RTTHREADTYPE_INFREQUENT_POLLER, "ACPI Poller");
    986986    if (RT_FAILURE(rc))
    987987        return rc;
  • trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp

    r26173 r28258  
    379379     * Start waiting for interrupts.
    380380     */
    381     rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostParallelMonitorThread, drvHostParallelWakeupMonitorThread, 0,
    382                                   RTTHREADTYPE_IO, "ParMon");
     381    rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostParallelMonitorThread, drvHostParallelWakeupMonitorThread, 0,
     382                               RTTHREADTYPE_IO, "ParMon");
    383383    if (RT_FAILURE(rc))
    384384        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostParallel#%d cannot create monitor thread"), pDrvIns->iInstance);
  • trunk/src/VBox/Devices/Serial/DrvHostSerial.cpp

    r27394 r28258  
    14351435     * Create the receive, send and monitor threads pluss the related send semaphore.
    14361436     */
    1437     rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pRecvThread, pThis, drvHostSerialRecvThread, drvHostSerialWakeupRecvThread, 0, RTTHREADTYPE_IO, "SerRecv");
     1437    rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pRecvThread, pThis, drvHostSerialRecvThread, drvHostSerialWakeupRecvThread, 0, RTTHREADTYPE_IO, "SerRecv");
    14381438    if (RT_FAILURE(rc))
    14391439        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create receive thread"), pDrvIns->iInstance);
     
    14421442    AssertRC(rc);
    14431443
    1444     rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pSendThread, pThis, drvHostSerialSendThread, drvHostSerialWakeupSendThread, 0, RTTHREADTYPE_IO, "SerSend");
     1444    rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pSendThread, pThis, drvHostSerialSendThread, drvHostSerialWakeupSendThread, 0, RTTHREADTYPE_IO, "SerSend");
    14451445    if (RT_FAILURE(rc))
    14461446        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create send thread"), pDrvIns->iInstance);
     
    14511451    ioctl(pThis->DeviceFile, TIOCMGET, &pThis->fStatusLines);
    14521452# endif
    1453     rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostSerialMonitorThread, drvHostSerialWakeupMonitorThread, 0, RTTHREADTYPE_IO, "SerMon");
     1453    rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostSerialMonitorThread, drvHostSerialWakeupMonitorThread, 0, RTTHREADTYPE_IO, "SerMon");
    14541454    if (RT_FAILURE(rc))
    14551455        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create monitor thread"), pDrvIns->iInstance);
  • trunk/src/VBox/Devices/Storage/DrvSCSI.cpp

    r28065 r28258  
    697697
    698698    /* Create I/O thread. */
    699     rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsiAsyncIOLoop,
    700                                   drvscsiAsyncIOLoopWakeup, 0, RTTHREADTYPE_IO, "SCSI async IO");
     699    rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsiAsyncIOLoop,
     700                               drvscsiAsyncIOLoopWakeup, 0, RTTHREADTYPE_IO, "SCSI async IO");
    701701    AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create async I/O thread rc=%Rrc\n"), rc);
    702702
  • trunk/src/VBox/Devices/Storage/DrvSCSIHost.cpp

    r28065 r28258  
    484484
    485485    /* Create I/O thread. */
    486     rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsihostAsyncIOLoop,
    487                                   drvscsihostAsyncIOLoopWakeup, 0, RTTHREADTYPE_IO, "SCSI async IO");
     486    rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pAsyncIOThread, pThis, drvscsihostAsyncIOLoop,
     487                               drvscsihostAsyncIOLoopWakeup, 0, RTTHREADTYPE_IO, "SCSI async IO");
    488488    AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create async I/O thread rc=%Rrc\n"), rc);
    489489
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r28065 r28258  
    344344        if (RT_SUCCESS(rc))
    345345        {
    346             rc = PDMDrvHlpPDMAsyncCompletionTemplateCreate(pThis->pDrvIns, &pStorageBackend->pTemplate,
    347                                                            drvvdAsyncTaskCompleted, pStorageBackend, "AsyncTaskCompleted");
     346            rc = PDMDrvHlpAsyncCompletionTemplateCreate(pThis->pDrvIns, &pStorageBackend->pTemplate,
     347                                                        drvvdAsyncTaskCompleted, pStorageBackend, "AsyncTaskCompleted");
    348348            if (RT_SUCCESS(rc))
    349349            {
  • trunk/src/VBox/VMM/PDM.cpp

    r27936 r28258  
    307307    AssertCompile(sizeof(pUVM->pdm.s) <= sizeof(pUVM->pdm.padding));
    308308    AssertRelease(sizeof(pUVM->pdm.s) <= sizeof(pUVM->pdm.padding));
    309     pUVM->pdm.s.pModules = NULL;
    310     return VINF_SUCCESS;
     309    pUVM->pdm.s.pModules   = NULL;
     310    pUVM->pdm.s.pCritSects = NULL;
     311    return RTCritSectInit(&pUVM->pdm.s.ListCritSect);
    311312}
    312313
     
    337338     * Initialize sub compontents.
    338339     */
    339     int rc = RTCritSectInit(&pVM->pdm.s.MiscCritSect);
    340     if (RT_SUCCESS(rc))
    341         rc = pdmR3CritSectInit(pVM);
     340    int rc = pdmR3CritSectInitStats(pVM);
    342341    if (RT_SUCCESS(rc))
    343342        rc = PDMR3CritSectInit(pVM, &pVM->pdm.s.CritSect, RT_SRC_POS, "PDM");
     
    649648     */
    650649    pdmR3LdrTermU(pUVM);
     650
     651    Assert(pUVM->pdm.s.pCritSects == NULL);
     652    RTCritSectDelete(&pUVM->pdm.s.ListCritSect);
    651653}
    652654
  • trunk/src/VBox/VMM/PDMCritSect.cpp

    r25748 r28258  
    2929#include <VBox/mm.h>
    3030#include <VBox/vm.h>
     31#include <VBox/uvm.h>
    3132
    3233#include <VBox/err.h>
     
    4344*   Internal Functions                                                         *
    4445*******************************************************************************/
    45 static int pdmR3CritSectDeleteOne(PVM pVM, PPDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal);
    46 
    47 
    48 
    49 /**
    50  * Initializes the critical section subcomponent.
     46static int pdmR3CritSectDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal);
     47
     48
     49
     50/**
     51 * Register statistics related to the critical sections.
    5152 *
    5253 * @returns VBox status code.
    5354 * @param   pVM         The VM handle.
    54  * @remark  Not to be confused with PDMR3CritSectInit and pdmR3CritSectInitDevice which are
    55  *          for initializing a critical section.
    56  */
    57 int pdmR3CritSectInit(PVM pVM)
     55 */
     56int pdmR3CritSectInitStats(PVM pVM)
    5857{
    5958    STAM_REG(pVM, &pVM->pdm.s.StatQueuedCritSectLeaves, STAMTYPE_COUNTER, "/PDM/QueuedCritSectLeaves", STAMUNIT_OCCURENCES,
     
    7069void pdmR3CritSectRelocate(PVM pVM)
    7170{
    72     RTCritSectEnter(&pVM->pdm.s.MiscCritSect);
    73     for (PPDMCRITSECTINT pCur = pVM->pdm.s.pCritSects;
     71    PUVM pUVM = pVM->pUVM;
     72    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     73
     74    for (PPDMCRITSECTINT pCur = pUVM->pdm.s.pCritSects;
    7475         pCur;
    7576         pCur = pCur->pNext)
    7677        pCur->pVMRC = pVM->pVMRC;
    77     RTCritSectLeave(&pVM->pdm.s.MiscCritSect);
     78
     79    RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    7880}
    7981
     
    8284 * Deletes all remaining critical sections.
    8385 *
    84  * This is called at the end of the termination process.
     86 * This is called at the very end of the termination process.  It is also called
     87 * at the end of vmR3CreateU failure cleanup, which may cause it to be called
     88 * twice depending on hwere vmR3CreateU actually failed.  We have to do the
     89 * latter call because other components expect the critical sections to be
     90 * automatically deleted.
    8591 *
    8692 * @returns VBox status.
    8793 *          First error code, rest is lost.
    88  * @param   pVM         The VM handle.
     94 * @param   pVMU        The user mode VM handle.
    8995 * @remark  Don't confuse this with PDMR3CritSectDelete.
    9096 */
    9197VMMDECL(int) PDMR3CritSectTerm(PVM pVM)
    9298{
    93     int rc = VINF_SUCCESS;
    94     RTCritSectEnter(&pVM->pdm.s.MiscCritSect);
    95     while (pVM->pdm.s.pCritSects)
    96     {
    97         int rc2 = pdmR3CritSectDeleteOne(pVM, pVM->pdm.s.pCritSects, NULL, true /* final */);
     99    PUVM    pUVM = pVM->pUVM;
     100    int     rc   = VINF_SUCCESS;
     101    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     102
     103    while (pUVM->pdm.s.pCritSects)
     104    {
     105        int rc2 = pdmR3CritSectDeleteOne(pVM, pUVM, pUVM->pdm.s.pCritSects, NULL, true /* final */);
    98106        AssertRC(rc2);
    99107        if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
    100108            rc = rc2;
    101109    }
    102     RTCritSectLeave(&pVM->pdm.s.MiscCritSect);
    103     RTCritSectDelete(&pVM->pdm.s.MiscCritSect);
     110
     111    RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    104112    return rc;
    105113}
    106 
    107114
    108115
     
    162169                pCritSect->pvKey                     = pvKey;
    163170                pCritSect->EventToSignal             = NIL_RTSEMEVENT;
    164                 pCritSect->pNext                     = pVM->pdm.s.pCritSects;
     171                pCritSect->pNext                     = pVM->pUVM->pdm.s.pCritSects;
    165172                pCritSect->pszName                   = pszName;
    166                 pVM->pdm.s.pCritSects = pCritSect;
     173                pVM->pUVM->pdm.s.pCritSects = pCritSect;
    167174                STAMR3RegisterF(pVM, &pCritSect->StatContentionRZLock,  STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,          NULL, "/PDM/CritSects/%s/ContentionRZLock", pCritSect->pszName);
    168175                STAMR3RegisterF(pVM, &pCritSect->StatContentionRZUnlock,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,          NULL, "/PDM/CritSects/%s/ContentionRZUnlock", pCritSect->pszName);
     
    215222
    216223/**
    217  * Initializes a PDM critical section.
     224 * Initializes a PDM critical section for a device.
    218225 *
    219226 * The PDM critical sections are derived from the IPRT critical sections, but
     
    224231 * @param   pDevIns         Device instance.
    225232 * @param   pCritSect       Pointer to the critical section.
    226  * @param   pszNameFmt      Format string for namging the critical section.  For
     233 * @param   pszNameFmt      Format string for naming the critical section.  For
    227234 *                          statistics and lock validation.
    228235 * @param   va              Arguments for the format string.
     
    232239{
    233240    return pdmR3CritSectInitOne(pVM, &pCritSect->s, pDevIns, RT_SRC_POS_ARGS, pszNameFmt, va);
     241}
     242
     243
     244/**
     245 * Initializes a PDM critical section for a driver.
     246 *
     247 * @returns VBox status code.
     248 * @param   pVM             The VM handle.
     249 * @param   pDrvIns         Driver instance.
     250 * @param   pCritSect       Pointer to the critical section.
     251 * @param   pszNameFmt      Format string for naming the critical section.  For
     252 *                          statistics and lock validation.
     253 * @param   ...             Arguments for the format string.
     254 */
     255int pdmR3CritSectInitDriver(PVM pVM, PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
     256                            const char *pszNameFmt, ...)
     257{
     258    va_list va;
     259    va_start(va, pszNameFmt);
     260    int rc = pdmR3CritSectInitOne(pVM, &pCritSect->s, pDrvIns, RT_SRC_POS_ARGS, pszNameFmt, va);
     261    va_end(va);
     262    return rc;
    234263}
    235264
     
    245274 * @param   fFinal      Set if this is the final call and statistics shouldn't be deregistered.
    246275 *
    247  * @remarks Caller must've entered the MiscCritSect.
    248  */
    249 static int pdmR3CritSectDeleteOne(PVM pVM, PPDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal)
     276 * @remarks Caller must've entered the ListCritSect.
     277 */
     278static int pdmR3CritSectDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal)
    250279{
    251280    /*
     
    256285    Assert(pCritSect->Core.cLockers == -1);
    257286    Assert(pCritSect->Core.NativeThreadOwner == NIL_RTNATIVETHREAD);
    258     Assert(RTCritSectIsOwner(&pVM->pdm.s.MiscCritSect));
     287    Assert(RTCritSectIsOwner(&pUVM->pdm.s.ListCritSect));
    259288
    260289    /*
     
    264293        pPrev->pNext = pCritSect->pNext;
    265294    else
    266         pVM->pdm.s.pCritSects = pCritSect->pNext;
     295        pUVM->pdm.s.pCritSects = pCritSect->pNext;
    267296
    268297    /*
     
    314343     * Iterate the list and match key.
    315344     */
     345    PUVM            pUVM  = pVM->pUVM;
    316346    int             rc    = VINF_SUCCESS;
    317347    PPDMCRITSECTINT pPrev = NULL;
    318     RTCritSectEnter(&pVM->pdm.s.MiscCritSect);
    319     PPDMCRITSECTINT pCur  = pVM->pdm.s.pCritSects;
     348    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     349    PPDMCRITSECTINT pCur  = pUVM->pdm.s.pCritSects;
    320350    while (pCur)
    321351    {
    322352        if (pCur->pvKey == pvKey)
    323353        {
    324             int rc2 = pdmR3CritSectDeleteOne(pVM, pCur, pPrev, false /* not final */);
     354            int rc2 = pdmR3CritSectDeleteOne(pVM, pUVM, pCur, pPrev, false /* not final */);
    325355            AssertRC(rc2);
    326356            if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
     
    332362        pCur = pCur->pNext;
    333363    }
    334     RTCritSectLeave(&pVM->pdm.s.MiscCritSect);
     364    RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    335365    return rc;
    336366}
     
    351381
    352382/**
     383 * Deletes all undeleted critical sections initalized by a given driver.
     384 *
     385 * @returns VBox status code.
     386 * @param   pVM         The VM handle.
     387 * @param   pDrvIns     The driver handle.
     388 */
     389int pdmR3CritSectDeleteDriver(PVM pVM, PPDMDRVINS pDrvIns)
     390{
     391    return pdmR3CritSectDeleteByKey(pVM, pDrvIns);
     392}
     393
     394
     395/**
    353396 * Deletes the critical section.
    354397 *
     
    365408     */
    366409    PVM             pVM   = pCritSect->s.pVMR3;
     410    PUVM            pUVM  = pVM->pUVM;
    367411    AssertReleaseReturn(pVM, VERR_INTERNAL_ERROR);
    368412    PPDMCRITSECTINT pPrev = NULL;
    369     RTCritSectEnter(&pVM->pdm.s.MiscCritSect);
    370     PPDMCRITSECTINT pCur  = pVM->pdm.s.pCritSects;
     413    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     414    PPDMCRITSECTINT pCur  = pUVM->pdm.s.pCritSects;
    371415    while (pCur)
    372416    {
    373417        if (pCur == &pCritSect->s)
    374418        {
    375             int rc = pdmR3CritSectDeleteOne(pVM, pCur, pPrev, false /* not final */);
    376             RTCritSectLeave(&pVM->pdm.s.MiscCritSect);
     419            int rc = pdmR3CritSectDeleteOne(pVM, pUVM, pCur, pPrev, false /* not final */);
     420            RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    377421            return rc;
    378422        }
     
    382426        pCur = pCur->pNext;
    383427    }
    384     RTCritSectLeave(&pVM->pdm.s.MiscCritSect);
     428    RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    385429    AssertReleaseMsgFailed(("pCritSect=%p wasn't found!\n", pCritSect));
    386430    return VERR_INTERNAL_ERROR;
     
    519563    RTNATIVETHREAD const    hNativeThread = RTThreadNativeSelf();
    520564    uint32_t                cCritSects = 0;
    521     for (PPDMCRITSECTINT pCur = pVM->pdm.s.pCritSects;
     565    for (PPDMCRITSECTINT pCur = pVM->pUVM->pdm.s.pCritSects;
    522566         pCur;
    523567         pCur = pCur->pNext)
     
    583627{
    584628    RTNATIVETHREAD const hNativeSelf = RTThreadNativeSelf();
    585 
    586     RTCritSectEnter(&pVM->pdm.s.MiscCritSect);
    587     for (PPDMCRITSECTINT pCur = pVM->pdm.s.pCritSects;
     629    PUVM                 pUVM        = pVM->pUVM;
     630
     631    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     632    for (PPDMCRITSECTINT pCur = pUVM->pdm.s.pCritSects;
    588633         pCur;
    589634         pCur = pCur->pNext)
     
    593638            PDMCritSectLeave((PPDMCRITSECT)pCur);
    594639    }
    595     RTCritSectLeave(&pVM->pdm.s.MiscCritSect);
    596 }
    597 
     640    RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
     641}
     642
  • trunk/src/VBox/VMM/PDMDriver.cpp

    r26264 r28258  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    654654        AssertRC(rc);
    655655
     656        /* PDM critsects. */
     657        rc = pdmR3CritSectDeleteDriver(pVM, pCur);
     658        AssertRC(rc);
     659
    656660        /* Finally, the driver it self. */
    657661        bool fHyperHeap = pCur->Internal.s.fHyperHeap;
     
    925929
    926930
    927 /** @interface_method_impl{PDMDRVHLP,pfnPDMQueueCreate} */
    928 static DECLCALLBACK(int) pdmR3DrvHlp_PDMQueueCreate(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
    929                                                     PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue)
     931/** @interface_method_impl{PDMDRVHLP,pfnQueueCreate} */
     932static DECLCALLBACK(int) pdmR3DrvHlp_QueueCreate(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
     933                                                 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue)
    930934{
    931935    PDMDRV_ASSERT_DRVINS(pDrvIns);
     
    11641168
    11651169
    1166 /** @interface_method_impl{PDMDRVHLP,pfnPDMThreadCreate} */
    1167 static DECLCALLBACK(int) pdmR3DrvHlp_PDMThreadCreate(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
    1168                                                      PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
    1169 {
    1170     PDMDRV_ASSERT_DRVINS(pDrvIns);
    1171     VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    1172     LogFlow(("pdmR3DrvHlp_PDMThreadCreate: caller='%s'/%d: ppThread=%p pvUser=%p pfnThread=%p pfnWakeup=%p cbStack=%#zx enmType=%d pszName=%p:{%s}\n",
     1170/** @interface_method_impl{PDMDRVHLP,pfnThreadCreate} */
     1171static DECLCALLBACK(int) pdmR3DrvHlp_ThreadCreate(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
     1172                                                  PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
     1173{
     1174    PDMDRV_ASSERT_DRVINS(pDrvIns);
     1175    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
     1176    LogFlow(("pdmR3DrvHlp_ThreadCreate: caller='%s'/%d: ppThread=%p pvUser=%p pfnThread=%p pfnWakeup=%p cbStack=%#zx enmType=%d pszName=%p:{%s}\n",
    11731177             pDrvIns->pReg->szName, pDrvIns->iInstance, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName, pszName));
    11741178
    11751179    int rc = pdmR3ThreadCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
    11761180
    1177     LogFlow(("pdmR3DrvHlp_PDMThreadCreate: caller='%s'/%d: returns %Rrc *ppThread=%RTthrd\n", pDrvIns->pReg->szName, pDrvIns->iInstance,
     1181    LogFlow(("pdmR3DrvHlp_ThreadCreate: caller='%s'/%d: returns %Rrc *ppThread=%RTthrd\n", pDrvIns->pReg->szName, pDrvIns->iInstance,
    11781182            rc, *ppThread));
    11791183    return rc;
     
    11811185
    11821186
    1183 /** @interface_method_impl{PDMDRVHLP,pfnPDMAsyncCompletionTemplateCreate} */
    1184 static DECLCALLBACK(int) pdmR3DrvHlp_PDMAsyncCompletionTemplateCreate(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
    1185                                                                       PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser,
    1186                                                                       const char *pszDesc)
    1187 {
    1188     PDMDRV_ASSERT_DRVINS(pDrvIns);
    1189     VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    1190     LogFlow(("pdmR3DrvHlp_PDMAsyncCompletionTemplateCreate: caller='%s'/%d: ppTemplate=%p pfnCompleted=%p pszDesc=%p:{%s}\n",
     1187/** @interface_method_impl{PDMDRVHLP,pfnAsyncCompletionTemplateCreate} */
     1188static DECLCALLBACK(int) pdmR3DrvHlp_AsyncCompletionTemplateCreate(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
     1189                                                                   PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser,
     1190                                                                   const char *pszDesc)
     1191{
     1192    PDMDRV_ASSERT_DRVINS(pDrvIns);
     1193    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
     1194    LogFlow(("pdmR3DrvHlp_AsyncCompletionTemplateCreate: caller='%s'/%d: ppTemplate=%p pfnCompleted=%p pszDesc=%p:{%s}\n",
    11911195             pDrvIns->pReg->szName, pDrvIns->iInstance, ppTemplate, pfnCompleted, pszDesc, pszDesc));
    11921196
    11931197    int rc = PDMR3AsyncCompletionTemplateCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, ppTemplate, pfnCompleted, pvTemplateUser, pszDesc);
    11941198
    1195     LogFlow(("pdmR3DrvHlp_PDMAsyncCompletionTemplateCreate: caller='%s'/%d: returns %Rrc *ppThread=%p\n", pDrvIns->pReg->szName,
     1199    LogFlow(("pdmR3DrvHlp_AsyncCompletionTemplateCreate: caller='%s'/%d: returns %Rrc *ppThread=%p\n", pDrvIns->pReg->szName,
    11961200             pDrvIns->iInstance, rc, *ppTemplate));
    11971201    return rc;
     
    11991203
    12001204
    1201 /** @interface_method_impl{PDMDRVHLP,pfnPDMLdrGetRCInterfaceSymbols} */
    1202 static DECLCALLBACK(int) pdmR3DrvHlp_PDMLdrGetRCInterfaceSymbols(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
    1203                                                                  const char *pszSymPrefix, const char *pszSymList)
    1204 {
    1205     PDMDRV_ASSERT_DRVINS(pDrvIns);
    1206     VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    1207     LogFlow(("pdmR3DrvHlp_PDMLdrGetRCInterfaceSymbols: caller='%s'/%d: pvInterface=%p cbInterface=%zu pszSymPrefix=%p:{%s} pszSymList=%p:{%s}\n",
     1205/** @interface_method_impl{PDMDRVHLP,pfnLdrGetRCInterfaceSymbols} */
     1206static DECLCALLBACK(int) pdmR3DrvHlp_LdrGetRCInterfaceSymbols(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
     1207                                                              const char *pszSymPrefix, const char *pszSymList)
     1208{
     1209    PDMDRV_ASSERT_DRVINS(pDrvIns);
     1210    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
     1211    LogFlow(("pdmR3DrvHlp_LdrGetRCInterfaceSymbols: caller='%s'/%d: pvInterface=%p cbInterface=%zu pszSymPrefix=%p:{%s} pszSymList=%p:{%s}\n",
    12081212             pDrvIns->pReg->szName, pDrvIns->iInstance, pvInterface, cbInterface, pszSymPrefix, pszSymPrefix, pszSymList, pszSymList));
    12091213
     
    12291233    }
    12301234
    1231     LogFlow(("pdmR3DrvHlp_PDMLdrGetRCInterfaceSymbols: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,
     1235    LogFlow(("pdmR3DrvHlp_LdrGetRCInterfaceSymbols: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,
    12321236             pDrvIns->iInstance, rc));
    12331237    return rc;
     
    12351239
    12361240
    1237 /** @interface_method_impl{PDMDRVHLP,pfnPDMLdrGetR0InterfaceSymbols} */
    1238 static DECLCALLBACK(int) pdmR3DrvHlp_PDMLdrGetR0InterfaceSymbols(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
    1239                                                                  const char *pszSymPrefix, const char *pszSymList)
    1240 {
    1241     PDMDRV_ASSERT_DRVINS(pDrvIns);
    1242     VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
    1243     LogFlow(("pdmR3DrvHlp_PDMLdrGetR0InterfaceSymbols: caller='%s'/%d: pvInterface=%p cbInterface=%zu pszSymPrefix=%p:{%s} pszSymList=%p:{%s}\n",
     1241/** @interface_method_impl{PDMDRVHLP,pfnLdrGetR0InterfaceSymbols} */
     1242static DECLCALLBACK(int) pdmR3DrvHlp_LdrGetR0InterfaceSymbols(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
     1243                                                              const char *pszSymPrefix, const char *pszSymList)
     1244{
     1245    PDMDRV_ASSERT_DRVINS(pDrvIns);
     1246    VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
     1247    LogFlow(("pdmR3DrvHlp_LdrGetR0InterfaceSymbols: caller='%s'/%d: pvInterface=%p cbInterface=%zu pszSymPrefix=%p:{%s} pszSymList=%p:{%s}\n",
    12441248             pDrvIns->pReg->szName, pDrvIns->iInstance, pvInterface, cbInterface, pszSymPrefix, pszSymPrefix, pszSymList, pszSymList));
    12451249
     
    12651269    }
    12661270
    1267     LogFlow(("pdmR3DrvHlp_PDMLdrGetR0InterfaceSymbols: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,
     1271    LogFlow(("pdmR3DrvHlp_LdrGetR0InterfaceSymbols: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,
     1272             pDrvIns->iInstance, rc));
     1273    return rc;
     1274}
     1275
     1276
     1277/** @interface_method_impl{PDMDRVHLP,pfnCritSectInit} */
     1278static DECLCALLBACK(int) pdmR3DrvHlp_CritSectInit(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect,
     1279                                                  RT_SRC_POS_DECL, const char *pszName)
     1280{
     1281    PDMDRV_ASSERT_DRVINS(pDrvIns);
     1282    PVM pVM = pDrvIns->Internal.s.pVMR3;
     1283    VM_ASSERT_EMT(pVM);
     1284    LogFlow(("pdmR3DrvHlp_CritSectInit: caller='%s'/%d: pCritSect=%p pszName=%s\n",
     1285             pDrvIns->pReg->szName, pDrvIns->iInstance, pCritSect, pszName));
     1286
     1287    int rc = pdmR3CritSectInitDriver(pVM, pDrvIns, pCritSect, RT_SRC_POS_ARGS, "%s_%u", pszName, pDrvIns->iInstance);
     1288
     1289    LogFlow(("pdmR3DrvHlp_CritSectInit: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,
    12681290             pDrvIns->iInstance, rc));
    12691291    return rc;
     
    12891311    pdmR3DrvHlp_VMState,
    12901312    pdmR3DrvHlp_VMTeleportedAndNotFullyResumedYet,
    1291     pdmR3DrvHlp_PDMQueueCreate,
     1313    pdmR3DrvHlp_QueueCreate,
    12921314    pdmR3DrvHlp_TMGetVirtualFreq,
    12931315    pdmR3DrvHlp_TMGetVirtualTime,
     
    13031325    pdmR3DrvHlp_SetAsyncNotification,
    13041326    pdmR3DrvHlp_AsyncNotificationCompleted,
    1305     pdmR3DrvHlp_PDMThreadCreate,
    1306     pdmR3DrvHlp_PDMAsyncCompletionTemplateCreate,
    1307     pdmR3DrvHlp_PDMLdrGetRCInterfaceSymbols,
    1308     pdmR3DrvHlp_PDMLdrGetR0InterfaceSymbols,
     1327    pdmR3DrvHlp_ThreadCreate,
     1328    pdmR3DrvHlp_AsyncCompletionTemplateCreate,
     1329    pdmR3DrvHlp_LdrGetRCInterfaceSymbols,
     1330    pdmR3DrvHlp_LdrGetR0InterfaceSymbols,
     1331    pdmR3DrvHlp_CritSectInit,
    13091332    PDM_DRVHLPR3_VERSION /* u32TheEnd */
    13101333};
  • trunk/src/VBox/VMM/PDMInternal.h

    r26175 r28258  
    940940    /** List of registered drivers. (FIFO) */
    941941    R3PTRTYPE(PPDMDRV)              pDrvs;
    942     /** List of initialized critical sections. (LIFO) */
    943     R3PTRTYPE(PPDMCRITSECTINT)      pCritSects;
    944942    /** PCI Buses. */
    945943    PDMPCIBUS                       aPciBuses[PDM_PCI_BUSSES_MAX];
     
    965963    RTRCPTR                         uPadding1; /**< Alignment padding. */
    966964
     965/** @name Move to PDMUSERPERVM
     966 * @{
     967 */
    967968    /** Linked list of timer driven PDM queues. */
    968969    R3PTRTYPE(struct PDMQUEUE *)    pQueuesTimer;
     
    983984    /** Tail of the PDM Thread list. (singly linked) */
    984985    R3PTRTYPE(PPDMTHREAD)           pThreadsTail;
     986/** @}  */
    985987
    986988    /** @name   PDM Async Completion
     989     * @todo Move to PDMUSERPERVM
    987990     * @{ */
    988991    /** Pointer to the array of supported endpoint classes. */
     
    10121015     * the PIC, APIC, IOAPIC and PCI devices pluss some PDM functions. */
    10131016    PDMCRITSECT                     CritSect;
    1014     /** The PDM miscellancous lock.
    1015      * This is used to protect things like critsect init/delete that formerly was
    1016      * serialized by there only being one EMT.
    1017      */
    1018     RTCRITSECT                      MiscCritSect;
    10191017
    10201018    /** Number of times a critical section leave requesed needed to be queued for ring-3 execution. */
     
    10331031typedef struct PDMUSERPERVM
    10341032{
     1033    /** @todo move more stuff over here. */
     1034
     1035    /** Lock protecting the lists below it. */
     1036    RTCRITSECT                      ListCritSect;
    10351037    /** Pointer to list of loaded modules. */
    10361038    PPDMMOD                         pModules;
    1037     /** @todo move more stuff over here. */
     1039    /** List of initialized critical sections. (LIFO) */
     1040    R3PTRTYPE(PPDMCRITSECTINT)      pCritSects;
     1041
    10381042} PDMUSERPERVM;
    10391043/** Pointer to the PDM data kept in the UVM. */
     
    10951099*******************************************************************************/
    10961100#ifdef IN_RING3
    1097 int         pdmR3CritSectInit(PVM pVM);
    1098 int         pdmR3CritSectTerm(PVM pVM);
     1101int         pdmR3CritSectInitStats(PVM pVM);
    10991102void        pdmR3CritSectRelocate(PVM pVM);
    11001103int         pdmR3CritSectInitDevice(PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszNameFmt, va_list va);
    11011104int         pdmR3CritSectDeleteDevice(PVM pVM, PPDMDEVINS pDevIns);
     1105int         pdmR3CritSectInitDriver(PVM pVM, PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszNameFmt, ...);
     1106int         pdmR3CritSectDeleteDriver(PVM pVM, PPDMDRVINS pDrvIns);
    11021107
    11031108int         pdmR3DevInit(PVM pVM);
  • trunk/src/VBox/VMM/VM.cpp

    r27789 r28258  
    707707            AssertRC(rc2);
    708708        }
     709
     710        /*
     711         * Do automatic cleanups while the VM structure is still alive and all
     712         * references to it are still working.
     713         */
     714        PDMR3CritSectTerm(pVM);
    709715
    710716        /*
  • trunk/src/VBox/VMM/testcase/tstVMStructRC.cpp

    r26172 r28258  
    274274    GEN_CHECK_OFF(PDM, pUsbInstances);
    275275    GEN_CHECK_OFF(PDM, pDrvs);
    276     GEN_CHECK_OFF(PDM, pCritSects);
    277276    GEN_CHECK_OFF(PDM, aPciBuses);
    278277    GEN_CHECK_OFF(PDM, aPciBuses[0].iBus);
Note: See TracChangeset for help on using the changeset viewer.

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