Changeset 92326 in vbox
- Timestamp:
- Nov 10, 2021 3:14:52 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/gmm.h
r92292 r92326 232 232 * @input GMMR0AllocateHandyPages expects the guest physical address 233 233 * to update the GMMPAGE structure with. Pass GMM_GCPHYS_UNSHAREABLE 234 * when appropriate and NIL_ RTHCPHYS when the page wasn't used234 * when appropriate and NIL_GMMPAGEDESC_PHYS when the page wasn't used 235 235 * for any specific guest address. 236 236 * 237 237 * GMMR0AllocatePage expects the guest physical address to put in 238 238 * the GMMPAGE structure for the page it allocates for this entry. 239 * Pass NIL_ RTHCPHYS and GMM_GCPHYS_UNSHAREABLE as above.239 * Pass NIL_GMMPAGEDESC_PHYS and GMM_GCPHYS_UNSHAREABLE as above. 240 240 * 241 241 * @output The host physical address of the allocated page. 242 * NIL_RTHCPHYS on allocation failure. 243 * 244 * ASSUMES: sizeof(RTHCPHYS) >= sizeof(RTGCPHYS). 242 * NIL_GMMPAGEDESC_PHYS on allocation failure. 243 * 244 * ASSUMES: sizeof(RTHCPHYS) >= sizeof(RTGCPHYS) and that physical addresses are 245 * limited to 63 or fewer bits (52 by AMD64 arch spec). 245 246 */ 246 RTHCPHYS HCPhysGCPhys; 247 RTHCPHYS HCPhysGCPhys : 63; 248 /** Set if the memory was zeroed. */ 249 RTHCPHYS fZeroed : 1; 247 250 248 251 /** The Page ID. … … 274 277 /** Pointer to a page allocation. */ 275 278 typedef GMMPAGEDESC *PGMMPAGEDESC; 279 280 /** Special NIL value for GMMPAGEDESC::HCPhysGCPhys. */ 281 #define NIL_GMMPAGEDESC_PHYS UINT64_C(0x7fffffffffffffff) 276 282 277 283 /** GMMPAGEDESC::HCPhysGCPhys value that indicates that the page is unsharable. -
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r92162 r92326 889 889 uint32_t iHandyPage = --pVM->pgm.s.cHandyPages; 890 890 AssertMsg(iHandyPage < RT_ELEMENTS(pVM->pgm.s.aHandyPages), ("%d\n", iHandyPage)); 891 Assert(pVM->pgm.s.aHandyPages[iHandyPage].HCPhysGCPhys != NIL_ RTHCPHYS);891 Assert(pVM->pgm.s.aHandyPages[iHandyPage].HCPhysGCPhys != NIL_GMMPAGEDESC_PHYS); 892 892 Assert(!(pVM->pgm.s.aHandyPages[iHandyPage].HCPhysGCPhys & ~X86_PTE_PAE_PG_MASK)); 893 893 Assert(pVM->pgm.s.aHandyPages[iHandyPage].idPage != NIL_GMM_PAGEID); -
trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
r92249 r92326 260 260 uint16_t u16Reserved0; 261 261 /** Reserved. Checksum or something? */ 262 uint32_t u30Reserved1 : 30; 262 uint32_t u30Reserved1 : 29; 263 /** Set if the page was zeroed. */ 264 uint32_t fZeroed : 1; 263 265 /** The page state. */ 264 266 uint32_t u2State : 2; … … 525 527 uint16_t cRegisteredVMs; 526 528 527 /** The number of freed chunks ever. This is used a list generation to 528 * avoid restarting the cleanup scanning when the list wasn't modified. */ 529 uint32_t cFreedChunks; 529 /** The index of the next mutex to use. */ 530 uint32_t iNextChunkMtx; 531 /** Chunk locks for reducing lock contention without having to allocate 532 * one lock per chunk. */ 533 struct 534 { 535 /** The mutex */ 536 RTSEMFASTMUTEX hMtx; 537 /** The number of threads currently using this mutex. */ 538 uint32_t volatile cUsers; 539 } aChunkMtx[64]; 540 541 /** The number of freed chunks ever. This is used as list generation to 542 * avoid restarting the cleanup scanning when the list wasn't modified. */ 543 uint32_t volatile cFreedChunks; 530 544 /** The previous allocated Chunk ID. 531 545 * Used as a hint to avoid scanning the whole bitmap. */ … … 535 549 * The NIL id (0) is marked allocated. */ 536 550 uint32_t bmChunkId[(GMM_CHUNKID_LAST + 1 + 31) / 32]; 537 538 /** The index of the next mutex to use. */539 uint32_t iNextChunkMtx;540 /** Chunk locks for reducing lock contention without having to allocate541 * one lock per chunk. */542 struct543 {544 /** The mutex */545 RTSEMFASTMUTEX hMtx;546 /** The number of threads currently using this mutex. */547 uint32_t volatile cUsers;548 } aChunkMtx[64];549 551 } GMM; 550 552 /** Pointer to the GMM instance. */ … … 1410 1412 */ 1411 1413 pChunk->aPages[iPage].u = 0; 1412 pChunk->aPages[iPage].Free.iNext = pChunk->iFreeHead;1413 1414 pChunk->aPages[iPage].Free.u2State = GMM_PAGE_STATE_FREE; 1415 pChunk->aPages[iPage].Free.fZeroed = false; 1416 pChunk->aPages[iPage].Free.iNext = pChunk->iFreeHead; 1414 1417 pChunk->iFreeHead = iPage; 1415 1418 pChunk->cPrivate--; … … 1996 1999 */ 1997 2000 int32_t idChunk = ++pGMM->idChunkPrev; 1998 #if 0 /** @todo enable this code */ 1999 if ( idChunk <= GMM_CHUNKID_LAST 2001 if ( (uint32_t)idChunk <= GMM_CHUNKID_LAST 2000 2002 && idChunk > NIL_GMM_CHUNKID 2001 && !ASMAtomicBitTestAndSet(&p VMM->bmChunkId[0], idChunk))2003 && !ASMAtomicBitTestAndSet(&pGMM->bmChunkId[0], idChunk)) 2002 2004 return idChunk; 2003 #endif2004 2005 2005 2006 /* … … 2056 2057 pPage, iPage, (pChunk->Core.Key << GMM_CHUNKID_SHIFT) | iPage, 2057 2058 pPage->Common.u2State, pChunk->iFreeHead, pPage->Free.iNext)); 2059 2060 bool const fZeroed = pPage->Free.fZeroed; 2058 2061 2059 2062 /* make the page private. */ … … 2069 2072 2070 2073 /* update the page descriptor. */ 2071 pPageDesc->HCPhysGCPhys = RTR0MemObjGetPagePhysAddr(pChunk->hMemObj, iPage);2072 Assert(pPageDesc->HCPhysGCPhys != NIL_RTHCPHYS);2073 pPageDesc->idPage = (pChunk->Core.Key << GMM_CHUNKID_SHIFT) | iPage;2074 2074 pPageDesc->idSharedPage = NIL_GMM_PAGEID; 2075 pPageDesc->idPage = (pChunk->Core.Key << GMM_CHUNKID_SHIFT) | iPage; 2076 RTHCPHYS const HCPhys = RTR0MemObjGetPagePhysAddr(pChunk->hMemObj, iPage); 2077 Assert(HCPhys != NIL_RTHCPHYS); Assert(HCPhys < NIL_GMMPAGEDESC_PHYS); 2078 pPageDesc->HCPhysGCPhys = HCPhys; 2079 pPageDesc->fZeroed = fZeroed; 2075 2080 } 2076 2081 … … 2166 2171 pChunk->fFlags = fChunkFlags; 2167 2172 pChunk->uidOwner = pSession ? SUPR0GetSessionUid(pSession) : NIL_RTUID; 2173 2168 2174 for (unsigned iPage = 0; iPage < RT_ELEMENTS(pChunk->aPages) - 1; iPage++) 2169 2175 { 2170 2176 pChunk->aPages[iPage].Free.u2State = GMM_PAGE_STATE_FREE; 2171 pChunk->aPages[iPage].Free.iNext = iPage + 1; 2177 pChunk->aPages[iPage].Free.fZeroed = true; 2178 pChunk->aPages[iPage].Free.iNext = iPage + 1; 2172 2179 } 2173 2180 pChunk->aPages[RT_ELEMENTS(pChunk->aPages) - 1].Free.u2State = GMM_PAGE_STATE_FREE; 2181 pChunk->aPages[RT_ELEMENTS(pChunk->aPages) - 1].Free.fZeroed = true; 2174 2182 pChunk->aPages[RT_ELEMENTS(pChunk->aPages) - 1].Free.iNext = UINT16_MAX; 2175 2183 2176 2184 /* 2177 * Allocate a Chunk ID and insert it into the tree. 2178 * This has to be done behind the mutex of course. 2185 * Zero the memory if it wasn't zeroed by the host already. 2186 * This simplifies keeping secret kernel bits from userland and brings 2187 * everyone to the same level wrt allocation zeroing. 2179 2188 */ 2180 rc = gmmR0MutexAcquire(pGMM); 2189 rc = VINF_SUCCESS; 2190 if (!RTR0MemObjWasZeroInitialized(hMemObj)) 2191 { 2192 #ifdef VBOX_WITH_LINEAR_HOST_PHYS_MEM 2193 for (uint32_t iPage = 0; iPage < (GMM_CHUNK_SIZE >> PAGE_SHIFT); iPage++) 2194 { 2195 void *pvPage = NULL; 2196 rc = SUPR0HCPhysToVirt(RTR0MemObjGetPagePhysAddr(hMemObj, iPage), &pvPage); 2197 AssertRC(rc); 2198 if (RT_SUCCESS(rc)) 2199 RT_BZERO(pvPage, PAGE_SIZE); 2200 else 2201 break; 2202 } 2203 #else 2204 RT_BZERO(pbMapping, GMM_CHUNK_SIZE); 2205 #endif 2206 } 2181 2207 if (RT_SUCCESS(rc)) 2182 2208 { 2183 if (GMM_CHECK_SANITY_UPON_ENTERING(pGMM)) 2209 /* 2210 * Allocate a Chunk ID and insert it into the tree. 2211 * This has to be done behind the mutex of course. 2212 */ 2213 rc = gmmR0MutexAcquire(pGMM); 2214 if (RT_SUCCESS(rc)) 2184 2215 { 2185 pChunk->Core.Key = gmmR0AllocateChunkId(pGMM); 2186 if ( pChunk->Core.Key != NIL_GMM_CHUNKID 2187 && pChunk->Core.Key <= GMM_CHUNKID_LAST) 2216 if (GMM_CHECK_SANITY_UPON_ENTERING(pGMM)) 2188 2217 { 2189 RTSpinlockAcquire(pGMM->hSpinLockTree); 2190 if (RTAvlU32Insert(&pGMM->pChunks, &pChunk->Core)) 2218 pChunk->Core.Key = gmmR0AllocateChunkId(pGMM); 2219 if ( pChunk->Core.Key != NIL_GMM_CHUNKID 2220 && pChunk->Core.Key <= GMM_CHUNKID_LAST) 2191 2221 { 2192 pGMM->cChunks++; 2193 RTListAppend(&pGMM->ChunkList, &pChunk->ListNode); 2222 RTSpinlockAcquire(pGMM->hSpinLockTree); 2223 if (RTAvlU32Insert(&pGMM->pChunks, &pChunk->Core)) 2224 { 2225 pGMM->cChunks++; 2226 RTListAppend(&pGMM->ChunkList, &pChunk->ListNode); 2227 RTSpinlockRelease(pGMM->hSpinLockTree); 2228 2229 gmmR0LinkChunk(pChunk, pSet); 2230 2231 LogFlow(("gmmR0RegisterChunk: pChunk=%p id=%#x cChunks=%d\n", pChunk, pChunk->Core.Key, pGMM->cChunks)); 2232 2233 if (ppChunk) 2234 *ppChunk = pChunk; 2235 GMM_CHECK_SANITY_UPON_LEAVING(pGMM); 2236 return VINF_SUCCESS; 2237 } 2194 2238 RTSpinlockRelease(pGMM->hSpinLockTree); 2195 2196 gmmR0LinkChunk(pChunk, pSet);2197 2198 LogFlow(("gmmR0RegisterChunk: pChunk=%p id=%#x cChunks=%d\n", pChunk, pChunk->Core.Key, pGMM->cChunks));2199 2200 if (ppChunk)2201 *ppChunk = pChunk;2202 GMM_CHECK_SANITY_UPON_LEAVING(pGMM);2203 return VINF_SUCCESS;2204 2239 } 2205 RTSpinlockRelease(pGMM->hSpinLockTree); 2240 2241 /* bail out */ 2242 rc = VERR_GMM_CHUNK_INSERT; 2206 2243 } 2207 2208 /* bail out */2209 rc = VERR_GMM_CHUNK_INSERT;2244 else 2245 rc = VERR_GMM_IS_NOT_SANE; 2246 gmmR0MutexRelease(pGMM); 2210 2247 } 2211 else2212 rc = VERR_GMM_IS_NOT_SANE;2213 gmmR0MutexRelease(pGMM);2214 2248 } 2215 2249 … … 2546 2580 * @param enmAccount The account to charge. 2547 2581 * 2548 * @remarks Call takes the giant GMM lock.2582 * @remarks Caller owns the giant GMM lock. 2549 2583 */ 2550 2584 static int gmmR0AllocatePagesNew(PGMM pGMM, PGVM pGVM, uint32_t cPages, PGMMPAGEDESC paPages, GMMACCOUNT enmAccount) … … 2726 2760 paPages[iPage].idPage = NIL_GMM_PAGEID; 2727 2761 paPages[iPage].idSharedPage = NIL_GMM_PAGEID; 2728 paPages[iPage].HCPhysGCPhys = NIL_RTHCPHYS; 2762 paPages[iPage].HCPhysGCPhys = NIL_GMMPAGEDESC_PHYS; 2763 paPages[iPage].fZeroed = false; 2729 2764 } 2730 2765 … … 2794 2829 AssertMsgReturn( ( paPages[iPage].HCPhysGCPhys <= GMM_GCPHYS_LAST 2795 2830 && !(paPages[iPage].HCPhysGCPhys & PAGE_OFFSET_MASK)) 2796 || paPages[iPage].HCPhysGCPhys == NIL_ RTHCPHYS2831 || paPages[iPage].HCPhysGCPhys == NIL_GMMPAGEDESC_PHYS 2797 2832 || paPages[iPage].HCPhysGCPhys == GMM_GCPHYS_UNSHAREABLE, 2798 2833 ("#%#x: %RHp\n", iPage, paPages[iPage].HCPhysGCPhys), 2799 2834 VERR_INVALID_PARAMETER); 2835 /* ignore fZeroed here */ 2800 2836 AssertMsgReturn( paPages[iPage].idPage <= GMM_PAGEID_LAST 2801 2837 /*|| paPages[iPage].idPage == NIL_GMM_PAGEID*/, … … 2808 2844 for (; iPage < cPagesToAlloc; iPage++) 2809 2845 { 2810 AssertMsgReturn(paPages[iPage].HCPhysGCPhys == NIL_RTHCPHYS, ("#%#x: %RHp\n", iPage, paPages[iPage].HCPhysGCPhys), VERR_INVALID_PARAMETER); 2846 AssertMsgReturn(paPages[iPage].HCPhysGCPhys == NIL_GMMPAGEDESC_PHYS, ("#%#x: %RHp\n", iPage, paPages[iPage].HCPhysGCPhys), VERR_INVALID_PARAMETER); 2847 AssertMsgReturn(paPages[iPage].fZeroed == false, ("#%#x: %#x\n", iPage, paPages[iPage].fZeroed), VERR_INVALID_PARAMETER); 2811 2848 AssertMsgReturn(paPages[iPage].idPage == NIL_GMM_PAGEID, ("#%#x: %#x\n", iPage, paPages[iPage].idPage), VERR_INVALID_PARAMETER); 2812 2849 AssertMsgReturn(paPages[iPage].idSharedPage == NIL_GMM_PAGEID, ("#%#x: %#x\n", iPage, paPages[iPage].idSharedPage), VERR_INVALID_PARAMETER); … … 2844 2881 2845 2882 paPages[iPage].idPage = NIL_GMM_PAGEID; 2846 paPages[iPage].HCPhysGCPhys = NIL_RTHCPHYS; 2883 paPages[iPage].HCPhysGCPhys = NIL_GMMPAGEDESC_PHYS; 2884 paPages[iPage].fZeroed = false; 2847 2885 } 2848 2886 else … … 2914 2952 if (RT_SUCCESS(rc) && cPagesToAlloc > 0) 2915 2953 { 2916 #if defined(VBOX_STRICT) && 0 /** @todo re-test this later. Appeared to be a PGM init bug. */2954 #ifdef VBOX_STRICT 2917 2955 for (iPage = 0; iPage < cPagesToAlloc; iPage++) 2918 2956 { 2919 Assert(paPages[iPage].HCPhysGCPhys == NIL_RTHCPHYS); 2957 Assert(paPages[iPage].HCPhysGCPhys == NIL_GMMPAGEDESC_PHYS); 2958 Assert(paPages[iPage].fZeroed == false); 2920 2959 Assert(paPages[iPage].idPage == NIL_GMM_PAGEID); 2921 2960 Assert(paPages[iPage].idSharedPage == NIL_GMM_PAGEID); … … 2984 3023 for (unsigned iPage = 0; iPage < cPages; iPage++) 2985 3024 { 2986 AssertMsgReturn( paPages[iPage].HCPhysGCPhys == NIL_ RTHCPHYS3025 AssertMsgReturn( paPages[iPage].HCPhysGCPhys == NIL_GMMPAGEDESC_PHYS 2987 3026 || paPages[iPage].HCPhysGCPhys == GMM_GCPHYS_UNSHAREABLE 2988 3027 || ( enmAccount == GMMACCOUNT_BASE … … 2991 3030 ("#%#x: %RHp enmAccount=%d\n", iPage, paPages[iPage].HCPhysGCPhys, enmAccount), 2992 3031 VERR_INVALID_PARAMETER); 2993 AssertMsgReturn(paPages[iPage].idPage == NIL_GMM_PAGEID, ("#%#x: %#x\n", iPage, paPages[iPage].idPage), VERR_INVALID_PARAMETER); 3032 AssertMsgReturn(paPages[iPage].fZeroed == false, ("#%#x: %#x\n", iPage, paPages[iPage].fZeroed), VERR_INVALID_PARAMETER); 3033 AssertMsgReturn(paPages[iPage].idPage == NIL_GMM_PAGEID, ("#%#x: %#x\n", iPage, paPages[iPage].idPage), VERR_INVALID_PARAMETER); 2994 3034 AssertMsgReturn(paPages[iPage].idSharedPage == NIL_GMM_PAGEID, ("#%#x: %#x\n", iPage, paPages[iPage].idSharedPage), VERR_INVALID_PARAMETER); 2995 3035 } 2996 3036 3037 /* 3038 * Grab the giant mutex and get working. 3039 */ 2997 3040 gmmR0MutexAcquire(pGMM); 2998 3041 if (GMM_CHECK_SANITY_UPON_ENTERING(pGMM)) … … 3011 3054 rc = VERR_GMM_IS_NOT_SANE; 3012 3055 gmmR0MutexRelease(pGMM); 3056 3013 3057 LogFlow(("GMMR0AllocatePages: returns %Rrc\n", rc)); 3014 3058 return rc; … … 3044 3088 * Allocate a large page to represent guest RAM 3045 3089 * 3046 * The allocated pages are not cleared and will contains random garbage.3090 * The allocated pages are zeroed upon return. 3047 3091 * 3048 3092 * @returns VBox status code: … … 3137 3181 gmmR0LinkChunk(pChunk, pSet); 3138 3182 gmmR0MutexRelease(pGMM); 3183 3139 3184 LogFlow(("GMMR0AllocateLargePage: returns VINF_SUCCESS\n")); 3140 3185 return VINF_SUCCESS; … … 3420 3465 pPage->u = 0; 3421 3466 pPage->Free.u2State = GMM_PAGE_STATE_FREE; 3467 pPage->Free.fZeroed = false; 3422 3468 Assert(pChunk->iFreeHead < RT_ELEMENTS(pChunk->aPages) || pChunk->iFreeHead == UINT16_MAX); 3423 3469 pPage->Free.iNext = pChunk->iFreeHead; … … 3458 3504 else 3459 3505 gmmR0FreeChunk(pGMM, NULL, pChunk, false); 3460 3461 3506 } 3462 3507 -
trunk/src/VBox/VMM/VMMR0/PGMR0.cpp
r92248 r92326 170 170 Assert(pGVM->pgm.s.aHandyPages[i].idPage <= GMM_PAGEID_LAST); 171 171 Assert(pGVM->pgm.s.aHandyPages[i].idSharedPage == NIL_GMM_PAGEID); 172 Assert(pGVM->pgm.s.aHandyPages[i].HCPhysGCPhys != NIL_ RTHCPHYS);172 Assert(pGVM->pgm.s.aHandyPages[i].HCPhysGCPhys != NIL_GMMPAGEDESC_PHYS); 173 173 Assert(!(pGVM->pgm.s.aHandyPages[i].HCPhysGCPhys & ~X86_PTE_PAE_PG_MASK)); 174 174 } … … 189 189 for (i = iFirst; i < RT_ELEMENTS(pGVM->pgm.s.aHandyPages); i++) 190 190 { 191 Assert(pGVM->pgm.s.aHandyPages[i].idPage == NIL_GMM_PAGEID);191 Assert(pGVM->pgm.s.aHandyPages[i].idPage == NIL_GMM_PAGEID); 192 192 Assert(pGVM->pgm.s.aHandyPages[i].idSharedPage == NIL_GMM_PAGEID); 193 Assert(pGVM->pgm.s.aHandyPages[i].HCPhysGCPhys == NIL_RTHCPHYS); 193 Assert(pGVM->pgm.s.aHandyPages[i].HCPhysGCPhys == NIL_GMMPAGEDESC_PHYS); 194 Assert(pGVM->pgm.s.aHandyPages[i].fZeroed == false); 194 195 } 195 196 #endif … … 216 217 Assert(pGVM->pgm.s.aHandyPages[i].idPage <= GMM_PAGEID_LAST); 217 218 Assert(pGVM->pgm.s.aHandyPages[i].idSharedPage == NIL_GMM_PAGEID); 218 Assert(pGVM->pgm.s.aHandyPages[i].HCPhysGCPhys != NIL_ RTHCPHYS);219 Assert(pGVM->pgm.s.aHandyPages[i].HCPhysGCPhys != NIL_GMMPAGEDESC_PHYS); 219 220 Assert(!(pGVM->pgm.s.aHandyPages[i].HCPhysGCPhys & ~X86_PTE_PAE_PG_MASK)); 220 221 } … … 222 223 for (i = cPages + iFirst; i < RT_ELEMENTS(pGVM->pgm.s.aHandyPages); i++) 223 224 { 224 Assert(pGVM->pgm.s.aHandyPages[i].idPage == NIL_GMM_PAGEID);225 Assert(pGVM->pgm.s.aHandyPages[i].idPage == NIL_GMM_PAGEID); 225 226 Assert(pGVM->pgm.s.aHandyPages[i].idSharedPage == NIL_GMM_PAGEID); 226 Assert(pGVM->pgm.s.aHandyPages[i].HCPhysGCPhys == NIL_RTHCPHYS); 227 Assert(pGVM->pgm.s.aHandyPages[i].HCPhysGCPhys == NIL_GMMPAGEDESC_PHYS); 228 Assert(pGVM->pgm.s.aHandyPages[i].fZeroed == false); 227 229 } 228 230 #endif … … 311 313 * Do the job. 312 314 */ 313 int rc = GMMR0AllocateLargePage(pGVM, idCpu, _2M, 314 &pGVM->pgm.s.aLargeHandyPage[0].idPage, 315 &pGVM->pgm.s.aLargeHandyPage[0].HCPhysGCPhys); 315 RTHCPHYS HCPhys = NIL_GMMPAGEDESC_PHYS; 316 int rc = GMMR0AllocateLargePage(pGVM, idCpu, _2M, &pGVM->pgm.s.aLargeHandyPage[0].idPage, &HCPhys); 316 317 if (RT_SUCCESS(rc)) 317 318 pGVM->pgm.s.cLargeHandyPages = 1; 319 pGVM->pgm.s.aLargeHandyPage[0].HCPhysGCPhys = HCPhys; 320 pGVM->pgm.s.aLargeHandyPage[0].fZeroed = true; 318 321 319 322 return rc; -
trunk/src/VBox/VMM/VMMR3/GMM.cpp
r92248 r92326 109 109 #ifdef LOG_ENABLED 110 110 for (uint32_t iPage = 0; iPage < pReq->cPages; iPage++) 111 Log3(("GMMR3AllocatePagesPerform: idPage=%#x HCPhys=%RHp \n",112 pReq->aPages[iPage].idPage, pReq->aPages[iPage].HCPhysGCPhys ));111 Log3(("GMMR3AllocatePagesPerform: idPage=%#x HCPhys=%RHp fZeroed=%d\n", 112 pReq->aPages[iPage].idPage, pReq->aPages[iPage].HCPhysGCPhys, pReq->aPages[iPage].fZeroed)); 113 113 #endif 114 114 return rc; -
trunk/src/VBox/VMM/VMMR3/PGM.cpp
r92248 r92326 755 755 for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.aHandyPages); i++) 756 756 { 757 pVM->pgm.s.aHandyPages[i].HCPhysGCPhys = NIL_RTHCPHYS; 757 pVM->pgm.s.aHandyPages[i].HCPhysGCPhys = NIL_GMMPAGEDESC_PHYS; 758 pVM->pgm.s.aHandyPages[i].fZeroed = false; 758 759 pVM->pgm.s.aHandyPages[i].idPage = NIL_GMM_PAGEID; 759 760 pVM->pgm.s.aHandyPages[i].idSharedPage = NIL_GMM_PAGEID; … … 762 763 for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.aLargeHandyPage); i++) 763 764 { 764 pVM->pgm.s.aLargeHandyPage[i].HCPhysGCPhys = NIL_RTHCPHYS; 765 pVM->pgm.s.aLargeHandyPage[i].HCPhysGCPhys = NIL_GMMPAGEDESC_PHYS; 766 pVM->pgm.s.aLargeHandyPage[i].fZeroed = false; 765 767 pVM->pgm.s.aLargeHandyPage[i].idPage = NIL_GMM_PAGEID; 766 768 pVM->pgm.s.aLargeHandyPage[i].idSharedPage = NIL_GMM_PAGEID; -
trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp
r92248 r92326 4403 4403 { 4404 4404 pReq->aPages[iPage].HCPhysGCPhys = GCPhys + (iPage << PAGE_SHIFT); 4405 pReq->aPages[iPage].idPage = NIL_GMM_PAGEID; 4405 pReq->aPages[iPage].fZeroed = false; 4406 pReq->aPages[iPage].idPage = NIL_GMM_PAGEID; 4406 4407 pReq->aPages[iPage].idSharedPage = NIL_GMM_PAGEID; 4407 4408 } … … 5840 5841 uint32_t idPage = pVM->pgm.s.aLargeHandyPage[0].idPage; 5841 5842 RTHCPHYS HCPhys = pVM->pgm.s.aLargeHandyPage[0].HCPhysGCPhys; 5842 5843 void *pv; 5844 5845 /* Map the large page into our address space. 5846 * 5847 * Note: assuming that within the 2 MB range: 5848 * - GCPhys + PAGE_SIZE = HCPhys + PAGE_SIZE (whole point of this exercise) 5849 * - user space mapping is continuous as well 5850 * - page id (GCPhys) + 1 = page id (GCPhys + PAGE_SIZE) 5843 Assert(pVM->pgm.s.aLargeHandyPage[0].fZeroed); 5844 5845 /* 5846 * Enter the pages into PGM. 5851 5847 */ 5852 rc = pgmPhysPageMapByPageID(pVM, idPage, HCPhys, &pv); 5853 AssertLogRelMsg(RT_SUCCESS(rc), ("idPage=%#x HCPhysGCPhys=%RHp rc=%Rrc\n", idPage, HCPhys, rc)); 5854 5855 if (RT_SUCCESS(rc)) 5856 { 5848 STAM_PROFILE_START(&pVM->pgm.s.Stats.StatClearLargePage, b); 5849 for (unsigned i = 0; i < _2M/PAGE_SIZE; i++) 5850 { 5851 PPGMPAGE pPage; 5852 rc = pgmPhysGetPageEx(pVM, GCPhys, &pPage); 5853 AssertRC(rc); 5854 5855 Assert(PGM_PAGE_IS_ZERO(pPage)); 5856 STAM_COUNTER_INC(&pVM->pgm.s.Stats.StatRZPageReplaceZero); 5857 pVM->pgm.s.cZeroPages--; 5858 5857 5859 /* 5858 * Clear the pages.5860 * Do the PGMPAGE modifications. 5859 5861 */ 5860 STAM_PROFILE_START(&pVM->pgm.s.Stats.StatClearLargePage, b); 5861 for (unsigned i = 0; i < _2M/PAGE_SIZE; i++) 5862 { 5863 ASMMemZeroPage(pv); 5864 5865 PPGMPAGE pPage; 5866 rc = pgmPhysGetPageEx(pVM, GCPhys, &pPage); 5867 AssertRC(rc); 5868 5869 Assert(PGM_PAGE_IS_ZERO(pPage)); 5870 STAM_COUNTER_INC(&pVM->pgm.s.Stats.StatRZPageReplaceZero); 5871 pVM->pgm.s.cZeroPages--; 5872 5873 /* 5874 * Do the PGMPAGE modifications. 5875 */ 5876 pVM->pgm.s.cPrivatePages++; 5877 PGM_PAGE_SET_HCPHYS(pVM, pPage, HCPhys); 5878 PGM_PAGE_SET_PAGEID(pVM, pPage, idPage); 5879 PGM_PAGE_SET_STATE(pVM, pPage, PGM_PAGE_STATE_ALLOCATED); 5880 PGM_PAGE_SET_PDE_TYPE(pVM, pPage, PGM_PAGE_PDE_TYPE_PDE); 5881 PGM_PAGE_SET_PTE_INDEX(pVM, pPage, 0); 5882 PGM_PAGE_SET_TRACKING(pVM, pPage, 0); 5883 5884 /* Somewhat dirty assumption that page ids are increasing. */ 5885 idPage++; 5886 5887 HCPhys += PAGE_SIZE; 5888 GCPhys += PAGE_SIZE; 5889 5890 pv = (void *)((uintptr_t)pv + PAGE_SIZE); 5891 5892 Log3(("PGMR3PhysAllocateLargePage: idPage=%#x HCPhys=%RGp\n", idPage, HCPhys)); 5893 } 5894 STAM_PROFILE_STOP(&pVM->pgm.s.Stats.StatClearLargePage, b); 5895 5896 /* Flush all TLBs. */ 5897 PGM_INVL_ALL_VCPU_TLBS(pVM); 5898 pgmPhysInvalidatePageMapTLB(pVM); 5899 } 5862 pVM->pgm.s.cPrivatePages++; 5863 PGM_PAGE_SET_HCPHYS(pVM, pPage, HCPhys); 5864 PGM_PAGE_SET_PAGEID(pVM, pPage, idPage); 5865 PGM_PAGE_SET_STATE(pVM, pPage, PGM_PAGE_STATE_ALLOCATED); 5866 PGM_PAGE_SET_PDE_TYPE(pVM, pPage, PGM_PAGE_PDE_TYPE_PDE); 5867 PGM_PAGE_SET_PTE_INDEX(pVM, pPage, 0); 5868 PGM_PAGE_SET_TRACKING(pVM, pPage, 0); 5869 5870 /* Somewhat dirty assumption that page ids are increasing. */ 5871 idPage++; 5872 5873 HCPhys += PAGE_SIZE; 5874 GCPhys += PAGE_SIZE; 5875 Log3(("PGMR3PhysAllocateLargePage: idPage=%#x HCPhys=%RGp\n", idPage, HCPhys)); 5876 } 5877 STAM_PROFILE_STOP(&pVM->pgm.s.Stats.StatClearLargePage, b); 5878 5879 /* Flush all TLBs. */ 5880 PGM_INVL_ALL_VCPU_TLBS(pVM); 5881 pgmPhysInvalidatePageMapTLB(pVM); 5882 5900 5883 pVM->pgm.s.cLargeHandyPages = 0; 5901 5884 } … … 6003 5986 { 6004 5987 PGMMPAGEDESC pPage = &pVM->pgm.s.aHandyPages[iClear]; 6005 void *pv; 6006 rc = pgmPhysPageMapByPageID(pVM, pPage->idPage, pPage->HCPhysGCPhys, &pv); 6007 AssertLogRelMsgBreak(RT_SUCCESS(rc), 6008 ("%u/%u: idPage=%#x HCPhysGCPhys=%RHp rc=%Rrc\n", 6009 iClear, pVM->pgm.s.cHandyPages, pPage->idPage, pPage->HCPhysGCPhys, rc)); 6010 ASMMemZeroPage(pv); 5988 if (!pPage->fZeroed) 5989 { 5990 void *pv; 5991 rc = pgmPhysPageMapByPageID(pVM, pPage->idPage, pPage->HCPhysGCPhys, &pv); 5992 AssertLogRelMsgBreak(RT_SUCCESS(rc), 5993 ("%u/%u: idPage=%#x HCPhysGCPhys=%RHp rc=%Rrc\n", 5994 iClear, pVM->pgm.s.cHandyPages, pPage->idPage, pPage->HCPhysGCPhys, rc)); 5995 ASMMemZeroPage(pv); 5996 pPage->fZeroed = true; 5997 } 5998 #ifdef VBOX_STRICT 5999 else 6000 { 6001 void *pv; 6002 rc = pgmPhysPageMapByPageID(pVM, pPage->idPage, pPage->HCPhysGCPhys, &pv); 6003 AssertLogRelMsgBreak(RT_SUCCESS(rc), 6004 ("%u/%u: idPage=%#x HCPhysGCPhys=%RHp rc=%Rrc\n", 6005 iClear, pVM->pgm.s.cHandyPages, pPage->idPage, pPage->HCPhysGCPhys, rc)); 6006 Assert(ASMMemIsZeroPage(pv)); 6007 } 6008 #endif 6011 6009 iClear++; 6012 6010 Log3(("PGMR3PhysAllocateHandyPages: idPage=%#x HCPhys=%RGp\n", pPage->idPage, pPage->HCPhysGCPhys));
Note:
See TracChangeset
for help on using the changeset viewer.