VirtualBox

Changeset 9228 in vbox for trunk/src/VBox/VMM/PATM/VMMGC


Ignore:
Timestamp:
May 29, 2008 3:23:15 PM (17 years ago)
Author:
vboxsync
Message:

More updates for 64 bits guest pointers. Introduced AVLOU32TREE.

Location:
trunk/src/VBox/VMM/PATM/VMMGC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PATM/VMMGC/CSAMGC.cpp

    r9220 r9228  
    6666{
    6767    PPATMGCSTATE pPATMGCState;
    68     bool         fPatchCode = PATMIsPatchGCAddr(pVM, (RTGCPTR32)pRegFrame->eip);
     68    bool         fPatchCode = PATMIsPatchGCAddr(pVM, (RTRCPTR)pRegFrame->eip);
    6969    int          rc;
    7070
     
    103103    if (cpl != 3)
    104104    {
    105         rc = PATMGCHandleWriteToPatchPage(pVM, pRegFrame, (RTGCPTR32)((RTGCUINTPTR)pvRange + offRange), 4 /** @todo */);
     105        rc = PATMGCHandleWriteToPatchPage(pVM, pRegFrame, (RTRCPTR)((RTRCUINTPTR)pvRange + offRange), 4 /** @todo */);
    106106        if (rc == VINF_SUCCESS)
    107107            return rc;
  • trunk/src/VBox/VMM/PATM/VMMGC/PATMGC.cpp

    r9220 r9228  
    6565PATMGCDECL(int) PATMGCMonitorPage(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange)
    6666{
    67     pVM->patm.s.pvFaultMonitor = (RTGCPTR32)pvFault;
     67    pVM->patm.s.pvFaultMonitor = (RTRCPTR)pvFault;
    6868    return VINF_PATM_CHECK_PATCH_PAGE;
    6969}
     
    8181 *
    8282 */
    83 PATMGCDECL(int) PATMGCHandleWriteToPatchPage(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR32 GCPtr, uint32_t cbWrite)
     83PATMGCDECL(int) PATMGCHandleWriteToPatchPage(PVM pVM, PCPUMCTXCORE pRegFrame, RTRCPTR GCPtr, uint32_t cbWrite)
    8484{
    8585    RTGCUINTPTR          pWritePageStart, pWritePageEnd;
     
    9797    pWritePageEnd   = ((RTGCUINTPTR)GCPtr + cbWrite - 1) & PAGE_BASE_GC_MASK;
    9898
    99     pPatchPage = (PPATMPATCHPAGE)RTAvloGCPtrGet(CTXSUFF(&pVM->patm.s.PatchLookupTree)->PatchTreeByPage, (RTGCPTR32)pWritePageStart);
     99    pPatchPage = (PPATMPATCHPAGE)RTAvloU32Get(CTXSUFF(&pVM->patm.s.PatchLookupTree)->PatchTreeByPage, (AVLOU32KEY)pWritePageStart);
    100100    if (    !pPatchPage
    101101        &&  pWritePageStart != pWritePageEnd
    102102       )
    103103    {
    104         pPatchPage = (PPATMPATCHPAGE)RTAvloGCPtrGet(CTXSUFF(&pVM->patm.s.PatchLookupTree)->PatchTreeByPage, (RTGCPTR32)pWritePageEnd);
     104        pPatchPage = (PPATMPATCHPAGE)RTAvloU32Get(CTXSUFF(&pVM->patm.s.PatchLookupTree)->PatchTreeByPage, (AVLOU32KEY)pWritePageEnd);
    105105    }
    106106
    107107#ifdef LOG_ENABLED
    108108    if (pPatchPage)
    109         Log(("PATMIsWriteToPatchPage: Found page %VGv 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));
    110110#endif
    111111
    112112    if (pPatchPage)
    113113    {
    114         if (    pPatchPage->pLowestAddrGC  > (RTGCPTR32)((RTGCUINTPTR)GCPtr + cbWrite - 1)
    115             ||  pPatchPage->pHighestAddrGC < (RTGCPTR32)GCPtr)
     114        if (    pPatchPage->pLowestAddrGC  > (RTRCPTR)((RTGCUINTPTR)GCPtr + cbWrite - 1)
     115            ||  pPatchPage->pHighestAddrGC < (RTRCPTR)GCPtr)
    116116        {
    117117            /* This part of the page was not patched; try to emulate the instruction. */
    118118            uint32_t cb;
    119119
    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);
    122122            if (rc == VINF_SUCCESS)
    123123            {
     
    162162    /* Very important check -> otherwise we have a security leak. */
    163163    AssertReturn(!pRegFrame->eflags.Bits.u1VM && (pRegFrame->ss & X86_SEL_RPL) == 1, VERR_ACCESS_DENIED);
    164     Assert(PATMIsPatchGCAddr(pVM, (RTGCPTR32)pRegFrame->eip));
     164    Assert(PATMIsPatchGCAddr(pVM, (RTRCPTR)pRegFrame->eip));
    165165
    166166    /* OP_ILLUD2 in PATM generated code? */
    167167    if (CTXSUFF(pVM->patm.s.pGCState)->uPendingAction)
    168168    {
    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));
    170170
    171171        /* Private PATM interface (@todo hack due to lack of anything generic). */
     
    188188                 *  edi = PATCHJUMPTABLE ptr
    189189                 */
    190                 AssertMsg(!pRegFrame->edi || PATMIsPatchGCAddr(pVM, (RTGCPTR32)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, (RTGCPTR32)(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));
    195195                if (pRec)
    196196                {
     
    198198                    {
    199199                        RTGCUINTPTR pRelAddr = pRec->patch.pPatchBlockOffset;   /* make it relative */
    200                         rc = PATMAddBranchToLookupCache(pVM, (RTGCPTR32)pRegFrame->edi, (RTGCPTR32)pRegFrame->edx, pRelAddr);
     200                        rc = PATMAddBranchToLookupCache(pVM, (RTRCPTR)pRegFrame->edi, (RTRCPTR)pRegFrame->edx, pRelAddr);
    201201                        if (rc == VINF_SUCCESS)
    202202                        {
     
    236236                 *  edi = GC address to jump to
    237237                 */
    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));
    239239
    240240                /* Change EIP to the guest address the patch would normally jump to after setting IF. */
     
    262262                 *  edi = GC address to jump to
    263263                 */
    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));
    265265                Assert(pVM->patm.s.CTXSUFF(pGCState)->Restore.uFlags == (PATM_RESTORE_EAX|PATM_RESTORE_ECX|PATM_RESTORE_EDI));
    266266                Assert(pVM->patm.s.CTXSUFF(pGCState)->fPIF == 0);
     
    281281            case PATM_ACTION_DO_V86_IRET:
    282282            {
    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));
    284284                Assert(pVM->patm.s.CTXSUFF(pGCState)->Restore.uFlags == (PATM_RESTORE_EAX|PATM_RESTORE_ECX));
    285285                Assert(pVM->patm.s.CTXSUFF(pGCState)->fPIF == 0);
     
    306306#ifdef DEBUG
    307307            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) ));
    309309                pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE;
    310310                return VINF_SUCCESS;
    311311
    312312            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) ));
    314314                pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE;
    315315                return VINF_SUCCESS;
    316316
    317317            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)));
    319319                pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE;
    320320                return VINF_SUCCESS;
    321321
    322322            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)));
    324324                pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE;
    325325                return VINF_SUCCESS;
    326326
    327327            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) ));
    329329                pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE;
    330330                return VINF_SUCCESS;
    331331
    332332            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));
    334334                pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE;
    335335                return VINF_SUCCESS;
     
    362362                            if (rc == VINF_SUCCESS)
    363363                            {
    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));
    365365                                Log(("PATMGC: IRET->VM stack frame: DS=%04X ES=%04X FS=%04X GS=%04X\n", selDS, selES, selFS, selGS));
    366366                            }
    367367                        }
    368368                        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));
    370370                    }
    371371                    else
    372                         Log(("PATMGC: IRET stack frame: return address %04X:%VGv eflags=%08x\n", selCS, eip, uEFlags));
     372                        Log(("PATMGC: IRET stack frame: return address %04X:%x eflags=%08x\n", selCS, eip, uEFlags));
    373373                }
    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));
    375375                pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE;
    376376                return VINF_SUCCESS;
     
    404404                            if (rc == VINF_SUCCESS)
    405405                            {
    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));
    407407                                Log(("PATMGC: GATE->VM stack frame: DS=%04X ES=%04X FS=%04X GS=%04X\n", selDS, selES, selFS, selGS));
    408408                            }
    409409                        }
    410410                        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));
    412412                    }
    413413                    else
    414                         Log(("PATMGC: GATE stack frame: return address %04X:%VGv eflags=%08x\n", selCS, eip, uEFlags));
     414                        Log(("PATMGC: GATE stack frame: return address %04X:%x eflags=%08x\n", selCS, eip, uEFlags));
    415415                }
    416416                pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE;
     
    419419
    420420            case PATM_ACTION_LOG_RET:
    421                 Log(("PATMGC: RET to %VGv ESP=%VGv iopl=%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)));
    422422                pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE;
    423423                return VINF_SUCCESS;
    424424
    425425            case PATM_ACTION_LOG_CALL:
    426                 Log(("PATMGC: CALL to %VGv return addr %VGv ESP=%VGv 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)));
     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)));
    427427                pRegFrame->eip += PATM_ILLEGAL_INSTR_SIZE;
    428428                return VINF_SUCCESS;
     
    437437        CTXSUFF(pVM->patm.s.pGCState)->uPendingAction = 0;
    438438    }
    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));
    440440    return VINF_EM_RAW_EMULATE_INSTR;
    441441}
     
    457457
    458458    /* Int 3 in PATM generated code? (most common case) */
    459     if (PATMIsPatchGCAddr(pVM, (RTGCPTR32)pRegFrame->eip))
     459    if (PATMIsPatchGCAddr(pVM, (RTRCPTR)pRegFrame->eip))
    460460    {
    461461        /* @note hardcoded assumption about it being a single byte int 3 instruction. */
     
    465465
    466466    /** @todo could use simple caching here to speed things up. */
    467     pRec = (PPATMPATCHREC)RTAvloGCPtrGet(&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 */
    468468    if (pRec && pRec->patch.uState == PATCH_ENABLED)
    469469    {
     
    487487            PATM_STAT_RUN_INC(&pRec->patch);
    488488
    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));
    490490
    491491            switch(pRec->patch.opcode)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette