VirtualBox

Changeset 37452 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Jun 14, 2011 6:13:48 PM (14 years ago)
Author:
vboxsync
Message:

IOM,PDMCritSect: Extended PDMCritSectEnter to handle rcBusy=VINF_SUCCESS as a request to call ring-3 to acquire a busy lock. Implemented device level locking in the MMIO code.

Location:
trunk/src/VBox/VMM/VMMAll
Files:
6 edited

Legend:

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

    r37443 r37452  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    11591159    return rcStrict;
    11601160}
     1161
     1162
     1163/**
     1164 * Fress an MMIO range after the reference counter has become zero.
     1165 *
     1166 * @param   pVM                 The VM handle.
     1167 * @param   pRange              The range to free.
     1168 */
     1169void iomMmioFreeRange(PVM pVM, PIOMMMIORANGE pRange)
     1170{
     1171    MMHyperFree(pVM, pRange);
     1172}
     1173
  • trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp

    r37424 r37452  
    7979 * @warning RT_SUCCESS(rc=VINF_IOM_HC_MMIO_WRITE) is TRUE!
    8080 */
    81 DECLINLINE(int) iomMMIODoWrite(PVM pVM, PIOMMMIORANGE pRange, RTGCPHYS GCPhysFault, const void *pvData, unsigned cb)
     81static int iomMMIODoWrite(PVM pVM, PIOMMMIORANGE pRange, RTGCPHYS GCPhysFault, const void *pvData, unsigned cb)
    8282{
    8383#ifdef VBOX_WITH_STATISTICS
    84     PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhysFault, pRange);
     84    PIOMMMIOSTATS pStats = iomMmioGetStats(pVM, GCPhysFault, pRange);
    8585    Assert(pStats);
    8686#endif
     
    8989    int rc;
    9090    if (RT_LIKELY(pRange->CTX_SUFF(pfnWriteCallback)))
    91         rc = pRange->CTX_SUFF(pfnWriteCallback)(pRange->CTX_SUFF(pDevIns), pRange->CTX_SUFF(pvUser), GCPhysFault, (void *)pvData, cb); /** @todo fix const!! */
     91        rc = pRange->CTX_SUFF(pfnWriteCallback)(pRange->CTX_SUFF(pDevIns), pRange->CTX_SUFF(pvUser),
     92                                                GCPhysFault, (void *)pvData, cb); /** @todo fix const!! */
    9293    else
    9394        rc = VINF_SUCCESS;
     
    104105{
    105106#ifdef VBOX_WITH_STATISTICS
    106     PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhys, pRange);
     107    PIOMMMIOSTATS pStats = iomMmioGetStats(pVM, GCPhys, pRange);
    107108    Assert(pStats);
    108109#endif
     
    303304
    304305
    305 #ifdef IOM_WITH_MOVS_SUPPORT
     306#if defined(IOM_WITH_MOVS_SUPPORT) && 0 /* locking prevents this from working */
    306307/**
    307308 * [REP] MOVSB
     
    322323 * @param   ppStat      Which sub-sample to attribute this call to.
    323324 */
    324 static int iomInterpretMOVS(PVM pVM, bool fWriteAccess, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange, PSTAMPROFILE *ppStat)
     325static int iomInterpretMOVS(PVM pVM, bool fWriteAccess, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange,
     326                            PSTAMPROFILE *ppStat)
    325327{
    326328    /*
     
    456458        PhysDst |= (RTGCUINTPTR)pu8Virt & PAGE_OFFSET_MASK;
    457459        if (    RT_SUCCESS(rc)
    458             &&  (pMMIODst = iomMMIOGetRange(pVM, PhysDst)))
     460            &&  (pMMIODst = iomMmioGetRangeWithRef(pVM, PhysDst)))
    459461        {
    460462            /** @todo implement per-device locks for MMIO access. */
     
    466468            STAM_STATS({ *ppStat = &pVM->iom.s.StatRZInstMovsMMIO; });
    467469            if (!pMMIODst->CTX_SUFF(pfnWriteCallback) && pMMIODst->pfnWriteCallbackR3)
     470            {
     471                iomMmioReleaseRange(pVM, pRange);
    468472                return VINF_IOM_HC_MMIO_READ_WRITE;
     473            }
    469474
    470475            /* copy loop. */
     
    485490                cTransfers--;
    486491            }
     492            iomMmioReleaseRange(pVM, pRange);
    487493        }
    488494        else
     
    10771083    PIOMMMIORANGE pRange = (PIOMMMIORANGE)pvUser;
    10781084    Assert(pRange);
    1079     Assert(pRange == iomMMIOGetRange(pVM, GCPhysFault));
    1080     /** @todo implement per-device locks for MMIO access. It can replace the IOM
    1081      *        lock for most of the code, provided that we retake the lock while
    1082      *        deregistering PIOMMMIORANGE to deal with remapping/access races
    1083      *        (unlikely, but an SMP guest shouldn't cause us to crash). */
    1084     Assert(!pRange->CTX_SUFF(pDevIns) || !pRange->CTX_SUFF(pDevIns)->CTX_SUFF(pCritSect));
     1085    Assert(pRange == iomMmioGetRange(pVM, GCPhysFault));
    10851086
    10861087#ifdef VBOX_WITH_STATISTICS
     
    10881089     * Locate the statistics, if > PAGE_SIZE we'll use the first byte for everything.
    10891090     */
    1090     PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhysFault, pRange);
     1091    PIOMMMIOSTATS pStats = iomMmioGetStats(pVM, GCPhysFault, pRange);
    10911092    if (!pStats)
    10921093    {
     
    11321133
    11331134    /*
     1135     * Retain the range and do locking.
     1136     */
     1137    iomMmioRetainRange(pRange);
     1138    PPDMDEVINS pDevIns = pRange->CTX_SUFF(pDevIns);
     1139    PPDMCRITSECT pLock = pDevIns->CTX_SUFF(pCritSect);
     1140    if (!pLock)
     1141        pLock = &pVM->iom.s.EmtLock;
     1142    else
     1143    {
     1144        iomUnlock(pVM);
     1145        rc = PDMCritSectEnter(pLock, VINF_IOM_HC_MMIO_READ_WRITE);
     1146        if (rc != VINF_SUCCESS)
     1147        {
     1148            iomMmioReleaseRange(pVM, pRange);
     1149            return rc;
     1150        }
     1151    }
     1152
     1153    /*
    11341154     * Disassemble the instruction and interpret it.
    11351155     */
     
    11411161    if (RT_FAILURE(rc))
    11421162    {
    1143         iomUnlock(pVM);
     1163        iomMmioReleaseRange(pVM, pRange);
     1164        PDMCritSectLeave(pLock);
    11441165        return rc;
    11451166    }
     
    11681189        {
    11691190            if (uErrorCode == UINT32_MAX)
    1170                 return VINF_IOM_HC_MMIO_READ_WRITE;
    1171             STAM_PROFILE_ADV_START(&pVM->iom.s.StatRZInstMovs, c);
    1172             PSTAMPROFILE pStat = NULL;
    1173             rc = iomInterpretMOVS(pVM, !!(uErrorCode & X86_TRAP_PF_RW), pCtxCore, GCPhysFault, pDis, pRange, &pStat);
    1174             STAM_PROFILE_ADV_STOP_EX(&pVM->iom.s.StatRZInstMovs, pStat, c);
     1191                rc = VINF_IOM_HC_MMIO_READ_WRITE;
     1192            else
     1193            {
     1194                STAM_PROFILE_ADV_START(&pVM->iom.s.StatRZInstMovs, c);
     1195                PSTAMPROFILE pStat = NULL;
     1196                rc = iomInterpretMOVS(pVM, !!(uErrorCode & X86_TRAP_PF_RW), pCtxCore, GCPhysFault, pDis, pRange, &pStat);
     1197                STAM_PROFILE_ADV_STOP_EX(&pVM->iom.s.StatRZInstMovs, pStat, c);
     1198            }
    11751199            break;
    11761200        }
     
    12711295
    12721296    STAM_PROFILE_STOP(&pVM->iom.s.StatRZMMIOHandler, a);
    1273     iomUnlock(pVM);
     1297    iomMmioReleaseRange(pVM, pRange);
     1298    PDMCritSectLeave(pLock);
    12741299    return rc;
    12751300}
     
    13101335        return VINF_IOM_HC_MMIO_READ_WRITE;
    13111336#endif
    1312     VBOXSTRICTRC rcStrict = iomMMIOHandler(pVM, (uint32_t)uErrorCode, pCtxCore, GCPhysFault, iomMMIOGetRange(pVM, GCPhysFault));
     1337    VBOXSTRICTRC rcStrict = iomMMIOHandler(pVM, (uint32_t)uErrorCode, pCtxCore, GCPhysFault, iomMmioGetRange(pVM, GCPhysFault));
    13131338    iomUnlock(pVM);
    13141339    return VBOXSTRICTRC_VAL(rcStrict);
    13151340}
     1341
    13161342
    13171343#ifdef IN_RING3
     
    13291355 * @param   pvUser          Pointer to the MMIO range entry.
    13301356 */
    1331 DECLCALLBACK(int) IOMR3MMIOHandler(PVM pVM, RTGCPHYS GCPhysFault, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser)
     1357DECLCALLBACK(int) IOMR3MMIOHandler(PVM pVM, RTGCPHYS GCPhysFault, void *pvPhys, void *pvBuf, size_t cbBuf,
     1358                                   PGMACCESSTYPE enmAccessType, void *pvUser)
    13321359{
    13331360    PIOMMMIORANGE pRange = (PIOMMMIORANGE)pvUser;
    13341361    STAM_COUNTER_INC(&pVM->iom.s.StatR3MMIOHandler);
    13351362
    1336     /* Take the IOM lock before performing any MMIO. */
     1363    AssertMsg(cbBuf == 1 || cbBuf == 2 || cbBuf == 4 || cbBuf == 8, ("%zu\n", cbBuf));
     1364    AssertPtr(pRange);
     1365
     1366    /*
     1367     * Validate the range.
     1368     */
    13371369    int rc = iomLock(pVM);
    13381370    AssertRC(rc);
    1339 
    1340     AssertMsg(cbBuf == 1 || cbBuf == 2 || cbBuf == 4 || cbBuf == 8, ("%zu\n", cbBuf));
    1341 
    1342     Assert(pRange);
    1343     Assert(pRange == iomMMIOGetRange(pVM, GCPhysFault));
    1344     /** @todo implement per-device locks for MMIO access. It can replace the IOM
    1345      *        lock for most of the code, provided that we retake the lock while
    1346      *        deregistering PIOMMMIORANGE to deal with remapping/access races
    1347      *        (unlikely, but an SMP guest shouldn't cause us to crash). */
    1348     Assert(!pRange->CTX_SUFF(pDevIns) || !pRange->CTX_SUFF(pDevIns)->CTX_SUFF(pCritSect));
    1349 
     1371    Assert(pRange == iomMmioGetRange(pVM, GCPhysFault));
     1372
     1373    /*
     1374     * Perform locking.
     1375     */
     1376    iomMmioRetainRange(pRange);
     1377    PPDMDEVINS pDevIns = pRange->CTX_SUFF(pDevIns);
     1378    PPDMCRITSECT pLock = pDevIns->CTX_SUFF(pCritSect);
     1379    if (!pLock)
     1380        pLock = &pVM->iom.s.EmtLock;
     1381    else
     1382    {
     1383        iomUnlock(pVM);
     1384        rc = PDMCritSectEnter(pLock, VINF_IOM_HC_MMIO_READ_WRITE);
     1385        if (rc != VINF_SUCCESS)
     1386        {
     1387            iomMmioReleaseRange(pVM, pRange);
     1388            return rc;
     1389        }
     1390    }
     1391
     1392    /*
     1393     * Perform the access.
     1394     */
    13501395    if (enmAccessType == PGMACCESSTYPE_READ)
    13511396        rc = iomMMIODoRead(pVM, pRange, GCPhysFault, pvBuf, (unsigned)cbBuf);
     
    13541399
    13551400    AssertRC(rc);
    1356     iomUnlock(pVM);
     1401    iomMmioReleaseRange(pVM, pRange);
     1402    PDMCritSectLeave(pLock);
    13571403    return rc;
    13581404}
    13591405#endif /* IN_RING3 */
     1406
    13601407
    13611408/**
     
    13851432     * Lookup the current context range node and statistics.
    13861433     */
    1387     PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhys);
     1434    PIOMMMIORANGE pRange = iomMmioGetRange(pVM, GCPhys);
    13881435    AssertMsg(pRange, ("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue));
    13891436    if (!pRange)
     
    13921439        return VERR_INTERNAL_ERROR;
    13931440    }
    1394     /** @todo implement per-device locks for MMIO access. */
    1395     Assert(!pRange->CTX_SUFF(pDevIns) || !pRange->CTX_SUFF(pDevIns)->CTX_SUFF(pCritSect));
    13961441#ifdef VBOX_WITH_STATISTICS
    1397     PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhys, pRange);
     1442    PIOMMMIOSTATS pStats = iomMmioGetStats(pVM, GCPhys, pRange);
    13981443    if (!pStats)
    13991444    {
     
    14101455    if (pRange->CTX_SUFF(pfnReadCallback))
    14111456    {
     1457        /*
     1458         * Perform locking.
     1459         */
     1460        iomMmioRetainRange(pRange);
     1461        PPDMDEVINS pDevIns = pRange->CTX_SUFF(pDevIns);
     1462        PPDMCRITSECT pLock = pDevIns->CTX_SUFF(pCritSect);
     1463        if (!pLock)
     1464            pLock = &pVM->iom.s.EmtLock;
     1465        else
     1466        {
     1467            iomUnlock(pVM);
     1468            rc = PDMCritSectEnter(pLock, VINF_IOM_HC_MMIO_WRITE);
     1469            if (rc != VINF_SUCCESS)
     1470            {
     1471                iomMmioReleaseRange(pVM, pRange);
     1472                return rc;
     1473            }
     1474        }
     1475
    14121476        /*
    14131477         * Perform the read and deal with the result.
     
    14201484            case VINF_SUCCESS:
    14211485                Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=VINF_SUCCESS\n", GCPhys, *pu32Value, cbValue));
    1422                 iomUnlock(pVM);
     1486                iomMmioReleaseRange(pVM, pRange);
     1487                PDMCritSectLeave(pLock);
    14231488                return rc;
    14241489#ifndef IN_RING3
     
    14291494            default:
    14301495                Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, rc));
    1431                 iomUnlock(pVM);
     1496                iomMmioReleaseRange(pVM, pRange);
     1497                PDMCritSectLeave(pLock);
    14321498                return rc;
    14331499
     
    14421508                }
    14431509                Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, rc));
    1444                 iomUnlock(pVM);
     1510                iomMmioReleaseRange(pVM, pRange);
     1511                PDMCritSectLeave(pLock);
    14451512                return VINF_SUCCESS;
    14461513
     
    14551522                }
    14561523                Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, rc));
    1457                 iomUnlock(pVM);
     1524                iomMmioReleaseRange(pVM, pRange);
     1525                PDMCritSectLeave(pLock);
    14581526                return VINF_SUCCESS;
    14591527        }
     1528        /* not reached */
    14601529    }
    14611530#ifndef IN_RING3
     
    14691538
    14701539    /*
    1471      * Lookup the ring-3 range.
     1540     * Unassigned memory - this is actually not supposed t happen...
    14721541     */
    14731542    STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfRead), a); /** @todo STAM_PROFILE_ADD_ZERO_PERIOD */
    14741543    STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfRead), a);
    1475     /* Unassigned memory; this is actually not supposed to happen. */
    14761544    switch (cbValue)
    14771545    {
    1478         case 1: *(uint8_t *)pu32Value = UINT8_C(0xff); break;
     1546        case 1: *(uint8_t  *)pu32Value = UINT8_C(0xff); break;
    14791547        case 2: *(uint16_t *)pu32Value = UINT16_C(0xffff); break;
    14801548        case 4: *(uint32_t *)pu32Value = UINT32_C(0xffffffff); break;
     
    15141582     * Lookup the current context range node.
    15151583     */
    1516     PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhys);
     1584    PIOMMMIORANGE pRange = iomMmioGetRange(pVM, GCPhys);
    15171585    AssertMsg(pRange, ("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue));
    15181586    if (!pRange)
     
    15211589        return VERR_INTERNAL_ERROR;
    15221590    }
    1523     /** @todo implement per-device locks for MMIO access. */
    1524     Assert(!pRange->CTX_SUFF(pDevIns) || !pRange->CTX_SUFF(pDevIns)->CTX_SUFF(pCritSect));
    15251591#ifdef VBOX_WITH_STATISTICS
    1526     PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhys, pRange);
     1592    PIOMMMIOSTATS pStats = iomMmioGetStats(pVM, GCPhys, pRange);
    15271593    if (!pStats)
    15281594    {
     
    15371603#endif /* VBOX_WITH_STATISTICS */
    15381604
    1539     /*
    1540      * Perform the write if there's a write handler. R0/GC may have
    1541      * to defer it to ring-3.
    1542      */
    15431605    if (pRange->CTX_SUFF(pfnWriteCallback))
    15441606    {
     1607        /*
     1608         * Perform locking.
     1609         */
     1610        iomMmioRetainRange(pRange);
     1611        PPDMDEVINS pDevIns = pRange->CTX_SUFF(pDevIns);
     1612        PPDMCRITSECT pLock = pDevIns->CTX_SUFF(pCritSect);
     1613        if (!pLock)
     1614            pLock = &pVM->iom.s.EmtLock;
     1615        else
     1616        {
     1617            iomUnlock(pVM);
     1618            rc = PDMCritSectEnter(pLock, VINF_IOM_HC_MMIO_READ);
     1619            if (rc != VINF_SUCCESS)
     1620            {
     1621                iomMmioReleaseRange(pVM, pRange);
     1622                return rc;
     1623            }
     1624        }
     1625
     1626        /*
     1627         * Perform the write.
     1628         */
    15451629        STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfWrite), a);
    1546         rc = pRange->CTX_SUFF(pfnWriteCallback)(pRange->CTX_SUFF(pDevIns), pRange->CTX_SUFF(pvUser), GCPhys, &u32Value, (unsigned)cbValue);
     1630        rc = pRange->CTX_SUFF(pfnWriteCallback)(pRange->CTX_SUFF(pDevIns), pRange->CTX_SUFF(pvUser),
     1631                                                GCPhys, &u32Value, (unsigned)cbValue);
    15471632        STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfWrite), a);
    15481633#ifndef IN_RING3
     
    15521637#endif
    15531638        Log4(("IOMMMIOWrite: GCPhys=%RGp u32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, u32Value, cbValue, rc));
    1554         iomUnlock(pVM);
     1639        iomMmioReleaseRange(pVM, pRange);
     1640        PDMCritSectLeave(pLock);
    15551641        return rc;
    15561642    }
     
    19192005{
    19202006    /* Currently only called from the VGA device during MMIO. */
    1921     Assert(IOMIsLockOwner(pVM));
    19222007    Log(("IOMMMIOMapMMIO2Page %RGp -> %RGp flags=%RX64\n", GCPhys, GCPhysRemapped, fPageFlags));
    1923 
    19242008    AssertReturn(fPageFlags == (X86_PTE_RW | X86_PTE_P), VERR_INVALID_PARAMETER);
    1925 
    19262009    PVMCPU pVCpu = VMMGetCpu(pVM);
    19272010
     
    19322015        return VINF_SUCCESS;    /* ignore */
    19332016
     2017    PDMCritSectEnter(&pVM->iom.s.EmtLock, VINF_SUCCESS);
     2018
    19342019    /*
    19352020     * Lookup the context range node the page belongs to.
    19362021     */
    1937     PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhys);
     2022    PIOMMMIORANGE pRange = iomMmioGetRange(pVM, GCPhys);
    19382023    AssertMsgReturn(pRange,
    19392024                    ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND);
     
    19492034
    19502035    int rc = PGMHandlerPhysicalPageAlias(pVM, pRange->GCPhys, GCPhys, GCPhysRemapped);
     2036
     2037    PDMCritSectLeave(&pVM->iom.s.EmtLock);
    19512038    AssertRCReturn(rc, rc);
    19522039
  • trunk/src/VBox/VMM/VMMAll/PDMAll.cpp

    r36822 r37452  
    301301}
    302302
    303 /**
    304  * Write MSR in APIC range.
     303
     304/**
     305 * Write a MSR in APIC range.
    305306 *
    306307 * @returns VBox status code.
     
    323324}
    324325
    325 /**
    326  * Read MSR in APIC range.
     326
     327/**
     328 * Read a MSR in APIC range.
    327329 *
    328330 * @returns VBox status code.
  • trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp

    r37443 r37452  
    238238    return pdmR3R0CritSectEnterContended(pCritSect, hNativeSelf, pSrcPos);
    239239
    240 #elif defined(IN_RING0)
     240#else
     241# ifdef IN_RING0
    241242    /** @todo If preemption is disabled it means we're in VT-x/AMD-V context
    242243     *        and would be better off switching out of that while waiting for
     
    245246     *        the lock wait and when the call return it will call ring-0
    246247     *        again and resume via in setjmp style.  Not very efficient. */
    247 # if 0
     248#  if 0
    248249    if (ASMIntAreEnabled()) /** @todo this can be handled as well by changing
    249250                             * callers not prepared for longjmp/blocking to
     
    274275        return rc;
    275276    }
    276 # else
     277#  else
    277278    /*
    278279     * We preemption hasn't been disabled, we can block here in ring-0.
     
    281282        && ASMIntAreEnabled())
    282283        return pdmR3R0CritSectEnterContended(pCritSect, hNativeSelf, pSrcPos);
    283 # endif
     284#  endif
     285#endif /* IN_RING0 */
    284286
    285287    STAM_REL_COUNTER_INC(&pCritSect->s.StatContentionRZLock);
     288
     289    /*
     290     * Call ring-3 to acquire the critical section?
     291     */
     292    if (rcBusy == VINF_SUCCESS)
     293    {
     294        PVM     pVM   = pCritSect->s.CTX_SUFF(pVM); AssertPtr(pVM);
     295        PVMCPU  pVCpu = VMMGetCpu(pVM);             AssertPtr(pVCpu);
     296        return VMMRZCallRing3(pVM, pVCpu, VMMCALLRING3_PDM_CRIT_SECT_ENTER, MMHyperCCToR3(pVM, pCritSect));
     297    }
     298
     299    /*
     300     * Return busy.
     301     */
    286302    LogFlow(("PDMCritSectEnter: locked => R3 (%Rrc)\n", rcBusy));
    287303    return rcBusy;
    288 
    289 #else  /* IN_RC */
    290     /*
    291      * Return busy.
    292      */
    293     STAM_REL_COUNTER_INC(&pCritSect->s.StatContentionRZLock);
    294     LogFlow(("PDMCritSectEnter: locked => R3 (%Rrc)\n", rcBusy));
    295     return rcBusy;
    296 #endif /* IN_RC */
     304#endif /* !IN_RING3 */
    297305}
    298306
     
    307315 * @param   pCritSect           The PDM critical section to enter.
    308316 * @param   rcBusy              The status code to return when we're in GC or R0
    309  *                              and the section is busy.
     317 *                              and the section is busy.  Pass VINF_SUCCESS to
     318 *                              acquired the critical section thru a ring-3
     319 *                              call if necessary.
    310320 */
    311321VMMDECL(int) PDMCritSectEnter(PPDMCRITSECT pCritSect, int rcBusy)
    312322{
     323    int rc;
     324#ifndef IN_RING3
     325    if (rcBusy == VINF_SUCCESS)
     326    {
     327# ifndef PDMCRITSECT_STRICT
     328        rc = pdmCritSectEnter(pCritSect, VERR_SEM_BUSY, NULL);
     329# else
     330        RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
     331        rc = pdmCritSectEnter(pCritSect, VERR_SEM_BUSY, &SrcPos);
     332# endif
     333        if (rc == VERR_SEM_BUSY)
     334        {
     335
     336        }
     337    }
     338    else
     339#endif /* !IN_RING3 */
     340    {
    313341#ifndef PDMCRITSECT_STRICT
    314     return pdmCritSectEnter(pCritSect, rcBusy, NULL);
    315 #else
    316     RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
    317     return pdmCritSectEnter(pCritSect, rcBusy, &SrcPos);
    318 #endif
     342        rc = pdmCritSectEnter(pCritSect, rcBusy, NULL);
     343#else
     344        RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
     345        rc = pdmCritSectEnter(pCritSect, rcBusy, &SrcPos);
     346#endif
     347    }
     348    return rc;
    319349}
    320350
     
    329359 * @param   pCritSect           The PDM critical section to enter.
    330360 * @param   rcBusy              The status code to return when we're in GC or R0
    331  *                              and the section is busy.
     361 *                              and the section is busy.   Pass VINF_SUCCESS to
     362 *                              acquired the critical section thru a ring-3
     363 *                              call if necessary.
    332364 * @param   uId                 Some kind of locking location ID.  Typically a
    333365 *                              return address up the stack.  Optional (0).
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r37362 r37452  
    22322232VMM_INT_DECL(void) PGMNotifyNxeChanged(PVMCPU pVCpu, bool fNxe)
    22332233{
    2234     VMCPU_ASSERT_EMT_OR_NOT_RUNNING(pVCpu);
     2234/** @todo VMCPU_ASSERT_EMT_OR_NOT_RUNNING(pVCpu); */
    22352235    Log(("PGMNotifyNxeChanged: fNxe=%RTbool\n", fNxe));
    22362236
  • trunk/src/VBox/VMM/VMMAll/TMAll.cpp

    r37414 r37452  
    812812 * @param   pTimer              The timer which clock lock we wish to take.
    813813 * @param   rcBusy              What to return in ring-0 and raw-mode context
    814  *                              if the lock is busy.
     814 *                              if the lock is busy.  Pass VINF_SUCCESS to
     815 *                              acquired the critical section thru a ring-3
     816                                call if necessary.
    815817 *
    816818 * @remarks Currently only supported on timers using the virtual sync clock.
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