VirtualBox

Changeset 102767 in vbox for trunk/src


Ignore:
Timestamp:
Jan 4, 2024 9:20:02 PM (13 months ago)
Author:
vboxsync
Message:

VMM/IEM: Reworking native translation of IEM_MC_*PUSH* in prep for doing TLB lookups. bugreg:10371

File:
1 edited

Legend:

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

    r102766 r102767  
    1145011450                                 (uintptr_t)iemNativeHlpStackFlatStoreU64, pCallEntry->idxInstr)
    1145111451
     11452
     11453DECL_FORCE_INLINE_THROW(uint32_t)
     11454iemNativeEmitStackPushUse16Sp(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t idxRegRsp, uint8_t idxRegEffSp, uint8_t cbMem)
     11455{
     11456    /* Use16BitSp: */
     11457#ifdef RT_ARCH_AMD64
     11458    off = iemNativeEmitSubGpr16ImmEx(pCodeBuf, off, idxRegRsp, cbMem); /* ASSUMES this does NOT modify bits [63:16]! */
     11459    off = iemNativeEmitLoadGprFromGpr16Ex(pCodeBuf, off, idxRegEffSp, idxRegRsp);
     11460#else
     11461    /* sub regeff, regrsp, #cbMem */
     11462    pCodeBuf[off++] = Armv8A64MkInstrSubUImm12(idxRegEffSp, idxRegRsp, cbMem, false /*f64Bit*/);
     11463    /* and regeff, regeff, #0xffff */
     11464    Assert(Armv8A64ConvertImmRImmS2Mask32(15, 0) == 0xffff);
     11465    pCodeBuf[off++] = Armv8A64MkInstrAndImm(idxRegEffSp, idxRegEffSp, 15, 0,  false /*f64Bit*/);
     11466    /* bfi regrsp, regeff, 0, 16 - moves bits 7:16 from idxVarReg to idxGstTmpReg bits 16:0. */
     11467    pCodeBuf[off++] = Armv8A64MkInstrBfi(idxRegRsp, idxRegEffSp, 15, 0, false /*f64Bit*/);
     11468#endif
     11469    return off;
     11470}
     11471
     11472
     11473DECL_FORCE_INLINE(uint32_t)
     11474iemNativeEmitStackPushUse32Sp(PIEMNATIVEINSTR pCodeBuf, uint32_t off, uint8_t idxRegRsp, uint8_t idxRegEffSp, uint8_t cbMem)
     11475{
     11476    /* Use32BitSp: */
     11477    off = iemNativeEmitSubGpr32ImmEx(pCodeBuf, off, idxRegRsp, cbMem);
     11478    off = iemNativeEmitLoadGprFromGpr32Ex(pCodeBuf, off, idxRegEffSp, idxRegRsp);
     11479    return off;
     11480}
     11481
     11482
    1145211483/** IEM_MC[|_FLAT32|_FLAT64]_PUSH_U16/32/32_SREG/64 */
    1145311484DECL_INLINE_THROW(uint32_t)
     
    1149911530
    1150011531    /*
    11501      * Define labels and allocate the result register (trying for the return
    11502      * register if we can).
    11503      */
    11504     uint16_t const uTlbSeqNo        = pReNative->uTlbSeqNo++;
    11505     uint32_t const idxLabelTlbMiss  = iemNativeLabelCreate(pReNative, kIemNativeLabelType_TlbMiss, UINT32_MAX, uTlbSeqNo);
    11506     uint32_t const idxLabelTlbDone  = iemNativeLabelCreate(pReNative, kIemNativeLabelType_TlbDone, UINT32_MAX, uTlbSeqNo);
    11507 
    11508     /*
    1150911532     * First we calculate the new RSP and the effective stack pointer value.
    1151011533     * For 64-bit mode and flat 32-bit these two are the same.
     
    1151611539                                                                kIemNativeGstRegUse_ForUpdate, true /*fNoVolatileRegs*/);
    1151711540    uint8_t const idxRegEffSp = cBitsFlat != 0 ? idxRegRsp : iemNativeRegAllocTmp(pReNative, &off);
     11541    uint32_t      offFixupJumpToUseOtherBitSp = UINT32_MAX;
    1151811542    if (cBitsFlat != 0)
    1151911543    {
     
    1153211556                                                                     kIemNativeGstRegUse_ReadOnly);
    1153311557#ifdef RT_ARCH_AMD64
    11534         PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 48);
     11558        PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 32);
    1153511559#else
    11536         PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 20);
     11560        PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 10);
    1153711561#endif
    1153811562        off = iemNativeEmitTestAnyBitsInGpr32Ex(pCodeBuf, off, idxRegSsAttr, X86DESCATTR_D);
    1153911563        iemNativeRegFreeTmp(pReNative, idxRegSsAttr);
    11540         uint32_t const offFixupJumpTo16BitSp = off;
    11541         off = iemNativeEmitJccToFixedEx(pCodeBuf, off, off /*8-bit suffices*/, kIemNativeInstrCond_e); /* jump if zero */
    11542         /* have_32bit_sp: */
    11543         off = iemNativeEmitSubGpr32ImmEx(pCodeBuf, off, idxRegRsp, cbMem);
    11544         off = iemNativeEmitLoadGprFromGpr32Ex(pCodeBuf, off, idxRegEffSp, idxRegRsp);
    11545         uint32_t const offFixupJumpToEnd = off;
    11546         off = iemNativeEmitJmpToFixedEx(pCodeBuf, off, off /*8-bit suffices*/);
    11547 
    11548         /** @todo Put snippet before TlbMiss. */
    11549         /* have_16bit_sp: */
    11550         iemNativeFixupFixedJump(pReNative, offFixupJumpTo16BitSp, off);
     11564        offFixupJumpToUseOtherBitSp = off;
     11565        if ((pReNative->fExec & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT)
     11566        {
     11567            off = iemNativeEmitJccToFixedEx(pCodeBuf, off, off /*8-bit suffices*/, kIemNativeInstrCond_e); /* jump if zero */
     11568            off = iemNativeEmitStackPushUse32Sp(pCodeBuf, off, idxRegRsp, idxRegEffSp, cbMem);
     11569        }
     11570        else
     11571        {
     11572            off = iemNativeEmitJccToFixedEx(pCodeBuf, off, off /*8-bit suffices*/, kIemNativeInstrCond_ne); /* jump if not zero */
     11573            off = iemNativeEmitStackPushUse16Sp(pCodeBuf, off, idxRegRsp, idxRegEffSp, cbMem);
     11574        }
     11575        IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     11576    }
     11577    /* SpUpdateEnd: */
     11578    uint32_t const offLabelSpUpdateEnd = off;
     11579
     11580    /*
     11581     * Okay, now prepare for TLB lookup and jump to code (or the TlbMiss if
     11582     * we're skipping lookup).
     11583     */
     11584    //IEMNATIVEEMITTLBSTATE const TlbState(pReNative, &off, idxVarGCPtrMem, iSegReg, cbMem);
     11585    uint16_t const uTlbSeqNo         = pReNative->uTlbSeqNo++;
     11586    uint32_t const idxLabelTlbMiss   = iemNativeLabelCreate(pReNative, kIemNativeLabelType_TlbMiss, UINT32_MAX, uTlbSeqNo);
     11587    uint32_t const idxLabelTlbDone   = iemNativeLabelCreate(pReNative, kIemNativeLabelType_TlbDone, UINT32_MAX, uTlbSeqNo);
     11588    uint32_t const idxLabelTlbLookup = !true//!TlbState.fSkip
     11589                                     ? iemNativeLabelCreate(pReNative, kIemNativeLabelType_TlbLookup, UINT32_MAX, uTlbSeqNo)
     11590                                     : UINT32_MAX;
     11591
     11592    if (!true)//TlbState.fSkip)
     11593        off = iemNativeEmitJmpToLabel(pReNative, off, idxLabelTlbLookup); /** @todo short jump */
     11594    else
     11595        off = iemNativeEmitJmpToLabel(pReNative, off, idxLabelTlbMiss); /** @todo short jump */
     11596
     11597    /*
     11598     * Use16BitSp:
     11599     */
     11600    if (cBitsFlat == 0)
     11601    {
    1155111602#ifdef RT_ARCH_AMD64
    11552         off = iemNativeEmitSubGpr16ImmEx(pCodeBuf, off, idxRegRsp, cbMem); /* ASSUMES this does NOT modify bits [63:16]! */
    11553         off = iemNativeEmitLoadGprFromGpr16Ex(pCodeBuf, off, idxRegEffSp, idxRegRsp);
     11603        PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 32);
    1155411604#else
    11555         /* sub regeff, regrsp, #cbMem */
    11556         pCodeBuf[off++] = Armv8A64MkInstrSubUImm12(idxRegEffSp, idxRegRsp, cbMem, false /*f64Bit*/);
    11557         /* and regeff, regeff, #0xffff */
    11558         Assert(Armv8A64ConvertImmRImmS2Mask32(15, 0) == 0xffff);
    11559         pCodeBuf[off++] = Armv8A64MkInstrAndImm(idxRegEffSp, idxRegEffSp, 15, 0,  false /*f64Bit*/);
    11560         /* bfi regrsp, regeff, 0, 16 - moves bits 7:16 from idxVarReg to idxGstTmpReg bits 16:0. */
    11561         pCodeBuf[off++] = Armv8A64MkInstrBfi(idxRegRsp, idxRegEffSp, 15, 0, false /*f64Bit*/);
    11562 #endif
    11563         /* sp_update_end: */
    11564         iemNativeFixupFixedJump(pReNative, offFixupJumpToEnd, off);
     11605        PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 10);
     11606#endif
     11607        iemNativeFixupFixedJump(pReNative, offFixupJumpToUseOtherBitSp, off);
     11608        if ((pReNative->fExec & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT)
     11609            off = iemNativeEmitStackPushUse16Sp(pCodeBuf, off, idxRegRsp, idxRegEffSp, cbMem);
     11610        else
     11611            off = iemNativeEmitStackPushUse32Sp(pCodeBuf, off, idxRegRsp, idxRegEffSp, cbMem);
     11612        off = iemNativeEmitJmpToFixedEx(pCodeBuf, off, offLabelSpUpdateEnd);
    1156511613        IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
    1156611614    }
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