Changeset 93618 in vbox for trunk/src/VBox
- Timestamp:
- Feb 6, 2022 9:26:15 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp
r93593 r93618 1143 1143 for (pCur = pVM->pgm.s.pRamRangesXR3; pCur; pCur = pCur->pNextR3) 1144 1144 { 1145 Assert((pCur->fFlags & PGM_RAM_RANGE_FLAGS_FLOATING) || pCur->pSelfR0 == MMHyperCCToR0(pVM, pCur));1146 1145 Assert((pCur->GCPhys & GUEST_PAGE_OFFSET_MASK) == 0); 1147 1146 Assert((pCur->GCPhysLast & GUEST_PAGE_OFFSET_MASK) == GUEST_PAGE_OFFSET_MASK); … … 1184 1183 { 1185 1184 AssertMsg(pNew->pszDesc, ("%RGp-%RGp\n", pNew->GCPhys, pNew->GCPhysLast)); 1186 Assert((pNew->fFlags & PGM_RAM_RANGE_FLAGS_FLOATING) || pNew->pSelfR0 == MMHyperCCToR0(pVM, pNew));1187 1185 1188 1186 PGM_LOCK_VOID(pVM); … … 1219 1217 { 1220 1218 Assert(pPrev ? pPrev->pNextR3 == pRam : pVM->pgm.s.pRamRangesXR3 == pRam); 1221 Assert((pRam->fFlags & PGM_RAM_RANGE_FLAGS_FLOATING) || pRam->pSelfR0 == MMHyperCCToR0(pVM, pRam));1222 1219 1223 1220 PGM_LOCK_VOID(pVM); … … 1820 1817 */ 1821 1818 const size_t cbRamRange = RT_UOFFSETOF_DYN(PGMRAMRANGE, aPages[cPages]); 1822 PPGMRAMRANGE pNew; 1823 rc = MMR3HyperAllocOnceNoRel(pVM, cbRamRange, 0, MM_TAG_PGM_PHYS, (void **)&pNew); 1819 PPGMRAMRANGE pNew = NULL; 1820 RTR0PTR pNewR0 = NIL_RTR0PTR; 1821 rc = SUPR3PageAllocEx(RT_ALIGN_Z(cbRamRange, HOST_PAGE_SIZE) >> HOST_PAGE_SHIFT, 0 /*fFlags*/, 1822 (void **)&pNew, &pNewR0, NULL /*paPages*/); 1824 1823 AssertLogRelMsgRCReturn(rc, ("rc=%Rrc cbRamRange=%zu\n", rc, cbRamRange), rc); 1825 1824 1826 rc = pgmR3PhysInitAndLinkRamRange(pVM, pNew, GCPhys, GCPhysLast, MMHyperCCToR0(pVM, pNew), 0 /*fFlags*/, pszDesc, pPrev);1825 rc = pgmR3PhysInitAndLinkRamRange(pVM, pNew, GCPhys, GCPhysLast, pNewR0, 0 /*fFlags*/, pszDesc, pPrev); 1827 1826 AssertLogRelMsgRCReturn(rc, ("rc=%Rrc cbRamRange=%zu\n", rc, cbRamRange), rc); 1828 1827 } … … 2782 2781 const size_t cbRange = RT_UOFFSETOF_DYN(PGMREGMMIO2RANGE, RamRange.aPages[cPagesTrackedByChunk]); 2783 2782 PPGMREGMMIO2RANGE pNew = NULL; 2784 if ( iChunk + 1 < cChunks 2785 || cbRange >= _1M) 2786 { 2787 /* 2788 * Allocate memory for the registration structure. 2789 */ 2790 size_t const cChunkPages = RT_ALIGN_Z(cbRange, HOST_PAGE_SIZE) >> HOST_PAGE_SHIFT; 2791 size_t const cbChunk = (1 + cChunkPages + 1) << HOST_PAGE_SHIFT; 2792 AssertLogRelBreakStmt(cbChunk == (uint32_t)cbChunk, rc = VERR_OUT_OF_RANGE); 2793 PSUPPAGE paChunkPages = (PSUPPAGE)RTMemTmpAllocZ(sizeof(SUPPAGE) * cChunkPages); 2794 AssertBreakStmt(paChunkPages, rc = VERR_NO_TMP_MEMORY); 2795 RTR0PTR R0PtrChunk = NIL_RTR0PTR; 2796 void *pvChunk = NULL; 2797 rc = SUPR3PageAllocEx(cChunkPages, 0 /*fFlags*/, &pvChunk, &R0PtrChunk, paChunkPages); 2798 AssertLogRelMsgRCBreakStmt(rc, ("rc=%Rrc, cChunkPages=%#zx\n", rc, cChunkPages), RTMemTmpFree(paChunkPages)); 2799 2800 Assert(R0PtrChunk != NIL_RTR0PTR || PGM_IS_IN_NEM_MODE(pVM)); 2801 RT_BZERO(pvChunk, cChunkPages << HOST_PAGE_SHIFT); 2802 2803 pNew = (PPGMREGMMIO2RANGE)pvChunk; 2804 pNew->RamRange.fFlags = PGM_RAM_RANGE_FLAGS_FLOATING; 2805 pNew->RamRange.pSelfR0 = R0PtrChunk + RT_UOFFSETOF(PGMREGMMIO2RANGE, RamRange); 2806 2807 RTMemTmpFree(paChunkPages); 2808 } 2783 2809 2784 /* 2810 * Not so big, do a one time hyper allocation.2785 * Allocate memory for the registration structure. 2811 2786 */ 2812 else 2813 { 2814 rc = MMR3HyperAllocOnceNoRel(pVM, cbRange, 0, MM_TAG_PGM_PHYS, (void **)&pNew); 2815 AssertLogRelMsgRCBreak(rc, ("cbRange=%zu\n", cbRange)); 2816 2817 /* 2818 * Initialize allocation specific items. 2819 */ 2820 //pNew->RamRange.fFlags = 0; 2821 pNew->RamRange.pSelfR0 = MMHyperCCToR0(pVM, &pNew->RamRange); 2822 } 2787 size_t const cChunkPages = RT_ALIGN_Z(cbRange, HOST_PAGE_SIZE) >> HOST_PAGE_SHIFT; 2788 size_t const cbChunk = (1 + cChunkPages + 1) << HOST_PAGE_SHIFT; 2789 AssertLogRelBreakStmt(cbChunk == (uint32_t)cbChunk, rc = VERR_OUT_OF_RANGE); 2790 RTR0PTR R0PtrChunk = NIL_RTR0PTR; 2791 void *pvChunk = NULL; 2792 rc = SUPR3PageAllocEx(cChunkPages, 0 /*fFlags*/, &pvChunk, &R0PtrChunk, NULL /*paPages*/); 2793 AssertLogRelMsgRCBreak(rc, ("rc=%Rrc, cChunkPages=%#zx\n", rc, cChunkPages)); 2794 2795 Assert(R0PtrChunk != NIL_RTR0PTR || PGM_IS_IN_NEM_MODE(pVM)); 2796 RT_BZERO(pvChunk, cChunkPages << HOST_PAGE_SHIFT); 2797 2798 pNew = (PPGMREGMMIO2RANGE)pvChunk; 2799 pNew->RamRange.fFlags = PGM_RAM_RANGE_FLAGS_FLOATING; 2800 pNew->RamRange.pSelfR0 = R0PtrChunk + RT_UOFFSETOF(PGMREGMMIO2RANGE, RamRange); 2823 2801 2824 2802 /*
Note:
See TracChangeset
for help on using the changeset viewer.