VirtualBox

Changeset 101984 in vbox for trunk/src/VBox/VMM/include


Ignore:
Timestamp:
Nov 8, 2023 3:56:18 PM (18 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
160081
Message:

VMM/IEM: Added a flush mask for guest register shadows to the IEM_MC_DEFER_TO_CIMPL_X_RET macros to better manage register optimizations when recompiling to native code. bugref:10371

Location:
trunk/src/VBox/VMM/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r101722 r101984  
    619619/** Force end of TB after the instruction. */
    620620#define IEM_CIMPL_F_END_TB              RT_BIT_32(15)
     621/** Flag set if a branch may also modify the stack (push/pop return address). */
     622#define IEM_CIMPL_F_BRANCH_STACK        RT_BIT_32(16)
     623/** Flag set if a branch may also modify the stack (push/pop return address)
     624 *  and switch it (load/restore SS:RSP). */
     625#define IEM_CIMPL_F_BRANCH_STACK_FAR    RT_BIT_32(17)
    621626/** Convenience: Raise exception (technically unnecessary, since it shouldn't return VINF_SUCCESS). */
    622627#define IEM_CIMPL_F_XCPT \
    623     (IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT)
     628    (IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR | IEM_CIMPL_F_BRANCH_STACK_FAR \
     629     | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT)
    624630
    625631/** The block calls a C-implementation instruction function with two implicit arguments.
     
    627633 * IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE.
    628634 * @note The python scripts will add this is missing.  */
    629 #define IEM_CIMPL_F_CALLS_CIMPL                 RT_BIT_32(16)
     635#define IEM_CIMPL_F_CALLS_CIMPL                 RT_BIT_32(18)
    630636/** The block calls an ASM-implementation instruction function.
    631637 * Mutually exclusive with IEM_CIMPL_F_CALLS_CIMPL and
    632638 * IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE.
    633639 * @note The python scripts will add this is missing.  */
    634 #define IEM_CIMPL_F_CALLS_AIMPL                 RT_BIT_32(17)
     640#define IEM_CIMPL_F_CALLS_AIMPL                 RT_BIT_32(19)
    635641/** The block calls an ASM-implementation instruction function with an implicit
    636642 * X86FXSTATE pointer argument.
    637643 * Mutually exclusive with IEM_CIMPL_F_CALLS_CIMPL and IEM_CIMPL_F_CALLS_AIMPL.
    638644 * @note The python scripts will add this is missing.  */
    639 #define IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE    RT_BIT_32(18)
     645#define IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE    RT_BIT_32(20)
    640646/** @} */
    641647
     
    13051311/** @name IEMBRANCHED_F_XXX - Branched indicator (IEMCPU::fTbBranched).
    13061312 *
    1307  * These flags parallels IEM_CIMPL_F_BRANCH_XXX.
     1313 * These flags parallels the main IEM_CIMPL_F_BRANCH_XXX flags.
    13081314 *
    13091315 * @{ */
     
    13201326/** Flag set if it's a far branch. */
    13211327#define IEMBRANCHED_F_FAR           UINT8_C(0x10)
     1328/** Flag set if the stack pointer is modified. */
     1329#define IEMBRANCHED_F_STACK         UINT8_C(0x20)
     1330/** Flag set if the stack pointer and (maybe) the stack segment are modified. */
     1331#define IEMBRANCHED_F_STACK_FAR     UINT8_C(0x40)
    13221332/** Flag set (by IEM_MC_REL_JMP_XXX) if it's a zero bytes relative jump. */
    1323 #define IEMBRANCHED_F_ZERO          UINT8_C(0x20)
     1333#define IEMBRANCHED_F_ZERO          UINT8_C(0x80)
    13241334/** @} */
    13251335
     
    49204930 * @return  Strict VBox status code.
    49214931 */
    4922 #define IEMOP_RAISE_DIVIDE_ERROR_RET()      IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, iemCImplRaiseDivideError)
     4932#define IEMOP_RAISE_DIVIDE_ERROR_RET()          IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseDivideError)
    49234933
    49244934/**
     
    49304940 * @return  Strict VBox status code.
    49314941 */
    4932 #define IEMOP_RAISE_INVALID_LOCK_PREFIX_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, iemCImplRaiseInvalidLockPrefix)
     4942#define IEMOP_RAISE_INVALID_LOCK_PREFIX_RET()   IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidLockPrefix)
    49334943
    49344944/**
     
    49404950 * @return  Strict VBox status code.
    49414951 */
    4942 #define IEMOP_RAISE_INVALID_OPCODE_RET()    IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, iemCImplRaiseInvalidOpcode)
     4952#define IEMOP_RAISE_INVALID_OPCODE_RET()        IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidOpcode)
    49434953
    49444954/**
     
    49514961 * @see     IEMOP_RAISE_INVALID_OPCODE_RET
    49524962 */
    4953 #define IEMOP_RAISE_INVALID_OPCODE_RUNTIME_RET()   IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, iemCImplRaiseInvalidOpcode)
     4963#define IEMOP_RAISE_INVALID_OPCODE_RUNTIME_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidOpcode)
    49544964
    49554965/** @} */
  • trunk/src/VBox/VMM/include/IEMMc.h

    r101958 r101984  
    21012101 *
    21022102 * @param   a_fFlags        IEM_CIMPL_F_XXX.
     2103 * @param   a_fGstShwFlush  Guest shadow register copies needing to be flushed
     2104 *                          in the native recompiler.
    21032105 * @param   a_pfnCImpl      The pointer to the C routine.
    21042106 * @sa      IEM_DECL_IMPL_C_TYPE_0 and IEM_CIMPL_DEF_0.
    21052107 */
    2106 #define IEM_MC_DEFER_TO_CIMPL_0_RET(a_fFlags, a_pfnCImpl) \
     2108#define IEM_MC_DEFER_TO_CIMPL_0_RET(a_fFlags, a_fGstShwFlush, a_pfnCImpl) \
    21072109    IEM_MC_CALL_CIMPL_HLP_RET(a_fFlags, (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu)))
    21082110
     
    21142116 *
    21152117 * @param   a_fFlags        IEM_CIMPL_F_XXX.
     2118 * @param   a_fGstShwFlush  Guest shadow register copies needing to be flushed
     2119 *                          in the native recompiler.
    21162120 * @param   a_pfnCImpl      The pointer to the C routine.
    21172121 * @param   a0              The argument.
    21182122 */
    2119 #define IEM_MC_DEFER_TO_CIMPL_1_RET(a_fFlags, a_pfnCImpl, a0) \
     2123#define IEM_MC_DEFER_TO_CIMPL_1_RET(a_fFlags, a_fGstShwFlush, a_pfnCImpl, a0) \
    21202124    IEM_MC_CALL_CIMPL_HLP_RET(a_fFlags, (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu), a0))
    21212125
     
    21272131 *
    21282132 * @param   a_fFlags        IEM_CIMPL_F_XXX.
     2133 * @param   a_fGstShwFlush  Guest shadow register copies needing to be flushed
     2134 *                          in the native recompiler.
    21292135 * @param   a_pfnCImpl      The pointer to the C routine.
    21302136 * @param   a0              The first extra argument.
    21312137 * @param   a1              The second extra argument.
    21322138 */
    2133 #define IEM_MC_DEFER_TO_CIMPL_2_RET(a_fFlags, a_pfnCImpl, a0, a1) \
     2139#define IEM_MC_DEFER_TO_CIMPL_2_RET(a_fFlags, a_fGstShwFlush, a_pfnCImpl, a0, a1) \
    21342140    IEM_MC_CALL_CIMPL_HLP_RET(a_fFlags, (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu), a0, a1))
    21352141
     
    21412147 *
    21422148 * @param   a_fFlags        IEM_CIMPL_F_XXX.
     2149 * @param   a_fGstShwFlush  Guest shadow register copies needing to be flushed
     2150 *                          in the native recompiler.
    21432151 * @param   a_pfnCImpl      The pointer to the C routine.
    21442152 * @param   a0              The first extra argument.
     
    21462154 * @param   a2              The third extra argument.
    21472155 */
    2148 #define IEM_MC_DEFER_TO_CIMPL_3_RET(a_fFlags, a_pfnCImpl, a0, a1, a2) \
     2156#define IEM_MC_DEFER_TO_CIMPL_3_RET(a_fFlags, a_fGstShwFlush, a_pfnCImpl, a0, a1, a2) \
    21492157    IEM_MC_CALL_CIMPL_HLP_RET(a_fFlags, (a_pfnCImpl)(pVCpu, IEM_GET_INSTR_LEN(pVCpu), a0, a1, a2))
    21502158
  • trunk/src/VBox/VMM/include/IEMN8veRecompiler.h

    r101913 r101984  
    348348{
    349349    kIemNativeGstReg_GprFirst      = 0,
    350     kIemNativeGstReg_GprLast       = 15,
     350    kIemNativeGstReg_GprLast       = kIemNativeGstReg_GprFirst + 15,
    351351    kIemNativeGstReg_Pc,
    352     kIemNativeGstReg_EFlags,            /**< This one is problematic since the higher bits are used internally. */
    353     /* gap: 18..23 */
    354     kIemNativeGstReg_SegSelFirst   = 24,
    355     kIemNativeGstReg_SegSelLast    = 29,
    356     kIemNativeGstReg_SegBaseFirst  = 30,
    357     kIemNativeGstReg_SegBaseLast   = 35,
    358     kIemNativeGstReg_SegLimitFirst = 36,
    359     kIemNativeGstReg_SegLimitLast  = 41,
     352    kIemNativeGstReg_EFlags,            /**< 32-bit, includes internal flags.  */
     353    kIemNativeGstReg_SegSelFirst,
     354    kIemNativeGstReg_SegSelLast    = kIemNativeGstReg_SegSelFirst + 5,
     355    kIemNativeGstReg_SegBaseFirst,
     356    kIemNativeGstReg_SegBaseLast   = kIemNativeGstReg_SegBaseFirst + 5,
     357    kIemNativeGstReg_SegLimitFirst,
     358    kIemNativeGstReg_SegLimitLast  = kIemNativeGstReg_SegLimitFirst + 5,
    360359    kIemNativeGstReg_End
    361360} IEMNATIVEGSTREG;
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