Changeset 9228 in vbox for trunk/src/VBox/VMM/PATM/VMMGC
- Timestamp:
- May 29, 2008 3:23:15 PM (17 years ago)
- Location:
- trunk/src/VBox/VMM/PATM/VMMGC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PATM/VMMGC/CSAMGC.cpp
r9220 r9228 66 66 { 67 67 PPATMGCSTATE pPATMGCState; 68 bool fPatchCode = PATMIsPatchGCAddr(pVM, (RT GCPTR32)pRegFrame->eip);68 bool fPatchCode = PATMIsPatchGCAddr(pVM, (RTRCPTR)pRegFrame->eip); 69 69 int rc; 70 70 … … 103 103 if (cpl != 3) 104 104 { 105 rc = PATMGCHandleWriteToPatchPage(pVM, pRegFrame, (RT GCPTR32)((RTGCUINTPTR)pvRange + offRange), 4 /** @todo */);105 rc = PATMGCHandleWriteToPatchPage(pVM, pRegFrame, (RTRCPTR)((RTRCUINTPTR)pvRange + offRange), 4 /** @todo */); 106 106 if (rc == VINF_SUCCESS) 107 107 return rc; -
trunk/src/VBox/VMM/PATM/VMMGC/PATMGC.cpp
r9220 r9228 65 65 PATMGCDECL(int) PATMGCMonitorPage(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange) 66 66 { 67 pVM->patm.s.pvFaultMonitor = (RT GCPTR32)pvFault;67 pVM->patm.s.pvFaultMonitor = (RTRCPTR)pvFault; 68 68 return VINF_PATM_CHECK_PATCH_PAGE; 69 69 } … … 81 81 * 82 82 */ 83 PATMGCDECL(int) PATMGCHandleWriteToPatchPage(PVM pVM, PCPUMCTXCORE pRegFrame, RT GCPTR32GCPtr, uint32_t cbWrite)83 PATMGCDECL(int) PATMGCHandleWriteToPatchPage(PVM pVM, PCPUMCTXCORE pRegFrame, RTRCPTR GCPtr, uint32_t cbWrite) 84 84 { 85 85 RTGCUINTPTR pWritePageStart, pWritePageEnd; … … 97 97 pWritePageEnd = ((RTGCUINTPTR)GCPtr + cbWrite - 1) & PAGE_BASE_GC_MASK; 98 98 99 pPatchPage = (PPATMPATCHPAGE)RTAvlo GCPtrGet(CTXSUFF(&pVM->patm.s.PatchLookupTree)->PatchTreeByPage, (RTGCPTR32)pWritePageStart);99 pPatchPage = (PPATMPATCHPAGE)RTAvloU32Get(CTXSUFF(&pVM->patm.s.PatchLookupTree)->PatchTreeByPage, (AVLOU32KEY)pWritePageStart); 100 100 if ( !pPatchPage 101 101 && pWritePageStart != pWritePageEnd 102 102 ) 103 103 { 104 pPatchPage = (PPATMPATCHPAGE)RTAvlo GCPtrGet(CTXSUFF(&pVM->patm.s.PatchLookupTree)->PatchTreeByPage, (RTGCPTR32)pWritePageEnd);104 pPatchPage = (PPATMPATCHPAGE)RTAvloU32Get(CTXSUFF(&pVM->patm.s.PatchLookupTree)->PatchTreeByPage, (AVLOU32KEY)pWritePageEnd); 105 105 } 106 106 107 107 #ifdef LOG_ENABLED 108 108 if (pPatchPage) 109 Log(("PATMIsWriteToPatchPage: Found page %V Gv for write to %VGv %d bytes (page low:high %VGv:%VGv\n", pPatchPage->Core.Key, GCPtr, cbWrite, pPatchPage->pLowestAddrGC, pPatchPage->pHighestAddrGC));109 Log(("PATMIsWriteToPatchPage: Found page %VRv for write to %VRv %d bytes (page low:high %VRv:%VRv\n", pPatchPage->Core.Key, GCPtr, cbWrite, pPatchPage->pLowestAddrGC, pPatchPage->pHighestAddrGC)); 110 110 #endif 111 111 112 112 if (pPatchPage) 113 113 { 114 if ( pPatchPage->pLowestAddrGC > (RT GCPTR32)((RTGCUINTPTR)GCPtr + cbWrite - 1)115 || pPatchPage->pHighestAddrGC < (RT GCPTR32)GCPtr)114 if ( pPatchPage->pLowestAddrGC > (RTRCPTR)((RTGCUINTPTR)GCPtr + cbWrite - 1) 115 || pPatchPage->pHighestAddrGC < (RTRCPTR)GCPtr) 116 116 { 117 117 /* This part of the page was not patched; try to emulate the instruction. */ 118 118 uint32_t cb; 119 119 120 LogFlow(("PATMHandleWriteToPatchPage: Interpret % VGv accessing %VGv\n", pRegFrame->eip, GCPtr));121 int rc = EMInterpretInstruction(pVM, pRegFrame, GCPtr, &cb);120 LogFlow(("PATMHandleWriteToPatchPage: Interpret %x accessing %VRv\n", pRegFrame->eip, GCPtr)); 121 int rc = EMInterpretInstruction(pVM, pRegFrame, (RTGCPTR)GCPtr, &cb); 122 122 if (rc == VINF_SUCCESS) 123 123 { … … 162 162 /* Very important check -> otherwise we have a security leak. */ 163 163 AssertReturn(!pRegFrame->eflags.Bits.u1VM && (pRegFrame->ss & X86_SEL_RPL) == 1, VERR_ACCESS_DENIED); 164 Assert(PATMIsPatchGCAddr(pVM, (RT GCPTR32)pRegFrame->eip));164 Assert(PATMIsPatchGCAddr(pVM, (RTRCPTR)pRegFrame->eip)); 165 165 166 166 /* OP_ILLUD2 in PATM generated code? */ 167 167 if (CTXSUFF(pVM->patm.s.pGCState)->uPendingAction) 168 168 { 169 LogFlow(("PATMGC: Pending action %x at % VGv\n", CTXSUFF(pVM->patm.s.pGCState)->uPendingAction, pRegFrame->eip));169 LogFlow(("PATMGC: Pending action %x at %x\n", CTXSUFF(pVM->patm.s.pGCState)->uPendingAction, pRegFrame->eip)); 170 170 171 171 /* Private PATM interface (@todo hack due to lack of anything generic). */ … … 188 188 * edi = PATCHJUMPTABLE ptr 189 189 */ 190 AssertMsg(!pRegFrame->edi || PATMIsPatchGCAddr(pVM, (RT GCPTR32)pRegFrame->edi), ("edx = %VGv\n", pRegFrame->edi));191 192 Log(("PATMGC: lookup % VGv jump table=%VGv\n", pRegFrame->edx, pRegFrame->edi));193 194 pRec = PATMQueryFunctionPatch(pVM, (RT GCPTR32)(pRegFrame->edx));190 AssertMsg(!pRegFrame->edi || PATMIsPatchGCAddr(pVM, (RTRCPTR)pRegFrame->edi), ("edx = %x\n", pRegFrame->edi)); 191 192 Log(("PATMGC: lookup %x jump table=%x\n", pRegFrame->edx, pRegFrame->edi)); 193 194 pRec = PATMQueryFunctionPatch(pVM, (RTRCPTR)(pRegFrame->edx)); 195 195 if (pRec) 196 196 { … … 198 198 { 199 199 RTGCUINTPTR pRelAddr = pRec->patch.pPatchBlockOffset; /* make it relative */ 200 rc = PATMAddBranchToLookupCache(pVM, (RT GCPTR32)pRegFrame->edi, (RTGCPTR32)pRegFrame->edx, pRelAddr);200 rc = PATMAddBranchToLookupCache(pVM, (RTRCPTR)pRegFrame->edi, (RTRCPTR)pRegFrame->edx, pRelAddr); 201 201 if (rc == VINF_SUCCESS) 202 202 { … … 236 236 * edi = GC address to jump to 237 237 */ 238 Log(("PATMGC: Dispatch pending interrupt; eip=% VGv->%VGv\n", pRegFrame->eip, pRegFrame->edi));238 Log(("PATMGC: Dispatch pending interrupt; eip=%x->%x\n", pRegFrame->eip, pRegFrame->edi)); 239 239 240 240 /* Change EIP to the guest address the patch would normally jump to after setting IF. */ … … 262 262 * edi = GC address to jump to 263 263 */ 264 Log(("PATMGC: Dispatch pending interrupt (iret); eip=% VGv->%VGv\n", pRegFrame->eip, pRegFrame->edi));264 Log(("PATMGC: Dispatch pending interrupt (iret); eip=%x->%x\n", pRegFrame->eip, pRegFrame->edi)); 265 265 Assert(pVM->patm.s.CTXSUFF(pGCState)->Restore.uFlags == (PATM_RESTORE_EAX|PATM_RESTORE_ECX|PATM_RESTORE_EDI)); 266 266 Assert(pVM->patm.s.CTXSUFF(pGCState)->fPIF == 0); … … 281 281 case PATM_ACTION_DO_V86_IRET: 282 282 { 283 Log(("PATMGC: Do iret to V86 code; eip=% VGv\n", pRegFrame->eip));283 Log(("PATMGC: Do iret to V86 code; eip=%x\n", pRegFrame->eip)); 284 284 Assert(pVM->patm.s.CTXSUFF(pGCState)->Restore.uFlags == (PATM_RESTORE_EAX|PATM_RESTORE_ECX)); 285 285 Assert(pVM->patm.s.CTXSUFF(pGCState)->fPIF == 0); … … 306 306 #ifdef DEBUG 307 307 case PATM_ACTION_LOG_CLI: 308 Log(("PATMGC: CLI at % VGv(current IF=%d iopl=%d)\n", pRegFrame->eip, !!(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags & X86_EFL_IF), X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags) ));308 Log(("PATMGC: CLI at %x (current IF=%d iopl=%d)\n", pRegFrame->eip, !!(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags & X86_EFL_IF), X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags) )); 309 309 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE; 310 310 return VINF_SUCCESS; 311 311 312 312 case PATM_ACTION_LOG_STI: 313 Log(("PATMGC: STI at % VGv(current IF=%d iopl=%d)\n", pRegFrame->eip, !!(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags & X86_EFL_IF), X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags) ));313 Log(("PATMGC: STI at %x (current IF=%d iopl=%d)\n", pRegFrame->eip, !!(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags & X86_EFL_IF), X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags) )); 314 314 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE; 315 315 return VINF_SUCCESS; 316 316 317 317 case PATM_ACTION_LOG_POPF_IF1: 318 Log(("PATMGC: POPF setting IF at % VGv(current IF=%d iopl=%d)\n", pRegFrame->eip, !!(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags & X86_EFL_IF), X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags)));318 Log(("PATMGC: POPF setting IF at %x (current IF=%d iopl=%d)\n", pRegFrame->eip, !!(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags & X86_EFL_IF), X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags))); 319 319 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE; 320 320 return VINF_SUCCESS; 321 321 322 322 case PATM_ACTION_LOG_POPF_IF0: 323 Log(("PATMGC: POPF at % VGv(current IF=%d iopl=%d)\n", pRegFrame->eip, !!(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags & X86_EFL_IF), X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags)));323 Log(("PATMGC: POPF at %x (current IF=%d iopl=%d)\n", pRegFrame->eip, !!(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags & X86_EFL_IF), X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags))); 324 324 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE; 325 325 return VINF_SUCCESS; 326 326 327 327 case PATM_ACTION_LOG_PUSHF: 328 Log(("PATMGC: PUSHF at % VGv(current IF=%d iopl=%d)\n", pRegFrame->eip, !!(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags & X86_EFL_IF), X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags) ));328 Log(("PATMGC: PUSHF at %x (current IF=%d iopl=%d)\n", pRegFrame->eip, !!(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags & X86_EFL_IF), X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags) )); 329 329 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE; 330 330 return VINF_SUCCESS; 331 331 332 332 case PATM_ACTION_LOG_IF1: 333 Log(("PATMGC: IF=1 escape from % VGv\n", pRegFrame->eip));333 Log(("PATMGC: IF=1 escape from %x\n", pRegFrame->eip)); 334 334 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE; 335 335 return VINF_SUCCESS; … … 362 362 if (rc == VINF_SUCCESS) 363 363 { 364 Log(("PATMGC: IRET->VM stack frame: return address %04X:% VGv eflags=%08x ss:esp=%04X:%VGv\n", selCS, eip, uEFlags, selSS, esp));364 Log(("PATMGC: IRET->VM stack frame: return address %04X:%x eflags=%08x ss:esp=%04X:%x\n", selCS, eip, uEFlags, selSS, esp)); 365 365 Log(("PATMGC: IRET->VM stack frame: DS=%04X ES=%04X FS=%04X GS=%04X\n", selDS, selES, selFS, selGS)); 366 366 } 367 367 } 368 368 else 369 Log(("PATMGC: IRET stack frame: return address %04X:% VGv eflags=%08x ss:esp=%04X:%VGv\n", selCS, eip, uEFlags, selSS, esp));369 Log(("PATMGC: IRET stack frame: return address %04X:%x eflags=%08x ss:esp=%04X:%x\n", selCS, eip, uEFlags, selSS, esp)); 370 370 } 371 371 else 372 Log(("PATMGC: IRET stack frame: return address %04X:% VGveflags=%08x\n", selCS, eip, uEFlags));372 Log(("PATMGC: IRET stack frame: return address %04X:%x eflags=%08x\n", selCS, eip, uEFlags)); 373 373 } 374 Log(("PATMGC: IRET from % VGv(IF->1) current eflags=%x\n", pRegFrame->eip, pVM->patm.s.CTXSUFF(pGCState)->uVMFlags));374 Log(("PATMGC: IRET from %x (IF->1) current eflags=%x\n", pRegFrame->eip, pVM->patm.s.CTXSUFF(pGCState)->uVMFlags)); 375 375 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE; 376 376 return VINF_SUCCESS; … … 404 404 if (rc == VINF_SUCCESS) 405 405 { 406 Log(("PATMGC: GATE->VM stack frame: return address %04X:% VGv eflags=%08x ss:esp=%04X:%VGv\n", selCS, eip, uEFlags, selSS, esp));406 Log(("PATMGC: GATE->VM stack frame: return address %04X:%x eflags=%08x ss:esp=%04X:%x\n", selCS, eip, uEFlags, selSS, esp)); 407 407 Log(("PATMGC: GATE->VM stack frame: DS=%04X ES=%04X FS=%04X GS=%04X\n", selDS, selES, selFS, selGS)); 408 408 } 409 409 } 410 410 else 411 Log(("PATMGC: GATE stack frame: return address %04X:% VGv eflags=%08x ss:esp=%04X:%VGv\n", selCS, eip, uEFlags, selSS, esp));411 Log(("PATMGC: GATE stack frame: return address %04X:%x eflags=%08x ss:esp=%04X:%x\n", selCS, eip, uEFlags, selSS, esp)); 412 412 } 413 413 else 414 Log(("PATMGC: GATE stack frame: return address %04X:% VGveflags=%08x\n", selCS, eip, uEFlags));414 Log(("PATMGC: GATE stack frame: return address %04X:%x eflags=%08x\n", selCS, eip, uEFlags)); 415 415 } 416 416 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE; … … 419 419 420 420 case PATM_ACTION_LOG_RET: 421 Log(("PATMGC: RET to % VGv ESP=%VGviopl=%d\n", pRegFrame->edx, pRegFrame->ebx, X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags)));421 Log(("PATMGC: RET to %x ESP=%x iopl=%d\n", pRegFrame->edx, pRegFrame->ebx, X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags))); 422 422 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE; 423 423 return VINF_SUCCESS; 424 424 425 425 case PATM_ACTION_LOG_CALL: 426 Log(("PATMGC: CALL to %V Gv return addr %VGv ESP=%VGviopl=%d\n", pVM->patm.s.CTXSUFF(pGCState)->GCCallPatchTargetAddr, pVM->patm.s.CTXSUFF(pGCState)->GCCallReturnAddr, pRegFrame->edx, X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags)));426 Log(("PATMGC: CALL to %VRv return addr %VRv ESP=%x iopl=%d\n", pVM->patm.s.CTXSUFF(pGCState)->GCCallPatchTargetAddr, pVM->patm.s.CTXSUFF(pGCState)->GCCallReturnAddr, pRegFrame->edx, X86_EFL_GET_IOPL(pVM->patm.s.CTXSUFF(pGCState)->uVMFlags))); 427 427 pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE; 428 428 return VINF_SUCCESS; … … 437 437 CTXSUFF(pVM->patm.s.pGCState)->uPendingAction = 0; 438 438 } 439 AssertMsgFailed(("Unexpected OP_ILLUD2 in patch code at % VGv(pending action %x)!!!!\n", pRegFrame->eip, CTXSUFF(pVM->patm.s.pGCState)->uPendingAction));439 AssertMsgFailed(("Unexpected OP_ILLUD2 in patch code at %x (pending action %x)!!!!\n", pRegFrame->eip, CTXSUFF(pVM->patm.s.pGCState)->uPendingAction)); 440 440 return VINF_EM_RAW_EMULATE_INSTR; 441 441 } … … 457 457 458 458 /* Int 3 in PATM generated code? (most common case) */ 459 if (PATMIsPatchGCAddr(pVM, (RT GCPTR32)pRegFrame->eip))459 if (PATMIsPatchGCAddr(pVM, (RTRCPTR)pRegFrame->eip)) 460 460 { 461 461 /* @note hardcoded assumption about it being a single byte int 3 instruction. */ … … 465 465 466 466 /** @todo could use simple caching here to speed things up. */ 467 pRec = (PPATMPATCHREC)RTAvlo GCPtrGet(&CTXSUFF(pVM->patm.s.PatchLookupTree)->PatchTree, (RTGCPTR32)(pRegFrame->eip - 1)); /* eip is pointing to the instruction *after* 'int 3' already */467 pRec = (PPATMPATCHREC)RTAvloU32Get(&CTXSUFF(pVM->patm.s.PatchLookupTree)->PatchTree, (AVLOU32KEY)(pRegFrame->eip - 1)); /* eip is pointing to the instruction *after* 'int 3' already */ 468 468 if (pRec && pRec->patch.uState == PATCH_ENABLED) 469 469 { … … 487 487 PATM_STAT_RUN_INC(&pRec->patch); 488 488 489 Log(("PATMHandleInt3PatchTrap found int3 for %s at % VGv\n", patmGetInstructionString(pRec->patch.opcode, 0), pRegFrame->eip));489 Log(("PATMHandleInt3PatchTrap found int3 for %s at %x\n", patmGetInstructionString(pRec->patch.opcode, 0), pRegFrame->eip)); 490 490 491 491 switch(pRec->patch.opcode)
Note:
See TracChangeset
for help on using the changeset viewer.