VirtualBox

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


Ignore:
Timestamp:
Feb 24, 2009 12:14:19 PM (16 years ago)
Author:
vboxsync
Message:

Experiment with temporarily locking dynamic pages

File:
1 edited

Legend:

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

    r17048 r17057  
    21312131 * Temporarily maps one host page specified by HC physical address.
    21322132 *
    2133  * Be WARNED that the dynamic page mapping area is small, 8 pages, thus the space is
    2134  * reused after 8 mappings (or perhaps a few more if you score with the cache).
     2133 * Be WARNED that the dynamic page mapping area is small, 16 pages, thus the space is
     2134 * reused after 16 mappings (or perhaps a few more if you score with the cache).
    21352135 *
    21362136 * @returns VINF_SUCCESS, will bail out to ring-3 on failure.
     
    21852185    }
    21862186    AssertCompile(RT_ELEMENTS(pVM->pgm.s.aHCPhysDynPageMapCache) == 8);
     2187    AssertCompile((MM_HYPER_DYNAMIC_SIZE >> PAGE_SHIFT) == 16);
    21872188    STAM_COUNTER_INC(&pVM->pgm.s.StatRCDynMapCacheMisses);
    21882189
     
    21912192     */
    21922193    register unsigned iPage = pVM->pgm.s.iDynPageMapLast;
     2194#  ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
     2195    for (unsigned i=0;i<(MM_HYPER_DYNAMIC_SIZE >> PAGE_SHIFT);i++)
     2196    {
     2197        pVM->pgm.s.iDynPageMapLast = iPage = (iPage + 1) & ((MM_HYPER_DYNAMIC_SIZE >> PAGE_SHIFT) - 1);
     2198        if (!(pVM->pgm.s.paDynPageMap32BitPTEsGC[iPage].u & PGM_PTFLAGS_DYN_LOCKED))
     2199            break;
     2200        iPage++;
     2201    }
     2202    AssertRelease(i != (MM_HYPER_DYNAMIC_SIZE >> PAGE_SHIFT));
     2203#  else
    21932204    pVM->pgm.s.iDynPageMapLast = iPage = (iPage + 1) & ((MM_HYPER_DYNAMIC_SIZE >> PAGE_SHIFT) - 1);
    2194     Assert((MM_HYPER_DYNAMIC_SIZE >> PAGE_SHIFT) == 16);
     2205#  endif
    21952206
    21962207    pVM->pgm.s.aHCPhysDynPageMapCache[iPage & (RT_ELEMENTS(pVM->pgm.s.aHCPhysDynPageMapCache) - 1)] = HCPhys;
     
    22042215    return VINF_SUCCESS;
    22052216}
     2217
     2218/**
     2219 * Temporarily lock a dynamic page to prevent it from being reused.
     2220 *
     2221 * @returns VINF_SUCCESS, will bail out to ring-3 on failure.
     2222 * @param   pVM         VM handle.
     2223 * @param   GCPage      GC address of page
     2224 */
     2225VMMDECL(int) PGMDynLockHCPage(PVM pVM, RCPTRTYPE(uint8_t *) GCPage)
     2226{
     2227    unsigned iPage;
     2228
     2229    iPage = ((uintptr_t)(GCPage - pVM->pgm.s.pbDynPageMapBaseGC)) >> PAGE_SHIFT;
     2230    Assert(!(pVM->pgm.s.paDynPageMap32BitPTEsGC[iPage].u & PGM_PTFLAGS_DYN_LOCKED));
     2231    pVM->pgm.s.paDynPageMap32BitPTEsGC[iPage].u |= PGM_PTFLAGS_DYN_LOCKED;
     2232    return VINF_SUCCESS;
     2233}
     2234
     2235/**
     2236 * Unlock a dynamic page
     2237 *
     2238 * @returns VINF_SUCCESS, will bail out to ring-3 on failure.
     2239 * @param   pVM         VM handle.
     2240 * @param   GCPage      GC address of page
     2241 */
     2242VMMDECL(int) PGMDynUnlockHCPage(PVM pVM, RCPTRTYPE(uint8_t *) GCPage)
     2243{
     2244    unsigned iPage;
     2245
     2246    iPage = ((uintptr_t)(GCPage - pVM->pgm.s.pbDynPageMapBaseGC)) >> PAGE_SHIFT;
     2247    Assert(pVM->pgm.s.paDynPageMap32BitPTEsGC[iPage].u & PGM_PTFLAGS_DYN_LOCKED);
     2248    pVM->pgm.s.paDynPageMap32BitPTEsGC[iPage].u &= ~PGM_PTFLAGS_DYN_LOCKED;
     2249    return VINF_SUCCESS;
     2250}
     2251
    22062252# endif /* IN_RC */
    22072253
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