VirtualBox

Changeset 20151 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
May 29, 2009 12:40:31 PM (16 years ago)
Author:
vboxsync
Message:

Handle pgm pool flushes a bit differently.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PGMHandler.cpp

    r19141 r20151  
    388388        if (enmType != PGMVIRTHANDLERTYPE_HYPERVISOR)
    389389        {
     390            PVMCPU pVCpu = VMMGetCpu(pVM);
     391
    390392            pVM->pgm.s.fPhysCacheFlushPending = true;
    391             for (unsigned i=0;i<pVM->cCPUs;i++)
    392             {
    393                 PVMCPU pVCpu = &pVM->aCpus[i];
    394 
    395                 pVCpu->pgm.s.fSyncFlags |= PGM_SYNC_UPDATE_PAGE_BIT_VIRTUAL;
    396                 VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3);
    397             }
    398             pVM->pgm.s.fGlobalSyncFlags |= PGM_GLOBAL_SYNC_CLEAR_PGM_POOL;
     393
     394            pVCpu->pgm.s.fSyncFlags |= PGM_SYNC_UPDATE_PAGE_BIT_VIRTUAL | PGM_SYNC_CLEAR_PGM_POOL;
     395            VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3);
    399396        }
    400397        pgmUnlock(pVM);
     
    475472         * Schedule CR3 sync.
    476473         */
    477         for (unsigned i=0;i<pVM->cCPUs;i++)
    478         {
    479             PVMCPU pVCpu = &pVM->aCpus[i];
    480 
    481             pVCpu->pgm.s.fSyncFlags |= PGM_SYNC_UPDATE_PAGE_BIT_VIRTUAL;
    482             VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3);
    483         }
    484         pVM->pgm.s.fGlobalSyncFlags |= PGM_GLOBAL_SYNC_CLEAR_PGM_POOL;
     474        PVMCPU pVCpu = VMMGetCpu(pVM);
     475
     476        pVCpu->pgm.s.fSyncFlags |= PGM_SYNC_UPDATE_PAGE_BIT_VIRTUAL | PGM_SYNC_CLEAR_PGM_POOL;
     477        VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3);
    485478    }
    486479    else
  • trunk/src/VBox/VMM/PGMInternal.h

    r20136 r20151  
    22242224    bool                            afAlignment0[7];
    22252225
    2226     /** What needs syncing (PGM_SYNC_*).
    2227      * This is used to queue operations for PGMSyncCR3, PGMInvalidatePage,
    2228      * PGMFlushTLB, and PGMR3Load. */
    2229     RTUINT                          fGlobalSyncFlags;
    2230 
    22312226    /*
    22322227     * This will be redefined at least two more times before we're done, I'm sure.
     
    29172912#define PGM_SYNC_MAP_CR3                        RT_BIT(3)
    29182913/** Clear the page pool (a light weight flush). */
    2919 #define PGM_GLOBAL_SYNC_CLEAR_PGM_POOL_BIT      8
    2920 #define PGM_GLOBAL_SYNC_CLEAR_PGM_POOL          RT_BIT(PGM_GLOBAL_SYNC_CLEAR_PGM_POOL_BIT)
     2914#define PGM_SYNC_CLEAR_PGM_POOL_BIT             8
     2915#define PGM_SYNC_CLEAR_PGM_POOL                 RT_BIT(PGM_SYNC_CLEAR_PGM_POOL_BIT)
    29212916/** @} */
    29222917
     
    29832978void            pgmPoolClearAll(PVM pVM);
    29842979PPGMPOOLPAGE    pgmPoolGetPage(PPGMPOOL pPool, RTHCPHYS HCPhys);
    2985 int             pgmPoolSyncCR3(PVM pVM);
     2980int             pgmPoolSyncCR3(PVMCPU pVCpu);
    29862981int             pgmPoolTrackFlushGCPhys(PVM pVM, PPGMPAGE pPhysPage, bool *pfFlushTLBs);
    29872982uint16_t        pgmPoolTrackPhysExtAddref(PVM pVM, uint16_t u16, uint16_t iShwPT);
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r20068 r20151  
    17741774     * clear the whole thing.
    17751775     */
    1776     rc = pgmPoolSyncCR3(pVM);
     1776    rc = pgmPoolSyncCR3(pVCpu);
    17771777    if (rc != VINF_SUCCESS)
    17781778        return rc;
     
    18331833#ifdef IN_RING3
    18341834        if (rc == VINF_PGM_SYNC_CR3)
    1835             rc = pgmPoolSyncCR3(pVM);
     1835            rc = pgmPoolSyncCR3(pVCpu);
    18361836#else
    18371837        if (rc == VINF_PGM_SYNC_CR3)
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r20140 r20151  
    17461746         * the heap size should suffice. */
    17471747        AssertFatalMsgRC(rc, ("PGMHandlerPhysicalRegisterEx %RGp failed with %Rrc\n", GCPhysPage, rc));
    1748         Assert(!(pVM->pgm.s.fGlobalSyncFlags & PGM_GLOBAL_SYNC_CLEAR_PGM_POOL) || VMCPU_FF_ISSET(VMMGetCpu(pVM), VMCPU_FF_PGM_SYNC_CR3));
     1748        Assert(!(VMMGetCpu(pVM)->pgm.s.fSyncFlags & PGM_SYNC_CLEAR_PGM_POOL) || VMCPU_FF_ISSET(VMMGetCpu(pVM), VMCPU_FF_PGM_SYNC_CR3));
    17491749    }
    17501750    pPage->fMonitored = true;
     
    18431843        rc = PGMHandlerPhysicalDeregister(pVM, pPage->GCPhys & ~(RTGCPHYS)(PAGE_SIZE - 1));
    18441844        AssertFatalRC(rc);
    1845         AssertMsg(!(pVM->pgm.s.fGlobalSyncFlags & PGM_GLOBAL_SYNC_CLEAR_PGM_POOL) || VMCPU_FF_ISSET(VMMGetCpu(pVM), VMCPU_FF_PGM_SYNC_CR3),
    1846                   ("%#x %#x\n", pVM->pgm.s.fGlobalSyncFlags, pVM->fGlobalForcedActions));
     1845#ifdef VBOX_STRICT
     1846        PVMCPU pVCpu = VMMGetCpu(pVM);
     1847#endif
     1848        AssertMsg(!(pVCpu->pgm.s.fSyncFlags & PGM_SYNC_CLEAR_PGM_POOL) || VMCPU_FF_ISSET(pVCpu, VMCPU_FF_PGM_SYNC_CR3),
     1849                  ("%#x %#x\n", pVCpu->pgm.s.fSyncFlags, pVM->fGlobalForcedActions));
    18471850    }
    18481851    pPage->fMonitored = false;
     
    20752078#endif
    20762079
     2080    /* Clear the PGM_SYNC_CLEAR_PGM_POOL flag on all VCPUs to prevent redundant flushes. */
     2081    for (unsigned idCpu = 0; idCpu < pVM->cCPUs; idCpu++)
     2082    {
     2083        PVMCPU pVCpu = &pVM->aCpus[idCpu];
     2084
     2085        pVCpu->pgm.s.fSyncFlags &= ~PGM_SYNC_CLEAR_PGM_POOL;
     2086    }
     2087
    20772088    pPool->cPresent = 0;
    20782089    pgmUnlock(pVM);
     
    20902101 * @retval  VINF_SUCCESS if successfully added.
    20912102 * @retval  VINF_PGM_SYNC_CR3 is it needs to be deferred to ring 3 (GC only)
    2092  * @param   pVM     The VM handle.
     2103 * @param   pVCpu     The VMCPU handle.
    20932104 * @remark  Should only be used when monitoring is available, thus placed in
    20942105 *          the PGMPOOL_WITH_MONITORING #ifdef.
    20952106 */
    2096 int pgmPoolSyncCR3(PVM pVM)
    2097 {
     2107int pgmPoolSyncCR3(PVMCPU pVCpu)
     2108{
     2109    PVM pVM = pVCpu->CTX_SUFF(pVM);
    20982110    LogFlow(("pgmPoolSyncCR3\n"));
    20992111    /*
     
    21042116     */
    21052117# ifdef IN_RING3 /* Don't flush in ring-0 or raw mode, it's taking too long. */
    2106     if (ASMBitTestAndClear(&pVM->pgm.s.fGlobalSyncFlags, PGM_GLOBAL_SYNC_CLEAR_PGM_POOL_BIT))
     2118    if (ASMBitTestAndClear(&pVCpu->pgm.s.fSyncFlags, PGM_SYNC_CLEAR_PGM_POOL_BIT))
    21072119    {
    21082120        VMMR3AtomicExecuteHandler(pVM, pgmPoolClearAll, NULL);
    21092121# else  /* !IN_RING3 */
    2110     if (pVM->pgm.s.fGlobalSyncFlags & PGM_GLOBAL_SYNC_CLEAR_PGM_POOL)
    2111     {
    2112         LogFlow(("SyncCR3: PGM_GLOBAL_SYNC_CLEAR_PGM_POOL is set -> VINF_PGM_SYNC_CR3\n"));
    2113         VMCPU_FF_SET(VMMGetCpu(pVM), VMCPU_FF_PGM_SYNC_CR3); /** @todo no need to do global sync, right? */
     2122    if (pVCpu->pgm.s.fSyncFlags & PGM_SYNC_CLEAR_PGM_POOL)
     2123    {
     2124        LogFlow(("SyncCR3: PGM_SYNC_CLEAR_PGM_POOL is set -> VINF_PGM_SYNC_CR3\n"));
     2125        VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3); /** @todo no need to do global sync, right? */
    21142126        return VINF_PGM_SYNC_CR3;
    21152127# endif /* !IN_RING3 */
     
    27492761    if (rc == VINF_PGM_GCPHYS_ALIASED)
    27502762    {
    2751         pVM->pgm.s.fGlobalSyncFlags |= PGM_GLOBAL_SYNC_CLEAR_PGM_POOL;
     2763        pVCpu->pgm.s.fSyncFlags |= PGM_SYNC_CLEAR_PGM_POOL;
    27522764        VMCPU_FF_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3);
    27532765        rc = VINF_PGM_SYNC_CR3;
     
    40484060    /** @todo CSAM/PGMPrefetchPage messes up here during CSAMR3CheckGates
    40494061     *  (TRPMR3SyncIDT) because of FF priority. Try fix that?
    4050      *  Assert(!(pVM->pgm.s.fGlobalSyncFlags & PGM_GLOBAL_SYNC_CLEAR_PGM_POOL)); */
     4062     *  Assert(!(pVM->pgm.s.fGlobalSyncFlags & PGM_SYNC_CLEAR_PGM_POOL)); */
    40514063
    40524064    pgmLock(pVM);
  • trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp

    r20135 r20151  
    475475    GEN_CHECK_OFF(PGM, offVCpuPGM);
    476476    GEN_CHECK_OFF(PGM, fRamPreAlloc);
    477     GEN_CHECK_OFF(PGM, fGlobalSyncFlags);
    478477    GEN_CHECK_OFF(PGM, paDynPageMap32BitPTEsGC);
    479478    GEN_CHECK_OFF(PGM, paDynPageMapPaePTEsGC);
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