VirtualBox

Changeset 102757 in vbox for trunk/src


Ignore:
Timestamp:
Jan 3, 2024 8:09:41 PM (13 months ago)
Author:
vboxsync
Message:

VMM/IEM: Avoid flushing volatile registers during IEM_MC_MEM_FETCH/STORE. bugref:10371

File:
1 edited

Legend:

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

    r102756 r102757  
    1080610806    off = iemNativeRegFlushPendingWrites(pReNative, off);
    1080710807
     10808#ifdef IEMNATIVE_WITH_FREE_AND_FLUSH_VOLATILE_REGS_AT_TLB_LOOKUP
    1080810809    /*
    1080910810     * Move/spill/flush stuff out of call-volatile registers.
     
    1081110812     * by saving and restoring active stuff here.
    1081210813     */
    10813     /** @todo save+restore active registers and maybe guest shadows in tlb-miss.  */
    1081410814    off = iemNativeRegMoveAndFreeAndFlushAtCall(pReNative, off, 0 /* vacate all non-volatile regs */);
     10815#endif
    1081510816
    1081610817    /*
     
    1085410855#endif
    1085510856
     10857#ifndef IEMNATIVE_WITH_FREE_AND_FLUSH_VOLATILE_REGS_AT_TLB_LOOKUP
     10858    /* Save variables in volatile registers. */
     10859    uint32_t const fHstRegsNotToSave = TlbState.getRegsNotToSave()
     10860                                     | (idxRegMemResult  != UINT8_MAX ? RT_BIT_32(idxRegMemResult)  : 0)
     10861                                     | (idxRegValueFetch != UINT8_MAX ? RT_BIT_32(idxRegValueFetch) : 0);
     10862    off = iemNativeVarSaveVolatileRegsPreHlpCall(pReNative, off, fHstRegsNotToSave);
     10863#endif
     10864
    1085610865    /* IEMNATIVE_CALL_ARG2/3_GREG = uValue (idxVarValue) - if store */
     10866    uint32_t fVolGregMask = IEMNATIVE_CALL_VOLATILE_GREG_MASK;
    1085710867    if (enmOp == kIemNativeEmitMemOp_Store)
    1085810868    {
    1085910869        uint8_t const idxRegArgValue = iSegReg == UINT8_MAX ? IEMNATIVE_CALL_ARG2_GREG : IEMNATIVE_CALL_ARG3_GREG;
    10860         if (pReNative->Core.aVars[idxVarValue].enmKind == kIemNativeVarKind_Immediate)
    10861             off = iemNativeEmitLoadGprImm64(pReNative, off, idxRegArgValue, pReNative->Core.aVars[idxVarValue].u.uValue);
    10862         else
    10863         {
    10864             uint8_t const idxRegVarValue = pReNative->Core.aVars[idxVarValue].idxReg;
    10865             if (idxRegVarValue < RT_ELEMENTS(pReNative->Core.aHstRegs))
    10866             {
    10867                 Assert(!(RT_BIT_32(idxRegVarValue) & IEMNATIVE_CALL_VOLATILE_GREG_MASK));
    10868                 off = iemNativeEmitLoadGprFromGpr(pReNative, off, idxRegArgValue, idxRegVarValue);
    10869             }
    10870             else
    10871             {
    10872                 uint8_t const idxStackSlot = pReNative->Core.aVars[idxVarValue].idxStackSlot;
    10873                 AssertStmt(idxStackSlot != UINT8_MAX, IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_NOT_INITIALIZED));
    10874                 off = iemNativeEmitLoadGprByBp(pReNative, off, idxRegArgValue, iemNativeStackCalcBpDisp(idxStackSlot));
    10875             }
    10876         }
     10870        off = iemNativeEmitLoadArgGregFromImmOrStackVar(pReNative, off, idxRegArgValue, idxVarValue, 0 /*cbAppend*/,
     10871#ifdef IEMNATIVE_WITH_FREE_AND_FLUSH_VOLATILE_REGS_AT_TLB_LOOKUP
     10872                                                        IEMNATIVE_CALL_VOLATILE_GREG_MASK);
     10873#else
     10874                                                        IEMNATIVE_CALL_VOLATILE_GREG_MASK, true /*fSpilledVarsInvolatileRegs*/);
     10875        fVolGregMask &= ~RT_BIT_32(idxRegArgValue);
     10876#endif
    1087710877    }
    1087810878
    1087910879    /* IEMNATIVE_CALL_ARG1_GREG = GCPtrMem */
    10880     if (pReNative->Core.aVars[idxVarGCPtrMem].enmKind == kIemNativeVarKind_Immediate)
    10881         off = iemNativeEmitLoadGprImm64(pReNative, off, IEMNATIVE_CALL_ARG1_GREG,
    10882                                         pReNative->Core.aVars[idxVarGCPtrMem].u.uValue + offDisp);
    10883     else
    10884     {
    10885         uint8_t const idxRegVarGCPtrMem = pReNative->Core.aVars[idxVarGCPtrMem].idxReg;
    10886         if (idxRegVarGCPtrMem < RT_ELEMENTS(pReNative->Core.aHstRegs))
    10887         {
    10888             Assert(!(RT_BIT_32(idxRegVarGCPtrMem) & IEMNATIVE_CALL_VOLATILE_GREG_MASK));
    10889             if (!offDisp)
    10890                 off = iemNativeEmitLoadGprFromGpr(pReNative, off, IEMNATIVE_CALL_ARG1_GREG, idxRegVarGCPtrMem);
    10891             else
    10892                 off = iemNativeEmitLoadGprFromGprWithAddend(pReNative, off, IEMNATIVE_CALL_ARG1_GREG, idxRegVarGCPtrMem, offDisp);
    10893         }
    10894         else
    10895         {
    10896             uint8_t const idxStackSlot = pReNative->Core.aVars[idxVarGCPtrMem].idxStackSlot;
    10897             AssertStmt(idxStackSlot != UINT8_MAX, IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_NOT_INITIALIZED));
    10898             AssertFailed(); /** @todo This was probably caused by iemNativeRegMoveAndFreeAndFlushAtCall above. Improve... */
    10899             off = iemNativeEmitLoadGprByBp(pReNative, off, IEMNATIVE_CALL_ARG1_GREG, iemNativeStackCalcBpDisp(idxStackSlot));
    10900             if (offDisp)
    10901                 off = iemNativeEmitAddGprImm(pReNative, off, IEMNATIVE_CALL_ARG1_GREG, offDisp);
    10902         }
    10903     }
     10880    off = iemNativeEmitLoadArgGregFromImmOrStackVar(pReNative, off, IEMNATIVE_CALL_ARG1_GREG, idxVarGCPtrMem, offDisp /*cbAppend*/,
     10881#ifdef IEMNATIVE_WITH_FREE_AND_FLUSH_VOLATILE_REGS_AT_TLB_LOOKUP
     10882                                                    fVolGregMask);
     10883#else
     10884                                                    fVolGregMask, true /*fSpilledVarsInvolatileRegs*/);
     10885#endif
    1090410886
    1090510887    if (iSegReg != UINT8_MAX)
     
    1092510907            off = iemNativeEmitLoadGprFromGpr(pReNative, off, idxRegValueFetch, IEMNATIVE_CALL_RET_GREG);
    1092610908    }
     10909
     10910#ifndef IEMNATIVE_WITH_FREE_AND_FLUSH_VOLATILE_REGS_AT_TLB_LOOKUP
     10911    /* Restore variables and guest shadow registers to volatile registers. */
     10912    off = iemNativeVarRestoreVolatileRegsPostHlpCall(pReNative, off, fHstRegsNotToSave);
     10913    off = iemNativeRegRestoreGuestShadowsInVolatileRegs(pReNative, off, TlbState.getActiveRegsWithShadows());
     10914#endif
    1092710915
    1092810916#ifdef IEMNATIVE_WITH_TLB_LOOKUP
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