VirtualBox

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


Ignore:
Timestamp:
Mar 26, 2009 10:18:55 PM (16 years ago)
Author:
vboxsync
Message:

pgmPoolCacheFreeOne: Rewrote recursion to a finit loop; overflowing the stack is bad both in RC (#DF) and R0 (panic/corruption).

File:
1 edited

Legend:

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

    r18290 r18355  
    12461246     * Select one page from the tail of the age list.
    12471247     */
    1248     uint16_t iToFree = pPool->iAgeTail;
    1249     if (iToFree == iUser)
    1250         iToFree = pPool->aPages[iToFree].iAgePrev;
     1248    PPGMPOOLPAGE    pPage;
     1249    for (unsigned iLoop = 0; ; iLoop++)
     1250    {
     1251        uint16_t iToFree = pPool->iAgeTail;
     1252        if (iToFree == iUser)
     1253            iToFree = pPool->aPages[iToFree].iAgePrev;
    12511254/* This is the alternative to the SyncCR3 pgmPoolCacheUsed calls.
    1252     if (pPool->aPages[iToFree].iUserHead != NIL_PGMPOOL_USER_INDEX)
    1253     {
    1254         uint16_t i = pPool->aPages[iToFree].iAgePrev;
    1255         for (unsigned j = 0; j < 10 && i != NIL_PGMPOOL_USER_INDEX; j++, i = pPool->aPages[i].iAgePrev)
    1256         {
    1257             if (pPool->aPages[iToFree].iUserHead == NIL_PGMPOOL_USER_INDEX)
    1258                 continue;
    1259             iToFree = i;
     1255        if (pPool->aPages[iToFree].iUserHead != NIL_PGMPOOL_USER_INDEX)
     1256        {
     1257            uint16_t i = pPool->aPages[iToFree].iAgePrev;
     1258            for (unsigned j = 0; j < 10 && i != NIL_PGMPOOL_USER_INDEX; j++, i = pPool->aPages[i].iAgePrev)
     1259            {
     1260                if (pPool->aPages[iToFree].iUserHead == NIL_PGMPOOL_USER_INDEX)
     1261                    continue;
     1262                iToFree = i;
     1263                break;
     1264            }
     1265        }
     1266*/
     1267        Assert(iToFree != iUser);
     1268        AssertRelease(iToFree != NIL_PGMPOOL_IDX);
     1269        pPage = &pPool->aPages[iToFree];
     1270
     1271        /*
     1272         * Reject any attempts at flushing the currently active shadow CR3 mapping.
     1273         * Call pgmPoolCacheUsed to move the page to the head of the age list.
     1274         */
     1275        if (!pgmPoolIsPageLocked(&pPool->CTX_SUFF(pVM)->pgm.s, pPage))
    12601276            break;
    1261         }
    1262     }
    1263 */
    1264 
    1265     Assert(iToFree != iUser);
    1266     AssertRelease(iToFree != NIL_PGMPOOL_IDX);
    1267 
    1268     PPGMPOOLPAGE pPage = &pPool->aPages[iToFree];
    1269 
    1270     /*
    1271      * Reject any attempts at flushing the currently active shadow CR3 mapping
    1272      */
    1273     if (pgmPoolIsPageLocked(&pPool->CTX_SUFF(pVM)->pgm.s, pPage))
    1274     {
    1275         /* Refresh the cr3 mapping by putting it at the head of the age list. */
    1276         LogFlow(("pgmPoolCacheFreeOne refuse CR3 mapping\n"));
     1277        LogFlow(("pgmPoolCacheFreeOne: refuse CR3 mapping\n"));
    12771278        pgmPoolCacheUsed(pPool, pPage);
    1278         return pgmPoolCacheFreeOne(pPool, iUser);
    1279     }
    1280 
     1279        AssertLogRelReturn(iLoop < 8192, VERR_INTERNAL_ERROR);
     1280    }
     1281
     1282    /*
     1283     * Found a usable page, flush it and return.
     1284     */
    12811285    int rc = pgmPoolFlushPage(pPool, pPage);
    12821286    if (rc == VINF_SUCCESS)
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