/** * Performs a GMMR0FreePages request. * This will call VMSetError on failure. * * @returns VBox status code. * @param pVM Pointer to the shared VM structure. * @param pReq Pointer to the request (returned by GMMR3FreePagesPrepare). * @param cActualPages The number of pages actually freed. */ GMMR3DECL(int) GMMR3FreePagesPerform(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t cActualPages) { /* * Adjust the request if we ended up with fewer pages than anticipated. */ if (cActualPages != pReq->cPages) { AssertReturn(cActualPages < pReq->cPages, VERR_INTERNAL_ERROR); if (!cActualPages) return VINF_SUCCESS; pReq->cPages = cActualPages; pReq->Hdr.cbReq = RT_OFFSETOF(GMMFREEPAGESREQ, aPages[cActualPages]); } /* * Do the job. */ int rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_FREE_PAGES, 0, &pReq->Hdr); if (RT_SUCCESS(rc)) return rc; AssertRC(rc); return VMSetError(pVM, rc, RT_SRC_POS, N_("GMMR0FreePages failed to free %u pages"), pReq->cPages); }
/** * @see GMMR0FreeLargePage */ GMMR3DECL(int) GMMR3FreeLargePage(PVM pVM, uint32_t idPage) { GMMFREELARGEPAGEREQ Req; Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; Req.Hdr.cbReq = sizeof(Req); Req.idPage = idPage; return VMMR3CallR0(pVM, VMMR0_DO_GMM_FREE_LARGE_PAGE, 0, &Req.Hdr); }
/** * @see GMMR0RegisterSharedModule */ GMMR3DECL(int) GMMR3RegisterSharedModule(PVM pVM, PGMMREGISTERSHAREDMODULEREQ pReq) { pReq->Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; pReq->Hdr.cbReq = RT_OFFSETOF(GMMREGISTERSHAREDMODULEREQ, aRegions[pReq->cRegions]); int rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_REGISTER_SHARED_MODULE, 0, &pReq->Hdr); if (rc == VINF_SUCCESS) rc = pReq->rc; return rc; }
/** * @see GMMR0UpdateReservation */ GMMR3DECL(int) GMMR3UpdateReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages) { GMMUPDATERESERVATIONREQ Req; Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; Req.Hdr.cbReq = sizeof(Req); Req.cBasePages = cBasePages; Req.cShadowPages = cShadowPages; Req.cFixedPages = cFixedPages; return VMMR3CallR0(pVM, VMMR0_DO_GMM_UPDATE_RESERVATION, 0, &Req.Hdr); }
/** * @see GMMR0BalloonedPages */ GMMR3DECL(int) GMMR3BalloonedPages(PVM pVM, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages) { GMMBALLOONEDPAGESREQ Req; Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; Req.Hdr.cbReq = sizeof(Req); Req.enmAction = enmAction; Req.cBalloonedPages = cBalloonedPages; return VMMR3CallR0(pVM, VMMR0_DO_GMM_BALLOONED_PAGES, 0, &Req.Hdr); }
/** * @see GMMR0InitialReservation */ GMMR3DECL(int) GMMR3InitialReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages, GMMOCPOLICY enmPolicy, GMMPRIORITY enmPriority) { GMMINITIALRESERVATIONREQ Req; Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; Req.Hdr.cbReq = sizeof(Req); Req.cBasePages = cBasePages; Req.cShadowPages = cShadowPages; Req.cFixedPages = cFixedPages; Req.enmPolicy = enmPolicy; Req.enmPriority = enmPriority; return VMMR3CallR0(pVM, VMMR0_DO_GMM_INITIAL_RESERVATION, 0, &Req.Hdr); }
/** * @see GMMR0MapUnmapChunk */ GMMR3DECL(int) GMMR3MapUnmapChunk(PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3) { GMMMAPUNMAPCHUNKREQ Req; Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; Req.Hdr.cbReq = sizeof(Req); Req.idChunkMap = idChunkMap; Req.idChunkUnmap = idChunkUnmap; Req.pvR3 = NULL; int rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_MAP_UNMAP_CHUNK, 0, &Req.Hdr); if (RT_SUCCESS(rc) && ppvR3) *ppvR3 = Req.pvR3; return rc; }
/** * @see GMMR0QueryMemoryStatsReq */ GMMR3DECL(int) GMMR3QueryMemoryStats(PVM pVM, uint64_t *pcAllocPages, uint64_t *pcMaxPages, uint64_t *pcBalloonPages) { GMMMEMSTATSREQ Req; Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; Req.Hdr.cbReq = sizeof(Req); Req.cAllocPages = 0; Req.cFreePages = 0; Req.cBalloonedPages = 0; *pcAllocPages = 0; *pcMaxPages = 0; *pcBalloonPages = 0; int rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_QUERY_MEM_STATS, 0, &Req.Hdr); if (rc == VINF_SUCCESS) { *pcAllocPages = Req.cAllocPages; *pcMaxPages = Req.cMaxPages; *pcBalloonPages = Req.cBalloonedPages; } return rc; }
/** * Frees allocated pages, for bailing out on failure. * * This will not call VMSetError on failure but will use AssertLogRel instead. * * @param pVM The cross context VM structure. * @param pAllocReq The allocation request to undo. */ GMMR3DECL(void) GMMR3FreeAllocatedPages(PVM pVM, GMMALLOCATEPAGESREQ const *pAllocReq) { uint32_t cb = RT_OFFSETOF(GMMFREEPAGESREQ, aPages[pAllocReq->cPages]); PGMMFREEPAGESREQ pReq = (PGMMFREEPAGESREQ)RTMemTmpAllocZ(cb); AssertLogRelReturnVoid(pReq); pReq->Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; pReq->Hdr.cbReq = cb; pReq->enmAccount = pAllocReq->enmAccount; pReq->cPages = pAllocReq->cPages; uint32_t iPage = pAllocReq->cPages; while (iPage-- > 0) { Assert(pAllocReq->aPages[iPage].idPage != NIL_GMM_PAGEID); pReq->aPages[iPage].idPage = pAllocReq->aPages[iPage].idPage; } int rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_FREE_PAGES, 0, &pReq->Hdr); AssertLogRelRC(rc); RTMemTmpFree(pReq); }
/** * @see GMMR0CheckSharedModules */ GMMR3DECL(int) GMMR3CheckSharedModules(PVM pVM) { return VMMR3CallR0(pVM, VMMR0_DO_GMM_CHECK_SHARED_MODULES, 0, NULL); }
/** * @see GMMR0ResetSharedModules */ GMMR3DECL(int) GMMR3ResetSharedModules(PVM pVM) { return VMMR3CallR0(pVM, VMMR0_DO_GMM_RESET_SHARED_MODULES, 0, NULL); }
/** * @see GMMR0RegisterSharedModule */ GMMR3DECL(int) GMMR3UnregisterSharedModule(PVM pVM, PGMMUNREGISTERSHAREDMODULEREQ pReq) { pReq->Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; pReq->Hdr.cbReq = sizeof(*pReq); return VMMR3CallR0(pVM, VMMR0_DO_GMM_UNREGISTER_SHARED_MODULE, 0, &pReq->Hdr); }
/** * @see GMMR0SeedChunk */ GMMR3DECL(int) GMMR3SeedChunk(PVM pVM, RTR3PTR pvR3) { return VMMR3CallR0(pVM, VMMR0_DO_GMM_SEED_CHUNK, (uintptr_t)pvR3, NULL); }