VirtualBox

Changeset 13144 in vbox for trunk/src/VBox/VMM/PATM


Ignore:
Timestamp:
Oct 9, 2008 10:44:11 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
37653
Message:

#1865: Implmented the alternative R0 code for darwin (turned out to be all generic new-phys code). Started renaming the read/write functions: PGMPhysReadGCPtr -> PGMPhysSimpleReadGCPtr, PGMPhysWriteGCPtr -> PGMPhysSimpleWriteGCPtr, PGMPhysWriteGCPtrDirty -> PGMPhysSimpleDirtyWriteGCPtr.

Location:
trunk/src/VBox/VMM/PATM
Files:
5 edited

Legend:

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

    r12989 r13144  
    630630    if (PAGE_ADDRESS(pInstrGC) != PAGE_ADDRESS(pSrc + size - 1) && !PATMIsPatchGCAddr(pVM, pSrc))
    631631    {
    632         return PGMPhysReadGCPtr(pVM, pDest, pSrc, size);
     632        return PGMPhysSimpleReadGCPtr(pVM, pDest, pSrc, size);
    633633    }
    634634    else
     
    12061206            {
    12071207                addr = 0;
    1208                 PGMPhysReadGCPtr(pVM, &addr, (RTRCUINTPTR)cpu.param1.disp32, sizeof(addr));
     1208                PGMPhysSimpleReadGCPtr(pVM, &addr, (RTRCUINTPTR)cpu.param1.disp32, sizeof(addr));
    12091209            }
    12101210            else
     
    13571357    Assert((pInstr & PAGE_OFFSET_MASK) == 0);
    13581358
    1359     rc = PGMPhysReadGCPtr(pVM, &val[0], pInstr, sizeof(val[0]));
     1359    rc = PGMPhysSimpleReadGCPtr(pVM, &val[0], pInstr, sizeof(val[0]));
    13601360    AssertMsg(VBOX_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Vrc\n", rc));
    13611361    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
     
    13651365    }
    13661366
    1367     rc = PGMPhysReadGCPtr(pVM, &val[1], pInstr+1024, sizeof(val[0]));
     1367    rc = PGMPhysSimpleReadGCPtr(pVM, &val[1], pInstr+1024, sizeof(val[0]));
    13681368    AssertMsg(VBOX_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Vrc\n", rc));
    13691369    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
     
    13731373    }
    13741374
    1375     rc = PGMPhysReadGCPtr(pVM, &val[2], pInstr+2048, sizeof(val[0]));
     1375    rc = PGMPhysSimpleReadGCPtr(pVM, &val[2], pInstr+2048, sizeof(val[0]));
    13761376    AssertMsg(VBOX_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Vrc\n", rc));
    13771377    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
     
    13811381    }
    13821382
    1383     rc = PGMPhysReadGCPtr(pVM, &val[3], pInstr+3072, sizeof(val[0]));
     1383    rc = PGMPhysSimpleReadGCPtr(pVM, &val[3], pInstr+3072, sizeof(val[0]));
    13841384    AssertMsg(VBOX_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Vrc\n", rc));
    13851385    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
     
    13891389    }
    13901390
    1391     rc = PGMPhysReadGCPtr(pVM, &val[4], pInstr+4092, sizeof(val[0]));
     1391    rc = PGMPhysSimpleReadGCPtr(pVM, &val[4], pInstr+4092, sizeof(val[0]));
    13921392    AssertMsg(VBOX_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Vrc\n", rc));
    13931393    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
     
    23402340    {
    23412341        /* Slow method when it crosses a page boundary. */
    2342         rc = PGMPhysReadGCPtr(pVM, aIDT, GCPtrIDT,  cGates*sizeof(VBOXIDTE));
     2342        rc = PGMPhysSimpleReadGCPtr(pVM, aIDT, GCPtrIDT,  cGates*sizeof(VBOXIDTE));
    23432343        if (VBOX_FAILURE(rc))
    23442344        {
  • trunk/src/VBox/VMM/PATM/PATM.cpp

    r12989 r13144  
    560560    if (PAGE_ADDRESS(pDisInfo->pInstrGC) != PAGE_ADDRESS(pSrc + size - 1) && !PATMIsPatchGCAddr(pDisInfo->pVM, pSrc))
    561561    {
    562         return PGMPhysReadGCPtr(pDisInfo->pVM, pDest, pSrc, size);
     562        return PGMPhysSimpleReadGCPtr(pDisInfo->pVM, pDest, pSrc, size);
    563563    }
    564564    else
     
    654654                *(RTRCPTR *)&oldInstr[pPatch->patch.cbPrivInstr - sizeof(RTRCPTR)] = pRec->pDest;
    655655
    656                 rc = PGMPhysReadGCPtr(pVM, curInstr, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPrivInstr);
     656                rc = PGMPhysSimpleReadGCPtr(pVM, curInstr, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPrivInstr);
    657657                Assert(VBOX_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    658658
     
    681681                {
    682682                    *(RTRCPTR *)&curInstr[pPatch->patch.cbPrivInstr - sizeof(RTRCPTR)] = pRec->pDest;
    683                     rc = PGMPhysWriteGCPtrDirty(pVM, pRec->pSource, curInstr, pPatch->patch.cbPrivInstr);
     683                    rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pRec->pSource, curInstr, pPatch->patch.cbPrivInstr);
    684684                    AssertRC(rc);
    685685                }
     
    731731                 * Read old patch jump and compare it to the one we previously installed
    732732                 */
    733                 rc = PGMPhysReadGCPtr(pVM, temp, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPatchJump);
     733                rc = PGMPhysSimpleReadGCPtr(pVM, temp, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPatchJump);
    734734                Assert(VBOX_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    735735
     
    754754                if (VBOX_SUCCESS(rc))
    755755                {
    756                     rc = PGMPhysWriteGCPtrDirty(pVM, pJumpOffGC, &displ, sizeof(displ));
     756                    rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pJumpOffGC, &displ, sizeof(displ));
    757757                    AssertRC(rc);
    758758                }
     
    25322532        *(uint32_t *)&temp[1] = (RTRCUINTPTR)PATCHCODE_PTR_GC(pPatch) - ((RTRCUINTPTR)pPatch->pPrivInstrGC + SIZEOF_NEARJUMP32);    //return address
    25332533    }
    2534     rc = PGMPhysWriteGCPtrDirty(pVM, pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump);
     2534    rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump);
    25352535    AssertRC(rc);
    25362536
     
    25702570
    25712571    /* Restore original code (privileged instruction + following instructions that were overwritten because of the 5/6 byte jmp). */
    2572     int rc = PGMPhysWriteGCPtrDirty(pVM, pPatch->pPrivInstrGC, pPatch->aPrivInstr, pPatch->cbPatchJump);
     2572    int rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pPatch->pPrivInstrGC, pPatch->aPrivInstr, pPatch->cbPatchJump);
    25732573#ifdef DEBUG
    25742574    if (rc == VINF_SUCCESS)
     
    26292629    *(uint32_t *)&temp[1] = (uint32_t)pTargetGC - ((uint32_t)pPatch->pPrivInstrGC + SIZEOF_NEARJUMP32);    //return address
    26302630
    2631     rc = PGMPhysWriteGCPtrDirty(pVM, pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump);
     2631    rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump);
    26322632    AssertRC(rc);
    26332633
     
    27952795    pPatch->cbPatchJump = SIZEOF_NEARJUMP32;
    27962796
    2797     rc = PGMPhysReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     2797    rc = PGMPhysSimpleReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    27982798    AssertRC(rc);
    27992799
     
    35273527    pPatch->cbPatchJump = SIZEOF_NEARJUMP32;
    35283528
    3529     rc = PGMPhysReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     3529    rc = PGMPhysSimpleReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    35303530    AssertRC(rc);
    35313531
     
    36033603
    36043604    /* Save original instruction. */
    3605     rc = PGMPhysReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPrivInstr);
     3605    rc = PGMPhysSimpleReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPrivInstr);
    36063606    AssertRC(rc);
    36073607
     
    36093609
    36103610    /* Replace address with that of the cached item. */
    3611     rc = PGMPhysWriteGCPtrDirty(pVM, pInstrGC + pCpu->opsize - sizeof(RTRCPTR), &pVM->patm.s.mmio.pCachedData, sizeof(RTRCPTR));
     3611    rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pInstrGC + pCpu->opsize - sizeof(RTRCPTR), &pVM->patm.s.mmio.pCachedData, sizeof(RTRCPTR));
    36123612    AssertRC(rc);
    36133613    if (VBOX_FAILURE(rc))
     
    37163716
    37173717    /* Replace first opcode byte with 'int 3'. */
    3718     rc = PGMPhysWriteGCPtrDirty(pVM, pPatch->pPrivInstrGC, &ASMInt3, sizeof(ASMInt3));
     3718    rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pPatch->pPrivInstrGC, &ASMInt3, sizeof(ASMInt3));
    37193719    AssertRC(rc);
    37203720
     
    37403740
    37413741    /* Restore first opcode byte. */
    3742     rc = PGMPhysWriteGCPtrDirty(pVM, pPatch->pPrivInstrGC, pPatch->aPrivInstr, sizeof(ASMInt3));
     3742    rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pPatch->pPrivInstrGC, pPatch->aPrivInstr, sizeof(ASMInt3));
    37433743    AssertRC(rc);
    37443744    return rc;
     
    37763776
    37773777    /* Save the original instruction. */
    3778     rc = PGMPhysReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPrivInstr);
     3778    rc = PGMPhysSimpleReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPrivInstr);
    37793779    AssertRC(rc);
    37803780    pPatch->cbPatchJump = sizeof(ASMInt3);  /* bit of a misnomer in this case; size of replacement instruction. */
     
    38803880    pPatch->cbPatchJump = pCpu->opsize;
    38813881
    3882     rc = PGMPhysReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     3882    rc = PGMPhysSimpleReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    38833883    AssertRC(rc);
    38843884
     
    50105010
    50115011                    /* Let's first check if the guest code is still the same. */
    5012                     rc = PGMPhysReadGCPtr(pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     5012                    rc = PGMPhysSimpleReadGCPtr(pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    50135013                    Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_TABLE_NOT_PRESENT || rc == VERR_PAGE_NOT_PRESENT);
    50145014                    if (rc == VINF_SUCCESS)
     
    50525052
    50535053            /* Let's first check if the guest code is still the same. */
    5054             rc = PGMPhysReadGCPtr(pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     5054            rc = PGMPhysSimpleReadGCPtr(pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    50555055            Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_TABLE_NOT_PRESENT || rc == VERR_PAGE_NOT_PRESENT);
    50565056            if (rc == VINF_SUCCESS)
     
    52345234
    52355235                    // let's first check if the guest code is still the same
    5236                     int rc = PGMPhysReadGCPtr(pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     5236                    int rc = PGMPhysSimpleReadGCPtr(pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    52375237                    AssertRC(rc);
    52385238
     
    52735273
    52745274                /* Let's first check if the guest code is still the same. */
    5275                 int rc = PGMPhysReadGCPtr(pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     5275                int rc = PGMPhysSimpleReadGCPtr(pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    52765276                AssertRC(rc);
    52775277
     
    59195919
    59205920                /* Copy the new instruction. */
    5921                 rc = PGMPhysReadGCPtr(pVM, pCurPatchInstrHC, pCurInstrGC, CpuNew.opsize);
     5921                rc = PGMPhysSimpleReadGCPtr(pVM, pCurPatchInstrHC, pCurInstrGC, CpuNew.opsize);
    59225922                AssertRC(rc);
    59235923
     
    61886188            AssertRC(rc);
    61896189
    6190             rc = PGMPhysReadGCPtr(pVM, &retaddr, pCtx->esp, sizeof(retaddr));
     6190            rc = PGMPhysSimpleReadGCPtr(pVM, &retaddr, pCtx->esp, sizeof(retaddr));
    61916191            AssertRC(rc);
    61926192
  • trunk/src/VBox/VMM/PATM/PATMGuest.cpp

    r9220 r13144  
    111111    /* check the epilog of KiFastSystemCall */
    112112    lpfnKiFastSystemCall = pInstrGC - 2;
    113     rc = PGMPhysReadGCPtr(pVM, uTemp, lpfnKiFastSystemCall, sizeof(uFnKiFastSystemCall));
     113    rc = PGMPhysSimpleReadGCPtr(pVM, uTemp, lpfnKiFastSystemCall, sizeof(uFnKiFastSystemCall));
    114114    if (    VBOX_FAILURE(rc)
    115115        ||  memcmp(uFnKiFastSystemCall, uTemp, sizeof(uFnKiFastSystemCall)))
     
    121121    for (i=0;i<64;i++)
    122122    {
    123         rc = PGMPhysReadGCPtr(pVM, uTemp, pInstrGC + i, sizeof(uFnKiIntSystemCall));
     123        rc = PGMPhysSimpleReadGCPtr(pVM, uTemp, pInstrGC + i, sizeof(uFnKiIntSystemCall));
    124124        if(VBOX_FAILURE(rc))
    125125        {
     
    146146
    147147    // make a copy of the guest code bytes that will be overwritten
    148     rc = PGMPhysReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, SIZEOF_NEARJUMP32);
     148    rc = PGMPhysSimpleReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, SIZEOF_NEARJUMP32);
    149149    AssertRC(rc);
    150150
     
    152152    uTemp[0] = 0xE9;
    153153    *(RTGCPTR32 *)&uTemp[1] = lpfnKiIntSystemCall - (pInstrGC + SIZEOF_NEARJUMP32);
    154     rc = PGMPhysWriteGCPtrDirty(pVM, pInstrGC, uTemp, SIZEOF_NEARJUMP32);
     154    rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pInstrGC, uTemp, SIZEOF_NEARJUMP32);
    155155    if (VBOX_FAILURE(rc))
    156156    {
     
    189189    /* Guest OS specific patch; check heuristics first */
    190190
    191     rc = PGMPhysReadGCPtr(pVM, uTemp, pInstrGC, RT_MAX(sizeof(uFnOpenBSDHandlerPrefix1), sizeof(uFnOpenBSDHandlerPrefix2)));
    192     if (    VBOX_FAILURE(rc) 
     191    rc = PGMPhysSimpleReadGCPtr(pVM, uTemp, pInstrGC, RT_MAX(sizeof(uFnOpenBSDHandlerPrefix1), sizeof(uFnOpenBSDHandlerPrefix2)));
     192    if (    VBOX_FAILURE(rc)
    193193        || (    memcmp(uFnOpenBSDHandlerPrefix1, uTemp, sizeof(uFnOpenBSDHandlerPrefix1))
    194194            &&  memcmp(uFnOpenBSDHandlerPrefix2, uTemp, sizeof(uFnOpenBSDHandlerPrefix2))))
  • trunk/src/VBox/VMM/PATM/PATMPatch.cpp

    r12600 r13144  
    404404static int patmPatchReadBytes(PVM pVM, uint8_t *pDest, RTRCPTR pSrc, uint32_t cb)
    405405{
    406     int rc = PGMPhysReadGCPtr(pVM, pDest, pSrc, cb);
     406    int rc = PGMPhysSimpleReadGCPtr(pVM, pDest, pSrc, cb);
    407407    AssertRCReturn(rc, rc);
    408408    /*
  • trunk/src/VBox/VMM/PATM/PATMSSM.cpp

    r12600 r13144  
    360360        rc = SSMR3GetS32(pSSM, &patmInfo.uCurrentPatchIdx);
    361361        AssertRCReturn(rc, rc);
    362                
     362
    363363        AssertCompile(sizeof(patmInfo.pPatchedInstrGCLowest) == sizeof(RTRCPTR));
    364364        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pPatchedInstrGCLowest);
     
    400400        rc = SSMR3GetU32(pSSM, &patmInfo.savedstate.cPatches);
    401401        AssertRCReturn(rc, rc);
    402        
     402
    403403    }
    404404#endif
     
    440440    Log(("pGCStackGC  %VRv vs old %VRv\n", pVM->patm.s.pGCStackGC, patmInfo.pGCStackGC));
    441441    Log(("pCPUMCtxGC  %VRv vs old %VRv\n", pVM->patm.s.pCPUMCtxGC, patmInfo.pCPUMCtxGC));
    442    
     442
    443443
    444444    /** @note patch statistics are not restored. */
     
    670670    /*
    671671     * Correct absolute fixups in the global patch. (helper functions)
    672      * Bit of a mess. Uses the new patch record, but restored patch functions. 
     672     * Bit of a mess. Uses the new patch record, but restored patch functions.
    673673     */
    674674    PRELOCREC pRec = 0;
     
    731731            break;
    732732
    733         if (    *pFixup >= patmInfo.pGCStateGC 
     733        if (    *pFixup >= patmInfo.pGCStateGC
    734734            &&  *pFixup <  patmInfo.pGCStateGC + sizeof(PATMGCSTATE))
    735735        {
     
    738738        }
    739739        else
    740         if (    *pFixup >= patmInfo.pCPUMCtxGC 
     740        if (    *pFixup >= patmInfo.pCPUMCtxGC
    741741            &&  *pFixup <  patmInfo.pCPUMCtxGC + sizeof(CPUMCTX))
    742742        {
     
    848848        }
    849849        else
    850         if (    *pFixup >= patmInfo.pStatsGC 
     850        if (    *pFixup >= patmInfo.pStatsGC
    851851            &&  *pFixup <  patmInfo.pStatsGC + PATM_STAT_MEMSIZE)
    852852        {
     
    855855        }
    856856        else
    857         if (    *pFixup >= patmInfo.pGCStackGC 
     857        if (    *pFixup >= patmInfo.pGCStackGC
    858858            &&  *pFixup <  patmInfo.pGCStackGC + PATM_STACK_TOTAL_SIZE)
    859859        {
     
    862862        }
    863863        else
    864         if (    *pFixup >= patmInfo.pPatchMemGC 
     864        if (    *pFixup >= patmInfo.pPatchMemGC
    865865            &&  *pFixup <  patmInfo.pPatchMemGC + patmInfo.cbPatchMem)
    866866        {
     
    956956             * Read old patch jump and compare it to the one we previously installed
    957957             */
    958             int rc = PGMPhysReadGCPtr(pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     958            int rc = PGMPhysSimpleReadGCPtr(pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    959959            Assert(VBOX_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    960960
     
    979979            if (VBOX_SUCCESS(rc))
    980980            {
    981                 rc = PGMPhysWriteGCPtrDirty(pVM, pJumpOffGC, &displ, sizeof(displ));
     981                rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pJumpOffGC, &displ, sizeof(displ));
    982982                AssertRC(rc);
    983983            }
     
    10061006        pRec->pSource = pSource;
    10071007        break;
    1008  
     1008
    10091009    }
    10101010}
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