VirtualBox

Changeset 9064 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 23, 2008 9:20:55 AM (17 years ago)
Author:
vboxsync
Message:

Properly deal with CR3 changes in nested paging mode.

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

Legend:

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

    r9032 r9064  
    11571157}
    11581158
     1159/**
     1160 * Performs and schedules necessary updates following a CR3 load or reload,
     1161 * without actually the TLB as with PGMFlushTLB.
     1162 *
     1163 * This will normally involve mapping the guest PD or nPDPT
     1164 *
     1165 * @returns VBox status code.
     1166 * @retval  VINF_PGM_SYNC_CR3 if monitoring requires a CR3 sync. This can
     1167 *          safely be ignored and overridden since the FF will be set too then.
     1168 * @param   pVM         VM handle.
     1169 * @param   cr3         The new cr3.
     1170 */
     1171PGMDECL(int) PGMUpdateCR3(PVM pVM, uint64_t cr3)
     1172{
     1173    LogFlow(("PGMUpdateCR3: cr3=%VX64 OldCr3=%VX64\n", cr3, pVM->pgm.s.GCPhysCR3));
     1174
     1175    /* We assume we're only called in nested paging mode. */
     1176    Assert(pVM->pgm.s.fMappingsFixed);
     1177    Assert(!(pVM->pgm.s.fSyncFlags & PGM_SYNC_MONITOR_CR3));
     1178    Assert(pVM->pgm.s.enmShadowMode == PGMMODE_NESTED);
     1179
     1180    /*
     1181     * Remap the CR3 content and adjust the monitoring if CR3 was actually changed.
     1182     */
     1183    int rc = VINF_SUCCESS;
     1184    RTGCPHYS GCPhysCR3;
     1185    if (    pVM->pgm.s.enmGuestMode == PGMMODE_PAE
     1186        ||  pVM->pgm.s.enmGuestMode == PGMMODE_PAE_NX
     1187        ||  pVM->pgm.s.enmGuestMode == PGMMODE_AMD64
     1188        ||  pVM->pgm.s.enmGuestMode == PGMMODE_AMD64_NX)
     1189        GCPhysCR3 = (RTGCPHYS)(cr3 & X86_CR3_PAE_PAGE_MASK);
     1190    else
     1191        GCPhysCR3 = (RTGCPHYS)(cr3 & X86_CR3_PAGE_MASK);
     1192    if (pVM->pgm.s.GCPhysCR3 != GCPhysCR3)
     1193    {
     1194        pVM->pgm.s.GCPhysCR3 = GCPhysCR3;
     1195        rc = PGM_GST_PFN(MapCR3, pVM)(pVM, GCPhysCR3);
     1196    }
     1197    AssertRC(rc);
     1198    return rc;
     1199}
    11591200
    11601201/**
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r9038 r9064  
    258258        pVMCB->ctrl.u16InterceptRdCRx = RT_BIT(0) | RT_BIT(3) | RT_BIT(4);
    259259    else
    260         pVMCB->ctrl.u16InterceptRdCRx = RT_BIT(0);
     260        pVMCB->ctrl.u16InterceptRdCRx = RT_BIT(0) | RT_BIT(4);
    261261
    262262    /*
     
    266266        pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(3) | RT_BIT(4) | RT_BIT(8);
    267267    else
    268         pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(8);
     268        pVMCB->ctrl.u16InterceptWrCRx = RT_BIT(0) | RT_BIT(4) | RT_BIT(8);
    269269
    270270    /* Intercept all DRx reads and writes. */
     
    10411041    {
    10421042        CPUMSetGuestCR3(pVM, pVMCB->guest.u64CR3);
    1043         CPUMSetGuestCR4(pVM, pVMCB->guest.u64CR4);
     1043        PGMUpdateCR3(pVM, pVMCB->guest.u64CR3);
    10441044    }
    10451045
     
    14231423            break;
    14241424        case 4:
    1425             Assert(!pVM->hwaccm.s.fNestedPaging);
    14261425            pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR4;
    14271426            break;
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