Changeset 5629 in vbox
- Timestamp:
- Nov 5, 2007 9:48:30 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/param.h
r5265 r5629 83 83 #define PAGE_ADDRESS(pv) ((uintptr_t)(pv) & ~(uintptr_t)0xfff) 84 84 85 #if 1 /** @todo remove this! Use X86_PAGE_* defines. */86 /**87 * i386 Page directory shift.88 * This is used to convert between PDR index and virtual address.89 * @deprecated Use X86_*.90 */91 #define PGDIR_SHIFT 2292 93 /**94 * i386 Page table mask.95 * This is used together with PAGE_SHIFT to get the page table96 * index from a virtual address.97 * @deprecated Use X86_*.98 */99 #define PTE_MASK 0x3ff100 101 /**102 * i386 Page table and page directory entry count for the default103 * paging mode.104 * @deprecated Use X86_*.105 */106 #define PAGE_ENTRIES 1024107 108 /**109 * i386 4MB Page offset mask.110 * @deprecated Use X86_*.111 */112 #define PAGE_OFFSET_MASK_BIG 0x3fffff113 #endif /* obsolete */114 115 85 /** 116 86 * Host max path (the reasonable value). -
trunk/src/VBox/VMM/PGM.cpp
r5605 r5629 1423 1423 rc = MMR3HyperReserve(pVM, MM_HYPER_DYNAMIC_SIZE, "Dynamic mapping", &pVM->pgm.s.pbDynPageMapBaseGC); 1424 1424 if ( VBOX_SUCCESS(rc) 1425 && (pVM->pgm.s.pbDynPageMapBaseGC >> PGDIR_SHIFT) != ((pVM->pgm.s.pbDynPageMapBaseGC + MM_HYPER_DYNAMIC_SIZE - 1) >> PGDIR_SHIFT))1425 && (pVM->pgm.s.pbDynPageMapBaseGC >> X86_PD_SHIFT) != ((pVM->pgm.s.pbDynPageMapBaseGC + MM_HYPER_DYNAMIC_SIZE - 1) >> X86_PD_SHIFT)) 1426 1426 rc = MMR3HyperReserve(pVM, MM_HYPER_DYNAMIC_SIZE, "Dynamic mapping not crossing", &pVM->pgm.s.pbDynPageMapBaseGC); 1427 1427 if (VBOX_SUCCESS(rc)) 1428 1428 { 1429 AssertRelease((pVM->pgm.s.pbDynPageMapBaseGC >> PGDIR_SHIFT) == ((pVM->pgm.s.pbDynPageMapBaseGC + MM_HYPER_DYNAMIC_SIZE - 1) >> PGDIR_SHIFT));1429 AssertRelease((pVM->pgm.s.pbDynPageMapBaseGC >> X86_PD_SHIFT) == ((pVM->pgm.s.pbDynPageMapBaseGC + MM_HYPER_DYNAMIC_SIZE - 1) >> X86_PD_SHIFT)); 1430 1430 MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL); 1431 1431 } … … 1944 1944 if (pMapping->GCPtr != GCPtr) 1945 1945 { 1946 AssertMsg((GCPtr >> PGDIR_SHIFT << PGDIR_SHIFT) == GCPtr, ("GCPtr=%VGv\n", GCPtr));1946 AssertMsg((GCPtr >> X86_PD_SHIFT << X86_PD_SHIFT) == GCPtr, ("GCPtr=%VGv\n", GCPtr)); 1947 1947 #if HC_ARCH_BITS == 64 1948 1948 LogRel(("Mapping: %VGv -> %VGv %s\n", pMapping->GCPtr, GCPtr, pMapping->pszDesc)); 1949 1949 #endif 1950 pgmR3MapRelocate(pVM, pMapping, pMapping->GCPtr >> PGDIR_SHIFT, GCPtr >> PGDIR_SHIFT);1950 pgmR3MapRelocate(pVM, pMapping, pMapping->GCPtr >> X86_PD_SHIFT, GCPtr >> X86_PD_SHIFT); 1951 1951 } 1952 1952 else -
trunk/src/VBox/VMM/PGMMap.cpp
r5348 r5629 110 110 * Check for conflicts with intermediate mappings. 111 111 */ 112 const unsigned iPageDir = GCPtr >> PGDIR_SHIFT;113 const unsigned cPTs = cb >> PGDIR_SHIFT;112 const unsigned iPageDir = GCPtr >> X86_PD_SHIFT; 113 const unsigned cPTs = cb >> X86_PD_SHIFT; 114 114 unsigned i; 115 115 for (i = 0; i < cPTs; i++) … … 247 247 */ 248 248 MMHyperFree(pVM, pCur->aPTs[0].pPTR3); 249 pgmR3MapClearPDEs(&pVM->pgm.s, pCur, pCur->GCPtr >> PGDIR_SHIFT);249 pgmR3MapClearPDEs(&pVM->pgm.s, pCur, pCur->GCPtr >> X86_PD_SHIFT); 250 250 MMHyperFree(pVM, pCur); 251 251 … … 303 303 * This is all or nothing at all. So, a tiny bit of paranoia first. 304 304 */ 305 if (GCPtrBase & PAGE_OFFSET_MASK_BIG)305 if (GCPtrBase & X86_PAGE_4M_OFFSET_MASK) 306 306 { 307 307 AssertMsgFailed(("GCPtrBase (%#x) has to be aligned on a 4MB address!\n", GCPtrBase)); 308 308 return VERR_INVALID_PARAMETER; 309 309 } 310 if (!cb || (cb & PAGE_OFFSET_MASK_BIG))310 if (!cb || (cb & X86_PAGE_4M_OFFSET_MASK)) 311 311 { 312 312 AssertMsgFailed(("cb (%#x) is 0 or not aligned on a 4MB address!\n", cb)); … … 323 323 * Check that it's not conflicting with a core code mapping in the intermediate page table. 324 324 */ 325 unsigned iPDNew = GCPtrBase >> PGDIR_SHIFT;326 unsigned i = cb >> PGDIR_SHIFT;325 unsigned iPDNew = GCPtrBase >> X86_PD_SHIFT; 326 unsigned i = cb >> X86_PD_SHIFT; 327 327 while (i-- > 0) 328 328 { … … 333 333 while (pCur) 334 334 { 335 if (iPDNew + i - (pCur->GCPtr >> PGDIR_SHIFT) < (pCur->cb >> PGDIR_SHIFT))335 if (iPDNew + i - (pCur->GCPtr >> X86_PD_SHIFT) < (pCur->cb >> X86_PD_SHIFT)) 336 336 break; 337 337 pCur = pCur->pNextR3; … … 376 376 while (pCur) 377 377 { 378 unsigned iPDOld = pCur->GCPtr >> PGDIR_SHIFT;379 iPDNew = GCPtrCur >> PGDIR_SHIFT;378 unsigned iPDOld = pCur->GCPtr >> X86_PD_SHIFT; 379 iPDNew = GCPtrCur >> X86_PD_SHIFT; 380 380 381 381 /* … … 394 394 * Callback to execute the relocation. 395 395 */ 396 pCur->pfnRelocate(pVM, iPDOld << PGDIR_SHIFT, iPDNew << PGDIR_SHIFT, PGMRELOCATECALL_RELOCATE, pCur->pvUser);396 pCur->pfnRelocate(pVM, iPDOld << X86_PD_SHIFT, iPDNew << X86_PD_SHIFT, PGMRELOCATECALL_RELOCATE, pCur->pvUser); 397 397 398 398 /* … … 786 786 void pgmR3MapRelocate(PVM pVM, PPGMMAPPING pMapping, int iPDOld, int iPDNew) 787 787 { 788 Log(("PGM: Relocating %s from %#x to %#x\n", pMapping->pszDesc, iPDOld << PGDIR_SHIFT, iPDNew << PGDIR_SHIFT));789 Assert(((unsigned)iPDOld << PGDIR_SHIFT) == pMapping->GCPtr);788 Log(("PGM: Relocating %s from %#x to %#x\n", pMapping->pszDesc, iPDOld << X86_PD_SHIFT, iPDNew << X86_PD_SHIFT)); 789 Assert(((unsigned)iPDOld << X86_PD_SHIFT) == pMapping->GCPtr); 790 790 791 791 /* … … 811 811 812 812 /* Find mapping which >= than pMapping. */ 813 RTGCPTR GCPtrNew = iPDNew << PGDIR_SHIFT;813 RTGCPTR GCPtrNew = iPDNew << X86_PD_SHIFT; 814 814 PPGMMAPPING pPrev = NULL; 815 815 pCur = pVM->pgm.s.pMappingsR3; … … 870 870 * Callback to execute the relocation. 871 871 */ 872 pMapping->pfnRelocate(pVM, iPDOld << PGDIR_SHIFT, iPDNew << PGDIR_SHIFT, PGMRELOCATECALL_RELOCATE, pMapping->pvUser);872 pMapping->pfnRelocate(pVM, iPDOld << X86_PD_SHIFT, iPDNew << X86_PD_SHIFT, PGMRELOCATECALL_RELOCATE, pMapping->pvUser); 873 873 } 874 874 … … 924 924 * Ask the mapping. 925 925 */ 926 if (pMapping->pfnRelocate(pVM, iPDOld << PGDIR_SHIFT, iPDNew << PGDIR_SHIFT, PGMRELOCATECALL_SUGGEST, pMapping->pvUser))926 if (pMapping->pfnRelocate(pVM, iPDOld << X86_PD_SHIFT, iPDNew << X86_PD_SHIFT, PGMRELOCATECALL_SUGGEST, pMapping->pvUser)) 927 927 { 928 928 pgmR3MapRelocate(pVM, pMapping, iPDOld, iPDNew); … … 933 933 934 934 STAM_PROFILE_STOP(&pVM->pgm.s.StatHCResolveConflict, a); 935 AssertMsgFailed(("Failed to relocate page table mapping '%s' from %#x! (cPTs=%d)\n", pMapping->pszDesc, iPDOld << PGDIR_SHIFT, cPTs));935 AssertMsgFailed(("Failed to relocate page table mapping '%s' from %#x! (cPTs=%d)\n", pMapping->pszDesc, iPDOld << X86_PD_SHIFT, cPTs)); 936 936 return VERR_PGM_NO_HYPERVISOR_ADDRESS; 937 937 } … … 968 968 for (PPGMMAPPING pCur = pVM->pgm.s.pMappingsR3; pCur; pCur = pCur->pNextR3) 969 969 { 970 unsigned iPDE = pCur->GCPtr >> PGDIR_SHIFT;970 unsigned iPDE = pCur->GCPtr >> X86_PD_SHIFT; 971 971 unsigned iPT = pCur->cPTs; 972 972 while (iPT-- > 0) … … 978 978 Log(("PGMR3HasMappingConflicts: Conflict was detected at %VGv for mapping %s\n" 979 979 " iPDE=%#x iPT=%#x PDE=%VGp.\n", 980 (iPT + iPDE) << PGDIR_SHIFT, pCur->pszDesc,980 (iPT + iPDE) << X86_PD_SHIFT, pCur->pszDesc, 981 981 iPDE, iPT, pPD->a[iPDE + iPT].au32[0])); 982 982 #else 983 983 AssertMsgFailed(("PGMR3HasMappingConflicts: Conflict was detected at %VGv for mapping %s\n" 984 984 " iPDE=%#x iPT=%#x PDE=%VGp.\n", 985 (iPT + iPDE) << PGDIR_SHIFT, pCur->pszDesc,985 (iPT + iPDE) << X86_PD_SHIFT, pCur->pszDesc, 986 986 iPDE, iPT, pPD->a[iPDE + iPT].au32[0])); 987 987 #endif … … 1048 1048 } 1049 1049 1050 unsigned iPT = off >> PGDIR_SHIFT;1051 unsigned iPTE = (off >> PAGE_SHIFT) & PTE_MASK;1050 unsigned iPT = off >> X86_PD_SHIFT; 1051 unsigned iPTE = (off >> PAGE_SHIFT) & X86_PT_MASK; 1052 1052 while (cb > 0 && iPTE < ELEMENTS(CTXALLSUFF(pCur->aPTs[iPT].pPT)->a)) 1053 1053 { -
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r5605 r5629 273 273 && (cr4 & X86_CR4_PSE)) 274 274 GCPhys = (PdeSrc.u & X86_PDE4M_PG_MASK) 275 | ((RTGCPHYS)pvFault & ( PAGE_OFFSET_MASK_BIG^ PAGE_OFFSET_MASK));275 | ((RTGCPHYS)pvFault & (X86_PAGE_4M_OFFSET_MASK ^ PAGE_OFFSET_MASK)); 276 276 else 277 277 { … … 286 286 if (VBOX_SUCCESS(rc)) 287 287 { 288 unsigned iPTESrc = ((RTGCUINTPTR)pvFault >> PAGE_SHIFT) & PTE_MASK;288 unsigned iPTESrc = ((RTGCUINTPTR)pvFault >> PAGE_SHIFT) & X86_PT_MASK; 289 289 if (pPTSrc->a[iPTESrc].n.u1Present) 290 290 GCPhys = pPTSrc->a[iPTESrc].u & X86_PTE_PG_MASK; … … 1455 1455 */ 1456 1456 /* Calculate the GC physical address of this 4KB shadow page. */ 1457 RTGCPHYS GCPhys = (PdeSrc.u & X86_PDE4M_PAE_PG_MASK) | ((RTGCUINTPTR)GCPtrPage & PAGE_OFFSET_MASK_BIG);1457 RTGCPHYS GCPhys = (PdeSrc.u & X86_PDE4M_PAE_PG_MASK) | ((RTGCUINTPTR)GCPtrPage & X86_PAGE_4M_OFFSET_MASK); 1458 1458 /* Find ram range. */ 1459 1459 PPGMPAGE pPage; … … 1696 1696 if (VBOX_SUCCESS(rc)) 1697 1697 { 1698 PVBOXPTE pPteSrc = &pPTSrc->a[(GCPtrPage >> PAGE_SHIFT) & PTE_MASK];1698 PVBOXPTE pPteSrc = &pPTSrc->a[(GCPtrPage >> PAGE_SHIFT) & X86_PT_MASK]; 1699 1699 const VBOXPTE PteSrc = *pPteSrc; 1700 1700 if (pPteSrc->n.u1Present) … … 1753 1753 * Real page fault? 1754 1754 */ 1755 PVBOXPTE pPteSrc = &pPTSrc->a[(GCPtrPage >> PAGE_SHIFT) & PTE_MASK];1755 PVBOXPTE pPteSrc = &pPTSrc->a[(GCPtrPage >> PAGE_SHIFT) & X86_PT_MASK]; 1756 1756 const VBOXPTE PteSrc = *pPteSrc; 1757 1757 if ( !PteSrc.n.u1Present … … 2614 2614 { 2615 2615 pMapping = pVM->pgm.s.CTXALLSUFF(pMappings); 2616 iPdNoMapping = (pMapping) ? pMapping->GCPtr >> PGDIR_SHIFT : ~0U;2616 iPdNoMapping = (pMapping) ? pMapping->GCPtr >> X86_PD_SHIFT : ~0U; 2617 2617 } 2618 2618 else … … 2645 2645 pPDEDst += cPTs + (PGM_SHW_TYPE != PGM_TYPE_32BIT) * cPTs; 2646 2646 pMapping = pMapping->CTXALLSUFF(pNext); 2647 iPdNoMapping = pMapping ? pMapping->GCPtr >> PGDIR_SHIFT : ~0U;2647 iPdNoMapping = pMapping ? pMapping->GCPtr >> X86_PD_SHIFT : ~0U; 2648 2648 continue; 2649 2649 } … … 2658 2658 */ 2659 2659 pMapping = pVM->pgm.s.pMappingsR3; 2660 while (pMapping && pMapping->GCPtr < (iPD << PGDIR_SHIFT))2660 while (pMapping && pMapping->GCPtr < (iPD << X86_PD_SHIFT)) 2661 2661 pMapping = pMapping->pNextR3; 2662 iPdNoMapping = pMapping ? pMapping->GCPtr >> PGDIR_SHIFT : ~0U;2662 iPdNoMapping = pMapping ? pMapping->GCPtr >> X86_PD_SHIFT : ~0U; 2663 2663 #else 2664 2664 LogFlow(("SyncCR3: detected conflict -> VINF_PGM_SYNC_CR3\n")); … … 2778 2778 /* It's fixed, just skip the mapping. */ 2779 2779 pMapping = pMapping->CTXALLSUFF(pNext); 2780 iPdNoMapping = pMapping ? pMapping->GCPtr >> PGDIR_SHIFT : ~0U;2780 iPdNoMapping = pMapping ? pMapping->GCPtr >> X86_PD_SHIFT : ~0U; 2781 2781 } 2782 2782 else … … 2802 2802 */ 2803 2803 pMapping = pVM->pgm.s.CTXALLSUFF(pMappings); 2804 while (pMapping && pMapping->GCPtr < (iPD << PGDIR_SHIFT))2804 while (pMapping && pMapping->GCPtr < (iPD << X86_PD_SHIFT)) 2805 2805 pMapping = pMapping->CTXALLSUFF(pNext); 2806 iPdNoMapping = pMapping ? pMapping->GCPtr >> PGDIR_SHIFT : ~0U;2806 iPdNoMapping = pMapping ? pMapping->GCPtr >> X86_PD_SHIFT : ~0U; 2807 2807 break; 2808 2808 # else … … 2816 2816 pMapping = pMapping->CTXALLSUFF(pNext); 2817 2817 if (pMapping) 2818 iPdNoMapping = pMapping->GCPtr >> PGDIR_SHIFT;2818 iPdNoMapping = pMapping->GCPtr >> X86_PD_SHIFT; 2819 2819 } 2820 2820 } -
trunk/src/VBox/VMM/VMMAll/PGMAllMap.cpp
r4071 r5629 83 83 { 84 84 RTGCUINTPTR off = GCPtr - pCur->GCPtr; 85 const unsigned iPT = off >> PGDIR_SHIFT;86 const unsigned iPageNo = (off >> PAGE_SHIFT) & PTE_MASK;85 const unsigned iPT = off >> X86_PD_SHIFT; 86 const unsigned iPageNo = (off >> PAGE_SHIFT) & X86_PT_MASK; 87 87 88 88 /* 32-bit */ … … 183 183 while (cb > 0) 184 184 { 185 unsigned iPT = off >> PGDIR_SHIFT;186 unsigned iPTE = (off >> PAGE_SHIFT) & PTE_MASK;185 unsigned iPT = off >> X86_PD_SHIFT; 186 unsigned iPTE = (off >> PAGE_SHIFT) & X86_PT_MASK; 187 187 while (cb > 0 && iPTE < ELEMENTS(CTXALLSUFF(pCur->aPTs[iPT].pPT)->a)) 188 188 { -
trunk/src/VBox/VMM/VMMAll/PGMAllShw.h
r4071 r5629 185 185 AssertMsgReturn(pMap, ("GCPtr=%VGv\n", GCPtr), VERR_INTERNAL_ERROR); 186 186 #if PGM_SHW_TYPE == PGM_TYPE_32BIT 187 pPT = pMap->aPTs[(GCPtr - pMap->GCPtr) >> PGDIR_SHIFT].CTXALLSUFF(pPT);187 pPT = pMap->aPTs[(GCPtr - pMap->GCPtr) >> X86_PD_SHIFT].CTXALLSUFF(pPT); 188 188 #else /* PAE and AMD64: */ 189 pPT = pMap->aPTs[(GCPtr - pMap->GCPtr) >> PGDIR_SHIFT].CTXALLSUFF(paPaePTs);189 pPT = pMap->aPTs[(GCPtr - pMap->GCPtr) >> X86_PD_SHIFT].CTXALLSUFF(paPaePTs); 190 190 #endif 191 191 }
Note:
See TracChangeset
for help on using the changeset viewer.