VirtualBox

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


Ignore:
Timestamp:
Dec 12, 2023 12:26:29 PM (17 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
160733
Message:

VMM/IEM: Refactored the IEM_MC_SET_RIP_Uxx_AND_FINISH MCs in prep for native translation. bugref:10371

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

Legend:

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

    r102430 r102585  
    27732773
    27742774
     2775
     2776/**
     2777 * Performs a near jump to the specified address, no checking or clearing of
     2778 * flags
     2779 *
     2780 * May raise a \#GP(0) if the new IP outside the code segment limit.
     2781 *
     2782 * @param   pVCpu               The cross context virtual CPU structure of the calling thread.
     2783 * @param   uNewIp              The new IP value.
     2784 */
     2785DECLINLINE(VBOXSTRICTRC) iemRegRipJumpU16AndFinishNoFlags(PVMCPUCC pVCpu, uint16_t uNewIp) RT_NOEXCEPT
     2786{
     2787    if (RT_LIKELY(   uNewIp <= pVCpu->cpum.GstCtx.cs.u32Limit
     2788                  || IEM_IS_64BIT_CODE(pVCpu) /* no limit checks in 64-bit mode */))
     2789        pVCpu->cpum.GstCtx.rip = uNewIp;
     2790    else
     2791        return iemRaiseGeneralProtectionFault0(pVCpu);
     2792#ifndef IEM_WITH_CODE_TLB
     2793    pVCpu->iem.s.cbOpcode = IEM_GET_INSTR_LEN(pVCpu);
     2794#endif
     2795    return iemRegFinishNoFlags(pVCpu);
     2796}
     2797
     2798
     2799/**
     2800 * Performs a near jump to the specified address, no checking or clearing of
     2801 * flags
     2802 *
     2803 * May raise a \#GP(0) if the new RIP is outside the code segment limit.
     2804 *
     2805 * @param   pVCpu               The cross context virtual CPU structure of the calling thread.
     2806 * @param   uNewEip             The new EIP value.
     2807 */
     2808DECLINLINE(VBOXSTRICTRC) iemRegRipJumpU32AndFinishNoFlags(PVMCPUCC pVCpu, uint32_t uNewEip) RT_NOEXCEPT
     2809{
     2810    Assert(pVCpu->cpum.GstCtx.rip <= UINT32_MAX);
     2811    Assert(!IEM_IS_64BIT_CODE(pVCpu));
     2812    if (RT_LIKELY(uNewEip <= pVCpu->cpum.GstCtx.cs.u32Limit))
     2813        pVCpu->cpum.GstCtx.rip = uNewEip;
     2814    else
     2815        return iemRaiseGeneralProtectionFault0(pVCpu);
     2816#ifndef IEM_WITH_CODE_TLB
     2817    pVCpu->iem.s.cbOpcode = IEM_GET_INSTR_LEN(pVCpu);
     2818#endif
     2819    return iemRegFinishNoFlags(pVCpu);
     2820}
     2821
     2822
     2823/**
     2824 * Performs a near jump to the specified address, no checking or clearing of
     2825 * flags.
     2826 *
     2827 * May raise a \#GP(0) if the new RIP is non-canonical or outside the code
     2828 * segment limit.
     2829 *
     2830 * @param   pVCpu               The cross context virtual CPU structure of the calling thread.
     2831 * @param   uNewRip             The new RIP value.
     2832 */
     2833DECLINLINE(VBOXSTRICTRC) iemRegRipJumpU64AndFinishNoFlags(PVMCPUCC pVCpu, uint64_t uNewRip) RT_NOEXCEPT
     2834{
     2835    Assert(IEM_IS_64BIT_CODE(pVCpu));
     2836    if (RT_LIKELY(IEM_IS_CANONICAL(uNewRip)))
     2837        pVCpu->cpum.GstCtx.rip = uNewRip;
     2838    else
     2839        return iemRaiseGeneralProtectionFault0(pVCpu);
     2840#ifndef IEM_WITH_CODE_TLB
     2841    pVCpu->iem.s.cbOpcode = IEM_GET_INSTR_LEN(pVCpu);
     2842#endif
     2843    return iemRegFinishNoFlags(pVCpu);
     2844}
     2845
     2846
     2847/**
     2848 * Performs a near jump to the specified address.
     2849 *
     2850 * May raise a \#GP(0) if the new IP outside the code segment limit.
     2851 *
     2852 * @param   pVCpu               The cross context virtual CPU structure of the calling thread.
     2853 * @param   uNewIp              The new IP value.
     2854 */
     2855DECLINLINE(VBOXSTRICTRC) iemRegRipJumpU16AndFinishClearingRF(PVMCPUCC pVCpu, uint16_t uNewIp) RT_NOEXCEPT
     2856{
     2857    if (RT_LIKELY(   uNewIp <= pVCpu->cpum.GstCtx.cs.u32Limit
     2858                  || IEM_IS_64BIT_CODE(pVCpu) /* no limit checks in 64-bit mode */))
     2859        pVCpu->cpum.GstCtx.rip = uNewIp;
     2860    else
     2861        return iemRaiseGeneralProtectionFault0(pVCpu);
     2862#ifndef IEM_WITH_CODE_TLB
     2863    pVCpu->iem.s.cbOpcode = IEM_GET_INSTR_LEN(pVCpu);
     2864#endif
     2865    return iemRegFinishClearingRF(pVCpu);
     2866}
     2867
     2868
     2869/**
     2870 * Performs a near jump to the specified address.
     2871 *
     2872 * May raise a \#GP(0) if the new RIP is outside the code segment limit.
     2873 *
     2874 * @param   pVCpu               The cross context virtual CPU structure of the calling thread.
     2875 * @param   uNewEip             The new EIP value.
     2876 */
     2877DECLINLINE(VBOXSTRICTRC) iemRegRipJumpU32AndFinishClearingRF(PVMCPUCC pVCpu, uint32_t uNewEip) RT_NOEXCEPT
     2878{
     2879    Assert(pVCpu->cpum.GstCtx.rip <= UINT32_MAX);
     2880    Assert(!IEM_IS_64BIT_CODE(pVCpu));
     2881    if (RT_LIKELY(uNewEip <= pVCpu->cpum.GstCtx.cs.u32Limit))
     2882        pVCpu->cpum.GstCtx.rip = uNewEip;
     2883    else
     2884        return iemRaiseGeneralProtectionFault0(pVCpu);
     2885#ifndef IEM_WITH_CODE_TLB
     2886    pVCpu->iem.s.cbOpcode = IEM_GET_INSTR_LEN(pVCpu);
     2887#endif
     2888    return iemRegFinishClearingRF(pVCpu);
     2889}
     2890
     2891
     2892/**
     2893 * Performs a near jump to the specified address.
     2894 *
     2895 * May raise a \#GP(0) if the new RIP is non-canonical or outside the code
     2896 * segment limit.
     2897 *
     2898 * @param   pVCpu               The cross context virtual CPU structure of the calling thread.
     2899 * @param   uNewRip             The new RIP value.
     2900 */
     2901DECLINLINE(VBOXSTRICTRC) iemRegRipJumpU64AndFinishClearingRF(PVMCPUCC pVCpu, uint64_t uNewRip) RT_NOEXCEPT
     2902{
     2903    Assert(IEM_IS_64BIT_CODE(pVCpu));
     2904    if (RT_LIKELY(IEM_IS_CANONICAL(uNewRip)))
     2905        pVCpu->cpum.GstCtx.rip = uNewRip;
     2906    else
     2907        return iemRaiseGeneralProtectionFault0(pVCpu);
     2908#ifndef IEM_WITH_CODE_TLB
     2909    pVCpu->iem.s.cbOpcode = IEM_GET_INSTR_LEN(pVCpu);
     2910#endif
     2911    return iemRegFinishClearingRF(pVCpu);
     2912}
     2913
     2914
     2915
    27752916/**
    27762917 * Adds to the stack pointer.
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r102572 r102585  
    49944994VBOXSTRICTRC    iemRegRipRelativeJumpS32AndFinishClearingRF(PVMCPUCC pVCpu, uint8_t cbInstr, int32_t offNextInstr,
    49954995                                                            IEMMODE enmEffOpSize) RT_NOEXCEPT;
    4996 VBOXSTRICTRC    iemRegRipJumpU16AndFinishClearningRF(PVMCPUCC pVCpu, uint16_t uNewRip) RT_NOEXCEPT;
    4997 VBOXSTRICTRC    iemRegRipJumpU32AndFinishClearningRF(PVMCPUCC pVCpu, uint32_t uNewRip) RT_NOEXCEPT;
    4998 VBOXSTRICTRC    iemRegRipJumpU64AndFinishClearningRF(PVMCPUCC pVCpu, uint64_t uNewRip) RT_NOEXCEPT;
    49994996/** @} */
    50004997
  • trunk/src/VBox/VMM/include/IEMMc.h

    r102572 r102585  
    7373    return iemRegRipRelativeJumpS32AndFinishClearingRF(pVCpu, IEM_GET_INSTR_LEN(pVCpu), (a_i32), pVCpu->iem.s.enmEffOpSize)
    7474/** Sets RIP (may trigger \#GP), finishes the instruction and returns. */
    75 #define IEM_MC_SET_RIP_U16_AND_FINISH(a_u16NewIP)       return iemRegRipJumpU16AndFinishClearningRF((pVCpu), (a_u16NewIP))
     75#define IEM_MC_SET_RIP_U16_AND_FINISH(a_u16NewIP)       return iemRegRipJumpU16AndFinishClearingRF((pVCpu), (a_u16NewIP))
    7676/** Sets RIP (may trigger \#GP), finishes the instruction and returns. */
    77 #define IEM_MC_SET_RIP_U32_AND_FINISH(a_u32NewIP)       return iemRegRipJumpU32AndFinishClearningRF((pVCpu), (a_u32NewIP))
     77#define IEM_MC_SET_RIP_U32_AND_FINISH(a_u32NewIP)       return iemRegRipJumpU32AndFinishClearingRF((pVCpu), (a_u32NewIP))
    7878/** Sets RIP (may trigger \#GP), finishes the instruction and returns. */
    79 #define IEM_MC_SET_RIP_U64_AND_FINISH(a_u64NewIP)       return iemRegRipJumpU64AndFinishClearningRF((pVCpu), (a_u64NewIP))
     79#define IEM_MC_SET_RIP_U64_AND_FINISH(a_u64NewIP)       return iemRegRipJumpU64AndFinishClearingRF((pVCpu), (a_u64NewIP))
    8080
    8181#define IEM_MC_RAISE_DIVIDE_ERROR()                     return iemRaiseDivideError(pVCpu)
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