VirtualBox

Changeset 102444 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Dec 3, 2023 9:18:06 PM (16 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
160587
Message:

VMM/IEM: IEM_MC_STORE_GREG_U8_THREADED. bugref:10371

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8vePython.py

    r102443 r102444  
    9090    'IEM_MC_REL_JMP_S32_AND_FINISH_THREADED_PC64_WITH_FLAGS':    (None, True,  True,  ),
    9191
    92     'IEM_MC_STORE_GREG_U8_THREADED':                             (None, True,  False, ),
     92    'IEM_MC_STORE_GREG_U8_THREADED':                             (None, True,  True, ),
    9393    'IEM_MC_STORE_GREG_U8_CONST_THREADED':                       (None, True,  True,  ),
    94     'IEM_MC_FETCH_GREG_U8_THREADED':                             (None, False, True, ),
     94    'IEM_MC_FETCH_GREG_U8_THREADED':                             (None, False, True,  ),
    9595    'IEM_MC_FETCH_GREG_U8_SX_U16_THREADED':                      (None, False, False, ),
    9696    'IEM_MC_FETCH_GREG_U8_SX_U32_THREADED':                      (None, False, False, ),
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp

    r102443 r102444  
    74227422    return off;
    74237423}
     7424
     7425
     7426#define IEM_MC_STORE_GREG_U8_THREADED(a_iGRegEx, a_u8Value) \
     7427    off = iemNativeEmitStoreGregU8(pReNative, off, a_iGRegEx, a_u8Value)
     7428
     7429/** Emits code for IEM_MC_STORE_GREG_U8_THREADED. */
     7430DECL_INLINE_THROW(uint32_t)
     7431iemNativeEmitStoreGregU8(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t iGRegEx, uint8_t idxValueVar)
     7432{
     7433    Assert(iGRegEx < 20);
     7434    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxValueVar);
     7435
     7436    /*
     7437     * If it's a constant value (unlikely) we treat this as a
     7438     * IEM_MC_STORE_GREG_U8_CONST statement.
     7439     */
     7440    if (pReNative->Core.aVars[idxValueVar].enmKind == kIemNativeVarKind_Stack)
     7441    { /* likely */ }
     7442    else
     7443    {
     7444        AssertStmt(pReNative->Core.aVars[idxValueVar].enmKind != kIemNativeVarKind_Immediate,
     7445                   IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND));
     7446        return iemNativeEmitStoreGregU8Const(pReNative, off, iGRegEx, (uint8_t)pReNative->Core.aVars[idxValueVar].u.uValue);
     7447    }
     7448
     7449    uint8_t const idxGstTmpReg = iemNativeRegAllocTmpForGuestReg(pReNative, &off, IEMNATIVEGSTREG_GPR(iGRegEx & 15),
     7450                                                                 kIemNativeGstRegUse_ForUpdate);
     7451    uint8_t const    idxVarReg = iemNativeVarAllocRegister(pReNative, idxValueVar, &off, true /*fInitialized*/);
     7452
     7453#ifdef RT_ARCH_AMD64
     7454    /* To the lowest byte of the register: mov reg8, reg8(r/m) */
     7455    if (iGRegEx < 16)
     7456    {
     7457        uint8_t * const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 3);
     7458        if (idxGstTmpReg >= 8 || idxVarReg >= 8)
     7459            pbCodeBuf[off++] = (idxGstTmpReg >= 8 ? X86_OP_REX_R : 0) | (idxVarReg >= 8 ? X86_OP_REX_B : 0);
     7460        else if (idxGstTmpReg >= 4)
     7461            pbCodeBuf[off++] = X86_OP_REX;
     7462        pbCodeBuf[off++] = 0x8a;
     7463        pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, idxGstTmpReg & 7, idxVarReg & 7);
     7464    }
     7465    /* Otherwise it's to ah, ch, dh or bh from al, cl, dl or bl: use mov r8, r8 if we can, otherwise, we rotate. */
     7466    else if (idxGstTmpReg < 4 && idxVarReg < 4)
     7467    {
     7468        /** @todo test this.   */
     7469        uint8_t * const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 2+1);
     7470        pbCodeBuf[off++] = 0x8a;
     7471        pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, idxGstTmpReg + 4, idxVarReg);
     7472    }
     7473    else
     7474    {
     7475        uint8_t * const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 15);
     7476
     7477        /* ror reg64, 8 */
     7478        pbCodeBuf[off++] = X86_OP_REX_W | (idxGstTmpReg < 8 ? 0 : X86_OP_REX_B);
     7479        pbCodeBuf[off++] = 0xc1;
     7480        pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 1, idxGstTmpReg & 7);
     7481        pbCodeBuf[off++] = 8;
     7482
     7483        /* mov reg8, reg8(r/m)  */
     7484        if (idxGstTmpReg >= 8 || idxVarReg >= 8)
     7485            pbCodeBuf[off++] = (idxGstTmpReg >= 8 ? X86_OP_REX_R : 0) | (idxVarReg >= 8 ? X86_OP_REX_B : 0);
     7486        else if (idxGstTmpReg >= 4)
     7487            pbCodeBuf[off++] = X86_OP_REX;
     7488        pbCodeBuf[off++] = 0x8a;
     7489        pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, idxGstTmpReg & 7, idxVarReg & 7);
     7490
     7491        /* rol reg64, 8 */
     7492        pbCodeBuf[off++] = X86_OP_REX_W | (idxGstTmpReg < 8 ? 0 : X86_OP_REX_B);
     7493        pbCodeBuf[off++] = 0xc1;
     7494        pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 0, idxGstTmpReg & 7);
     7495        pbCodeBuf[off++] = 8;
     7496    }
     7497
     7498#elif defined(RT_ARCH_ARM64)
     7499    /* bfi w1, w2, 0, 8 - moves bits 7:0 from idxVarReg to idxGstTmpReg bits 7:0.
     7500            or
     7501       bfi w1, w2, 8, 8 - moves bits 7:0 from idxVarReg to idxGstTmpReg bits 15:8. */
     7502    uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1);
     7503    if (iGRegEx < 16)
     7504        pu32CodeBuf[off++] = Armv8A64MkInstrBfi(idxGstTmpReg, idxVarReg, 0, 8);
     7505    else
     7506        pu32CodeBuf[off++] = Armv8A64MkInstrBfi(idxGstTmpReg, idxVarReg, 8, 8);
     7507
     7508#else
     7509# error "Port me!"
     7510#endif
     7511
     7512    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
     7513
     7514    off = iemNativeEmitStoreGprToVCpuU64(pReNative, off, idxGstTmpReg, RT_UOFFSETOF_DYN(VMCPU, cpum.GstCtx.aGRegs[iGRegEx & 15]));
     7515    iemNativeRegFreeTmp(pReNative, idxGstTmpReg);
     7516    return off;
     7517}
     7518
    74247519
    74257520
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette