VirtualBox

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


Ignore:
Timestamp:
Jul 29, 2010 1:08:04 PM (15 years ago)
Author:
vboxsync
Message:

PGMAllPhys.cpp: Don't put ROM pages in the page mapping TLB as we'll get into trouble with there being two different pages for the same GCPhys. (A better solution would be to not do this for unshadowed ROMs, but there is no easy way to do that.)

File:
1 edited

Legend:

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

    r31178 r31208  
    230230        pVM->pgm.s.PhysTlbHC.aEntries[i].pv = 0;
    231231    }
    232     /* @todo clear the RC TLB whenever we add it. */
     232    /** @todo clear the RC TLB whenever we add it. */
    233233    pgmUnlock(pVM);
    234234}
     
    390390            return rc;
    391391
    392         /* fall back to 4kb pages. */
     392        /* fall back to 4KB pages. */
    393393    }
    394394# endif
     
    471471    if (pvSharedPage)
    472472    {
     473        /* Get the virtual address of the new page. */
    473474        void *pvNewPage;
    474 
    475         /* Get the virtual address of the new page. */
    476475        rc = pgmPhysGCPhys2CCPtrInternal(pVM, pPage, GCPhys, &pvNewPage);
    477476        AssertRC(rc);
    478477        if (rc == VINF_SUCCESS)
    479478        {
    480             /** todo write ASMMemCopy */
     479            /** @todo todo write ASMMemCopyPage */
    481480            memcpy(pvNewPage, pvSharedPage, PAGE_SIZE);
    482481        }
     
    10211020{
    10221021    Assert(PGMIsLocked(PGM2VM(pPGM)));
    1023     STAM_COUNTER_INC(&pPGM->CTX_SUFF(pStats)->CTX_MID_Z(Stat,PageMapTlbMisses));
    1024 
    1025     /*
    1026      * Find the ram range.
     1022
     1023    /*
     1024     * Find the ram range and page and hand it over to the with-page function.
    10271025     * 99.8% of requests are expected to be in the first range.
    10281026     */
     
    10351033            pRam = pRam->CTX_SUFF(pNext);
    10361034            if (!pRam)
     1035            {
     1036                STAM_COUNTER_INC(&pPGM->CTX_SUFF(pStats)->CTX_MID_Z(Stat,PageMapTlbMisses));
    10371037                return VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS;
     1038            }
    10381039            off = GCPhys - pRam->GCPhys;
    10391040        } while (off >= pRam->cb);
    10401041    }
    10411042
     1043    return pgmPhysPageLoadIntoTlbWithPage(pPGM, &pRam->aPages[off >> PAGE_SHIFT], GCPhys);
     1044}
     1045
     1046
     1047/**
     1048 * Load a guest page into the ring-3 physical TLB.
     1049 *
     1050 * @returns VBox status code.
     1051 * @retval  VINF_SUCCESS on success
     1052 * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
     1053 *
     1054 * @param   pPGM        The PGM instance pointer.
     1055 * @param   pPage       Pointer to the PGMPAGE structure corresponding to
     1056 *                      GCPhys.
     1057 * @param   GCPhys      The guest physical address in question.
     1058 */
     1059int pgmPhysPageLoadIntoTlbWithPage(PPGM pPGM, PPGMPAGE pPage, RTGCPHYS GCPhys)
     1060{
     1061    Assert(PGMIsLocked(PGM2VM(pPGM)));
     1062    STAM_COUNTER_INC(&pPGM->CTX_SUFF(pStats)->CTX_MID_Z(Stat,PageMapTlbMisses));
     1063
    10421064    /*
    10431065     * Map the page.
    10441066     * Make a special case for the zero page as it is kind of special.
    10451067     */
    1046     PPGMPAGE pPage = &pRam->aPages[off >> PAGE_SHIFT];
    10471068    PPGMPAGEMAPTLBE pTlbe = &pPGM->CTXSUFF(PhysTlb).aEntries[PGM_PAGEMAPTLB_IDX(GCPhys)];
    10481069    if (    !PGM_PAGE_IS_ZERO(pPage)
     
    10651086    }
    10661087#ifdef PGM_WITH_PHYS_TLB
    1067     pTlbe->GCPhys = GCPhys & X86_PTE_PAE_PG_MASK;
    1068 #else
    1069     pTlbe->GCPhys = NIL_RTGCPHYS;
    1070 #endif
    1071     pTlbe->pPage  = pPage;
    1072     return VINF_SUCCESS;
    1073 }
    1074 
    1075 
    1076 /**
    1077  * Load a guest page into the ring-3 physical TLB.
    1078  *
    1079  * @returns VBox status code.
    1080  * @retval  VINF_SUCCESS on success
    1081  * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
    1082  *
    1083  * @param   pPGM        The PGM instance pointer.
    1084  * @param   pPage       Pointer to the PGMPAGE structure corresponding to
    1085  *                      GCPhys.
    1086  * @param   GCPhys      The guest physical address in question.
    1087  */
    1088 int pgmPhysPageLoadIntoTlbWithPage(PPGM pPGM, PPGMPAGE pPage, RTGCPHYS GCPhys)
    1089 {
    1090     Assert(PGMIsLocked(PGM2VM(pPGM)));
    1091     STAM_COUNTER_INC(&pPGM->CTX_SUFF(pStats)->CTX_MID_Z(Stat,PageMapTlbMisses));
    1092 
    1093     /*
    1094      * Map the page.
    1095      * Make a special case for the zero page as it is kind of special.
    1096      */
    1097     PPGMPAGEMAPTLBE pTlbe = &pPGM->CTXSUFF(PhysTlb).aEntries[PGM_PAGEMAPTLB_IDX(GCPhys)];
    1098     if (    !PGM_PAGE_IS_ZERO(pPage)
    1099         &&  !PGM_PAGE_IS_BALLOONED(pPage))
    1100     {
    1101         void *pv;
    1102         PPGMPAGEMAP pMap;
    1103         int rc = pgmPhysPageMapCommon(PGM2VM(pPGM), pPage, GCPhys, &pMap, &pv);
    1104         if (RT_FAILURE(rc))
    1105             return rc;
    1106         pTlbe->pMap = pMap;
    1107         pTlbe->pv = pv;
    1108         Assert(!((uintptr_t)pTlbe->pv & PAGE_OFFSET_MASK));
    1109     }
     1088    if (    PGM_PAGE_GET_TYPE(pPage) < PGMPAGETYPE_ROM_SHADOW
     1089        ||  PGM_PAGE_GET_TYPE(pPage) > PGMPAGETYPE_ROM)
     1090        pTlbe->GCPhys = GCPhys & X86_PTE_PAE_PG_MASK;
    11101091    else
    1111     {
    1112         Assert(PGM_PAGE_GET_HCPHYS(pPage) == pPGM->HCPhysZeroPg);
    1113         pTlbe->pMap = NULL;
    1114         pTlbe->pv = pPGM->CTXALLSUFF(pvZeroPg);
    1115     }
    1116 #ifdef PGM_WITH_PHYS_TLB
    1117     pTlbe->GCPhys = GCPhys & X86_PTE_PAE_PG_MASK;
     1092        pTlbe->GCPhys = NIL_RTGCPHYS; /* ROM: Problematic because of the two pages. :-/ */
    11181093#else
    11191094    pTlbe->GCPhys = NIL_RTGCPHYS;
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