VirtualBox

Changeset 21174 in vbox for trunk


Ignore:
Timestamp:
Jul 2, 2009 3:45:46 PM (16 years ago)
Author:
vboxsync
Message:

Preread opcode bytes when disassembling instructions. PGMPhysSimpleReadGCPtr is quite expensive.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r20682 r21174  
    7070typedef struct
    7171{
    72     PVM     pVM;
    73     PVMCPU  pVCpu;
     72    PVM         pVM;
     73    PVMCPU      pVCpu;
     74    RTGCPTR     GCPtr;
     75    uint8_t     aOpcode[8];
    7476} EMDISSTATE, *PEMDISSTATE;
    7577
     
    125127
    126128# ifdef IN_RING0
    127     int rc = PGMPhysSimpleReadGCPtr(pVCpu, pDest, pSrc, cb);
     129    int rc;
     130
     131    if (    pState->GCPtr
     132        &&  pSrc + cb <= pState->GCPtr + sizeof(pState->aOpcode))
     133    {
     134        unsigned offset = pSrc - pState->GCPtr;
     135
     136        Assert(pSrc >= pState->GCPtr);
     137
     138        for (unsigned i=0; i<cb; i++)
     139        {
     140            pDest[i] = pState->aOpcode[offset + i];
     141        }
     142        return VINF_SUCCESS;
     143    }
     144
     145    rc = PGMPhysSimpleReadGCPtr(pVCpu, pDest, pSrc, cb);
    128146    AssertMsgRC(rc, ("PGMPhysSimpleReadGCPtr failed for pSrc=%RGv cb=%x rc=%d\n", pSrc, cb, rc));
    129147# else /* IN_RING3 */
     
    135153    else
    136154    {
    137         for (uint32_t i = 0; i < cb; i++)
     155        for (unsigned i = 0; i < cb; i++)
    138156        {
    139157            uint8_t opcode;
     
    153171    State.pVM   = pVM;
    154172    State.pVCpu = pVCpu;
     173    int rc = PGMPhysSimpleReadGCPtr(pVCpu, &State.aOpcode, InstrGC, sizeof(State.aOpcode));
     174    if (RT_SUCCESS(rc))
     175        State.GCPtr = InstrGC;
     176    else
     177        State.GCPtr = NULL;
    155178
    156179    return DISCoreOneEx(InstrGC, pDis->mode, EMReadBytes, &State, pDis, pOpsize);
     
    213236VMMDECL(int) EMInterpretDisasOneEx(PVM pVM, PVMCPU pVCpu, RTGCUINTPTR GCPtrInstr, PCCPUMCTXCORE pCtxCore, PDISCPUSTATE pDis, unsigned *pcbInstr)
    214237{
     238    int rc;
     239
    215240#ifndef IN_RC
    216241    EMDISSTATE State;
     
    218243    State.pVM   = pVM;
    219244    State.pVCpu = pVCpu;
    220 #endif
    221 
    222     int rc = DISCoreOneEx(GCPtrInstr, SELMGetCpuModeFromSelector(pVM, pCtxCore->eflags, pCtxCore->cs, (PCPUMSELREGHID)&pCtxCore->csHid),
     245
     246    rc = PGMPhysSimpleReadGCPtr(pVCpu, &State.aOpcode, GCPtrInstr, sizeof(State.aOpcode));
     247    if (RT_SUCCESS(rc))
     248        State.GCPtr = GCPtrInstr;
     249    else
     250        State.GCPtr = NULL;
     251#endif
     252
     253    rc = DISCoreOneEx(GCPtrInstr, SELMGetCpuModeFromSelector(pVM, pCtxCore->eflags, pCtxCore->cs, (PCPUMSELREGHID)&pCtxCore->csHid),
    223254#ifdef IN_RC
    224255                          NULL, NULL,
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