Changeset 7715 in vbox for trunk/src/VBox/VMM/PGM.cpp
- Timestamp:
- Apr 3, 2008 9:03:01 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PGM.cpp
r7700 r7715 54 54 * [..] 55 55 * 56 * Because of guest context mappings requires PDPT Rand PML4 entries to allow56 * Because of guest context mappings requires PDPT and PML4 entries to allow 57 57 * writing on AMD64, the two upper levels will have fixed flags whatever the 58 58 * guest is thinking of using there. So, when shadowing the PD level we will … … 888 888 pVM->pgm.s.GCPhysGstCR3Monitored = NIL_RTGCPHYS; 889 889 pVM->pgm.s.fA20Enabled = true; 890 pVM->pgm.s.pGstPaePDPT RHC= NULL;891 pVM->pgm.s.pGstPaePDPT RGC= 0;890 pVM->pgm.s.pGstPaePDPTHC = NULL; 891 pVM->pgm.s.pGstPaePDPTGC = 0; 892 892 for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.apGstPaePDsHC); i++) 893 893 { … … 1073 1073 pVM->pgm.s.apInterPaePDs[2] = (PX86PDPAE)MMR3PageAlloc(pVM); 1074 1074 pVM->pgm.s.apInterPaePDs[3] = (PX86PDPAE)MMR3PageAlloc(pVM); 1075 pVM->pgm.s.pInterPaePDPT R = (PX86PDPTR)MMR3PageAllocLow(pVM);1076 pVM->pgm.s.pInterPaePDPT R64 = (PX86PDPTR)MMR3PageAllocLow(pVM);1075 pVM->pgm.s.pInterPaePDPT = (PX86PDPT)MMR3PageAllocLow(pVM); 1076 pVM->pgm.s.pInterPaePDPT64 = (PX86PDPT)MMR3PageAllocLow(pVM); 1077 1077 pVM->pgm.s.pInterPaePML4 = (PX86PML4)MMR3PageAllocLow(pVM); 1078 1078 if ( !pVM->pgm.s.pInterPD … … 1085 1085 || !pVM->pgm.s.apInterPaePDs[2] 1086 1086 || !pVM->pgm.s.apInterPaePDs[3] 1087 || !pVM->pgm.s.pInterPaePDPT R1088 || !pVM->pgm.s.pInterPaePDPT R641087 || !pVM->pgm.s.pInterPaePDPT 1088 || !pVM->pgm.s.pInterPaePDPT64 1089 1089 || !pVM->pgm.s.pInterPaePML4) 1090 1090 { … … 1095 1095 pVM->pgm.s.HCPhysInterPD = MMPage2Phys(pVM, pVM->pgm.s.pInterPD); 1096 1096 AssertRelease(pVM->pgm.s.HCPhysInterPD != NIL_RTHCPHYS && !(pVM->pgm.s.HCPhysInterPD & PAGE_OFFSET_MASK)); 1097 pVM->pgm.s.HCPhysInterPaePDPT R = MMPage2Phys(pVM, pVM->pgm.s.pInterPaePDPTR);1098 AssertRelease(pVM->pgm.s.HCPhysInterPaePDPT R != NIL_RTHCPHYS && !(pVM->pgm.s.HCPhysInterPaePDPTR& PAGE_OFFSET_MASK));1097 pVM->pgm.s.HCPhysInterPaePDPT = MMPage2Phys(pVM, pVM->pgm.s.pInterPaePDPT); 1098 AssertRelease(pVM->pgm.s.HCPhysInterPaePDPT != NIL_RTHCPHYS && !(pVM->pgm.s.HCPhysInterPaePDPT & PAGE_OFFSET_MASK)); 1099 1099 pVM->pgm.s.HCPhysInterPaePML4 = MMPage2Phys(pVM, pVM->pgm.s.pInterPaePML4); 1100 1100 AssertRelease(pVM->pgm.s.HCPhysInterPaePML4 != NIL_RTHCPHYS && !(pVM->pgm.s.HCPhysInterPaePML4 & PAGE_OFFSET_MASK)); 1101 1101 1102 1102 /* 1103 * Initialize the pages, setting up the PML4 and PDPT Rfor repetitive 4GB action.1103 * Initialize the pages, setting up the PML4 and PDPT for repetitive 4GB action. 1104 1104 */ 1105 1105 ASMMemZeroPage(pVM->pgm.s.pInterPD); … … 1110 1110 ASMMemZeroPage(pVM->pgm.s.apInterPaePTs[1]); 1111 1111 1112 ASMMemZeroPage(pVM->pgm.s.pInterPaePDPT R);1112 ASMMemZeroPage(pVM->pgm.s.pInterPaePDPT); 1113 1113 for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.apInterPaePDs); i++) 1114 1114 { 1115 1115 ASMMemZeroPage(pVM->pgm.s.apInterPaePDs[i]); 1116 pVM->pgm.s.pInterPaePDPT R->a[i].u = X86_PDPE_P | PGM_PLXFLAGS_PERMANENT1116 pVM->pgm.s.pInterPaePDPT->a[i].u = X86_PDPE_P | PGM_PLXFLAGS_PERMANENT 1117 1117 | MMPage2Phys(pVM, pVM->pgm.s.apInterPaePDs[i]); 1118 1118 } 1119 1119 1120 for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.pInterPaePDPT R64->a); i++)1120 for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.pInterPaePDPT64->a); i++) 1121 1121 { 1122 1122 const unsigned iPD = i % ELEMENTS(pVM->pgm.s.apInterPaePDs); 1123 pVM->pgm.s.pInterPaePDPT R64->a[i].u = X86_PDPE_P | X86_PDPE_RW | X86_PDPE_US | X86_PDPE_A | PGM_PLXFLAGS_PERMANENT1123 pVM->pgm.s.pInterPaePDPT64->a[i].u = X86_PDPE_P | X86_PDPE_RW | X86_PDPE_US | X86_PDPE_A | PGM_PLXFLAGS_PERMANENT 1124 1124 | MMPage2Phys(pVM, pVM->pgm.s.apInterPaePDs[iPD]); 1125 1125 } 1126 1126 1127 RTHCPHYS HCPhysInterPaePDPT R64 = MMPage2Phys(pVM, pVM->pgm.s.pInterPaePDPTR64);1127 RTHCPHYS HCPhysInterPaePDPT64 = MMPage2Phys(pVM, pVM->pgm.s.pInterPaePDPT64); 1128 1128 for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.pInterPaePML4->a); i++) 1129 1129 pVM->pgm.s.pInterPaePML4->a[i].u = X86_PML4E_P | X86_PML4E_RW | X86_PML4E_US | X86_PML4E_A | PGM_PLXFLAGS_PERMANENT 1130 | HCPhysInterPaePDPT R64;1130 | HCPhysInterPaePDPT64; 1131 1131 1132 1132 /* … … 1135 1135 * avoid resource failure during mode switches. So, we need to cover all levels of the 1136 1136 * of the first 4GB down to PD level. 1137 * As with the intermediate context, AMD64 uses the PAE PDPT Rand PDs.1137 * As with the intermediate context, AMD64 uses the PAE PDPT and PDs. 1138 1138 */ 1139 1139 pVM->pgm.s.pHC32BitPD = (PX86PD)MMR3PageAllocLow(pVM); … … 1145 1145 pVM->pgm.s.apHCPaePDs[3] = (PX86PDPAE)MMR3PageAlloc(pVM); 1146 1146 AssertRelease((uintptr_t)pVM->pgm.s.apHCPaePDs[2] + PAGE_SIZE == (uintptr_t)pVM->pgm.s.apHCPaePDs[3]); 1147 pVM->pgm.s.pHCPaePDPT R = (PX86PDPTR)MMR3PageAllocLow(pVM);1147 pVM->pgm.s.pHCPaePDPT = (PX86PDPT)MMR3PageAllocLow(pVM); 1148 1148 pVM->pgm.s.pHCPaePML4 = (PX86PML4)MMR3PageAllocLow(pVM); 1149 1149 if ( !pVM->pgm.s.pHC32BitPD … … 1152 1152 || !pVM->pgm.s.apHCPaePDs[2] 1153 1153 || !pVM->pgm.s.apHCPaePDs[3] 1154 || !pVM->pgm.s.pHCPaePDPT R1154 || !pVM->pgm.s.pHCPaePDPT 1155 1155 || !pVM->pgm.s.pHCPaePML4) 1156 1156 { … … 1166 1166 pVM->pgm.s.aHCPhysPaePDs[2] = MMPage2Phys(pVM, pVM->pgm.s.apHCPaePDs[2]); 1167 1167 pVM->pgm.s.aHCPhysPaePDs[3] = MMPage2Phys(pVM, pVM->pgm.s.apHCPaePDs[3]); 1168 pVM->pgm.s.HCPhysPaePDPT R = MMPage2Phys(pVM, pVM->pgm.s.pHCPaePDPTR);1168 pVM->pgm.s.HCPhysPaePDPT = MMPage2Phys(pVM, pVM->pgm.s.pHCPaePDPT); 1169 1169 pVM->pgm.s.HCPhysPaePML4 = MMPage2Phys(pVM, pVM->pgm.s.pHCPaePML4); 1170 1170 1171 1171 /* 1172 * Initialize the pages, setting up the PML4 and PDPT Rfor action below 4GB.1172 * Initialize the pages, setting up the PML4 and PDPT for action below 4GB. 1173 1173 */ 1174 1174 ASMMemZero32(pVM->pgm.s.pHC32BitPD, PAGE_SIZE); 1175 1175 1176 ASMMemZero32(pVM->pgm.s.pHCPaePDPT R, PAGE_SIZE);1176 ASMMemZero32(pVM->pgm.s.pHCPaePDPT, PAGE_SIZE); 1177 1177 for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.apHCPaePDs); i++) 1178 1178 { 1179 1179 ASMMemZero32(pVM->pgm.s.apHCPaePDs[i], PAGE_SIZE); 1180 pVM->pgm.s.pHCPaePDPT R->a[i].u = X86_PDPE_P | PGM_PLXFLAGS_PERMANENT | pVM->pgm.s.aHCPhysPaePDs[i];1180 pVM->pgm.s.pHCPaePDPT->a[i].u = X86_PDPE_P | PGM_PLXFLAGS_PERMANENT | pVM->pgm.s.aHCPhysPaePDs[i]; 1181 1181 /* The flags will be corrected when entering and leaving long mode. */ 1182 1182 } … … 1184 1184 ASMMemZero32(pVM->pgm.s.pHCPaePML4, PAGE_SIZE); 1185 1185 pVM->pgm.s.pHCPaePML4->a[0].u = X86_PML4E_P | X86_PML4E_RW | X86_PML4E_A 1186 | PGM_PLXFLAGS_PERMANENT | pVM->pgm.s.HCPhysPaePDPT R;1186 | PGM_PLXFLAGS_PERMANENT | pVM->pgm.s.HCPhysPaePDPT; 1187 1187 1188 1188 CPUMSetHyperCR3(pVM, (uint32_t)pVM->pgm.s.HCPhys32BitPD); … … 1227 1227 LogFlow(("pgmR3InitPaging: returns successfully\n")); 1228 1228 #if HC_ARCH_BITS == 64 1229 LogRel(("Debug: HCPhys32BitPD=%VHp aHCPhysPaePDs={%VHp,%VHp,%VHp,%VHp} HCPhysPaePDPT R=%VHp HCPhysPaePML4=%VHp\n",1229 LogRel(("Debug: HCPhys32BitPD=%VHp aHCPhysPaePDs={%VHp,%VHp,%VHp,%VHp} HCPhysPaePDPT=%VHp HCPhysPaePML4=%VHp\n", 1230 1230 pVM->pgm.s.HCPhys32BitPD, pVM->pgm.s.aHCPhysPaePDs[0], pVM->pgm.s.aHCPhysPaePDs[1], pVM->pgm.s.aHCPhysPaePDs[2], pVM->pgm.s.aHCPhysPaePDs[3], 1231 pVM->pgm.s.HCPhysPaePDPT R, pVM->pgm.s.HCPhysPaePML4));1232 LogRel(("Debug: HCPhysInterPD=%VHp HCPhysInterPaePDPT R=%VHp HCPhysInterPaePML4=%VHp\n",1233 pVM->pgm.s.HCPhysInterPD, pVM->pgm.s.HCPhysInterPaePDPT R, pVM->pgm.s.HCPhysInterPaePML4));1234 LogRel(("Debug: apInterPTs={%VHp,%VHp} apInterPaePTs={%VHp,%VHp} apInterPaePDs={%VHp,%VHp,%VHp,%VHp} pInterPaePDPT R64=%VHp\n",1231 pVM->pgm.s.HCPhysPaePDPT, pVM->pgm.s.HCPhysPaePML4)); 1232 LogRel(("Debug: HCPhysInterPD=%VHp HCPhysInterPaePDPT=%VHp HCPhysInterPaePML4=%VHp\n", 1233 pVM->pgm.s.HCPhysInterPD, pVM->pgm.s.HCPhysInterPaePDPT, pVM->pgm.s.HCPhysInterPaePML4)); 1234 LogRel(("Debug: apInterPTs={%VHp,%VHp} apInterPaePTs={%VHp,%VHp} apInterPaePDs={%VHp,%VHp,%VHp,%VHp} pInterPaePDPT64=%VHp\n", 1235 1235 MMPage2Phys(pVM, pVM->pgm.s.apInterPTs[0]), MMPage2Phys(pVM, pVM->pgm.s.apInterPTs[1]), 1236 1236 MMPage2Phys(pVM, pVM->pgm.s.apInterPaePTs[0]), MMPage2Phys(pVM, pVM->pgm.s.apInterPaePTs[1]), 1237 1237 MMPage2Phys(pVM, pVM->pgm.s.apInterPaePDs[0]), MMPage2Phys(pVM, pVM->pgm.s.apInterPaePDs[1]), MMPage2Phys(pVM, pVM->pgm.s.apInterPaePDs[2]), MMPage2Phys(pVM, pVM->pgm.s.apInterPaePDs[3]), 1238 MMPage2Phys(pVM, pVM->pgm.s.pInterPaePDPT R64)));1238 MMPage2Phys(pVM, pVM->pgm.s.pInterPaePDPT64))); 1239 1239 #endif 1240 1240 … … 1321 1321 STAM_REG(pVM, &pPGM->StatGCTrap0eMap, STAMTYPE_COUNTER, "/PGM/GC/Trap0e/GuestPF/Map", STAMUNIT_OCCURENCES, "Number of guest page faults due to map accesses."); 1322 1322 1323 STAM_REG(pVM, &pPGM->StatTrap0eWPEmulGC, STAMTYPE_COUNTER, "/PGM/GC/Trap0e/WP/InGC", STAMUNIT_OCCURENCES, "Number of guest page faults due to X86_CR0_WP emulation."); 1324 STAM_REG(pVM, &pPGM->StatTrap0eWPEmulR3, STAMTYPE_COUNTER, "/PGM/GC/Trap0e/WP/ToR3", STAMUNIT_OCCURENCES, "Number of guest page faults due to X86_CR0_WP emulation (forward to R3 for emulation)."); 1323 1325 1324 1326 STAM_REG(pVM, &pPGM->StatGCGuestCR3WriteHandled, STAMTYPE_COUNTER, "/PGM/GC/CR3WriteInt", STAMUNIT_OCCURENCES, "The number of times the Guest CR3 change was successfully handled."); … … 1524 1526 GCPtr += PAGE_SIZE; /* reserved page */ 1525 1527 1526 rc = PGMMap(pVM, GCPtr, pVM->pgm.s.HCPhysPaePDPT R, PAGE_SIZE, 0);1528 rc = PGMMap(pVM, GCPtr, pVM->pgm.s.HCPhysPaePDPT, PAGE_SIZE, 0); 1527 1529 AssertRCReturn(rc, rc); 1528 pVM->pgm.s.pGCPaePDPT R= GCPtr;1530 pVM->pgm.s.pGCPaePDPT = GCPtr; 1529 1531 GCPtr += PAGE_SIZE; 1530 1532 GCPtr += PAGE_SIZE; /* reserved page */ … … 1587 1589 for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.apGCPaePDs); i++) 1588 1590 pVM->pgm.s.apGCPaePDs[i] += offDelta; 1589 pVM->pgm.s.pGCPaePDPT R+= offDelta;1591 pVM->pgm.s.pGCPaePDPT += offDelta; 1590 1592 pVM->pgm.s.pGCPaePML4 += offDelta; 1591 1593 … … 3152 3154 * @param pHlp Pointer to the output functions. 3153 3155 */ 3154 static int pgmR3DumpHierarchyHCPaePDPT R(PVM pVM, RTHCPHYS HCPhys, uint64_t u64Address, uint32_t cr4, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp)3155 { 3156 PX86PDPT R pPDPTR = (PX86PDPTR)MMPagePhys2Page(pVM, HCPhys);3157 if (!pPDPT R)3156 static int pgmR3DumpHierarchyHCPaePDPT(PVM pVM, RTHCPHYS HCPhys, uint64_t u64Address, uint32_t cr4, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp) 3157 { 3158 PX86PDPT pPDPT = (PX86PDPT)MMPagePhys2Page(pVM, HCPhys); 3159 if (!pPDPT) 3158 3160 { 3159 3161 pHlp->pfnPrintf(pHlp, "%0*llx error! Page directory pointer table at HCPhys=%#VHp was not found in the page pool!\n", … … 3163 3165 3164 3166 int rc = VINF_SUCCESS; 3165 const unsigned c = fLongMode ? ELEMENTS(pPDPT R->a) : X86_PG_PAE_PDPE_ENTRIES;3167 const unsigned c = fLongMode ? ELEMENTS(pPDPT->a) : X86_PG_PAE_PDPE_ENTRIES; 3166 3168 for (unsigned i = 0; i < c; i++) 3167 3169 { 3168 X86PDPE Pdpe = pPDPT R->a[i];3170 X86PDPE Pdpe = pPDPT->a[i]; 3169 3171 if (Pdpe.n.u1Present) 3170 3172 { … … 3172 3174 pHlp->pfnPrintf(pHlp, /*P R S A D G WT CD AT NX 4M a p ? */ 3173 3175 "%016llx 1 | P %c %c %c %c %c %s %s %s %s .. %c%c%c %016llx\n", 3174 u64Address + ((uint64_t)i << X86_PDPT R_SHIFT),3176 u64Address + ((uint64_t)i << X86_PDPT_SHIFT), 3175 3177 Pdpe.n.u1Write ? 'W' : 'R', 3176 3178 Pdpe.n.u1User ? 'U' : 'S', … … 3189 3191 pHlp->pfnPrintf(pHlp, /*P R S A D G WT CD AT NX 4M a p ? */ 3190 3192 "%08x 0 | P %c %c %c %c %c %s %s %s %s .. %c%c%c %016llx\n", 3191 i << X86_PDPT R_SHIFT,3193 i << X86_PDPT_SHIFT, 3192 3194 Pdpe.n.u1Write ? '!' : '.', /* mbz */ 3193 3195 Pdpe.n.u1User ? '!' : '.', /* mbz */ … … 3205 3207 if (cMaxDepth >= 1) 3206 3208 { 3207 int rc2 = pgmR3DumpHierarchyHCPaePD(pVM, Pdpe.u & X86_PDPE_PG_MASK, u64Address + ((uint64_t)i << X86_PDPT R_SHIFT),3209 int rc2 = pgmR3DumpHierarchyHCPaePD(pVM, Pdpe.u & X86_PDPE_PG_MASK, u64Address + ((uint64_t)i << X86_PDPT_SHIFT), 3208 3210 cr4, fLongMode, cMaxDepth - 1, pHlp); 3209 3211 if (rc2 < rc && VBOX_SUCCESS(rc)) … … 3241 3243 if (Pml4e.n.u1Present) 3242 3244 { 3243 uint64_t u64Address = ((uint64_t)i << X86_PML4_SHIFT) | (((uint64_t)i >> (X86_PML4_SHIFT - X86_PDPT R_SHIFT - 1)) * 0xffff000000000000ULL);3245 uint64_t u64Address = ((uint64_t)i << X86_PML4_SHIFT) | (((uint64_t)i >> (X86_PML4_SHIFT - X86_PDPT_SHIFT - 1)) * 0xffff000000000000ULL); 3244 3246 pHlp->pfnPrintf(pHlp, /*P R S A D G WT CD AT NX 4M a p ? */ 3245 3247 "%016llx 0 | P %c %c %c %c %c %s %s %s %s .. %c%c%c %016llx\n", … … 3261 3263 if (cMaxDepth >= 1) 3262 3264 { 3263 int rc2 = pgmR3DumpHierarchyHCPaePDPT R(pVM, Pml4e.u & X86_PML4E_PG_MASK, u64Address, cr4, true, cMaxDepth - 1, pHlp);3265 int rc2 = pgmR3DumpHierarchyHCPaePDPT(pVM, Pml4e.u & X86_PML4E_PG_MASK, u64Address, cr4, true, cMaxDepth - 1, pHlp); 3264 3266 if (rc2 < rc && VBOX_SUCCESS(rc)) 3265 3267 rc = rc2; … … 3597 3599 if (fLongMode) 3598 3600 return pgmR3DumpHierarchyHcPaePML4(pVM, cr3 & X86_CR3_PAGE_MASK, cr4, cMaxDepth, pHlp); 3599 return pgmR3DumpHierarchyHCPaePDPT R(pVM, cr3 & X86_CR3_PAE_PAGE_MASK, 0, cr4, false, cMaxDepth, pHlp);3601 return pgmR3DumpHierarchyHCPaePDPT(pVM, cr3 & X86_CR3_PAE_PAGE_MASK, 0, cr4, false, cMaxDepth, pHlp); 3600 3602 } 3601 3603 return pgmR3DumpHierarchyHC32BitPD(pVM, cr3 & X86_CR3_PAGE_MASK, cr4, cMaxDepth, pHlp);
Note:
See TracChangeset
for help on using the changeset viewer.