Changeset 12855 in vbox for trunk/src/VBox/VMM/PATM
- Timestamp:
- Oct 1, 2008 9:37:46 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 37231
- Location:
- trunk/src/VBox/VMM/PATM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PATM/PATM.cpp
r12835 r12855 1048 1048 /* Special case: call function replacement patch from this patch block. 1049 1049 */ 1050 if (PATMQueryFunctionPatch(pVM, pRec->pTargetGC) == 0) 1050 PPATMPATCHREC pFunctionRec = PATMQueryFunctionPatch(pVM, pRec->pTargetGC); 1051 if (!pFunctionRec) 1051 1052 { 1052 1053 int rc; … … 1080 1081 } 1081 1082 } 1083 else 1084 { 1085 Log(("Patch block %VRv called as function\n", pFunctionRec->patch.pPrivInstrGC)); 1086 pFunctionRec->patch.flags |= PATMFL_CODE_REFERENCED; 1087 } 1088 1082 1089 pBranchTargetGC = PATMR3QueryPatchGCPtr(pVM, pRec->pTargetGC); 1083 1090 } … … 4079 4086 } 4080 4087 } 4081 PATMR3RemovePatch(pVM, pInstrGC); 4088 rc = PATMR3RemovePatch(pVM, pInstrGC); 4089 if (VBOX_FAILURE(rc)) 4090 return VERR_PATCHING_REFUSED; 4082 4091 } 4083 4092 else … … 4727 4736 Log(("PATMR3PatchWrite: overwriting jump to patch code -> remove patch.\n")); 4728 4737 int rc = PATMR3RemovePatch(pVM, pPatch->pPrivInstrGC); 4729 AssertRC(rc); 4730 4731 /** @note jump back to the start as the pPatchPage has been deleted or changed */ 4732 goto loop_start; 4738 if (rc == VINF_SUCCESS) 4739 /** @note jump back to the start as the pPatchPage has been deleted or changed */ 4740 goto loop_start; 4741 4742 continue; 4733 4743 } 4734 4744 … … 5232 5242 STAM_COUNTER_INC(&pVM->patm.s.StatOverwritten); 5233 5243 /* Remove it completely */ 5234 PATMR3RemovePatch(pVM, pInstrGC); 5244 rc = PATMR3RemovePatch(pVM, pInstrGC); 5245 AssertRC(rc); 5235 5246 return VERR_PATCH_NOT_FOUND; 5236 5247 } … … 5269 5280 Log(("PATMR3EnablePatch: Can't enable a patch who's guest code has changed!!\n")); 5270 5281 STAM_COUNTER_INC(&pVM->patm.s.StatOverwritten); 5271 PATMR3RemovePatch(pVM, pInstrGC); 5282 rc = PATMR3RemovePatch(pVM, pInstrGC); 5283 AssertRC(rc); 5272 5284 return VERR_PATCH_NOT_FOUND; 5273 5285 } … … 5311 5323 5312 5324 /* Strictly forbidden to remove such patches. There can be dependencies!! */ 5313 AssertReturn(fForceRemove || !(pPatch->flags & (PATMFL_DUPLICATE_FUNCTION)), VERR_ACCESS_DENIED); 5325 if (!fForceRemove && (pPatch->flags & (PATMFL_DUPLICATE_FUNCTION|PATMFL_CODE_REFERENCED))) 5326 { 5327 Log(("PATMRemovePatch %VRv REFUSED!\n", pPatch->pPrivInstrGC)); 5328 return VERR_ACCESS_DENIED; 5329 } 5330 Log(("PATMRemovePatch %VRv\n", pPatch->pPrivInstrGC)); 5314 5331 5315 5332 /** @note NEVER EVER REUSE PATCH MEMORY */ … … 5464 5481 LogRel(("PATM: patmR3RefreshPatch: succeeded to refresh patch at %VRv \n", pInstrGC)); 5465 5482 STAM_COUNTER_INC(&pVM->patm.s.StatPatchRefreshSuccess); 5483 5484 /* Used by another patch, so don't remove it! */ 5485 pNewPatchRec->patch.flags |= PATMFL_CODE_REFERENCED; 5466 5486 } 5467 5487 … … 5985 6005 pPatch = PATM_PATCHREC_FROM_COREOFFSET(pvPatchCoreOffset); 5986 6006 6007 Assert(offset >= pPatch->patch.pPatchBlockOffset && offset < pPatch->patch.pPatchBlockOffset + pPatch->patch.cbPatchBlockSize); 6008 5987 6009 if (pPatch->patch.uState == PATCH_DIRTY) 5988 6010 { 5989 6011 Log(("PATMR3HandleTrap: trap in dirty patch at %VRv\n", pEip)); 5990 if (pPatch->patch.flags & (PATMFL_DUPLICATE_FUNCTION|PATMFL_C ALLABLE_AS_FUNCTION))6012 if (pPatch->patch.flags & (PATMFL_DUPLICATE_FUNCTION|PATMFL_CODE_REFERENCED)) 5991 6013 { 5992 6014 /* Function duplication patches set fPIF to 1 on entry */ … … 5998 6020 { 5999 6021 Log(("PATMR3HandleTrap: trap in disabled patch at %VRv\n", pEip)); 6000 if (pPatch->patch.flags & (PATMFL_DUPLICATE_FUNCTION|PATMFL_C ALLABLE_AS_FUNCTION))6022 if (pPatch->patch.flags & (PATMFL_DUPLICATE_FUNCTION|PATMFL_CODE_REFERENCED)) 6001 6023 { 6002 6024 /* Function duplication patches set fPIF to 1 on entry */ -
trunk/src/VBox/VMM/PATM/PATMInternal.h
r12532 r12855 79 79 #define PATMFL_INT3_REPLACEMENT_BLOCK RT_BIT_64(32) /** int 3 replacement block */ 80 80 #define PATMFL_EXTERNAL_JUMP_INSIDE RT_BIT_64(33) /** A trampoline patch was created that jumps to an instruction in the patch block */ 81 #define PATMFL_CODE_REFERENCED RT_BIT_64(34) /** patch block referenced (called, jumped to) by another patch. */ 81 82 82 83 #define SIZEOF_NEARJUMP8 2 //opcode byte + 1 byte relative offset -
trunk/src/VBox/VMM/PATM/VMMGC/PATMGC.cpp
r9659 r12855 201 201 if (rc == VINF_SUCCESS) 202 202 { 203 Log(("Patch block %VRv called as function\n", pRec->patch.pPrivInstrGC)); 204 pRec->patch.flags |= PATMFL_CODE_REFERENCED; 205 203 206 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE; 204 207 pRegFrame->eax = pRelAddr; … … 218 221 else 219 222 { 220 #if 0221 if (pRegFrame->edx == 0x806eca98)222 {223 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE;224 pRegFrame->eax = 0; /* make it fault */225 STAM_COUNTER_INC(&pVM->patm.s.StatFunctionNotFound);226 return VINF_SUCCESS;227 }228 #endif229 223 STAM_COUNTER_INC(&pVM->patm.s.StatFunctionNotFound); 230 224 return VINF_PATM_DUPLICATE_FUNCTION;
Note:
See TracChangeset
for help on using the changeset viewer.