VirtualBox

Changeset 103665 in vbox for trunk


Ignore:
Timestamp:
Mar 4, 2024 12:50:11 PM (7 months ago)
Author:
vboxsync
Message:

VMM/IEM: Native translation of IEM_MC_MAYBE_RAISE_FPU_XCPT() body, bugref:10371

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

Legend:

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

    r103592 r103665  
    44984498    return iemRegUpdateRipAndFinishClearingRF(pVCpu);
    44994499}
     4500
     4501#ifdef IEM_WITH_SETJMP
     4502/** \#MF(0) - 10, longjmp.  */
     4503DECL_NO_RETURN(void) iemRaiseMathFaultJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP
     4504{
     4505    IEM_DO_LONGJMP(pVCpu, VBOXSTRICTRC_VAL(iemRaiseMathFault(pVCpu)));
     4506}
     4507#endif
    45004508
    45014509
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstPython.py

    r103663 r103665  
    31253125    'IEM_MC_MAYBE_RAISE_AVX_RELATED_XCPT':                       (McBlock.parseMcGeneric,           True,  True,  True,  ),
    31263126    'IEM_MC_MAYBE_RAISE_DEVICE_NOT_AVAILABLE':                   (McBlock.parseMcGeneric,           True,  True,  True,  ),
    3127     'IEM_MC_MAYBE_RAISE_FPU_XCPT':                               (McBlock.parseMcGeneric,           True,  True,  False, ),
     3127    'IEM_MC_MAYBE_RAISE_FPU_XCPT':                               (McBlock.parseMcGeneric,           True,  True,  True, ),
    31283128    'IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT':                          (McBlock.parseMcGeneric,           True,  True,  False, ),
    31293129    'IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT':                       (McBlock.parseMcGeneric,           True,  True,  False, ),
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp

    r103664 r103665  
    16221622
    16231623/**
     1624 * Used by TB code when it wants to raise a \#MF.
     1625 */
     1626IEM_DECL_NATIVE_HLP_DEF(int, iemNativeHlpExecRaiseMf,(PVMCPUCC pVCpu))
     1627{
     1628    iemRaiseMathFaultJmp(pVCpu);
     1629#ifndef _MSC_VER
     1630    return VINF_IEM_RAISED_XCPT; /* not reached */
     1631#endif
     1632}
     1633
     1634
     1635/**
    16241636 * Used by TB code when detecting opcode changes.
    16251637 * @see iemThreadeFuncWorkerObsoleteTb
     
    29342946    pReNative->Core.u64ArgVars             = UINT64_MAX;
    29352947
    2936     AssertCompile(RT_ELEMENTS(pReNative->aidxUniqueLabels) == 11);
     2948    AssertCompile(RT_ELEMENTS(pReNative->aidxUniqueLabels) == 12);
    29372949    pReNative->aidxUniqueLabels[0]         = UINT32_MAX;
    29382950    pReNative->aidxUniqueLabels[1]         = UINT32_MAX;
     
    29462958    pReNative->aidxUniqueLabels[9]         = UINT32_MAX;
    29472959    pReNative->aidxUniqueLabels[10]        = UINT32_MAX;
     2960    pReNative->aidxUniqueLabels[11]        = UINT32_MAX;
    29482961
    29492962    /* Full host register reinit: */
     
    59475960
    59485961/**
     5962 * Emits the code at the RaiseMf label.
     5963 */
     5964static uint32_t iemNativeEmitRaiseMf(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint32_t idxReturnLabel)
     5965{
     5966    uint32_t const idxLabel = iemNativeLabelFind(pReNative, kIemNativeLabelType_RaiseMf);
     5967    if (idxLabel != UINT32_MAX)
     5968    {
     5969        iemNativeLabelDefine(pReNative, idxLabel, off);
     5970
     5971        /* iemNativeHlpExecRaiseMf(PVMCPUCC pVCpu) */
     5972        off = iemNativeEmitLoadGprFromGpr(pReNative, off, IEMNATIVE_CALL_ARG0_GREG, IEMNATIVE_REG_FIXED_PVMCPU);
     5973        off = iemNativeEmitCallImm(pReNative, off, (uintptr_t)iemNativeHlpExecRaiseMf);
     5974
     5975        /* jump back to the return sequence. */
     5976        off = iemNativeEmitJmpToLabel(pReNative, off, idxReturnLabel);
     5977    }
     5978    return off;
     5979}
     5980
     5981
     5982/**
    59495983 * Emits the code at the ReturnWithFlags label (returns
    59505984 * VINF_IEM_REEXEC_FINISH_WITH_FLAGS).
     
    69466980    /* Free but don't flush the CR0 register. */
    69476981    iemNativeRegFreeTmp(pReNative, idxCr0Reg);
     6982
     6983    return off;
     6984}
     6985
     6986
     6987#define IEM_MC_MAYBE_RAISE_FPU_XCPT() \
     6988    off = iemNativeEmitMaybeFpuException(pReNative, off, pCallEntry->idxInstr)
     6989
     6990/**
     6991 * Emits code to check if a \#MF exception should be raised.
     6992 *
     6993 * @returns New code buffer offset, UINT32_MAX on failure.
     6994 * @param   pReNative       The native recompile state.
     6995 * @param   off             The code buffer offset.
     6996 * @param   idxInstr        The current instruction.
     6997 */
     6998DECL_INLINE_THROW(uint32_t)
     6999iemNativeEmitMaybeRaiseFpuException(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t idxInstr)
     7000{
     7001    /*
     7002     * Make sure we don't have any outstanding guest register writes as we may
     7003     * raise an #MF and all guest register must be up to date in CPUMCTX.
     7004     *
     7005     * @todo r=aeichner Can we postpone this to the RaiseMf path?
     7006     */
     7007    off = iemNativeRegFlushPendingWrites(pReNative, off);
     7008
     7009#ifdef IEMNATIVE_WITH_INSTRUCTION_COUNTING
     7010    off = iemNativeEmitStoreImmToVCpuU8(pReNative, off, idxInstr, RT_UOFFSETOF(VMCPUCC, iem.s.idxTbCurInstr));
     7011#else
     7012    RT_NOREF(idxInstr);
     7013#endif
     7014
     7015    /* Allocate a temporary FSW register. */
     7016    uint8_t const idxFpuFswReg    = iemNativeRegAllocTmpForGuestReg(pReNative, &off, kIemNativeGstReg_FpuFsw, kIemNativeGstRegUse_ReadOnly);
     7017    uint8_t const idxLabelRaiseMf = iemNativeLabelCreate(pReNative, kIemNativeLabelType_RaiseMf);
     7018
     7019    /*
     7020     * if (FSW & X86_FSW_ES != 0)
     7021     *     return raisexcpt();
     7022     */
     7023    /* Test and jump. */
     7024    off = iemNativeEmitTestAnyBitsInGprAndJmpToLabelIfAnySet(pReNative, off, idxFpuFswReg, X86_FSW_ES, idxLabelRaiseMf);
     7025
     7026    /* Free but don't flush the FSW register. */
     7027    iemNativeRegFreeTmp(pReNative, idxFpuFswReg);
    69487028
    69497029    return off;
     
    1434914429                                    pszName = "RaiseUd";
    1435014430                                    break;
     14431                                case kIemNativeLabelType_RaiseMf:
     14432                                    pszName = "RaiseUd";
     14433                                    break;
    1435114434                                case kIemNativeLabelType_ObsoleteTb:
    1435214435                                    pszName = "ObsoleteTb";
     
    1494915032        if (pReNative->bmLabelTypes & RT_BIT_64(kIemNativeLabelType_RaiseUd))
    1495015033            off = iemNativeEmitRaiseUd(pReNative, off, idxReturnLabel);
     15034        if (pReNative->bmLabelTypes & RT_BIT_64(kIemNativeLabelType_RaiseMf))
     15035            off = iemNativeEmitRaiseMf(pReNative, off, idxReturnLabel);
    1495115036        if (pReNative->bmLabelTypes & RT_BIT_64(kIemNativeLabelType_ObsoleteTb))
    1495215037            off = iemNativeEmitObsoleteTb(pReNative, off, idxReturnLabel);
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r103649 r103665  
    52195219#endif
    52205220VBOXSTRICTRC            iemRaiseMathFault(PVMCPUCC pVCpu) RT_NOEXCEPT;
     5221#ifdef IEM_WITH_SETJMP
     5222DECL_NO_RETURN(void)    iemRaiseMathFaultJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
     5223#endif
    52215224VBOXSTRICTRC            iemRaiseAlignmentCheckException(PVMCPUCC pVCpu) RT_NOEXCEPT;
    52225225#ifdef IEM_WITH_SETJMP
  • trunk/src/VBox/VMM/include/IEMN8veRecompiler.h

    r103662 r103665  
    330330    kIemNativeLabelType_RaiseNm,
    331331    kIemNativeLabelType_RaiseUd,
     332    kIemNativeLabelType_RaiseMf,
    332333    kIemNativeLabelType_ObsoleteTb,
    333334    kIemNativeLabelType_NeedCsLimChecking,
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