VirtualBox

Changeset 20749 in vbox


Ignore:
Timestamp:
Jun 21, 2009 8:57:37 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
48865
Message:

REMNotifyInvalidatePage: Don't overflow aGCPtrInvalidatedPages. 2xtodo

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/REMInternal.h

    r20747 r20749  
    165165
    166166    /** Number of recorded invlpg instructions. */
    167     uint32_t                cInvalidatedPages;
     167    uint32_t volatile       cInvalidatedPages;
    168168#if HC_ARCH_BITS == 32
    169169    uint32_t                uPadding2;
  • trunk/src/VBox/VMM/VMMAll/REMAll.cpp

    r20747 r20749  
    4747VMMDECL(int) REMNotifyInvalidatePage(PVM pVM, RTGCPTR GCPtrPage)
    4848{
    49     if (    pVM->rem.s.cInvalidatedPages < RT_ELEMENTS(pVM->rem.s.aGCPtrInvalidatedPages)
    50         &&  EMTryEnterRemLock(pVM) == VINF_SUCCESS) /* if this fails, then we'll just flush the tlb as we don't want to waste time here. */
    51     {
    52         /*
    53          * We sync them back in REMR3State.
    54          */
    55         pVM->rem.s.aGCPtrInvalidatedPages[pVM->rem.s.cInvalidatedPages++] = GCPtrPage;
     49    /*
     50     * Try take the REM lock and push the address onto the array.
     51     */
     52    if (   pVM->rem.s.cInvalidatedPages < RT_ELEMENTS(pVM->rem.s.aGCPtrInvalidatedPages)
     53        && EMTryEnterRemLock(pVM) == VINF_SUCCESS)
     54    {
     55        uint32_t iPage = pVM->rem.s.cInvalidatedPages;
     56        if (iPage < RT_ELEMENTS(pVM->rem.s.aGCPtrInvalidatedPages))
     57        {
     58            ASMAtomicWriteU32(&pVM->rem.s.cInvalidatedPages, iPage + 1);
     59            pVM->rem.s.aGCPtrInvalidatedPages[iPage] = GCPtrPage;
     60
     61            EMRemUnlock(pVM);
     62            return VINF_SUCCESS;
     63        }
     64
     65        CPUMSetChangedFlags(VMMGetCpu(pVM), CPUM_CHANGED_GLOBAL_TLB_FLUSH); /** @todo this should be flagged globally, not locally! ... this array should be per-cpu technically speaking. */
     66        ASMAtomicWriteU32(&pVM->rem.s.cInvalidatedPages, 0); /** @todo leave this alone? Optimize this code? */
     67
    5668        EMRemUnlock(pVM);
    5769    }
    5870    else
    5971    {
    60         /* Tell the recompiler to flush its TLB. */
     72        /* Fallback: Simply tell the recompiler to flush its TLB. */
    6173        CPUMSetChangedFlags(VMMGetCpu(pVM), CPUM_CHANGED_GLOBAL_TLB_FLUSH);
    62         pVM->rem.s.cInvalidatedPages = 0;
     74        ASMAtomicWriteU32(&pVM->rem.s.cInvalidatedPages, 0); /** @todo leave this alone?! Optimize this code? */
    6375    }
    6476
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette