VirtualBox

Changeset 11424

Show
Ignore:
Timestamp:
08/14/08 15:46:06 (3 months ago)
Author:
vboxsync
Message:

Emulate stosw/d/q ourselves.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/cpum.h

    r10630 r11424  
    9090    union 
    9191    { 
     92        uint16_t        di; 
    9293        uint32_t        edi; 
    9394        uint64_t        rdi; 
     
    9596    union 
    9697    { 
     98        uint16_t        si; 
    9799        uint32_t        esi; 
    98100        uint64_t        rsi; 
     
    100102    union 
    101103    { 
     104        uint16_t        bp; 
    102105        uint32_t        ebp; 
    103106        uint64_t        rbp; 
     
    105108    union 
    106109    { 
     110        uint16_t        ax; 
    107111        uint32_t        eax; 
    108112        uint64_t        rax; 
     
    110114    union 
    111115    { 
     116        uint16_t        bx; 
    112117        uint32_t        ebx; 
    113118        uint64_t        rbx; 
     
    115120    union 
    116121    { 
     122        uint16_t        dx; 
    117123        uint32_t        edx; 
    118124        uint64_t        rdx; 
     
    120126    union 
    121127    { 
     128        uint16_t        cx; 
    122129        uint32_t        ecx; 
    123130        uint64_t        rcx; 
     
    125132    union 
    126133    { 
     134        uint16_t        sp; 
    127135        uint32_t        esp; 
    128136        uint64_t        rsp; 
     
    151159    union 
    152160    { 
     161        uint16_t        ip; 
    153162        uint32_t        eip; 
    154163        uint64_t        rip; 
     
    193202    union 
    194203    { 
     204        uint16_t        di; 
    195205        uint32_t        edi; 
    196206        uint64_t        rdi; 
     
    198208    union 
    199209    { 
     210        uint16_t        si; 
    200211        uint32_t        esi; 
    201212        uint64_t        rsi; 
     
    203214    union 
    204215    { 
     216        uint16_t        bp; 
    205217        uint32_t        ebp; 
    206218        uint64_t        rbp; 
     
    208220    union 
    209221    { 
     222        uint16_t        ax; 
    210223        uint32_t        eax; 
    211224        uint64_t        rax; 
     
    213226    union 
    214227    { 
     228        uint16_t        bx; 
    215229        uint32_t        ebx; 
    216230        uint64_t        rbx; 
     
    218232    union 
    219233    { 
     234        uint16_t        dx; 
    220235        uint32_t        edx; 
    221236        uint64_t        rdx; 
     
    223238    union 
    224239    { 
     240        uint16_t        cx; 
    225241        uint32_t        ecx; 
    226242        uint64_t        rcx; 
     
    228244    union 
    229245    { 
     246        uint16_t        sp; 
    230247        uint32_t        esp; 
    231248        uint64_t        rsp; 
     
    254271    union 
    255272    { 
     273        uint16_t        ip; 
    256274        uint32_t        eip; 
    257275        uint64_t        rip; 
  • trunk/src/VBox/VMM/EM.cpp

    r10706 r11424  
    213213    STAM_REG_USED(pVM, &pStats->StatHCWrmsr,                STAMTYPE_COUNTER, "/EM/HC/Interpret/Success/Wrmsr",      STAMUNIT_OCCURENCES,   "The number of times WRMSR was not interpreted."); 
    214214    STAM_REG_USED(pVM, &pStats->StatGCWrmsr,                STAMTYPE_COUNTER, "/EM/GC/Interpret/Success/Wrmsr",      STAMUNIT_OCCURENCES,   "The number of times WRMSR was not interpreted."); 
     215    STAM_REG_USED(pVM, &pStats->StatHCStosWD,               STAMTYPE_COUNTER, "/EM/HC/Interpret/Success/Stoswd",     STAMUNIT_OCCURENCES,   "The number of times STOSWD was not interpreted."); 
     216    STAM_REG_USED(pVM, &pStats->StatGCStosWD,               STAMTYPE_COUNTER, "/EM/GC/Interpret/Success/Stoswd",     STAMUNIT_OCCURENCES,   "The number of times STOSWD was not interpreted."); 
    215217 
    216218    STAM_REG(pVM, &pStats->StatGCInterpretFailed,           STAMTYPE_COUNTER, "/EM/GC/Interpret/Failed",            STAMUNIT_OCCURENCES,    "The number of times an instruction was not interpreted."); 
  • trunk/src/VBox/VMM/EMInternal.h

    r9387 r11424  
    141141    STAMCOUNTER             StatGCClts; 
    142142    STAMCOUNTER             StatHCClts; 
     143    STAMCOUNTER             StatGCStosWD; 
     144    STAMCOUNTER             StatHCStosWD; 
    143145    STAMCOUNTER             StatHCRdmsr; 
    144146    STAMCOUNTER             StatHCWrmsr; 
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r10883 r11424  
    13011301    return VERR_EM_INTERPRETER; 
    13021302} 
     1303 
     1304#ifndef IN_GC 
     1305/* 
     1306 * [REP] STOSWD emulation 
     1307 * 
     1308 */ 
     1309static int emInterpretStosWD(PVM pVM, PDISCPUSTATE pCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize) 
     1310{ 
     1311    int      rc; 
     1312    RTGCPTR  GCDest, GCOffset; 
     1313    uint32_t cbSize; 
     1314    uint64_t cTransfers; 
     1315 
     1316    /* Don't support any but these three prefix bytes. */ 
     1317    if ((pCpu->prefix & ~(PREFIX_ADDRSIZE|PREFIX_OPSIZE|PREFIX_REP|PREFIX_REX))) 
     1318        return VERR_EM_INTERPRETER; 
     1319 
     1320    switch (pCpu->addrmode) 
     1321    { 
     1322    case CPUMODE_16BIT: 
     1323        GCOffset   = pRegFrame->di; 
     1324        cTransfers = pRegFrame->cx; 
     1325        break; 
     1326    case CPUMODE_32BIT: 
     1327        GCOffset   = pRegFrame->edi; 
     1328        cTransfers = pRegFrame->ecx; 
     1329        break; 
     1330    case CPUMODE_64BIT: 
     1331        GCOffset   = pRegFrame->rdi; 
     1332        cTransfers = pRegFrame->rcx; 
     1333        break; 
     1334    default: 
     1335        AssertFailed(); 
     1336        return VERR_EM_INTERPRETER; 
     1337    } 
     1338 
     1339    GCDest = SELMToFlat(pVM, DIS_SELREG_ES, pRegFrame, GCOffset); 
     1340    switch (pCpu->opmode) 
     1341    { 
     1342    case CPUMODE_16BIT: 
     1343        cbSize = 2; 
     1344        break; 
     1345    case CPUMODE_32BIT: 
     1346        cbSize = 4; 
     1347        break; 
     1348    case CPUMODE_64BIT: 
     1349        cbSize = 8; 
     1350        break; 
     1351    default: 
     1352        AssertFailed(); 
     1353        return VERR_EM_INTERPRETER; 
     1354    } 
     1355 
     1356    LogFlow(("emInterpretStosWD dest=%VGv cbSize=%d\n", GCDest, cbSize)); 
     1357 
     1358    if (!(pCpu->prefix & PREFIX_REP)) 
     1359    { 
     1360        rc = PGMPhysWriteGCPtrSafe(pVM, GCDest, &pRegFrame->rax, cbSize); 
     1361        if (VBOX_FAILURE(rc)) 
     1362            return VERR_EM_INTERPRETER; 
     1363        Assert(rc == VINF_SUCCESS); 
     1364    } 
     1365    else 
     1366    {     
     1367        /* REP case */ 
     1368        while (cTransfers) 
     1369        { 
     1370            rc = PGMPhysWriteGCPtrSafe(pVM, GCDest, &pRegFrame->rax, cbSize); 
     1371            if (VBOX_FAILURE(rc)) 
     1372            { 
     1373                rc = VERR_EM_INTERPRETER; 
     1374                break; 
     1375            } 
     1376 
     1377            Assert(rc == VINF_SUCCESS); 
     1378            GCOffset += cbSize; 
     1379            GCDest   += cbSize; 
     1380            cTransfers--; 
     1381        } 
     1382 
     1383        /* Update the registers. */ 
     1384        switch (pCpu->addrmode) 
     1385        { 
     1386        case CPUMODE_16BIT: 
     1387            pRegFrame->di = GCOffset; 
     1388            pRegFrame->cx = cTransfers; 
     1389            break; 
     1390        case CPUMODE_32BIT: 
     1391            pRegFrame->edi = GCOffset; 
     1392            pRegFrame->ecx = cTransfers; 
     1393            break; 
     1394        case CPUMODE_64BIT: 
     1395            pRegFrame->rdi = GCOffset; 
     1396            pRegFrame->rcx = cTransfers; 
     1397            break; 
     1398        } 
     1399    } 
     1400 
     1401    *pcbSize = cbSize; 
     1402    return rc; 
     1403} 
     1404#endif 
     1405 
    13031406 
    13041407/* 
     
    25312634       ) 
    25322635#else 
    2533     if (    (pCpu->prefix & (PREFIX_REPNE | PREFIX_REP)) 
     2636    if (    (pCpu->prefix & PREFIX_REPNE) 
     2637        ||  (   (pCpu->prefix & PREFIX_REP) 
     2638             && pCpu->pCurInstr->opcode != OP_STOSWD 
     2639            ) 
    25342640        ||  (   (pCpu->prefix & PREFIX_LOCK) 
    25352641             && pCpu->pCurInstr->opcode != OP_OR 
     
    25942700        INTERPRET_CASE_EX_PARAM3(OP_AND,And, OrXorAnd, EMEmulateAnd); 
    25952701        INTERPRET_CASE(OP_MOV,Mov); 
     2702#ifndef IN_GC 
     2703        INTERPRET_CASE(OP_STOSWD,StosWD); 
     2704#endif 
    25962705        INTERPRET_CASE(OP_INVLPG,InvlPg); 
    25972706        INTERPRET_CASE(OP_CPUID,CpuId); 
     
    26262735#endif 
    26272736        INTERPRET_STAT_CASE(OP_MOVNTPS,MovNTPS); 
    2628         INTERPRET_STAT_CASE(OP_STOSWD,StosWD); 
    26292737        INTERPRET_STAT_CASE(OP_WBINVD,WbInvd); 
    26302738#endif 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy