VirtualBox

Changeset 26717 in vbox


Ignore:
Timestamp:
Feb 23, 2010 4:04:28 PM (15 years ago)
Author:
vboxsync
Message:

Large page cleanup

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r26711 r26717  
    29392939    if (rc != VINF_SUCCESS)
    29402940    {
     2941        STAM_PROFILE_STOP(&pVCpu->pgm.s.CTX_MID_Z(Stat,SyncPT), a);
    29412942        AssertRC(rc);
    29422943        return rc;
     
    29552956
    29562957# if (PGM_SHW_TYPE == PGM_TYPE_EPT) && (HC_ARCH_BITS == 64) && defined(RT_OS_WINDOWS)
    2957     if (PGMIsUsingLargePages(pVM))
    2958     {
    2959         RTHCPHYS HCPhys;
    2960         rc = pgmPhysAllocLargePage(pVM, GCPtrPage & SHW_PDE_PG_MASK, &HCPhys);
     2958    {
     2959        PPGMPAGE pPage;
     2960
     2961        /* Check if we allocated a big page before for this 2 MB range. */
     2962        int rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPtrPage & X86_PDE2M_PAE_PG_MASK, &pPage);
    29612963        if (RT_SUCCESS(rc))
    29622964        {
    2963             PdeDst.u &= X86_PDE_AVL_MASK;
    2964             PdeDst.u |= HCPhys;
    2965             PdeDst.n.u1Present   = 1;
    2966             PdeDst.n.u1Write     = 1;
    2967             PdeDst.n.u1Execute   = 1;
    2968             PdeDst.b.u1Size      = 1;
    2969             PdeDst.b.u1IgnorePAT = 1;
    2970             PdeDst.b.u3EMT       = VMX_EPT_MEMTYPE_WB;
    2971             ASMAtomicWriteSize(pPdeDst, PdeDst.u);
    2972 
    2973             STAM_PROFILE_STOP(&pVCpu->pgm.s.CTX_MID_Z(Stat,SyncPT), a);
    2974             return VINF_SUCCESS;
    2975 
     2965            RTHCPHYS HCPhys = NIL_RTHCPHYS;
     2966
     2967            if (PGM_PAGE_GET_PDE_TYPE(pPage) == PGM_PAGE_PDE_TYPE_PDE)
     2968            {
     2969                AssertRelease(PGM_PAGE_GET_STATE(pPage) == PGM_PAGE_STATE_ALLOCATED);
     2970                HCPhys = PGM_PAGE_GET_HCPHYS(pPage);
     2971            }
     2972            else
     2973            if (PGMIsUsingLargePages(pVM))
     2974            {
     2975                rc = pgmPhysAllocLargePage(pVM, GCPtrPage);
     2976                if (RT_SUCCESS(rc))
     2977                {
     2978                    Assert(PGM_PAGE_GET_STATE(pPage) == PGM_PAGE_STATE_ALLOCATED);
     2979                    Assert(PGM_PAGE_GET_PDE_TYPE(pPage) == PGM_PAGE_PDE_TYPE_PDE);
     2980                    HCPhys = PGM_PAGE_GET_HCPHYS(pPage);
     2981                }
     2982                else
     2983                    LogFlow(("pgmPhysAllocLargePage failed with %Rrc\n", rc));
     2984            }
     2985
     2986            if (HCPhys != NIL_RTHCPHYS)
     2987            {
     2988                PdeDst.u &= X86_PDE_AVL_MASK;
     2989                PdeDst.u |= HCPhys;
     2990                PdeDst.n.u1Present   = 1;
     2991                PdeDst.n.u1Write     = 1;
     2992                PdeDst.n.u1Execute   = 1;
     2993                PdeDst.b.u1Size      = 1;
     2994                PdeDst.b.u1IgnorePAT = 1;
     2995                PdeDst.b.u3EMT       = VMX_EPT_MEMTYPE_WB;
     2996                ASMAtomicWriteSize(pPdeDst, PdeDst.u);
     2997
     2998                STAM_PROFILE_STOP(&pVCpu->pgm.s.CTX_MID_Z(Stat,SyncPT), a);
     2999                return VINF_SUCCESS;
     3000            }
    29763001        }
    2977         else
    2978             LogFlow(("pgmPhysAllocLargePage failed with %Rrc\n", rc));
    29793002    }
    29803003# endif
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r26686 r26717  
    371371        &&  PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_RAM)
    372372    {
    373         RTHCPHYS HCPhysDummy;
    374 
    375         int rc = pgmPhysAllocLargePage(pVM, GCPhys, &HCPhysDummy);
     373        int rc = pgmPhysAllocLargePage(pVM, GCPhys);
    376374        if (rc == VINF_SUCCESS)
    377375            return rc;
     
    468466 * @param   pVM         The VM address.
    469467 * @param   GCPhys      The address of the page.
    470  * @param   pHCPhys     Pointer to HC physical address (out)
    471468 *
    472469 * @remarks Must be called from within the PGM critical section. It may
    473470 *          nip back to ring-3/0 in some cases.
    474471 */
    475 int pgmPhysAllocLargePage(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS *pHCPhys)
     472int pgmPhysAllocLargePage(PVM pVM, RTGCPHYS GCPhys)
    476473{
    477474    RTGCPHYS GCPhysBase = GCPhys & X86_PDE2M_PAE_PG_MASK;
     
    483480    Assert(PGMIsLocked(pVM));
    484481    Assert(PGMIsUsingLargePages(pVM));
    485     Assert((GCPhys & X86_PD_PAE_MASK) == 0);
    486     AssertPtr(pHCPhys);
    487482
    488483    PPGMPAGE pPage;
     
    491486        &&  PGM_PAGE_GET_TYPE(pPage) == PGMPAGETYPE_RAM)
    492487    {
    493         RTHCPHYS HCPhys = NIL_RTHCPHYS;
    494488        unsigned uPDEType = PGM_PAGE_GET_PDE_TYPE(pPage);
    495489
    496         if  (uPDEType == PGM_PAGE_PDE_TYPE_PDE)
    497         {
    498             /* Previously allocated 2 MB range can be reused. */
    499             Assert(PGM_PAGE_GET_STATE(pPage) == PGM_PAGE_STATE_ALLOCATED);
    500 
    501             *pHCPhys = PGM_PAGE_GET_HCPHYS(pPage);
    502             return VINF_SUCCESS;
    503         }
    504         else
     490        /* Don't call this function for already allocated pages. */
     491        Assert(uPDEType != PGM_PAGE_PDE_TYPE_PDE);
     492
    505493        if  (   uPDEType == PGM_PAGE_PDE_TYPE_DONTCARE
    506494             && PGM_PAGE_GET_STATE(pPage) == PGM_PAGE_STATE_ZERO)
     
    547535                {   
    548536                    Assert(PGM_PAGE_GET_STATE(pPage) == PGM_PAGE_STATE_ALLOCATED);
    549                     *pHCPhys = PGM_PAGE_GET_HCPHYS(pPage);
    550537                    STAM_COUNTER_INC(&pVM->pgm.s.StatLargePageUsed);
    551538                    return 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