VirtualBox

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


Ignore:
Timestamp:
May 21, 2008 3:33:04 PM (17 years ago)
Author:
vboxsync
Message:

More updates for nested paging. (setting up the paging mode)

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

Legend:

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

    r9021 r9026  
    215215    /* Disable the switcher */
    216216    VMMR3DisableSwitcher(pVM);
     217
     218    if (pVM->hwaccm.s.fNestedPaging)
     219    {
     220        /* Reinit the paging mode to force the new shadow mode. */
     221        PGMR3ChangeMode(pVM, PGMMODE_REAL);
     222    }
    217223}
    218224
  • trunk/src/VBox/VMM/PGM.cpp

    r9021 r9026  
    621621static int               pgmR3ModeDataInit(PVM pVM, bool fResolveGCAndR0);
    622622static void              pgmR3ModeDataSwitch(PVM pVM, PGMMODE enmShw, PGMMODE enmGst);
    623 static PGMMODE           pgmR3CalcShadowMode(PGMMODE enmGuestMode, SUPPAGINGMODE enmHostMode, PGMMODE enmShadowMode, VMMSWITCHER *penmSwitcher);
     623static PGMMODE           pgmR3CalcShadowMode(PVM pVM, PGMMODE enmGuestMode, SUPPAGINGMODE enmHostMode, PGMMODE enmShadowMode, VMMSWITCHER *penmSwitcher);
    624624
    625625#ifdef VBOX_WITH_STATISTICS
     
    13401340    rc = pgmR3ModeDataInit(pVM, false /* don't resolve GC and R0 syms yet */);
    13411341    if (VBOX_SUCCESS(rc))
    1342         rc = pgmR3ChangeMode(pVM, PGMMODE_REAL);
     1342        rc = PGMR3ChangeMode(pVM, PGMMODE_REAL);
    13431343    if (VBOX_SUCCESS(rc))
    13441344    {
     
    19051905             * Switch mode back to real mode.
    19061906             */
    1907             rc = pgmR3ChangeMode(pVM, PGMMODE_REAL);
     1907            rc = PGMR3ChangeMode(pVM, PGMMODE_REAL);
    19081908            STAM_REL_COUNTER_RESET(&pVM->pgm.s.cGuestModeChanges);
    19091909        }
     
    22792279     * Change the paging mode.
    22802280     */
    2281     return pgmR3ChangeMode(pVM, pPGM->enmGuestMode);
     2281    return PGMR3ChangeMode(pVM, pPGM->enmGuestMode);
    22822282}
    22832283
     
    27252725 *
    27262726 * @returns The shadow paging mode.
     2727 * @param   pVM             VM handle.
    27272728 * @param   enmGuestMode    The guest mode.
    27282729 * @param   enmHostMode     The host mode.
     
    27312732 *                          VMMSWITCHER_INVALID means no change.
    27322733 */
    2733 static PGMMODE pgmR3CalcShadowMode(PGMMODE enmGuestMode, SUPPAGINGMODE enmHostMode, PGMMODE enmShadowMode, VMMSWITCHER *penmSwitcher)
     2734static PGMMODE pgmR3CalcShadowMode(PVM pVM, PGMMODE enmGuestMode, SUPPAGINGMODE enmHostMode, PGMMODE enmShadowMode, VMMSWITCHER *penmSwitcher)
    27342735{
    27352736    VMMSWITCHER enmSwitcher = VMMSWITCHER_INVALID;
     
    28842885            return PGMMODE_INVALID;
    28852886    }
     2887    /* Override the shadow mode is nested paging is active. */
     2888    if (HWACCMIsNestedPagingActive(pVM))
     2889        enmShadowMode = PGMMODE_NESTED;
    28862890
    28872891    *penmSwitcher = enmSwitcher;
     
    28992903 *                          the current mode.
    29002904 */
    2901 int pgmR3ChangeMode(PVM pVM, PGMMODE enmGuestMode)
    2902 {
    2903     LogFlow(("pgmR3ChangeMode: Guest mode: %d -> %d\n", pVM->pgm.s.enmGuestMode, enmGuestMode));
     2905PGMR3DECL(int) PGMR3ChangeMode(PVM pVM, PGMMODE enmGuestMode)
     2906{
     2907    LogFlow(("PGMR3ChangeMode: Guest mode: %d -> %d\n", pVM->pgm.s.enmGuestMode, enmGuestMode));
    29042908    STAM_REL_COUNTER_INC(&pVM->pgm.s.cGuestModeChanges);
    29052909
     
    29082912     */
    29092913    VMMSWITCHER enmSwitcher;
    2910     PGMMODE     enmShadowMode = pgmR3CalcShadowMode(enmGuestMode, pVM->pgm.s.enmHostMode, pVM->pgm.s.enmShadowMode, &enmSwitcher);
     2914    PGMMODE     enmShadowMode = pgmR3CalcShadowMode(pVM, enmGuestMode, pVM->pgm.s.enmHostMode, pVM->pgm.s.enmShadowMode, &enmSwitcher);
    29112915    if (enmSwitcher != VMMSWITCHER_INVALID)
    29122916    {
     
    29282932    if (enmShadowMode != pVM->pgm.s.enmShadowMode)
    29292933    {
    2930         LogFlow(("pgmR3ChangeMode: Shadow mode: %d -> %d\n",  pVM->pgm.s.enmShadowMode, enmShadowMode));
     2934        LogFlow(("PGMR3ChangeMode: Shadow mode: %d -> %d\n",  pVM->pgm.s.enmShadowMode, enmShadowMode));
    29312935        if (PGM_SHW_PFN(Exit, pVM))
    29322936        {
  • trunk/src/VBox/VMM/PGMInternal.h

    r9021 r9026  
    25792579PGMGCDECL(int)  pgmGCGuestPDWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, RTGCPHYS GCPhysFault, void *pvUser);
    25802580PGMDECL(int)    pgmPhysRomWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, RTGCPHYS GCPhysFault, void *pvUser);
    2581 int             pgmR3ChangeMode(PVM pVM, PGMMODE enmGuestMode);
    25822581
    25832582int             pgmR3SyncPTResolveConflict(PVM pVM, PPGMMAPPING pMapping, PX86PD pPDSrc, RTGCPTR GCPtrOldMapping);
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r9024 r9026  
    908908PGMDECL(uint32_t) PGMGetHyperCR3(PVM pVM)
    909909{
    910     switch (pVM->pgm.s.enmShadowMode)
     910    PGMMODE enmShadowMode = pVM->pgm.s.enmShadowMode;
     911    switch (enmShadowMode)
    911912    {
    912913        case PGMMODE_32_BIT:
     
    922923
    923924        default:
    924             AssertMsgFailed(("enmShadowMode=%d\n", pVM->pgm.s.enmShadowMode));
     925            AssertMsgFailed(("enmShadowMode=%d\n", enmShadowMode));
     926            return ~0;
     927    }
     928}
     929
     930/**
     931 * Gets the current CR3 register value for the nested memory context.
     932 * @returns CR3 value.
     933 * @param   pVM         The VM handle.
     934 */
     935PGMDECL(uint32_t) PGMGetNestedCR3(PVM pVM, PGMMODE enmShadowMode)
     936{
     937    switch (enmShadowMode)
     938    {
     939        case PGMMODE_32_BIT:
     940            return pVM->pgm.s.HCPhys32BitPD;
     941
     942        case PGMMODE_PAE:
     943        case PGMMODE_PAE_NX:
     944            return pVM->pgm.s.HCPhysPaePDPT;
     945
     946        case PGMMODE_AMD64:
     947        case PGMMODE_AMD64_NX:
     948            return pVM->pgm.s.HCPhysPaePML4;
     949
     950        default:
     951            AssertMsgFailed(("enmShadowMode=%d\n", enmShadowMode));
    925952            return ~0;
    926953    }
     
    12451272        return VINF_SUCCESS;
    12461273#ifdef IN_RING3
    1247     return pgmR3ChangeMode(pVM, enmGuestMode);
     1274    return PGMR3ChangeMode(pVM, enmGuestMode);
    12481275#else
    12491276    Log(("PGMChangeMode: returns VINF_PGM_CHANGE_MODE.\n"));
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r9021 r9026  
    610610        if (pVM->hwaccm.s.fNestedPaging)
    611611        {
    612             pVMCB->ctrl.u64NestedPagingCR3  = PGMGetHyperCR3(pVM);
     612            pVMCB->ctrl.u64NestedPagingCR3  = PGMGetNestedCR3(pVM, PGMGetHostMode(pVM));
    613613            pVMCB->guest.u64CR3             = pCtx->cr3;
    614614        }
     
    12921292
    12931293        /* Handle the pagefault trap for the nested shadow table. */
    1294         rc = PGMR0Trap0eHandlerNestedPaging(pVM, PGMGetShadowMode(pVM), errCode, CPUMCTX2CORE(pCtx), uFaultAddress);
     1294        rc = PGMR0Trap0eHandlerNestedPaging(pVM, PGMGetHostMode(pVM), errCode, CPUMCTX2CORE(pCtx), uFaultAddress);
    12951295        Log2(("PGMR0Trap0eHandlerNestedPaging %VGv returned %Vrc\n", pCtx->eip, rc));
    12961296        if (rc == VINF_SUCCESS)
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