VirtualBox

Changeset 9228 in vbox for trunk/src/VBox


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
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r9166 r9228  
    207207        common/table/avlhcphys.cpp \
    208208        common/table/avllu32.cpp \
     209        common/table/avlou32.cpp \
    209210        common/table/avlogcphys.cpp \
    210211        common/table/avlogcptr.cpp \
     
    12701271        common/string/strprintf.cpp \
    12711272        common/table/avllu32.cpp \
     1273        common/table/avlou32.cpp \
    12721274        common/table/avlogcphys.cpp \
    12731275        common/table/avlogcptr.cpp \
  • trunk/src/VBox/VMM/PATM/CSAM.cpp

    r9220 r9228  
    578578    if (rc != VINF_SUCCESS)
    579579    {
    580 ////        AssertMsgRC(rc, ("MMR3PhysGCVirt2HCVirtEx failed for %VGv\n", pGCPtr));
     580////        AssertMsgRC(rc, ("MMR3PhysGCVirt2HCVirtEx failed for %VRv\n", pGCPtr));
    581581        STAM_PROFILE_STOP(&pVM->csam.s.StatTimeAddrConv, a);
    582582        return NULL;
     
    738738            if (pCurInstrHC == NULL)
    739739            {
    740                 Log(("CSAMGCVirtToHCVirt failed for %VGv\n", pCurInstrGC));
     740                Log(("CSAMGCVirtToHCVirt failed for %VRv\n", pCurInstrGC));
    741741                break;
    742742            }
     
    772772        {
    773773        case OP_STR:
    774             Log(("Privileged instruction at %VGv: str!!\n", pCurInstrGC));
     774            Log(("Privileged instruction at %VRv: str!!\n", pCurInstrGC));
    775775            break;
    776776        case OP_LSL:
    777             Log(("Privileged instruction at %VGv: lsl!!\n", pCurInstrGC));
     777            Log(("Privileged instruction at %VRv: lsl!!\n", pCurInstrGC));
    778778            break;
    779779        case OP_LAR:
    780             Log(("Privileged instruction at %VGv: lar!!\n", pCurInstrGC));
     780            Log(("Privileged instruction at %VRv: lar!!\n", pCurInstrGC));
    781781            break;
    782782        case OP_SGDT:
    783             Log(("Privileged instruction at %VGv: sgdt!!\n", pCurInstrGC));
     783            Log(("Privileged instruction at %VRv: sgdt!!\n", pCurInstrGC));
    784784            break;
    785785        case OP_SLDT:
    786             Log(("Privileged instruction at %VGv: sldt!!\n", pCurInstrGC));
     786            Log(("Privileged instruction at %VRv: sldt!!\n", pCurInstrGC));
    787787            break;
    788788        case OP_SIDT:
    789             Log(("Privileged instruction at %VGv: sidt!!\n", pCurInstrGC));
     789            Log(("Privileged instruction at %VRv: sidt!!\n", pCurInstrGC));
    790790            break;
    791791        case OP_SMSW:
    792             Log(("Privileged instruction at %VGv: smsw!!\n", pCurInstrGC));
     792            Log(("Privileged instruction at %VRv: smsw!!\n", pCurInstrGC));
    793793            break;
    794794        case OP_VERW:
    795             Log(("Privileged instruction at %VGv: verw!!\n", pCurInstrGC));
     795            Log(("Privileged instruction at %VRv: verw!!\n", pCurInstrGC));
    796796            break;
    797797        case OP_VERR:
    798             Log(("Privileged instruction at %VGv: verr!!\n", pCurInstrGC));
     798            Log(("Privileged instruction at %VRv: verr!!\n", pCurInstrGC));
    799799            break;
    800800        case OP_CPUID:
    801             Log(("Privileged instruction at %VGv: cpuid!!\n", pCurInstrGC));
     801            Log(("Privileged instruction at %VRv: cpuid!!\n", pCurInstrGC));
    802802            break;
    803803        case OP_PUSH:
    804             Log(("Privileged instruction at %VGv: push cs!!\n", pCurInstrGC));
     804            Log(("Privileged instruction at %VRv: push cs!!\n", pCurInstrGC));
    805805            break;
    806806        case OP_IRET:
    807             Log(("Privileged instruction at %VGv: iret!!\n", pCurInstrGC));
     807            Log(("Privileged instruction at %VRv: iret!!\n", pCurInstrGC));
    808808            break;
    809809        }
     
    834834            {
    835835            case OP_JMP:
    836                 Log(("Control Flow instruction at %VGv: jmp!!\n", pCurInstrGC));
     836                Log(("Control Flow instruction at %VRv: jmp!!\n", pCurInstrGC));
    837837                break;
    838838            case OP_CALL:
    839                 Log(("Control Flow instruction at %VGv: call!!\n", pCurInstrGC));
     839                Log(("Control Flow instruction at %VRv: call!!\n", pCurInstrGC));
    840840                break;
    841841            }
     
    919919                if (pCurInstrHC == NULL)
    920920                {
    921                     Log(("CSAMGCVirtToHCVirt failed for %VGv\n", pCurInstrGC));
     921                    Log(("CSAMGCVirtToHCVirt failed for %VRv\n", pCurInstrGC));
    922922                    goto done;
    923923                }
     
    935935                if (VBOX_FAILURE(rc2))
    936936                {
    937                     Log(("Disassembly failed at %VGv with %Vrc (probably page not present) -> return to caller\n", pCurInstrGC, rc2));
     937                    Log(("Disassembly failed at %VRv with %Vrc (probably page not present) -> return to caller\n", pCurInstrGC, rc2));
    938938                    goto done;
    939939                }
     
    949949                    {
    950950                        /// @todo fault in the page
    951                         Log(("Page for current instruction %VGv is not present!!\n", pCurInstrGC));
     951                        Log(("Page for current instruction %VRv is not present!!\n", pCurInstrGC));
    952952                        goto done;
    953953                    }
     
    10031003
    10041004                        /* Analyse the function. */
    1005                         Log(("Found new function at %VGv\n", pCurInstrGC));
     1005                        Log(("Found new function at %VRv\n", pCurInstrGC));
    10061006                        STAM_COUNTER_INC(&pVM->csam.s.StatScanNextFunction);
    10071007                        csamAnalyseCallCodeStream(pVM, pInstrGC, pCurInstrGC, fCode32, pfnCSAMR3Analyse, pUserData, pCacheRec);
     
    10291029
    10301030                        /* Analyse the function. */
    1031                         Log(("Found new function at %VGv\n", pCurInstrGC));
     1031                        Log(("Found new function at %VRv\n", pCurInstrGC));
    10321032                        STAM_COUNTER_INC(&pVM->csam.s.StatScanNextFunction);
    10331033                        csamAnalyseCallCodeStream(pVM, pInstrGC, pCurInstrGC, fCode32, pfnCSAMR3Analyse, pUserData, pCacheRec);
     
    10821082#endif
    10831083
    1084     LogFlow(("csamAnalyseCodeStream: code at %VGv depth=%d\n", pCurInstrGC, pCacheRec->depth));
     1084    LogFlow(("csamAnalyseCodeStream: code at %VRv depth=%d\n", pCurInstrGC, pCacheRec->depth));
    10851085
    10861086    pVM->csam.s.fScanningStarted = true;
     
    10951095    if (pCacheRec->depth > 512)
    10961096    {
    1097         LogFlow(("CSAM: maximum calldepth reached for %VGv\n", pCurInstrGC));
     1097        LogFlow(("CSAM: maximum calldepth reached for %VRv\n", pCurInstrGC));
    10981098        pCacheRec->depth--;
    10991099        return VINF_SUCCESS;    //let's not go on forever
     
    11201120        else
    11211121        {
    1122             LogFlow(("Code at %VGv has been scanned before\n", pCurInstrGC));
     1122            LogFlow(("Code at %VRv has been scanned before\n", pCurInstrGC));
    11231123            rc = VINF_SUCCESS;
    11241124            goto done;
     
    11281128        if (pCurInstrHC == NULL)
    11291129        {
    1130             Log(("CSAMGCVirtToHCVirt failed for %VGv\n", pCurInstrGC));
     1130            Log(("CSAMGCVirtToHCVirt failed for %VRv\n", pCurInstrGC));
    11311131            rc = VERR_PATCHING_REFUSED;
    11321132            goto done;
     
    11451145        if (VBOX_FAILURE(rc2))
    11461146        {
    1147             Log(("Disassembly failed at %VGv with %Vrc (probably page not present) -> return to caller\n", pCurInstrGC, rc2));
     1147            Log(("Disassembly failed at %VRv with %Vrc (probably page not present) -> return to caller\n", pCurInstrGC, rc2));
    11481148            rc = VINF_SUCCESS;
    11491149            goto done;
     
    11621162            {
    11631163                /// @todo fault in the page
    1164                 Log(("Page for current instruction %VGv is not present!!\n", pCurInstrGC));
     1164                Log(("Page for current instruction %VRv is not present!!\n", pCurInstrGC));
    11651165                rc = VWRN_CONTINUE_ANALYSIS;
    11661166                goto next_please;
     
    12241224                if (!PGMGstIsPagePresent(pVM, addr))
    12251225                {
    1226                     Log(("Page for current instruction %VGv is not present!!\n", addr));
     1226                    Log(("Page for current instruction %VRv is not present!!\n", addr));
    12271227                    rc = VWRN_CONTINUE_ANALYSIS;
    12281228                    goto next_please;
     
    12971297                       break;
    12981298
    1299                     Log(("Jump to %VGv\n", addr));
     1299                    Log(("Jump to %VRv\n", addr));
    13001300
    13011301                    pJmpPage = NULL;
     
    13581358    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
    13591359    {
    1360         Log(("csamR3CalcPageHash: page %VGv not present!!\n", pInstr));
     1360        Log(("csamR3CalcPageHash: page %VRv not present!!\n", pInstr));
    13611361        return ~0ULL;
    13621362    }
     
    13661366    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
    13671367    {
    1368         Log(("csamR3CalcPageHash: page %VGv not present!!\n", pInstr));
     1368        Log(("csamR3CalcPageHash: page %VRv not present!!\n", pInstr));
    13691369        return ~0ULL;
    13701370    }
     
    13741374    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
    13751375    {
    1376         Log(("csamR3CalcPageHash: page %VGv not present!!\n", pInstr));
     1376        Log(("csamR3CalcPageHash: page %VRv not present!!\n", pInstr));
    13771377        return ~0ULL;
    13781378    }
     
    13821382    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
    13831383    {
    1384         Log(("csamR3CalcPageHash: page %VGv not present!!\n", pInstr));
     1384        Log(("csamR3CalcPageHash: page %VRv not present!!\n", pInstr));
    13851385        return ~0ULL;
    13861386    }
     
    13901390    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
    13911391    {
    1392         Log(("csamR3CalcPageHash: page %VGv not present!!\n", pInstr));
     1392        Log(("csamR3CalcPageHash: page %VRv not present!!\n", pInstr));
    13931393        return ~0ULL;
    13941394    }
     
    14561456    else
    14571457    if (rc != VERR_PAGE_NOT_PRESENT && rc != VERR_PAGE_TABLE_NOT_PRESENT)
    1458         AssertMsgFailed(("PGMR3GetPage %VGv failed with %Vrc\n", addr, rc));
     1458        AssertMsgFailed(("PGMR3GetPage %VRv failed with %Vrc\n", addr, rc));
    14591459
    14601460    pPageRec = (PCSAMPAGEREC)RTAvlPVGet(&pVM->csam.s.pPageTree, (AVLPVKEY)addr);
     
    14691469        }
    14701470
    1471         Log(("CSAMR3FlushPage: page %VGv has changed -> FLUSH (rc=%Vrc) (Phys: %VGp vs %VGp)\n", addr, rc, GCPhys, pPageRec->page.GCPhys));
     1471        Log(("CSAMR3FlushPage: page %VRv has changed -> FLUSH (rc=%Vrc) (Phys: %VGp vs %VGp)\n", addr, rc, GCPhys, pPageRec->page.GCPhys));
    14721472
    14731473        STAM_COUNTER_ADD(&pVM->csam.s.StatNrFlushes, 1);
     
    16081608    bool         ret;
    16091609
    1610     Log(("New page record for %VGv\n", GCPtr & PAGE_BASE_GC_MASK));
     1610    Log(("New page record for %VRv\n", GCPtr & PAGE_BASE_GC_MASK));
    16111611
    16121612    pPage = (PCSAMPAGEREC)MMR3HeapAllocZ(pVM, MM_TAG_CSAM_PATCH, sizeof(CSAMPAGEREC));
     
    16461646                                             (fMonitorInvalidation) ? CSAMCodePageInvalidate : 0, CSAMCodePageWriteHandler, "CSAMGCCodePageWriteHandler", 0,
    16471647                                             csamGetMonitorDescription(enmTag));
    1648         AssertMsg(VBOX_SUCCESS(rc) || rc == VERR_PGM_HANDLER_VIRTUAL_CONFLICT, ("PGMR3HandlerVirtualRegisterEx %VGv failed with %Vrc\n", GCPtr, rc));
     1648        AssertMsg(VBOX_SUCCESS(rc) || rc == VERR_PGM_HANDLER_VIRTUAL_CONFLICT, ("PGMR3HandlerVirtualRegisterEx %VRv failed with %Vrc\n", GCPtr, rc));
    16491649        if (VBOX_FAILURE(rc))
    1650             Log(("PGMR3HandlerVirtualRegisterEx for %VGv failed with %Vrc\n", GCPtr, rc));
     1650            Log(("PGMR3HandlerVirtualRegisterEx for %VRv failed with %Vrc\n", GCPtr, rc));
    16511651
    16521652        /* Could fail, because it's already monitored. Don't treat that condition as fatal. */
     
    16671667    }
    16681668
    1669     Log(("csamCreatePageRecord %VGv HCPhys=%VGp\n", GCPtr, pPage->page.GCPhys));
     1669    Log(("csamCreatePageRecord %VRv HCPhys=%VGp\n", GCPtr, pPage->page.GCPhys));
    16701670
    16711671#ifdef VBOX_WITH_STATISTICS
     
    17171717    pPageAddrGC &= PAGE_BASE_GC_MASK;
    17181718
    1719     Log(("CSAMR3MonitorPage %VGv %d\n", pPageAddrGC, enmTag));
     1719    Log(("CSAMR3MonitorPage %VRv %d\n", pPageAddrGC, enmTag));
    17201720
    17211721    /** @todo implicit assumption */
     
    17511751    if (!pPageRec->page.fMonitorActive)
    17521752    {
    1753         Log(("CSAMR3MonitorPage: activate monitoring for %VGv\n", pPageAddrGC));
     1753        Log(("CSAMR3MonitorPage: activate monitoring for %VRv\n", pPageAddrGC));
    17541754
    17551755        rc = PGMR3HandlerVirtualRegister(pVM, PGMVIRTHANDLERTYPE_WRITE, pPageAddrGC, pPageAddrGC + (PAGE_SIZE - 1) /* inclusive! */,
    17561756                                         (fMonitorInvalidation) ? CSAMCodePageInvalidate : 0, CSAMCodePageWriteHandler, "CSAMGCCodePageWriteHandler", 0,
    17571757                                         csamGetMonitorDescription(enmTag));
    1758         AssertMsg(VBOX_SUCCESS(rc) || rc == VERR_PGM_HANDLER_VIRTUAL_CONFLICT, ("PGMR3HandlerVirtualRegisterEx %VGv failed with %Vrc\n", pPageAddrGC, rc));
     1758        AssertMsg(VBOX_SUCCESS(rc) || rc == VERR_PGM_HANDLER_VIRTUAL_CONFLICT, ("PGMR3HandlerVirtualRegisterEx %VRv failed with %Vrc\n", pPageAddrGC, rc));
    17591759        if (VBOX_FAILURE(rc))
    1760             Log(("PGMR3HandlerVirtualRegisterEx for %VGv failed with %Vrc\n", pPageAddrGC, rc));
     1760            Log(("PGMR3HandlerVirtualRegisterEx for %VRv failed with %Vrc\n", pPageAddrGC, rc));
    17611761
    17621762        /* Could fail, because it's already monitored. Don't treat that condition as fatal. */
     
    18001800//        AssertMsg(     (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
    18011801//                ||  !(fPageShw & X86_PTE_RW)
    1802 //                ||   (pPageRec->page.GCPhys == 0), ("Shadow page flags for %VGv (%VHp) aren't readonly (%VX64)!!\n", pPageAddrGC, GCPhys, fPageShw));
     1802//                ||   (pPageRec->page.GCPhys == 0), ("Shadow page flags for %VRv (%VHp) aren't readonly (%VX64)!!\n", pPageAddrGC, GCPhys, fPageShw));
    18031803    }
    18041804#endif
     
    18291829    pPageAddrGC &= PAGE_BASE_GC_MASK;
    18301830
    1831     Log(("CSAMR3UnmonitorPage %VGv %d\n", pPageAddrGC, enmTag));
     1831    Log(("CSAMR3UnmonitorPage %VRv %d\n", pPageAddrGC, enmTag));
    18321832
    18331833    Assert(enmTag == CSAM_TAG_REM);
     
    18531853    PCSAMPAGEREC pPageRec;
    18541854
    1855     Log(("csamRemovePageRecord %VGv\n", GCPtr));
     1855    Log(("csamRemovePageRecord %VRv\n", GCPtr));
    18561856    pPageRec = (PCSAMPAGEREC)RTAvlPVRemove(&pVM->csam.s.pPageTree, (AVLPVKEY)GCPtr);
    18571857
     
    20382038static void csamMarkCode(PVM pVM, PCSAMPAGE pPage, RTGCPTR32 pInstr, uint32_t opsize, bool fScanned)
    20392039{
    2040     LogFlow(("csamMarkCodeAsScanned %VGv opsize=%d\n", pInstr, opsize));
     2040    LogFlow(("csamMarkCodeAsScanned %VRv opsize=%d\n", pInstr, opsize));
    20412041    CSAMMarkPage(pVM, pInstr, fScanned);
    20422042
     
    20552055        if (pPage->uSize >= PAGE_SIZE)
    20562056        {
    2057             Log(("Scanned full page (%VGv) -> free bitmap\n", pInstr & PAGE_BASE_GC_MASK));
     2057            Log(("Scanned full page (%VRv) -> free bitmap\n", pInstr & PAGE_BASE_GC_MASK));
    20582058            MMR3HeapFree(pPage->pBitmap);
    20592059            pPage->pBitmap = NULL;
     
    20882088    }
    20892089
    2090     Log(("CSAMR3MarkCode: %VGv size=%d fScanned=%d\n", pInstr, opsize, fScanned));
     2090    Log(("CSAMR3MarkCode: %VRv size=%d fScanned=%d\n", pInstr, opsize, fScanned));
    20912091    csamMarkCode(pVM, pPage, pInstr, opsize, fScanned);
    20922092    return VINF_SUCCESS;
     
    21902190        Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    21912191
    2192         Log(("CSAMR3FlushDirtyPages: flush %VGv (modifypage rc=%Vrc)\n", pVM->csam.s.pvDirtyBasePage[i], rc));
     2192        Log(("CSAMR3FlushDirtyPages: flush %VRv (modifypage rc=%Vrc)\n", pVM->csam.s.pvDirtyBasePage[i], rc));
    21932193
    21942194        pPageRec = (PCSAMPAGEREC)RTAvlPVGet(&pVM->csam.s.pPageTree, (AVLPVKEY)GCPtr);
     
    22272227        GCPtr = GCPtr & PAGE_BASE_GC_MASK;
    22282228
    2229         Log(("csamR3FlushCodePages: %VGv\n", GCPtr));
     2229        Log(("csamR3FlushCodePages: %VRv\n", GCPtr));
    22302230        PGMShwSetPage(pVM, GCPtr, 1, 0);
    22312231        /* Resync the page to make sure instruction fetch will fault */
     
    23022302                PCSAMPAGE pPage = NULL;
    23032303
    2304                 Log(("CSAMCheckGates: checking previous call instruction %VGv\n", pHandler));
     2304                Log(("CSAMCheckGates: checking previous call instruction %VRv\n", pHandler));
    23052305                STAM_PROFILE_START(&pVM->csam.s.StatTime, a);
    23062306                rc = csamAnalyseCodeStream(pVM, pHandler, pHandler, true, CSAMR3AnalyseCallback, pPage, &cacheRec);
     
    23842384            {
    23852385                /* Refuse to patch a handler whose idt cs selector isn't wide open. */
    2386                 Log(("CSAMCheckGates: check gate %d failed due to rc %Vrc GCPtrBase=%VGv limit=%x\n", iGate, rc, selInfo.GCPtrBase, selInfo.cbLimit));
     2386                Log(("CSAMCheckGates: check gate %d failed due to rc %Vrc GCPtrBase=%VRv limit=%x\n", iGate, rc, selInfo.GCPtrBase, selInfo.cbLimit));
    23872387                continue;
    23882388            }
     
    23912391            if (pGuestIdte->Gen.u5Type2 == VBOX_IDTE_TYPE2_TRAP_32)
    23922392            {
    2393                 Log(("CSAMCheckGates: check trap gate %d at %04X:%08X (flat %VGv)\n", iGate, pGuestIdte->Gen.u16SegSel, (pGuestIdte->Gen.u16OffsetHigh << 16) | pGuestIdte->Gen.u16OffsetLow, pHandler));
     2393                Log(("CSAMCheckGates: check trap gate %d at %04X:%08X (flat %VRv)\n", iGate, pGuestIdte->Gen.u16SegSel, (pGuestIdte->Gen.u16OffsetHigh << 16) | pGuestIdte->Gen.u16OffsetLow, pHandler));
    23942394            }
    23952395            else
    23962396            {
    2397                 Log(("CSAMCheckGates: check interrupt gate %d at %04X:%08X (flat %VGv)\n", iGate, pGuestIdte->Gen.u16SegSel, (pGuestIdte->Gen.u16OffsetHigh << 16) | pGuestIdte->Gen.u16OffsetLow, pHandler));
     2397                Log(("CSAMCheckGates: check interrupt gate %d at %04X:%08X (flat %VRv)\n", iGate, pGuestIdte->Gen.u16SegSel, (pGuestIdte->Gen.u16OffsetHigh << 16) | pGuestIdte->Gen.u16OffsetLow, pHandler));
    23982398            }
    23992399
     
    24552455            }
    24562456
    2457             Log(("Installing %s gate handler for 0x%X at %VGv\n", (pGuestIdte->Gen.u5Type2 == VBOX_IDTE_TYPE2_TRAP_32) ? "trap" : "intr", iGate, pHandler));
     2457            Log(("Installing %s gate handler for 0x%X at %VRv\n", (pGuestIdte->Gen.u5Type2 == VBOX_IDTE_TYPE2_TRAP_32) ? "trap" : "intr", iGate, pHandler));
    24582458
    24592459            rc = PATMR3InstallPatch(pVM, pHandler, fPatchFlags);
     
    24912491    }
    24922492
    2493     Log(("CSAMR3RecordCallAddress %VGv\n", GCPtrCall));
     2493    Log(("CSAMR3RecordCallAddress %VRv\n", GCPtrCall));
    24942494
    24952495    pVM->csam.s.pvCallInstruction[pVM->csam.s.iCallInstruction++] = GCPtrCall;
  • trunk/src/VBox/VMM/PATM/PATM.cpp

    r9220 r9228  
    6464*******************************************************************************/
    6565
    66 static int          patmDisableUnusablePatch(PVM pVM, RTGCPTR32 pInstrGC, RTGCPTR32 pConflictAddr, PPATCHINFO pPatch);
     66static int          patmDisableUnusablePatch(PVM pVM, RTRCPTR pInstrGC, RTRCPTR pConflictAddr, PPATCHINFO pPatch);
    6767static int          patmActivateInt3Patch(PVM pVM, PPATCHINFO pPatch);
    6868static int          patmDeactivateInt3Patch(PVM pVM, PPATCHINFO pPatch);
    6969
    7070#ifdef LOG_ENABLED // keep gcc quiet
    71 static bool         patmIsCommonIDTHandlerPatch(PVM pVM, RTGCPTR32 pInstrGC);
     71static bool         patmIsCommonIDTHandlerPatch(PVM pVM, RTRCPTR pInstrGC);
    7272#endif
    7373#ifdef VBOX_WITH_STATISTICS
     
    8181
    8282static int               patmReinit(PVM pVM);
    83 static DECLCALLBACK(int) RelocatePatches(PAVLOGCPTRNODECORE pNode, void *pParam);
     83static DECLCALLBACK(int) RelocatePatches(PAVLOU32NODECORE pNode, void *pParam);
    8484static DECLCALLBACK(int) patmVirtPageHandler(PVM pVM, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
    8585
    8686#ifdef VBOX_WITH_DEBUGGER
    87 static DECLCALLBACK(int) DisableAllPatches(PAVLOGCPTRNODECORE pNode, void *pVM);
     87static DECLCALLBACK(int) DisableAllPatches(PAVLOU32NODECORE pNode, void *pVM);
    8888static DECLCALLBACK(int) patmr3CmdOn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
    8989static DECLCALLBACK(int) patmr3CmdOff(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
     
    126126
    127127    /* PATM stack page for call instruction execution. (2 parts: one for our private stack and one to store the original return address */
    128     pVM->patm.s.pGCStackHC  = (RTGCPTR32 *)(pVM->patm.s.pPatchMemHC + PATCH_MEMORY_SIZE + PAGE_SIZE);
     128    pVM->patm.s.pGCStackHC  = (RTRCPTR *)(pVM->patm.s.pPatchMemHC + PATCH_MEMORY_SIZE + PAGE_SIZE);
    129129    pVM->patm.s.pGCStackGC  = MMHyperHC2GC(pVM, pVM->patm.s.pGCStackHC);
    130130
     
    324324    memset(pVM->patm.s.pGCStateHC, 0, PAGE_SIZE);
    325325    AssertReleaseMsg(pVM->patm.s.pGCStateGC, ("Impossible! MMHyperHC2GC(%p) failed!\n", pVM->patm.s.pGCStateGC));
    326     Log(("Patch memory allocated at %p - %VGv\n", pVM->patm.s.pPatchMemHC, pVM->patm.s.pPatchMemGC));
     326   
     327    Log(("Patch memory allocated at %p - %VRv\n", pVM->patm.s.pPatchMemHC, pVM->patm.s.pPatchMemGC));
    327328    pVM->patm.s.pGCStateHC->uVMFlags = X86_EFL_IF;
    328329
     
    409410PATMR3DECL(void) PATMR3Relocate(PVM pVM)
    410411{
    411     RTGCPTR32         GCPtrNew = MMHyperHC2GC(pVM, pVM->patm.s.pGCStateHC);
    412     RTGCINTPTR      delta = GCPtrNew - pVM->patm.s.pGCStateGC;
    413 
    414     Log(("PATMR3Relocate from %VGv to %VGv - delta %08X\n", pVM->patm.s.pGCStateGC, GCPtrNew, delta));
     412    RTRCPTR     GCPtrNew = MMHyperHC2GC(pVM, pVM->patm.s.pGCStateHC);
     413    RTRCINTPTR  delta = GCPtrNew - pVM->patm.s.pGCStateGC;
     414
     415    Log(("PATMR3Relocate from %VRv to %VRv - delta %08X\n", pVM->patm.s.pGCStateGC, GCPtrNew, delta));
    415416    if (delta)
    416417    {
     
    423424        pVM->patm.s.deltaReloc = delta;
    424425
    425         RTAvloGCPtrDoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, RelocatePatches, (void *)pVM);
     426        RTAvloU32DoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, RelocatePatches, (void *)pVM);
    426427
    427428        rc = CPUMQueryGuestCtxPtr(pVM, &pCtx);
     
    484485    while (true)
    485486    {
    486         PPATMPATCHREC pPatchRec = (PPATMPATCHREC)RTAvloGCPtrRemoveBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, 0, true);
     487        PPATMPATCHREC pPatchRec = (PPATMPATCHREC)RTAvloU32RemoveBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, 0, true);
    487488        if (pPatchRec)
    488489        {
     
    533534        for (int i=0;i<orgsize;i++)
    534535        {
    535             int rc = PATMR3QueryOpcode(pDisInfo->pVM, (RTGCPTR32)pSrc, pDest);
     536            int rc = PATMR3QueryOpcode(pDisInfo->pVM, (RTRCPTR)pSrc, pDest);
    536537            if (VBOX_SUCCESS(rc))
    537538            {
     
    575576
    576577/**
    577  * Callback function for RTAvloGCPtrDoWithAll
     578 * Callback function for RTAvloU32DoWithAll
    578579 *
    579580 * Updates all fixups in the patches
     
    583584 * @param   pParam      The VM to operate on.
    584585 */
    585 static DECLCALLBACK(int) RelocatePatches(PAVLOGCPTRNODECORE pNode, void *pParam)
     586static DECLCALLBACK(int) RelocatePatches(PAVLOU32NODECORE pNode, void *pParam)
    586587{
    587588    PPATMPATCHREC   pPatch = (PPATMPATCHREC)pNode;
    588589    PVM             pVM = (PVM)pParam;
    589     RTGCINTPTR      delta;
     590    RTRCINTPTR      delta;
    590591#ifdef LOG_ENABLED
    591592    DISCPUSTATE     cpu;
     
    615616
    616617    Log(("Nr of fixups %d\n", pPatch->patch.nrFixups));
    617     delta = (RTGCINTPTR)pVM->patm.s.deltaReloc;
     618    delta = (RTRCINTPTR)pVM->patm.s.deltaReloc;
    618619
    619620    /*
     
    635636        {
    636637        case FIXUP_ABSOLUTE:
    637             Log(("Absolute fixup at %VGv %VHv -> %VHv at %VGv\n", pRec->pSource, *(RTGCUINTPTR32*)pRec->pRelocPos, *(RTGCINTPTR*)pRec->pRelocPos + delta, pRec->pRelocPos));
     638            Log(("Absolute fixup at %VRv %VHv -> %VHv at %VRv\n", pRec->pSource, *(RTRCUINTPTR *)pRec->pRelocPos, *(RTRCINTPTR*)pRec->pRelocPos + delta, pRec->pRelocPos));
    638639            if (!pRec->pSource || PATMIsPatchGCAddr(pVM, pRec->pSource))
    639640            {
    640                 *(RTGCUINTPTR32 *)pRec->pRelocPos += delta;
     641                *(RTRCUINTPTR *)pRec->pRelocPos += delta;
    641642            }
    642643            else
     
    649650
    650651                memcpy(oldInstr, pPatch->patch.aPrivInstr, pPatch->patch.cbPrivInstr);
    651                 *(RTGCPTR32 *)&oldInstr[pPatch->patch.cbPrivInstr - sizeof(RTGCPTR32)] = pRec->pDest;
     652                *(RTRCPTR *)&oldInstr[pPatch->patch.cbPrivInstr - sizeof(RTRCPTR)] = pRec->pDest;
    652653
    653654                rc = PGMPhysReadGCPtr(pVM, curInstr, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPrivInstr);
    654655                Assert(VBOX_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    655656
    656                 pRec->pDest = (RTGCPTR32)((RTGCUINTPTR32)pRec->pDest + delta);
     657                pRec->pDest = (RTRCPTR)((RTRCUINTPTR)pRec->pDest + delta);
    657658
    658659                if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
    659660                {
    660                     RTGCPTR32 pPage = pPatch->patch.pPrivInstrGC & PAGE_BASE_GC_MASK;
     661                    RTRCPTR pPage = pPatch->patch.pPrivInstrGC & PAGE_BASE_GC_MASK;
    661662
    662663                    Log(("PATM: Patch page not present -> check later!\n"));
     
    677678                if (VBOX_SUCCESS(rc))
    678679                {
    679                     *(RTGCPTR32 *)&curInstr[pPatch->patch.cbPrivInstr - sizeof(RTGCPTR32)] = pRec->pDest;
     680                    *(RTRCPTR *)&curInstr[pPatch->patch.cbPrivInstr - sizeof(RTRCPTR)] = pRec->pDest;
    680681                    rc = PGMPhysWriteGCPtrDirty(pVM, pRec->pSource, curInstr, pPatch->patch.cbPrivInstr);
    681682                    AssertRC(rc);
     
    686687        case FIXUP_REL_JMPTOPATCH:
    687688        {
    688             RTGCPTR32 pTarget = (RTGCPTR32)((RTGCINTPTR)pRec->pDest + delta);
     689            RTRCPTR pTarget = (RTRCPTR)((RTRCINTPTR)pRec->pDest + delta);
    689690
    690691            if (    pPatch->patch.uState == PATCH_ENABLED
     
    693694                uint8_t    oldJump[SIZEOF_NEAR_COND_JUMP32];
    694695                uint8_t    temp[SIZEOF_NEAR_COND_JUMP32];
    695                 RTGCPTR32    pJumpOffGC;
    696                 RTGCINTPTR displ   = (RTGCINTPTR)pTarget - (RTGCINTPTR)pRec->pSource;
    697                 RTGCINTPTR displOld= (RTGCINTPTR)pRec->pDest - (RTGCINTPTR)pRec->pSource;
     696                RTRCPTR    pJumpOffGC;
     697                RTRCINTPTR displ   = (RTRCINTPTR)pTarget - (RTRCINTPTR)pRec->pSource;
     698                RTRCINTPTR displOld= (RTRCINTPTR)pRec->pDest - (RTRCINTPTR)pRec->pSource;
    698699
    699700                Log(("Relative fixup (g2p) %08X -> %08X at %08X (source=%08x, target=%08x)\n", *(int32_t*)pRec->pRelocPos, displ, pRec->pRelocPos, pRec->pSource, pRec->pDest));
     
    708709                    oldJump[0] = pPatch->patch.aPrivInstr[0];
    709710                    oldJump[1] = pPatch->patch.aPrivInstr[1];
    710                     *(RTGCUINTPTR32 *)&oldJump[2] = displOld;
     711                    *(RTRCUINTPTR *)&oldJump[2] = displOld;
    711712                }
    712713                else
     
    716717                    pJumpOffGC = pPatch->patch.pPrivInstrGC + 1;    //one byte opcode
    717718                    oldJump[0] = 0xE9;
    718                     *(RTGCUINTPTR32 *)&oldJump[1] = displOld;
     719                    *(RTRCUINTPTR *)&oldJump[1] = displOld;
    719720                }
    720721                else
     
    733734                if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
    734735                {
    735                     RTGCPTR32 pPage = pPatch->patch.pPrivInstrGC & PAGE_BASE_GC_MASK;
     736                    RTRCPTR pPage = pPatch->patch.pPrivInstrGC & PAGE_BASE_GC_MASK;
    736737
    737738                    rc = PGMR3HandlerVirtualRegister(pVM, PGMVIRTHANDLERTYPE_ALL, pPage, pPage + (PAGE_SIZE - 1) /* inclusive! */, 0, patmVirtPageHandler, "PATMGCMonitorPage", 0, "PATMMonitorPatchJump");
     
    770771        case FIXUP_REL_JMPTOGUEST:
    771772        {
    772             RTGCPTR32    pSource = (RTGCPTR32)((RTGCINTPTR)pRec->pSource + delta);
    773             RTGCINTPTR displ   = (RTGCINTPTR)pRec->pDest - (RTGCINTPTR)pSource;
     773            RTRCPTR    pSource = (RTRCPTR)((RTRCINTPTR)pRec->pSource + delta);
     774            RTRCINTPTR displ   = (RTRCINTPTR)pRec->pDest - (RTRCINTPTR)pSource;
    774775
    775776            Assert(!(pPatch->patch.flags & PATMFL_GLOBAL_FUNCTIONS));
    776777            Log(("Relative fixup (p2g) %08X -> %08X at %08X (source=%08x, target=%08x)\n", *(int32_t*)pRec->pRelocPos, displ, pRec->pRelocPos, pRec->pSource, pRec->pDest));
    777             *(RTGCUINTPTR32 *)pRec->pRelocPos = displ;
     778            *(RTRCUINTPTR *)pRec->pRelocPos = displ;
    778779            pRec->pSource = pSource;
    779780            break;
     
    830831#ifdef VBOX_WITH_DEBUGGER
    831832/**
    832  * Callback function for RTAvloGCPtrDoWithAll
     833 * Callback function for RTAvloU32DoWithAll
    833834 *
    834835 * Enables the patch that's being enumerated
     
    838839 * @param   pVM         The VM to operate on.
    839840 */
    840 static DECLCALLBACK(int) EnableAllPatches(PAVLOGCPTRNODECORE pNode, void *pVM)
     841static DECLCALLBACK(int) EnableAllPatches(PAVLOU32NODECORE pNode, void *pVM)
    841842{
    842843    PPATMPATCHREC pPatch = (PPATMPATCHREC)pNode;
    843844
    844     PATMR3EnablePatch((PVM)pVM, (RTGCPTR32)pPatch->Core.Key);
     845    PATMR3EnablePatch((PVM)pVM, (RTRCPTR)pPatch->Core.Key);
    845846    return 0;
    846847}
     
    850851#ifdef VBOX_WITH_DEBUGGER
    851852/**
    852  * Callback function for RTAvloGCPtrDoWithAll
     853 * Callback function for RTAvloU32DoWithAll
    853854 *
    854855 * Disables the patch that's being enumerated
     
    858859 * @param   pVM         The VM to operate on.
    859860 */
    860 static DECLCALLBACK(int) DisableAllPatches(PAVLOGCPTRNODECORE pNode, void *pVM)
     861static DECLCALLBACK(int) DisableAllPatches(PAVLOU32NODECORE pNode, void *pVM)
    861862{
    862863    PPATMPATCHREC pPatch = (PPATMPATCHREC)pNode;
    863864
    864     PATMR3DisablePatch((PVM)pVM, (RTGCPTR32)pPatch->Core.Key);
     865    PATMR3DisablePatch((PVM)pVM, (RTRCPTR)pPatch->Core.Key);
    865866    return 0;
    866867}
     
    891892 * @param   pcb         Size of the patch memory block
    892893 */
    893 PATMR3DECL(RTGCPTR32) PATMR3QueryPatchMemGC(PVM pVM, uint32_t *pcb)
     894PATMR3DECL(RTRCPTR) PATMR3QueryPatchMemGC(PVM pVM, uint32_t *pcb)
    894895{
    895896    if (pcb)
     
    946947 * @param   pAddrGC     GC pointer
    947948 */
    948 PATMR3DECL(R3PTRTYPE(void *)) PATMR3GCPtrToHCPtr(PVM pVM, RTGCPTR32 pAddrGC)
     949PATMR3DECL(R3PTRTYPE(void *)) PATMR3GCPtrToHCPtr(PVM pVM, RTRCPTR pAddrGC)
    949950{
    950951    if (pVM->patm.s.pPatchMemGC <= pAddrGC && pVM->patm.s.pPatchMemGC + pVM->patm.s.cbPatchMem > pAddrGC)
     
    10571058                {
    10581059                    uint8_t *pPatchHC;
    1059                     RTGCPTR32  pPatchGC;
    1060                     RTGCPTR32  pOrgInstrGC;
     1060                    RTRCPTR  pPatchGC;
     1061                    RTRCPTR  pOrgInstrGC;
    10611062
    10621063                    pOrgInstrGC = PATMR3PatchToGCPtr(pVM, pInstrGC, 0);
     
    10901091        }
    10911092        /* Our jumps *always* have a dword displacement (to make things easier). */
    1092         Assert(sizeof(uint32_t) == sizeof(RTGCPTR32));
    1093         displ =  pBranchTargetGC - (pInstrGC + pRec->offDispl + sizeof(RTGCPTR32));
    1094         *(RTGCPTR32 *)(pRec->pJumpHC + pRec->offDispl) = displ;
    1095         Log(("Set branch target %d to %08X : %08x - (%08x + %d + %d)\n", nrJumpRecs, displ, pBranchTargetGC, pInstrGC, pRec->offDispl, sizeof(RTGCPTR32)));
     1093        Assert(sizeof(uint32_t) == sizeof(RTRCPTR));
     1094        displ =  pBranchTargetGC - (pInstrGC + pRec->offDispl + sizeof(RTRCPTR));
     1095        *(RTRCPTR *)(pRec->pJumpHC + pRec->offDispl) = displ;
     1096        Log(("Set branch target %d to %08X : %08x - (%08x + %d + %d)\n", nrJumpRecs, displ, pBranchTargetGC, pInstrGC, pRec->offDispl, sizeof(RTRCPTR)));
    10961097    }
    10971098    Assert(nrJumpRecs == pPatch->nrJumpRecs);
     
    11071108 *
    11081109 */
    1109 static void patmAddIllegalInstrRecord(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pInstrGC)
     1110static void patmAddIllegalInstrRecord(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC)
    11101111{
    11111112    PAVLPVNODECORE pRec;
     
    11201121}
    11211122
    1122 static bool patmIsIllegalInstr(PPATCHINFO pPatch, RTGCPTR32 pInstrGC)
     1123static bool patmIsIllegalInstr(PPATCHINFO pPatch, RTRCPTR pInstrGC)
    11231124{
    11241125    PAVLPVNODECORE pRec;
     
    11421143 */
    11431144 /** @note Be extremely careful with this function. Make absolutely sure the guest address is correct! (to avoid executing instructions twice!) */
    1144 void patmr3AddP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, uint8_t *pPatchInstrHC, RTGCPTR32 pInstrGC, PATM_LOOKUP_TYPE enmType, bool fDirty)
     1145void patmr3AddP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, uint8_t *pPatchInstrHC, RTRCPTR pInstrGC, PATM_LOOKUP_TYPE enmType, bool fDirty)
    11451146{
    11461147    bool ret;
     
    11781179    if (enmType == PATM_LOOKUP_BOTHDIR)
    11791180    {
    1180         pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlGCPtrGet(&pPatch->Guest2PatchAddrTree, pInstrGC);
     1181        pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlU32Get(&pPatch->Guest2PatchAddrTree, pInstrGC);
    11811182        if (!pGuestToPatchRec)
    11821183        {
     
    11851186            pGuestToPatchRec->PatchOffset = PatchOffset;
    11861187
    1187             ret = RTAvlGCPtrInsert(&pPatch->Guest2PatchAddrTree, &pGuestToPatchRec->Core);
     1188            ret = RTAvlU32Insert(&pPatch->Guest2PatchAddrTree, &pGuestToPatchRec->Core);
    11881189            Assert(ret);
    11891190        }
     
    12011202 * @param   pPatchInstrGC   Guest context pointer to patch block
    12021203 */
    1203 void patmr3RemoveP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pPatchInstrGC)
     1204void patmr3RemoveP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, RTRCPTR pPatchInstrGC)
    12041205{
    12051206    PAVLU32NODECORE     pNode;
    1206     PAVLGCPTRNODECORE   pNode2;
     1207    PAVLU32NODECORE     pNode2;
    12071208    PRECPATCHTOGUEST    pPatchToGuestRec;
    12081209    uint32_t            PatchOffset = pPatchInstrGC - pVM->patm.s.pPatchMemGC;  /* Offset in memory reserved for PATM. */
     
    12171218
    12181219            Assert(pGuestToPatchRec->Core.Key);
    1219             pNode2 = RTAvlGCPtrRemove(&pPatch->Guest2PatchAddrTree, pGuestToPatchRec->Core.Key);
     1220            pNode2 = RTAvlU32Remove(&pPatch->Guest2PatchAddrTree, pGuestToPatchRec->Core.Key);
    12201221            Assert(pNode2);
    12211222        }
     
    12991300    if (pPatch->cbPatchBlockSize >= MAX_PATCH_SIZE)
    13001301    {
    1301         Log(("Code block too big (%x) for patch at %VGv!!\n", pPatch->cbPatchBlockSize, pCurInstrGC));
     1302        Log(("Code block too big (%x) for patch at %VRv!!\n", pPatch->cbPatchBlockSize, pCurInstrGC));
    13021303        fIllegalInstr = true;
    13031304        patmAddIllegalInstrRecord(pVM, pPatch, pCurInstrGC);
     
    14231424    {
    14241425        // The end marker for this kind of patch is any instruction at a location outside our patch jump
    1425         Log(("End of block at %VGv size %d\n", pCurInstrGC, pCpu->opsize));
     1426        Log(("End of block at %VRv size %d\n", pCurInstrGC, pCpu->opsize));
    14261427        return VINF_SUCCESS;
    14271428    }
     
    14551456    if (pPatch->cbPatchBlockSize >= MAX_PATCH_SIZE)
    14561457    {
    1457         Log(("Code block too big (%x) for function patch at %VGv!!\n", pPatch->cbPatchBlockSize, pCurInstrGC));
     1458        Log(("Code block too big (%x) for function patch at %VRv!!\n", pPatch->cbPatchBlockSize, pCurInstrGC));
    14581459        fIllegalInstr = true;
    14591460        patmAddIllegalInstrRecord(pVM, pPatch, pCurInstrGC);
     
    15521553    bool fInhibitIRQInstr = false;  /* did the instruction cause PATMFL_INHIBITIRQS to be set? */
    15531554
    1554     LogFlow(("patmRecompileCallback %VGv %VGv\n", pInstrGC, pCurInstrGC));
     1555    LogFlow(("patmRecompileCallback %VRv %VRv\n", pInstrGC, pCurInstrGC));
    15551556
    15561557    if (    patmGuestGCPtrToPatchGCPtr(pVM, pPatch, pCurInstrGC) != 0
     
    15611562         * no need to record this instruction as it's glue code that never crashes (it had better not!)
    15621563         */
    1563         Log(("patmRecompileCallback: jump to code we've recompiled before %VGv!\n", pCurInstrGC));
     1564        Log(("patmRecompileCallback: jump to code we've recompiled before %VRv!\n", pCurInstrGC));
    15641565        return patmPatchGenRelJump(pVM, pPatch, pCurInstrGC, OP_JMP, !!(pCpu->prefix & PREFIX_OPSIZE));
    15651566    }
     
    15941595    if (patmIsIllegalInstr(pPatch, pCurInstrGC))
    15951596    {
    1596         Log(("Illegal instruction at %VGv -> mark with int 3\n", pCurInstrGC));
     1597        Log(("Illegal instruction at %VRv -> mark with int 3\n", pCurInstrGC));
    15971598        rc = patmPatchGenIllegalInstr(pVM, pPatch);
    15981599        goto end;
     
    16591660                &&  (pCpu->param1.base.reg_seg == USE_REG_SS))
    16601661            {
    1661                 Log(("Force recompilation of next instruction for OP_MOV at %VGv\n", pCurInstrGC));
     1662                Log(("Force recompilation of next instruction for OP_MOV at %VRv\n", pCurInstrGC));
    16621663                pPatch->flags |= PATMFL_RECOMPILE_NEXT;
    16631664                /** @todo this could cause a fault (ring 0 selector being loaded in ring 1) */
     
    16841685            Assert(pCpu->pCurInstr->optype & OPTYPE_INHIBIT_IRQS);
    16851686
    1686             Log(("Force recompilation of next instruction for OP_MOV at %VGv\n", pCurInstrGC));
     1687            Log(("Force recompilation of next instruction for OP_MOV at %VRv\n", pCurInstrGC));
    16871688            pPatch->flags |= PATMFL_RECOMPILE_NEXT;
    16881689        }
     
    16911692    case OP_STI:
    16921693    {
    1693         RTGCPTR32 pNextInstrGC = 0;   /* by default no inhibit irq */
     1694        RTRCPTR pNextInstrGC = 0;   /* by default no inhibit irq */
    16941695
    16951696        /** In a sequence of instructions that inhibit irqs, only the first one actually inhibits irqs. */
     
    16991700            fInhibitIRQInstr = true;
    17001701            pNextInstrGC     = pCurInstrGC + pCpu->opsize;
    1701             Log(("Inhibit irqs for instruction OP_STI at %VGv\n", pCurInstrGC));
     1702            Log(("Inhibit irqs for instruction OP_STI at %VRv\n", pCurInstrGC));
    17021703        }
    17031704        rc = patmPatchGenSti(pVM, pPatch, pCurInstrGC, pNextInstrGC);
     
    17961797
    17971798    case OP_IRET:
    1798         Log(("IRET at %VGv\n", pCurInstrGC));
     1799        Log(("IRET at %VRv\n", pCurInstrGC));
    17991800        rc = patmPatchGenIret(pVM, pPatch, pCurInstrGC, !!(pCpu->prefix & PREFIX_OPSIZE));
    18001801        if (VBOX_SUCCESS(rc))
     
    18551856        if (pPatch->flags & PATMFL_SUPPORT_INDIRECT_CALLS && pCpu->param1.size == 4 /* no far calls! */)
    18561857        {
    1857             rc = patmPatchGenCall(pVM, pPatch, pCpu, pCurInstrGC, (RTGCPTR32)0xDEADBEEF, true);
     1858            rc = patmPatchGenCall(pVM, pPatch, pCpu, pCurInstrGC, (RTRCPTR)0xDEADBEEF, true);
    18581859            if (VBOX_SUCCESS(rc))
    18591860            {
     
    19311932    {
    19321933        int     rc2;
    1933         RTGCPTR32 pNextInstrGC = pCurInstrGC + pCpu->opsize;
     1934        RTRCPTR pNextInstrGC = pCurInstrGC + pCpu->opsize;
    19341935
    19351936        pPatch->flags &= ~PATMFL_INHIBIT_IRQS;
    1936         Log(("Clear inhibit IRQ flag at %VGv\n", pCurInstrGC));
     1937        Log(("Clear inhibit IRQ flag at %VRv\n", pCurInstrGC));
    19371938        if (pPatch->flags & PATMFL_GENERATE_JUMPTOGUEST)
    19381939        {
    1939             Log(("patmRecompileCallback: generate jump back to guest (%VGv) after fused instruction\n", pNextInstrGC));
     1940            Log(("patmRecompileCallback: generate jump back to guest (%VRv) after fused instruction\n", pNextInstrGC));
    19401941
    19411942            rc2 = patmPatchGenJumpToGuest(pVM, pPatch, pNextInstrGC, true /* clear inhibit irq flag */);
     
    19601961           )
    19611962        {
    1962             RTGCPTR32 pNextInstrGC = pCurInstrGC + pCpu->opsize;
     1963            RTRCPTR pNextInstrGC = pCurInstrGC + pCpu->opsize;
    19631964
    19641965            // The end marker for this kind of patch is any instruction at a location outside our patch jump
    1965             Log(("patmRecompileCallback: end found for single instruction patch at %VGv opsize %d\n", pNextInstrGC, pCpu->opsize));
     1966            Log(("patmRecompileCallback: end found for single instruction patch at %VRv opsize %d\n", pNextInstrGC, pCpu->opsize));
    19661967
    19671968            rc = patmPatchGenJumpToGuest(pVM, pPatch, pNextInstrGC);
     
    19821983 *
    19831984 */
    1984 static void patmPatchAddDisasmJump(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pInstrGC)
     1985static void patmPatchAddDisasmJump(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC)
    19851986{
    19861987    PAVLPVNODECORE pRec;
     
    20022003 *
    20032004 */
    2004 static bool patmIsKnownDisasmJump(PPATCHINFO pPatch, RTGCPTR32 pInstrGC)
     2005static bool patmIsKnownDisasmJump(PPATCHINFO pPatch, RTRCPTR pInstrGC)
    20052006{
    20062007    PAVLPVNODECORE pRec;
     
    20322033        DISCPUSTATE cpu;
    20332034        uint8_t    *pOrgJumpHC;
    2034         RTGCPTR32     pOrgJumpGC;
     2035        RTRCPTR     pOrgJumpGC;
    20352036        uint32_t    dummy;
    20362037
     
    21102111        if (PATMIsPatchGCAddr(pVM, pCurInstrGC))
    21112112        {
    2112             RTGCPTR32 pOrgInstrGC = patmPatchGCPtr2GuestGCPtr(pVM, pPatch, pCurInstrGC);
     2113            RTRCPTR pOrgInstrGC = patmPatchGCPtr2GuestGCPtr(pVM, pPatch, pCurInstrGC);
    21132114
    21142115            if (pOrgInstrGC != pPatch->pTempInfo->pLastDisasmInstrGC)
    2115                 Log(("DIS %VGv<-%s", pOrgInstrGC, szOutput));
     2116                Log(("DIS %VRv<-%s", pOrgInstrGC, szOutput));
    21162117            else
    21172118                Log(("DIS           %s", szOutput));
     
    21452146           )
    21462147        {
    2147             RTGCPTR32 pTargetGC = PATMResolveBranch(&cpu, pCurInstrGC);
    2148             RTGCPTR32 pOrgTargetGC;
     2148            RTRCPTR pTargetGC = PATMResolveBranch(&cpu, pCurInstrGC);
     2149            RTRCPTR pOrgTargetGC;
    21492150
    21502151            if (pTargetGC == 0)
     
    22312232 *
    22322233 */
    2233 PATMR3DECL(int) PATMR3DetectConflict(PVM pVM, RTGCPTR32 pInstrGC, RTGCPTR32 pConflictGC)
     2234PATMR3DECL(int) PATMR3DetectConflict(PVM pVM, RTRCPTR pInstrGC, RTRCPTR pConflictGC)
    22342235{
    22352236    PPATCHINFO pTargetPatch = PATMFindActivePatchByEntrypoint(pVM, pConflictGC, true /* include patch hints */);
     
    22682269        cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
    22692270
    2270         ////Log(("patmRecompileCodeStream %VGv %VGv\n", pInstrGC, pCurInstrGC));
     2271        ////Log(("patmRecompileCodeStream %VRv %VRv\n", pInstrGC, pCurInstrGC));
    22712272
    22722273        pCurInstrHC = PATMGCVirtToHCVirt(pVM, pPatch, pCurInstrGC);
     
    23032304                uint32_t    opsizenext;
    23042305                uint8_t *pNextInstrHC;
    2305                 RTGCPTR32  pNextInstrGC = pCurInstrGC + opsize;
    2306 
    2307                 Log(("patmRecompileCodeStream: irqs inhibited by instruction %VGv\n", pNextInstrGC));
     2306                RTRCPTR  pNextInstrGC = pCurInstrGC + opsize;
     2307
     2308                Log(("patmRecompileCodeStream: irqs inhibited by instruction %VRv\n", pNextInstrGC));
    23082309
    23092310                /* Certain instructions (e.g. sti) force the next instruction to be executed before any interrupts can occur.
     
    23782379            }
    23792380
    2380             Log(("Jump encountered target %VGv\n", addr));
     2381            Log(("Jump encountered target %VRv\n", addr));
    23812382
    23822383            /* We don't check if the branch target lies in a valid page as we've already done that in the analysis phase. */
     
    24072408                if(pTargetPatch)
    24082409                {
    2409                     Log(("Found active patch at target %VGv (%VGv) -> temporarily disabling it!!\n", addr, pTargetPatch->pPrivInstrGC));
     2410                    Log(("Found active patch at target %VRv (%VRv) -> temporarily disabling it!!\n", addr, pTargetPatch->pPrivInstrGC));
    24102411                    PATMR3DisablePatch(pVM, pTargetPatch->pPrivInstrGC);
    24112412                }
     
    25202521        }
    25212522        temp[0] = 0xE9;  //jmp
    2522         *(uint32_t *)&temp[1] = (RTGCUINTPTR32)PATCHCODE_PTR_GC(pPatch) - ((RTGCUINTPTR32)pPatch->pPrivInstrGC + SIZEOF_NEARJUMP32);    //return address
     2523        *(uint32_t *)&temp[1] = (RTRCUINTPTR)PATCHCODE_PTR_GC(pPatch) - ((RTRCUINTPTR)pPatch->pPrivInstrGC + SIZEOF_NEARJUMP32);    //return address
    25232524    }
    25242525    rc = PGMPhysWriteGCPtrDirty(pVM, pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump);
     
    25932594 * @param   pPatch      Patch record
    25942595 */
    2595 static int patmGenCallToPatch(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pTargetGC, bool fAddFixup = true)
     2596static int patmGenCallToPatch(PVM pVM, PPATCHINFO pPatch, RTRCPTR pTargetGC, bool fAddFixup = true)
    25962597{
    25972598    uint8_t  temp[8];
     
    26402641 *
    26412642 */
    2642 PATMR3DECL(int) PATMR3PatchBlock(PVM pVM, RTGCPTR32 pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC,
     2643PATMR3DECL(int) PATMR3PatchBlock(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC,
    26432644                                 uint32_t uOpcode, uint32_t uOpSize, PPATMPATCHREC pPatchRec)
    26442645{
     
    26472648    DISCPUSTATE cpu;
    26482649    uint32_t orgOffsetPatchMem = ~0;
    2649     RTGCPTR32 pInstrStart;
     2650    RTRCPTR pInstrStart;
    26502651#ifdef LOG_ENABLED
    26512652    uint32_t opsize;
     
    27582759     * Insert into patch to guest lookup tree
    27592760     */
    2760     LogFlow(("Insert %VGv patch offset %VGv\n", pPatchRec->patch.pPrivInstrGC, pPatch->pPatchBlockOffset));
     2761    LogFlow(("Insert %VRv patch offset %VRv\n", pPatchRec->patch.pPrivInstrGC, pPatch->pPatchBlockOffset));
    27612762    pPatchRec->CoreOffset.Key = pPatch->pPatchBlockOffset;
    2762     rc = RTAvloGCPtrInsert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
     2763    rc = RTAvloU32Insert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
    27632764    AssertMsg(rc, ("RTAvlULInsert failed for %x\n", pPatchRec->CoreOffset.Key));
    27642765    if (!rc)
     
    27922793        /*uint8_t ASMInt3 = 0xCC; - unused */
    27932794
    2794         Log(("PATMR3PatchBlock %VGv -> int 3 callable patch.\n", pPatch->pPrivInstrGC));
     2795        Log(("PATMR3PatchBlock %VRv -> int 3 callable patch.\n", pPatch->pPrivInstrGC));
    27952796        /* Replace first opcode byte with 'int 3'. */
    27962797        rc = patmActivateInt3Patch(pVM, pPatch);
     
    28252826    pPatch->pTempInfo->nrIllegalInstr = 0;
    28262827
    2827     Log(("Successfully installed %s patch at %VGv\n", patmGetInstructionString(pPatch->opcode, pPatch->flags), pInstrGC));
     2828    Log(("Successfully installed %s patch at %VRv\n", patmGetInstructionString(pPatch->opcode, pPatch->flags), pInstrGC));
    28282829
    28292830    pPatch->uState = PATCH_ENABLED;
     
    28322833failure:
    28332834    if (pPatchRec->CoreOffset.Key)
    2834         RTAvloGCPtrRemove(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, pPatchRec->CoreOffset.Key);
     2835        RTAvloU32Remove(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, pPatchRec->CoreOffset.Key);
    28352836
    28362837    patmEmptyTree(pVM, &pPatch->FixupTree);
     
    28672868 *
    28682869 */
    2869 static int patmIdtHandler(PVM pVM, RTGCPTR32 pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC,
     2870static int patmIdtHandler(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC,
    28702871                          uint32_t uOpSize, PPATMPATCHREC pPatchRec)
    28712872{
     
    28742875    DISCPUSTATE cpuPush, cpuJmp;
    28752876    uint32_t opsize;
    2876     RTGCPTR32  pCurInstrGC = pInstrGC;
     2877    RTRCPTR  pCurInstrGC = pInstrGC;
    28772878    uint8_t *pCurInstrHC = pInstrHC;
    28782879    uint32_t orgOffsetPatchMem = ~0;
     
    28882889    if (disret && cpuPush.pCurInstr->opcode == OP_PUSH)
    28892890    {
    2890         RTGCPTR32  pJmpInstrGC;
     2891        RTRCPTR  pJmpInstrGC;
    28912892        int      rc;
    28922893
     
    29012902           )
    29022903        {
    2903             PPATMPATCHREC pJmpPatch = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pJmpInstrGC);
     2904            PPATMPATCHREC pJmpPatch = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pJmpInstrGC);
    29042905            if (pJmpPatch == 0)
    29052906            {
     
    29082909                if (rc != VINF_SUCCESS)
    29092910                    goto failure;
    2910                 pJmpPatch = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pJmpInstrGC);
     2911                pJmpPatch = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pJmpInstrGC);
    29112912                Assert(pJmpPatch);
    29122913            }
     
    29622963            Log(("Patch code ends -----------------------------------------------------\n"));
    29632964#endif
    2964             Log(("Successfully installed IDT handler patch at %VGv\n", pInstrGC));
     2965            Log(("Successfully installed IDT handler patch at %VRv\n", pInstrGC));
    29652966
    29662967            /*
    29672968             * Insert into patch to guest lookup tree
    29682969             */
    2969             LogFlow(("Insert %VGv patch offset %VGv\n", pPatchRec->patch.pPrivInstrGC, pPatch->pPatchBlockOffset));
     2970            LogFlow(("Insert %VRv patch offset %VRv\n", pPatchRec->patch.pPrivInstrGC, pPatch->pPatchBlockOffset));
    29702971            pPatchRec->CoreOffset.Key = pPatch->pPatchBlockOffset;
    2971             rc = RTAvloGCPtrInsert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
     2972            rc = RTAvloU32Insert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
    29722973            AssertMsg(rc, ("RTAvlULInsert failed for %x\n", pPatchRec->CoreOffset.Key));
    29732974
     
    29942995 *
    29952996 */
    2996 static int patmInstallTrapTrampoline(PVM pVM, RTGCPTR32 pInstrGC, PPATMPATCHREC pPatchRec)
     2997static int patmInstallTrapTrampoline(PVM pVM, RTRCPTR pInstrGC, PPATMPATCHREC pPatchRec)
    29972998{
    29982999    PPATCHINFO pPatch = &pPatchRec->patch;
     
    30453046    Log(("TRAP handler patch: %s", szOutput));
    30463047#endif
    3047     Log(("Successfully installed Trap Trampoline patch at %VGv\n", pInstrGC));
     3048    Log(("Successfully installed Trap Trampoline patch at %VRv\n", pInstrGC));
    30483049
    30493050    /*
    30503051     * Insert into patch to guest lookup tree
    30513052     */
    3052     LogFlow(("Insert %VGv patch offset %VGv\n", pPatchRec->patch.pPrivInstrGC, pPatch->pPatchBlockOffset));
     3053    LogFlow(("Insert %VRv patch offset %VRv\n", pPatchRec->patch.pPrivInstrGC, pPatch->pPatchBlockOffset));
    30533054    pPatchRec->CoreOffset.Key = pPatch->pPatchBlockOffset;
    3054     rc = RTAvloGCPtrInsert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
     3055    rc = RTAvloU32Insert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
    30553056    AssertMsg(rc, ("RTAvlULInsert failed for %x\n", pPatchRec->CoreOffset.Key));
    30563057
     
    30823083 *
    30833084 */
    3084 static bool patmIsCommonIDTHandlerPatch(PVM pVM, RTGCPTR32 pInstrGC)
     3085static bool patmIsCommonIDTHandlerPatch(PVM pVM, RTRCPTR pInstrGC)
    30853086{
    30863087    PPATMPATCHREC pRec;
    30873088
    3088     pRec = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
     3089    pRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
    30893090    if (pRec && pRec->patch.flags & PATMFL_IDTHANDLER_WITHOUT_ENTRYPOINT)
    30903091        return true;
     
    31033104 *
    31043105 */
    3105 static int patmDuplicateFunction(PVM pVM, RTGCPTR32 pInstrGC, PPATMPATCHREC pPatchRec)
     3106static int patmDuplicateFunction(PVM pVM, RTRCPTR pInstrGC, PPATMPATCHREC pPatchRec)
    31063107{
    31073108    PPATCHINFO pPatch = &pPatchRec->patch;
     
    31103111    uint32_t orgOffsetPatchMem = ~0;
    31113112
    3112     Log(("patmDuplicateFunction %VGv\n", pInstrGC));
     3113    Log(("patmDuplicateFunction %VRv\n", pInstrGC));
    31133114    /* Save original offset (in case of failures later on). */
    31143115    orgOffsetPatchMem = pVM->patm.s.offPatchMem;
     
    31653166     * Insert into patch to guest lookup tree
    31663167     */
    3167     LogFlow(("Insert %VGv patch offset %VGv\n", pPatchRec->patch.pPrivInstrGC, pPatch->pPatchBlockOffset));
     3168    LogFlow(("Insert %VRv patch offset %VRv\n", pPatchRec->patch.pPrivInstrGC, pPatch->pPatchBlockOffset));
    31683169    pPatchRec->CoreOffset.Key = pPatch->pPatchBlockOffset;
    3169     rc = RTAvloGCPtrInsert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
    3170     AssertMsg(rc, ("RTAvloGCPtrInsert failed for %x\n", pPatchRec->CoreOffset.Key));
     3170    rc = RTAvloU32Insert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
     3171    AssertMsg(rc, ("RTAvloU32Insert failed for %x\n", pPatchRec->CoreOffset.Key));
    31713172    if (!rc)
    31723173    {
     
    31893190#endif
    31903191
    3191     Log(("Successfully installed function duplication patch at %VGv\n", pInstrGC));
     3192    Log(("Successfully installed function duplication patch at %VRv\n", pInstrGC));
    31923193
    31933194    patmEmptyTree(pVM, &pPatch->pTempInfo->IllegalInstrTree);
     
    32003201failure:
    32013202    if (pPatchRec->CoreOffset.Key)
    3202         RTAvloGCPtrRemove(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, pPatchRec->CoreOffset.Key);
     3203        RTAvloU32Remove(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, pPatchRec->CoreOffset.Key);
    32033204
    32043205    patmEmptyTree(pVM, &pPatch->FixupTree);
     
    32203221
    32213222    pVM->patm.s.ulCallDepth--;
    3222     Log(("patmDupicateFunction %VGv failed!!\n", pInstrGC));
     3223    Log(("patmDupicateFunction %VRv failed!!\n", pInstrGC));
    32233224    return rc;
    32243225}
     
    32333234 *
    32343235 */
    3235 static int patmCreateTrampoline(PVM pVM, RTGCPTR32 pInstrGC, PPATMPATCHREC pPatchRec)
     3236static int patmCreateTrampoline(PVM pVM, RTRCPTR pInstrGC, PPATMPATCHREC pPatchRec)
    32363237{
    32373238    PPATCHINFO  pPatch = &pPatchRec->patch;
    3238     RTGCPTR32     pPage, pPatchTargetGC = 0;
     3239    RTRCPTR     pPage, pPatchTargetGC = 0;
    32393240    uint32_t    orgOffsetPatchMem = ~0;
    32403241    int         rc = VERR_PATCHING_REFUSED;
    32413242
    3242     Log(("patmCreateTrampoline %VGv\n", pInstrGC));
     3243    Log(("patmCreateTrampoline %VRv\n", pInstrGC));
    32433244    /* Save original offset (in case of failures later on). */
    32443245    orgOffsetPatchMem = pVM->patm.s.offPatchMem;
     
    32483249    pPage = pInstrGC & PAGE_BASE_GC_MASK;
    32493250
    3250     PPATMPATCHPAGE pPatchPage = (PPATMPATCHPAGE)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, (RTGCPTR32)pPage);
     3251    PPATMPATCHPAGE pPatchPage = (PPATMPATCHPAGE)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, (RTRCPTR)pPage);
    32513252    if (pPatchPage)
    32523253    {
     
    32713272                        pPatchToGuestRec->fJumpTarget = true;
    32723273                        Assert(pPatchTargetGC != pPatch->pPrivInstrGC);
    3273                         Log(("patmCreateTrampoline: generating jump to code inside patch at %VGv\n", pPatch->pPrivInstrGC));
     3274                        Log(("patmCreateTrampoline: generating jump to code inside patch at %VRv\n", pPatch->pPrivInstrGC));
    32743275                        pPatch->flags |= PATMFL_EXTERNAL_JUMP_INSIDE;
    32753276                        break;
     
    33033304     * Insert into patch to guest lookup tree
    33043305     */
    3305     LogFlow(("Insert %VGv patch offset %VGv\n", pPatchRec->patch.pPrivInstrGC, pPatch->pPatchBlockOffset));
     3306    LogFlow(("Insert %VRv patch offset %VRv\n", pPatchRec->patch.pPrivInstrGC, pPatch->pPatchBlockOffset));
    33063307    pPatchRec->CoreOffset.Key = pPatch->pPatchBlockOffset;
    3307     rc = RTAvloGCPtrInsert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
    3308     AssertMsg(rc, ("RTAvloGCPtrInsert failed for %x\n", pPatchRec->CoreOffset.Key));
     3308    rc = RTAvloU32Insert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
     3309    AssertMsg(rc, ("RTAvloU32Insert failed for %x\n", pPatchRec->CoreOffset.Key));
    33093310    if (!rc)
    33103311    {
     
    33333334failure:
    33343335    if (pPatchRec->CoreOffset.Key)
    3335         RTAvloGCPtrRemove(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, pPatchRec->CoreOffset.Key);
     3336        RTAvloU32Remove(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, pPatchRec->CoreOffset.Key);
    33363337
    33373338    patmEmptyTree(pVM, &pPatch->FixupTree);
     
    33673368PATMR3DECL(int) PATMR3DuplicateFunctionRequest(PVM pVM, PCPUMCTX pCtx)
    33683369{
    3369     RTGCPTR32     pBranchTarget, pPage;
     3370    RTRCPTR     pBranchTarget, pPage;
    33703371    int         rc;
    3371     RTGCPTR32     pPatchTargetGC = 0;
     3372    RTRCPTR     pPatchTargetGC = 0;
    33723373
    33733374    pBranchTarget = pCtx->edx;
     
    33773378    pPage = pBranchTarget & PAGE_BASE_GC_MASK;
    33783379
    3379     PPATMPATCHPAGE pPatchPage = (PPATMPATCHPAGE)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, (RTGCPTR32)pPage);
     3380    PPATMPATCHPAGE pPatchPage = (PPATMPATCHPAGE)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, (RTRCPTR)pPage);
    33803381    if (pPatchPage)
    33813382    {
     
    34213422    {
    34223423        pCtx->eax = pPatchTargetGC;
    3423         pCtx->eax = pCtx->eax - (RTGCUINTPTR32)pVM->patm.s.pPatchMemGC;   /* make it relative */
     3424        pCtx->eax = pCtx->eax - (RTRCUINTPTR)pVM->patm.s.pPatchMemGC;   /* make it relative */
    34243425    }
    34253426    else
     
    34483449 *
    34493450 */
    3450 static int patmReplaceFunctionCall(PVM pVM, DISCPUSTATE *pCpu, RTGCPTR32 pInstrGC, PPATCHINFO pPatch)
     3451static int patmReplaceFunctionCall(PVM pVM, DISCPUSTATE *pCpu, RTRCPTR pInstrGC, PPATCHINFO pPatch)
    34513452{
    34523453    int           rc = VERR_PATCHING_REFUSED;
    34533454    DISCPUSTATE   cpu;
    3454     RTGCPTR32       pTargetGC;
     3455    RTRCPTR       pTargetGC;
    34553456    PPATMPATCHREC pPatchFunction;
    34563457    uint32_t      opsize;
     
    34773478    }
    34783479
    3479     pPatchFunction = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pTargetGC);
     3480    pPatchFunction = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pTargetGC);
    34803481    if (pPatchFunction == NULL)
    34813482    {
     
    35033504            }
    35043505
    3505             pPatchFunction = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pTargetGC);
     3506            pPatchFunction = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pTargetGC);
    35063507            break;
    35073508        }
    35083509        if (pPatchFunction == 0)
    35093510        {
    3510             AssertMsgFailed(("Unable to find duplicate function %VGv\n", pTargetGC));
     3511            AssertMsgFailed(("Unable to find duplicate function %VRv\n", pTargetGC));
    35113512            rc = VERR_PATCHING_REFUSED;
    35123513            goto failure;
     
    35363537#endif
    35373538
    3538     Log(("Successfully installed function replacement patch at %VGv\n", pInstrGC));
     3539    Log(("Successfully installed function replacement patch at %VRv\n", pInstrGC));
    35393540
    35403541    pPatch->uState = PATCH_ENABLED;
     
    35603561 *
    35613562 */
    3562 static int patmPatchMMIOInstr(PVM pVM, RTGCPTR32 pInstrGC, DISCPUSTATE *pCpu, PPATCHINFO pPatch)
     3563static int patmPatchMMIOInstr(PVM pVM, RTRCPTR pInstrGC, DISCPUSTATE *pCpu, PPATCHINFO pPatch)
    35633564{
    35643565    uint8_t *pPB;
     
    35813582
    35823583    /* Add relocation record for cached data access. */
    3583     if (patmPatchAddReloc32(pVM, pPatch, &pPB[pCpu->opsize - sizeof(RTGCPTR32)], FIXUP_ABSOLUTE, pPatch->pPrivInstrGC, pVM->patm.s.mmio.pCachedData) != VINF_SUCCESS)
     3584    if (patmPatchAddReloc32(pVM, pPatch, &pPB[pCpu->opsize - sizeof(RTRCPTR)], FIXUP_ABSOLUTE, pPatch->pPrivInstrGC, pVM->patm.s.mmio.pCachedData) != VINF_SUCCESS)
    35843585    {
    35853586        Log(("Relocation failed for cached mmio address!!\n"));
     
    35993600
    36003601    /* Replace address with that of the cached item. */
    3601     rc = PGMPhysWriteGCPtrDirty(pVM, pInstrGC + pCpu->opsize - sizeof(RTGCPTR32), &pVM->patm.s.mmio.pCachedData, sizeof(RTGCPTR32));
     3602    rc = PGMPhysWriteGCPtrDirty(pVM, pInstrGC + pCpu->opsize - sizeof(RTRCPTR), &pVM->patm.s.mmio.pCachedData, sizeof(RTRCPTR));
    36023603    AssertRC(rc);
    36033604    if (VBOX_FAILURE(rc))
     
    36353636 *
    36363637 */
    3637 static int patmPatchPATMMMIOInstr(PVM pVM, RTGCPTR32 pInstrGC, PPATCHINFO pPatch)
     3638static int patmPatchPATMMMIOInstr(PVM pVM, RTRCPTR pInstrGC, PPATCHINFO pPatch)
    36383639{
    36393640    DISCPUSTATE   cpu;
     
    36673668
    36683669    /* Add relocation record for cached data access. */
    3669     if (patmPatchAddReloc32(pVM, pPatch, &pInstrHC[cpu.opsize - sizeof(RTGCPTR32)], FIXUP_ABSOLUTE) != VINF_SUCCESS)
     3670    if (patmPatchAddReloc32(pVM, pPatch, &pInstrHC[cpu.opsize - sizeof(RTRCPTR)], FIXUP_ABSOLUTE) != VINF_SUCCESS)
    36703671    {
    36713672        Log(("Relocation failed for cached mmio address!!\n"));
     
    36733674    }
    36743675    /* Replace address with that of the cached item. */
    3675     *(RTGCPTR32 *)&pInstrHC[cpu.opsize - sizeof(RTGCPTR32)] = pVM->patm.s.mmio.pCachedData;
     3676    *(RTRCPTR *)&pInstrHC[cpu.opsize - sizeof(RTRCPTR)] = pVM->patm.s.mmio.pCachedData;
    36763677
    36773678    /* Lowest and highest address for write monitoring. */
     
    37483749 *
    37493750 */
    3750 PATMR3DECL(int) PATMR3PatchInstrInt3(PVM pVM, RTGCPTR32 pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATCHINFO pPatch)
     3751PATMR3DECL(int) PATMR3PatchInstrInt3(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATCHINFO pPatch)
    37513752{
    37523753    uint8_t ASMInt3 = 0xCC;
     
    38033804 *
    38043805 */
    3805 int patmPatchJump(PVM pVM, RTGCPTR32 pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATMPATCHREC pPatchRec)
     3806int patmPatchJump(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATMPATCHREC pPatchRec)
    38063807{
    38073808    PPATCHINFO pPatch = &pPatchRec->patch;
     
    38783879     * references the target instruction in the conflict patch.
    38793880     */
    3880     RTGCPTR32 pJmpDest = PATMR3GuestGCPtrToPatchGCPtr(pVM, pInstrGC + pCpu->opsize + (int32_t)pCpu->param1.parval);
    3881 
    3882     AssertMsg(pJmpDest, ("PATMR3GuestGCPtrToPatchGCPtr failed for %VGv\n", pInstrGC + pCpu->opsize + (int32_t)pCpu->param1.parval));
     3881    RTRCPTR pJmpDest = PATMR3GuestGCPtrToPatchGCPtr(pVM, pInstrGC + pCpu->opsize + (int32_t)pCpu->param1.parval);
     3882
     3883    AssertMsg(pJmpDest, ("PATMR3GuestGCPtrToPatchGCPtr failed for %VRv\n", pInstrGC + pCpu->opsize + (int32_t)pCpu->param1.parval));
    38833884    pPatch->pPatchJumpDestGC = pJmpDest;
    38843885
     
    38963897#endif
    38973898
    3898     Log(("Successfully installed %s patch at %VGv\n", patmGetInstructionString(pPatch->opcode, pPatch->flags), pInstrGC));
     3899    Log(("Successfully installed %s patch at %VRv\n", patmGetInstructionString(pPatch->opcode, pPatch->flags), pInstrGC));
    38993900
    39003901    STAM_COUNTER_INC(&pVM->patm.s.StatInstalledJump);
     
    39243925 * @param   flags       Patch flags
    39253926 */
    3926 PATMR3DECL(int) PATMR3AddHint(PVM pVM, RTGCPTR32 pInstrGC, uint32_t flags)
     3927PATMR3DECL(int) PATMR3AddHint(PVM pVM, RTRCPTR pInstrGC, uint32_t flags)
    39273928{
    39283929    Assert(pInstrGC);
    39293930    Assert(flags == PATMFL_CODE32);
    39303931
    3931     Log(("PATMR3AddHint %VGv\n", pInstrGC));
     3932    Log(("PATMR3AddHint %VRv\n", pInstrGC));
    39323933    return PATMR3InstallPatch(pVM, pInstrGC, PATMFL_CODE32 | PATMFL_INSTR_HINT);
    39333934}
     
    39433944 * @note    returns failure if patching is not allowed or possible
    39443945 */
    3945 PATMR3DECL(int) PATMR3InstallPatch(PVM pVM, RTGCPTR32 pInstrGC, uint64_t flags)
     3946PATMR3DECL(int) PATMR3InstallPatch(PVM pVM, RTRCPTR pInstrGC, uint64_t flags)
    39463947{
    39473948    DISCPUSTATE cpu;
     
    39663967    {
    39673968        PPATCHINFO pConflictPatch = PATMFindActivePatchByEntrypoint(pVM, pInstrGC);
    3968         AssertReleaseMsg(pConflictPatch == 0, ("Unable to patch overwritten instruction at %VGv (%VGv)\n", pInstrGC, pConflictPatch->pPrivInstrGC));
     3969        AssertReleaseMsg(pConflictPatch == 0, ("Unable to patch overwritten instruction at %VRv (%VRv)\n", pInstrGC, pConflictPatch->pPrivInstrGC));
    39693970        if (pConflictPatch != 0)
    39703971            return VERR_PATCHING_REFUSED;
     
    39863987    if (CPUMGetGuestCPL(pVM, CPUMCTX2CORE(pCtx)) == 0)
    39873988    {
    3988         RTGCPTR32 pInstrGCFlat = SELMToFlat(pVM, pCtx->eflags, pCtx->cs, &pCtx->csHid, pInstrGC);
     3989        RTRCPTR pInstrGCFlat = SELMToFlat(pVM, pCtx->eflags, pCtx->cs, &pCtx->csHid, pInstrGC);
    39893990        if (pInstrGCFlat != pInstrGC)
    39903991        {
    3991             Log(("PATMR3InstallPatch: code selector not wide open: %04x:%VGv != %VGv eflags=%08x\n", pCtx->cs, pInstrGCFlat, pInstrGC, pCtx->eflags.u32));
     3992            Log(("PATMR3InstallPatch: code selector not wide open: %04x:%VRv != %VRv eflags=%08x\n", pCtx->cs, pInstrGCFlat, pInstrGC, pCtx->eflags.u32));
    39923993            return VERR_PATCHING_REFUSED;
    39933994        }
     
    40054006        && (flags & PATMFL_MMIO_ACCESS))
    40064007    {
    4007         RTGCUINTPTR32 offset;
     4008        RTRCUINTPTR offset;
    40084009        void         *pvPatchCoreOffset;
    40094010
    40104011        /* Find the patch record. */
    40114012        offset = pInstrGC - pVM->patm.s.pPatchMemGC;
    4012         pvPatchCoreOffset = RTAvloGCPtrGetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, offset, false);
     4013        pvPatchCoreOffset = RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, offset, false);
    40134014        if (pvPatchCoreOffset == NULL)
    40144015        {
    4015             AssertMsgFailed(("PATMR3InstallPatch: patch not found at address %VGv!!\n", pInstrGC));
     4016            AssertMsgFailed(("PATMR3InstallPatch: patch not found at address %VRv!!\n", pInstrGC));
    40164017            return VERR_PATCH_NOT_FOUND;    //fatal error
    40174018        }
     
    40234024    AssertReturn(!PATMIsPatchGCAddr(pVM, pInstrGC), VERR_PATCHING_REFUSED);
    40244025
    4025     pPatchRec = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
     4026    pPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
    40264027    if (pPatchRec)
    40274028    {
     
    40344035        if (pPatchRec->patch.uState == PATCH_DISABLE_PENDING)
    40354036        {
    4036             Log(("PATMR3InstallPatch: disable operation is pending for patch at %VGv\n", pPatchRec->patch.pPrivInstrGC));
     4037            Log(("PATMR3InstallPatch: disable operation is pending for patch at %VRv\n", pPatchRec->patch.pPrivInstrGC));
    40374038            PATMR3DisablePatch(pVM, pPatchRec->patch.pPrivInstrGC);
    40384039            Assert(pPatchRec->patch.uState == PATCH_DISABLED);
     
    40444045            if (pPatchRec->patch.flags & PATMFL_INSTR_HINT)
    40454046            {
    4046                 Log(("Enabling HINTED patch %VGv\n", pInstrGC));
     4047                Log(("Enabling HINTED patch %VRv\n", pInstrGC));
    40474048                pPatchRec->patch.flags &= ~PATMFL_INSTR_HINT;
    40484049            }
    40494050            else
    4050                 Log(("Enabling patch %VGv again\n", pInstrGC));
     4051                Log(("Enabling patch %VRv again\n", pInstrGC));
    40514052
    40524053            /** @todo we shouldn't disable and enable patches too often (it's relatively cheap, but pointless if it always happens) */
     
    40674068            {
    40684069                /* Patch must have been overwritten; remove it and pretend nothing happened. */
    4069                 Log(("Patch an existing patched instruction?!? (%VGv)\n", pInstrGC));
     4070                Log(("Patch an existing patched instruction?!? (%VRv)\n", pInstrGC));
    40704071                if (pPatchRec->patch.flags & (PATMFL_DUPLICATE_FUNCTION|PATMFL_IDTHANDLER|PATMFL_MMIO_ACCESS|PATMFL_INT3_REPLACEMENT|PATMFL_INT3_REPLACEMENT_BLOCK))
    40714072                {
     
    40804081        else
    40814082        {
    4082             AssertMsg(pPatchRec->patch.uState == PATCH_REFUSED || pPatchRec->patch.uState == PATCH_UNUSABLE, ("Patch an existing patched instruction?!? (%VGv, state=%d)\n", pInstrGC, pPatchRec->patch.uState));
     4083            AssertMsg(pPatchRec->patch.uState == PATCH_REFUSED || pPatchRec->patch.uState == PATCH_UNUSABLE, ("Patch an existing patched instruction?!? (%VRv, state=%d)\n", pInstrGC, pPatchRec->patch.uState));
    40834084            /* already tried it once! */
    40844085            return VERR_PATCHING_REFUSED;
     
    40944095    pPatchRec->Core.Key = pInstrGC;
    40954096    pPatchRec->patch.uState = PATCH_REFUSED;   //default
    4096     rc = RTAvloGCPtrInsert(&pVM->patm.s.PatchLookupTreeHC->PatchTree, &pPatchRec->Core);
     4097    rc = RTAvloU32Insert(&pVM->patm.s.PatchLookupTreeHC->PatchTree, &pPatchRec->Core);
    40974098    Assert(rc);
    40984099
     
    41284129         * Close proximity to an unusable patch is a possible hint that this patch would turn out to be dangerous too!
    41294130         */
    4130         PPATMPATCHREC pPatchNear = (PPATMPATCHREC)RTAvloGCPtrGetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, (pInstrGC + SIZEOF_NEARJUMP32 - 1), false);
     4131        PPATMPATCHREC pPatchNear = (PPATMPATCHREC)RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, (pInstrGC + SIZEOF_NEARJUMP32 - 1), false);
    41314132        if (pPatchNear)
    41324133        {
    41334134            if (pPatchNear->patch.uState == PATCH_UNUSABLE && pInstrGC < pPatchNear->patch.pPrivInstrGC && pInstrGC + SIZEOF_NEARJUMP32 > pPatchNear->patch.pPrivInstrGC)
    41344135            {
    4135                 Log(("Dangerous patch; would overwrite the ususable patch at %VGv\n", pPatchNear->patch.pPrivInstrGC));
     4136                Log(("Dangerous patch; would overwrite the ususable patch at %VRv\n", pPatchNear->patch.pPrivInstrGC));
    41364137
    41374138                pPatchRec->patch.uState = PATCH_UNUSABLE;
     
    42374238            {
    42384239                if (rc == VINF_SUCCESS)
    4239                     Log(("PATMR3InstallPatch GUEST: %s %VGv code32=%d\n", patmGetInstructionString(pPatchRec->patch.opcode, pPatchRec->patch.flags), pInstrGC, (flags & PATMFL_CODE32) ? 1 : 0));
     4240                    Log(("PATMR3InstallPatch GUEST: %s %VRv code32=%d\n", patmGetInstructionString(pPatchRec->patch.opcode, pPatchRec->patch.flags), pInstrGC, (flags & PATMFL_CODE32) ? 1 : 0));
    42404241                return rc;
    42414242            }
     
    42554256            if (rc == VINF_SUCCESS)
    42564257            {
    4257                 Log(("PATMR3InstallPatch GUEST: %s %VGv code32=%d\n", patmGetInstructionString(pPatchRec->patch.opcode, pPatchRec->patch.flags), pInstrGC, (flags & PATMFL_CODE32) ? 1 : 0));
     4258                Log(("PATMR3InstallPatch GUEST: %s %VRv code32=%d\n", patmGetInstructionString(pPatchRec->patch.opcode, pPatchRec->patch.flags), pInstrGC, (flags & PATMFL_CODE32) ? 1 : 0));
    42584259                return VINF_SUCCESS;
    42594260            }
     
    42924293        case OP_PUSHF:
    42934294        case OP_CLI:
    4294             Log(("PATMR3InstallPatch %s %VGv code32=%d\n", patmGetInstructionString(pPatchRec->patch.opcode, pPatchRec->patch.flags), pInstrGC, (flags & PATMFL_CODE32) ? 1 : 0));
     4295            Log(("PATMR3InstallPatch %s %VRv code32=%d\n", patmGetInstructionString(pPatchRec->patch.opcode, pPatchRec->patch.flags), pInstrGC, (flags & PATMFL_CODE32) ? 1 : 0));
    42954296            rc = PATMR3PatchBlock(pVM, pInstrGC, pInstrHC, cpu.pCurInstr->opcode, opsize, pPatchRec);
    42964297            break;
     
    43354336            pVM->patm.s.pPatchedInstrGCHighest = pPatchRec->patch.pInstrGCHighest;
    43364337
    4337         Log(("Patch  lowest %VGv highest %VGv\n", pPatchRec->patch.pInstrGCLowest, pPatchRec->patch.pInstrGCHighest));
    4338         Log(("Global lowest %VGv highest %VGv\n", pVM->patm.s.pPatchedInstrGCLowest, pVM->patm.s.pPatchedInstrGCHighest));
     4338        Log(("Patch  lowest %VRv highest %VRv\n", pPatchRec->patch.pInstrGCLowest, pPatchRec->patch.pInstrGCHighest));
     4339        Log(("Global lowest %VRv highest %VRv\n", pVM->patm.s.pPatchedInstrGCLowest, pVM->patm.s.pPatchedInstrGCHighest));
    43394340
    43404341        STAM_COUNTER_ADD(&pVM->patm.s.StatInstalled, 1);
     
    43554356        {
    43564357            STAMR3RegisterCallback(pVM, &pPatchRec->patch, STAMVISIBILITY_NOT_GUI, STAMUNIT_GOOD_BAD, patmResetStat, patmPrintStat, "Patch statistics",
    4357                                    "/PATM/Stats/Patch/0x%VGv", pPatchRec->patch.pPrivInstrGC);
     4358                                   "/PATM/Stats/Patch/0x%VRv", pPatchRec->patch.pPrivInstrGC);
    43584359#ifndef DEBUG_sandervl
    43594360            /* Full breakdown for the GUI. */
    43604361            STAMR3RegisterF(pVM, &pVM->patm.s.pStatsHC[pPatchRec->patch.uPatchIdx], STAMTYPE_RATIO_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_GOOD_BAD, PATMPatchType(pVM, &pPatchRec->patch),
    4361                             "/PATM/Stats/PatchBD/0x%VGv", pPatchRec->patch.pPrivInstrGC);
    4362             STAMR3RegisterF(pVM, &pPatchRec->patch.cbPatchBlockSize,STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,      NULL, "/PATM/Stats/PatchBD/0x%VGv/cbPatchBlockSize", pPatchRec->patch.pPrivInstrGC);
    4363             STAMR3RegisterF(pVM, &pPatchRec->patch.cbPatchJump,     STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,      NULL, "/PATM/Stats/PatchBD/0x%VGv/cbPatchJump", pPatchRec->patch.pPrivInstrGC);
    4364             STAMR3RegisterF(pVM, &pPatchRec->patch.cbPrivInstr,     STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,      NULL, "/PATM/Stats/PatchBD/0x%VGv/cbPrivInstr", pPatchRec->patch.pPrivInstrGC);
    4365             STAMR3RegisterF(pVM, &pPatchRec->patch.cCodeWrites,     STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VGv/cCodeWrites", pPatchRec->patch.pPrivInstrGC);
    4366             STAMR3RegisterF(pVM, &pPatchRec->patch.cInvalidWrites,  STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VGv/cInvalidWrites", pPatchRec->patch.pPrivInstrGC);
    4367             STAMR3RegisterF(pVM, &pPatchRec->patch.cTraps,          STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VGv/cTraps", pPatchRec->patch.pPrivInstrGC);
    4368             STAMR3RegisterF(pVM, &pPatchRec->patch.flags,           STAMTYPE_X32, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE,       NULL, "/PATM/Stats/PatchBD/0x%VGv/flags", pPatchRec->patch.pPrivInstrGC);
    4369             STAMR3RegisterF(pVM, &pPatchRec->patch.nrJumpRecs,      STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VGv/nrJumpRecs", pPatchRec->patch.pPrivInstrGC);
    4370             STAMR3RegisterF(pVM, &pPatchRec->patch.nrFixups,        STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VGv/nrFixups", pPatchRec->patch.pPrivInstrGC);
    4371             STAMR3RegisterF(pVM, &pPatchRec->patch.opcode,          STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VGv/opcode", pPatchRec->patch.pPrivInstrGC);
    4372             STAMR3RegisterF(pVM, &pPatchRec->patch.uOldState,       STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE,       NULL, "/PATM/Stats/PatchBD/0x%VGv/uOldState", pPatchRec->patch.pPrivInstrGC);
    4373             STAMR3RegisterF(pVM, &pPatchRec->patch.uOpMode,         STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE,       NULL, "/PATM/Stats/PatchBD/0x%VGv/uOpMode", pPatchRec->patch.pPrivInstrGC);
     4362                            "/PATM/Stats/PatchBD/0x%VRv", pPatchRec->patch.pPrivInstrGC);
     4363            STAMR3RegisterF(pVM, &pPatchRec->patch.cbPatchBlockSize,STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,      NULL, "/PATM/Stats/PatchBD/0x%VRv/cbPatchBlockSize", pPatchRec->patch.pPrivInstrGC);
     4364            STAMR3RegisterF(pVM, &pPatchRec->patch.cbPatchJump,     STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,      NULL, "/PATM/Stats/PatchBD/0x%VRv/cbPatchJump", pPatchRec->patch.pPrivInstrGC);
     4365            STAMR3RegisterF(pVM, &pPatchRec->patch.cbPrivInstr,     STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,      NULL, "/PATM/Stats/PatchBD/0x%VRv/cbPrivInstr", pPatchRec->patch.pPrivInstrGC);
     4366            STAMR3RegisterF(pVM, &pPatchRec->patch.cCodeWrites,     STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VRv/cCodeWrites", pPatchRec->patch.pPrivInstrGC);
     4367            STAMR3RegisterF(pVM, &pPatchRec->patch.cInvalidWrites,  STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VRv/cInvalidWrites", pPatchRec->patch.pPrivInstrGC);
     4368            STAMR3RegisterF(pVM, &pPatchRec->patch.cTraps,          STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VRv/cTraps", pPatchRec->patch.pPrivInstrGC);
     4369            STAMR3RegisterF(pVM, &pPatchRec->patch.flags,           STAMTYPE_X32, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE,       NULL, "/PATM/Stats/PatchBD/0x%VRv/flags", pPatchRec->patch.pPrivInstrGC);
     4370            STAMR3RegisterF(pVM, &pPatchRec->patch.nrJumpRecs,      STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VRv/nrJumpRecs", pPatchRec->patch.pPrivInstrGC);
     4371            STAMR3RegisterF(pVM, &pPatchRec->patch.nrFixups,        STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VRv/nrFixups", pPatchRec->patch.pPrivInstrGC);
     4372            STAMR3RegisterF(pVM, &pPatchRec->patch.opcode,          STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PATM/Stats/PatchBD/0x%VRv/opcode", pPatchRec->patch.pPrivInstrGC);
     4373            STAMR3RegisterF(pVM, &pPatchRec->patch.uOldState,       STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE,       NULL, "/PATM/Stats/PatchBD/0x%VRv/uOldState", pPatchRec->patch.pPrivInstrGC);
     4374            STAMR3RegisterF(pVM, &pPatchRec->patch.uOpMode,         STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE,       NULL, "/PATM/Stats/PatchBD/0x%VRv/uOpMode", pPatchRec->patch.pPrivInstrGC);
    43744375            /// @todo change the state to be a callback so we can get a state mnemonic instead.
    4375             STAMR3RegisterF(pVM, &pPatchRec->patch.uState,          STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE,       NULL, "/PATM/Stats/PatchBD/0x%VGv/uState", pPatchRec->patch.pPrivInstrGC);
     4376            STAMR3RegisterF(pVM, &pPatchRec->patch.uState,          STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE,       NULL, "/PATM/Stats/PatchBD/0x%VRv/uState", pPatchRec->patch.pPrivInstrGC);
    43764377#endif
    43774378        }
     
    43894390 * @param   pInstrGC    Instruction address
    43904391 */
    4391 static uint32_t patmGetInstrSize(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pInstrGC)
     4392static uint32_t patmGetInstrSize(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC)
    43924393{
    43934394    uint8_t *pInstrHC;
     
    44164417 * @param   pPatch      Patch record
    44174418 */
    4418 int patmAddPatchToPage(PVM pVM, RTGCUINTPTR32 pPage, PPATCHINFO pPatch)
     4419int patmAddPatchToPage(PVM pVM, RTRCUINTPTR pPage, PPATCHINFO pPatch)
    44194420{
    44204421    PPATMPATCHPAGE pPatchPage;
    44214422    int            rc;
    44224423
    4423     Log(("patmAddPatchToPage: insert patch %VHv to page %VGv\n", pPatch, pPage));
    4424 
    4425     pPatchPage = (PPATMPATCHPAGE)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, pPage);
     4424    Log(("patmAddPatchToPage: insert patch %VHv to page %VRv\n", pPatch, pPage));
     4425
     4426    pPatchPage = (PPATMPATCHPAGE)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, pPage);
    44264427    if (pPatchPage)
    44274428    {
     
    44664467        pPatchPage->aPatch[0] = pPatch;
    44674468
    4468         rc = RTAvloGCPtrInsert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, &pPatchPage->Core);
     4469        rc = RTAvloU32Insert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, &pPatchPage->Core);
    44694470        Assert(rc);
    44704471        pVM->patm.s.cPageRecords++;
     
    44754476
    44764477    /* Get the closest guest instruction (from below) */
    4477     PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlGCPtrGetBestFit(&pPatch->Guest2PatchAddrTree, pPage, true);
     4478    PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlU32GetBestFit(&pPatch->Guest2PatchAddrTree, pPage, true);
    44784479    Assert(pGuestToPatchRec);
    44794480    if (pGuestToPatchRec)
    44804481    {
    4481         LogFlow(("patmAddPatchToPage: lowest patch page address %VGv current lowest %VGv\n", pGuestToPatchRec->Core.Key, pPatchPage->pLowestAddrGC));
     4482        LogFlow(("patmAddPatchToPage: lowest patch page address %VRv current lowest %VRv\n", pGuestToPatchRec->Core.Key, pPatchPage->pLowestAddrGC));
    44824483        if (    pPatchPage->pLowestAddrGC == 0
    4483             ||  pPatchPage->pLowestAddrGC > (RTGCPTR32)pGuestToPatchRec->Core.Key)
    4484         {
    4485             RTGCUINTPTR32 offset;
    4486 
    4487             pPatchPage->pLowestAddrGC = (RTGCPTR32)pGuestToPatchRec->Core.Key;
     4484            ||  pPatchPage->pLowestAddrGC > (RTRCPTR)pGuestToPatchRec->Core.Key)
     4485        {
     4486            RTRCUINTPTR offset;
     4487
     4488            pPatchPage->pLowestAddrGC = (RTRCPTR)pGuestToPatchRec->Core.Key;
    44884489
    44894490            offset = pPatchPage->pLowestAddrGC & PAGE_OFFSET_MASK;
     
    44924493            {
    44934494                /* Get the closest guest instruction (from above) */
    4494                 pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlGCPtrGetBestFit(&pPatch->Guest2PatchAddrTree, pPage-1, false);
     4495                pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlU32GetBestFit(&pPatch->Guest2PatchAddrTree, pPage-1, false);
    44954496
    44964497                if (pGuestToPatchRec)
    44974498                {
    4498                     uint32_t size = patmGetInstrSize(pVM, pPatch, (RTGCPTR32)pGuestToPatchRec->Core.Key);
    4499                     if ((RTGCUINTPTR32)pGuestToPatchRec->Core.Key + size  > pPage)
     4499                    uint32_t size = patmGetInstrSize(pVM, pPatch, (RTRCPTR)pGuestToPatchRec->Core.Key);
     4500                    if ((RTRCUINTPTR)pGuestToPatchRec->Core.Key + size  > pPage)
    45004501                    {
    45014502                        pPatchPage->pLowestAddrGC = pPage;
    4502                         LogFlow(("patmAddPatchToPage: new lowest %VGv\n", pPatchPage->pLowestAddrGC));
     4503                        LogFlow(("patmAddPatchToPage: new lowest %VRv\n", pPatchPage->pLowestAddrGC));
    45034504                    }
    45044505                }
     
    45084509
    45094510    /* Get the closest guest instruction (from above) */
    4510     pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlGCPtrGetBestFit(&pPatch->Guest2PatchAddrTree, pPage+PAGE_SIZE-1, false);
     4511    pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlU32GetBestFit(&pPatch->Guest2PatchAddrTree, pPage+PAGE_SIZE-1, false);
    45114512    Assert(pGuestToPatchRec);
    45124513    if (pGuestToPatchRec)
    45134514    {
    4514         LogFlow(("patmAddPatchToPage: highest patch page address %VGv current lowest %VGv\n", pGuestToPatchRec->Core.Key, pPatchPage->pHighestAddrGC));
     4515        LogFlow(("patmAddPatchToPage: highest patch page address %VRv current lowest %VRv\n", pGuestToPatchRec->Core.Key, pPatchPage->pHighestAddrGC));
    45154516        if (    pPatchPage->pHighestAddrGC == 0
    4516             ||  pPatchPage->pHighestAddrGC <= (RTGCPTR32)pGuestToPatchRec->Core.Key)
    4517         {
    4518             pPatchPage->pHighestAddrGC = (RTGCPTR32)pGuestToPatchRec->Core.Key;
     4517            ||  pPatchPage->pHighestAddrGC <= (RTRCPTR)pGuestToPatchRec->Core.Key)
     4518        {
     4519            pPatchPage->pHighestAddrGC = (RTRCPTR)pGuestToPatchRec->Core.Key;
    45194520            /* Increase by instruction size. */
    45204521            uint32_t size = patmGetInstrSize(pVM, pPatch, pPatchPage->pHighestAddrGC);
    45214522////            Assert(size);
    45224523            pPatchPage->pHighestAddrGC += size;
    4523             LogFlow(("patmAddPatchToPage: new highest %VGv\n", pPatchPage->pHighestAddrGC));
     4524            LogFlow(("patmAddPatchToPage: new highest %VRv\n", pPatchPage->pHighestAddrGC));
    45244525        }
    45254526    }
     
    45364537 * @param   pPatch      Patch record
    45374538 */
    4538 int patmRemovePatchFromPage(PVM pVM, RTGCUINTPTR32 pPage, PPATCHINFO pPatch)
     4539int patmRemovePatchFromPage(PVM pVM, RTRCUINTPTR pPage, PPATCHINFO pPatch)
    45394540{
    45404541    PPATMPATCHPAGE pPatchPage;
    45414542    int            rc;
    45424543
    4543     pPatchPage = (PPATMPATCHPAGE)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, pPage);
     4544    pPatchPage = (PPATMPATCHPAGE)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, pPage);
    45444545    Assert(pPatchPage);
    45454546
     
    45494550    Assert(pPatchPage->cCount <= pPatchPage->cMaxPatches);
    45504551
    4551     Log(("patmRemovePatchPage: remove patch %VHv from page %VGv\n", pPatch, pPage));
     4552    Log(("patmRemovePatchPage: remove patch %VHv from page %VRv\n", pPatch, pPage));
    45524553    if (pPatchPage->cCount > 1)
    45534554    {
     
    45684569            memcpy(&pPatchPage->aPatch[i], &pPatchPage->aPatch[i+1], sizeof(PPATCHINFO)*(pPatchPage->cCount - (i+1)));
    45694570        }
    4570         AssertMsg(i < pPatchPage->cCount, ("Unable to find patch %VHv in page %VGv\n", pPatch, pPage));
     4571        AssertMsg(i < pPatchPage->cCount, ("Unable to find patch %VHv in page %VRv\n", pPatch, pPage));
    45714572
    45724573        pPatchPage->cCount--;
     
    45764577        PPATMPATCHPAGE pPatchNode;
    45774578
    4578         Log(("patmRemovePatchFromPage %VGv\n", pPage));
     4579        Log(("patmRemovePatchFromPage %VRv\n", pPage));
    45794580
    45804581        STAM_COUNTER_INC(&pVM->patm.s.StatPatchPageRemoved);
    4581         pPatchNode = (PPATMPATCHPAGE)RTAvloGCPtrRemove(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, pPage);
     4582        pPatchNode = (PPATMPATCHPAGE)RTAvloU32Remove(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, pPage);
    45824583        Assert(pPatchNode && pPatchNode == pPatchPage);
    45834584
     
    46024603{
    46034604    int           rc;
    4604     RTGCUINTPTR32 pPatchPageStart, pPatchPageEnd, pPage;
     4605    RTRCUINTPTR pPatchPageStart, pPatchPageEnd, pPage;
    46054606
    46064607    /* Insert the pages that contain patched instructions into a lookup tree for detecting self-modifying code. */
    4607     pPatchPageStart = (RTGCUINTPTR32)pPatch->pInstrGCLowest  & PAGE_BASE_GC_MASK;
    4608     pPatchPageEnd   = (RTGCUINTPTR32)pPatch->pInstrGCHighest & PAGE_BASE_GC_MASK;
     4608    pPatchPageStart = (RTRCUINTPTR)pPatch->pInstrGCLowest  & PAGE_BASE_GC_MASK;
     4609    pPatchPageEnd   = (RTRCUINTPTR)pPatch->pInstrGCHighest & PAGE_BASE_GC_MASK;
    46094610
    46104611    /** @todo optimize better (large gaps between current and next used page) */
     
    46124613    {
    46134614        /* Get the closest guest instruction (from above) */
    4614         PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlGCPtrGetBestFit(&pPatch->Guest2PatchAddrTree, pPage, true);
     4615        PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlU32GetBestFit(&pPatch->Guest2PatchAddrTree, pPage, true);
    46154616        if (    pGuestToPatchRec
    46164617            &&  PAGE_ADDRESS(pGuestToPatchRec->Core.Key) == PAGE_ADDRESS(pPage)
     
    46364637{
    46374638    int         rc;
    4638     RTGCUINTPTR32 pPatchPageStart, pPatchPageEnd, pPage;
     4639    RTRCUINTPTR pPatchPageStart, pPatchPageEnd, pPage;
    46394640
    46404641    /* Insert the pages that contain patched instructions into a lookup tree for detecting self-modifying code. */
    4641     pPatchPageStart = (RTGCUINTPTR32)pPatch->pInstrGCLowest  & PAGE_BASE_GC_MASK;
    4642     pPatchPageEnd   = (RTGCUINTPTR32)pPatch->pInstrGCHighest & PAGE_BASE_GC_MASK;
     4642    pPatchPageStart = (RTRCUINTPTR)pPatch->pInstrGCLowest  & PAGE_BASE_GC_MASK;
     4643    pPatchPageEnd   = (RTRCUINTPTR)pPatch->pInstrGCHighest & PAGE_BASE_GC_MASK;
    46434644
    46444645    for(pPage = pPatchPageStart; pPage <= pPatchPageEnd; pPage += PAGE_SIZE)
    46454646    {
    46464647        /* Get the closest guest instruction (from above) */
    4647         PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlGCPtrGetBestFit(&pPatch->Guest2PatchAddrTree, pPage, true);
     4648        PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlU32GetBestFit(&pPatch->Guest2PatchAddrTree, pPage, true);
    46484649        if (    pGuestToPatchRec
    46494650            &&  PAGE_ADDRESS(pGuestToPatchRec->Core.Key) == PAGE_ADDRESS(pPage) /** @todo bird: PAGE_ADDRESS is for the current context really. check out these. */
     
    46684669 *
    46694670 */
    4670 PATMR3DECL(int) PATMR3PatchWrite(PVM pVM, RTGCPTR32 GCPtr, uint32_t cbWrite)
    4671 {
    4672     RTGCUINTPTR32          pWritePageStart, pWritePageEnd, pPage;
    4673 
    4674     Log(("PATMR3PatchWrite %VGv %x\n", GCPtr, cbWrite));
     4671PATMR3DECL(int) PATMR3PatchWrite(PVM pVM, RTRCPTR GCPtr, uint32_t cbWrite)
     4672{
     4673    RTRCUINTPTR          pWritePageStart, pWritePageEnd, pPage;
     4674
     4675    Log(("PATMR3PatchWrite %VRv %x\n", GCPtr, cbWrite));
    46754676
    46764677    Assert(VM_IS_EMT(pVM));
     
    46844685    STAM_PROFILE_ADV_START(&pVM->patm.s.StatPatchWrite, a);
    46854686
    4686     pWritePageStart =  (RTGCUINTPTR32)GCPtr & PAGE_BASE_GC_MASK;
    4687     pWritePageEnd   = ((RTGCUINTPTR32)GCPtr + cbWrite - 1) & PAGE_BASE_GC_MASK;
     4687    pWritePageStart =  (RTRCUINTPTR)GCPtr & PAGE_BASE_GC_MASK;
     4688    pWritePageEnd   = ((RTRCUINTPTR)GCPtr + cbWrite - 1) & PAGE_BASE_GC_MASK;
    46884689
    46894690    for (pPage = pWritePageStart; pPage <= pWritePageEnd; pPage += PAGE_SIZE)
    46904691    {
    46914692loop_start:
    4692         PPATMPATCHPAGE pPatchPage = (PPATMPATCHPAGE)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, (RTGCPTR32)pPage);
     4693        PPATMPATCHPAGE pPatchPage = (PPATMPATCHPAGE)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, (RTRCPTR)pPage);
    46934694        if (pPatchPage)
    46944695        {
     
    46974698
    46984699            /* Quick check to see if the write is in the patched part of the page */
    4699             if (    pPatchPage->pLowestAddrGC  > (RTGCPTR32)((RTGCUINTPTR32)GCPtr + cbWrite - 1)
     4700            if (    pPatchPage->pLowestAddrGC  > (RTRCPTR)((RTRCUINTPTR)GCPtr + cbWrite - 1)
    47004701                ||  pPatchPage->pHighestAddrGC < GCPtr)
    47014702            {
     
    47084709                {
    47094710                    PPATCHINFO pPatch = pPatchPage->aPatch[i];
    4710                     RTGCPTR32 pPatchInstrGC;
     4711                    RTRCPTR pPatchInstrGC;
    47114712                    //unused: bool    fForceBreak = false;
    47124713
     
    47154716                    for (uint32_t j=0; j<cbWrite; j++)
    47164717                    {
    4717                         RTGCPTR32 pGuestPtrGC = (RTGCPTR32)((RTGCUINTPTR32)GCPtr + j);
     4718                        RTRCPTR pGuestPtrGC = (RTRCPTR)((RTRCUINTPTR)GCPtr + j);
    47184719
    47194720                        if (    pPatch->cbPatchJump
     
    47344735                        if (!pPatchInstrGC)
    47354736                        {
    4736                             RTGCPTR32  pClosestInstrGC;
     4737                            RTRCPTR  pClosestInstrGC;
    47374738                            uint32_t size;
    47384739
     
    47584759                            if (pPatchToGuestRec && !pPatchToGuestRec->fDirty)
    47594760                            {
    4760                                 Log(("PATMR3PatchWrite: Found patched instruction %VGv -> %VGv\n", pGuestPtrGC, pPatchInstrGC));
     4761                                Log(("PATMR3PatchWrite: Found patched instruction %VRv -> %VRv\n", pGuestPtrGC, pPatchInstrGC));
    47614762
    47624763                                if (++pPatch->cCodeWrites > PATM_MAX_CODE_WRITES)
    47634764                                {
    4764                                     LogRel(("PATM: Disable block at %VGv - write %VGv-%VGv\n", pPatch->pPrivInstrGC, pGuestPtrGC, pGuestPtrGC+cbWrite));
     4765                                    LogRel(("PATM: Disable block at %VRv - write %VRv-%VRv\n", pPatch->pPrivInstrGC, pGuestPtrGC, pGuestPtrGC+cbWrite));
    47654766
    47664767                                    PATMR3MarkDirtyPatch(pVM, pPatch);
     
    47954796                 */
    47964797invalid_write_loop_start:
    4797                 pPatchPage = (PPATMPATCHPAGE)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, (RTGCPTR32)pPage);
     4798                pPatchPage = (PPATMPATCHPAGE)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, (RTRCPTR)pPage);
    47984799
    47994800                if (pPatchPage)
     
    48084809                            if (pPatch->flags & PATMFL_IDTHANDLER)
    48094810                            {
    4810                                 LogRel(("PATM: Stop monitoring IDT handler pages at %VGv - invalid write %VGv-%VGv (this is not a fatal error)\n", pPatch->pPrivInstrGC, GCPtr, GCPtr+cbWrite));
     4811                                LogRel(("PATM: Stop monitoring IDT handler pages at %VRv - invalid write %VRv-%VRv (this is not a fatal error)\n", pPatch->pPrivInstrGC, GCPtr, GCPtr+cbWrite));
    48114812
    48124813                                Assert(pPatch->flags & PATMFL_CODE_MONITORED);
     
    48164817                            else
    48174818                            {
    4818                                 LogRel(("PATM: Disable block at %VGv - invalid write %VGv-%VGv \n", pPatch->pPrivInstrGC, GCPtr, GCPtr+cbWrite));
     4819                                LogRel(("PATM: Disable block at %VRv - invalid write %VRv-%VRv \n", pPatch->pPrivInstrGC, GCPtr, GCPtr+cbWrite));
    48194820                                PATMR3MarkDirtyPatch(pVM, pPatch);
    48204821                            }
     
    48414842/** @note Currently only called by CSAMR3FlushPage; optimization to avoid having to double check if the physical address has changed
    48424843 */
    4843 PATMR3DECL(int) PATMR3FlushPage(PVM pVM, RTGCPTR32 addr)
     4844PATMR3DECL(int) PATMR3FlushPage(PVM pVM, RTRCPTR addr)
    48444845{
    48454846    addr &= PAGE_BASE_GC_MASK;
    48464847
    4847     PPATMPATCHPAGE pPatchPage = (PPATMPATCHPAGE)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, addr);
     4848    PPATMPATCHPAGE pPatchPage = (PPATMPATCHPAGE)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPage, addr);
    48484849    if (pPatchPage)
    48494850    {
     
    48574858                PPATCHINFO pPatch = pPatchPage->aPatch[i];
    48584859
    4859                 Log(("PATMR3FlushPage %VGv remove patch at %VGv\n", addr, pPatch->pPrivInstrGC));
     4860                Log(("PATMR3FlushPage %VRv remove patch at %VRv\n", addr, pPatch->pPrivInstrGC));
    48604861                PATMR3MarkDirtyPatch(pVM, pPatch);
    48614862            }
     
    48734874 * @param   pInstrGC    Guest context pointer to instruction
    48744875 */
    4875 PATMR3DECL(bool) PATMR3HasBeenPatched(PVM pVM, RTGCPTR32 pInstrGC)
     4876PATMR3DECL(bool) PATMR3HasBeenPatched(PVM pVM, RTRCPTR pInstrGC)
    48764877{
    48774878    PPATMPATCHREC pPatchRec;
    4878     pPatchRec = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
     4879    pPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
    48794880    if (pPatchRec && pPatchRec->patch.uState == PATCH_ENABLED)
    48804881        return true;
     
    48914892 *
    48924893 */
    4893 PATMR3DECL(int) PATMR3QueryOpcode(PVM pVM, RTGCPTR32 pInstrGC, uint8_t *pByte)
     4894PATMR3DECL(int) PATMR3QueryOpcode(PVM pVM, RTRCPTR pInstrGC, uint8_t *pByte)
    48944895{
    48954896    PPATMPATCHREC pPatchRec;
     
    49054906    }
    49064907
    4907     pPatchRec = (PPATMPATCHREC)RTAvloGCPtrGetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC, false);
     4908    pPatchRec = (PPATMPATCHREC)RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC, false);
    49084909    // if the patch is enabled and the pointer lies within 5 bytes of this priv instr ptr, then we've got a hit!
    49094910    if (    pPatchRec
     
    49124913        &&  pInstrGC < pPatchRec->patch.pPrivInstrGC + pPatchRec->patch.cbPatchJump)
    49134914    {
    4914         RTGCPTR32 offset = pInstrGC - pPatchRec->patch.pPrivInstrGC;
     4915        RTRCPTR offset = pInstrGC - pPatchRec->patch.pPrivInstrGC;
    49154916        *pByte = pPatchRec->patch.aPrivInstr[offset];
    49164917
    49174918        if (pPatchRec->patch.cbPatchJump == 1)
    49184919        {
    4919             Log(("PATMR3QueryOpcode: returning opcode %2X for instruction at %VGv\n", *pByte, pInstrGC));
     4920            Log(("PATMR3QueryOpcode: returning opcode %2X for instruction at %VRv\n", *pByte, pInstrGC));
    49204921        }
    49214922        STAM_COUNTER_ADD(&pVM->patm.s.StatNrOpcodeRead, 1);
     
    49354936 *
    49364937 */
    4937 PATMR3DECL(int) PATMR3DisablePatch(PVM pVM, RTGCPTR32 pInstrGC)
     4938PATMR3DECL(int) PATMR3DisablePatch(PVM pVM, RTRCPTR pInstrGC)
    49384939{
    49394940    PPATMPATCHREC pPatchRec;
    49404941    PPATCHINFO    pPatch;
    49414942
    4942     Log(("PATMR3DisablePatch: %VGv\n", pInstrGC));
    4943     pPatchRec = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
     4943    Log(("PATMR3DisablePatch: %VRv\n", pInstrGC));
     4944    pPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
    49444945    if (pPatchRec)
    49454946    {
     
    49634964            {
    49644965                TRPMR3SetGuestTrapHandler(pVM, iGate, TRPM_INVALID_HANDLER);
    4965                 LogRel(("PATM: Disabling IDT %x patch handler %VGv\n", iGate, pInstrGC));
     4966                LogRel(("PATM: Disabling IDT %x patch handler %VRv\n", iGate, pInstrGC));
    49664967            }
    49674968        }
     
    49714972            &&  pPatch->uState == PATCH_ENABLED)
    49724973        {
    4973             Log(("Invalidate patch at %VGv (HC=%VGv)\n", PATCHCODE_PTR_GC(pPatch), PATCHCODE_PTR_HC(pPatch)));
     4974            Log(("Invalidate patch at %VRv (HC=%VRv)\n", PATCHCODE_PTR_GC(pPatch), PATCHCODE_PTR_HC(pPatch)));
    49744975            pPatch->bDirtyOpcode   = *PATCHCODE_PTR_HC(pPatch);
    49754976            *PATCHCODE_PTR_HC(pPatch) = 0xCC;
     
    49844985            if (pPatch->uState != PATCH_REFUSED)
    49854986            {
    4986                 AssertMsg(pPatch->pPrivInstrHC, ("Invalid HC pointer?!? (%VGv)\n", pInstrGC));
     4987                AssertMsg(pPatch->pPrivInstrHC, ("Invalid HC pointer?!? (%VRv)\n", pInstrGC));
    49874988                Assert(pPatch->cbPatchJump);
    49884989
     
    50005001                    if (rc == VINF_SUCCESS)
    50015002                    {
    5002                         RTGCINTPTR displ = (RTGCUINTPTR32)PATCHCODE_PTR_GC(pPatch) - ((RTGCUINTPTR32)pPatch->pPrivInstrGC + SIZEOF_NEARJUMP32);
     5003                        RTRCINTPTR displ = (RTRCUINTPTR)PATCHCODE_PTR_GC(pPatch) - ((RTRCUINTPTR)pPatch->pPrivInstrGC + SIZEOF_NEARJUMP32);
    50035004
    50045005                        if (    temp[0] != 0xE9 /* jmp opcode */
    5005                             ||  *(RTGCINTPTR *)(&temp[1]) != displ
     5006                            ||  *(RTRCINTPTR *)(&temp[1]) != displ
    50065007                           )
    50075008                        {
     
    50735074        }
    50745075
    5075         Log(("PATMR3DisablePatch: disabled patch at %VGv\n", pInstrGC));
     5076        Log(("PATMR3DisablePatch: disabled patch at %VRv\n", pInstrGC));
    50765077        return VINF_SUCCESS;
    50775078    }
     
    50905091 *
    50915092 */
    5092 static int patmDisableUnusablePatch(PVM pVM, RTGCPTR32 pInstrGC, RTGCPTR32 pConflictAddr, PPATCHINFO pConflictPatch)
     5093static int patmDisableUnusablePatch(PVM pVM, RTRCPTR pInstrGC, RTRCPTR pConflictAddr, PPATCHINFO pConflictPatch)
    50935094{
    50945095#ifdef PATM_RESOLVE_CONFLICTS_WITH_JUMP_PATCHES
     
    51165117        if (pConflictPatch->flags & PATMFL_INSTR_HINT)
    51175118        {
    5118             Log(("Enabling HINTED patch %VGv\n", pConflictPatch->pPrivInstrGC));
     5119            Log(("Enabling HINTED patch %VRv\n", pConflictPatch->pPrivInstrGC));
    51195120            pConflictPatch->flags &= ~PATMFL_INSTR_HINT;
    51205121            rc = PATMR3EnablePatch(pVM, pConflictPatch->pPrivInstrGC);
     
    51285129        if (VBOX_SUCCESS(rc))
    51295130        {
    5130             Log(("PATM -> CONFLICT: Installed JMP patch for patch conflict at %VGv\n", pInstrGC));
     5131            Log(("PATM -> CONFLICT: Installed JMP patch for patch conflict at %VRv\n", pInstrGC));
    51315132            STAM_COUNTER_INC(&pVM->patm.s.StatFixedConflicts);
    51325133            return VINF_SUCCESS;
     
    51385139    {
    51395140        /* Turn it into an int3 patch; our GC trap handler will call the generated code manually. */
    5140         Log(("PATM -> CONFLICT: Found active patch at instruction %VGv with target %VGv -> turn into int 3 patch!!\n", pInstrGC, pConflictPatch->pPrivInstrGC));
     5141        Log(("PATM -> CONFLICT: Found active patch at instruction %VRv with target %VRv -> turn into int 3 patch!!\n", pInstrGC, pConflictPatch->pPrivInstrGC));
    51415142        int rc =  PATMR3DisablePatch(pVM, pConflictPatch->pPrivInstrGC);
    51425143        if (rc == VWRN_PATCH_REMOVED)
     
    51615162    else
    51625163    {
    5163         Log(("PATM -> CONFLICT: Found active patch at instruction %VGv with target %VGv -> DISABLING it!!\n", pInstrGC, pConflictPatch->pPrivInstrGC));
     5164        Log(("PATM -> CONFLICT: Found active patch at instruction %VRv with target %VRv -> DISABLING it!!\n", pInstrGC, pConflictPatch->pPrivInstrGC));
    51645165        int rc = PATMR3DisablePatch(pVM, pConflictPatch->pPrivInstrGC);
    51655166        if (rc == VWRN_PATCH_REMOVED)
     
    51885189 *
    51895190 */
    5190 PATMR3DECL(int) PATMR3EnablePatch(PVM pVM, RTGCPTR32 pInstrGC)
     5191PATMR3DECL(int) PATMR3EnablePatch(PVM pVM, RTRCPTR pInstrGC)
    51915192{
    51925193    PPATMPATCHREC pPatchRec;
    51935194    PPATCHINFO    pPatch;
    51945195
    5195     Log(("PATMR3EnablePatch %VGv\n", pInstrGC));
    5196     pPatchRec = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
     5196    Log(("PATMR3EnablePatch %VRv\n", pInstrGC));
     5197    pPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
    51975198    if (pPatchRec)
    51985199    {
     
    52855286        }
    52865287        else
    5287             Log(("PATMR3EnablePatch: Unable to enable patch %VGv with state %d\n", pInstrGC, pPatch->uState));
     5288            Log(("PATMR3EnablePatch: Unable to enable patch %VRv with state %d\n", pInstrGC, pPatch->uState));
    52885289
    52895290        return rc;
     
    53145315    if (pPatchRec->patch.pPatchBlockOffset)
    53155316    {
    5316         PAVLOGCPTRNODECORE pNode;
    5317 
    5318         pNode = RTAvloGCPtrRemove(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, pPatchRec->patch.pPatchBlockOffset);
     5317        PAVLOU32NODECORE pNode;
     5318
     5319        pNode = RTAvloU32Remove(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, pPatchRec->patch.pPatchBlockOffset);
    53195320        Assert(pNode);
    53205321    }
     
    53625363
    53635364    /** @note might fail, because it has already been removed (e.g. during reset). */
    5364     RTAvloGCPtrRemove(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pPatchRec->Core.Key);
     5365    RTAvloU32Remove(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pPatchRec->Core.Key);
    53655366
    53665367    /* Free the patch record */
     
    53805381    PPATCHINFO  pPatch;
    53815382    int         rc;
    5382     RTGCPTR32     pInstrGC = pPatchRec->patch.pPrivInstrGC;
    5383 
    5384     Log(("patmR3RefreshPatch: attempt to refresh patch at %VGv\n", pInstrGC));
     5383    RTRCPTR     pInstrGC = pPatchRec->patch.pPrivInstrGC;
     5384
     5385    Log(("patmR3RefreshPatch: attempt to refresh patch at %VRv\n", pInstrGC));
    53855386
    53865387    pPatch = &pPatchRec->patch;
     
    53985399
    53995400    /** Kick it out of the lookup tree to make sure PATMR3InstallPatch doesn't fail (hack alert) */
    5400     RTAvloGCPtrRemove(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pPatchRec->Core.Key);
     5401    RTAvloU32Remove(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pPatchRec->Core.Key);
    54015402#ifdef VBOX_WITH_STATISTICS
    54025403    if (PATM_STAT_INDEX_IS_VALID(pPatchRec->patch.uPatchIdx))
     
    54285429    if (VBOX_SUCCESS(rc))
    54295430    {
    5430         RTGCPTR32         pPatchTargetGC;
     5431        RTRCPTR         pPatchTargetGC;
    54315432        PPATMPATCHREC   pNewPatchRec;
    54325433
     
    54485449            goto failure;
    54495450
    5450         pNewPatchRec = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
     5451        pNewPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
    54515452        Assert(pNewPatchRec); /* can't fail */
    54525453
     
    54565457
    54575458        /* Put the new patch back into the tree, because removing the old one kicked this one out. (hack alert) */
    5458         RTAvloGCPtrInsert(&pVM->patm.s.PatchLookupTreeHC->PatchTree, &pNewPatchRec->Core);
    5459 
    5460         LogRel(("PATM: patmR3RefreshPatch: succeeded to refresh patch at %VGv \n", pInstrGC));
     5459        RTAvloU32Insert(&pVM->patm.s.PatchLookupTreeHC->PatchTree, &pNewPatchRec->Core);
     5460
     5461        LogRel(("PATM: patmR3RefreshPatch: succeeded to refresh patch at %VRv \n", pInstrGC));
    54615462        STAM_COUNTER_INC(&pVM->patm.s.StatPatchRefreshSuccess);
    54625463    }
     
    54655466    if (VBOX_FAILURE(rc))
    54665467    {
    5467         LogRel(("PATM: patmR3RefreshPatch: failed to refresh patch at %VGv. Reactiving old one. \n", pInstrGC));
     5468        LogRel(("PATM: patmR3RefreshPatch: failed to refresh patch at %VRv. Reactiving old one. \n", pInstrGC));
    54685469
    54695470        /* Remove the new inactive patch */
     
    54725473
    54735474        /* Put the old patch back into the tree (or else it won't be saved) (hack alert) */
    5474         RTAvloGCPtrInsert(&pVM->patm.s.PatchLookupTreeHC->PatchTree, &pPatchRec->Core);
     5475        RTAvloU32Insert(&pVM->patm.s.PatchLookupTreeHC->PatchTree, &pPatchRec->Core);
    54755476
    54765477        /* Enable again in case the dirty instruction is near the end and there are safe code paths. */
     
    54925493 *
    54935494 */
    5494 PPATCHINFO PATMFindActivePatchByEntrypoint(PVM pVM, RTGCPTR32 pInstrGC, bool fIncludeHints)
    5495 {
    5496     PPATMPATCHREC pPatchRec = (PPATMPATCHREC)RTAvloGCPtrGetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC, false);
     5495PPATCHINFO PATMFindActivePatchByEntrypoint(PVM pVM, RTRCPTR pInstrGC, bool fIncludeHints)
     5496{
     5497    PPATMPATCHREC pPatchRec = (PPATMPATCHREC)RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC, false);
    54975498    /* if the patch is enabled, the pointer is not indentical to the privileged patch ptr and it lies within 5 bytes of this priv instr ptr, then we've got a hit! */
    54985499    if (pPatchRec)
     
    55035504            &&  pInstrGC < pPatchRec->patch.pPrivInstrGC + pPatchRec->patch.cbPatchJump)
    55045505        {
    5505             Log(("Found active patch at %VGv (org %VGv)\n", pInstrGC, pPatchRec->patch.pPrivInstrGC));
     5506            Log(("Found active patch at %VRv (org %VRv)\n", pInstrGC, pPatchRec->patch.pPrivInstrGC));
    55065507            return &pPatchRec->patch;
    55075508        }
     
    55135514            &&  pInstrGC < pPatchRec->patch.pPrivInstrGC + pPatchRec->patch.cbPatchJump)
    55145515        {
    5515             Log(("Found HINT patch at %VGv (org %VGv)\n", pInstrGC, pPatchRec->patch.pPrivInstrGC));
     5516            Log(("Found HINT patch at %VRv (org %VRv)\n", pInstrGC, pPatchRec->patch.pPrivInstrGC));
    55165517            return &pPatchRec->patch;
    55175518        }
     
    55285529 * @param   pPatchAddr  Guest context patch address (if true)
    55295530 */
    5530 PATMR3DECL(bool) PATMR3IsInsidePatchJump(PVM pVM, RTGCPTR32 pAddr, PRTGCPTR32 pPatchAddr)
    5531 {
    5532     RTGCPTR32 addr;
     5531PATMR3DECL(bool) PATMR3IsInsidePatchJump(PVM pVM, RTRCPTR pAddr, PRTGCPTR32 pPatchAddr)
     5532{
     5533    RTRCPTR addr;
    55335534    PPATCHINFO pPatch;
    55345535
     
    55595560 *
    55605561 */
    5561 PATMR3DECL(int) PATMR3RemovePatch(PVM pVM, RTGCPTR32 pInstrGC)
     5562PATMR3DECL(int) PATMR3RemovePatch(PVM pVM, RTRCPTR pInstrGC)
    55625563{
    55635564    PPATMPATCHREC pPatchRec;
    55645565
    5565     pPatchRec = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
     5566    pPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC);
    55665567    if (pPatchRec)
    55675568    {
     
    55895590    if (pPatch->pPatchBlockOffset)
    55905591    {
    5591         Log(("Invalidate patch at %VGv (HC=%VGv)\n", PATCHCODE_PTR_GC(pPatch), PATCHCODE_PTR_HC(pPatch)));
     5592        Log(("Invalidate patch at %VRv (HC=%VRv)\n", PATCHCODE_PTR_GC(pPatch), PATCHCODE_PTR_HC(pPatch)));
    55925593        pPatch->bDirtyOpcode   = *PATCHCODE_PTR_HC(pPatch);
    55935594        *PATCHCODE_PTR_HC(pPatch) = 0xCC;
     
    56255626 * @param   pPatchGC    GC address in patch block
    56265627 */
    5627 RTGCPTR32 patmPatchGCPtr2GuestGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t *) pPatchGC)
     5628RTRCPTR patmPatchGCPtr2GuestGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t *) pPatchGC)
    56285629{
    56295630    Assert(pPatch->Patch2GuestAddrTree);
     
    56445645 *
    56455646 */
    5646 RTGCPTR32 patmGuestGCPtrToPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC)
     5647RTRCPTR patmGuestGCPtrToPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC)
    56475648{
    56485649    if (pPatch->Guest2PatchAddrTree)
    56495650    {
    5650         PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlGCPtrGet(&pPatch->Guest2PatchAddrTree, pInstrGC);
     5651        PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlU32Get(&pPatch->Guest2PatchAddrTree, pInstrGC);
    56515652        if (pGuestToPatchRec)
    56525653            return pVM->patm.s.pPatchMemGC + pGuestToPatchRec->PatchOffset;
     
    56645665 *
    56655666 */
    5666 RTGCPTR32 patmGuestGCPtrToClosestPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC)
    5667 {
    5668         PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlGCPtrGetBestFit(&pPatch->Guest2PatchAddrTree, pInstrGC, false);
     5667RTRCPTR patmGuestGCPtrToClosestPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC)
     5668{
     5669        PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlU32GetBestFit(&pPatch->Guest2PatchAddrTree, pInstrGC, false);
    56695670        if (pGuestToPatchRec)
    56705671            return pVM->patm.s.pPatchMemGC + pGuestToPatchRec->PatchOffset;
     
    56805681 *
    56815682 */
    5682 PATMR3DECL(RTGCPTR32) PATMR3GuestGCPtrToPatchGCPtr(PVM pVM, RCPTRTYPE(uint8_t*) pInstrGC)
    5683 {
    5684     PPATMPATCHREC pPatchRec = (PPATMPATCHREC)RTAvloGCPtrGetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC, false);
     5683PATMR3DECL(RTRCPTR) PATMR3GuestGCPtrToPatchGCPtr(PVM pVM, RCPTRTYPE(uint8_t*) pInstrGC)
     5684{
     5685    PPATMPATCHREC pPatchRec = (PPATMPATCHREC)RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pInstrGC, false);
    56855686    if (pPatchRec && pPatchRec->patch.uState == PATCH_ENABLED && pInstrGC >= pPatchRec->patch.pPrivInstrGC)
    56865687    {
     
    56995700 *
    57005701 */
    5701 PATMR3DECL(RTGCPTR32) PATMR3PatchToGCPtr(PVM pVM, RTGCPTR32 pPatchGC, PATMTRANSSTATE *pEnmState)
     5702PATMR3DECL(RTRCPTR) PATMR3PatchToGCPtr(PVM pVM, RTRCPTR pPatchGC, PATMTRANSSTATE *pEnmState)
    57025703{
    57035704    PPATMPATCHREC pPatchRec;
    57045705    void         *pvPatchCoreOffset;
    5705     RTGCPTR32       pPrivInstrGC;
     5706    RTRCPTR       pPrivInstrGC;
    57065707
    57075708    Assert(PATMIsPatchGCAddr(pVM, pPatchGC));
    5708     pvPatchCoreOffset = RTAvloGCPtrGetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, pPatchGC - pVM->patm.s.pPatchMemGC, false);
     5709    pvPatchCoreOffset = RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, pPatchGC - pVM->patm.s.pPatchMemGC, false);
    57095710    if (pvPatchCoreOffset == 0)
    57105711    {
    5711         Log(("PATMR3PatchToGCPtr failed for %VGv offset %x\n", pPatchGC, pPatchGC - pVM->patm.s.pPatchMemGC));
     5712        Log(("PATMR3PatchToGCPtr failed for %VRv offset %x\n", pPatchGC, pPatchGC - pVM->patm.s.pPatchMemGC));
    57125713        return 0;
    57135714    }
     
    57205721                                    ||  pPatchRec->patch.uState == PATCH_DISABLE_PENDING
    57215722                                    ||  pPatchRec->patch.uState == PATCH_UNUSABLE),
    5722                   ("pPrivInstrGC=%VGv uState=%d\n", pPrivInstrGC, pPatchRec->patch.uState));
     5723                  ("pPrivInstrGC=%VRv uState=%d\n", pPrivInstrGC, pPatchRec->patch.uState));
    57235724
    57245725        if (    !pPrivInstrGC
     
    57655766 * @param   pAddrGC     Guest context address
    57665767 */
    5767 PATMR3DECL(RTGCPTR32) PATMR3QueryPatchGCPtr(PVM pVM, RTGCPTR32 pAddrGC)
     5768PATMR3DECL(RTRCPTR) PATMR3QueryPatchGCPtr(PVM pVM, RTRCPTR pAddrGC)
    57685769{
    57695770    PPATMPATCHREC pPatchRec;
    57705771
    57715772    // Find the patch record
    5772     pPatchRec = (PPATMPATCHREC)RTAvloGCPtrGet(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pAddrGC);
     5773    pPatchRec = (PPATMPATCHREC)RTAvloU32Get(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pAddrGC);
    57735774    /** @todo we should only use patches that are enabled! always did this, but it's incorrect! */
    57745775    if (pPatchRec && (pPatchRec->patch.uState == PATCH_ENABLED || pPatchRec->patch.uState == PATCH_DIRTY))
     
    57885789 * @param   pEip        GC pointer of trapping instruction
    57895790 */
    5790 static int patmR3HandleDirtyInstr(PVM pVM, PCPUMCTX pCtx, PPATMPATCHREC pPatch, PRECPATCHTOGUEST pPatchToGuestRec, RTGCPTR32 pEip)
     5791static int patmR3HandleDirtyInstr(PVM pVM, PCPUMCTX pCtx, PPATMPATCHREC pPatch, PRECPATCHTOGUEST pPatchToGuestRec, RTRCPTR pEip)
    57915792{
    57925793    DISCPUSTATE  CpuOld, CpuNew;
    57935794    uint8_t     *pPatchInstrHC, *pCurPatchInstrHC;
    57945795    int          rc;
    5795     RTGCPTR32      pCurInstrGC, pCurPatchInstrGC;
     5796    RTRCPTR      pCurInstrGC, pCurPatchInstrGC;
    57965797    uint32_t     cbDirty;
    57975798    PRECPATCHTOGUEST pRec;
    57985799
    5799     Log(("patmR3HandleDirtyInstr: dirty instruction at %VGv (%VGv)\n", pEip, pPatchToGuestRec->pOrgInstrGC));
     5800    Log(("patmR3HandleDirtyInstr: dirty instruction at %VRv (%VRv)\n", pEip, pPatchToGuestRec->pOrgInstrGC));
    58005801
    58015802    pRec             = pPatchToGuestRec;
     
    58105811        if (pRec->fJumpTarget)
    58115812        {
    5812             LogRel(("PATM: patmR3HandleDirtyInstr: dirty instruction at %VGv (%VGv) ignored, because instruction in function was reused as target of jump\n", pEip, pPatchToGuestRec->pOrgInstrGC));
     5813            LogRel(("PATM: patmR3HandleDirtyInstr: dirty instruction at %VRv (%VRv) ignored, because instruction in function was reused as target of jump\n", pEip, pPatchToGuestRec->pOrgInstrGC));
    58135814            pRec->fDirty = false;
    58145815            return VERR_PATCHING_REFUSED;
     
    58675868               )
    58685869            {
    5869                 RTGCPTR32 pTargetGC = PATMResolveBranch(&CpuNew, pCurInstrGC);
     5870                RTRCPTR pTargetGC = PATMResolveBranch(&CpuNew, pCurInstrGC);
    58705871
    58715872                if (    pTargetGC >= pPatchToGuestRec->pOrgInstrGC
     
    59385939            if (VBOX_FAILURE(rc))
    59395940            {
    5940                 LogRel(("PATM: Failed to refresh dirty patch at %VGv. Disabling it.\n", pPatch->patch.pPrivInstrGC));
     5941                LogRel(("PATM: Failed to refresh dirty patch at %VRv. Disabling it.\n", pPatch->patch.pPrivInstrGC));
    59415942            }
    59425943            /* Even if we succeed, we must go back to the original instruction as the patched one could be invalid. */
     
    59565957 * @param   ppNewEip    GC pointer to new instruction
    59575958 */
    5958 PATMR3DECL(int) PATMR3HandleTrap(PVM pVM, PCPUMCTX pCtx, RTGCPTR32 pEip, RTGCPTR *ppNewEip)
     5959PATMR3DECL(int) PATMR3HandleTrap(PVM pVM, PCPUMCTX pCtx, RTRCPTR pEip, RTGCPTR *ppNewEip)
    59595960{
    59605961    PPATMPATCHREC    pPatch = 0;
    59615962    void            *pvPatchCoreOffset;
    5962     RTGCUINTPTR32      offset;
    5963     RTGCPTR32          pNewEip;
     5963    RTRCUINTPTR      offset;
     5964    RTRCPTR          pNewEip;
    59645965    int              rc ;
    59655966    PRECPATCHTOGUEST pPatchToGuestRec = 0;
     
    59735974    /** @note there might not be a patch to guest translation record (global function) */
    59745975    offset = pEip - pVM->patm.s.pPatchMemGC;
    5975     pvPatchCoreOffset = RTAvloGCPtrGetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, offset, false);
     5976    pvPatchCoreOffset = RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, offset, false);
    59765977    if (pvPatchCoreOffset)
    59775978    {
     
    59805981        if (pPatch->patch.uState == PATCH_DIRTY)
    59815982        {
    5982             Log(("PATMR3HandleTrap: trap in dirty patch at %VGv\n", pEip));
     5983            Log(("PATMR3HandleTrap: trap in dirty patch at %VRv\n", pEip));
    59835984            if (pPatch->patch.flags & (PATMFL_DUPLICATE_FUNCTION|PATMFL_CALLABLE_AS_FUNCTION))
    59845985            {
     
    59905991        if (pPatch->patch.uState == PATCH_DISABLED)
    59915992        {
    5992             Log(("PATMR3HandleTrap: trap in disabled patch at %VGv\n", pEip));
     5993            Log(("PATMR3HandleTrap: trap in disabled patch at %VRv\n", pEip));
    59935994            if (pPatch->patch.flags & (PATMFL_DUPLICATE_FUNCTION|PATMFL_CALLABLE_AS_FUNCTION))
    59945995            {
     
    60006001        if (pPatch->patch.uState == PATCH_DISABLE_PENDING)
    60016002        {
    6002             RTGCPTR32 pPrivInstrGC = pPatch->patch.pPrivInstrGC;
    6003 
    6004             Log(("PATMR3HandleTrap: disable operation is pending for patch at %VGv\n", pPatch->patch.pPrivInstrGC));
     6003            RTRCPTR pPrivInstrGC = pPatch->patch.pPrivInstrGC;
     6004
     6005            Log(("PATMR3HandleTrap: disable operation is pending for patch at %VRv\n", pPatch->patch.pPrivInstrGC));
    60056006            rc = PATMR3DisablePatch(pVM, pPatch->patch.pPrivInstrGC);
    6006             AssertReleaseMsg(rc != VWRN_PATCH_REMOVED, ("PATMR3DisablePatch removed patch at %VGv\n", pPrivInstrGC));
     6007            AssertReleaseMsg(rc != VWRN_PATCH_REMOVED, ("PATMR3DisablePatch removed patch at %VRv\n", pPrivInstrGC));
    60076008            AssertMsg(pPatch->patch.uState == PATCH_DISABLED || pPatch->patch.uState == PATCH_UNUSABLE, ("Unexpected failure to disable patch state=%d rc=%Vrc\n", pPatch->patch.uState, rc));
    60086009        }
    60096010
    60106011        pPatchToGuestRec = (PRECPATCHTOGUEST)RTAvlU32GetBestFit(&pPatch->patch.Patch2GuestAddrTree, offset, false);
    6011         AssertReleaseMsg(pPatchToGuestRec, ("PATMR3HandleTrap: Unable to find corresponding guest address for %VGv (offset %x)\n", pEip, offset));
     6012        AssertReleaseMsg(pPatchToGuestRec, ("PATMR3HandleTrap: Unable to find corresponding guest address for %VRv (offset %x)\n", pEip, offset));
    60126013
    60136014        pNewEip = pPatchToGuestRec->pOrgInstrGC;
     
    60166017    }
    60176018    else
    6018         AssertReleaseMsg(pVM->patm.s.pGCStateHC->fPIF == 0, ("PATMR3HandleTrap: Unable to find translation record for %VGv (PIF=0)\n", pEip));
     6019        AssertReleaseMsg(pVM->patm.s.pGCStateHC->fPIF == 0, ("PATMR3HandleTrap: Unable to find translation record for %VRv (PIF=0)\n", pEip));
    60196020
    60206021    /* Check if we were interrupted in PATM generated instruction code. */
     
    60816082        {
    60826083            AssertReleaseMsg(pVM->patm.s.pGCStateHC->fPIF == 1,
    6083                             ("Crash in patch code %VGv (%VGv) esp=%RX32\nPatch state=%x flags=%x fDirty=%d\n%s\n", pEip, pNewEip, CPUMGetGuestESP(pVM), pPatch->patch.uState, pPatch->patch.flags, pPatchToGuestRec->fDirty, szBuf));
     6084                            ("Crash in patch code %VRv (%VRv) esp=%RX32\nPatch state=%x flags=%x fDirty=%d\n%s\n", pEip, pNewEip, CPUMGetGuestESP(pVM), pPatch->patch.uState, pPatch->patch.flags, pPatchToGuestRec->fDirty, szBuf));
    60846085        }
    60856086        else
    60866087            AssertReleaseMsg(pVM->patm.s.pGCStateHC->fPIF == 1,
    6087                             ("Crash in patch code %VGv (%VGv) esp=%RX32\n%s\n", pEip, pNewEip, CPUMGetGuestESP(pVM), szBuf));
     6088                            ("Crash in patch code %VRv (%VRv) esp=%RX32\n%s\n", pEip, pNewEip, CPUMGetGuestESP(pVM), szBuf));
    60886089        EMR3FatalError(pVM, VERR_INTERNAL_ERROR);
    60896090    }
     
    60936094    {
    60946095        STAM_PROFILE_ADV_STOP(&pVM->patm.s.StatHandleTrap, a);
    6095         AssertMsgFailed(("PATMR3HandleTrap: patch not found at address %VGv!!\n", pEip));
     6096        AssertMsgFailed(("PATMR3HandleTrap: patch not found at address %VRv!!\n", pEip));
    60966097        return VERR_PATCH_NOT_FOUND;    //fatal error
    60976098    }
     
    61346135        if (disret && cpu.pCurInstr->opcode == OP_RETN)
    61356136        {
    6136             RTGCPTR32 retaddr;
     6137            RTRCPTR retaddr;
    61376138            PCPUMCTX pCtx;
    61386139            int      rc;
     
    61446145            AssertRC(rc);
    61456146
    6146             Log(("Return failed at %VGv (%VGv)\n", pEip, pNewEip));
    6147             Log(("Expected return address %VGv found address %VGv Psp=%x\n", pVM->patm.s.pGCStackHC[(pVM->patm.s.pGCStateHC->Psp+PATM_STACK_SIZE)/sizeof(RTGCPTR32)], retaddr, pVM->patm.s.pGCStateHC->Psp));
     6147            Log(("Return failed at %VRv (%VRv)\n", pEip, pNewEip));
     6148            Log(("Expected return address %VRv found address %VRv Psp=%x\n", pVM->patm.s.pGCStackHC[(pVM->patm.s.pGCStateHC->Psp+PATM_STACK_SIZE)/sizeof(RTRCPTR)], retaddr, pVM->patm.s.pGCStateHC->Psp));
    61486149        }
    61496150    }
     
    61596160    {
    61606161        /* Must be a faulting instruction after sti; currently only sysexit, hlt or iret */
    6161         Log(("PATMR3HandleTrap %VGv -> inhibit irqs set!\n", pEip));
     6162        Log(("PATMR3HandleTrap %VRv -> inhibit irqs set!\n", pEip));
    61626163#ifdef VBOX_STRICT
    61636164        DISCPUSTATE cpu;
     
    61806181    }
    61816182
    6182     Log2(("pPatchBlockGC %VGv - pEip %VGv corresponding GC address %VGv\n", PATCHCODE_PTR_GC(&pPatch->patch), pEip, pNewEip));
     6183    Log2(("pPatchBlockGC %VRv - pEip %VRv corresponding GC address %VRv\n", PATCHCODE_PTR_GC(&pPatch->patch), pEip, pNewEip));
    61836184
    61846185    if (pNewEip >= pPatch->patch.pPrivInstrGC && pNewEip < pPatch->patch.pPrivInstrGC + pPatch->patch.cbPatchJump)
    61856186    {
    61866187        /* We can't jump back to code that we've overwritten with a 5 byte jump! */
    6187         Log(("Disabling patch at location %VGv due to trap too close to the privileged instruction \n", pPatch->patch.pPrivInstrGC));
     6188        Log(("Disabling patch at location %VRv due to trap too close to the privileged instruction \n", pPatch->patch.pPrivInstrGC));
    61886189        PATMR3DisablePatch(pVM, pPatch->patch.pPrivInstrGC);
    61896190        STAM_PROFILE_ADV_STOP(&pVM->patm.s.StatHandleTrap, a);
     
    61956196    if (pPatch->patch.cTraps > MAX_PATCH_TRAPS)
    61966197    {
    6197         Log(("Disabling patch at location %VGv due to too many traps inside patch code\n", pPatch->patch.pPrivInstrGC));
     6198        Log(("Disabling patch at location %VRv due to too many traps inside patch code\n", pPatch->patch.pPrivInstrGC));
    61986199        //we are only wasting time, back out the patch
    61996200        PATMR3DisablePatch(pVM, pPatch->patch.pPrivInstrGC);
     
    62176218PATMR3DECL(int) PATMR3HandleMonitoredPage(PVM pVM)
    62186219{
    6219     RTGCPTR32 addr = pVM->patm.s.pvFaultMonitor;
     6220    RTRCPTR addr = pVM->patm.s.pvFaultMonitor;
    62206221
    62216222    addr &= PAGE_BASE_GC_MASK;
     
    62246225    AssertRC(rc); NOREF(rc);
    62256226
    6226     PPATMPATCHREC pPatchRec = (PPATMPATCHREC)RTAvloGCPtrGetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, addr, false);
     6227    PPATMPATCHREC pPatchRec = (PPATMPATCHREC)RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, addr, false);
    62276228    if (pPatchRec && pPatchRec->patch.uState == PATCH_ENABLED && PAGE_ADDRESS(pPatchRec->patch.pPrivInstrGC) == PAGE_ADDRESS(addr))
    62286229    {
    62296230        STAM_COUNTER_INC(&pVM->patm.s.StatMonitored);
    6230         Log(("Renewing patch at %VGv\n", pPatchRec->patch.pPrivInstrGC));
     6231        Log(("Renewing patch at %VRv\n", pPatchRec->patch.pPrivInstrGC));
    62316232        rc = PATMR3DisablePatch(pVM, pPatchRec->patch.pPrivInstrGC);
    62326233        if (rc == VWRN_PATCH_REMOVED)
     
    62416242    for(;;)
    62426243    {
    6243         pPatchRec = (PPATMPATCHREC)RTAvloGCPtrGetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, addr, true);
     6244        pPatchRec = (PPATMPATCHREC)RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTree, addr, true);
    62446245
    62456246        if (!pPatchRec || PAGE_ADDRESS(pPatchRec->patch.pPrivInstrGC) != PAGE_ADDRESS(addr))
     
    62496250        {
    62506251            STAM_COUNTER_INC(&pVM->patm.s.StatMonitored);
    6251             Log(("Renewing patch at %VGv\n", pPatchRec->patch.pPrivInstrGC));
     6252            Log(("Renewing patch at %VRv\n", pPatchRec->patch.pPrivInstrGC));
    62526253            PATMR3DisablePatch(pVM, pPatchRec->patch.pPrivInstrGC);
    62536254            PATMR3EnablePatch(pVM, pPatchRec->patch.pPrivInstrGC);
     
    63596360 * @param   pPatch      Patch structure
    63606361 */
    6361 RTGCPTR32 patmPatchQueryStatAddress(PVM pVM, PPATCHINFO pPatch)
     6362RTRCPTR patmPatchQueryStatAddress(PVM pVM, PPATCHINFO pPatch)
    63626363{
    63636364    Assert(pPatch->uPatchIdx != PATM_STAT_INDEX_NONE);
     
    63866387        return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: The command requires VM to be selected.\n");
    63876388
    6388     RTAvloGCPtrDoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, DisableAllPatches, pVM);
     6389    RTAvloU32DoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, DisableAllPatches, pVM);
    63896390    PATMR3AllowPatching(pVM, false);
    63906391    return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Patching disabled\n");
     
    64106411
    64116412    PATMR3AllowPatching(pVM, true);
    6412     RTAvloGCPtrDoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, EnableAllPatches, pVM);
     6413    RTAvloU32DoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, EnableAllPatches, pVM);
    64136414    return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Patching enabled\n");
    64146415}
  • trunk/src/VBox/VMM/PATM/PATMA.h

    r9220 r9228  
    133133    struct
    134134    {
    135         RTGCPTR32      pInstrGC;
    136         RTGCUINTPTR32  pRelPatchGC; /* relative to patch base */
     135        RTRCPTR      pInstrGC;
     136        RTRCUINTPTR  pRelPatchGC; /* relative to patch base */
    137137    } Slot[1];
    138138} PATCHJUMPTABLE, *PPATCHJUMPTABLE;
  • trunk/src/VBox/VMM/PATM/PATMInternal.h

    r9220 r9228  
    136136    uint32_t        uType;
    137137    R3PTRTYPE(uint8_t *) pRelocPos;
    138     RTGCPTR32       pSource;
    139     RTGCPTR32       pDest;
     138    RTRCPTR       pSource;
     139    RTRCPTR       pDest;
    140140} RELOCREC, *PRELOCREC;
    141141
     
    176176    AVLU32NODECORE   Core;
    177177
    178     RTGCPTR32        pOrgInstrGC;
     178    RTRCPTR          pOrgInstrGC;
    179179    PATM_LOOKUP_TYPE enmType;
    180180    bool             fDirty;
     
    189189{
    190190    /** The key is a GC virtual address. */
    191     AVLGCPTRNODECORE    Core;
     191    AVLU32NODECORE      Core;
    192192
    193193    /** Patch offset (relative to PATM::pPatchMemGC / PATM::pPatchMemHC). */
     
    213213
    214214    /** Last original guest instruction pointer; used for disassmebly log. */
    215     RTGCPTR32                   pLastDisasmInstrGC;
     215    RTRCPTR                   pLastDisasmInstrGC;
    216216
    217217    /** Keeping track of multiple ret instructions. */
    218     RTGCPTR32                 pPatchRetInstrGC;
     218    RTRCPTR                 pPatchRetInstrGC;
    219219    uint32_t                    uPatchRetParam1;
    220220} PATCHINFOTEMP, *PPATCHINFOTEMP;
     
    234234
    235235    /* Only valid for PATMFL_JUMP_CONFLICT patches */
    236     RTGCPTR32       pPatchJumpDestGC;
     236    RTRCPTR       pPatchJumpDestGC;
    237237
    238238    RTGCUINTPTR32   pPatchBlockOffset;
     
    248248     * Lowest and highest patched GC instruction address. To optimize searches.
    249249     */
    250     RTGCPTR32                 pInstrGCLowest;
    251     RTGCPTR32                 pInstrGCHighest;
     250    RTRCPTR                 pInstrGCLowest;
     251    RTRCPTR                 pInstrGCHighest;
    252252
    253253    /* Tree of fixup records for the patch. */
     
    264264     */
    265265    R3PTRTYPE(PAVLU32NODECORE) Patch2GuestAddrTree;
    266     R3PTRTYPE(PAVLGCPTRNODECORE) Guest2PatchAddrTree;
     266    R3PTRTYPE(PAVLU32NODECORE) Guest2PatchAddrTree;
    267267    uint32_t                  nrPatch2GuestRecs;
    268268#if HC_ARCH_BITS == 64
     
    293293} PATCHINFO, *PPATCHINFO;
    294294
    295 #define PATCHCODE_PTR_GC(pPatch)    (RTGCPTR32)  (pVM->patm.s.pPatchMemGC + (pPatch)->pPatchBlockOffset)
     295#define PATCHCODE_PTR_GC(pPatch)    (RTRCPTR)  (pVM->patm.s.pPatchMemGC + (pPatch)->pPatchBlockOffset)
    296296#define PATCHCODE_PTR_HC(pPatch)    (uint8_t *)(pVM->patm.s.pPatchMemHC + (pPatch)->pPatchBlockOffset)
    297297
     
    302302{
    303303    /** The key is a GC virtual address. */
    304     AVLOGCPTRNODECORE  Core;
     304    AVLOU32NODECORE  Core;
    305305    /** The key is a patch offset. */
    306     AVLOGCPTRNODECORE  CoreOffset;
     306    AVLOU32NODECORE  CoreOffset;
    307307
    308308    PATCHINFO  patch;
     
    318318{
    319319    /** The key is a GC virtual address. */
    320     AVLOGCPTRNODECORE  Core;
     320    AVLOU32NODECORE  Core;
    321321    /** Region to monitor. */
    322     RTGCPTR32          pLowestAddrGC;
    323     RTGCPTR32          pHighestAddrGC;
     322    RTRCPTR          pLowestAddrGC;
     323    RTRCPTR          pHighestAddrGC;
    324324    /** Number of patches for this page. */
    325325    uint32_t           cCount;
     
    338338     * AVL tree with all patches (active or disabled) sorted by guest instruction address
    339339     */
    340     AVLOGCPTRTREE           PatchTree;
     340    AVLOU32TREE           PatchTree;
    341341
    342342    /**
    343343     * AVL tree with all patches sorted by patch address (offset actually)
    344344     */
    345     AVLOGCPTRTREE           PatchTreeByPatchAddr;
     345    AVLOU32TREE           PatchTreeByPatchAddr;
    346346
    347347    /**
    348348     * AVL tree with all pages which were (partly) patched
    349349     */
    350     AVLOGCPTRTREE           PatchTreeByPage;
     350    AVLOU32TREE           PatchTreeByPage;
    351351
    352352    uint32_t                align[1];
     
    376376
    377377    /** PATM stack page for call instruction execution. (2 parts: one for our private stack and one to store the original return address */
    378     RCPTRTYPE(RTGCPTR32 *)    pGCStackGC;
    379     R3PTRTYPE(RTGCPTR32 *)    pGCStackHC;
     378    RCPTRTYPE(RTRCPTR *)    pGCStackGC;
     379    R3PTRTYPE(RTRCPTR *)    pGCStackHC;
    380380
    381381    /** GC pointer to CPUMCTX structure. */
     
    398398     * Lowest and highest patched GC instruction addresses. To optimize searches.
    399399     */
    400     RTGCPTR32                 pPatchedInstrGCLowest;
    401     RTGCPTR32                 pPatchedInstrGCHighest;
     400    RTRCPTR                 pPatchedInstrGCLowest;
     401    RTRCPTR                 pPatchedInstrGCHighest;
    402402
    403403    /** Pointer to the patch tree for instructions replaced by 'int 3'. */
     
    406406
    407407    /** Global PATM lookup and call function (used by call patches). */
    408     RTGCPTR32               pfnHelperCallGC;
     408    RTRCPTR               pfnHelperCallGC;
    409409    /** Global PATM return function (used by ret patches). */
    410     RTGCPTR32               pfnHelperRetGC;
     410    RTRCPTR               pfnHelperRetGC;
    411411    /** Global PATM jump function (used by indirect jmp patches). */
    412     RTGCPTR32               pfnHelperJumpGC;
     412    RTRCPTR               pfnHelperJumpGC;
    413413    /** Global PATM return function (used by iret patches). */
    414     RTGCPTR32               pfnHelperIretGC;
     414    RTRCPTR               pfnHelperIretGC;
    415415
    416416    /** Fake patch record for global functions. */
     
    418418
    419419    /** Pointer to original sysenter handler */
    420     RTGCPTR32               pfnSysEnterGC;
     420    RTRCPTR               pfnSysEnterGC;
    421421    /** Pointer to sysenter handler trampoline */
    422     RTGCPTR32               pfnSysEnterPatchGC;
     422    RTRCPTR               pfnSysEnterPatchGC;
    423423    /** Sysenter patch index (for stats only) */
    424424    uint32_t                uSysEnterPatchIdx;
    425425
    426426    // GC address of fault in monitored page (set by PATMGCMonitorPage, used by PATMR3HandleMonitoredPage)
    427     RTGCPTR32               pvFaultMonitor;
     427    RTRCPTR               pvFaultMonitor;
    428428
    429429    /* Temporary information for pending MMIO patch. Set in GC or R0 context. */
     
    431431    {
    432432        RTGCPHYS            GCPhys;
    433         RTGCPTR32           pCachedData;
     433        RTRCPTR           pCachedData;
    434434#if GC_ARCH_BITS == 32
    435         RTGCPTR32           Alignment0; /**< Align the structure size on a 8-byte boundrary. */
     435        RTRCPTR           Alignment0; /**< Align the structure size on a 8-byte boundrary. */
    436436#endif
    437437    } mmio;
     
    529529
    530530#ifdef IN_RING3
    531 RTGCPTR32 patmPatchGCPtr2GuestGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t *) pPatchGC);
    532 RTGCPTR32 patmGuestGCPtrToPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC);
    533 RTGCPTR32 patmGuestGCPtrToClosestPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC);
     531RTRCPTR patmPatchGCPtr2GuestGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t *) pPatchGC);
     532RTRCPTR patmGuestGCPtrToPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC);
     533RTRCPTR patmGuestGCPtrToClosestPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC);
    534534#endif
    535535
     
    544544 *
    545545 */
    546 void patmr3AddP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, uint8_t *pPatchInstrHC, RTGCPTR32 pInstrGC, PATM_LOOKUP_TYPE enmType, bool fDirty=false);
     546void patmr3AddP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, uint8_t *pPatchInstrHC, RTRCPTR pInstrGC, PATM_LOOKUP_TYPE enmType, bool fDirty=false);
    547547
    548548/**
     
    571571 * @param   pPatch      Patch structure
    572572 */
    573 RTGCPTR32 patmPatchQueryStatAddress(PVM pVM, PPATCHINFO pPatch);
     573RTRCPTR patmPatchQueryStatAddress(PVM pVM, PPATCHINFO pPatch);
    574574
    575575/**
     
    607607 *
    608608 */
    609 int PATMInstallGuestSpecificPatch(PVM pVM, PDISCPUSTATE pCpu, RTGCPTR32 pInstrGC, uint8_t *pInstrHC, PPATMPATCHREC pPatchRec);
     609int PATMInstallGuestSpecificPatch(PVM pVM, PDISCPUSTATE pCpu, RTRCPTR pInstrGC, uint8_t *pInstrHC, PPATMPATCHREC pPatchRec);
    610610
    611611/**
     
    631631 *
    632632 */
    633 PATMDECL(PPATMPATCHREC) PATMQueryFunctionPatch(PVM pVM, RTGCPTR32 pInstrGC);
     633PATMDECL(PPATMPATCHREC) PATMQueryFunctionPatch(PVM pVM, RTRCPTR pInstrGC);
    634634
    635635
     
    690690    PPATCHINFO    pPatchInfo;
    691691    R3PTRTYPE(uint8_t *) pInstrHC;
    692     RTGCPTR32       pInstrGC;
     692    RTRCPTR       pInstrGC;
    693693    uint32_t      fReadFlags;
    694694} PATMDISASM, *PPATMDISASM;
    695695
    696 inline bool PATMR3DISInstr(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR32 InstrGC,
     696inline bool PATMR3DISInstr(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTRCPTR InstrGC,
    697697                           uint8_t *InstrHC, uint32_t *pOpsize, char *pszOutput,
    698698                           uint32_t fReadFlags = PATMREAD_ORGCODE)
     
    734734 *
    735735 */
    736 PPATCHINFO PATMFindActivePatchByEntrypoint(PVM pVM, RTGCPTR32 pInstrGC, bool fIncludeHints=false);
     736PPATCHINFO PATMFindActivePatchByEntrypoint(PVM pVM, RTRCPTR pInstrGC, bool fIncludeHints=false);
    737737
    738738/**
     
    750750 *
    751751 */
    752 PATMR3DECL(int) PATMR3PatchBlock(PVM pVM, RTGCPTR32 pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC,
     752PATMR3DECL(int) PATMR3PatchBlock(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC,
    753753                                 uint32_t uOpcode, uint32_t uOpSize, PPATMPATCHREC pPatchRec);
    754754
     
    767767 *
    768768 */
    769 PATMR3DECL(int) PATMR3PatchInstrInt3(PVM pVM, RTGCPTR32 pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATCHINFO pPatch);
     769PATMR3DECL(int) PATMR3PatchInstrInt3(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATCHINFO pPatch);
    770770
    771771/**
     
    788788 * @param   pBranchInstrGC  GC pointer of branch instruction
    789789 */
    790 inline RTGCPTR32 PATMResolveBranch(PDISCPUSTATE pCpu, RTGCPTR32 pBranchInstrGC)
     790inline RTRCPTR PATMResolveBranch(PDISCPUSTATE pCpu, RTRCPTR pBranchInstrGC)
    791791{
    792792    uint32_t disp;
     
    811811    }
    812812#ifdef IN_GC
    813     return (RTGCPTR32)((uint8_t *)pBranchInstrGC + pCpu->opsize + disp);
     813    return (RTRCPTR)((uint8_t *)pBranchInstrGC + pCpu->opsize + disp);
    814814#else
    815815    return pBranchInstrGC + pCpu->opsize + disp;
  • trunk/src/VBox/VMM/PATM/PATMPatch.cpp

    r9220 r9228  
    5959typedef struct
    6060{
    61     RTGCPTR32   pTargetGC;
    62     RTGCPTR32   pCurInstrGC;
    63     RTGCPTR32   pNextInstrGC;
    64     RTGCPTR32   pReturnGC;
     61    RTRCPTR   pTargetGC;
     62    RTRCPTR   pCurInstrGC;
     63    RTRCPTR   pNextInstrGC;
     64    RTRCPTR   pReturnGC;
    6565} PATMCALLINFO, *PPATMCALLINFO;
    6666
    67 int patmPatchAddReloc32(PVM pVM, PPATCHINFO pPatch, uint8_t *pRelocHC, uint32_t uType, RTGCPTR32 pSource, RTGCPTR32 pDest)
     67int patmPatchAddReloc32(PVM pVM, PPATCHINFO pPatch, uint8_t *pRelocHC, uint32_t uType, RTRCPTR pSource, RTRCPTR pDest)
    6868{
    6969    PRELOCREC pRec;
     
    8888}
    8989
    90 int patmPatchAddJump(PVM pVM, PPATCHINFO pPatch, uint8_t *pJumpHC, uint32_t offset, RTGCPTR32 pTargetGC, uint32_t opcode)
     90int patmPatchAddJump(PVM pVM, PPATCHINFO pPatch, uint8_t *pJumpHC, uint32_t offset, RTRCPTR pTargetGC, uint32_t opcode)
    9191{
    9292    PJUMPREC pRec;
     
    306306                case PATM_LOOKUP_AND_CALL_FUNCTION:
    307307                {
    308                     RTGCPTR32 pInstrAfterCall = pVM->patm.s.pPatchMemGC + (RTGCUINTPTR32)(&pPB[j] + sizeof(RTGCPTR32) - pVM->patm.s.pPatchMemHC);
     308                    RTRCPTR pInstrAfterCall = pVM->patm.s.pPatchMemGC + (RTGCUINTPTR32)(&pPB[j] + sizeof(RTRCPTR) - pVM->patm.s.pPatchMemHC);
    309309                    Assert(pVM->patm.s.pfnHelperCallGC);
    310                     Assert(sizeof(uint32_t) == sizeof(RTGCPTR32));
     310                    Assert(sizeof(uint32_t) == sizeof(RTRCPTR));
    311311
    312312                    /* Relative value is target minus address of instruction after the actual call instruction. */
     
    317317                case PATM_RETURN_FUNCTION:
    318318                {
    319                     RTGCPTR32 pInstrAfterCall = pVM->patm.s.pPatchMemGC + (RTGCUINTPTR32)(&pPB[j] + sizeof(RTGCPTR32) - pVM->patm.s.pPatchMemHC);
     319                    RTRCPTR pInstrAfterCall = pVM->patm.s.pPatchMemGC + (RTGCUINTPTR32)(&pPB[j] + sizeof(RTRCPTR) - pVM->patm.s.pPatchMemHC);
    320320                    Assert(pVM->patm.s.pfnHelperRetGC);
    321                     Assert(sizeof(uint32_t) == sizeof(RTGCPTR32));
     321                    Assert(sizeof(uint32_t) == sizeof(RTRCPTR));
    322322
    323323                    /* Relative value is target minus address of instruction after the actual call instruction. */
     
    328328                case PATM_IRET_FUNCTION:
    329329                {
    330                     RTGCPTR32 pInstrAfterCall = pVM->patm.s.pPatchMemGC + (RTGCUINTPTR32)(&pPB[j] + sizeof(RTGCPTR32) - pVM->patm.s.pPatchMemHC);
     330                    RTRCPTR pInstrAfterCall = pVM->patm.s.pPatchMemGC + (RTGCUINTPTR32)(&pPB[j] + sizeof(RTRCPTR) - pVM->patm.s.pPatchMemHC);
    331331                    Assert(pVM->patm.s.pfnHelperIretGC);
    332                     Assert(sizeof(uint32_t) == sizeof(RTGCPTR32));
     332                    Assert(sizeof(uint32_t) == sizeof(RTRCPTR));
    333333
    334334                    /* Relative value is target minus address of instruction after the actual call instruction. */
     
    339339                case PATM_LOOKUP_AND_JUMP_FUNCTION:
    340340                {
    341                     RTGCPTR32 pInstrAfterCall = pVM->patm.s.pPatchMemGC + (RTGCUINTPTR32)(&pPB[j] + sizeof(RTGCPTR32) - pVM->patm.s.pPatchMemHC);
     341                    RTRCPTR pInstrAfterCall = pVM->patm.s.pPatchMemGC + (RTGCUINTPTR32)(&pPB[j] + sizeof(RTRCPTR) - pVM->patm.s.pPatchMemHC);
    342342                    Assert(pVM->patm.s.pfnHelperJumpGC);
    343                     Assert(sizeof(uint32_t) == sizeof(RTGCPTR32));
     343                    Assert(sizeof(uint32_t) == sizeof(RTRCPTR));
    344344
    345345                    /* Relative value is target minus address of instruction after the actual call instruction. */
     
    354354                }
    355355
    356                 *(RTGCPTR32 *)&pPB[j] = dest;
     356                *(RTRCPTR *)&pPB[j] = dest;
    357357                if (pAsmRecord->uReloc[i] < PATM_NO_FIXUP)
    358358                {
     
    393393
    394394/* Read bytes and check for overwritten instructions. */
    395 static int patmPatchReadBytes(PVM pVM, uint8_t *pDest, RTGCPTR32 pSrc, uint32_t cb)
     395static int patmPatchReadBytes(PVM pVM, uint8_t *pDest, RTRCPTR pSrc, uint32_t cb)
    396396{
    397397    int rc = PGMPhysReadGCPtr(pVM, pDest, pSrc, cb);
     
    426426}
    427427
    428 int patmPatchGenIret(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pCurInstrGC, bool fSizeOverride)
     428int patmPatchGenIret(PVM pVM, PPATCHINFO pPatch, RTRCPTR pCurInstrGC, bool fSizeOverride)
    429429{
    430430    uint32_t size;
     
    457457 * Generate an STI patch
    458458 */
    459 int patmPatchGenSti(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pCurInstrGC, RTGCPTR32 pNextInstrGC)
     459int patmPatchGenSti(PVM pVM, PPATCHINFO pPatch, RTRCPTR pCurInstrGC, RTRCPTR pNextInstrGC)
    460460{
    461461    PATMCALLINFO callInfo;
     
    564564    }
    565565
    566     *(RTGCPTR32 *)&pPB[pPatchAsmRec->offRelJump] = 0xDEADBEEF;
     566    *(RTRCPTR *)&pPB[pPatchAsmRec->offRelJump] = 0xDEADBEEF;
    567567
    568568    patmPatchAddJump(pVM, pPatch, &pPB[pPatchAsmRec->offRelJump - 1], 1, pTargetGC, opcode);
     
    657657    else offset++;
    658658
    659     *(RTGCPTR32 *)&pPB[offset] = 0xDEADBEEF;
     659    *(RTRCPTR *)&pPB[offset] = 0xDEADBEEF;
    660660
    661661    patmPatchAddJump(pVM, pPatch, pPB, offset, pTargetGC, opcode);
    662662
    663     offset += sizeof(RTGCPTR32);
     663    offset += sizeof(RTRCPTR);
    664664
    665665    PATCHGEN_EPILOG(pPatch, offset);
     
    670670 * Rewrite call to dynamic or currently unknown function (on-demand patching of function)
    671671 */
    672 int patmPatchGenCall(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR32 pCurInstrGC, RTGCPTR32 pTargetGC, bool fIndirect)
     672int patmPatchGenCall(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTRCPTR pCurInstrGC, RTRCPTR pTargetGC, bool fIndirect)
    673673{
    674674    PATMCALLINFO        callInfo;
     
    710710            i++;    //skip segment prefix
    711711
    712         rc = patmPatchReadBytes(pVM, &pPB[offset], (RTGCPTR32)((RTGCUINTPTR32)pCurInstrGC + i), pCpu->opsize - i);
     712        rc = patmPatchReadBytes(pVM, &pPB[offset], (RTRCPTR)((RTGCUINTPTR32)pCurInstrGC + i), pCpu->opsize - i);
    713713        AssertRCReturn(rc, rc);
    714714        offset += (pCpu->opsize - i);
     
    730730        offset = 0;
    731731        pPB[offset++] = 0x68;              // push %Iv
    732         *(RTGCPTR32 *)&pPB[offset] = pTargetGC;
    733         offset += sizeof(RTGCPTR32);
     732        *(RTRCPTR *)&pPB[offset] = pTargetGC;
     733        offset += sizeof(RTRCPTR);
    734734    }
    735735
     
    771771 * @param   pCurInstrGC Current instruction address
    772772 */
    773 int patmPatchGenJump(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR32 pCurInstrGC)
     773int patmPatchGenJump(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTRCPTR pCurInstrGC)
    774774{
    775775    PATMCALLINFO        callInfo;
     
    807807        i++;    //skip segment prefix
    808808
    809     rc = patmPatchReadBytes(pVM, &pPB[offset], (RTGCPTR32)((RTGCUINTPTR32)pCurInstrGC + i), pCpu->opsize - i);
     809    rc = patmPatchReadBytes(pVM, &pPB[offset], (RTRCPTR)((RTGCUINTPTR32)pCurInstrGC + i), pCpu->opsize - i);
    810810    AssertRCReturn(rc, rc);
    811811    offset += (pCpu->opsize - i);
     
    846846{
    847847    int size = 0, rc;
    848     RTGCPTR32 pPatchRetInstrGC;
     848    RTRCPTR pPatchRetInstrGC;
    849849
    850850    /* Remember start of this patch for below. */
     
    970970 *
    971971 */
    972 int patmPatchGenCheckIF(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pCurInstrGC)
     972int patmPatchGenCheckIF(PVM pVM, PPATCHINFO pPatch, RTRCPTR pCurInstrGC)
    973973{
    974974    uint32_t size;
     
    995995 *
    996996 */
    997 int patmPatchGenSetPIF(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pInstrGC)
     997int patmPatchGenSetPIF(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC)
    998998{
    999999    PATCHGEN_PROLOG(pVM, pPatch);
     
    10161016 *
    10171017 */
    1018 int patmPatchGenClearPIF(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pInstrGC)
     1018int patmPatchGenClearPIF(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC)
    10191019{
    10201020    PATCHGEN_PROLOG(pVM, pPatch);
     
    10371037 * @param   pNextInstrGC    Next guest instruction
    10381038 */
    1039 int patmPatchGenClearInhibitIRQ(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pNextInstrGC)
     1039int patmPatchGenClearInhibitIRQ(PVM pVM, PPATCHINFO pPatch, RTRCPTR pNextInstrGC)
    10401040{
    10411041    int          size;
     
    10701070 ** @todo must check if virtual IF is already cleared on entry!!!!!!!!!!!!!!!!!!!!!!!
    10711071 */
    1072 int patmPatchGenIntEntry(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pIntHandlerGC)
     1072int patmPatchGenIntEntry(PVM pVM, PPATCHINFO pPatch, RTRCPTR pIntHandlerGC)
    10731073{
    10741074    uint32_t size;
     
    11021102 * @param   pTrapHandlerGC  IDT handler address
    11031103 */
    1104 int patmPatchGenTrapEntry(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pTrapHandlerGC)
     1104int patmPatchGenTrapEntry(PVM pVM, PPATCHINFO pPatch, RTRCPTR pTrapHandlerGC)
    11051105{
    11061106    uint32_t size;
     
    11211121
    11221122#ifdef VBOX_WITH_STATISTICS
    1123 int patmPatchGenStats(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pInstrGC)
     1123int patmPatchGenStats(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC)
    11241124{
    11251125    uint32_t size;
     
    12131213        break;
    12141214    }
    1215     *(RTGCPTR32 *)&pPB[2] = pVM->patm.s.pCPUMCtxGC + offset;
     1215    *(RTRCPTR *)&pPB[2] = pVM->patm.s.pCPUMCtxGC + offset;
    12161216    patmPatchAddReloc32(pVM, pPatch, &pPB[2], FIXUP_ABSOLUTE);
    12171217
    1218     PATCHGEN_EPILOG(pPatch, 2 + sizeof(RTGCPTR32));
     1218    PATCHGEN_EPILOG(pPatch, 2 + sizeof(RTRCPTR));
    12191219    return rc;
    12201220}
     
    12791279        break;
    12801280    }
    1281     *(RTGCPTR32 *)&pPB[2] = pVM->patm.s.pCPUMCtxGC + offset;
     1281    *(RTRCPTR *)&pPB[2] = pVM->patm.s.pCPUMCtxGC + offset;
    12821282    patmPatchAddReloc32(pVM, pPatch, &pPB[2], FIXUP_ABSOLUTE);
    12831283
    1284     PATCHGEN_EPILOG(pPatch, 2 + sizeof(RTGCPTR32));
     1284    PATCHGEN_EPILOG(pPatch, 2 + sizeof(RTRCPTR));
    12851285    return rc;
    12861286}
     
    12891289 * mov GPR, SS
    12901290 */
    1291 int patmPatchGenMovFromSS(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR32 pCurInstrGC)
     1291int patmPatchGenMovFromSS(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTRCPTR pCurInstrGC)
    12921292{
    12931293    uint32_t size, offset;
     
    13401340 * @param   pCurInstrGC Guest instruction address
    13411341 */
    1342 int patmPatchGenSldtStr(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR32 pCurInstrGC)
     1342int patmPatchGenSldtStr(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTRCPTR pCurInstrGC)
    13431343{
    13441344    // sldt %Ew
     
    13651365        if (pCpu->pCurInstr->opcode == OP_STR)
    13661366        {
    1367             *(RTGCPTR32 *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + RT_OFFSETOF(CPUMCTX, tr);
     1367            *(RTRCPTR *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + RT_OFFSETOF(CPUMCTX, tr);
    13681368        }
    13691369        else
    13701370        {
    1371             *(RTGCPTR32 *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + RT_OFFSETOF(CPUMCTX, ldtr);
     1371            *(RTRCPTR *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + RT_OFFSETOF(CPUMCTX, ldtr);
    13721372        }
    13731373        patmPatchAddReloc32(pVM, pPatch, &pPB[offset], FIXUP_ABSOLUTE);
    1374         offset += sizeof(RTGCPTR32);
     1374        offset += sizeof(RTRCPTR);
    13751375    }
    13761376    else
     
    14021402            i++;    //skip segment prefix
    14031403
    1404         rc = patmPatchReadBytes(pVM, &pPB[offset], (RTGCPTR32)((RTGCUINTPTR32)pCurInstrGC + i), pCpu->opsize - i);
     1404        rc = patmPatchReadBytes(pVM, &pPB[offset], (RTRCPTR)((RTGCUINTPTR32)pCurInstrGC + i), pCpu->opsize - i);
    14051405        AssertRCReturn(rc, rc);
    14061406        offset += (pCpu->opsize - i);
     
    14101410        if (pCpu->pCurInstr->opcode == OP_STR)
    14111411        {
    1412             *(RTGCPTR32 *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + RT_OFFSETOF(CPUMCTX, tr);
     1412            *(RTRCPTR *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + RT_OFFSETOF(CPUMCTX, tr);
    14131413        }
    14141414        else
    14151415        {
    1416             *(RTGCPTR32 *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + RT_OFFSETOF(CPUMCTX, ldtr);
     1416            *(RTRCPTR *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + RT_OFFSETOF(CPUMCTX, ldtr);
    14171417        }
    14181418        patmPatchAddReloc32(pVM, pPatch, &pPB[offset], FIXUP_ABSOLUTE);
    1419         offset += sizeof(RTGCPTR32);
     1419        offset += sizeof(RTRCPTR);
    14201420
    14211421        pPB[offset++] = 0x66;              // mov       word ptr [edx],ax
     
    14411441 * @param   pCurInstrGC Guest instruction address
    14421442 */
    1443 int patmPatchGenSxDT(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR32 pCurInstrGC)
     1443int patmPatchGenSxDT(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTRCPTR pCurInstrGC)
    14441444{
    14451445    int rc = VINF_SUCCESS;
     
    14961496    if (pCpu->prefix == PREFIX_SEG)
    14971497        i++;    //skip segment prefix
    1498     rc = patmPatchReadBytes(pVM, &pPB[offset], (RTGCPTR32)((RTGCUINTPTR32)pCurInstrGC + i), pCpu->opsize - i);
     1498    rc = patmPatchReadBytes(pVM, &pPB[offset], (RTRCPTR)((RTGCUINTPTR32)pCurInstrGC + i), pCpu->opsize - i);
    14991499    AssertRCReturn(rc, rc);
    15001500    offset += (pCpu->opsize - i);
     
    15021502    pPB[offset++] = 0x66;              // mov       ax, CPUMCTX.gdtr.limit
    15031503    pPB[offset++] = 0xA1;
    1504     *(RTGCPTR32 *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + offset_limit;
     1504    *(RTRCPTR *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + offset_limit;
    15051505    patmPatchAddReloc32(pVM, pPatch, &pPB[offset], FIXUP_ABSOLUTE);
    1506     offset += sizeof(RTGCPTR32);
     1506    offset += sizeof(RTRCPTR);
    15071507
    15081508    pPB[offset++] = 0x66;              // mov       word ptr [edx],ax
     
    15111511
    15121512    pPB[offset++] = 0xA1;              // mov       eax, CPUMCTX.gdtr.base
    1513     *(RTGCPTR32 *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + offset_base;
     1513    *(RTRCPTR *)&pPB[offset] = pVM->patm.s.pCPUMCtxGC + offset_base;
    15141514    patmPatchAddReloc32(pVM, pPatch, &pPB[offset], FIXUP_ABSOLUTE);
    1515     offset += sizeof(RTGCPTR32);
     1515    offset += sizeof(RTRCPTR);
    15161516
    15171517    pPB[offset++] = 0x89;              // mov       dword ptr [edx+2],eax
     
    15351535 * @param   pCurInstrGC Guest instruction address
    15361536 */
    1537 int patmPatchGenCpuid(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pCurInstrGC)
     1537int patmPatchGenCpuid(PVM pVM, PPATCHINFO pPatch, RTRCPTR pCurInstrGC)
    15381538{
    15391539    uint32_t size;
     
    15831583 * Relative jump from patch code to patch code (no fixup required)
    15841584 */
    1585 int patmPatchGenPatchJump(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pCurInstrGC, RCPTRTYPE(uint8_t *) pPatchAddrGC, bool fAddLookupRecord)
     1585int patmPatchGenPatchJump(PVM pVM, PPATCHINFO pPatch, RTRCPTR pCurInstrGC, RCPTRTYPE(uint8_t *) pPatchAddrGC, bool fAddLookupRecord)
    15861586{
    15871587    int32_t displ;
  • trunk/src/VBox/VMM/PATM/PATMPatch.h

    r9220 r9228  
    2222#define ___PATMPATCH_H
    2323
    24 int patmPatchAddReloc32(PVM pVM, PPATCHINFO pPatch, uint8_t *pRelocHC, uint32_t uType, RTGCPTR32 pSource = 0, RTGCPTR32 pDest = 0);
    25 int patmPatchAddJump(PVM pVM, PPATCHINFO pPatch, uint8_t *pJumpHC, uint32_t offset, RTGCPTR32 pTargetGC, uint32_t opcode);
     24int patmPatchAddReloc32(PVM pVM, PPATCHINFO pPatch, uint8_t *pRelocHC, uint32_t uType, RTRCPTR pSource = 0, RTRCPTR pDest = 0);
     25int patmPatchAddJump(PVM pVM, PPATCHINFO pPatch, uint8_t *pJumpHC, uint32_t offset, RTRCPTR pTargetGC, uint32_t opcode);
    2626
    27 int patmPatchGenCpuid(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pCurInstrGC);
    28 int patmPatchGenSxDT(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR32 pCurInstrGC);
    29 int patmPatchGenSldtStr(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR32 pCurInstrGC);
     27int patmPatchGenCpuid(PVM pVM, PPATCHINFO pPatch, RTRCPTR pCurInstrGC);
     28int patmPatchGenSxDT(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTRCPTR pCurInstrGC);
     29int patmPatchGenSldtStr(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTRCPTR pCurInstrGC);
    3030int patmPatchGenMovControl(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu);
    3131int patmPatchGenMovDebug(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu);
    32 int patmPatchGenMovFromSS(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR32 pCurInstrGC);
     32int patmPatchGenMovFromSS(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTRCPTR pCurInstrGC);
    3333int patmPatchGenRelJump(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t *) pTargetGC, uint32_t opcode, bool fSizeOverride);
    3434int patmPatchGenLoop(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t *) pTargetGC, uint32_t opcode, bool fSizeOverride);
    3535int patmPatchGenPushf(PVM pVM, PPATCHINFO pPatch, bool fSizeOverride);
    3636int patmPatchGenPopf(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t *) pReturnAddrGC, bool fSizeOverride, bool fGenJumpBack);
    37 int patmPatchGenSti(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pCurInstrGC, RTGCPTR32 pNextInstrGC);
     37int patmPatchGenSti(PVM pVM, PPATCHINFO pPatch, RTRCPTR pCurInstrGC, RTRCPTR pNextInstrGC);
    3838
    3939int patmPatchGenCli(PVM pVM, PPATCHINFO pPatch);
    40 int patmPatchGenIret(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pCurInstrGC, bool fSizeOverride);
     40int patmPatchGenIret(PVM pVM, PPATCHINFO pPatch, RTRCPTR pCurInstrGC, bool fSizeOverride);
    4141int patmPatchGenDuplicate(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RCPTRTYPE(uint8_t *) pCurInstrGC);
    4242int patmPatchGenPushCS(PVM pVM, PPATCHINFO pPatch);
    4343
    44 int patmPatchGenStats(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pInstrGC);
     44int patmPatchGenStats(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC);
    4545
    46 int patmPatchGenCall(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR32 pInstrGC, RTGCPTR32 pTargetGC, bool fIndirect);
     46int patmPatchGenCall(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTRCPTR pInstrGC, RTRCPTR pTargetGC, bool fIndirect);
    4747int patmPatchGenRet(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RCPTRTYPE(uint8_t *) pCurInstrGC);
    4848
    49 int patmPatchGenPatchJump(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pCurInstrGC, RCPTRTYPE(uint8_t *) pPatchAddrGC, bool fAddLookupRecord = true);
     49int patmPatchGenPatchJump(PVM pVM, PPATCHINFO pPatch, RTRCPTR pCurInstrGC, RCPTRTYPE(uint8_t *) pPatchAddrGC, bool fAddLookupRecord = true);
    5050
    5151/**
     
    5858 * @param   pCurInstrGC Current instruction address
    5959 */
    60 int patmPatchGenJump(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR32 pCurInstrGC);
     60int patmPatchGenJump(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTRCPTR pCurInstrGC);
    6161
    6262/**
     
    6868 * @param   pTrapHandlerGC  IDT handler address
    6969 */
    70 int patmPatchGenTrapEntry(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pTrapHandlerGC);
     70int patmPatchGenTrapEntry(PVM pVM, PPATCHINFO pPatch, RTRCPTR pTrapHandlerGC);
    7171
    7272/**
     
    7878 * @param   pIntHandlerGC IDT handler address
    7979 */
    80 int patmPatchGenIntEntry(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pIntHandlerGC);
     80int patmPatchGenIntEntry(PVM pVM, PPATCHINFO pPatch, RTRCPTR pIntHandlerGC);
    8181
    8282/**
     
    110110 *
    111111 */
    112 int patmPatchGenSetPIF(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pInstrGC);
     112int patmPatchGenSetPIF(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC);
    113113
    114114/**
     
    121121 *
    122122 */
    123 int patmPatchGenClearPIF(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pInstrGC);
     123int patmPatchGenClearPIF(PVM pVM, PPATCHINFO pPatch, RTRCPTR pInstrGC);
    124124
    125125/**
     
    131131 * @param   pNextInstrGC    Next guest instruction
    132132 */
    133 int patmPatchGenClearInhibitIRQ(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pNextInstrGC);
     133int patmPatchGenClearInhibitIRQ(PVM pVM, PPATCHINFO pPatch, RTRCPTR pNextInstrGC);
    134134
    135135/**
     
    142142 *
    143143 */
    144 int patmPatchGenCheckIF(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 pCurInstrGC);
     144int patmPatchGenCheckIF(PVM pVM, PPATCHINFO pPatch, RTRCPTR pCurInstrGC);
    145145
    146146/**
  • trunk/src/VBox/VMM/PATM/PATMSSM.cpp

    r8155 r9228  
    8989
    9090/**
    91  * Callback function for RTAvloGCPtrDoWithAll
     91 * Callback function for RTAvloU32DoWithAll
    9292 *
    9393 * Counts the number of patches in the tree
     
    9797 * @param   pcPatches       Pointer to patch counter
    9898 */
    99 static DECLCALLBACK(int) patmCountPatch(PAVLOGCPTRNODECORE pNode, void *pcPatches)
     99static DECLCALLBACK(int) patmCountPatch(PAVLOU32NODECORE pNode, void *pcPatches)
    100100{
    101101    *(uint32_t *)pcPatches = *(uint32_t *)pcPatches + 1;
     
    152152
    153153/**
    154  * Callback function for RTAvloGCPtrDoWithAll
     154 * Callback function for RTAvloU32DoWithAll
    155155 *
    156156 * Saves the state of the patch that's being enumerated
     
    160160 * @param   pVM1            VM Handle
    161161 */
    162 static DECLCALLBACK(int) patmSavePatchState(PAVLOGCPTRNODECORE pNode, void *pVM1)
     162static DECLCALLBACK(int) patmSavePatchState(PAVLOU32NODECORE pNode, void *pVM1)
    163163{
    164164    PVM           pVM    = (PVM)pVM1;
     
    232232     */
    233233    patmInfo.savedstate.cPatches = 0;
    234     RTAvloGCPtrDoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, patmCountPatch, &patmInfo.savedstate.cPatches);
     234    RTAvloU32DoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, patmCountPatch, &patmInfo.savedstate.cPatches);
    235235
    236236    /*
     
    261261     * Save all patches
    262262     */
    263     rc = RTAvloGCPtrDoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, patmSavePatchState, pVM);
     263    rc = RTAvloU32DoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, patmSavePatchState, pVM);
    264264    AssertRCReturn(rc, rc);
    265265
     
    390390        pPatchRec->CoreOffset.Key    = patch.CoreOffset.Key;
    391391
    392         bool ret = RTAvloGCPtrInsert(&pVM->patm.s.PatchLookupTreeHC->PatchTree, &pPatchRec->Core);
     392        bool ret = RTAvloU32Insert(&pVM->patm.s.PatchLookupTreeHC->PatchTree, &pPatchRec->Core);
    393393        Assert(ret);
    394394        if (pPatchRec->patch.uState != PATCH_REFUSED)
     
    397397            {
    398398                /* We actually generated code for this patch. */
    399                 ret = RTAvloGCPtrInsert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
     399                ret = RTAvloU32Insert(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, &pPatchRec->CoreOffset);
    400400                AssertMsg(ret, ("Inserting patch %VGv offset %VGv failed!!\n", pPatchRec->patch.pPrivInstrGC, pPatchRec->CoreOffset.Key));
    401401            }
  • trunk/src/VBox/VMM/PATM/VMMAll/PATMAll.cpp

    r9220 r9228  
    5252PATMDECL(void) PATMRawEnter(PVM pVM, PCPUMCTXCORE pCtxCore)
    5353{
    54     bool fPatchCode = PATMIsPatchGCAddr(pVM, (RTGCPTR32)pCtxCore->eip);
     54    bool fPatchCode = PATMIsPatchGCAddr(pVM, (RTRCPTR)pCtxCore->eip);
    5555
    5656    /*
     
    6060    register uint32_t efl = pCtxCore->eflags.u32;
    6161    CTXSUFF(pVM->patm.s.pGCState)->uVMFlags = efl & PATM_VIRTUAL_FLAGS_MASK;
    62     AssertMsg((efl & X86_EFL_IF) || PATMShouldUseRawMode(pVM, (RTGCPTR32)pCtxCore->eip), ("X86_EFL_IF is clear and PATM is disabled! (eip=%VGv eflags=%08x fPATM=%d pPATMGC=%VGv-%VGv\n", pCtxCore->eip, pCtxCore->eflags.u32, PATMIsEnabled(pVM), pVM->patm.s.pPatchMemGC, pVM->patm.s.pPatchMemGC + pVM->patm.s.cbPatchMem));
     62    AssertMsg((efl & X86_EFL_IF) || PATMShouldUseRawMode(pVM, (RTRCPTR)pCtxCore->eip), ("X86_EFL_IF is clear and PATM is disabled! (eip=%VGv eflags=%08x fPATM=%d pPATMGC=%VGv-%VGv\n", pCtxCore->eip, pCtxCore->eflags.u32, PATMIsEnabled(pVM), pVM->patm.s.pPatchMemGC, pVM->patm.s.pPatchMemGC + pVM->patm.s.cbPatchMem));
    6363
    6464    AssertReleaseMsg(CTXSUFF(pVM->patm.s.pGCState)->fPIF || fPatchCode, ("fPIF=%d eip=%VGv\n", CTXSUFF(pVM->patm.s.pGCState)->fPIF, pCtxCore->eip));
     
    8181       )
    8282    {
    83         if (pVM->patm.s.pfnSysEnterGC != (RTGCPTR32)pCtx->SysEnter.eip)
     83        if (pVM->patm.s.pfnSysEnterGC != (RTRCPTR)pCtx->SysEnter.eip)
    8484        {
    8585            pVM->patm.s.pfnSysEnterPatchGC = 0;
     
    9494                {
    9595                    pVM->patm.s.pfnSysEnterPatchGC  = PATMR3QueryPatchGCPtr(pVM, pCtx->SysEnter.eip);
    96                     pVM->patm.s.pfnSysEnterGC       = (RTGCPTR32)pCtx->SysEnter.eip;
     96                    pVM->patm.s.pfnSysEnterGC       = (RTRCPTR)pCtx->SysEnter.eip;
    9797                    Assert(pVM->patm.s.pfnSysEnterPatchGC);
    9898                }
    9999            }
    100100            else
    101                 pVM->patm.s.pfnSysEnterGC = (RTGCPTR32)pCtx->SysEnter.eip;
     101                pVM->patm.s.pfnSysEnterGC = (RTRCPTR)pCtx->SysEnter.eip;
    102102        }
    103103    }
     
    126126PATMDECL(void) PATMRawLeave(PVM pVM, PCPUMCTXCORE pCtxCore, int rawRC)
    127127{
    128     bool fPatchCode = PATMIsPatchGCAddr(pVM, (RTGCPTR32)pCtxCore->eip);
     128    bool fPatchCode = PATMIsPatchGCAddr(pVM, (RTRCPTR)pCtxCore->eip);
    129129    /*
    130130     * We will only be called if PATMRawEnter was previously called.
     
    157157            {
    158158                PATMTRANSSTATE  enmState;
    159                 RTGCPTR32         pOrgInstrGC = PATMR3PatchToGCPtr(pVM, pCtxCore->eip, &enmState);
     159                RTRCPTR         pOrgInstrGC = PATMR3PatchToGCPtr(pVM, pCtxCore->eip, &enmState);
    160160
    161161                AssertRelease(pOrgInstrGC);
     
    191191    if (!fPatchCode)
    192192    {
    193         if (CTXSUFF(pVM->patm.s.pGCState)->GCPtrInhibitInterrupts == (RTGCPTR32)pCtxCore->eip)
     193        if (CTXSUFF(pVM->patm.s.pGCState)->GCPtrInhibitInterrupts == (RTRCPTR)pCtxCore->eip)
    194194        {
    195195            EMSetInhibitInterruptsPC(pVM, pCtxCore->eip);
     
    246246 * @param   pAddrGC     Guest context address
    247247 */
    248 PATMDECL(bool) PATMShouldUseRawMode(PVM pVM, RTGCPTR32 pAddrGC)
     248PATMDECL(bool) PATMShouldUseRawMode(PVM pVM, RTRCPTR pAddrGC)
    249249{
    250250    return (    PATMIsEnabled(pVM)
    251             && ((pAddrGC >= (RTGCPTR32)pVM->patm.s.pPatchMemGC && pAddrGC < (RTGCPTR32)pVM->patm.s.pPatchMemGC + pVM->patm.s.cbPatchMem))) ? true : false;
     251            && ((pAddrGC >= (RTRCPTR)pVM->patm.s.pPatchMemGC && pAddrGC < (RTRCPTR)((RTRCUINTPTR)pVM->patm.s.pPatchMemGC + pVM->patm.s.cbPatchMem)))) ? true : false;
    252252}
    253253
     
    270270 * @param   pAddrGC     Guest context address
    271271 */
    272 PATMDECL(bool) PATMIsPatchGCAddr(PVM pVM, RTGCPTR32 pAddrGC)
    273 {
    274     RTGCPTR32 pAddrGG32 = (RTGCPTR32)pAddrGC;
    275 
    276     return (PATMIsEnabled(pVM) && pAddrGG32 >= (RTGCPTR32)pVM->patm.s.pPatchMemGC && pAddrGG32 < (RTGCPTR32)pVM->patm.s.pPatchMemGC + pVM->patm.s.cbPatchMem) ? true : false;
     272PATMDECL(bool) PATMIsPatchGCAddr(PVM pVM, RTRCPTR pAddrGC)
     273{
     274    return (PATMIsEnabled(pVM) && pAddrGC >= pVM->patm.s.pPatchMemGC && pAddrGC < (RTRCPTR)((RTRCUINTPTR)pVM->patm.s.pPatchMemGC + pVM->patm.s.cbPatchMem)) ? true : false;
    277275}
    278276
     
    285283 * @param   pCachedData     GC pointer to cached data
    286284 */
    287 PATMDECL(int) PATMSetMMIOPatchInfo(PVM pVM, RTGCPHYS GCPhys, RTGCPTR32 pCachedData)
     285PATMDECL(int) PATMSetMMIOPatchInfo(PVM pVM, RTGCPHYS GCPhys, RTRCPTR pCachedData)
    288286{
    289287    pVM->patm.s.mmio.GCPhys = GCPhys;
    290     pVM->patm.s.mmio.pCachedData = (RTGCPTR32)pCachedData;
     288    pVM->patm.s.mmio.pCachedData = (RTRCPTR)pCachedData;
    291289
    292290    return VINF_SUCCESS;
     
    325323    if (PATMIsEnabled(pVM))
    326324    {
    327         if (PATMIsPatchGCAddr(pVM, (RTGCPTR32)pCtxCore->eip))
     325        if (PATMIsPatchGCAddr(pVM, (RTRCPTR)pCtxCore->eip))
    328326            return false;
    329327    }
     
    339337 *
    340338 */
    341 PATMDECL(PPATMPATCHREC) PATMQueryFunctionPatch(PVM pVM, RTGCPTR32 pInstrGC)
     339PATMDECL(PPATMPATCHREC) PATMQueryFunctionPatch(PVM pVM, RTRCPTR pInstrGC)
    342340{
    343341    PPATMPATCHREC pRec;
    344342
    345     pRec = (PPATMPATCHREC)RTAvloGCPtrGet(&CTXSUFF(pVM->patm.s.PatchLookupTree)->PatchTree, pInstrGC);
     343    AssertCompile(sizeof(AVLOU32KEY) == sizeof(pInstrGC));
     344    pRec = (PPATMPATCHREC)RTAvloU32Get(&CTXSUFF(pVM->patm.s.PatchLookupTree)->PatchTree, (AVLOU32KEY)pInstrGC);
    346345    if (    pRec
    347346        && (pRec->patch.uState == PATCH_ENABLED)
     
    362361 * @param   pSize       Original instruction size (out, optional)
    363362 */
    364 PATMDECL(bool) PATMIsInt3Patch(PVM pVM, RTGCPTR32 pInstrGC, uint32_t *pOpcode, uint32_t *pSize)
     363PATMDECL(bool) PATMIsInt3Patch(PVM pVM, RTRCPTR pInstrGC, uint32_t *pOpcode, uint32_t *pSize)
    365364{
    366365    PPATMPATCHREC pRec;
    367366
    368     pRec = (PPATMPATCHREC)RTAvloGCPtrGet(&CTXSUFF(pVM->patm.s.PatchLookupTree)->PatchTree, pInstrGC);
     367    pRec = (PPATMPATCHREC)RTAvloU32Get(&CTXSUFF(pVM->patm.s.PatchLookupTree)->PatchTree, (AVLOU32KEY)pInstrGC);
    369368    if (    pRec
    370369        && (pRec->patch.uState == PATCH_ENABLED)
     
    402401            ||  (pRegFrame->cs & X86_SEL_RPL) != 3
    403402            ||  pVM->patm.s.pfnSysEnterPatchGC == 0
    404             ||  pVM->patm.s.pfnSysEnterGC != (RTGCPTR32)pCtx->SysEnter.eip
     403            ||  pVM->patm.s.pfnSysEnterGC != (RTRCPTR)pCtx->SysEnter.eip
    405404            ||  !(PATMRawGetEFlags(pVM, pRegFrame) & X86_EFL_IF))
    406405            goto end;
     
    467466 * @param   pRelBranchPatch     Relative duplicated function address
    468467 */
    469 PATMDECL(int) PATMAddBranchToLookupCache(PVM pVM, RTGCPTR32 pJumpTableGC, RTGCPTR32 pBranchTarget, RTGCUINTPTR pRelBranchPatch)
     468PATMDECL(int) PATMAddBranchToLookupCache(PVM pVM, RTRCPTR pJumpTableGC, RTRCPTR pBranchTarget, RTGCUINTPTR pRelBranchPatch)
    470469{
    471470    PPATCHJUMPTABLE pJumpTable;
  • 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