Changeset 32362 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Sep 9, 2010 3:55:20 PM (14 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r32042 r32362 1104 1104 * 1105 1105 * @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)) 1106 1107 */ 1107 1108 PGM_BTH_DECL(int, InvalidatePage)(PVMCPU pVCpu, RTGCPTR GCPtrPage) … … 1119 1120 1120 1121 # ifdef PGMPOOL_WITH_OPTIMIZED_DIRTY_PT 1122 /** @todo this shouldn't be necessary. */ 1121 1123 if (pPool->cDirtyPages) 1122 1124 pgmPoolResetDirtyPages(pVM); … … 1566 1568 PPGMPOOLPAGE pShwPage, unsigned iPTDst) 1567 1569 { 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 1568 1585 if ( PteSrc.n.u1Present 1569 1586 && GST_IS_PTE_VALID(pVCpu, PteSrc)) 1570 1587 { 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 # endif1585 1588 /* 1586 1589 * Find the ram range. -
trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp
r32109 r32362 1488 1488 unsigned idxPage; 1489 1489 1490 Assert(idxSlot < RT_ELEMENTS(pPool->a IdxDirtyPages));1491 if (pPool->a IdxDirtyPages[idxSlot]== NIL_PGMPOOL_IDX)1490 Assert(idxSlot < RT_ELEMENTS(pPool->aDirtyPages)); 1491 if (pPool->aDirtyPages[idxSlot].uIdx == NIL_PGMPOOL_IDX) 1492 1492 return; 1493 1493 1494 idxPage = pPool->a IdxDirtyPages[idxSlot];1494 idxPage = pPool->aDirtyPages[idxSlot].uIdx; 1495 1495 AssertRelease(idxPage != NIL_PGMPOOL_IDX); 1496 1496 pPage = &pPool->aPages[idxPage]; … … 1530 1530 bool fFlush; 1531 1531 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); 1533 1533 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvGst); 1534 1534 PGM_DYNMAP_UNUSED_HINT_VM(pVM, pvShw); … … 1544 1544 1545 1545 STAM_COUNTER_INC(&pPool->StatResetDirtyPages); 1546 if (pPool->cDirtyPages == RT_ELEMENTS(pPool->a IdxDirtyPages))1546 if (pPool->cDirtyPages == RT_ELEMENTS(pPool->aDirtyPages)) 1547 1547 pPool->idxFreeDirtyPage = idxSlot; 1548 1548 1549 1549 pPool->cDirtyPages--; 1550 pPool->a IdxDirtyPages[idxSlot]= NIL_PGMPOOL_IDX;1551 Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->a IdxDirtyPages));1550 pPool->aDirtyPages[idxSlot].uIdx = NIL_PGMPOOL_IDX; 1551 Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->aDirtyPages)); 1552 1552 if (fFlush) 1553 1553 { … … 1578 1578 1579 1579 Assert(PGMIsLocked(pVM)); 1580 AssertCompile(RT_ELEMENTS(pPool->a IdxDirtyPages) == 8 || RT_ELEMENTS(pPool->aIdxDirtyPages) == 16);1580 AssertCompile(RT_ELEMENTS(pPool->aDirtyPages) == 8 || RT_ELEMENTS(pPool->aDirtyPages) == 16); 1581 1581 Assert(!pPage->fDirty); 1582 1582 1583 1583 idxFree = pPool->idxFreeDirtyPage; 1584 Assert(idxFree < RT_ELEMENTS(pPool->a IdxDirtyPages));1584 Assert(idxFree < RT_ELEMENTS(pPool->aDirtyPages)); 1585 1585 Assert(pPage->iMonitoredNext == NIL_PGMPOOL_IDX && pPage->iMonitoredPrev == NIL_PGMPOOL_IDX); 1586 1586 1587 if (pPool->cDirtyPages >= RT_ELEMENTS(pPool->a IdxDirtyPages))1587 if (pPool->cDirtyPages >= RT_ELEMENTS(pPool->aDirtyPages)) 1588 1588 { 1589 1589 STAM_COUNTER_INC(&pPool->StatDirtyPageOverFlowFlush); 1590 1590 pgmPoolFlushDirtyPage(pVM, pPool, idxFree, true /* allow removal of reused page tables*/); 1591 1591 } 1592 Assert(pPool->cDirtyPages < RT_ELEMENTS(pPool->a IdxDirtyPages));1593 AssertMsg(pPool->a IdxDirtyPages[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)); 1594 1594 1595 1595 Log(("Add dirty page %RGp (slot=%d)\n", pPage->GCPhys, idxFree)); … … 1602 1602 void *pvGst; 1603 1603 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); 1605 1605 #ifdef VBOX_STRICT 1606 1606 void *pvShw = PGMPOOL_PAGE_2_PTR(pVM, pPage); … … 1611 1611 1612 1612 STAM_COUNTER_INC(&pPool->StatDirtyPage); 1613 pPage->fDirty = true;1614 pPage->idxDirty = idxFree;1615 pPool->a IdxDirtyPages[idxFree]= pPage->idx;1613 pPage->fDirty = true; 1614 pPage->idxDirty = idxFree; 1615 pPool->aDirtyPages[idxFree].uIdx = pPage->idx; 1616 1616 pPool->cDirtyPages++; 1617 1617 1618 pPool->idxFreeDirtyPage = (pPool->idxFreeDirtyPage + 1) & (RT_ELEMENTS(pPool->a IdxDirtyPages) - 1);1619 if ( pPool->cDirtyPages < RT_ELEMENTS(pPool->a IdxDirtyPages)1620 && pPool->a IdxDirtyPages[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) 1621 1621 { 1622 1622 unsigned i; 1623 for (i = 1; i < RT_ELEMENTS(pPool->a IdxDirtyPages); i++)1624 { 1625 idxFree = (pPool->idxFreeDirtyPage + i) & (RT_ELEMENTS(pPool->a IdxDirtyPages) - 1);1626 if (pPool->a IdxDirtyPages[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) 1627 1627 { 1628 1628 pPool->idxFreeDirtyPage = idxFree; … … 1630 1630 } 1631 1631 } 1632 Assert(i != RT_ELEMENTS(pPool->a IdxDirtyPages));1633 } 1634 1635 Assert(pPool->cDirtyPages == RT_ELEMENTS(pPool->a IdxDirtyPages) || 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); 1636 1636 return; 1637 1637 } … … 1654 1654 GCPhys = GCPhys & ~(RTGCPHYS)PAGE_OFFSET_MASK; 1655 1655 1656 for (unsigned i = 0; i < RT_ELEMENTS(pPool->a IdxDirtyPages); i++)1657 { 1658 if (pPool->a IdxDirtyPages[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) 1659 1659 { 1660 1660 PPGMPOOLPAGE pPage; 1661 unsigned idxPage = pPool->a IdxDirtyPages[i];1661 unsigned idxPage = pPool->aDirtyPages[i].uIdx; 1662 1662 1663 1663 pPage = &pPool->aPages[idxPage]; … … 1678 1678 PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool); 1679 1679 Assert(PGMIsLocked(pVM)); 1680 Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->a IdxDirtyPages));1680 Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->aDirtyPages)); 1681 1681 1682 1682 if (!pPool->cDirtyPages) … … 1684 1684 1685 1685 Log(("pgmPoolResetDirtyPages\n")); 1686 for (unsigned i = 0; i < RT_ELEMENTS(pPool->a IdxDirtyPages); i++)1686 for (unsigned i = 0; i < RT_ELEMENTS(pPool->aDirtyPages); i++) 1687 1687 pgmPoolFlushDirtyPage(pVM, pPool, i, true /* allow removal of reused page tables*/); 1688 1688 1689 1689 pPool->idxFreeDirtyPage = 0; 1690 if ( pPool->cDirtyPages != RT_ELEMENTS(pPool->a IdxDirtyPages)1691 && pPool->a IdxDirtyPages[pPool->idxFreeDirtyPage]!= NIL_PGMPOOL_IDX)1690 if ( pPool->cDirtyPages != RT_ELEMENTS(pPool->aDirtyPages) 1691 && pPool->aDirtyPages[pPool->idxFreeDirtyPage].uIdx != NIL_PGMPOOL_IDX) 1692 1692 { 1693 1693 unsigned i; 1694 for (i = 1; i < RT_ELEMENTS(pPool->a IdxDirtyPages); i++)1695 { 1696 if (pPool->a IdxDirtyPages[i]== NIL_PGMPOOL_IDX)1694 for (i = 1; i < RT_ELEMENTS(pPool->aDirtyPages); i++) 1695 { 1696 if (pPool->aDirtyPages[i].uIdx == NIL_PGMPOOL_IDX) 1697 1697 { 1698 1698 pPool->idxFreeDirtyPage = i; … … 1700 1700 } 1701 1701 } 1702 AssertMsg(i != RT_ELEMENTS(pPool->a IdxDirtyPages), ("cDirtyPages %d", pPool->cDirtyPages));1703 } 1704 1705 Assert(pPool->a IdxDirtyPages[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)); 1706 1706 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 */ 1715 void 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 } 1707 1728 } 1708 1729 … … 1717 1738 PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool); 1718 1739 Assert(PGMIsLocked(pVM)); 1719 Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->a IdxDirtyPages));1720 unsigned idxDirtyPage = RT_ELEMENTS(pPool->a IdxDirtyPages);1740 Assert(pPool->cDirtyPages <= RT_ELEMENTS(pPool->aDirtyPages)); 1741 unsigned idxDirtyPage = RT_ELEMENTS(pPool->aDirtyPages); 1721 1742 1722 1743 if (!pPool->cDirtyPages) … … 1725 1746 GCPhysPT = GCPhysPT & ~(RTGCPHYS)PAGE_OFFSET_MASK; 1726 1747 1727 for (unsigned i = 0; i < RT_ELEMENTS(pPool->a IdxDirtyPages); i++)1728 { 1729 if (pPool->a IdxDirtyPages[i]!= NIL_PGMPOOL_IDX)1730 { 1731 unsigned idxPage = pPool->a IdxDirtyPages[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; 1732 1753 1733 1754 PPGMPOOLPAGE pPage = &pPool->aPages[idxPage]; … … 1740 1761 } 1741 1762 1742 if (idxDirtyPage != RT_ELEMENTS(pPool->a IdxDirtyPages))1763 if (idxDirtyPage != RT_ELEMENTS(pPool->aDirtyPages)) 1743 1764 { 1744 1765 pgmPoolFlushDirtyPage(pVM, pPool, idxDirtyPage, true /* allow removal of reused page tables*/); 1745 if ( pPool->cDirtyPages != RT_ELEMENTS(pPool->a IdxDirtyPages)1746 && pPool->a IdxDirtyPages[pPool->idxFreeDirtyPage]!= NIL_PGMPOOL_IDX)1766 if ( pPool->cDirtyPages != RT_ELEMENTS(pPool->aDirtyPages) 1767 && pPool->aDirtyPages[pPool->idxFreeDirtyPage].uIdx != NIL_PGMPOOL_IDX) 1747 1768 { 1748 1769 unsigned i; 1749 for (i = 0; i < RT_ELEMENTS(pPool->a IdxDirtyPages); i++)1750 { 1751 if (pPool->a IdxDirtyPages[i]== NIL_PGMPOOL_IDX)1770 for (i = 0; i < RT_ELEMENTS(pPool->aDirtyPages); i++) 1771 { 1772 if (pPool->aDirtyPages[i].uIdx == NIL_PGMPOOL_IDX) 1752 1773 { 1753 1774 pPool->idxFreeDirtyPage = i; … … 1755 1776 } 1756 1777 } 1757 AssertMsg(i != RT_ELEMENTS(pPool->a IdxDirtyPages), ("cDirtyPages %d", pPool->cDirtyPages));1778 AssertMsg(i != RT_ELEMENTS(pPool->aDirtyPages), ("cDirtyPages %d", pPool->cDirtyPages)); 1758 1779 } 1759 1780 } … … 5204 5225 pPool->idxFreeDirtyPage = 0; 5205 5226 pPool->cDirtyPages = 0; 5206 for (unsigned i = 0; i < RT_ELEMENTS(pPool->a IdxDirtyPages); i++)5207 pPool->a IdxDirtyPages[i]= NIL_PGMPOOL_IDX;5227 for (unsigned i = 0; i < RT_ELEMENTS(pPool->aDirtyPages); i++) 5228 pPool->aDirtyPages[i].uIdx = NIL_PGMPOOL_IDX; 5208 5229 #endif 5209 5230
Note:
See TracChangeset
for help on using the changeset viewer.