Changeset 18205 in vbox for trunk/src/VBox/VMM/PGMPhys.cpp
- Timestamp:
- Mar 24, 2009 4:41:24 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PGMPhys.cpp
r18167 r18205 24 24 * Header Files * 25 25 *******************************************************************************/ 26 #define LOG_GROUP LOG_GROUP_PGM 26 #define LOG_GROUP LOG_GROUP_PGM_PHYS 27 27 #include <VBox/pgm.h> 28 28 #include <VBox/cpum.h> … … 2158 2158 if (!pVM->pgm.s.fRamPreAlloc) 2159 2159 { 2160 /* Count dirty shadow pages. */ 2161 uint32_t cDirty = 0; 2162 uint32_t iPage = cPages; 2163 while (iPage-- > 0) 2160 /* Free the dirty pages. */ 2161 uint32_t cPendingPages = 0; 2162 PGMMFREEPAGESREQ pReq; 2163 rc = GMMR3FreePagesPrepare(pVM, &pReq, PGMPHYS_FREE_PAGE_BATCH_SIZE, GMMACCOUNT_BASE); 2164 AssertRCReturn(rc, rc); 2165 2166 for (uint32_t iPage = 0; iPage < cPages; iPage++) 2164 2167 if (PGM_PAGE_GET_STATE(&pRom->aPages[iPage].Shadow) != PGM_PAGE_STATE_ZERO) 2165 cDirty++; 2166 if (cDirty) 2168 { 2169 Assert(PGM_PAGE_GET_STATE(&pRom->aPages[iPage].Shadow) == PGM_PAGE_STATE_ALLOCATED); 2170 rc = pgmPhysFreePage(pVM, pReq, &cPendingPages, &pRom->aPages[iPage].Shadow, pRom->GCPhys + (iPage << PAGE_SHIFT)); 2171 AssertLogRelRCReturn(rc, rc); 2172 } 2173 2174 if (cPendingPages) 2167 2175 { 2168 /* Free the dirty pages. */ 2169 PGMMFREEPAGESREQ pReq; 2170 rc = GMMR3FreePagesPrepare(pVM, &pReq, cDirty, GMMACCOUNT_BASE); 2171 AssertRCReturn(rc, rc); 2172 2173 uint32_t iReqPage = 0; 2174 for (iPage = 0; iPage < cPages; iPage++) 2175 if (PGM_PAGE_GET_STATE(&pRom->aPages[iPage].Shadow) != PGM_PAGE_STATE_ZERO) 2176 { 2177 Assert(PGM_PAGE_GET_STATE(&pRom->aPages[iPage].Shadow) == PGM_PAGE_STATE_ALLOCATED); 2178 pReq->aPages[iReqPage].idPage = PGM_PAGE_GET_PAGEID(&pRom->aPages[iPage].Shadow); 2179 iReqPage++; 2180 } 2181 2182 rc = GMMR3FreePagesPerform(pVM, pReq, cDirty); 2183 GMMR3FreePagesCleanup(pReq); 2184 AssertRCReturn(rc, rc); 2185 2186 /* setup the zero page. */ 2187 for (iPage = 0; iPage < cPages; iPage++) 2188 if (PGM_PAGE_GET_STATE(&pRom->aPages[iPage].Shadow) != PGM_PAGE_STATE_ZERO) 2189 PGM_PAGE_INIT_ZERO_REAL(&pRom->aPages[iPage].Shadow, pVM, PGMPAGETYPE_ROM_SHADOW); 2190 2191 /* update the page count stats. */ 2192 pVM->pgm.s.cPrivatePages -= cDirty; 2193 pVM->pgm.s.cZeroPages += cDirty; 2176 rc = GMMR3FreePagesPerform(pVM, pReq, cPendingPages); 2177 AssertLogRelRCReturn(rc, rc); 2194 2178 } 2179 GMMR3FreePagesCleanup(pReq); 2195 2180 } 2196 2181 else 2197 2182 { 2198 /* clear all the pages. */2183 /* clear all the shadow pages. */ 2199 2184 for (uint32_t iPage = 0; iPage < cPages; iPage++) 2200 2185 { … … 3072 3057 ASMMemZeroPage(pv); 3073 3058 iClear++; 3059 Log3(("PGMR3PhysAllocateHandyPages: idPage=%#x HCPhys=%RGp\n", pPage->idPage, pPage->HCPhysGCPhys)); 3074 3060 } 3075 3061 … … 3089 3075 for (uint32_t i = 0; i < RT_ELEMENTS(pVM->pgm.s.aHandyPages); i++) 3090 3076 { 3091 LogRel(("PGM: aHandyPages[#% -2d] = {.HCPhysGCPhys=%RHp, .idPage=%#08x, .idSharedPage=%#08x}\n",3077 LogRel(("PGM: aHandyPages[#%#04x] = {.HCPhysGCPhys=%RHp, .idPage=%#08x, .idSharedPage=%#08x}\n", 3092 3078 i, pVM->pgm.s.aHandyPages[i].HCPhysGCPhys, pVM->pgm.s.aHandyPages[i].idPage, 3093 3079 pVM->pgm.s.aHandyPages[i].idSharedPage)); … … 3141 3127 */ 3142 3128 Assert(PDMCritSectIsOwner(&pVM->pgm.s.CritSect)); 3143 if (RT_UNLIKELY(PGM_PAGE_GET_TYPE(pPage) != PGMPAGETYPE_RAM)) 3129 if (RT_UNLIKELY( PGM_PAGE_GET_TYPE(pPage) != PGMPAGETYPE_RAM 3130 && PGM_PAGE_GET_TYPE(pPage) != PGMPAGETYPE_ROM_SHADOW)) 3144 3131 { 3145 3132 AssertMsgFailed(("GCPhys=%RGp pPage=%R[pgmpage]\n", GCPhys, pPage)); … … 3151 3138 3152 3139 const uint32_t idPage = PGM_PAGE_GET_PAGEID(pPage); 3140 Log3(("pgmPhysFreePage: idPage=%#x HCPhys=%RGp pPage=%R[pgmpage]\n", idPage, pPage)); 3153 3141 if (RT_UNLIKELY( idPage == NIL_GMM_PAGEID 3154 3142 || idPage > GMM_PAGEID_LAST
Note:
See TracChangeset
for help on using the changeset viewer.