VirtualBox

Changeset 102558 in vbox


Ignore:
Timestamp:
Dec 8, 2023 10:59:19 PM (12 months ago)
Author:
vboxsync
Message:

VMM/IEM: Prevent variable registers from being spilled or moved while we're using them. bugref:10371

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

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

    r102557 r102558  
    29802980            uint32_t const idxVar = ASMBitFirstSetU32(fVars) - 1;
    29812981            uint8_t const  idxReg = pReNative->Core.aVars[idxVar].idxReg;
    2982 /** @todo Prevent active variables from changing here... */
    29832982            if (   idxReg < RT_ELEMENTS(pReNative->Core.aHstRegs)
    29842983                && (RT_BIT_32(idxReg) & fRegMask)
    29852984                && (  iLoop == 0
    29862985                    ? pReNative->Core.aVars[idxVar].enmKind != kIemNativeVarKind_Stack
    2987                     : pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Stack))
     2986                    : pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Stack)
     2987                && !pReNative->Core.aVars[idxVar].fRegAcquired)
    29882988            {
    29892989                Assert(pReNative->Core.bmHstRegs & RT_BIT_32(idxReg));
     
    30803080                                                uint32_t fForbiddenRegs = IEMNATIVE_CALL_VOLATILE_GREG_MASK)
    30813081{
    3082     Assert(idxVar < RT_ELEMENTS(pReNative->Core.aVars));
     3082    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
    30833083    Assert(pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Stack);
     3084    Assert(!pReNative->Core.aVars[idxVar].fRegAcquired);
    30843085
    30853086    uint8_t const idxRegOld = pReNative->Core.aVars[idxVar].idxReg;
     
    59715972    pReNative->Core.aVars[idxVar].idxReferrerVar = UINT8_MAX;
    59725973    pReNative->Core.aVars[idxVar].enmGstReg      = kIemNativeGstReg_End;
     5974    pReNative->Core.aVars[idxVar].fRegAcquired   = false;
    59735975    pReNative->Core.aVars[idxVar].u.uValue       = 0;
    59745976    return idxVar;
     
    62606262
    62616263/**
    6262  * Makes sure variable @a idxVar has a register assigned to it.
     6264 * Releases the variable's register.
     6265 *
     6266 * The register must have been previously acquired calling
     6267 * iemNativeVarRegisterAcquire(), iemNativeVarRegisterAcquireForGuestReg() or
     6268 * iemNativeVarRegisterSetAndAcquire().
     6269 */
     6270DECL_INLINE_THROW(void) iemNativeVarRegisterRelease(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar)
     6271{
     6272    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
     6273    Assert(pReNative->Core.aVars[idxVar].fRegAcquired);
     6274    pReNative->Core.aVars[idxVar].fRegAcquired = false;
     6275}
     6276
     6277
     6278/**
     6279 * Makes sure variable @a idxVar has a register assigned to it and that it stays
     6280 * fixed till we call iemNativeVarRegisterRelease.
    62636281 *
    62646282 * @returns The host register number.
     
    62726290 *                      the case.
    62736291 */
    6274 DECL_HIDDEN_THROW(uint8_t) iemNativeVarAllocRegister(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar,
    6275                                                      uint32_t *poff, bool fInitialized = false)
     6292DECL_HIDDEN_THROW(uint8_t) iemNativeVarRegisterAcquire(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar,
     6293                                                       uint32_t *poff, bool fInitialized = false)
    62766294{
    62776295    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
    62786296    Assert(pReNative->Core.aVars[idxVar].cbVar <= 8);
    6279 /** @todo we must mark the variable as active and add a release function to
    6280  *        mark it as inactive, otherwise temporary register allocations may
    6281  *        cause the variable to be spilled onto the stack. */
     6297    Assert(!pReNative->Core.aVars[idxVar].fRegAcquired);
    62826298
    62836299    uint8_t idxReg = pReNative->Core.aVars[idxVar].idxReg;
     
    62866302        Assert(   pReNative->Core.aVars[idxVar].enmKind > kIemNativeVarKind_Invalid
    62876303               && pReNative->Core.aVars[idxVar].enmKind < kIemNativeVarKind_End);
     6304        pReNative->Core.aVars[idxVar].fRegAcquired = true;
    62886305        return idxReg;
    62896306    }
     
    63216338        idxReg = g_aidxIemNativeCallRegs[uArgNo];
    63226339        iemNativeRegClearGstRegShadowing(pReNative, idxReg, *poff);
    6323         Log11(("iemNativeVarAllocRegister: idxVar=%u idxReg=%u (matching arg %u)\n", idxVar, idxReg, uArgNo));
     6340        Log11(("iemNativeVarRegisterAcquire: idxVar=%u idxReg=%u (matching arg %u)\n", idxVar, idxReg, uArgNo));
    63246341    }
    63256342    else
     
    63376354            Assert(pReNative->Core.aHstRegs[idxReg].fGstRegShadows == 0);
    63386355            Assert(!(pReNative->Core.bmHstRegsWithGstShadow & RT_BIT_32(idxReg)));
    6339             Log11(("iemNativeVarAllocRegister: idxVar=%u idxReg=%u (uArgNo=%u)\n", idxVar, idxReg, uArgNo));
     6356            Log11(("iemNativeVarRegisterAcquire: idxVar=%u idxReg=%u (uArgNo=%u)\n", idxVar, idxReg, uArgNo));
    63406357        }
    63416358        else
     
    63446361                                               IEMNATIVE_HST_GREG_MASK & ~IEMNATIVE_REG_FIXED_MASK & fNotArgsMask);
    63456362            AssertStmt(idxReg != UINT8_MAX, IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_REG_ALLOCATOR_NO_FREE_VAR));
    6346             Log11(("iemNativeVarAllocRegister: idxVar=%u idxReg=%u (slow, uArgNo=%u)\n", idxVar, idxReg, uArgNo));
     6363            Log11(("iemNativeVarRegisterAcquire: idxVar=%u idxReg=%u (slow, uArgNo=%u)\n", idxVar, idxReg, uArgNo));
    63476364        }
    63486365    }
     
    63726389        AssertStmt(!fInitialized, IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_NOT_INITIALIZED));
    63736390    }
     6391    pReNative->Core.aVars[idxVar].fRegAcquired = true;
    63746392    return idxReg;
    63756393}
     
    63976415 */
    63986416DECL_HIDDEN_THROW(uint8_t)
    6399 iemNativeVarAllocRegisterForGuestReg(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, IEMNATIVEGSTREG enmGstReg, uint32_t *poff)
     6417iemNativeVarRegisterAcquireForGuestReg(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, IEMNATIVEGSTREG enmGstReg, uint32_t *poff)
    64006418{
    64016419    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
     6420    Assert(!pReNative->Core.aVars[idxVar].fRegAcquired);
    64026421    AssertMsgStmt(   pReNative->Core.aVars[idxVar].cbVar <= 8
    64036422                  && (   pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Immediate
     
    64156434     * ensure we get a register suitable for the intended argument number.
    64166435     */
    6417     AssertStmt(pReNative->Core.aVars[idxVar].uArgNo == UINT8_MAX, iemNativeVarAllocRegister(pReNative, idxVar, poff));
     6436    AssertStmt(pReNative->Core.aVars[idxVar].uArgNo == UINT8_MAX, iemNativeVarRegisterAcquire(pReNative, idxVar, poff));
    64186437
    64196438    /*
     
    64286447            uint8_t const idxRegOld = pReNative->Core.aidxGstRegShadows[enmGstReg];
    64296448            iemNativeRegTransferGstRegShadowing(pReNative, idxRegOld, idxReg, enmGstReg, *poff);
    6430             Log12(("iemNativeVarAllocRegisterForGuestReg: Moved %s for guest %s into %s for full write\n",
     6449            Log12(("iemNativeVarRegisterAcquireForGuestReg: Moved %s for guest %s into %s for full write\n",
    64316450                   g_apszIemNativeHstRegNames[idxRegOld], g_aGstShadowInfo[enmGstReg].pszName, g_apszIemNativeHstRegNames[idxReg]));
    64326451        }
     
    64346453        {
    64356454            iemNativeRegMarkAsGstRegShadow(pReNative, idxReg, enmGstReg, *poff);
    6436             Log12(("iemNativeVarAllocRegisterForGuestReg: Marking %s as copy of guest %s (full write)\n",
     6455            Log12(("iemNativeVarRegisterAcquireForGuestReg: Marking %s as copy of guest %s (full write)\n",
    64376456                   g_apszIemNativeHstRegNames[idxReg], g_aGstShadowInfo[enmGstReg].pszName));
    64386457        }
    64396458        /** @todo figure this one out. We need some way of making sure the register isn't
    64406459         * modified after this point, just in case we start writing crappy MC code. */
    6441         pReNative->Core.aVars[idxVar].enmGstReg = enmGstReg;
     6460        pReNative->Core.aVars[idxVar].enmGstReg    = enmGstReg;
     6461        pReNative->Core.aVars[idxVar].fRegAcquired = true;
    64426462        return idxReg;
    64436463    }
     
    64836503    }
    64846504
     6505    pReNative->Core.aVars[idxVar].fRegAcquired = true;
    64856506    return idxReg;
    64866507}
     
    65056526 * @throws  VERR_IEM_VAR_IPE_10, VERR_IEM_VAR_IPE_11
    65066527 */
    6507 DECL_INLINE_THROW(uint8_t) iemNativeVarSetRegister(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint8_t idxReg, uint32_t off)
     6528DECL_INLINE_THROW(uint8_t) iemNativeVarRegisterSet(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar, uint8_t idxReg, uint32_t off)
    65086529{
    65096530    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
     6531    Assert(!pReNative->Core.aVars[idxVar].fRegAcquired);
    65106532    Assert(idxReg < RT_ELEMENTS(pReNative->Core.aHstRegs));
    65116533    AssertStmt(pReNative->Core.aVars[idxVar].idxReg == UINT8_MAX, IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_IPE_10));
     
    65186540    pReNative->Core.aVars[idxVar].idxReg = idxReg;
    65196541
     6542    return idxReg;
     6543}
     6544
     6545
     6546/**
     6547 * A convenient helper function.
     6548 */
     6549DECL_INLINE_THROW(uint8_t) iemNativeVarRegisterSetAndAcquire(PIEMRECOMPILERSTATE pReNative, uint8_t idxVar,
     6550                                                             uint8_t idxReg, uint32_t *poff)
     6551{
     6552    idxReg = iemNativeVarRegisterSet(pReNative, idxVar, idxReg, *poff);
     6553    pReNative->Core.aVars[idxVar].fRegAcquired = true;
    65206554    return idxReg;
    65216555}
     
    66946728         *        variable passed to IEM_MC_ASSIGN_TO_SMALLER is not used after the
    66956729         *        statement.   Then we could just transfer the register assignments. */
    6696         uint8_t const idxRegDst = iemNativeVarAllocRegister(pReNative, idxVarDst, &off);
    6697         uint8_t const idxRegSrc = iemNativeVarAllocRegister(pReNative, idxVarSrc, &off);
     6730        uint8_t const idxRegDst = iemNativeVarRegisterAcquire(pReNative, idxVarDst, &off);
     6731        uint8_t const idxRegSrc = iemNativeVarRegisterAcquire(pReNative, idxVarSrc, &off);
    66986732        switch (pReNative->Core.aVars[idxVarDst].cbVar)
    66996733        {
     
    67066740            default: AssertFailed(); break;
    67076741        }
     6742        iemNativeVarRegisterRelease(pReNative, idxVarSrc);
     6743        iemNativeVarRegisterRelease(pReNative, idxVarDst);
    67086744    }
    67096745    return off;
     
    72937329    {
    72947330pReNative->pInstrBuf[off++] = 0xcc; /** @todo test IEM_MC_CALL_AIMPL_3 and IEM_MC_CALL_AIMPL_4 return codes. */
    7295         iemNativeVarSetRegister(pReNative, idxVarRc, IEMNATIVE_CALL_RET_GREG, off);
     7331        iemNativeVarRegisterSet(pReNative, idxVarRc, IEMNATIVE_CALL_RET_GREG, off);
    72967332    }
    72977333
     
    74167452
    74177453    iemNativeVarSetKindToStack(pReNative, idxDstVar);
    7418     uint8_t const idxVarReg = iemNativeVarAllocRegister(pReNative, idxDstVar, &off);
     7454    uint8_t const idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxDstVar, &off);
    74197455
    74207456    /* The value is zero-extended to the full 64-bit host register width. */
     
    74247460        off = iemNativeEmitLoadGprFromGpr8Hi(pReNative, off, idxVarReg, idxGstFullReg);
    74257461
     7462    iemNativeVarRegisterRelease(pReNative, idxDstVar);
    74267463    iemNativeRegFreeTmp(pReNative, idxGstFullReg);
    74277464    return off;
     
    74517488
    74527489    iemNativeVarSetKindToStack(pReNative, idxDstVar);
    7453     uint8_t const idxVarReg = iemNativeVarAllocRegister(pReNative, idxDstVar, &off);
     7490    uint8_t const idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxDstVar, &off);
    74547491
    74557492    if (iGRegEx < 16)
     
    74877524    }
    74887525
     7526    iemNativeVarRegisterRelease(pReNative, idxDstVar);
    74897527    iemNativeRegFreeTmp(pReNative, idxGstFullReg);
    74907528    return off;
     
    75217559
    75227560    iemNativeVarSetKindToStack(pReNative, idxDstVar);
    7523     uint8_t const idxVarReg = iemNativeVarAllocRegister(pReNative, idxDstVar, &off);
     7561    uint8_t const idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxDstVar, &off);
    75247562    off = iemNativeEmitLoadGprFromGpr16(pReNative, off, idxVarReg, idxGstFullReg);
     7563    iemNativeVarRegisterRelease(pReNative, idxDstVar);
    75257564
    75267565    iemNativeRegFreeTmp(pReNative, idxGstFullReg);
     
    75547593
    75557594    iemNativeVarSetKindToStack(pReNative, idxDstVar);
    7556     uint8_t const idxVarReg = iemNativeVarAllocRegister(pReNative, idxDstVar, &off);
     7595    uint8_t const idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxDstVar, &off);
    75577596    if (cbSignExtended == sizeof(uint32_t))
    75587597        off = iemNativeEmitLoadGpr32SignExtendedFromGpr16(pReNative, off, idxVarReg, idxGstFullReg);
     
    75627601        off = iemNativeEmitLoadGprSignExtendedFromGpr16(pReNative, off, idxVarReg, idxGstFullReg);
    75637602    }
     7603    iemNativeVarRegisterRelease(pReNative, idxDstVar);
    75647604
    75657605    iemNativeRegFreeTmp(pReNative, idxGstFullReg);
     
    75937633
    75947634    iemNativeVarSetKindToStack(pReNative, idxDstVar);
    7595     uint8_t const idxVarReg = iemNativeVarAllocRegister(pReNative, idxDstVar, &off);
     7635    uint8_t const idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxDstVar, &off);
    75967636    off = iemNativeEmitLoadGprFromGpr32(pReNative, off, idxVarReg, idxGstFullReg);
     7637    iemNativeVarRegisterRelease(pReNative, idxDstVar);
    75977638
    75987639    iemNativeRegFreeTmp(pReNative, idxGstFullReg);
     
    76237664
    76247665    iemNativeVarSetKindToStack(pReNative, idxDstVar);
    7625     uint8_t const idxVarReg = iemNativeVarAllocRegister(pReNative, idxDstVar, &off);
     7666    uint8_t const idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxDstVar, &off);
    76267667    off = iemNativeEmitLoadGprSignExtendedFromGpr32(pReNative, off, idxVarReg, idxGstFullReg);
     7668    iemNativeVarRegisterRelease(pReNative, idxDstVar);
    76277669
    76287670    iemNativeRegFreeTmp(pReNative, idxGstFullReg);
     
    76507692
    76517693    iemNativeVarSetKindToStack(pReNative, idxDstVar);
    7652     uint8_t const idxVarReg = iemNativeVarAllocRegister(pReNative, idxDstVar, &off);
     7694    uint8_t const idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxDstVar, &off);
    76537695    off = iemNativeEmitLoadGprFromGpr(pReNative, off, idxVarReg, idxGstFullReg);
    76547696    /** @todo name the register a shadow one already? */
     7697    iemNativeVarRegisterRelease(pReNative, idxDstVar);
    76557698
    76567699    iemNativeRegFreeTmp(pReNative, idxGstFullReg);
     
    77657808    uint8_t const idxGstTmpReg = iemNativeRegAllocTmpForGuestReg(pReNative, &off, IEMNATIVEGSTREG_GPR(iGRegEx & 15),
    77667809                                                                 kIemNativeGstRegUse_ForUpdate);
    7767     uint8_t const    idxVarReg = iemNativeVarAllocRegister(pReNative, idxValueVar, &off, true /*fInitialized*/);
     7810    uint8_t const    idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxValueVar, &off, true /*fInitialized*/);
    77687811
    77697812#ifdef RT_ARCH_AMD64
     
    78257868# error "Port me!"
    78267869#endif
    7827 
    78287870    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     7871
     7872    iemNativeVarRegisterRelease(pReNative, idxValueVar);
    78297873
    78307874    off = iemNativeEmitStoreGprToVCpuU64(pReNative, off, idxGstTmpReg, RT_UOFFSETOF_DYN(VMCPU, cpum.GstCtx.aGRegs[iGRegEx & 15]));
     
    79227966#elif defined(RT_ARCH_ARM64)
    79237967    /* bfi w1, w2, 0, 16 - moves bits 15:0 from idxVarReg to idxGstTmpReg bits 15:0. */
    7924     uint8_t const    idxVarReg   = iemNativeVarAllocRegister(pReNative, idxValueVar, &off, true /*fInitialized*/);
     7968    uint8_t const    idxVarReg   = iemNativeVarRegisterAcquire(pReNative, idxValueVar, &off, true /*fInitialized*/);
    79257969    uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1);
    79267970    pu32CodeBuf[off++] = Armv8A64MkInstrBfi(idxGstTmpReg, idxVarReg, 0, 16);
     7971    iemNativeVarRegisterRelease(pReNative, idxValueVar);
    79277972
    79287973#else
     
    79828027     * it to the CPUMCTX structure.
    79838028     */
    7984     uint8_t const idxVarReg = iemNativeVarAllocRegisterForGuestReg(pReNative, idxValueVar, IEMNATIVEGSTREG_GPR(iGReg), &off);
     8029    uint8_t const idxVarReg = iemNativeVarRegisterAcquireForGuestReg(pReNative, idxValueVar, IEMNATIVEGSTREG_GPR(iGReg), &off);
    79858030    off = iemNativeEmitStoreGprToVCpuU64(pReNative, off, idxVarReg, RT_UOFFSETOF_DYN(VMCPU, cpum.GstCtx.aGRegs[iGReg]));
    79868031#ifdef VBOX_STRICT
    79878032    off = iemNativeEmitTop32BitsClearCheck(pReNative, off, idxVarReg);
    79888033#endif
     8034    iemNativeVarRegisterRelease(pReNative, idxValueVar);
    79898035    return off;
    79908036}
     
    80358081     * it to the CPUMCTX structure.
    80368082     */
    8037     uint8_t const idxVarReg = iemNativeVarAllocRegisterForGuestReg(pReNative, idxValueVar, IEMNATIVEGSTREG_GPR(iGReg), &off);
     8083    uint8_t const idxVarReg = iemNativeVarRegisterAcquireForGuestReg(pReNative, idxValueVar, IEMNATIVEGSTREG_GPR(iGReg), &off);
    80388084    off = iemNativeEmitStoreGprToVCpuU64(pReNative, off, idxVarReg, RT_UOFFSETOF_DYN(VMCPU, cpum.GstCtx.aGRegs[iGReg]));
     8085    iemNativeVarRegisterRelease(pReNative, idxValueVar);
    80398086    return off;
    80408087}
     
    81848231    Assert(pReNative->Core.aVars[idxVarEFlags].cbVar == sizeof(uint32_t));
    81858232
    8186     uint8_t const idxReg = iemNativeVarAllocRegister(pReNative, idxVarEFlags, &off, false /*fInitialized*/);
     8233    uint8_t const idxReg = iemNativeVarRegisterAcquire(pReNative, idxVarEFlags, &off, false /*fInitialized*/);
    81878234    iemNativeRegClearAndMarkAsGstRegShadow(pReNative, idxReg, kIemNativeGstReg_EFlags, off);
    8188     return iemNativeEmitLoadGprFromVCpuU32(pReNative, off, idxReg, RT_UOFFSETOF(VMCPUCC, cpum.GstCtx.eflags));
     8235    off = iemNativeEmitLoadGprFromVCpuU32(pReNative, off, idxReg, RT_UOFFSETOF(VMCPUCC, cpum.GstCtx.eflags));
     8236    iemNativeVarRegisterRelease(pReNative, idxVarEFlags);
     8237    return off;
    81898238}
    81908239
     
    82008249    Assert(pReNative->Core.aVars[idxVarEFlags].cbVar == sizeof(uint32_t));
    82018250
    8202     uint8_t const idxReg = iemNativeVarAllocRegister(pReNative, idxVarEFlags, &off, true /*fInitialized*/);
     8251    uint8_t const idxReg = iemNativeVarRegisterAcquire(pReNative, idxVarEFlags, &off, true /*fInitialized*/);
    82038252
    82048253#ifdef VBOX_STRICT
     
    82138262
    82148263    iemNativeRegClearAndMarkAsGstRegShadow(pReNative, idxReg, kIemNativeGstReg_EFlags, off);
    8215     return iemNativeEmitStoreGprToVCpuU32(pReNative, off, idxReg, RT_UOFFSETOF_DYN(VMCPUCC, cpum.GstCtx.eflags));
     8264    off = iemNativeEmitStoreGprToVCpuU32(pReNative, off, idxReg, RT_UOFFSETOF_DYN(VMCPUCC, cpum.GstCtx.eflags));
     8265    iemNativeVarRegisterRelease(pReNative, idxVarEFlags);
     8266    return off;
    82168267}
    82178268
     
    84068457     * Now emit code that calculates: idxRegRet = (uint16_t)(u16EffAddr + idxGstRegBase [+ idxGstRegIndex])
    84078458     */
    8408     uint8_t const idxRegRet   = iemNativeVarAllocRegister(pReNative, idxVarRet, &off);
     8459    uint8_t const idxRegRet   = iemNativeVarRegisterAcquire(pReNative, idxVarRet, &off);
    84098460    uint8_t const idxRegBase  = iemNativeRegAllocTmpForGuestReg(pReNative, &off, IEMNATIVEGSTREG_GPR(idxGstRegBase),
    84108461                                                               kIemNativeGstRegUse_ReadOnly);
     
    85058556        iemNativeRegFreeTmp(pReNative, idxRegIndex);
    85068557    iemNativeRegFreeTmp(pReNative, idxRegBase);
     8558    iemNativeVarRegisterRelease(pReNative, idxVarRet);
    85078559    return off;
    85088560}
     
    86128664     * Now emit code that calculates: idxRegRet = (uint32_t)(u32EffAddr [+ idxGstRegBase] [+ (idxGstRegIndex << cShiftIndex)])
    86138665     */
    8614     uint8_t const idxRegRet   = iemNativeVarAllocRegister(pReNative, idxVarRet, &off);
     8666    uint8_t const idxRegRet   = iemNativeVarRegisterAcquire(pReNative, idxVarRet, &off);
    86158667    uint8_t       idxRegBase  = idxGstRegBase == UINT8_MAX ? UINT8_MAX
    86168668                              : iemNativeRegAllocTmpForGuestReg(pReNative, &off, IEMNATIVEGSTREG_GPR(idxGstRegBase),
     
    87658817    if (idxRegBase != UINT8_MAX)
    87668818        iemNativeRegFreeTmp(pReNative, idxRegBase);
     8819    iemNativeVarRegisterRelease(pReNative, idxVarRet);
    87678820    return off;
    87688821}
     
    88158868    if ((bRmEx & (X86_MODRM_MOD_MASK | X86_MODRM_RM_MASK)) == 5)
    88168869    {
    8817         uint8_t const idxRegRet = iemNativeVarAllocRegister(pReNative, idxVarRet, &off);
     8870        uint8_t const idxRegRet = iemNativeVarRegisterAcquire(pReNative, idxVarRet, &off);
    88188871        uint8_t const idxRegPc  = iemNativeRegAllocTmpForGuestReg(pReNative, &off, kIemNativeGstReg_Pc,
    88198872                                                                  kIemNativeGstRegUse_ReadOnly);
     
    88458898#endif
    88468899        iemNativeRegFreeTmp(pReNative, idxRegPc);
     8900        iemNativeVarRegisterRelease(pReNative, idxVarRet);
    88478901        return off;
    88488902    }
     
    89138967     *      idxRegRet = (uint32_t)(i64EffAddr [+ idxGstRegBase] [+ (idxGstRegIndex << cShiftIndex)])
    89148968     */
    8915     uint8_t const idxRegRet   = iemNativeVarAllocRegister(pReNative, idxVarRet, &off);
     8969    uint8_t const idxRegRet   = iemNativeVarRegisterAcquire(pReNative, idxVarRet, &off);
    89168970    uint8_t       idxRegBase  = idxGstRegBase == UINT8_MAX ? UINT8_MAX
    89178971                              : iemNativeRegAllocTmpForGuestReg(pReNative, &off, IEMNATIVEGSTREG_GPR(idxGstRegBase),
     
    90999153    if (idxRegBase != UINT8_MAX)
    91009154        iemNativeRegFreeTmp(pReNative, idxRegBase);
     9155    iemNativeVarRegisterRelease(pReNative, idxVarRet);
    91019156    return off;
    91029157}
     
    92679322    uint8_t  const idxRegValueFetch = enmOp == kIemNativeEmitMemOp_Store ? UINT8_MAX /* special case value storing below */
    92689323                                    : !(pReNative->Core.bmHstRegs & RT_BIT_32(IEMNATIVE_CALL_RET_GREG))
    9269                                     ? iemNativeVarSetRegister(pReNative, idxVarValue, IEMNATIVE_CALL_RET_GREG, off)
    9270                                     : iemNativeVarAllocRegister(pReNative, idxVarValue, &off);
     9324                                    ? iemNativeVarRegisterSetAndAcquire(pReNative, idxVarValue, IEMNATIVE_CALL_RET_GREG, &off)
     9325                                    : iemNativeVarRegisterAcquire(pReNative, idxVarValue, &off);
    92719326
    92729327    /*
     
    93639418        if (idxRegValueFetch != IEMNATIVE_CALL_RET_GREG)
    93649419            off = iemNativeEmitLoadGprFromGpr(pReNative, off, idxRegValueFetch, IEMNATIVE_CALL_RET_GREG);
     9420        iemNativeVarRegisterRelease(pReNative, idxVarValue);
    93659421    }
    93669422
     
    1000210058    uint32_t const idxLabelTlbDone  = iemNativeLabelCreate(pReNative, kIemNativeLabelType_TlbDone, UINT32_MAX, uTlbSeqNo);
    1000310059    uint8_t  const idxRegMemResult  = !(pReNative->Core.bmHstRegs & RT_BIT_32(IEMNATIVE_CALL_RET_GREG))
    10004                                     ? iemNativeVarSetRegister(pReNative, idxVarMem, IEMNATIVE_CALL_RET_GREG, off)
    10005                                     : iemNativeVarAllocRegister(pReNative, idxVarMem, &off);
     10060                                    ? iemNativeVarRegisterSetAndAcquire(pReNative, idxVarMem, IEMNATIVE_CALL_RET_GREG, &off)
     10061                                    : iemNativeVarRegisterAcquire(pReNative, idxVarMem, &off);
    1000610062
    1000710063    /*
     
    1005010106    if (idxRegMemResult != IEMNATIVE_CALL_RET_GREG)
    1005110107        off = iemNativeEmitLoadGprFromGpr(pReNative, off, idxRegMemResult, IEMNATIVE_CALL_RET_GREG);
     10108    iemNativeVarRegisterRelease(pReNative, idxVarMem);
    1005210109
    1005310110    iemNativeLabelDefine(pReNative, idxLabelTlbDone, off);
     
    1012810185#endif
    1012910186    {
    10130         uint8_t const idxVarReg = iemNativeVarAllocRegister(pReNative, idxVarUnmapInfo, &off);
     10187        uint8_t const idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxVarUnmapInfo, &off);
    1013110188        off = iemNativeEmitTestAnyBitsInGpr8(pReNative, off, idxVarReg, 0xff);
     10189        iemNativeVarRegisterRelease(pReNative, idxVarUnmapInfo);
    1013210190    }
    1013310191    uint32_t const offJmpFixup = off;
  • trunk/src/VBox/VMM/include/IEMN8veRecompiler.h

    r102527 r102558  
    477477     * @todo not sure what this really is for...   */
    478478    IEMNATIVEGSTREG     enmGstReg;
    479     uint8_t             bAlign;
     479    /** Set if the registered is currently used exclusively, false if the
     480     *  variable is idle and the register can be grabbed. */
     481    bool                fRegAcquired;
    480482
    481483    union
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