Lines Matching defs:pInstrGC

86     RTRCPTR              pInstrGC;
95 static int patmDisableUnusablePatch(PVM pVM, RTRCPTR pInstrGC, RTRCPTR pConflictAddr, PPATCHINFO pPatch);
100 static bool patmIsCommonIDTHandlerPatch(PVM pVM, RTRCPTR pInstrGC);
113 static RTRCPTR patmR3GuestGCPtrToPatchGCPtrSimple(PVM pVM, RCPTRTYPE(uint8_t*) pInstrGC);
633 || ( PAGE_ADDRESS(pDisInfo->pInstrGC) != PAGE_ADDRESS(uSrcAddr + cbMinRead - 1)
651 pbInstrHC += uSrcAddr - pDisInfo->pInstrGC;
675 disinfo.pInstrGC = InstrGCPtr32;
691 disinfo.pInstrGC = InstrGCPtr32;
708 disinfo.pInstrGC = InstrGCPtr32;
1168 RCPTRTYPE(uint8_t *) pInstrGC;
1178 pInstrGC = patmPatchHCPtr2PatchGCPtr(pVM, pRec->pJumpHC);
1200 pOrgInstrGC = PATMR3PatchToGCPtr(pVM, pInstrGC, 0);
1235 displ = pBranchTargetGC - (pInstrGC + pRec->offDispl + sizeof(RTRCPTR));
1237 Log(("Set branch target %d to %08X : %08x - (%08x + %d + %d)\n", nrJumpRecs, displ, pBranchTargetGC, pInstrGC, pRec->offDispl, sizeof(RTRCPTR)));
1249 * @param pInstrGC Guest context pointer to privileged instruction
1252 static void patmAddIllegalInstrRecord(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC)
1258 pRec->Key = (AVLPVKEY)(uintptr_t)pInstrGC;
1265 static bool patmIsIllegalInstr(PPATCHINFO pPatch, RTRCPTR pInstrGC)
1269 pRec = RTAvlPVGet(&pPatch->pTempInfo->IllegalInstrTree, (AVLPVKEY)(uintptr_t)pInstrGC);
1282 * @param pInstrGC Guest context pointer to privileged instruction
1289 void patmR3AddP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, uint8_t *pPatchInstrHC, RTRCPTR pInstrGC, PATM_LOOKUP_TYPE enmType, bool fDirty)
1296 LogFlowFunc(("pVM=%#p pPatch=%#p pPatchInstrHC=%#p pInstrGC=%#x enmType=%d fDirty=%RTbool\n",
1297 pVM, pPatch, pPatchInstrHC, pInstrGC, enmType, fDirty));
1318 pPatchToGuestRec->pOrgInstrGC = pInstrGC;
1328 pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlU32Get(&pPatch->Guest2PatchAddrTree, pInstrGC);
1332 pGuestToPatchRec->Core.Key = pInstrGC;
1429 * @param pInstrGC Guest context pointer to privileged instruction
1434 static int patmAnalyseBlockCallback(PVM pVM, DISCPUSTATE *pCpu, RCPTRTYPE(uint8_t *) pInstrGC, RCPTRTYPE(uint8_t *) pCurInstrGC, PPATMP2GLOOKUPREC pCacheRec)
1490 if (pCurInstrGC != pInstrGC && pCpu->pCurInstr->uOpcode == OP_PUSHF)
1597 * @param pInstrGC Guest context pointer to privileged instruction
1602 static int patmAnalyseFunctionCallback(PVM pVM, DISCPUSTATE *pCpu, RCPTRTYPE(uint8_t *) pInstrGC, RCPTRTYPE(uint8_t *) pCurInstrGC, PPATMP2GLOOKUPREC pCacheRec)
1606 NOREF(pInstrGC);
1708 * @param pInstrGC Guest context pointer to privileged instruction
1713 static int patmRecompileCallback(PVM pVM, DISCPUSTATE *pCpu, RCPTRTYPE(uint8_t *) pInstrGC, RCPTRTYPE(uint8_t *) pCurInstrGC, PPATMP2GLOOKUPREC pCacheRec)
1719 LogFlow(("patmRecompileCallback %RRv %RRv\n", pInstrGC, pCurInstrGC));
1734 rc = patmAnalyseFunctionCallback(pVM, pCpu, pInstrGC, pCurInstrGC, pCacheRec);
1737 rc = patmAnalyseBlockCallback(pVM, pCpu, pInstrGC, pCurInstrGC, pCacheRec);
1803 if ( pCurInstrGC != pInstrGC
1900 || pReturnInstrGC <= pInstrGC
1901 || pReturnInstrGC - pInstrGC >= SIZEOF_NEARJUMP32
1924 bool fGenerateJmpBack = (pCurInstrGC + pCpu->cbInstr - pInstrGC >= SIZEOF_NEARJUMP32);
2129 && pCurInstrGC + pCpu->cbInstr - pInstrGC >= SIZEOF_NEARJUMP32
2154 * @param pInstrGC Guest context pointer to privileged instruction
2157 static void patmPatchAddDisasmJump(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC)
2163 pRec->Key = (AVLPVKEY)(uintptr_t)pInstrGC;
2174 * @param pInstrGC Jump target
2177 static bool patmIsKnownDisasmJump(PPATCHINFO pPatch, RTRCPTR pInstrGC)
2181 pRec = RTAvlPVGet(&pPatch->pTempInfo->DisasmJumpTree, (AVLPVKEY)(uintptr_t)pInstrGC);
2193 * @param pInstrGC Guest context pointer to privileged instruction
2198 int patmr3DisasmCallback(PVM pVM, DISCPUSTATE *pCpu, RCPTRTYPE(uint8_t *) pInstrGC, RCPTRTYPE(uint8_t *) pCurInstrGC, PPATMP2GLOOKUPREC pCacheRec)
2201 NOREF(pInstrGC);
2250 * @param pInstrGC Guest context pointer to the initial privileged instruction
2256 int patmr3DisasmCode(PVM pVM, RCPTRTYPE(uint8_t *) pInstrGC, RCPTRTYPE(uint8_t *) pCurInstrGC, PFN_PATMR3ANALYSE pfnPATMR3Disasm, PPATMP2GLOOKUPREC pCacheRec)
2308 rc = pfnPATMR3Disasm(pVM, &cpu, pInstrGC, pCurInstrGC, pCacheRec);
2349 rc = patmr3DisasmCode(pVM, pInstrGC, pTargetGC, pfnPATMR3Disasm, pCacheRec);
2376 * @param pInstrGC Guest context pointer to the initial privileged instruction
2382 int patmr3DisasmCodeStream(PVM pVM, RCPTRTYPE(uint8_t *) pInstrGC, RCPTRTYPE(uint8_t *) pCurInstrGC, PFN_PATMR3ANALYSE pfnPATMR3Disasm, PPATMP2GLOOKUPREC pCacheRec)
2386 int rc = patmr3DisasmCode(pVM, pInstrGC, pCurInstrGC, pfnPATMR3Disasm, pCacheRec);
2399 * @param pInstrGC Guest context pointer to instruction
2405 VMMR3_INT_DECL(int) PATMR3DetectConflict(PVM pVM, RTRCPTR pInstrGC, RTRCPTR pConflictGC)
2410 return patmDisableUnusablePatch(pVM, pInstrGC, pConflictGC, pTargetPatch);
2419 * @param pInstrGC Guest context pointer to privileged instruction
2425 static int patmRecompileCodeStream(PVM pVM, RCPTRTYPE(uint8_t *) pInstrGC, RCPTRTYPE(uint8_t *) pCurInstrGC, PFN_PATMR3ANALYSE pfnPATMR3Recompile, PPATMP2GLOOKUPREC pCacheRec)
2463 rc = pfnPATMR3Recompile(pVM, &cpu, pInstrGC, pCurInstrGC, pCacheRec);
2515 rc = pfnPATMR3Recompile(pVM, &cpunext, pInstrGC, pNextInstrGC, pCacheRec);
2554 rc = patmRecompileCodeStream(pVM, pInstrGC, pCurInstrGC+cbInstr, pfnPATMR3Recompile, pCacheRec);
2581 rc = patmRecompileCodeStream(pVM, pInstrGC, addr, pfnPATMR3Recompile, pCacheRec);
2803 * @param pInstrGC Guest context point to privileged instruction
2812 static int patmR3PatchBlock(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC,
2852 && PAGE_ADDRESS(pInstrGC) != PAGE_ADDRESS(pInstrGC + SIZEOF_NEARJUMP32)
2862 pInstrStart = pInstrGC;
2876 rc = patmPatchGenIntEntry(pVM, pPatch, pInstrGC);
2887 rc = patmPatchGenStats(pVM, pPatch, pInstrGC);
2897 rc = patmRecompileCodeStream(pVM, pInstrGC, pInstrGC, patmRecompileCallback, &cacheRec);
3003 Log(("Successfully installed %s patch at %RRv\n", patmGetInstructionString(pPatch->opcode, pPatch->flags), pInstrGC));
3037 * @param pInstrGC Guest context point to privileged instruction
3045 static int patmIdtHandler(PVM pVM, RTRCPTR pInstrGC, uint32_t uOpSize, PPATMPATCHREC pPatchRec, PPATMP2GLOOKUPREC pCacheRec)
3051 RTRCPTR pCurInstrGC = pInstrGC;
3099 rc = patmPatchGenStats(pVM, pPatch, pInstrGC);
3105 rc = patmPatchGenIntEntry(pVM, pPatch, pInstrGC);
3110 patmR3AddP2GLookupRecord(pVM, pPatch, PATCHCODE_PTR_HC(pPatch) + pPatch->uCurPatchOffset, pInstrGC, PATM_LOOKUP_BOTHDIR);
3113 rc = patmPatchGenDuplicate(pVM, pPatch, &cpuPush, pInstrGC);
3139 Log(("Successfully installed IDT handler patch at %RRv\n", pInstrGC));
3160 return patmR3PatchBlock(pVM, pInstrGC, pInstrHC, OP_CLI, uOpSize, pPatchRec);
3168 * @param pInstrGC Guest context point to privileged instruction
3173 static int patmInstallTrapTrampoline(PVM pVM, RTRCPTR pInstrGC, PPATMPATCHREC pPatchRec, PPATMP2GLOOKUPREC pCacheRec)
3188 rc = patmPatchGenStats(pVM, pPatch, pInstrGC);
3193 rc = patmPatchGenTrapEntry(pVM, pPatch, pInstrGC);
3214 Log(("Successfully installed Trap Trampoline patch at %RRv\n", pInstrGC));
3249 * @param pInstrGC Guest context point to the instruction
3252 static bool patmIsCommonIDTHandlerPatch(PVM pVM, RTRCPTR pInstrGC)
3256 pRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
3269 * @param pInstrGC Guest context point to privileged instruction
3274 static int patmDuplicateFunction(PVM pVM, RTRCPTR pInstrGC, PPATMPATCHREC pPatchRec, PPATMP2GLOOKUPREC pCacheRec)
3281 Log(("patmDuplicateFunction %RRv\n", pInstrGC));
3305 rc = patmPatchGenSetPIF(pVM, pPatch, pInstrGC);
3310 rc = patmPatchGenStats(pVM, pPatch, pInstrGC);
3315 rc = patmRecompileCodeStream(pVM, pInstrGC, pInstrGC, patmRecompileCallback, pCacheRec);
3361 Log(("Successfully installed function duplication patch at %RRv\n", pInstrGC));
3392 Log(("patmDupicateFunction %RRv failed!!\n", pInstrGC));
3401 * @param pInstrGC Guest context point to privileged instruction
3405 static int patmCreateTrampoline(PVM pVM, RTRCPTR pInstrGC, PPATMPATCHREC pPatchRec)
3415 Log(("patmCreateTrampoline %RRv\n", pInstrGC));
3421 pPage = pInstrGC & PAGE_BASE_GC_MASK;
3437 pPatchTargetGC = patmGuestGCPtrToPatchGCPtr(pVM, pPatchToJmp, pInstrGC);
3479 rc = patmPatchGenSetPIF(pVM, pPatch, pInstrGC);
3484 rc = patmPatchGenStats(pVM, pPatch, pInstrGC);
3489 rc = patmPatchGenPatchJump(pVM, pPatch, pInstrGC, pPatchTargetGC);
3648 * @param pInstrGC Guest context point to privileged instruction
3652 static int patmReplaceFunctionCall(PVM pVM, DISCPUSTATE *pCpu, RTRCPTR pInstrGC, PPATMP2GLOOKUPREC pCacheRec)
3671 pTargetGC = PATMResolveBranch(pCpu, pInstrGC);
3728 pPatch->pInstrGCLowest = pInstrGC;
3729 pPatch->pInstrGCHighest = pInstrGC + pCpu->cbInstr;
3732 Log(("Successfully installed function replacement patch at %RRv\n", pInstrGC));
3749 * @param pInstrGC Guest context point to privileged instruction
3756 static int patmPatchMMIOInstr(PVM pVM, RTRCPTR pInstrGC, DISCPUSTATE *pCpu, PPATMP2GLOOKUPREC pCacheRec)
3789 rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pInstrGC + pCpu->cbInstr - sizeof(RTRCPTR),
3816 * @param pInstrGC Guest context point to privileged instruction
3822 static int patmPatchPATMMMIOInstr(PVM pVM, RTRCPTR pInstrGC, PPATCHINFO pPatch)
3832 pInstrHC = patmPatchGCPtr2PatchHCPtr(pVM, pInstrGC);
3836 disret = patmR3DisInstrNoStrOpMode(pVM, pPatch, pInstrGC, pInstrHC, PATMREAD_ORGCODE,
3860 pPatch->pInstrGCLowest = pInstrGC;
3861 pPatch->pInstrGCHighest = pInstrGC + cpu.cbInstr;
3920 * @param pInstrGC Guest context point to privileged instruction
3928 int patmR3PatchInstrInt3(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATCHINFO pPatch)
3949 pPatch->pInstrGCLowest = pInstrGC;
3950 pPatch->pInstrGCHighest = pInstrGC + pCpu->cbInstr;
3966 * @param pInstrGC Guest context point to privileged instruction
3974 int patmPatchJump(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATMPATCHREC pPatchRec)
4016 if (PAGE_ADDRESS(pInstrGC) != PAGE_ADDRESS(pInstrGC + pCpu->cbInstr))
4043 RTRCPTR pJmpDest = patmR3GuestGCPtrToPatchGCPtrSimple(pVM, pInstrGC + pCpu->cbInstr + (int32_t)pCpu->Param1.uValue);
4045 AssertMsg(pJmpDest, ("patmR3GuestGCPtrToPatchGCPtrSimple failed for %RRv\n", pInstrGC + pCpu->cbInstr + (int32_t)pCpu->Param1.uValue));
4066 Log(("Successfully installed %s patch at %RRv\n", patmGetInstructionString(pPatch->opcode, pPatch->flags), pInstrGC));
4071 pPatch->pInstrGCLowest = pInstrGC;
4072 pPatch->pInstrGCHighest = pInstrGC + pPatch->cbPatchJump;
4094 VMMR3_INT_DECL(int) PATMR3AddHint(PVM pVM, RTRCPTR pInstrGC, uint32_t flags)
4096 Assert(pInstrGC);
4099 Log(("PATMR3AddHint %RRv\n", pInstrGC));
4100 return PATMR3InstallPatch(pVM, pInstrGC, PATMFL_CODE32 | PATMFL_INSTR_HINT);
4113 VMMR3_INT_DECL(int) PATMR3InstallPatch(PVM pVM, RTRCPTR pInstrGC, uint64_t flags)
4123 LogFlow(("PATMR3InstallPatch: %08x (%#llx)\n", pInstrGC, flags));
4128 || pInstrGC == 0
4141 PPATCHINFO pConflictPatch = patmFindActivePatchByEntrypoint(pVM, pInstrGC);
4142 AssertReleaseMsg(pConflictPatch == 0, ("Unable to patch overwritten instruction at %RRv (%RRv)\n", pInstrGC, pConflictPatch->pPrivInstrGC));
4161 //|| (pInstrGC - 0x80010000U) < 0x10000U // NT4SP1 HAL
4162 //|| (pInstrGC - 0x80010000U) < 0x5000U // NT4SP1 HAL
4163 //|| (pInstrGC - 0x80013000U) < 0x2000U // NT4SP1 HAL
4164 //|| (pInstrGC - 0x80014000U) < 0x1000U // NT4SP1 HAL
4165 //|| (pInstrGC - 0x80014000U) < 0x800U // NT4SP1 HAL
4166 //|| (pInstrGC - 0x80014400U) < 0x400U // NT4SP1 HAL
4167 //|| (pInstrGC - 0x80014400U) < 0x200U // NT4SP1 HAL
4168 //|| (pInstrGC - 0x80014400U) < 0x100U // NT4SP1 HAL
4169 //|| (pInstrGC - 0x80014500U) < 0x100U // NT4SP1 HAL - negative
4170 //|| (pInstrGC - 0x80014400U) < 0x80U // NT4SP1 HAL
4171 //|| (pInstrGC - 0x80014400U) < 0x80U // NT4SP1 HAL
4172 //|| (pInstrGC - 0x80014440U) < 0x40U // NT4SP1 HAL
4173 //|| (pInstrGC - 0x80014440U) < 0x20U // NT4SP1 HAL
4174 || pInstrGC == 0x80014447 /* KfLowerIrql */
4177 Log(("PATMR3InstallPatch: %08x is blacklisted\n", pInstrGC));
4186 RTRCPTR pInstrGCFlat = SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE(pCtx), pInstrGC);
4187 if (pInstrGCFlat != pInstrGC)
4189 Log(("PATMR3InstallPatch: code selector not wide open: %04x:%RRv != %RRv eflags=%08x\n", pCtx->cs.Sel, pInstrGCFlat, pInstrGC, pCtx->eflags.u32));
4198 CSAMR3CheckCode(pVM, pInstrGC);
4202 if ( PATMIsPatchGCAddr(pVM, pInstrGC)
4209 offset = pInstrGC - pVM->patm.s.pPatchMemGC;
4213 AssertMsgFailed(("PATMR3InstallPatch: patch not found at address %RRv!!\n", pInstrGC));
4218 return patmPatchPATMMMIOInstr(pVM, pInstrGC, &pPatchRec->patch);
4221 AssertReturn(!PATMIsPatchGCAddr(pVM, pInstrGC), VERR_PATCHING_REFUSED);
4223 pPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
4244 Log(("Enabling HINTED patch %RRv\n", pInstrGC));
4248 Log(("Enabling patch %RRv again\n", pInstrGC));
4251 rc = PATMR3EnablePatch(pVM, pInstrGC);
4267 Log(("Patch an existing patched instruction?!? (%RRv)\n", pInstrGC));
4276 rc = PATMR3RemovePatch(pVM, pInstrGC);
4282 AssertMsg(pPatchRec->patch.uState == PATCH_REFUSED || pPatchRec->patch.uState == PATCH_UNUSABLE, ("Patch an existing patched instruction?!? (%RRv, state=%d)\n", pInstrGC, pPatchRec->patch.uState));
4289 rc = PGMGstGetPage(pVCpu, pInstrGC, NULL, &GCPhys);
4299 Log(("Code at %RGv (phys %RGp) is in a ROM, MMIO or invalid page - refused\n", pInstrGC, GCPhys));
4308 pInstrHC = patmR3GCVirtToHCVirt(pVM, &cacheRec, pInstrGC);
4318 pPatchRec->Core.Key = pInstrGC;
4324 pPatchRec->patch.pPrivInstrGC = pInstrGC;
4329 pPatchRec->patch.pInstrGCLowest = pInstrGC;
4330 pPatchRec->patch.pInstrGCHighest = pInstrGC;
4337 PPATMPATCHREC pPatchNear = (PPATMPATCHREC)RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, (pInstrGC + SIZEOF_NEARJUMP32 - 1), false);
4340 if (pPatchNear->patch.uState == PATCH_UNUSABLE && pInstrGC < pPatchNear->patch.pPrivInstrGC && pInstrGC + SIZEOF_NEARJUMP32 > pPatchNear->patch.pPrivInstrGC)
4360 disret = patmR3DisInstrNoStrOpMode(pVM, &pPatchRec->patch, pInstrGC, NULL, PATMREAD_ORGCODE, &cpu, &cbInstr);
4393 rc = patmInstallTrapTrampoline(pVM, pInstrGC, pPatchRec, &cacheRec);
4398 rc = patmDuplicateFunction(pVM, pInstrGC, pPatchRec, &cacheRec);
4403 rc = patmCreateTrampoline(pVM, pInstrGC, pPatchRec);
4408 rc = patmReplaceFunctionCall(pVM, &cpu, pInstrGC, &cacheRec);
4413 rc = patmR3PatchInstrInt3(pVM, pInstrGC, pInstrHC, &cpu, &pPatchRec->patch);
4418 rc = patmPatchMMIOInstr(pVM, pInstrGC, &cpu, &cacheRec);
4426 rc = patmIdtHandler(pVM, pInstrGC, cbInstr, pPatchRec, &cacheRec);
4442 rc = patmR3InstallGuestSpecificPatch(pVM, &cpu, pInstrGC, pInstrHC, pPatchRec);
4446 Log(("PATMR3InstallPatch GUEST: %s %RRv code32=%d\n", patmGetInstructionString(pPatchRec->patch.opcode, pPatchRec->patch.flags), pInstrGC, (flags & PATMFL_CODE32) ? 1 : 0));
4461 rc = patmR3InstallGuestSpecificPatch(pVM, &cpu, pInstrGC, pInstrHC, pPatchRec);
4464 Log(("PATMR3InstallPatch GUEST: %s %RRv code32=%d\n", patmGetInstructionString(pPatchRec->patch.opcode, pPatchRec->patch.flags), pInstrGC, (flags & PATMFL_CODE32) ? 1 : 0));
4493 rc = patmPatchJump(pVM, pInstrGC, pInstrHC, &cpu, pPatchRec);
4501 Log(("PATMR3InstallPatch %s %RRv code32=%d\n", patmGetInstructionString(pPatchRec->patch.opcode, pPatchRec->patch.flags), pInstrGC, (flags & PATMFL_CODE32) ? 1 : 0));
4502 rc = patmR3PatchBlock(pVM, pInstrGC, pInstrHC, cpu.pCurInstr->uOpcode, cbInstr, pPatchRec);
4521 rc = patmR3PatchInstrInt3(pVM, pInstrGC, pInstrHC, &cpu, &pPatchRec->patch);
4560 rc = PATMR3DisablePatch(pVM, pInstrGC);
4608 * @param pInstrGC Instruction address
4610 static uint32_t patmGetInstrSize(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC)
4615 int rc = PGMPhysGCPtr2CCPtrReadOnly(VMMGetCpu(pVM), pInstrGC, (const void **)&pInstrHC, &Lock);
4622 disret = patmR3DisInstr(pVM, pPatch, pInstrGC, pInstrHC, PATMREAD_ORGCODE | PATMREAD_NOCHECK, &cpu, &cbInstr);
5100 * @param pInstrGC Guest context pointer to instruction
5102 VMMR3_INT_DECL(bool) PATMR3HasBeenPatched(PVM pVM, RTRCPTR pInstrGC)
5106 pPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
5117 * @param pInstrGC GC address of instr
5121 VMMR3DECL(int) PATMR3QueryOpcode(PVM pVM, RTRCPTR pInstrGC, uint8_t *pByte)
5131 if ( pInstrGC < pVM->patm.s.pPatchedInstrGCLowest
5132 || pInstrGC > pVM->patm.s.pPatchedInstrGCHighest)
5135 pPatchRec = (PPATMPATCHREC)RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC, false);
5139 && pInstrGC >= pPatchRec->patch.pPrivInstrGC
5140 && pInstrGC < pPatchRec->patch.pPrivInstrGC + pPatchRec->patch.cbPatchJump)
5142 RTRCPTR offset = pInstrGC - pPatchRec->patch.pPrivInstrGC;
5147 Log(("PATMR3QueryOpcode: returning opcode %2X for instruction at %RRv\n", *pByte, pInstrGC));
5225 VMMR3_INT_DECL(int) PATMR3DisablePatch(PVM pVM, RTRCPTR pInstrGC)
5230 Log(("PATMR3DisablePatch: %RRv\n", pInstrGC));
5232 pPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
5255 LogRel(("PATM: Disabling IDT %x patch handler %RRv\n", iGate, pInstrGC));
5295 rc = PATMR3RemovePatch(pVM, pInstrGC);
5331 rc = PATMR3RemovePatch(pVM, pInstrGC);
5356 Log(("PATMR3DisablePatch: disabled patch at %RRv\n", pInstrGC));
5373 static int patmDisableUnusablePatch(PVM pVM, RTRCPTR pInstrGC, RTRCPTR pConflictAddr, PPATCHINFO pConflictPatch)
5385 pInstrHC = patmR3GCVirtToHCVirt(pVM, &patch, pInstrGC);
5386 disret = patmR3DisInstr(pVM, &patch, pInstrGC, pInstrHC, PATMREAD_ORGCODE, &cpu, &cbInstr);
5409 rc = PATMR3InstallPatch(pVM, pInstrGC, PATMFL_CODE32 | PATMFL_JUMP_CONFLICT);
5412 Log(("PATM -> CONFLICT: Installed JMP patch for patch conflict at %RRv\n", pInstrGC));
5422 Log(("PATM -> CONFLICT: Found active patch at instruction %RRv with target %RRv -> turn into int 3 patch!!\n", pInstrGC, pConflictPatch->pPrivInstrGC));
5445 Log(("PATM -> CONFLICT: Found active patch at instruction %RRv with target %RRv -> DISABLING it!!\n", pInstrGC, pConflictPatch->pPrivInstrGC));
5472 VMMR3_INT_DECL(int) PATMR3EnablePatch(PVM pVM, RTRCPTR pInstrGC)
5477 Log(("PATMR3EnablePatch %RRv\n", pInstrGC));
5479 pPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
5505 rc = PATMR3RemovePatch(pVM, pInstrGC);
5558 rc = PATMR3RemovePatch(pVM, pInstrGC);
5577 Log(("PATMR3EnablePatch: Unable to enable patch %RRv with state %d\n", pInstrGC, pPatch->uState));
5702 RTRCPTR pInstrGC = pPatchRec->patch.pPrivInstrGC;
5705 Log(("patmR3RefreshPatch: attempt to refresh patch at %RRv\n", pInstrGC));
5731 rc = PATMR3DisablePatch(pVM, pInstrGC);
5747 rc = PATMR3InstallPatch(pVM, pInstrGC, pPatch->flags & (PATMFL_CODE32|PATMFL_IDTHANDLER|PATMFL_INTHANDLER|PATMFL_TRAPHANDLER|PATMFL_DUPLICATE_FUNCTION|PATMFL_TRAPHANDLER_WITH_ERRORCODE|PATMFL_IDTHANDLER_WITHOUT_ENTRYPOINT));
5754 pPatchTargetGC = PATMR3QueryPatchGCPtr(pVM, pInstrGC);
5766 rc = patmPatchGenPatchJump(pVM, pPatch, pInstrGC, pPatchTargetGC, false /* no lookup record */);
5770 pNewPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
5781 Log(("PATM: patmR3RefreshPatch: succeeded to refresh patch at %RRv \n", pInstrGC));
5823 LogRel(("PATM: patmR3RefreshPatch: failed to refresh patch at %RRv. Reactiving old one. \n", pInstrGC));
5826 rc = PATMR3RemovePatch(pVM, pInstrGC);
5834 int rc2 = PATMR3EnablePatch(pVM, pInstrGC);
5851 PPATCHINFO patmFindActivePatchByEntrypoint(PVM pVM, RTRCPTR pInstrGC, bool fIncludeHints)
5853 PPATMPATCHREC pPatchRec = (PPATMPATCHREC)RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC, false);
5859 && pInstrGC > pPatchRec->patch.pPrivInstrGC
5860 && pInstrGC < pPatchRec->patch.pPrivInstrGC + pPatchRec->patch.cbPatchJump)
5862 Log(("Found active patch at %RRv (org %RRv)\n", pInstrGC, pPatchRec->patch.pPrivInstrGC));
5869 && pInstrGC > pPatchRec->patch.pPrivInstrGC
5870 && pInstrGC < pPatchRec->patch.pPrivInstrGC + pPatchRec->patch.cbPatchJump)
5872 Log(("Found HINT patch at %RRv (org %RRv)\n", pInstrGC, pPatchRec->patch.pPrivInstrGC));
5918 VMMR3_INT_DECL(int) PATMR3RemovePatch(PVM pVM, RTRCPTR pInstrGC)
5923 pPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
5926 int rc = PATMR3DisablePatch(pVM, pInstrGC);
6003 * @param pInstrGC Guest context pointer to privileged instruction
6006 RTRCPTR patmGuestGCPtrToPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC)
6010 PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlU32Get(&pPatch->Guest2PatchAddrTree, pInstrGC);
6023 * @param pInstrGC Guest context pointer to privileged instruction
6025 static RTRCPTR patmR3GuestGCPtrToPatchGCPtrSimple(PVM pVM, RCPTRTYPE(uint8_t*) pInstrGC)
6027 PPATMPATCHREC pPatchRec = (PPATMPATCHREC)RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC, false);
6028 if (pPatchRec && pPatchRec->patch.uState == PATCH_ENABLED && pInstrGC >= pPatchRec->patch.pPrivInstrGC)
6029 return patmGuestGCPtrToPatchGCPtr(pVM, &pPatchRec->patch, pInstrGC);
6040 * @param pInstrGC Guest context pointer to privileged instruction
6043 RTRCPTR patmGuestGCPtrToClosestPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC)
6045 PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlU32GetBestFit(&pPatch->Guest2PatchAddrTree, pInstrGC, false);