VirtualBox

Ignore:
Timestamp:
Oct 20, 2023 9:53:15 PM (15 months ago)
Author:
vboxsync
Message:

VMM/IEM: Assert that we don't overshoot iemNativeInstrBufEnsure space reservations (mainly an x86 host issue). bugref:10371

File:
1 edited

Legend:

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

    r101523 r101535  
    29602960#  error "Port me!"
    29612961# endif
     2962    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
    29622963    return off;
    29632964}
     
    29892990    pbCodeBuf[off++] = 0x0b;                    /* or edx, eax */
    29902991    pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, X86_GREG_xDX, X86_GREG_xAX);
     2992    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
    29912993
    29922994    /* Jump to non-zero status return path. */
     
    30153017# error "port me"
    30163018#endif
     3019    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
    30173020    return off;
    30183021}
     
    32013204     * Make the call.
    32023205     */
    3203 #ifdef RT_ARCH_AMD64
    3204     off = iemNativeEmitLoadGprImm64(pReNative, off, X86_GREG_xAX, pfnCImpl);
    3205 
    3206     uint8_t *pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 2);
    3207     AssertReturn(pbCodeBuf, UINT32_MAX);
    3208     pbCodeBuf[off++] = 0xff;                    /* call rax */
    3209     pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, 2, X86_GREG_xAX);
    3210 
    3211 # if defined(VBOXSTRICTRC_STRICT_ENABLED) && defined(RT_OS_WINDOWS)
     3206    off = iemNativeEmitCallImm(pReNative, off, pfnCImpl);
     3207
     3208#if defined(RT_ARCH_AMD64) && defined(VBOXSTRICTRC_STRICT_ENABLED) && defined(RT_OS_WINDOWS)
    32123209    off = iemNativeEmitLoadGprByBpU32(pReNative, off, X86_GREG_xAX, IEMNATIVE_FP_OFF_IN_SHADOW_ARG0); /* rcStrict (see above) */
    3213 # endif
    3214 
    3215 #elif defined(RT_ARCH_ARM64)
    3216     off = iemNativeEmitLoadGprImm64(pReNative, off, IEMNATIVE_REG_FIXED_TMP0, pfnCImpl);
    3217 
    3218     uint32_t *pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1);
    3219     AssertReturn(pu32CodeBuf, UINT32_MAX);
    3220     pu32CodeBuf[off++] = Armv8A64MkInstrBlr(IEMNATIVE_REG_FIXED_TMP0);
    3221 
    3222 #else
    3223 # error "Port me!"
    32243210#endif
    32253211
     
    33473333        /* iemNativeHlpExecStatusCodeFiddling(PVMCPUCC pVCpu, int rc, uint8_t idxInstr) */
    33483334#ifdef RT_ARCH_AMD64
    3349         /*
    3350          * AMD64:
    3351          */
    3352         uint8_t *pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 20);
    3353         AssertReturn(pbCodeBuf, UINT32_MAX);
    3354 
    3355         /* Call helper and jump to return point. */
    33563335# ifdef RT_OS_WINDOWS
    33573336#  ifdef IEMNATIVE_WITH_INSTRUCTION_COUNTING
     
    33713350# endif
    33723351
    3373 #elif defined(RT_ARCH_ARM64)
    3374         /*
    3375          * ARM64:
    3376          */
     3352#else
    33773353        off = iemNativeEmitLoadGprFromGpr(pReNative, off, IEMNATIVE_CALL_ARG1_GREG, IEMNATIVE_CALL_RET_GREG);
    33783354        off = iemNativeEmitLoadGprFromGpr(pReNative, off, IEMNATIVE_CALL_ARG0_GREG, IEMNATIVE_REG_FIXED_PVMCPU);
    33793355        /* IEMNATIVE_CALL_ARG2_GREG is already set. */
    3380         off = iemNativeEmitLoadGprImm64(pReNative, off, IEMNATIVE_REG_FIXED_TMP0, (uintptr_t)iemNativeHlpExecStatusCodeFiddling);
    3381         AssertReturn(off != UINT32_MAX, UINT32_MAX);
    3382 #else
    3383 # error "port me"
    33843356#endif
    33853357
     
    34773449# error "port me"
    34783450#endif
     3451    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
    34793452
    34803453    return iemNativeEmitRcFiddling(pReNative, off, idxReturn);
     
    35833556# error "port me"
    35843557#endif
     3558    IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);
    35853559    return off;
    35863560}
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