VirtualBox

Changeset 103592 in vbox


Ignore:
Timestamp:
Feb 27, 2024 5:19:48 PM (9 months ago)
Author:
vboxsync
Message:

VMM/IEM: Native translation of IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT() body (untested due to no instruction still being re-compilable), bugref:10371

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

Legend:

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

    r103588 r103592  
    42164216    return iemRaiseXcptOrInt(pVCpu, 0, X86_XCPT_UD, IEM_XCPT_FLAGS_T_CPU_XCPT, 0, 0);
    42174217}
     4218
     4219
     4220#ifdef IEM_WITH_SETJMP
     4221/** \#UD - 06.  */
     4222DECL_NO_RETURN(void) iemRaiseUndefinedOpcodeJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP
     4223{
     4224    iemRaiseXcptOrIntJmp(pVCpu, 0, X86_XCPT_UD, IEM_XCPT_FLAGS_T_CPU_XCPT, 0, 0);
     4225}
     4226#endif
    42184227
    42194228
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstPython.py

    r103590 r103592  
    31113111    'IEM_MC_MAYBE_RAISE_NON_CANONICAL_ADDR_GP0':                 (McBlock.parseMcGeneric,           True,  True,  False, ),
    31123112    'IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT':             (McBlock.parseMcGeneric,           True,  True,  False, ),
    3113     'IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT':                       (McBlock.parseMcGeneric,           True,  True,  False, ),
     3113    'IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT':                       (McBlock.parseMcGeneric,           True,  True,  True, ),
    31143114    'IEM_MC_MAYBE_RAISE_WAIT_DEVICE_NOT_AVAILABLE':              (McBlock.parseMcGeneric,           True,  True,  False, ),
    31153115    'IEM_MC_MEM_COMMIT_AND_UNMAP_ATOMIC':                        (McBlock.parseMcGeneric,           True,  True,  True,  ),
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstTwoByte0f.cpp.h

    r103590 r103592  
    33893389                                    iemCImpl_mov_Cd_Rd, iCrReg, IEM_GET_MODRM_RM(pVCpu, bRm));
    33903390    else
    3391         IEM_MC_DEFER_TO_CIMPL_2_RET(IEM_CIMPL_F_MODE | IEM_CIMPL_F_VMEXIT, RT_BIT_64(kIemNativeGstReg_Cr0),
     3391        IEM_MC_DEFER_TO_CIMPL_2_RET(IEM_CIMPL_F_MODE | IEM_CIMPL_F_VMEXIT, RT_BIT_64(kIemNativeGstReg_Cr0) | RT_BIT_64(kIemNativeGstReg_Cr4),
    33923392                                    iemCImpl_mov_Cd_Rd, iCrReg, IEM_GET_MODRM_RM(pVCpu, bRm));
    33933393}
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp

    r103591 r103592  
    16101610
    16111611/**
     1612 * Used by TB code when it wants to raise a \#UD.
     1613 */
     1614IEM_DECL_NATIVE_HLP_DEF(int, iemNativeHlpExecRaiseUd,(PVMCPUCC pVCpu))
     1615{
     1616    iemRaiseUndefinedOpcodeJmp(pVCpu);
     1617#ifndef _MSC_VER
     1618    return VINF_IEM_RAISED_XCPT; /* not reached */
     1619#endif
     1620}
     1621
     1622
     1623/**
    16121624 * Used by TB code when detecting opcode changes.
    16131625 * @see iemThreadeFuncWorkerObsoleteTb
     
    29182930    pReNative->Core.u64ArgVars             = UINT64_MAX;
    29192931
    2920     AssertCompile(RT_ELEMENTS(pReNative->aidxUniqueLabels) == 10);
     2932    AssertCompile(RT_ELEMENTS(pReNative->aidxUniqueLabels) == 11);
    29212933    pReNative->aidxUniqueLabels[0]         = UINT32_MAX;
    29222934    pReNative->aidxUniqueLabels[1]         = UINT32_MAX;
     
    29292941    pReNative->aidxUniqueLabels[8]         = UINT32_MAX;
    29302942    pReNative->aidxUniqueLabels[9]         = UINT32_MAX;
     2943    pReNative->aidxUniqueLabels[10]        = UINT32_MAX;
    29312944
    29322945    /* Full host register reinit: */
     
    35253538    /* [kIemNativeGstReg_SegSelFirst + 4] = */          { CPUMCTX_OFF_AND_SIZE(aSRegs[4].Sel),      "fs", },
    35263539    /* [kIemNativeGstReg_SegSelFirst + 5] = */          { CPUMCTX_OFF_AND_SIZE(aSRegs[5].Sel),      "gs", },
     3540    /* [kIemNativeGstReg_Cr4] = */                      { CPUMCTX_OFF_AND_SIZE(cr4),                "cr4", },
    35273541    /* [kIemNativeGstReg_EFlags] = */                   { CPUMCTX_OFF_AND_SIZE(eflags),             "eflags", },
    35283542#undef CPUMCTX_OFF_AND_SIZE
     
    58025816
    58035817/**
     5818 * Emits the code at the RaiseUd label.
     5819 */
     5820static uint32_t iemNativeEmitRaiseUd(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint32_t idxReturnLabel)
     5821{
     5822    uint32_t const idxLabel = iemNativeLabelFind(pReNative, kIemNativeLabelType_RaiseNm);
     5823    if (idxLabel != UINT32_MAX)
     5824    {
     5825        iemNativeLabelDefine(pReNative, idxLabel, off);
     5826
     5827        /* iemNativeHlpExecRaiseUd(PVMCPUCC pVCpu) */
     5828        off = iemNativeEmitLoadGprFromGpr(pReNative, off, IEMNATIVE_CALL_ARG0_GREG, IEMNATIVE_REG_FIXED_PVMCPU);
     5829        off = iemNativeEmitCallImm(pReNative, off, (uintptr_t)iemNativeHlpExecRaiseUd);
     5830
     5831        /* jump back to the return sequence. */
     5832        off = iemNativeEmitJmpToLabel(pReNative, off, idxReturnLabel);
     5833    }
     5834    return off;
     5835}
     5836
     5837
     5838/**
    58045839 * Emits the code at the ReturnWithFlags label (returns
    58055840 * VINF_IEM_REEXEC_FINISH_WITH_FLAGS).
     
    66636698    /* Free but don't flush the CR0 register. */
    66646699    iemNativeRegFreeTmp(pReNative, idxCr0Reg);
     6700
     6701    return off;
     6702}
     6703
     6704
     6705#define IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT() \
     6706    off = iemNativeEmitMaybeRaiseSseRelatedXcpt(pReNative, off, pCallEntry->idxInstr)
     6707
     6708/**
     6709 * Emits code to check if a SSE exception (either \#UD or \#NM) should be raised.
     6710 *
     6711 * @returns New code buffer offset, UINT32_MAX on failure.
     6712 * @param   pReNative       The native recompile state.
     6713 * @param   off             The code buffer offset.
     6714 * @param   idxInstr        The current instruction.
     6715 */
     6716DECL_INLINE_THROW(uint32_t)
     6717iemNativeEmitMaybeRaiseSseRelatedXcpt(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t idxInstr)
     6718{
     6719    /*
     6720     * Make sure we don't have any outstanding guest register writes as we may
     6721     * raise an \#UD or \#NM and all guest register must be up to date in CPUMCTX.
     6722     *
     6723     * @todo r=aeichner Can we postpone this to the RaiseNm/RaiseUd path?
     6724     */
     6725    off = iemNativeRegFlushPendingWrites(pReNative, off);
     6726
     6727#ifdef IEMNATIVE_WITH_INSTRUCTION_COUNTING
     6728    off = iemNativeEmitStoreImmToVCpuU8(pReNative, off, idxInstr, RT_UOFFSETOF(VMCPUCC, iem.s.idxTbCurInstr));
     6729#else
     6730    RT_NOREF(idxInstr);
     6731#endif
     6732
     6733    /* Allocate a temporary CR0 and CR4 register. */
     6734    uint8_t const idxCr0Reg       = iemNativeRegAllocTmpForGuestReg(pReNative, &off, kIemNativeGstReg_Cr0, kIemNativeGstRegUse_ReadOnly);
     6735    uint8_t const idxCr4Reg       = iemNativeRegAllocTmpForGuestReg(pReNative, &off, kIemNativeGstReg_Cr4, kIemNativeGstRegUse_ReadOnly);
     6736    uint8_t const idxLabelRaiseNm = iemNativeLabelCreate(pReNative, kIemNativeLabelType_RaiseNm);
     6737    uint8_t const idxLabelRaiseUd = iemNativeLabelCreate(pReNative, kIemNativeLabelType_RaiseUd);
     6738
     6739    /** @todo r=aeichner Optimize this more later to have less compares and branches,
     6740     *                   (see IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT() in IEMMc.h but check that it has some
     6741     *                   actual performance benefit first). */
     6742    /*
     6743     * if (cr0 & X86_CR0_EM)
     6744     *     return raisexcpt();
     6745     */
     6746    off = iemNativeEmitTestAnyBitsInGprAndJmpToLabelIfAnySet(pReNative, off, idxCr0Reg, X86_CR0_EM, idxLabelRaiseUd);
     6747    /*
     6748     * if (!(cr4 & X86_CR4_OSFXSR))
     6749     *     return raisexcpt();
     6750     */
     6751    off = iemNativeEmitTestAnyBitsInGprAndJmpToLabelIfNoneSet(pReNative, off, idxCr4Reg, X86_CR4_OSFXSR, idxLabelRaiseUd);
     6752    /*
     6753     * if (cr0 & X86_CR0_TS)
     6754     *     return raisexcpt();
     6755     */
     6756    off = iemNativeEmitTestAnyBitsInGprAndJmpToLabelIfAnySet(pReNative, off, idxCr0Reg, X86_CR0_TS, idxLabelRaiseNm);
     6757
     6758    /* Free but don't flush the CR0 and CR4 register. */
     6759    iemNativeRegFreeTmp(pReNative, idxCr0Reg);
     6760    iemNativeRegFreeTmp(pReNative, idxCr4Reg);
    66656761
    66666762    return off;
     
    1377713873                                    pszName = "RaiseNm";
    1377813874                                    break;
     13875                                case kIemNativeLabelType_RaiseUd:
     13876                                    pszName = "RaiseUd";
     13877                                    break;
    1377913878                                case kIemNativeLabelType_ObsoleteTb:
    1378013879                                    pszName = "ObsoleteTb";
     
    1432614425        if (pReNative->bmLabelTypes & RT_BIT_64(kIemNativeLabelType_RaiseNm))
    1432714426            off = iemNativeEmitRaiseNm(pReNative, off, idxReturnLabel);
     14427        if (pReNative->bmLabelTypes & RT_BIT_64(kIemNativeLabelType_RaiseUd))
     14428            off = iemNativeEmitRaiseUd(pReNative, off, idxReturnLabel);
    1432814429        if (pReNative->bmLabelTypes & RT_BIT_64(kIemNativeLabelType_ObsoleteTb))
    1432914430            off = iemNativeEmitObsoleteTb(pReNative, off, idxReturnLabel);
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r103588 r103592  
    51475147VBOXSTRICTRC            iemRaiseBoundRangeExceeded(PVMCPUCC pVCpu) RT_NOEXCEPT;
    51485148VBOXSTRICTRC            iemRaiseUndefinedOpcode(PVMCPUCC pVCpu) RT_NOEXCEPT;
     5149#ifdef IEM_WITH_SETJMP
     5150DECL_NO_RETURN(void)    iemRaiseUndefinedOpcodeJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
     5151#endif
    51495152VBOXSTRICTRC            iemRaiseDeviceNotAvailable(PVMCPUCC pVCpu) RT_NOEXCEPT;
    51505153#ifdef IEM_WITH_SETJMP
  • trunk/src/VBox/VMM/include/IEMN8veRecompiler.h

    r103590 r103592  
    320320    kIemNativeLabelType_RaiseGp0,
    321321    kIemNativeLabelType_RaiseNm,
     322    kIemNativeLabelType_RaiseUd,
    322323    kIemNativeLabelType_ObsoleteTb,
    323324    kIemNativeLabelType_NeedCsLimChecking,
     
    698699    kIemNativeGstReg_SegSelFirst,
    699700    kIemNativeGstReg_SegSelLast    = kIemNativeGstReg_SegSelFirst + 5,
     701    kIemNativeGstReg_Cr4,
    700702    kIemNativeGstReg_EFlags,            /**< 32-bit, includes internal flags - last! */
    701703    kIemNativeGstReg_End
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