VirtualBox

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


Ignore:
Timestamp:
Sep 9, 2010 3:55:20 PM (14 years ago)
Author:
vboxsync
Message:

Some cleanup

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r32042 r32362  
    11041104 *
    11051105 * @todo    Clean this up! Most of it is (or should be) no longer necessary as we catch all page table accesses.
     1106 *          Should only required when PGMPOOL_WITH_OPTIMIZED_DIRTY_PT is active (PAE or AMD64 (for now))
    11061107 */
    11071108PGM_BTH_DECL(int, InvalidatePage)(PVMCPU pVCpu, RTGCPTR GCPtrPage)
     
    11191120
    11201121# ifdef PGMPOOL_WITH_OPTIMIZED_DIRTY_PT
     1122    /** @todo this shouldn't be necessary. */
    11211123    if (pPool->cDirtyPages)
    11221124        pgmPoolResetDirtyPages(pVM);
     
    15661568                                              PPGMPOOLPAGE pShwPage, unsigned iPTDst)
    15671569{
     1570    PVM pVM = pVCpu->CTX_SUFF(pVM);
     1571
     1572# if    defined(PGMPOOL_WITH_OPTIMIZED_DIRTY_PT) \
     1573     && PGM_WITH_PAGING(PGM_GST_TYPE, PGM_SHW_TYPE) \
     1574     && (PGM_GST_TYPE == PGM_TYPE_PAE || PGM_GST_TYPE == PGM_TYPE_AMD64)
     1575    if (pShwPage->fDirty)
     1576    {
     1577        PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
     1578        PX86PTPAE pGstPT;
     1579
     1580        pGstPT = (PX86PTPAE)&pPool->aDirtyPages[pShwPage->idxDirty].aPage[0];
     1581        pGstPT->a[iPTDst].u = PteSrc.u;
     1582    }
     1583# endif
     1584
    15681585    if (   PteSrc.n.u1Present
    15691586        && GST_IS_PTE_VALID(pVCpu, PteSrc))
    15701587    {
    1571         PVM pVM = pVCpu->CTX_SUFF(pVM);
    1572 
    1573 # if defined(PGMPOOL_WITH_OPTIMIZED_DIRTY_PT) \
    1574   && PGM_WITH_PAGING(PGM_GST_TYPE, PGM_SHW_TYPE) \
    1575   && (PGM_GST_TYPE == PGM_TYPE_PAE || PGM_GST_TYPE == PGM_TYPE_AMD64)
    1576         if (pShwPage->fDirty)
    1577         {
    1578             PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
    1579             PX86PTPAE pGstPT;
    1580 
    1581             pGstPT = (PX86PTPAE)&pPool->aDirtyPages[pShwPage->idxDirty][0];
    1582             pGstPT->a[iPTDst].u = PteSrc.u;
    1583         }
    1584 # endif
    15851588        /*
    15861589         * Find the ram range.
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r32109 r32362  
    14881488    unsigned     idxPage;
    14891489
    1490     Assert(idxSlot < RT_ELEMENTS(pPool->aIdxDirtyPages));
    1491     if (pPool->aIdxDirtyPages[idxSlot] == NIL_PGMPOOL_IDX)
     1490    Assert(idxSlot < RT_ELEMENTS(pPool->aDirtyPages));
     1491    if (pPool->aDirtyPages[idxSlot].uIdx == NIL_PGMPOOL_IDX)
    14921492        return;
    14931493
    1494     idxPage = pPool->aIdxDirtyPages[idxSlot];
     1494    idxPage = pPool->aDirtyPages[idxSlot].uIdx;
    14951495    AssertRelease(idxPage != NIL_PGMPOOL_IDX);
    14961496    pPage = &pPool->aPages[idxPage];
     
    15301530    bool  fFlush;
    15311531    unsigned cChanges = pgmPoolTrackFlushPTPaePae(pPool, pPage, (PPGMSHWPTPAE)pvShw, (PCX86PTPAE)pvGst,
    1532                                                   (PCX86PTPAE)&pPool->aDirtyPages[idxSlot][0], fAllowRemoval, &fFlush);
     1532                                                  (PCX86PTPAE)&pPool->aDirtyPages[idxSlot].aPage[0], fAllowRemoval, &fFlush);
    15331533    PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst);
    15341534    PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvShw);
     
    15441544
    15451545    STAM_COUNTER_INC(&pPool->StatResetDirtyPages);
    1546     if (pPool->cDirtyPages == RT_ELEMENTS(pPool->aIdxDirtyPages))
     1546    if (pPool->cDirtyPages == RT_ELEMENTS(pPool->aDirtyPages))
    15471547        pPool->idxFreeDirtyPage = idxSlot;
    15481548
    15491549    pPool->cDirtyPages--;
    1550     pPool->aIdxDirtyPages[idxSlot] = NIL_PGMPOOL_IDX;
    1551     Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->aIdxDirtyPages));
     1550    pPool->aDirtyPages[idxSlot].uIdx = NIL_PGMPOOL_IDX;
     1551    Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->aDirtyPages));
    15521552    if (fFlush)
    15531553    {
     
    15781578
    15791579    Assert(PGMIsLocked(pVM));
    1580     AssertCompile(RT_ELEMENTS(pPool->aIdxDirtyPages) == 8 || RT_ELEMENTS(pPool->aIdxDirtyPages) == 16);
     1580    AssertCompile(RT_ELEMENTS(pPool->aDirtyPages) == 8 || RT_ELEMENTS(pPool->aDirtyPages) == 16);
    15811581    Assert(!pPage->fDirty);
    15821582
    15831583    idxFree = pPool->idxFreeDirtyPage;
    1584     Assert(idxFree < RT_ELEMENTS(pPool->aIdxDirtyPages));
     1584    Assert(idxFree < RT_ELEMENTS(pPool->aDirtyPages));
    15851585    Assert(pPage->iMonitoredNext == NIL_PGMPOOL_IDX && pPage->iMonitoredPrev == NIL_PGMPOOL_IDX);
    15861586
    1587     if (pPool->cDirtyPages >= RT_ELEMENTS(pPool->aIdxDirtyPages))
     1587    if (pPool->cDirtyPages >= RT_ELEMENTS(pPool->aDirtyPages))
    15881588    {
    15891589        STAM_COUNTER_INC(&pPool->StatDirtyPageOverFlowFlush);
    15901590        pgmPoolFlushDirtyPage(pVM, pPool, idxFree, true /* allow removal of reused page tables*/);
    15911591    }
    1592     Assert(pPool->cDirtyPages < RT_ELEMENTS(pPool->aIdxDirtyPages));
    1593     AssertMsg(pPool->aIdxDirtyPages[idxFree] == NIL_PGMPOOL_IDX, ("idxFree=%d cDirtyPages=%d\n", idxFree, pPool->cDirtyPages));
     1592    Assert(pPool->cDirtyPages < RT_ELEMENTS(pPool->aDirtyPages));
     1593    AssertMsg(pPool->aDirtyPages[idxFree].uIdx == NIL_PGMPOOL_IDX, ("idxFree=%d cDirtyPages=%d\n", idxFree, pPool->cDirtyPages));
    15941594
    15951595    Log(("Add dirty page %RGp (slot=%d)\n", pPage->GCPhys, idxFree));
     
    16021602    void *pvGst;
    16031603    int   rc  = PGM_GCPHYS_2_PTR(pVM, pPage->GCPhys, &pvGst); AssertReleaseRC(rc);
    1604     memcpy(&pPool->aDirtyPages[idxFree][0], pvGst, PAGE_SIZE);
     1604    memcpy(&pPool->aDirtyPages[idxFree].aPage[0], pvGst, PAGE_SIZE);
    16051605#ifdef VBOX_STRICT
    16061606    void *pvShw = PGMPOOL_PAGE_2_PTR(pVM, pPage);
     
    16111611
    16121612    STAM_COUNTER_INC(&pPool->StatDirtyPage);
    1613     pPage->fDirty                  = true;
    1614     pPage->idxDirty                = idxFree;
    1615     pPool->aIdxDirtyPages[idxFree] = pPage->idx;
     1613    pPage->fDirty                    = true;
     1614    pPage->idxDirty                  = idxFree;
     1615    pPool->aDirtyPages[idxFree].uIdx = pPage->idx;
    16161616    pPool->cDirtyPages++;
    16171617
    1618     pPool->idxFreeDirtyPage        = (pPool->idxFreeDirtyPage + 1) & (RT_ELEMENTS(pPool->aIdxDirtyPages) - 1);
    1619     if (    pPool->cDirtyPages < RT_ELEMENTS(pPool->aIdxDirtyPages)
    1620         &&  pPool->aIdxDirtyPages[pPool->idxFreeDirtyPage] != NIL_PGMPOOL_IDX)
     1618    pPool->idxFreeDirtyPage        = (pPool->idxFreeDirtyPage + 1) & (RT_ELEMENTS(pPool->aDirtyPages) - 1);
     1619    if (    pPool->cDirtyPages < RT_ELEMENTS(pPool->aDirtyPages)
     1620        &&  pPool->aDirtyPages[pPool->idxFreeDirtyPage].uIdx != NIL_PGMPOOL_IDX)
    16211621    {
    16221622        unsigned i;
    1623         for (i = 1; i < RT_ELEMENTS(pPool->aIdxDirtyPages); i++)
    1624         {
    1625             idxFree = (pPool->idxFreeDirtyPage + i) & (RT_ELEMENTS(pPool->aIdxDirtyPages) - 1);
    1626             if (pPool->aIdxDirtyPages[idxFree] == NIL_PGMPOOL_IDX)
     1623        for (i = 1; i < RT_ELEMENTS(pPool->aDirtyPages); i++)
     1624        {
     1625            idxFree = (pPool->idxFreeDirtyPage + i) & (RT_ELEMENTS(pPool->aDirtyPages) - 1);
     1626            if (pPool->aDirtyPages[idxFree].uIdx == NIL_PGMPOOL_IDX)
    16271627            {
    16281628                pPool->idxFreeDirtyPage = idxFree;
     
    16301630            }
    16311631        }
    1632         Assert(i != RT_ELEMENTS(pPool->aIdxDirtyPages));
    1633     }
    1634 
    1635     Assert(pPool->cDirtyPages == RT_ELEMENTS(pPool->aIdxDirtyPages) || pPool->aIdxDirtyPages[pPool->idxFreeDirtyPage] == NIL_PGMPOOL_IDX);
     1632        Assert(i != RT_ELEMENTS(pPool->aDirtyPages));
     1633    }
     1634
     1635    Assert(pPool->cDirtyPages == RT_ELEMENTS(pPool->aDirtyPages) || pPool->aDirtyPages[pPool->idxFreeDirtyPage].uIdx == NIL_PGMPOOL_IDX);
    16361636    return;
    16371637}
     
    16541654    GCPhys = GCPhys & ~(RTGCPHYS)PAGE_OFFSET_MASK;
    16551655
    1656     for (unsigned i = 0; i < RT_ELEMENTS(pPool->aIdxDirtyPages); i++)
    1657     {
    1658         if (pPool->aIdxDirtyPages[i] != NIL_PGMPOOL_IDX)
     1656    for (unsigned i = 0; i < RT_ELEMENTS(pPool->aDirtyPages); i++)
     1657    {
     1658        if (pPool->aDirtyPages[i].uIdx != NIL_PGMPOOL_IDX)
    16591659        {
    16601660            PPGMPOOLPAGE pPage;
    1661             unsigned     idxPage = pPool->aIdxDirtyPages[i];
     1661            unsigned     idxPage = pPool->aDirtyPages[i].uIdx;
    16621662
    16631663            pPage = &pPool->aPages[idxPage];
     
    16781678    PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
    16791679    Assert(PGMIsLocked(pVM));
    1680     Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->aIdxDirtyPages));
     1680    Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->aDirtyPages));
    16811681
    16821682    if (!pPool->cDirtyPages)
     
    16841684
    16851685    Log(("pgmPoolResetDirtyPages\n"));
    1686     for (unsigned i = 0; i < RT_ELEMENTS(pPool->aIdxDirtyPages); i++)
     1686    for (unsigned i = 0; i < RT_ELEMENTS(pPool->aDirtyPages); i++)
    16871687        pgmPoolFlushDirtyPage(pVM, pPool, i, true /* allow removal of reused page tables*/);
    16881688
    16891689    pPool->idxFreeDirtyPage = 0;
    1690     if (    pPool->cDirtyPages != RT_ELEMENTS(pPool->aIdxDirtyPages)
    1691         &&  pPool->aIdxDirtyPages[pPool->idxFreeDirtyPage] != NIL_PGMPOOL_IDX)
     1690    if (    pPool->cDirtyPages != RT_ELEMENTS(pPool->aDirtyPages)
     1691        &&  pPool->aDirtyPages[pPool->idxFreeDirtyPage].uIdx != NIL_PGMPOOL_IDX)
    16921692    {
    16931693        unsigned i;
    1694         for (i = 1; i < RT_ELEMENTS(pPool->aIdxDirtyPages); i++)
    1695         {
    1696             if (pPool->aIdxDirtyPages[i] == NIL_PGMPOOL_IDX)
     1694        for (i = 1; i < RT_ELEMENTS(pPool->aDirtyPages); i++)
     1695        {
     1696            if (pPool->aDirtyPages[i].uIdx == NIL_PGMPOOL_IDX)
    16971697            {
    16981698                pPool->idxFreeDirtyPage = i;
     
    17001700            }
    17011701        }
    1702         AssertMsg(i != RT_ELEMENTS(pPool->aIdxDirtyPages), ("cDirtyPages %d", pPool->cDirtyPages));
    1703     }
    1704 
    1705     Assert(pPool->aIdxDirtyPages[pPool->idxFreeDirtyPage] == NIL_PGMPOOL_IDX || pPool->cDirtyPages == RT_ELEMENTS(pPool->aIdxDirtyPages));
     1702        AssertMsg(i != RT_ELEMENTS(pPool->aDirtyPages), ("cDirtyPages %d", pPool->cDirtyPages));
     1703    }
     1704
     1705    Assert(pPool->aDirtyPages[pPool->idxFreeDirtyPage].uIdx == NIL_PGMPOOL_IDX || pPool->cDirtyPages == RT_ELEMENTS(pPool->aDirtyPages));
    17061706    return;
     1707}
     1708
     1709/**
     1710 * Invalidate the PT entry for the specified page
     1711 *
     1712 * @param   pVM             VM Handle.
     1713 * @param   GCPtrPage       Guest page to invalidate
     1714 */
     1715void pgmPoolResetDirtyPage(PVM pVM, RTGCPTR GCPtrPage)
     1716{
     1717    PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
     1718    Assert(PGMIsLocked(pVM));
     1719    Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->aDirtyPages));
     1720
     1721    if (!pPool->cDirtyPages)
     1722        return;
     1723
     1724    Log(("pgmPoolResetDirtyPage %RGv\n", GCPtrPage));
     1725    for (unsigned i = 0; i < RT_ELEMENTS(pPool->aDirtyPages); i++)
     1726    {
     1727    }
    17071728}
    17081729
     
    17171738    PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
    17181739    Assert(PGMIsLocked(pVM));
    1719     Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->aIdxDirtyPages));
    1720     unsigned idxDirtyPage = RT_ELEMENTS(pPool->aIdxDirtyPages);
     1740    Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->aDirtyPages));
     1741    unsigned idxDirtyPage = RT_ELEMENTS(pPool->aDirtyPages);
    17211742
    17221743    if (!pPool->cDirtyPages)
     
    17251746    GCPhysPT = GCPhysPT & ~(RTGCPHYS)PAGE_OFFSET_MASK;
    17261747
    1727     for (unsigned i = 0; i < RT_ELEMENTS(pPool->aIdxDirtyPages); i++)
    1728     {
    1729         if (pPool->aIdxDirtyPages[i] != NIL_PGMPOOL_IDX)
    1730         {
    1731             unsigned     idxPage = pPool->aIdxDirtyPages[i];
     1748    for (unsigned i = 0; i < RT_ELEMENTS(pPool->aDirtyPages); i++)
     1749    {
     1750        if (pPool->aDirtyPages[i].uIdx != NIL_PGMPOOL_IDX)
     1751        {
     1752            unsigned     idxPage = pPool->aDirtyPages[i].uIdx;
    17321753
    17331754            PPGMPOOLPAGE pPage = &pPool->aPages[idxPage];
     
    17401761    }
    17411762
    1742     if (idxDirtyPage != RT_ELEMENTS(pPool->aIdxDirtyPages))
     1763    if (idxDirtyPage != RT_ELEMENTS(pPool->aDirtyPages))
    17431764    {
    17441765        pgmPoolFlushDirtyPage(pVM, pPool, idxDirtyPage, true /* allow removal of reused page tables*/);
    1745         if (    pPool->cDirtyPages != RT_ELEMENTS(pPool->aIdxDirtyPages)
    1746             &&  pPool->aIdxDirtyPages[pPool->idxFreeDirtyPage] != NIL_PGMPOOL_IDX)
     1766        if (    pPool->cDirtyPages != RT_ELEMENTS(pPool->aDirtyPages)
     1767            &&  pPool->aDirtyPages[pPool->idxFreeDirtyPage].uIdx != NIL_PGMPOOL_IDX)
    17471768        {
    17481769            unsigned i;
    1749             for (i = 0; i < RT_ELEMENTS(pPool->aIdxDirtyPages); i++)
    1750             {
    1751                 if (pPool->aIdxDirtyPages[i] == NIL_PGMPOOL_IDX)
     1770            for (i = 0; i < RT_ELEMENTS(pPool->aDirtyPages); i++)
     1771            {
     1772                if (pPool->aDirtyPages[i].uIdx == NIL_PGMPOOL_IDX)
    17521773                {
    17531774                    pPool->idxFreeDirtyPage = i;
     
    17551776                }
    17561777            }
    1757             AssertMsg(i != RT_ELEMENTS(pPool->aIdxDirtyPages), ("cDirtyPages %d", pPool->cDirtyPages));
     1778            AssertMsg(i != RT_ELEMENTS(pPool->aDirtyPages), ("cDirtyPages %d", pPool->cDirtyPages));
    17581779        }
    17591780    }
     
    52045225    pPool->idxFreeDirtyPage = 0;
    52055226    pPool->cDirtyPages      = 0;
    5206     for (unsigned i = 0; i < RT_ELEMENTS(pPool->aIdxDirtyPages); i++)
    5207         pPool->aIdxDirtyPages[i] = NIL_PGMPOOL_IDX;
     5227    for (unsigned i = 0; i < RT_ELEMENTS(pPool->aDirtyPages); i++)
     5228        pPool->aDirtyPages[i].uIdx = NIL_PGMPOOL_IDX;
    52085229#endif
    52095230
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