Changeset 17371 in vbox for trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
- Timestamp:
- Mar 5, 2009 1:37:58 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
r14299 r17371 196 196 struct GMMPAGECOMMON 197 197 { 198 uint32_t uStuff1 : 32;199 uint32_t uStuff2 : 20;198 uint32_t uStuff1 : 32; 199 uint32_t uStuff2 : 30; 200 200 /** The page state. */ 201 201 uint32_t u2State : 2; … … 346 346 #endif 347 347 348 /** @def GMM_GCPHYS_ END349 * The endof the valid guest physical address as it applies to GMM pages.348 /** @def GMM_GCPHYS_LAST 349 * The last of the valid guest physical address as it applies to GMM pages. 350 350 * 351 351 * This must reflect the constraints imposed by the RTGCPHYS type and 352 352 * the guest page frame number used internally in GMMPAGE. */ 353 #define GMM_GCPHYS_END UINT32_C(0xfffff000) 353 #if 1 354 # define GMM_GCPHYS_LAST UINT32_C(0xfffff000) /* 2^32 (4GB) - 0x1000 */ 355 #else /** @todo enable this after changing NIL_RTHCPHYS to ~(RTHCPHYS)0! */ 356 #if HC_ARCH_BITS == 64 357 # define GMM_GCPHYS_LAST UINT64_C(0x00000fffffff0000) /* 2^44 (16TB) - 0x10000 */ 358 #else 359 # define GMM_GCPHYS_LAST UINT64_C(0x0000000fffff0000) /* 2^36 (64GB) - 0x10000 */ 360 #endif 361 #endif 354 362 355 363 … … 603 611 * Check and see if RTR0MemObjAllocPhysNC works. 604 612 */ 605 #if 0 /* later */613 #if 0 /* later, see #3170. */ 606 614 RTR0MEMOBJ MemObj; 607 615 rc = RTR0MemObjAllocPhysNC(&MemObj, _64K, NIL_RTHCPHYS); … … 618 626 pGMM->fLegacyMode = true; 619 627 #endif 628 629 /* 630 * Query system page count and guess a reasonable cMaxPages value. 631 */ 632 pGMM->cMaxPages = UINT32_MAX; /** @todo IPRT function for query ram size and such. */ 620 633 621 634 g_pGMM = pGMM; … … 1314 1327 if (pChunk->cFree > 0) 1315 1328 { 1329 pChunk->pSet = pSet; 1316 1330 pChunk->pFreePrev = NULL; 1317 1331 unsigned iList = (pChunk->cFree - 1) >> GMM_CHUNK_FREE_SET_SHIFT; … … 1426 1440 pGMM->cChunks++; 1427 1441 gmmR0LinkChunk(pChunk, pSet); 1442 LogFlow(("gmmR0RegisterChunk: pChunk=%p id=%#x cChunks=%d\n", pChunk, pChunk->Core.Key, pGMM->cChunks)); 1428 1443 return VINF_SUCCESS; 1429 1444 } … … 1527 1542 AssertReleaseMsg(iPage < RT_ELEMENTS(pChunk->aPages), ("%d\n", iPage)); 1528 1543 PGMMPAGE pPage = &pChunk->aPages[iPage]; 1544 Log3(("pPage=%x iPage=%#x iFreeHead=%#x iNext=%#x u2State=%d\n", pPage, iPage, pChunk->iFreeHead, pPage->Free.iNext, pPage->Common.u2State)); 1529 1545 Assert(GMM_PAGE_IS_FREE(pPage)); 1530 1546 pChunk->iFreeHead = pPage->Free.iNext; … … 1534 1550 AssertCompile(GMM_PAGE_STATE_PRIVATE == 0); 1535 1551 pPage->Private.hGVM = hGVM; 1536 AssertCompile(NIL_RTHCPHYS >= GMM_GCPHYS_ END);1537 AssertCompile(GMM_GCPHYS_UNSHAREABLE >= GMM_GCPHYS_ END);1538 if (pPageDesc->HCPhysGCPhys < GMM_GCPHYS_END)1552 AssertCompile(NIL_RTHCPHYS >= GMM_GCPHYS_LAST); 1553 AssertCompile(GMM_GCPHYS_UNSHAREABLE >= GMM_GCPHYS_LAST); 1554 if (pPageDesc->HCPhysGCPhys <= GMM_GCPHYS_LAST) 1539 1555 pPage->Private.pfn = pPageDesc->HCPhysGCPhys >> PAGE_SHIFT; 1540 1556 else … … 1645 1661 1646 1662 if ( pCur->hGVM == hGVM 1647 && ( pCur->cFree < GMM_CHUNK_NUM_PAGES1663 && ( pCur->cFree <= GMM_CHUNK_NUM_PAGES 1648 1664 || pGMM->fLegacyMode)) 1649 1665 { … … 1680 1696 switch (enmAccount) 1681 1697 { 1682 case GMMACCOUNT_BASE: pGVM->gmm.s.Allocated.cBasePages += iPage; 1683 case GMMACCOUNT_SHADOW: pGVM->gmm.s.Allocated.cShadowPages += iPage; 1684 case GMMACCOUNT_FIXED: pGVM->gmm.s.Allocated.cFixedPages += iPage; 1698 case GMMACCOUNT_BASE: pGVM->gmm.s.Allocated.cBasePages += iPage; break; 1699 case GMMACCOUNT_SHADOW: pGVM->gmm.s.Allocated.cShadowPages += iPage; break; 1700 case GMMACCOUNT_FIXED: pGVM->gmm.s.Allocated.cFixedPages += iPage; break; 1685 1701 default: 1686 1702 AssertMsgFailedReturn(("enmAccount=%d\n", enmAccount), VERR_INTERNAL_ERROR); … … 1741 1757 for (; iPage < cPagesToUpdate; iPage++) 1742 1758 { 1743 AssertMsgReturn( ( paPages[iPage].HCPhysGCPhys < GMM_GCPHYS_END1759 AssertMsgReturn( ( paPages[iPage].HCPhysGCPhys <= GMM_GCPHYS_LAST 1744 1760 && !(paPages[iPage].HCPhysGCPhys & PAGE_OFFSET_MASK)) 1745 1761 || paPages[iPage].HCPhysGCPhys == NIL_RTHCPHYS … … 1785 1801 if (RT_LIKELY(pPage->Private.hGVM == pGVM->hSelf)) 1786 1802 { 1787 AssertCompile(NIL_RTHCPHYS > GMM_GCPHYS_ END && GMM_GCPHYS_UNSHAREABLE > GMM_GCPHYS_END);1788 if (RT_LIKELY(paPages[iPage].HCPhysGCPhys < GMM_GCPHYS_END))1803 AssertCompile(NIL_RTHCPHYS > GMM_GCPHYS_LAST && GMM_GCPHYS_UNSHAREABLE > GMM_GCPHYS_LAST); 1804 if (RT_LIKELY(paPages[iPage].HCPhysGCPhys <= GMM_GCPHYS_LAST)) 1789 1805 pPage->Private.pfn = paPages[iPage].HCPhysGCPhys >> PAGE_SHIFT; 1790 1806 else if (paPages[iPage].HCPhysGCPhys == GMM_GCPHYS_UNSHAREABLE) … … 1825 1841 if (RT_LIKELY(GMM_PAGE_IS_SHARED(pPage))) 1826 1842 { 1827 AssertCompile(NIL_RTHCPHYS > GMM_GCPHYS_ END && GMM_GCPHYS_UNSHAREABLE > GMM_GCPHYS_END);1843 AssertCompile(NIL_RTHCPHYS > GMM_GCPHYS_LAST && GMM_GCPHYS_UNSHAREABLE > GMM_GCPHYS_LAST); 1828 1844 Assert(pPage->Shared.cRefs); 1829 1845 Assert(pGVM->gmm.s.cSharedPages); … … 1908 1924 || paPages[iPage].HCPhysGCPhys == GMM_GCPHYS_UNSHAREABLE 1909 1925 || ( enmAccount == GMMACCOUNT_BASE 1910 && paPages[iPage].HCPhysGCPhys < GMM_GCPHYS_END1926 && paPages[iPage].HCPhysGCPhys <= GMM_GCPHYS_LAST 1911 1927 && !(paPages[iPage].HCPhysGCPhys & PAGE_OFFSET_MASK)), 1912 1928 ("#%#x: %RHp enmAccount=%d\n", iPage, paPages[iPage].HCPhysGCPhys, enmAccount), … … 1928 1944 1929 1945 RTSemFastMutexRelease(pGMM->Mtx); 1930 LogFlow(("GMMR0 UpdateReservation: returns %Rrc\n", rc));1946 LogFlow(("GMMR0AllocatePages: returns %Rrc\n", rc)); 1931 1947 return rc; 1932 1948 } … … 2517 2533 static int gmmR0UnmapChunk(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk) 2518 2534 { 2519 /* 2520 * Find the mapping and try unmapping it. 2521 */ 2522 for (uint32_t i = 0; i < pChunk->cMappings; i++) 2523 { 2524 Assert(pChunk->paMappings[i].pGVM && pChunk->paMappings[i].MapObj != NIL_RTR0MEMOBJ); 2525 if (pChunk->paMappings[i].pGVM == pGVM) 2535 if (!pGMM->fLegacyMode) 2536 { 2537 /* 2538 * Find the mapping and try unmapping it. 2539 */ 2540 for (uint32_t i = 0; i < pChunk->cMappings; i++) 2526 2541 { 2527 /* unmap */ 2528 int rc = RTR0MemObjFree(pChunk->paMappings[i].MapObj, false /* fFreeMappings (NA) */); 2529 if (RT_SUCCESS(rc)) 2542 Assert(pChunk->paMappings[i].pGVM && pChunk->paMappings[i].MapObj != NIL_RTR0MEMOBJ); 2543 if (pChunk->paMappings[i].pGVM == pGVM) 2530 2544 { 2531 /* update the record. */ 2532 pChunk->cMappings--; 2533 if (i < pChunk->cMappings) 2534 pChunk->paMappings[i] = pChunk->paMappings[pChunk->cMappings]; 2535 pChunk->paMappings[pChunk->cMappings].MapObj = NIL_RTR0MEMOBJ; 2536 pChunk->paMappings[pChunk->cMappings].pGVM = NULL; 2545 /* unmap */ 2546 int rc = RTR0MemObjFree(pChunk->paMappings[i].MapObj, false /* fFreeMappings (NA) */); 2547 if (RT_SUCCESS(rc)) 2548 { 2549 /* update the record. */ 2550 pChunk->cMappings--; 2551 if (i < pChunk->cMappings) 2552 pChunk->paMappings[i] = pChunk->paMappings[pChunk->cMappings]; 2553 pChunk->paMappings[pChunk->cMappings].MapObj = NIL_RTR0MEMOBJ; 2554 pChunk->paMappings[pChunk->cMappings].pGVM = NULL; 2555 } 2556 return rc; 2537 2557 } 2538 return rc;2539 2558 } 2540 2559 } 2560 else if (pChunk->hGVM == pGVM->hSelf) 2561 return VINF_SUCCESS; 2541 2562 2542 2563 Log(("gmmR0MapChunk: Chunk %#x is not mapped into pGVM=%p/%#x\n", pChunk->Core.Key, pGVM, pGVM->hSelf)); … … 2558 2579 static int gmmR0MapChunk(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk, PRTR3PTR ppvR3) 2559 2580 { 2581 /* 2582 * If we're in legacy mode this is simple. 2583 */ 2584 if (pGMM->fLegacyMode) 2585 { 2586 if (pChunk->hGVM != pGVM->hSelf) 2587 { 2588 Log(("gmmR0MapChunk: chunk %#x is already mapped at %p!\n", pChunk->Core.Key, *ppvR3)); 2589 return VERR_GMM_CHUNK_NOT_FOUND; 2590 } 2591 2592 *ppvR3 = RTR0MemObjAddressR3(pChunk->MemObj); 2593 return VINF_SUCCESS; 2594 } 2595 2560 2596 /* 2561 2597 * Check to see if the chunk is already mapped. … … 2649 2685 } 2650 2686 2651 if (pGMM->fLegacyMode)2652 {2653 Log(("GMMR0MapUnmapChunk: legacy mode!\n"));2654 return VERR_NOT_SUPPORTED;2655 }2656 2657 2687 /* 2658 2688 * Take the semaphore and do the work. … … 2775 2805 } 2776 2806 2807 LogFlow(("GMMR0SeedChunk: rc=%d (pvR3=%p)\n", rc, pvR3)); 2777 2808 return rc; 2778 2809 }
Note:
See TracChangeset
for help on using the changeset viewer.