/** * Free a page allocated from the page pool by physical address. * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys() * and MMR3PageAllocLow(). * * @param pVM The cross context VM structure. * @param HCPhysPage The physical address of the page to be freed. * @thread The Emulation Thread. */ VMMR3DECL(void) MMR3PageFreeByPhys(PVM pVM, RTHCPHYS HCPhysPage) { void *pvPage = mmPagePoolPhys2Ptr(pVM->mm.s.pPagePoolR3, HCPhysPage); if (!pvPage) pvPage = mmPagePoolPhys2Ptr(pVM->mm.s.pPagePoolLowR3, HCPhysPage); if (pvPage) mmR3PagePoolFree(pVM->mm.s.pPagePoolR3, pvPage); else AssertMsgFailed(("Invalid address HCPhysPT=%#x\n", HCPhysPage)); }
/** * Try convert physical address of a page to a HC virtual address. * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys() * and MMR3PageAllocLow(). * * @returns VBox status code. * @param pVM The cross context VM structure. * @param HCPhysPage The physical address of a page. * @param ppvPage Where to store the address corresponding to HCPhysPage. * @thread The Emulation Thread. */ VMMDECL(int) MMPagePhys2PageTry(PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage) { void *pvPage = mmPagePoolPhys2Ptr(pVM->mm.s.CTX_SUFF(pPagePool), HCPhysPage); if (!pvPage) { pvPage = mmPagePoolPhys2Ptr(pVM->mm.s.CTX_SUFF(pPagePoolLow), HCPhysPage); if (!pvPage) return VERR_INVALID_POINTER; } *ppvPage = pvPage; return VINF_SUCCESS; }
/** * Convert physical address of a page to a HC virtual address. * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys() * and MMR3PageAllocLow(). * * @returns Pointer to the page at that physical address. * @param pVM The cross context VM structure. * @param HCPhysPage The physical address of a page. * @thread The Emulation Thread. */ VMMDECL(void *) MMPagePhys2Page(PVM pVM, RTHCPHYS HCPhysPage) { void *pvPage = mmPagePoolPhys2Ptr(pVM->mm.s.CTX_SUFF(pPagePool), HCPhysPage); if (!pvPage) { pvPage = mmPagePoolPhys2Ptr(pVM->mm.s.CTX_SUFF(pPagePoolLow), HCPhysPage); if (!pvPage) { STAM_COUNTER_INC(&pVM->mm.s.CTX_SUFF(pPagePool)->cErrors); AssertMsg(pvPage, ("Invalid HCPhysPage=%RHp specified\n", HCPhysPage)); } } return pvPage; }
/** * Convert physical address of a page to a HC virtual address. * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys() * and MMR3PageAllocLow(). * * @returns VBox status code. * @param pVM The cross context VM structure. * @param HCPhysPage The physical address of a page. * @param ppvPage Where to store the address corresponding to HCPhysPage. * @thread The Emulation Thread. */ VMMDECL(int) MMPagePhys2PageEx(PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage) { void *pvPage = mmPagePoolPhys2Ptr(pVM->mm.s.CTX_SUFF(pPagePool), HCPhysPage); if (!pvPage) { pvPage = mmPagePoolPhys2Ptr(pVM->mm.s.CTX_SUFF(pPagePoolLow), HCPhysPage); if (!pvPage) { STAM_COUNTER_INC(&pVM->mm.s.CTX_SUFF(pPagePool)->cErrors); AssertMsg(pvPage, ("Invalid HCPhysPage=%RHp specified\n", HCPhysPage)); return VERR_INVALID_POINTER; } } *ppvPage = pvPage; return VINF_SUCCESS; }