VirtualBox

Changeset 106117 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 23, 2024 1:59:08 PM (2 months ago)
Author:
vboxsync
Message:

VMM/IEM: Recompilation-time checks of skipped EFLAGS. bugref:10720

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompFuncs.h

    r106113 r106117  
    59755975    off = iemNativeEmitCommitEFlags<true /*fUpdateSkipping*/, a_fEflOutput, \
    59765976                                    iemNativeEflagsToLivenessMask<a_fEflInput>(), \
    5977                                     iemNativeEflagsToLivenessMask<a_fEflOutput>()>(pReNative, off, a_EFlags)
     5977                                    iemNativeEflagsToLivenessMask<a_fEflOutput>()>(pReNative, off, a_EFlags, a_fEflInput)
    59785978
    59795979#undef IEM_MC_COMMIT_EFLAGS_OPT /* should not be used */
     
    59825982    off = iemNativeEmitCommitEFlags<false /*fUpdateSkipping*/, a_fEflOutput, \
    59835983                                    iemNativeEflagsToLivenessMask<a_fEflInput>(), \
    5984                                     iemNativeEflagsToLivenessMask<a_fEflOutput>()>(pReNative, off, a_EFlags)
     5984                                    iemNativeEflagsToLivenessMask<a_fEflOutput>()>(pReNative, off, a_EFlags, a_fEflInput)
    59855985
    59865986/** Handles IEM_MC_COMMIT_EFLAGS_EX. */
    59875987template<bool const a_fUpdateSkipping, uint32_t const a_fEflOutput,
    59885988         uint64_t const a_fLivenessEflInputBits, uint64_t const a_fLivenessEflOutputBits>
    5989 DECL_INLINE_THROW(uint32_t) iemNativeEmitCommitEFlags(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t idxVarEFlags)
     5989DECL_INLINE_THROW(uint32_t)
     5990iemNativeEmitCommitEFlags(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t idxVarEFlags, uint32_t fElfInput)
    59905991{
    59915992    uint8_t const idxReg = iemNativeVarRegisterAcquire(pReNative, idxVarEFlags, &off, true /*fInitialized*/);
     
    60346035#endif
    60356036
    6036 #ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
     6037#ifdef IEMNATIVE_WITH_EFLAGS_SKIPPING
    60376038    if RT_CONSTEXPR_IF(a_fUpdateSkipping)
    60386039    {
     6040        Assert(!(pReNative->fSkippingEFlags & fElfInput)); RT_NOREF(fElfInput);
     6041        if RT_CONSTEXPR_IF((a_fEflOutput & X86_EFL_STATUS_BITS) == X86_EFL_STATUS_BITS)
     6042            pReNative->fSkippingEFlags  = 0;
     6043        else
     6044            pReNative->fSkippingEFlags &= ~(a_fEflOutput & X86_EFL_STATUS_BITS);
     6045# ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
    60396046        if RT_CONSTEXPR_IF((a_fEflOutput & X86_EFL_STATUS_BITS) == X86_EFL_STATUS_BITS)
    60406047            off = iemNativeEmitStoreImmToVCpuU32(pReNative, off, 0, RT_UOFFSETOF(VMCPU, iem.s.fSkippingEFlags));
     
    60426049            off = iemNativeEmitAndImmIntoVCpuU32(pReNative, off, ~(a_fEflOutput & X86_EFL_STATUS_BITS),
    60436050                                                 RT_UOFFSETOF(VMCPU, iem.s.fSkippingEFlags));
     6051# endif
    60446052    }
    60456053#endif
     
    62376245    IEMNATIVE_ASSERT_VAR_SIZE(pReNative, idxVarRef, sizeof(void *));
    62386246
    6239 #ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
     6247#ifdef IEMNATIVE_WITH_EFLAGS_SKIPPING
     6248    Assert(!(pReNative->fSkippingEFlags & fEflInput));
     6249    pReNative->fSkippingEFlags &= ~fEflOutput;
    62406250    IEMNATIVE_STRICT_EFLAGS_SKIPPING_EMIT_CHECK(pReNative, off, fEflInput);
     6251# ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
    62416252
    62426253    /* Updating the skipping according to the outputs is a little early, but
     
    62476258        off = iemNativeEmitAndImmIntoVCpuU32(pReNative, off, ~(fEflOutput & X86_EFL_STATUS_BITS),
    62486259                                             RT_UOFFSETOF(VMCPU, iem.s.fSkippingEFlags));
    6249 #else
     6260# endif
     6261#endif
    62506262    RT_NOREF(fEflInput, fEflOutput);
    6251 #endif
    62526263
    62536264    /* If we've delayed writing back the register value, flush it now. */
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp

    r106113 r106117  
    20682068    pReNative->uCheckIrqSeqNo              = 0;
    20692069    pReNative->uTlbSeqNo                   = 0;
     2070#ifdef IEMNATIVE_WITH_EFLAGS_SKIPPING
     2071    pReNative->fSkippingEFlags             = 0;
     2072#endif
     2073#ifdef IEMNATIVE_WITH_EFLAGS_POSTPONING
     2074    pReNative->fPostponingEFlags           = 0;
     2075#endif
    20702076
    20712077#ifdef IEMNATIVE_WITH_DELAYED_PC_UPDATING
     
    1030110307            STAM_REL_COUNTER_INC(&pVCpu->iem.s.StatNativeFullyRecompiledTbs);
    1030210308
     10309#ifdef IEMNATIVE_WITH_EFLAGS_SKIPPING
     10310        Assert(pReNative->fSkippingEFlags == 0);
     10311#endif
     10312#ifdef IEMNATIVE_WITH_EFLAGS_POSTPONING
     10313        Assert(pReNative->fPostponingEFlags == 0);
     10314#endif
     10315
    1030310316#ifdef VBOX_WITH_STATISTICS
    1030410317        off = iemNativeEmitNativeTbExitStats(pReNative, off, RT_UOFFSETOF(VMCPUCC, iem.s.StatNativeTbFinished));
  • trunk/src/VBox/VMM/VMMAll/target-x86/IEMAllN8veEmit-x86.h

    r106101 r106117  
    217217    {
    218218        STAM_COUNTER_INC(&pReNative->pVCpu->iem.s.StatNativeEflSkippedLogical);
     219        pReNative->fSkippingEFlags |= X86_EFL_STATUS_BITS;
    219220# ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
    220221        off = iemNativeEmitOrImmIntoVCpuU32(pReNative, off, X86_EFL_STATUS_BITS, RT_UOFFSETOF(VMCPU, iem.s.fSkippingEFlags));
     
    290291        IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
    291292
    292 #  ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
     293#ifdef IEMNATIVE_WITH_EFLAGS_SKIPPING
     294        pReNative->fSkippingEFlags &= ~X86_EFL_STATUS_BITS;
     295# ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
    293296        off = iemNativeEmitStoreImmToVCpuU32(pReNative, off, 0, RT_UOFFSETOF(VMCPU, iem.s.fSkippingEFlags));
    294 #  endif
     297# endif
     298#endif
    295299    }
    296300    return off;
     
    321325    {
    322326        STAM_COUNTER_INC(&pReNative->pVCpu->iem.s.StatNativeEflSkippedArithmetic);
     327        pReNative->fSkippingEFlags |= X86_EFL_STATUS_BITS;
    323328# ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
    324329        off = iemNativeEmitOrImmIntoVCpuU32(pReNative, off, X86_EFL_STATUS_BITS, RT_UOFFSETOF(VMCPU, iem.s.fSkippingEFlags));
     
    328333#endif
    329334    {
    330 #ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
     335#ifdef IEMNATIVE_WITH_EFLAGS_SKIPPING
    331336        uint32_t fSkipped = 0;
    332337#endif
     
    485490        IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
    486491
    487 #ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
     492#ifdef IEMNATIVE_WITH_EFLAGS_SKIPPING
     493        pReNative->fSkippingEFlags = fSkipped;
     494# ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
    488495        off = iemNativeEmitStoreImmToVCpuU32(pReNative, off, fSkipped, RT_UOFFSETOF(VMCPU, iem.s.fSkippingEFlags));
     496# endif
    489497#endif
    490498    }
     
    15721580    {
    15731581        STAM_COUNTER_INC(&pReNative->pVCpu->iem.s.StatNativeEflSkippedShift);
     1582        pReNative->fSkippingEFlags |= X86_EFL_STATUS_BITS;
    15741583# ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
    15751584        off = iemNativeEmitOrImmIntoVCpuU32(pReNative, off, X86_EFL_STATUS_BITS, RT_UOFFSETOF(VMCPU, iem.s.fSkippingEFlags));
     
    17361745        IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
    17371746
    1738 #  ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
     1747#ifdef IEMNATIVE_WITH_EFLAGS_SKIPPING
     1748        pReNative->fSkippingEFlags = 0;
     1749# ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
    17391750        off = iemNativeEmitStoreImmToVCpuU32(pReNative, off, 0, RT_UOFFSETOF(VMCPU, iem.s.fSkippingEFlags));
    1740 #  endif
     1751# endif
     1752#endif
    17411753    }
    17421754    return off;
  • trunk/src/VBox/VMM/include/IEMN8veRecompiler.h

    r106113 r106117  
    10531053 */
    10541054#ifdef IEMNATIVE_STRICT_EFLAGS_SKIPPING
     1055# define IEMNATIVE_STRICT_EFLAGS_SKIPPING_EMIT_CHECK(a_pReNative, a_off, a_fEflNeeded) do { \
     1056        AssertMsg(!((a_pReNative)->fSkippingEFlags & (a_fEflNeeded)), \
     1057                  ("%#x & %#x -> %#x; off=%#x\n", (a_pReNative)->fSkippingEFlags, a_fEflNeeded, \
     1058                  ((a_pReNative)->fSkippingEFlags & (a_fEflNeeded)), a_off)); \
     1059        (a_off) = iemNativeEmitEFlagsSkippingCheck(a_pReNative, a_off, a_fEflNeeded); \
     1060    } while (0)
     1061#else
    10551062# define IEMNATIVE_STRICT_EFLAGS_SKIPPING_EMIT_CHECK(a_pReNative, a_off, a_fEflNeeded) \
    1056     do { (a_off) = iemNativeEmitEFlagsSkippingCheck(a_pReNative, a_off, a_fEflNeeded); } while (0)
    1057 #else
    1058 # define IEMNATIVE_STRICT_EFLAGS_SKIPPING_EMIT_CHECK(a_pReNative, a_off, a_fEflNeeded) do { } while (0)
     1063    AssertMsg(!((a_pReNative)->fSkippingEFlags & (a_fEflNeeded)), \
     1064              ("%#x & %#x -> %#x; off=%#x\n", (a_pReNative)->fSkippingEFlags, a_fEflNeeded, \
     1065              ((a_pReNative)->fSkippingEFlags & (a_fEflNeeded)), a_off))
    10591066#endif
    10601067
     
    16481655    /** The call number of the last CheckIrq, UINT32_MAX if not seen. */
    16491656    uint32_t                    idxLastCheckIrqCallNo;
     1657#ifdef IEMNATIVE_WITH_EFLAGS_SKIPPING
     1658    uint32_t                    fSkippingEFlags;
     1659#endif
     1660#ifdef IEMNATIVE_WITH_EFLAGS_POSTPONING
     1661    uint32_t                    fPostponingEFlags;
     1662#endif
    16501663
    16511664    /** Core state requiring care with branches. */
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