Changeset 93 in vbox
- Timestamp:
- Jan 17, 2007 12:57:07 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 17539
- Location:
- trunk/src/VBox/VMM/PATM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PATM/PATM.cpp
r77 r93 1125 1125 PRECPATCHTOGUEST pPatchToGuestRec; 1126 1126 PRECGUESTTOPATCH pGuestToPatchRec; 1127 RTGCUINTPTRPatchOffset = pPatchInstrHC - pVM->patm.s.pPatchMemHC; /* Offset in memory reserved for PATM. */1127 uint32_t PatchOffset = pPatchInstrHC - pVM->patm.s.pPatchMemHC; /* Offset in memory reserved for PATM. */ 1128 1128 1129 1129 if (enmType == PATM_LOOKUP_PATCH2GUEST) 1130 1130 { 1131 pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvl PVGet(&pPatch->Patch2GuestAddrTree, (AVLPVKEY)PatchOffset);1132 if (pPatchToGuestRec && pPatchToGuestRec->Core.Key == (AVLPVKEY)PatchOffset)1131 pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvlU32Get(&pPatch->Patch2GuestAddrTree, PatchOffset); 1132 if (pPatchToGuestRec && pPatchToGuestRec->Core.Key == PatchOffset) 1133 1133 return; /* already there */ 1134 1134 … … 1138 1138 else 1139 1139 { 1140 pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvl PVGet(&pPatch->Patch2GuestAddrTree, (AVLPVKEY)PatchOffset);1140 pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvlU32Get(&pPatch->Patch2GuestAddrTree, PatchOffset); 1141 1141 Assert(!pPatchToGuestRec); 1142 1142 } … … 1145 1145 pPatchToGuestRec = (PRECPATCHTOGUEST)MMR3HeapAllocZ(pVM, MM_TAG_PATM_PATCH, sizeof(RECPATCHTOGUEST) + sizeof(RECGUESTTOPATCH)); 1146 1146 Assert(pPatchToGuestRec); 1147 pPatchToGuestRec->Core.Key = (AVLPVKEY)PatchOffset;1147 pPatchToGuestRec->Core.Key = PatchOffset; 1148 1148 pPatchToGuestRec->pOrgInstrGC = pInstrGC; 1149 1149 pPatchToGuestRec->enmType = enmType; 1150 1150 pPatchToGuestRec->fDirty = fDirty; 1151 1151 1152 ret = RTAvl PVInsert(&pPatch->Patch2GuestAddrTree, &pPatchToGuestRec->Core);1152 ret = RTAvlU32Insert(&pPatch->Patch2GuestAddrTree, &pPatchToGuestRec->Core); 1153 1153 Assert(ret); 1154 1154 … … 1156 1156 if (enmType == PATM_LOOKUP_BOTHDIR) 1157 1157 { 1158 pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlPVGet(&pPatch->Guest2PatchAddrTree, (AVLPVKEY)PatchOffset); 1158 pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlPVGet(&pPatch->Guest2PatchAddrTree, (AVLPVKEY)PatchOffset); /** @todo bird: this doesn't look right. check it out later. */ 1159 1159 if (!pGuestToPatchRec) 1160 1160 { … … 1181 1181 void patmr3RemoveP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, RTGCPTR pPatchInstrGC) 1182 1182 { 1183 PAVLPVNODECORE pNode; 1183 PAVLU32NODECORE pNode; 1184 PAVLPVNODECORE pNode2; 1184 1185 PRECPATCHTOGUEST pPatchToGuestRec; 1185 RTGCUINTPTRPatchOffset = pPatchInstrGC - pVM->patm.s.pPatchMemGC; /* Offset in memory reserved for PATM. */1186 1187 pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvl PVGet(&pPatch->Patch2GuestAddrTree, (AVLPVKEY)PatchOffset);1186 uint32_t PatchOffset = pPatchInstrGC - pVM->patm.s.pPatchMemGC; /* Offset in memory reserved for PATM. */ 1187 1188 pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvlU32Get(&pPatch->Patch2GuestAddrTree, PatchOffset); 1188 1189 Assert(pPatchToGuestRec); 1189 1190 if (pPatchToGuestRec) … … 1194 1195 1195 1196 Assert(pGuestToPatchRec->Core.Key); 1196 pNode = RTAvlPVRemove(&pPatch->Guest2PatchAddrTree, pGuestToPatchRec->Core.Key);1197 Assert(pNode );1198 } 1199 pNode = RTAvl PVRemove(&pPatch->Patch2GuestAddrTree, pPatchToGuestRec->Core.Key);1197 pNode2 = RTAvlPVRemove(&pPatch->Guest2PatchAddrTree, pGuestToPatchRec->Core.Key); 1198 Assert(pNode2); 1199 } 1200 pNode = RTAvlU32Remove(&pPatch->Patch2GuestAddrTree, pPatchToGuestRec->Core.Key); 1200 1201 Assert(pNode); 1201 1202 … … 1206 1207 1207 1208 1208 /* Empty the specified tree (PV tree, MMR3 heap) 1209 /** 1210 * RTAvlPVDestroy callback. 1211 */ 1212 static DECLCALLBACK(int) patmEmptyTreePVCallback(PAVLPVNODECORE pNode, void *) 1213 { 1214 MMR3HeapFree(pNode); 1215 return 0; 1216 } 1217 1218 /** 1219 * Empty the specified tree (PV tree, MMR3 heap) 1209 1220 * 1210 1221 * @param pVM The VM to operate on. … … 1213 1224 void patmEmptyTree(PVM pVM, PAVLPVNODECORE *ppTree) 1214 1225 { 1215 PAVLPVNODECORE pRec; 1216 1217 if (*ppTree == 0) 1218 return; 1219 1220 while (true) 1221 { 1222 pRec = RTAvlPVRemoveBestFit(ppTree, 0, true); 1223 if (pRec) 1224 { 1225 MMR3HeapFree(pRec); 1226 } 1227 else 1228 break; 1229 } 1230 Assert(*ppTree == 0); 1226 RTAvlPVDestroy(ppTree, patmEmptyTreePVCallback, NULL); 1227 } 1228 1229 1230 /** 1231 * RTAvlU32Destroy callback. 1232 */ 1233 static DECLCALLBACK(int) patmEmptyTreeU32Callback(PAVLU32NODECORE pNode, void *) 1234 { 1235 MMR3HeapFree(pNode); 1236 return 0; 1237 } 1238 1239 /** 1240 * Empty the specified tree (U32 tree, MMR3 heap) 1241 * 1242 * @param pVM The VM to operate on. 1243 * @param ppTree Tree to empty 1244 */ 1245 void patmEmptyTreeU32(PVM pVM, PPAVLU32NODECORE ppTree) 1246 { 1247 RTAvlU32Destroy(ppTree, patmEmptyTreeU32Callback, NULL); 1231 1248 } 1232 1249 … … 4243 4260 if (pPatchRec && pPatchRec->patch.nrPatch2GuestRecs) 4244 4261 { 4245 patmEmptyTree (pVM, &pPatchRec->patch.Patch2GuestAddrTree);4262 patmEmptyTreeU32(pVM, &pPatchRec->patch.Patch2GuestAddrTree); 4246 4263 pPatchRec->patch.nrPatch2GuestRecs = 0; 4247 4264 } … … 4644 4661 if (pPatchInstrGC) 4645 4662 { 4646 RTGCUINTPTRPatchOffset = pPatchInstrGC - pVM->patm.s.pPatchMemGC; /* Offset in memory reserved for PATM. */4663 uint32_t PatchOffset = pPatchInstrGC - pVM->patm.s.pPatchMemGC; /* Offset in memory reserved for PATM. */ 4647 4664 4648 4665 fValidPatchWrite = true; 4649 4666 4650 PRECPATCHTOGUEST pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvl PVGet(&pPatch->Patch2GuestAddrTree, (AVLPVKEY)PatchOffset);4667 PRECPATCHTOGUEST pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvlU32Get(&pPatch->Patch2GuestAddrTree, PatchOffset); 4651 4668 Assert(pPatchToGuestRec); 4652 4669 if (pPatchToGuestRec && !pPatchToGuestRec->fDirty) … … 5234 5251 5235 5252 /** @note no need to free Guest2PatchAddrTree as those records share memory with Patch2GuestAddrTree records. */ 5236 patmEmptyTree (pVM, &pPatch->Patch2GuestAddrTree);5253 patmEmptyTreeU32(pVM, &pPatch->Patch2GuestAddrTree); 5237 5254 pPatch->nrPatch2GuestRecs = 0; 5238 5255 Assert(pPatch->Patch2GuestAddrTree == 0); … … 5399 5416 Assert(pPatch->Patch2GuestAddrTree); 5400 5417 /* Get the closest record from below. */ 5401 PRECPATCHTOGUEST pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvl PVGetBestFit(&pPatch->Patch2GuestAddrTree, (AVLPVKEY)(pPatchGC - pVM->patm.s.pPatchMemGC), false);5418 PRECPATCHTOGUEST pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvlU32GetBestFit(&pPatch->Patch2GuestAddrTree, pPatchGC - pVM->patm.s.pPatchMemGC, false); 5402 5419 if (pPatchToGuestRec) 5403 5420 return pPatchToGuestRec->pOrgInstrGC; … … 5601 5618 5602 5619 /* Let's see if there's another dirty instruction right after. */ 5603 pRec = (PRECPATCHTOGUEST)RTAvl PVGetBestFit(&pPatch->patch.Patch2GuestAddrTree, (AVLPVKEY)(pCurPatchInstrGC - pVM->patm.s.pPatchMemGC), true);5620 pRec = (PRECPATCHTOGUEST)RTAvlU32GetBestFit(&pPatch->patch.Patch2GuestAddrTree, pCurPatchInstrGC - pVM->patm.s.pPatchMemGC, true); 5604 5621 if (!pRec || !pRec->fDirty) 5605 5622 break; /* no more dirty instructions */ … … 5753 5770 } 5754 5771 5755 pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvl PVGetBestFit(&pPatch->patch.Patch2GuestAddrTree, (AVLPVKEY)offset, false);5772 pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvlU32GetBestFit(&pPatch->patch.Patch2GuestAddrTree, offset, false); 5756 5773 AssertReleaseMsg(pPatchToGuestRec, ("PATMR3HandleTrap: Unable to find corresponding guest address for %VGv (offset %x)\n", pEip, offset)); 5757 5774 … … 5821 5838 if (pPatchToGuestRec->fDirty) 5822 5839 { 5823 Assert(pPatchToGuestRec->Core.Key == (AVLPVKEY)offset);5840 Assert(pPatchToGuestRec->Core.Key == offset); 5824 5841 Assert(pVM->patm.s.pGCStateHC->fPIF == 1); 5825 5842 -
trunk/src/VBox/VMM/PATM/PATMInternal.h
r23 r93 149 149 typedef struct 150 150 { 151 /** The key is a GC virtual address. */151 /** The key is a pointer to a JUMPREC structure. */ 152 152 AVLPVNODECORE Core; 153 153 … … 173 173 { 174 174 /** The key is an offset inside the patch memory block. */ 175 AVL PVNODECORECore;175 AVLU32NODECORE Core; 176 176 177 177 RTGCPTR pOrgInstrGC; … … 189 189 AVLPVNODECORE Core; 190 190 191 RTGCUINTPTR PatchOffset; 191 /** Patch offset (relative to PATM::pPatchMemGC / PATM::pPatchMemHC). */ 192 uint32_t PatchOffset; 192 193 } RECGUESTTOPATCH, *PRECGUESTTOPATCH; 193 194 … … 257 258 * instruction in the patch block. 258 259 */ 259 HCPTRTYPE(PAVL PVNODECORE) Patch2GuestAddrTree;260 HCPTRTYPE(PAVLU32NODECORE) Patch2GuestAddrTree; 260 261 HCPTRTYPE(PAVLPVNODECORE) Guest2PatchAddrTree; 261 262 uint32_t nrPatch2GuestRecs; … … 609 610 610 611 611 /* Empty the specified tree (PV tree, MMR3 heap) 612 /** 613 * Empty the specified tree (PV tree, MMR3 heap) 612 614 * 613 615 * @param pVM The VM to operate on. 614 616 * @param ppTree Tree to empty 615 617 */ 616 void patmEmptyTree(PVM pVM, PAVLPVNODECORE *ppTree); 618 void patmEmptyTree(PVM pVM, PPAVLPVNODECORE ppTree); 619 620 621 /** 622 * Empty the specified tree (U32 tree, MMR3 heap) 623 * 624 * @param pVM The VM to operate on. 625 * @param ppTree Tree to empty 626 */ 627 void patmEmptyTreeU32(PVM pVM, PPAVLU32NODECORE ppTree); 617 628 618 629 -
trunk/src/VBox/VMM/PATM/PATMSSM.cpp
r23 r93 180 180 #ifdef VBOX_STRICT 181 181 int nrLookupRecords = 0; 182 RTAvl PVDoWithAll(&pPatch->patch.Patch2GuestAddrTree, true, patmCountLeaf, &nrLookupRecords);182 RTAvlU32DoWithAll(&pPatch->patch.Patch2GuestAddrTree, true, patmCountLeaf, &nrLookupRecords); 183 183 Assert(nrLookupRecords == pPatch->patch.nrPatch2GuestRecs); 184 184 #endif 185 185 186 RTAvl PVDoWithAll(&pPatch->patch.Patch2GuestAddrTree, true, patmSaveP2GLookupRecords, pVM);186 RTAvlU32DoWithAll(&pPatch->patch.Patch2GuestAddrTree, true, patmSaveP2GLookupRecords, pVM); 187 187 return VINF_SUCCESS; 188 188 }
Note:
See TracChangeset
for help on using the changeset viewer.