Lines Matching defs:pVM
174 static DECLCALLBACK(int) mmR3Save(PVM pVM, PSSMHANDLE pSSM);
175 static DECLCALLBACK(int) mmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
229 * @param pVM Pointer to the VM.
231 VMMR3DECL(int) MMR3Init(PVM pVM)
239 AssertRelease(sizeof(pVM->mm.s) <= sizeof(pVM->mm.padding));
240 AssertMsg(pVM->mm.s.offVM == 0, ("Already initialized!\n"));
245 pVM->mm.s.offVM = RT_OFFSETOF(VM, mm);
246 pVM->mm.s.offLookupHyper = NIL_OFFSET;
251 int rc = mmR3PagePoolInit(pVM);
257 rc = mmR3HyperInit(pVM);
263 rc = SSMR3RegisterInternal(pVM, "mm", 1, MM_SAVED_STATE_VERSION, sizeof(uint32_t) * 2,
272 STAM_REG(pVM, &pVM->mm.s.cBasePages, STAMTYPE_U64, "/MM/Reserved/cBasePages", STAMUNIT_PAGES, "Reserved number of base pages, ROM and Shadow ROM included.");
273 STAM_REG(pVM, &pVM->mm.s.cHandyPages, STAMTYPE_U32, "/MM/Reserved/cHandyPages", STAMUNIT_PAGES, "Reserved number of handy pages.");
274 STAM_REG(pVM, &pVM->mm.s.cShadowPages, STAMTYPE_U32, "/MM/Reserved/cShadowPages", STAMUNIT_PAGES, "Reserved number of shadow paging pages.");
275 STAM_REG(pVM, &pVM->mm.s.cFixedPages, STAMTYPE_U32, "/MM/Reserved/cFixedPages", STAMUNIT_PAGES, "Reserved number of fixed pages (MMIO2).");
276 STAM_REG(pVM, &pVM->mm.s.cbRamBase, STAMTYPE_U64, "/MM/cbRamBase", STAMUNIT_BYTES, "Size of the base RAM.");
284 MMR3Term(pVM);
293 * @param pVM Pointer to the VM.
296 VMMR3DECL(int) MMR3InitPaging(PVM pVM)
304 PCFGMNODE pMMCfg = CFGMR3GetChild(CFGMR3GetRoot(pVM), "MM");
307 rc = CFGMR3InsertNode(CFGMR3GetRoot(pVM), "MM", &pMMCfg);
316 rc = CFGMR3QueryU64(CFGMR3GetRoot(pVM), "RamSize", &cbRam);
324 pVM->mm.s.cbRamBase = cbRam;
331 rc = CFGMR3QueryU32Def(CFGMR3GetRoot(pVM), "RamHoleSize", &cbRamHole, MM_RAM_HOLE_SIZE_DEFAULT);
351 rc = CFGMR3QueryString(CFGMR3GetRoot(pVM), "Policy", sz, sizeof(sz));
358 return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS, "Unknown \"MM/Policy\" value \"%s\"", sz);
371 rc = CFGMR3QueryString(CFGMR3GetRoot(pVM), "Priority", sz, sizeof(sz));
381 return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS, "Unknown \"MM/Priority\" value \"%s\"", sz);
391 uint64_t cBasePages = (cbRam >> PAGE_SHIFT) + pVM->mm.s.cBasePages;
392 rc = GMMR3InitialReservation(pVM,
393 RT_MAX(cBasePages + pVM->mm.s.cHandyPages, 1),
394 RT_MAX(pVM->mm.s.cShadowPages, 1),
395 RT_MAX(pVM->mm.s.cFixedPages, 1),
401 return VMSetError(pVM, rc, RT_SRC_POS,
404 return VMSetError(pVM, rc, RT_SRC_POS, "GMMR3InitialReservation(,%#RX64,0,0,%d,%d)",
422 rc = PGMR3PhysRegisterRam(pVM, 0, offRamHole, "Base RAM");
424 rc = PGMR3PhysRegisterRam(pVM, _4G, cbRam - offRamHole, "Above 4GB Base RAM");
427 rc = PGMR3PhysRegisterRam(pVM, 0, RT_MIN(cbRam, offRamHole), "Base RAM");
433 pVM->mm.s.fDoneMMR3InitPaging = true;
434 AssertMsg(pVM->mm.s.cBasePages == cBasePages || RT_FAILURE(rc), ("%RX64 != %RX64\n", pVM->mm.s.cBasePages, cBasePages));
448 * @param pVM Pointer to the VM.
450 VMMR3DECL(int) MMR3Term(PVM pVM)
455 mmR3PagePoolTerm(pVM);
458 mmR3HyperTerm(pVM);
463 pVM->mm.s.offLookupHyper = NIL_OFFSET;
464 pVM->mm.s.pHyperHeapR3 = NULL; /* freed above. */
465 pVM->mm.s.pHyperHeapR0 = NIL_RTR0PTR; /* freed above. */
466 pVM->mm.s.pHyperHeapRC = NIL_RTRCPTR; /* freed above. */
467 pVM->mm.s.offVM = 0; /* init assertion on this */
473 mmR3UkHeapDestroy(pVM->pUVM->mm.s.pUkHeap);
474 pVM->pUVM->mm.s.pUkHeap = NULL;
508 * @param pVM Pointer to the VM.
511 static DECLCALLBACK(int) mmR3Save(PVM pVM, PSSMHANDLE pSSM)
516 SSMR3PutU64(pSSM, pVM->mm.s.cBasePages);
517 return SSMR3PutU64(pSSM, pVM->mm.s.cbRamBase);
525 * @param pVM Pointer to the VM.
530 static DECLCALLBACK(int) mmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
574 AssertLogRelMsgReturn(cb == pVM->mm.s.cbRamBase,
575 ("Memory configuration has changed. cbRamBase=%#RX64 save=%#RX64\n", pVM->mm.s.cbRamBase, cb),
589 * @param pVM The shared VM structure.
591 int mmR3UpdateReservation(PVM pVM)
593 VM_ASSERT_EMT(pVM);
594 if (pVM->mm.s.fDoneMMR3InitPaging)
595 return GMMR3UpdateReservation(pVM,
596 RT_MAX(pVM->mm.s.cBasePages + pVM->mm.s.cHandyPages, 1),
597 RT_MAX(pVM->mm.s.cShadowPages, 1),
598 RT_MAX(pVM->mm.s.cFixedPages, 1));
609 * @param pVM The shared VM structure.
612 VMMR3DECL(int) MMR3IncreaseBaseReservation(PVM pVM, uint64_t cAddBasePages)
614 uint64_t cOld = pVM->mm.s.cBasePages;
615 pVM->mm.s.cBasePages += cAddBasePages;
616 LogFlow(("MMR3IncreaseBaseReservation: +%RU64 (%RU64 -> %RU64\n", cAddBasePages, cOld, pVM->mm.s.cBasePages));
617 int rc = mmR3UpdateReservation(pVM);
620 VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to reserved physical memory for the RAM (%#RX64 -> %#RX64 + %#RX32)"),
621 cOld, pVM->mm.s.cBasePages, pVM->mm.s.cHandyPages);
622 pVM->mm.s.cBasePages = cOld;
635 * @param pVM The shared VM structure.
638 VMMR3DECL(int) MMR3ReserveHandyPages(PVM pVM, uint32_t cHandyPages)
640 AssertReturn(!pVM->mm.s.cHandyPages, VERR_WRONG_ORDER);
642 pVM->mm.s.cHandyPages = cHandyPages;
643 LogFlow(("MMR3ReserveHandyPages: %RU32 (base %RU64)\n", pVM->mm.s.cHandyPages, pVM->mm.s.cBasePages));
644 int rc = mmR3UpdateReservation(pVM);
647 VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to reserved physical memory for the RAM (%#RX64 + %#RX32)"),
648 pVM->mm.s.cBasePages, pVM->mm.s.cHandyPages);
649 pVM->mm.s.cHandyPages = 0;
661 * @param pVM The shared VM structure.
665 VMMR3DECL(int) MMR3AdjustFixedReservation(PVM pVM, int32_t cDeltaFixedPages, const char *pszDesc)
667 const uint32_t cOld = pVM->mm.s.cFixedPages;
668 pVM->mm.s.cFixedPages += cDeltaFixedPages;
669 LogFlow(("MMR3AdjustFixedReservation: %d (%u -> %u)\n", cDeltaFixedPages, cOld, pVM->mm.s.cFixedPages));
670 int rc = mmR3UpdateReservation(pVM);
673 VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to reserve physical memory (%#x -> %#x; %s)"),
674 cOld, pVM->mm.s.cFixedPages, pszDesc);
675 pVM->mm.s.cFixedPages = cOld;
687 * @param pVM The shared VM structure.
690 VMMR3DECL(int) MMR3UpdateShadowReservation(PVM pVM, uint32_t cShadowPages)
692 const uint32_t cOld = pVM->mm.s.cShadowPages;
693 pVM->mm.s.cShadowPages = cShadowPages;
694 LogFlow(("MMR3UpdateShadowReservation: %u -> %u\n", cOld, pVM->mm.s.cShadowPages));
695 int rc = mmR3UpdateReservation(pVM);
698 VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to reserve physical memory for shadow page tables (%#x -> %#x)"), cOld, pVM->mm.s.cShadowPages);
699 pVM->mm.s.cShadowPages = cOld;
709 * @param pVM Pointer to the VM.
718 VMMR3DECL(int) MMR3HCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys, void **ppv)
723 int rc = MMPagePhys2PageTry(pVM, HCPhys, ppv);
732 PMMLOOKUPHYPER pCur = (PMMLOOKUPHYPER)((uint8_t *)pVM->mm.s.CTX_SUFF(pHyperHeap) + pVM->mm.s.offLookupHyper);
784 * @param pVM Pointer to the VM.
789 VMMR3DECL(uint64_t) MMR3PhysGetRamSize(PVM pVM)
791 return pVM->mm.s.cbRamBase;