VirtualBox

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


Ignore:
Timestamp:
Jan 20, 2010 2:43:56 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56774
Message:

PGM,CPUM: Be more careful and flexible with guest mappings on restore. (#4362)

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

Legend:

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

    r25915 r25935  
    723723     * Check for conflicts and pending CR3 monitoring updates.
    724724     */
    725     if (!pVM->pgm.s.fMappingsFixed)
     725    if (pgmMapAreMappingsFloating(&pVM->pgm.s))
    726726    {
    727727        if (    pgmGetMapping(pVM, GCPtrPage)
     
    763763    {
    764764        pVCpu->pgm.s.fSyncFlags &= ~PGM_SYNC_MONITOR_CR3;
    765         Assert(!pVM->pgm.s.fMappingsFixed);
     765        Assert(!pVM->pgm.s.fMappingsFixed); Assert(!pVM->pgm.s.fMappingsDisabled);
    766766    }
    767767
     
    16901690        if (RT_LIKELY(rc == VINF_SUCCESS))
    16911691        {
    1692             if (!pVM->pgm.s.fMappingsFixed)
    1693             {
     1692            if (pgmMapAreMappingsFloating(&pVM->pgm.s))
    16941693                pVCpu->pgm.s.fSyncFlags &= ~PGM_SYNC_MONITOR_CR3;
    1695             }
    16961694        }
    16971695        else
     
    17011699            pVCpu->pgm.s.GCPhysCR3 = GCPhysOldCR3;
    17021700            pVCpu->pgm.s.fSyncFlags |= PGM_SYNC_MAP_CR3;
    1703             if (!pVM->pgm.s.fMappingsFixed)
     1701            if (pgmMapAreMappingsFloating(&pVM->pgm.s))
    17041702                pVCpu->pgm.s.fSyncFlags |= PGM_SYNC_MONITOR_CR3;
    17051703        }
     
    17271725        {
    17281726            pVCpu->pgm.s.fSyncFlags &= ~PGM_SYNC_MONITOR_CR3;
    1729             Assert(!pVM->pgm.s.fMappingsFixed);
     1727            Assert(!pVM->pgm.s.fMappingsFixed); Assert(!pVM->pgm.s.fMappingsDisabled);
    17301728        }
    17311729        if (fGlobal)
     
    17641762
    17651763    /* We assume we're only called in nested paging mode. */
    1766     Assert(pVM->pgm.s.fMappingsFixed);
     1764    Assert(HWACCMIsNestedPagingActive(pVM) || pVCpu->pgm.s.enmShadowMode == PGMMODE_EPT);
     1765    Assert(pVM->pgm.s.fMappingsDisabled);
    17671766    Assert(!(pVCpu->pgm.s.fSyncFlags & PGM_SYNC_MONITOR_CR3));
    1768     Assert(HWACCMIsNestedPagingActive(pVM) || pVCpu->pgm.s.enmShadowMode == PGMMODE_EPT);
    17691767
    17701768    /*
     
    19111909        {
    19121910            pVCpu->pgm.s.fSyncFlags &= ~PGM_SYNC_MONITOR_CR3;
    1913             Assert(!pVM->pgm.s.fMappingsFixed);
     1911            Assert(!pVM->pgm.s.fMappingsFixed); Assert(!pVM->pgm.s.fMappingsDisabled);
    19141912        }
    19151913    }
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r25866 r25935  
    291291                 * The first thing we check is if we've got an undetected conflict.
    292292                 */
    293                 if (!pVM->pgm.s.fMappingsFixed)
     293                if (pgmMapAreMappingsFloating(&pVM->pgm.s))
    294294                {
    295295                    unsigned iPT = pMapping->cb >> GST_PD_SHIFT;
     
    25992599#  endif
    26002600    }
    2601 # else  /* PGM_WITHOUT_MAPPINGS */
    2602     Assert(!pgmMapAreMappingsEnabled(&pVM->pgm.s));
    2603 # endif /* PGM_WITHOUT_MAPPINGS */
     2601# endif /* !PGM_WITHOUT_MAPPINGS */
    26042602    Assert(!PdeDst.n.u1Present); /* We're only supposed to call SyncPT on PDE!P and conflicts.*/
    26052603
     
    34493447    STAM_PROFILE_STOP(&pVCpu->pgm.s.CTX_MID_Z(Stat,SyncCR3Handlers), h);
    34503448    pgmUnlock(pVM);
    3451 #endif
     3449#endif /* !NESTED && !EPT */
    34523450
    34533451#if PGM_SHW_TYPE == PGM_TYPE_NESTED || PGM_SHW_TYPE == PGM_TYPE_EPT
     
    34573455    /** @todo check if this is really necessary; the call does it as well... */
    34583456    HWACCMFlushTLB(pVCpu);
     3457    Assert(!pgmMapAreMappingsEnabled(&pVM->pgm.s));
    34593458    return VINF_SUCCESS;
    34603459
     
    34643463     * out the shadow parts when the guest modifies its tables.
    34653464     */
     3465    Assert(!pgmMapAreMappingsEnabled(&pVM->pgm.s));
    34663466    return VINF_SUCCESS;
    34673467
    34683468#else /* PGM_SHW_TYPE != PGM_TYPE_NESTED && PGM_SHW_TYPE != PGM_TYPE_EPT && PGM_SHW_TYPE != PGM_TYPE_AMD64 */
    34693469
    3470 #  ifdef PGM_WITHOUT_MAPPINGS
    3471     Assert(pVM->pgm.s.fMappingsFixed);
    3472     return VINF_SUCCESS;
     3470#  ifndef PGM_WITHOUT_MAPPINGS
     3471    /*
     3472     * Check for and resolve conflicts with our guest mappings if they
     3473     * are enabled and not fixed.
     3474     */
     3475    if (pgmMapAreMappingsFloating(&pVM->pgm.s))
     3476    {
     3477        int rc = pgmMapResolveConflicts(pVM);
     3478        Assert(rc == VINF_SUCCESS || rc == VINF_PGM_SYNC_CR3);
     3479        if (rc == VINF_PGM_SYNC_CR3)
     3480        {
     3481            LogFlow(("SyncCR3: detected conflict -> VINF_PGM_SYNC_CR3\n"));
     3482            return VINF_PGM_SYNC_CR3;
     3483        }
     3484    }
    34733485#  else
    3474     /* Nothing to do when mappings are fixed. */
    3475     if (pVM->pgm.s.fMappingsFixed)
    3476         return VINF_SUCCESS;
    3477 
    3478     int rc = PGMMapResolveConflicts(pVM);
    3479     Assert(rc == VINF_SUCCESS || rc == VINF_PGM_SYNC_CR3);
    3480     if (rc == VINF_PGM_SYNC_CR3)
    3481     {
    3482         LogFlow(("SyncCR3: detected conflict -> VINF_PGM_SYNC_CR3\n"));
    3483         return VINF_PGM_SYNC_CR3;
    3484     }
     3486    Assert(!pgmMapAreMappingsEnabled(&pVM->pgm.s));
    34853487#  endif
    34863488    return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMAll/PGMAllMap.cpp

    r22890 r25935  
    389389    Log(("pgmMapClearShadowPDEs: old pde %x (cPTs=%x) (mappings enabled %d) fDeactivateCR3=%RTbool\n", iOldPDE, pMap->cPTs, pgmMapAreMappingsEnabled(&pVM->pgm.s), fDeactivateCR3));
    390390
     391    /*
     392     * Skip this if disabled or if it doesn't apply.
     393     */
    391394    if (    !pgmMapAreMappingsEnabled(&pVM->pgm.s)
    392395        ||  pVM->cCpus > 1)
     
    602605        return;
    603606
     607    /* This only applies to raw mode where we only support 1 VCPU. */
    604608    Assert(pVM->cCpus == 1);
    605 
    606     /* This only applies to raw mode where we only support 1 VCPU. */
    607609    PVMCPU pVCpu = VMMGetCpu0(pVM);
    608610    Assert(pVCpu->pgm.s.CTX_SUFF(pShwPageCR3));
     
    633635{
    634636    /*
    635      * Can skip this if mappings are disabled.
     637     * Skip this if disabled or if it doesn't apply.
    636638     */
    637639    if (    !pgmMapAreMappingsEnabled(&pVM->pgm.s)
     
    639641        return VINF_SUCCESS;
    640642
    641     /* Note. A log flush (in RC) can cause problems when called from MapCR3 (inconsistent state will trigger assertions). */
    642     Log4(("pgmMapActivateCR3: fixed mappings=%d idxShwPageCR3=%#x\n", pVM->pgm.s.fMappingsFixed, pShwPageCR3 ? pShwPageCR3->idx : NIL_PGMPOOL_IDX));
     643    /* Note! This might not be logged successfully in RC because we usually
     644             cannot flush the log at this point. */
     645    Log4(("pgmMapActivateCR3: fixed mappings=%RTbool idxShwPageCR3=%#x\n", pVM->pgm.s.fMappingsFixed, pShwPageCR3 ? pShwPageCR3->idx : NIL_PGMPOOL_IDX));
    643646
    644647#ifdef VBOX_STRICT
     
    669672{
    670673    /*
    671      * Can skip this if mappings are disabled.
     674     * Skip this if disabled or if it doesn't apply.
    672675     */
    673676    if (    !pgmMapAreMappingsEnabled(&pVM->pgm.s)
     
    702705     * Can skip this if mappings are safely fixed.
    703706     */
    704     if (pVM->pgm.s.fMappingsFixed)
     707    if (!pgmMapAreMappingsFloating(&pVM->pgm.s))
    705708        return false;
    706709
     
    788791
    789792/**
    790  * Checks and resolves (ring 3 only) guest conflicts with VMM GC mappings.
     793 * Checks and resolves (ring 3 only) guest conflicts with the guest mappings.
    791794 *
    792795 * @returns VBox status.
    793796 * @param   pVM                 The virtual machine.
    794797 */
    795 VMMDECL(int) PGMMapResolveConflicts(PVM pVM)
    796 {
    797     /*
    798      * Can skip this if mappings are safely fixed.
    799      */
    800     if (pVM->pgm.s.fMappingsFixed)
    801         return VINF_SUCCESS;
    802 
     798int pgmMapResolveConflicts(PVM pVM)
     799{
     800    /* The caller is expected to check these two conditions. */
     801    Assert(!pVM->pgm.s.fMappingsFixed);
     802    Assert(!pVM->pgm.s.fMappingsDisabled);
     803
     804    /* This only applies to raw mode where we only support 1 VCPU. */
    803805    Assert(pVM->cCpus == 1);
    804 
    805     /* This only applies to raw mode where we only support 1 VCPU. */
    806     PVMCPU pVCpu = &pVM->aCpus[0];
    807 
    808     PGMMODE const enmGuestMode = PGMGetGuestMode(pVCpu);
     806    PVMCPU          pVCpu        = &pVM->aCpus[0];
     807    PGMMODE const   enmGuestMode = PGMGetGuestMode(pVCpu);
    809808    Assert(enmGuestMode <= PGMMODE_PAE_NX);
    810809
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