5952
5952
pCurPatchInstrHC += CpuNew.opsize;
5953
5953
pCurPatchInstrGC += CpuNew.opsize;
5954
5954
cbLeft -= CpuNew.opsize;
5956
/* Check if we expanded a complex guest instruction into a patch stream (e.g. call) */
5959
/* If the next patch instruction doesn't correspond to the next guest instruction, then we have some extra room to fill. */
5960
if (RTAvlU32Get(&pPatch->patch.Patch2GuestAddrTree, pCurPatchInstrGC - pVM->patm.s.pPatchMemGC) == NULL)
5962
pRec = (PRECPATCHTOGUEST)RTAvlU32GetBestFit(&pPatch->patch.Patch2GuestAddrTree, pCurPatchInstrGC - pVM->patm.s.pPatchMemGC, true);
5965
unsigned cbFiller = pRec->Core.Key + pVM->patm.s.pPatchMemGC - pCurPatchInstrGC;
5966
uint8_t *pPatchFillHC = patmPatchGCPtr2PatchHCPtr(pVM, pCurPatchInstrGC);
5968
Assert(!pRec->fDirty);
5970
Log(("Room left in patched instruction stream (%d bytes)\n", cbFiller));
5971
if (cbFiller >= SIZEOF_NEARJUMP32)
5973
pPatchFillHC[0] = 0xE9;
5974
*(uint32_t *)&pPatchFillHC[1] = cbFiller - SIZEOF_NEARJUMP32;
5978
DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pCurPatchInstrGC, 0, szBuf, sizeof(szBuf), NULL);
5979
Log(("FILL: %s\n", szBuf));
5984
for (unsigned i = 0; i < cbFiller; i++)
5986
pPatchFillHC[i] = 0x90; /* NOP */
5990
DBGFR3DisasInstrEx(pVM, pVCpu->idCpu, pCtx->cs, pCurPatchInstrGC, 0, szBuf, sizeof(szBuf), NULL);
5991
Log(("FILL: %s\n", szBuf));