Lines Matching defs:pChunk

460     PGMMCHUNK           pChunk;
735 static bool gmmR0CleanupVMScanChunk(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk);
736 DECLINLINE(void) gmmR0UnlinkChunk(PGMMCHUNK pChunk);
737 DECLINLINE(void) gmmR0LinkChunk(PGMMCHUNK pChunk, PGMMCHUNKFREESET pSet);
738 DECLINLINE(void) gmmR0SelectSetAndLinkChunk(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk);
742 static bool gmmR0FreeChunk(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk, bool fRelaxedSem);
745 static int gmmR0UnmapChunkLocked(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk);
914 PGMMCHUNK pChunk = (PGMMCHUNK)pNode;
916 if (pChunk->cFree != (GMM_CHUNK_SIZE >> PAGE_SHIFT))
917 SUPR0Printf("GMMR0Term: %p/%#x: cFree=%d cPrivate=%d cShared=%d cMappings=%d\n", pChunk,
918 pChunk->Core.Key, pChunk->cFree, pChunk->cPrivate, pChunk->cShared, pChunk->cMappingsX);
920 int rc = RTR0MemObjFree(pChunk->hMemObj, true /* fFreeMappings */);
923 SUPR0Printf("GMMR0Term: %p/%#x: RTRMemObjFree(%p,true) -> %d (cMappings=%d)\n", pChunk,
924 pChunk->Core.Key, pChunk->hMemObj, rc, pChunk->cMappingsX);
927 pChunk->hMemObj = NIL_RTR0MEMOBJ;
929 RTMemFree(pChunk->paMappingsX);
930 pChunk->paMappingsX = NULL;
932 RTMemFree(pChunk);
1067 * @param pChunk Pointer to the chunk.
1070 static int gmmR0ChunkMutexAcquire(PGMMR0CHUNKMTXSTATE pMtxState, PGMM pGMM, PGMMCHUNK pChunk, uint32_t fFlags)
1082 uint32_t iChunkMtx = pChunk->iChunkMtx;
1105 pChunk->iChunkMtx = iChunkMtx;
1135 * @param pChunk Pointer to the chunk if it's still
1141 static int gmmR0ChunkMutexRelease(PGMMR0CHUNKMTXSTATE pMtxState, PGMMCHUNK pChunk)
1160 && pChunk
1164 pChunk->iChunkMtx = UINT8_MAX;
1171 pChunk->iChunkMtx = UINT8_MAX;
1270 PGMMCHUNK pChunk;
1274 RTListForEachReverse(&pGMM->ChunkList, pChunk, GMMCHUNK, ListNode)
1278 || pChunk->hGVM == pGVM->hSelf)
1279 && gmmR0CleanupVMScanChunk(pGMM, pGVM, pChunk))
1314 pChunk = pPrivateSet->apLists[GMM_CHUNK_FREE_SET_UNUSED_LIST];
1315 while (pChunk)
1317 PGMMCHUNK pNext = pChunk->pFreeNext;
1318 Assert(pChunk->cFree == GMM_CHUNK_NUM_PAGES);
1320 || pChunk->hGVM == pGVM->hSelf)
1323 if (gmmR0FreeChunk(pGMM, pGVM, pChunk, true /*fRelaxedSem*/))
1335 pChunk = pNext;
1401 * @param pChunk The chunk to scan.
1403 static bool gmmR0CleanupVMScanChunk(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk)
1405 Assert(!pGMM->fBoundMemoryMode || pChunk->hGVM == pGVM->hSelf);
1412 if (pChunk->cFree != (GMM_CHUNK_SIZE >> PAGE_SHIFT))
1419 gmmR0UnlinkChunk(pChunk); /* avoiding cFreePages updates. */
1424 if (GMM_PAGE_IS_PRIVATE(&pChunk->aPages[iPage]))
1426 if (pChunk->aPages[iPage].Private.hGVM == hGVM)
1435 pChunk->aPages[iPage].u = 0;
1436 pChunk->aPages[iPage].Free.iNext = pChunk->iFreeHead;
1437 pChunk->aPages[iPage].Free.u2State = GMM_PAGE_STATE_FREE;
1438 pChunk->iFreeHead = iPage;
1439 pChunk->cPrivate--;
1440 pChunk->cFree++;
1447 else if (GMM_PAGE_IS_FREE(&pChunk->aPages[iPage]))
1452 gmmR0SelectSetAndLinkChunk(pGMM, pGVM, pChunk);
1457 if (RT_UNLIKELY( pChunk->cFree != cFree
1458 || pChunk->cPrivate != cPrivate
1459 || pChunk->cShared != cShared))
1462 pChunk->cFree, cFree, pChunk->cPrivate, cPrivate, pChunk->cShared, cShared);
1463 pChunk->cFree = cFree;
1464 pChunk->cPrivate = cPrivate;
1465 pChunk->cShared = cShared;
1473 if (pChunk->hGVM == pGVM->hSelf)
1476 pChunk->hGVM = NIL_GVM_HANDLE;
1477 else if (pChunk->cFree != GMM_CHUNK_NUM_PAGES)
1480 pChunk, pChunk->Core.Key, pChunk->cFree);
1481 AssertMsgFailed(("%p/%#x: cFree=%#x - it should be 0 in bound mode!\n", pChunk, pChunk->Core.Key, pChunk->cFree));
1483 gmmR0UnlinkChunk(pChunk);
1484 pChunk->cFree = GMM_CHUNK_NUM_PAGES;
1485 gmmR0SelectSetAndLinkChunk(pGMM, pGVM, pChunk);
1493 gmmR0ChunkMutexAcquire(&MtxState, pGMM, pChunk, GMMR0CHUNK_MTX_KEEP_GIANT);
1494 unsigned cMappings = pChunk->cMappingsX;
1496 if (pChunk->paMappingsX[i].pGVM == pGVM)
1500 RTR0MEMOBJ hMemObj = pChunk->paMappingsX[i].hMapObj;
1504 pChunk->paMappingsX[i] = pChunk->paMappingsX[cMappings];
1505 pChunk->paMappingsX[cMappings].pGVM = NULL;
1506 pChunk->paMappingsX[cMappings].hMapObj = NIL_RTR0MEMOBJ;
1507 Assert(pChunk->cMappingsX - 1U == cMappings);
1508 pChunk->cMappingsX = cMappings;
1514 pChunk, pChunk->Core.Key, i, hMemObj, rc);
1518 gmmR0ChunkMutexRelease(&MtxState, pChunk);
1522 gmmR0ChunkMutexRelease(&MtxState, pChunk);
1804 PGMMCHUNK pChunk = (PGMMCHUNK)RTAvlU32Get(&pGMM->pChunks, idChunk);
1805 AssertMsgReturn(pChunk, ("Chunk %#x not found!\n", idChunk), NULL);
1807 pTlbe->pChunk = pChunk;
1808 return pChunk;
1828 || !pTlbe->pChunk)
1830 return pTlbe->pChunk;
1845 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, idPage >> GMM_CHUNKID_SHIFT);
1846 if (RT_LIKELY(pChunk))
1847 return &pChunk->aPages[idPage & GMM_PAGEID_IDX_MASK];
1861 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, idPage >> GMM_CHUNKID_SHIFT);
1862 if (RT_LIKELY(pChunk))
1863 return RTR0MemObjGetPagePhysAddr(pChunk->hMemObj, idPage & GMM_PAGEID_IDX_MASK);
1886 * @param pChunk The allocation chunk.
1888 DECLINLINE(void) gmmR0UnlinkChunk(PGMMCHUNK pChunk)
1890 PGMMCHUNKFREESET pSet = pChunk->pSet;
1893 pSet->cFreePages -= pChunk->cFree;
1896 PGMMCHUNK pPrev = pChunk->pFreePrev;
1897 PGMMCHUNK pNext = pChunk->pFreeNext;
1901 pSet->apLists[gmmR0SelectFreeSetList(pChunk->cFree)] = pNext;
1905 pChunk->pSet = NULL;
1906 pChunk->pFreeNext = NULL;
1907 pChunk->pFreePrev = NULL;
1911 Assert(!pChunk->pFreeNext);
1912 Assert(!pChunk->pFreePrev);
1913 Assert(!pChunk->cFree);
1923 * @param pChunk The allocation chunk.
1926 DECLINLINE(void) gmmR0LinkChunk(PGMMCHUNK pChunk, PGMMCHUNKFREESET pSet)
1928 Assert(!pChunk->pSet);
1929 Assert(!pChunk->pFreeNext);
1930 Assert(!pChunk->pFreePrev);
1932 if (pChunk->cFree > 0)
1934 pChunk->pSet = pSet;
1935 pChunk->pFreePrev = NULL;
1936 unsigned const iList = gmmR0SelectFreeSetList(pChunk->cFree);
1937 pChunk->pFreeNext = pSet->apLists[iList];
1938 if (pChunk->pFreeNext)
1939 pChunk->pFreeNext->pFreePrev = pChunk;
1940 pSet->apLists[iList] = pChunk;
1942 pSet->cFreePages += pChunk->cFree;
1953 * @param pChunk The allocation chunk.
1955 DECLINLINE(void) gmmR0SelectSetAndLinkChunk(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk)
1960 else if (pChunk->cShared)
1964 gmmR0LinkChunk(pChunk, pSet);
2035 * @param pChunk The chunk to allocate it from.
2039 static void gmmR0AllocatePage(PGMMCHUNK pChunk, uint32_t hGVM, PGMMPAGEDESC pPageDesc)
2042 if (pChunk->hGVM == NIL_GVM_HANDLE)
2043 pChunk->hGVM = hGVM;
2044 Assert(pChunk->cFree);
2045 pChunk->cFree--;
2046 pChunk->cPrivate++;
2049 const uint32_t iPage = pChunk->iFreeHead;
2050 AssertReleaseMsg(iPage < RT_ELEMENTS(pChunk->aPages), ("%d\n", iPage));
2051 PGMMPAGE pPage = &pChunk->aPages[iPage];
2053 pChunk->iFreeHead = pPage->Free.iNext;
2055 pPage, iPage, (pChunk->Core.Key << GMM_CHUNKID_SHIFT) | iPage,
2056 pPage->Common.u2State, pChunk->iFreeHead, pPage->Free.iNext));
2070 pPageDesc->HCPhysGCPhys = RTR0MemObjGetPagePhysAddr(pChunk->hMemObj, iPage);
2072 pPageDesc->idPage = (pChunk->Core.Key << GMM_CHUNKID_SHIFT) | iPage;
2083 * @param pChunk The chunk.
2088 static uint32_t gmmR0AllocatePagesFromChunk(PGMMCHUNK pChunk, uint16_t const hGVM, uint32_t iPage, uint32_t cPages,
2091 PGMMCHUNKFREESET pSet = pChunk->pSet; Assert(pSet);
2092 gmmR0UnlinkChunk(pChunk);
2094 for (; pChunk->cFree && iPage < cPages; iPage++)
2095 gmmR0AllocatePage(pChunk, hGVM, &paPages[iPage]);
2097 gmmR0LinkChunk(pChunk, pSet);
2129 PGMMCHUNK pChunk = (PGMMCHUNK)RTMemAllocZ(sizeof(*pChunk));
2130 if (pChunk)
2135 pChunk->hMemObj = MemObj;
2136 pChunk->cFree = GMM_CHUNK_NUM_PAGES;
2137 pChunk->hGVM = hGVM;
2138 /*pChunk->iFreeHead = 0;*/
2139 pChunk->idNumaNode = gmmR0GetCurrentNumaNodeId();
2140 pChunk->iChunkMtx = UINT8_MAX;
2141 pChunk->fFlags = fChunkFlags;
2142 for (unsigned iPage = 0; iPage < RT_ELEMENTS(pChunk->aPages) - 1; iPage++)
2144 pChunk->aPages[iPage].Free.u2State = GMM_PAGE_STATE_FREE;
2145 pChunk->aPages[iPage].Free.iNext = iPage + 1;
2147 pChunk->aPages[RT_ELEMENTS(pChunk->aPages) - 1].Free.u2State = GMM_PAGE_STATE_FREE;
2148 pChunk->aPages[RT_ELEMENTS(pChunk->aPages) - 1].Free.iNext = UINT16_MAX;
2159 pChunk->Core.Key = gmmR0AllocateChunkId(pGMM);
2160 if ( pChunk->Core.Key != NIL_GMM_CHUNKID
2161 && pChunk->Core.Key <= GMM_CHUNKID_LAST
2162 && RTAvlU32Insert(&pGMM->pChunks, &pChunk->Core))
2165 RTListAppend(&pGMM->ChunkList, &pChunk->ListNode);
2166 gmmR0LinkChunk(pChunk, pSet);
2167 LogFlow(("gmmR0RegisterChunk: pChunk=%p id=%#x cChunks=%d\n", pChunk, pChunk->Core.Key, pGMM->cChunks));
2170 *ppChunk = pChunk;
2183 RTMemFree(pChunk);
2218 PGMMCHUNK pChunk;
2219 rc = gmmR0RegisterChunk(pGMM, pSet, hMemObj, pGVM->hSelf, 0 /*fChunkFlags*/, &pChunk);
2222 *piPage = gmmR0AllocatePagesFromChunk(pChunk, pGVM->hSelf, *piPage, cPages, paPages);
2253 PGMMCHUNK pChunk = pSet->apLists[iList];
2254 while (pChunk)
2256 PGMMCHUNK pNext = pChunk->pFreeNext;
2258 iPage = gmmR0AllocatePagesFromChunk(pChunk, pGVM->hSelf, iPage, cPages, paPages);
2262 pChunk = pNext;
2282 PGMMCHUNK pChunk = pSet->apLists[GMM_CHUNK_FREE_SET_UNUSED_LIST];
2283 if (pChunk)
2286 while (pChunk)
2288 PGMMCHUNK pNext = pChunk->pFreeNext;
2290 if (pChunk->idNumaNode == idNumaNode)
2292 pChunk->hGVM = pGVM->hSelf;
2293 iPage = gmmR0AllocatePagesFromChunk(pChunk, pGVM->hSelf, iPage, cPages, paPages);
2296 pGVM->gmm.s.idLastChunkHint = pChunk->cFree ? pChunk->Core.Key : NIL_GMM_CHUNKID;
2301 pChunk = pNext;
2326 PGMMCHUNK pChunk = pSet->apLists[iList];
2327 while (pChunk)
2329 PGMMCHUNK pNext = pChunk->pFreeNext;
2331 if (pChunk->idNumaNode == idNumaNode)
2333 iPage = gmmR0AllocatePagesFromChunk(pChunk, pGVM->hSelf, iPage, cPages, paPages);
2336 pGVM->gmm.s.idLastChunkHint = pChunk->cFree ? pChunk->Core.Key : NIL_GMM_CHUNKID;
2341 pChunk = pNext;
2367 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, pGVM->gmm.s.idLastChunkHint);
2368 if (pChunk && pChunk->cFree)
2370 iPage = gmmR0AllocatePagesFromChunk(pChunk, hGVM, iPage, cPages, paPages);
2379 PGMMCHUNK pChunk = pSet->apLists[iList];
2380 while (pChunk)
2382 PGMMCHUNK pNext = pChunk->pFreeNext;
2384 if (pChunk->hGVM == hGVM)
2386 iPage = gmmR0AllocatePagesFromChunk(pChunk, hGVM, iPage, cPages, paPages);
2389 pGVM->gmm.s.idLastChunkHint = pChunk->cFree ? pChunk->Core.Key : NIL_GMM_CHUNKID;
2394 pChunk = pNext;
2415 PGMMCHUNK pChunk = pGVM->gmm.s.Private.apLists[iList];
2416 while (pChunk)
2418 Assert(pChunk->hGVM == pGVM->hSelf);
2419 PGMMCHUNK pNext = pChunk->pFreeNext;
2420 iPage = gmmR0AllocatePagesFromChunk(pChunk, pGVM->hSelf, iPage, cPages, paPages);
2423 pChunk = pNext;
3072 PGMMCHUNK pChunk;
3073 rc = gmmR0RegisterChunk(pGMM, pSet, hMemObj, pGVM->hSelf, GMM_CHUNK_FLAGS_LARGE_PAGE, &pChunk);
3080 gmmR0UnlinkChunk(pChunk);
3085 gmmR0AllocatePage(pChunk, pGVM->hSelf, &PageDesc);
3092 gmmR0AllocatePage(pChunk, pGVM->hSelf, &PageDesc);
3099 gmmR0LinkChunk(pChunk, pSet);
3159 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, idPage >> GMM_CHUNKID_SHIFT);
3160 Assert(pChunk);
3161 Assert(pChunk->cFree < GMM_CHUNK_NUM_PAGES);
3162 Assert(pChunk->cPrivate > 0);
3165 gmmR0FreeChunk(pGMM, NULL, pChunk, false /*fRelaxedSem*/); /** @todo this can be relaxed too! */
3213 * @param pChunk The chunk to free.
3217 static bool gmmR0FreeChunk(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk, bool fRelaxedSem)
3219 Assert(pChunk->Core.Key != NIL_GMM_CHUNKID);
3222 gmmR0ChunkMutexAcquire(&MtxState, pGMM, pChunk, GMMR0CHUNK_MTX_KEEP_GIANT);
3228 if ( pChunk->cMappingsX
3231 gmmR0UnmapChunkLocked(pGMM, pGVM, pChunk);
3238 if (pChunk->cMappingsX)
3242 Log(("gmmR0FreeChunk: chunk still has %d/%d mappings; don't free!\n", pChunk->cMappingsX));
3243 gmmR0ChunkMutexRelease(&MtxState, pChunk);
3251 RTR0MEMOBJ const hMemObj = pChunk->hMemObj;
3252 pChunk->hMemObj = NIL_RTR0MEMOBJ;
3257 gmmR0UnlinkChunk(pChunk);
3259 RTListNodeRemove(&pChunk->ListNode);
3261 PAVLU32NODECORE pCore = RTAvlU32Remove(&pGMM->pChunks, pChunk->Core.Key);
3262 Assert(pCore == &pChunk->Core); NOREF(pCore);
3264 PGMMCHUNKTLBE pTlbe = &pGMM->ChunkTLB.aEntries[GMM_CHUNKTLB_IDX(pChunk->Core.Key)];
3265 if (pTlbe->pChunk == pChunk)
3268 pTlbe->pChunk = NULL;
3277 gmmR0FreeChunkId(pGMM, pChunk->Core.Key);
3278 pChunk->Core.Key = NIL_GMM_CHUNKID;
3286 RTMemFree(pChunk->paMappingsX);
3287 pChunk->paMappingsX = NULL;
3289 RTMemFree(pChunk);
3307 * @param pChunk Pointer to the chunk this page belongs to.
3311 static void gmmR0FreePageWorker(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk, uint32_t idPage, PGMMPAGE pPage)
3314 pPage, pPage - &pChunk->aPages[0], idPage, pPage->Common.u2State, pChunk->iFreeHead)); NOREF(idPage);
3321 Assert(pChunk->iFreeHead < RT_ELEMENTS(pChunk->aPages) || pChunk->iFreeHead == UINT16_MAX);
3322 pPage->Free.iNext = pChunk->iFreeHead;
3323 pChunk->iFreeHead = pPage - &pChunk->aPages[0];
3329 unsigned const cFree = pChunk->cFree;
3333 gmmR0UnlinkChunk(pChunk);
3334 pChunk->cFree++;
3335 gmmR0SelectSetAndLinkChunk(pGMM, pGVM, pChunk);
3339 pChunk->cFree = cFree + 1;
3340 pChunk->pSet->cFreePages++;
3353 if (RT_UNLIKELY( pChunk->cFree == GMM_CHUNK_NUM_PAGES
3354 && pChunk->pFreeNext
3355 && pChunk->pFreePrev /** @todo this is probably misfiring, see reset... */
3357 gmmR0FreeChunk(pGMM, NULL, pChunk, false);
3372 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, idPage >> GMM_CHUNKID_SHIFT);
3373 Assert(pChunk);
3374 Assert(pChunk->cFree < GMM_CHUNK_NUM_PAGES);
3375 Assert(pChunk->cShared > 0);
3380 pChunk->cShared--;
3383 gmmR0FreePageWorker(pGMM, pGVM, pChunk, idPage, pPage);
3397 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, idPage >> GMM_CHUNKID_SHIFT);
3398 Assert(pChunk);
3399 Assert(pChunk->cFree < GMM_CHUNK_NUM_PAGES);
3400 Assert(pChunk->cPrivate > 0);
3403 pChunk->cPrivate--;
3405 gmmR0FreePageWorker(pGMM, pGVM, pChunk, idPage, pPage);
3878 * @param pChunk Pointer to the chunk to be unmapped.
3880 static int gmmR0UnmapChunkLocked(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk)
3887 uint32_t cMappings = pChunk->cMappingsX;
3890 Assert(pChunk->paMappingsX[i].pGVM && pChunk->paMappingsX[i].hMapObj != NIL_RTR0MEMOBJ);
3891 if (pChunk->paMappingsX[i].pGVM == pGVM)
3894 int rc = RTR0MemObjFree(pChunk->paMappingsX[i].hMapObj, false /* fFreeMappings (NA) */);
3900 pChunk->paMappingsX[i] = pChunk->paMappingsX[cMappings];
3901 pChunk->paMappingsX[cMappings].hMapObj = NIL_RTR0MEMOBJ;
3902 pChunk->paMappingsX[cMappings].pGVM = NULL;
3903 Assert(pChunk->cMappingsX - 1U == cMappings);
3904 pChunk->cMappingsX = cMappings;
3911 Log(("gmmR0UnmapChunk: Chunk %#x is not mapped into pGVM=%p/%#x\n", pChunk->Core.Key, pGVM, pGVM->hSelf));
3922 * @param pChunk Pointer to the chunk to be unmapped.
3924 static int gmmR0UnmapChunk(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk, bool fRelaxedSem)
3932 int rc = gmmR0ChunkMutexAcquire(&MtxState, pGMM, pChunk,
3936 rc = gmmR0UnmapChunkLocked(pGMM, pGVM, pChunk);
3937 gmmR0ChunkMutexRelease(&MtxState, pChunk);
3942 if (pChunk->hGVM == pGVM->hSelf)
3945 Log(("gmmR0UnmapChunk: Chunk %#x is not mapped into pGVM=%p/%#x (legacy)\n", pChunk->Core.Key, pGVM, pGVM->hSelf));
3956 * @param pChunk Pointer to the chunk to be mapped.
3961 static int gmmR0MapChunkLocked(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk, PRTR3PTR ppvR3)
3968 if (pChunk->hGVM != pGVM->hSelf)
3970 Log(("gmmR0MapChunk: chunk %#x is already mapped at %p!\n", pChunk->Core.Key, *ppvR3));
3974 *ppvR3 = RTR0MemObjAddressR3(pChunk->hMemObj);
3981 for (uint32_t i = 0; i < pChunk->cMappingsX; i++)
3983 Assert(pChunk->paMappingsX[i].pGVM && pChunk->paMappingsX[i].hMapObj != NIL_RTR0MEMOBJ);
3984 if (pChunk->paMappingsX[i].pGVM == pGVM)
3986 *ppvR3 = RTR0MemObjAddressR3(pChunk->paMappingsX[i].hMapObj);
3987 Log(("gmmR0MapChunk: chunk %#x is already mapped at %p!\n", pChunk->Core.Key, *ppvR3));
4001 int rc = RTR0MemObjMapUser(&hMapObj, pChunk->hMemObj, (RTR3PTR)-1, 0, RTMEM_PROT_READ | RTMEM_PROT_WRITE, NIL_RTR0PROCESS);
4005 unsigned iMapping = pChunk->cMappingsX;
4019 void *pvMappings = RTMemRealloc(pChunk->paMappingsX, cNewSize * sizeof(pChunk->paMappingsX[0]));
4025 pChunk->paMappingsX = (PGMMCHUNKMAP)pvMappings;
4029 pChunk->paMappingsX[iMapping].hMapObj = hMapObj;
4030 pChunk->paMappingsX[iMapping].pGVM = pGVM;
4031 Assert(pChunk->cMappingsX == iMapping);
4032 pChunk->cMappingsX = iMapping + 1;
4047 * @param pChunk Pointer to the chunk to be mapped.
4054 static int gmmR0MapChunk(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk, bool fRelaxedSem, PRTR3PTR ppvR3)
4061 int rc = gmmR0ChunkMutexAcquire(&MtxState, pGMM, pChunk,
4065 rc = gmmR0MapChunkLocked(pGMM, pGVM, pChunk, ppvR3);
4066 gmmR0ChunkMutexRelease(&MtxState, pChunk);
4081 * @param pChunk Pointer to the chunk to be mapped.
4084 static bool gmmR0IsChunkMapped(PGMM pGMM, PGVM pGVM, PGMMCHUNK pChunk, PRTR3PTR ppvR3)
4087 gmmR0ChunkMutexAcquire(&MtxState, pGMM, pChunk, GMMR0CHUNK_MTX_KEEP_GIANT);
4088 for (uint32_t i = 0; i < pChunk->cMappingsX; i++)
4090 Assert(pChunk->paMappingsX[i].pGVM && pChunk->paMappingsX[i].hMapObj != NIL_RTR0MEMOBJ);
4091 if (pChunk->paMappingsX[i].pGVM == pGVM)
4093 *ppvR3 = RTR0MemObjAddressR3(pChunk->paMappingsX[i].hMapObj);
4094 gmmR0ChunkMutexRelease(&MtxState, pChunk);
4099 gmmR0ChunkMutexRelease(&MtxState, pChunk);
4287 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, idPage >> GMM_CHUNKID_SHIFT);
4288 AssertMsgReturn(pChunk, ("idPage=%#x\n", idPage), 0);
4291 if (!gmmR0IsChunkMapped(pGMM, pGVM, pChunk, (PRTR3PTR)&pbChunk))
4800 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, idPage >> GMM_CHUNKID_SHIFT);
4801 Assert(pChunk);
4802 Assert(pChunk->cFree < GMM_CHUNK_NUM_PAGES);
4805 pChunk->cPrivate--;
4806 pChunk->cShared++;
4942 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, pPageDesc->idPage >> GMM_CHUNKID_SHIFT);
4943 AssertMsgReturn(pChunk, ("idPage=%#x (idxRegion=%#x idxPage=%#x) #4\n", pPageDesc->idPage, idxRegion, idxPage),
4947 AssertMsgReturn(gmmR0IsChunkMapped(pGMM, pGVM, pChunk, (PRTR3PTR)&pbChunk),
4955 pChunk = gmmR0GetChunk(pGMM, pGlobalRegion->paidPages[idxPage] >> GMM_CHUNKID_SHIFT);
4956 Assert(pChunk); /* can't fail as gmmR0GetPage succeeded. */
4962 if (!gmmR0IsChunkMapped(pGMM, pGVM, pChunk, (PRTR3PTR)&pbChunk))
4965 rc = gmmR0MapChunk(pGMM, pGVM, pChunk, false /*fRelaxedSem*/, (PRTR3PTR)&pbChunk);
5232 PGMMCHUNK pChunk = (PGMMCHUNK)pNode;
5239 if (!gmmR0IsChunkMapped(pGMM, pGVM, pChunk, (PRTR3PTR)&pbChunk))
5241 int rc = gmmR0MapChunk(pGMM, pGVM, pChunk, false /*fRelaxedSem*/, (PRTR3PTR)&pbChunk);
5250 if (GMM_PAGE_IS_PRIVATE(&pChunk->aPages[iPage]))
5261 gmmR0UnmapChunk(pGMM, pGVM, pChunk, false /*fRelaxedSem*/);
5299 PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, pReq->idPage >> GMM_CHUNKID_SHIFT);
5300 if (pChunk)
5302 if (gmmR0IsChunkMapped(pGMM, pGVM, pChunk, (PRTR3PTR)&pbChunk))