VirtualBox

Changeset 31444 in vbox


Ignore:
Timestamp:
Aug 6, 2010 7:47:04 PM (14 years ago)
Author:
vboxsync
Message:

PGM: Don't let the ATA device exhaust the dynamic mapping cache - implemented actual unlocking of pages in PGMPhysReleasePageMappingLock. (RC and darwin.x86+R0)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/types.h

    r30646 r31444  
    825825/**
    826826 * Page mapping lock.
    827  *
    828827 */
    829828typedef struct PGMPAGEMAPLOCK
    830829{
    831     /** @todo see PGMPhysIsPageMappingLockValid for possibly incorrect assumptions */
    832830#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
    833     /** Just a dummy for the time being. */
    834     uint32_t    u32Dummy;
    835     uint32_t    u32Dummy1;
    836 # if HC_ARCH_BITS == 64
    837     uint32_t    u32Align[2];
    838 # endif
     831    /** The locked page. */
     832    void       *pvPage;
     833    /** Pointer to the CPU that made the mapping.
     834     * In ring-0 and raw-mode context we don't intend to ever allow long term
     835     * locking and this is a way of making sure we're still on the same CPU. */
     836    PVMCPU      pVCpu;
    839837#else
    840838    /** Pointer to the PGMPAGE and lock type.
  • trunk/src/VBox/VMM/PGMInline.h

    r31402 r31444  
    500500    }
    501501    AssertFatalMsgFailed(("pgmPoolMapPageV2Inlined invalid page index %x\n", pPage->idx));
    502 }
    503 
    504 /**
    505  * Temporarily maps one host page specified by HC physical address, returning
    506  * pointer within the page.
    507  *
    508  * Be WARNED that the dynamic page mapping area is small, 8 pages, thus the space is
    509  * reused after 8 mappings (or perhaps a few more if you score with the cache).
    510  *
    511  * @returns The address corresponding to HCPhys.
    512  * @param   pVM         The VM handle.
    513  * @param   HCPhys      HC Physical address of the page.
    514  */
    515 DECLINLINE(void *) pgmRZDynMapHCPageOff(PVM pVM, RTHCPHYS HCPhys RTLOG_COMMA_SRC_POS_DECL)
    516 {
    517     void *pv;
    518     pgmRZDynMapHCPageInlined(VMMGetCpu(pVM), HCPhys & ~(RTHCPHYS)PAGE_OFFSET_MASK, &pv RTLOG_COMMA_SRC_POS_ARGS);
    519     pv = (void *)((uintptr_t)pv | ((uintptr_t)HCPhys & PAGE_OFFSET_MASK));
    520     return pv;
    521502}
    522503
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r31402 r31444  
    11281128     */
    11291129#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
    1130     *ppv = pgmRZDynMapHCPageOff(pVM, PGM_PAGE_GET_HCPHYS(pPage) | (GCPhys & PAGE_OFFSET_MASK) RTLOG_COMMA_SRC_POS);
     1130    void *pv;
     1131    rc = pgmRZDynMapHCPageInlined(VMMGetCpu(pVM),
     1132                                  PGM_PAGE_GET_HCPHYS(pPage),
     1133                                  &pv
     1134                                  RTLOG_COMMA_SRC_POS);
     1135    if (RT_FAILURE(rc))
     1136        return rc;
     1137    *ppv = (void *)((uintptr_t)pv | (uintptr_t)(GCPhys & PAGE_OFFSET_MASK));
    11311138#else
    11321139    PPGMPAGEMAPTLBE pTlbe;
     
    11661173     */
    11671174#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
    1168     *ppv = pgmRZDynMapHCPageOff(pVM, PGM_PAGE_GET_HCPHYS(pPage) | (GCPhys & PAGE_OFFSET_MASK) RTLOG_COMMA_SRC_POS); /** @todo add a read only flag? */
     1175    void *pv;
     1176    int rc = pgmRZDynMapHCPageInlined(VMMGetCpu(pVM),
     1177                                      PGM_PAGE_GET_HCPHYS(pPage),
     1178                                      &pv
     1179                                      RTLOG_COMMA_SRC_POS); /** @todo add a read only flag? */
     1180    if (RT_FAILURE(rc))
     1181        return rc;
     1182    *ppv = (void *)((uintptr_t)pv | (uintptr_t)(GCPhys & PAGE_OFFSET_MASK));
    11691183#else
    11701184    PPGMPAGEMAPTLBE pTlbe;
     
    12241238        if (RT_SUCCESS(rc))
    12251239        {
    1226             *ppv = pgmRZDynMapHCPageOff(pVM, PGM_PAGE_GET_HCPHYS(pPage) | (GCPhys & PAGE_OFFSET_MASK) RTLOG_COMMA_SRC_POS); /** @todo add a read only flag? */
    1227 # if 0
    1228             pLock->pvMap = 0;
    1229             pLock->pvPage = pPage;
    1230 # else
    1231             pLock->u32Dummy = UINT32_MAX;
    1232 # endif
    12331240            AssertMsg(rc == VINF_SUCCESS || rc == VINF_PGM_SYNC_CR3 /* not returned */, ("%Rrc\n", rc));
    1234             rc = VINF_SUCCESS;
     1241
     1242            PVMCPU pVCpu = VMMGetCpu(pVM);
     1243            void  *pv;
     1244            rc = pgmRZDynMapHCPageInlined(pVCpu,
     1245                                          PGM_PAGE_GET_HCPHYS(pPage),
     1246                                          &pv
     1247                                          RTLOG_COMMA_SRC_POS);
     1248            if (RT_SUCCESS(rc))
     1249            {
     1250                AssertRCSuccess(rc);
     1251
     1252                pv = (void *)((uintptr_t)pv | (uintptr_t)(GCPhys & PAGE_OFFSET_MASK));
     1253                *ppv = pv;
     1254                pLock->pvPage = pv;
     1255                pLock->pVCpu  = pVCpu;
     1256            }
    12351257        }
    12361258    }
     
    13351357        else
    13361358        {
    1337             *ppv = pgmRZDynMapHCPageOff(pVM, PGM_PAGE_GET_HCPHYS(pPage) | (GCPhys & PAGE_OFFSET_MASK) RTLOG_COMMA_SRC_POS); /** @todo add a read only flag? */
    1338 # if 0
    1339             pLock->pvMap = 0;
    1340             pLock->pvPage = pPage;
    1341 # else
    1342             pLock->u32Dummy = UINT32_MAX;
    1343 # endif
    1344             AssertMsg(rc == VINF_SUCCESS || rc == VINF_PGM_SYNC_CR3 /* not returned */, ("%Rrc\n", rc));
    1345             rc = VINF_SUCCESS;
     1359            PVMCPU pVCpu = VMMGetCpu(pVM);
     1360            void  *pv;
     1361            rc = pgmRZDynMapHCPageInlined(pVCpu,
     1362                                          PGM_PAGE_GET_HCPHYS(pPage),
     1363                                          &pv
     1364                                          RTLOG_COMMA_SRC_POS); /** @todo add a read only flag? */
     1365            if (RT_SUCCESS(rc))
     1366            {
     1367                AssertRCSuccess(rc);
     1368
     1369                pv = (void *)((uintptr_t)pv | (uintptr_t)(GCPhys & PAGE_OFFSET_MASK));
     1370                *ppv = pv;
     1371                pLock->pvPage = pv;
     1372                pLock->pVCpu  = pVCpu;
     1373            }
    13461374        }
    13471375    }
     
    14791507{
    14801508#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
    1481     /* currently nothing to do here. */
    1482     Assert(pLock->u32Dummy == UINT32_MAX);
    1483     pLock->u32Dummy = 0;
     1509    Assert(pLock->pvPage != NULL);
     1510    Assert(pLock->pVCpu == VMMGetCpu(pVM));
     1511    PGM_DYNMAP_UNUSED_HINT(pLock->pVCpu, pLock->pvPage);
     1512    pLock->pVCpu  = NULL;
     1513    pLock->pvPage = NULL;
    14841514
    14851515#else
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