VirtualBox

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


Ignore:
Timestamp:
Jun 2, 2023 2:49:14 PM (20 months ago)
Author:
vboxsync
Message:

VMM/IEM: Refactored the enmCpuMode, uCpl, fBypassHandlers, fDisregardLock and fPendingInstruction* IEMCPU members into a single fExec member and associated IEM_F_XXX flag defines. Added more flags needed for recompiled execution. The fExec value is maintained as code is executed, so it does not need to be recalculated in the instruction loops. bugref:10369

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

Legend:

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

    r100020 r100052  
    165165
    166166/**
    167  * Calculates the CPU mode.
    168  *
    169  * This is mainly for updating IEMCPU::enmCpuMode.
    170  *
    171  * @returns CPU mode.
     167 * Calculates the IEM_F_MODE_X86_32BIT_FLAT flag.
     168 *
     169 * Checks if CS, SS, DS and SS are all wide open flat 32-bit segments. This will
     170 * reject expand down data segments and conforming code segments.
     171 *
     172 * ASSUMES that the CPU is in 32-bit mode.
     173 *
     174 * @returns IEM_F_MODE_X86_32BIT_FLAT or zero.
    172175 * @param   pVCpu               The cross context virtual CPU structure of the
    173176 *                              calling thread.
    174  */
    175 DECLINLINE(IEMMODE) iemCalcCpuMode(PVMCPUCC pVCpu) RT_NOEXCEPT
    176 {
    177     if (CPUMIsGuestIn64BitCodeEx(&pVCpu->cpum.GstCtx))
    178         return IEMMODE_64BIT;
    179     if (pVCpu->cpum.GstCtx.cs.Attr.n.u1DefBig) /** @todo check if this is correct... */
    180         return IEMMODE_32BIT;
    181     return IEMMODE_16BIT;
    182 }
    183 
    184 
    185 /**
    186  * Checks if CS, SS, DS and SS are all wide open flat 32-bit segments.
    187  *
    188  * This will reject expand down data segments and conforming code segments.
    189  *
    190  * @returns The indicator.
    191  * @param   pVCpu               The cross context virtual CPU structure of the
    192  *                              calling thread.
    193  */
    194 DECLINLINE(uint8_t) iemCalc32BitFlatIndicator(PVMCPUCC pVCpu) RT_NOEXCEPT
     177 * @sa      iemCalc32BitFlatIndicatorEsDs
     178 */
     179DECL_FORCE_INLINE(uint32_t) iemCalc32BitFlatIndicator(PVMCPUCC pVCpu) RT_NOEXCEPT
    195180{
    196181    AssertCompile(X86_SEL_TYPE_DOWN == X86_SEL_TYPE_CONF);
    197     return pVCpu->iem.s.enmCpuMode == IEMMODE_32BIT
    198         &&   (  (  pVCpu->cpum.GstCtx.es.Attr.u
     182    return (  (  pVCpu->cpum.GstCtx.es.Attr.u
    199183                 | pVCpu->cpum.GstCtx.cs.Attr.u
    200184                 | pVCpu->cpum.GstCtx.ss.Attr.u
     
    212196               | pVCpu->cpum.GstCtx.ds.u64Base)
    213197           == 0
    214         ? 1 : 0; /** @todo define a constant/flag for this. */
    215 }
    216 
    217 #ifndef IEM_WITH_OPAQUE_DECODER_STATE
    218 
    219 # if defined(VBOX_INCLUDED_vmm_dbgf_h) || defined(DOXYGEN_RUNNING) /* dbgf.ro.cEnabledHwBreakpoints */
    220 /**
    221  * Initializes the execution state.
    222  *
     198        && !(pVCpu->cpum.GstCtx.fExtrn & (CPUMCTX_EXTRN_ES | CPUMCTX_EXTRN_CS | CPUMCTX_EXTRN_SS | CPUMCTX_EXTRN_ES))
     199        ? IEM_F_MODE_X86_32BIT_FLAT : 0;
     200}
     201
     202
     203/**
     204 * Calculates the IEM_F_MODE_X86_32BIT_FLAT flag, ASSUMING the CS and SS are
     205 * flat already.
     206 *
     207 * This is used by sysenter.
     208 *
     209 * @returns IEM_F_MODE_X86_32BIT_FLAT or zero.
    223210 * @param   pVCpu               The cross context virtual CPU structure of the
    224211 *                              calling thread.
    225  * @param   fBypassHandlers     Whether to bypass access handlers.
     212 * @sa      iemCalc32BitFlatIndicator
     213 */
     214DECL_FORCE_INLINE(uint32_t) iemCalc32BitFlatIndicatorEsDs(PVMCPUCC pVCpu) RT_NOEXCEPT
     215{
     216    AssertCompile(X86_SEL_TYPE_DOWN == X86_SEL_TYPE_CONF);
     217    return (  (  pVCpu->cpum.GstCtx.es.Attr.u
     218                 | pVCpu->cpum.GstCtx.ds.Attr.u)
     219              & (X86_SEL_TYPE_ACCESSED | X86_SEL_TYPE_DOWN | X86DESCATTR_UNUSABLE | X86DESCATTR_G | X86DESCATTR_D | X86DESCATTR_P))
     220           ==   (X86_SEL_TYPE_ACCESSED | X86_SEL_TYPE_DOWN | X86DESCATTR_UNUSABLE | X86DESCATTR_G | X86DESCATTR_D | X86DESCATTR_P)
     221        &&    (  (pVCpu->cpum.GstCtx.es.u32Limit + 1)
     222               | (pVCpu->cpum.GstCtx.ds.u32Limit + 1))
     223           == 0
     224        &&    (  pVCpu->cpum.GstCtx.es.u64Base
     225               | pVCpu->cpum.GstCtx.ds.u64Base)
     226           == 0
     227        && !(pVCpu->cpum.GstCtx.fExtrn & (CPUMCTX_EXTRN_ES | CPUMCTX_EXTRN_CS | CPUMCTX_EXTRN_SS | CPUMCTX_EXTRN_ES))
     228        ? IEM_F_MODE_X86_32BIT_FLAT : 0;
     229}
     230
     231
     232/**
     233 * Calculates the IEM_F_MODE_XXX and CPL flags.
     234 *
     235 * @returns IEM_F_MODE_XXX
     236 * @param   pVCpu               The cross context virtual CPU structure of the
     237 *                              calling thread.
     238 */
     239DECL_FORCE_INLINE(uint32_t) iemCalcExecModeAndCplFlags(PVMCPUCC pVCpu) RT_NOEXCEPT
     240{
     241    /*
     242     * We're duplicates code from CPUMGetGuestCPL and CPUMIsGuestIn64BitCodeEx
     243     * here to try get this done as efficiently as possible.
     244     */
     245    IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CR0 | CPUMCTX_EXTRN_EFER | CPUMCTX_EXTRN_RFLAGS | CPUMCTX_EXTRN_SS | CPUMCTX_EXTRN_CS);
     246
     247    if (pVCpu->cpum.GstCtx.cr0 & X86_CR0_PE)
     248    {
     249        if (!pVCpu->cpum.GstCtx.eflags.Bits.u1VM)
     250        {
     251            Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.ss));
     252            uint32_t fExec = ((uint32_t)pVCpu->cpum.GstCtx.ss.Attr.n.u2Dpl << IEM_F_X86_CPL_SHIFT);
     253            if (pVCpu->cpum.GstCtx.cs.Attr.n.u1DefBig)
     254            {
     255                Assert(!pVCpu->cpum.GstCtx.cs.Attr.n.u1Long || !(pVCpu->cpum.GstCtx.msrEFER & MSR_K6_EFER_LMA));
     256                fExec |= IEM_F_MODE_X86_32BIT_PROT | iemCalc32BitFlatIndicator(pVCpu);
     257            }
     258            else if (   pVCpu->cpum.GstCtx.cs.Attr.n.u1Long
     259                     && (pVCpu->cpum.GstCtx.msrEFER & MSR_K6_EFER_LMA))
     260                fExec |= IEM_F_MODE_X86_64BIT;
     261            else if (IEM_GET_TARGET_CPU(pVCpu) >= IEMTARGETCPU_386)
     262                fExec |= IEM_F_MODE_X86_16BIT_PROT;
     263            else
     264                fExec |= IEM_F_MODE_X86_16BIT_PROT_PRE_386;
     265            return fExec;
     266        }
     267        return IEM_F_MODE_X86_16BIT_PROT_V86 | (UINT32_C(3) << IEM_F_X86_CPL_SHIFT);
     268    }
     269
     270    /* Real mode is zero; CPL set to 3 for VT-x real-mode emulation. */
     271    if (RT_LIKELY(!pVCpu->cpum.GstCtx.cs.Attr.n.u1DefBig))
     272    {
     273        if (IEM_GET_TARGET_CPU(pVCpu) >= IEMTARGETCPU_386)
     274            return IEM_F_MODE_X86_16BIT;
     275        return IEM_F_MODE_X86_16BIT_PRE_386;
     276    }
     277
     278    /* 32-bit unreal mode. */
     279    return IEM_F_MODE_X86_32BIT | iemCalc32BitFlatIndicator(pVCpu);
     280}
     281
     282
     283/**
     284 * Calculates the AMD-V and VT-x related context flags.
     285 *
     286 * @returns 0 or a combination of IEM_F_X86_CTX_IN_GUEST, IEM_F_X86_CTX_SVM and
     287 *          IEM_F_X86_CTX_VMX.
     288 * @param   pVCpu               The cross context virtual CPU structure of the
     289 *                              calling thread.
     290 */
     291DECL_FORCE_INLINE(uint32_t) iemCalcExecHwVirtFlags(PVMCPUCC pVCpu) RT_NOEXCEPT
     292{
     293    /*
     294     * This duplicates code from CPUMIsGuestVmxEnabled, CPUMIsGuestSvmEnabled
     295     * and CPUMIsGuestInNestedHwvirtMode to some extent.
     296     */
     297    IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_CR4 | CPUMCTX_EXTRN_EFER);
     298
     299    AssertCompile(X86_CR4_VMXE != MSR_K6_EFER_SVME);
     300    uint64_t const fTmp = (pVCpu->cpum.GstCtx.cr4     & X86_CR4_VMXE)
     301                        | (pVCpu->cpum.GstCtx.msrEFER & MSR_K6_EFER_SVME);
     302    if (RT_LIKELY(!fTmp))
     303        return 0; /* likely */
     304
     305    if (fTmp & X86_CR4_VMXE)
     306    {
     307        Assert(pVCpu->cpum.GstCtx.hwvirt.enmHwvirt == CPUMHWVIRT_VMX);
     308        if (pVCpu->cpum.GstCtx.hwvirt.vmx.fInVmxNonRootMode)
     309            return IEM_F_X86_CTX_VMX | IEM_F_X86_CTX_IN_GUEST;
     310        return IEM_F_X86_CTX_VMX;
     311    }
     312
     313    Assert(pVCpu->cpum.GstCtx.hwvirt.enmHwvirt == CPUMHWVIRT_SVM);
     314    if (pVCpu->cpum.GstCtx.hwvirt.svm.Vmcb.ctrl.u64InterceptCtrl & SVM_CTRL_INTERCEPT_VMRUN)
     315        return IEM_F_X86_CTX_SVM | IEM_F_X86_CTX_IN_GUEST;
     316    return IEM_F_X86_CTX_SVM;
     317}
     318
     319
     320/**
     321 * Calculates IEM_F_BRK_PENDING_XXX (IEM_F_PENDING_BRK_MASK) flags.
     322 *
     323 * @returns IEM_F_BRK_PENDING_XXX or zero.
     324 * @param   pVCpu               The cross context virtual CPU structure of the
     325 *                              calling thread.
     326 */
     327DECL_FORCE_INLINE(uint32_t) iemCalcExecDbgFlags(PVMCPUCC pVCpu) RT_NOEXCEPT
     328{
     329    IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_DR7);
     330
     331    if (RT_LIKELY(   !(pVCpu->cpum.GstCtx.dr[7] & X86_DR7_ENABLED_MASK)
     332                  && pVCpu->CTX_SUFF(pVM)->dbgf.ro.cEnabledHwBreakpoints == 0))
     333        return 0;
     334    return iemCalcExecDbgFlagsSlow(pVCpu);
     335}
     336
     337/**
     338 * Calculates the the IEM_F_XXX flags.
     339 *
     340 * @returns IEM_F_XXX combination match the current CPU state.
     341 * @param   pVCpu               The cross context virtual CPU structure of the
     342 *                              calling thread.
     343 */
     344DECL_FORCE_INLINE(uint32_t) iemCalcExecFlags(PVMCPUCC pVCpu) RT_NOEXCEPT
     345{
     346    return iemCalcExecModeAndCplFlags(pVCpu)
     347         | iemCalcExecHwVirtFlags(pVCpu)
     348         /* SMM is not yet implemented */
     349         | iemCalcExecDbgFlags(pVCpu)
     350         ;
     351}
     352
     353
     354/**
     355 * Re-calculates the MODE and CPL parts of IEMCPU::fExec.
     356 *
     357 * @param   pVCpu               The cross context virtual CPU structure of the
     358 *                              calling thread.
     359 */
     360DECL_FORCE_INLINE(void) iemRecalcExecModeAndCplFlags(PVMCPUCC pVCpu)
     361{
     362    pVCpu->iem.s.fExec = (pVCpu->iem.s.fExec & ~(IEM_F_MODE_MASK | IEM_F_X86_CPL_MASK))
     363                       | iemCalcExecModeAndCplFlags(pVCpu);
     364}
     365
     366
     367/**
     368 * Re-calculates the IEM_F_PENDING_BRK_MASK part of IEMCPU::fExec.
     369 *
     370 * @param   pVCpu               The cross context virtual CPU structure of the
     371 *                              calling thread.
     372 */
     373DECL_FORCE_INLINE(void) iemRecalcExecDbgFlags(PVMCPUCC pVCpu)
     374{
     375    pVCpu->iem.s.fExec = (pVCpu->iem.s.fExec & ~IEM_F_PENDING_BRK_MASK)
     376                       | iemCalcExecDbgFlags(pVCpu);
     377}
     378
     379
     380#ifndef IEM_WITH_OPAQUE_DECODER_STATE
     381
     382# if defined(VBOX_INCLUDED_vmm_dbgf_h) || defined(DOXYGEN_RUNNING) /* dbgf.ro.cEnabledHwBreakpoints */
     383/**
     384 * Initializes the execution state.
     385 *
     386 * @param   pVCpu               The cross context virtual CPU structure of the
     387 *                              calling thread.
     388 * @param   fExecOpts           Optional execution flags:
     389 *                                  - IEM_F_BYPASS_HANDLERS
     390 *                                  - IEM_F_X86_DISREGARD_LOCK
    226391 *
    227392 * @remarks Callers of this must call iemUninitExec() to undo potentially fatal
    228393 *          side-effects in strict builds.
    229394 */
    230 DECLINLINE(void) iemInitExec(PVMCPUCC pVCpu, bool fBypassHandlers) RT_NOEXCEPT
     395DECLINLINE(void) iemInitExec(PVMCPUCC pVCpu, uint32_t fExecOpts) RT_NOEXCEPT
    231396{
    232397    IEM_CTX_ASSERT(pVCpu, IEM_CPUMCTX_EXTRN_EXEC_DECODED_NO_MEM_MASK);
     
    241406    Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.tr));
    242407
    243     pVCpu->iem.s.uCpl               = CPUMGetGuestCPL(pVCpu);
    244     pVCpu->iem.s.enmCpuMode         = iemCalcCpuMode(pVCpu);
     408    pVCpu->iem.s.fExec = iemCalcExecFlags(pVCpu) | fExecOpts;
    245409#  ifdef VBOX_STRICT
    246410    pVCpu->iem.s.enmDefAddrMode     = (IEMMODE)0xfe;
     
    275439    pVCpu->iem.s.iNextMapping       = 0;
    276440    pVCpu->iem.s.rcPassUp           = VINF_SUCCESS;
    277     pVCpu->iem.s.fBypassHandlers                = fBypassHandlers;
    278     pVCpu->iem.s.fDisregardLock                 = false;
    279     pVCpu->iem.s.fPendingInstructionBreakpoints = false;
    280     pVCpu->iem.s.fPendingDataBreakpoints        = false;
    281     pVCpu->iem.s.fPendingIoBreakpoints          = false;
    282     if (RT_LIKELY(   !(pVCpu->cpum.GstCtx.dr[7] & X86_DR7_ENABLED_MASK)
    283                   && pVCpu->CTX_SUFF(pVM)->dbgf.ro.cEnabledHwBreakpoints == 0))
    284     { /* likely */ }
    285     else
    286         iemInitPendingBreakpointsSlow(pVCpu);
    287441}
    288442# endif /* VBOX_INCLUDED_vmm_dbgf_h */
     
    302456DECLINLINE(void) iemReInitExec(PVMCPUCC pVCpu, uint8_t cbInstr) RT_NOEXCEPT
    303457{
    304     pVCpu->iem.s.uCpl             = CPUMGetGuestCPL(pVCpu);
    305     pVCpu->iem.s.enmCpuMode       = iemCalcCpuMode(pVCpu);
     458    pVCpu->iem.s.fExec = iemCalcExecFlags(pVCpu) | (pVCpu->iem.s.fExec & IEM_F_USER_OPTS);
    306459    iemOpcodeFlushHeavy(pVCpu, cbInstr);
    307460}
     
    374527     * Check for hardware instruction breakpoints.
    375528     */
    376     if (RT_LIKELY(!pVCpu->iem.s.fPendingInstructionBreakpoints))
     529    if (RT_LIKELY(!(pVCpu->iem.s.fExec & IEM_F_PENDING_BRK_INSTR)))
    377530    { /* likely */ }
    378531    else
     
    414567     * Check for hardware instruction breakpoints.
    415568     */
    416     if (RT_LIKELY(!pVCpu->iem.s.fPendingInstructionBreakpoints))
     569    if (RT_LIKELY(!(pVCpu->iem.s.fExec & IEM_F_PENDING_BRK_INSTR)))
    417570    { /* likely */ }
    418571    else
     
    13391492    {
    13401493        /* VT-x (Intel 3960x) observed doing something like this. */
    1341         pSReg->Attr.u   = X86DESCATTR_UNUSABLE | X86DESCATTR_G | X86DESCATTR_D | (pVCpu->iem.s.uCpl << X86DESCATTR_DPL_SHIFT);
     1494        pSReg->Attr.u   = X86DESCATTR_UNUSABLE | X86DESCATTR_G | X86DESCATTR_D | (IEM_GET_CPL(pVCpu) << X86DESCATTR_DPL_SHIFT);
    13421495        pSReg->u32Limit = UINT32_MAX;
    13431496        pSReg->u64Base  = 0;
     
    13711524DECLINLINE(void) iemRecalEffOpSize(PVMCPUCC pVCpu) RT_NOEXCEPT
    13721525{
    1373     switch (pVCpu->iem.s.enmCpuMode)
     1526    switch (IEM_GET_CPU_MODE(pVCpu))
    13741527    {
    13751528        case IEMMODE_16BIT:
     
    14081561DECLINLINE(void) iemRecalEffOpSize64Default(PVMCPUCC pVCpu) RT_NOEXCEPT
    14091562{
    1410     Assert(pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT);
     1563    Assert(IEM_IS_64BIT_CODE(pVCpu));
    14111564    pVCpu->iem.s.enmDefOpSize = IEMMODE_64BIT;
    14121565    if ((pVCpu->iem.s.fPrefixes & (IEM_OP_PRF_SIZE_REX_W | IEM_OP_PRF_SIZE_OP)) != IEM_OP_PRF_SIZE_OP)
     
    14271580DECLINLINE(void) iemRecalEffOpSize64DefaultAndIntelIgnoresOpSizePrefix(PVMCPUCC pVCpu) RT_NOEXCEPT
    14281581{
    1429     Assert(pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT);
     1582    Assert(IEM_IS_64BIT_CODE(pVCpu));
    14301583    pVCpu->iem.s.enmDefOpSize = IEMMODE_64BIT;
    14311584    if (   (pVCpu->iem.s.fPrefixes & (IEM_OP_PRF_SIZE_REX_W | IEM_OP_PRF_SIZE_OP)) != IEM_OP_PRF_SIZE_OP
     
    17451898DECLINLINE(RTGCPTR) iemRegGetEffRsp(PCVMCPU pVCpu) RT_NOEXCEPT
    17461899{
    1747     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     1900    if (IEM_IS_64BIT_CODE(pVCpu))
    17481901        return pVCpu->cpum.GstCtx.rsp;
    17491902    if (pVCpu->cpum.GstCtx.ss.Attr.n.u1DefBig)
     
    17741927    uint64_t const uRipNext = uRipPrev + cbInstr;
    17751928    if (RT_LIKELY(   !((uRipNext ^ uRipPrev) & (RT_BIT_64(32) | RT_BIT_64(16)))
    1776                   || pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT))
     1929                  || IEM_IS_64BIT_CODE(pVCpu)))
    17771930        pVCpu->cpum.GstCtx.rip = uRipNext;
    17781931    else if (IEM_GET_TARGET_CPU(pVCpu) >= IEMTARGETCPU_386)
     
    20082161DECLINLINE(void) iemRegAddToRsp(PVMCPUCC pVCpu, uint8_t cbToAdd) RT_NOEXCEPT
    20092162{
    2010     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     2163    if (IEM_IS_64BIT_CODE(pVCpu))
    20112164        pVCpu->cpum.GstCtx.rsp += cbToAdd;
    20122165    else if (pVCpu->cpum.GstCtx.ss.Attr.n.u1DefBig)
     
    20252178DECLINLINE(void) iemRegSubFromRsp(PVMCPUCC pVCpu, uint8_t cbToSub) RT_NOEXCEPT
    20262179{
    2027     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     2180    if (IEM_IS_64BIT_CODE(pVCpu))
    20282181        pVCpu->cpum.GstCtx.rsp -= cbToSub;
    20292182    else if (pVCpu->cpum.GstCtx.ss.Attr.n.u1DefBig)
     
    20432196DECLINLINE(void) iemRegAddToRspEx(PCVMCPU pVCpu, PRTUINT64U pTmpRsp, uint16_t cbToAdd) RT_NOEXCEPT
    20442197{
    2045     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     2198    if (IEM_IS_64BIT_CODE(pVCpu))
    20462199        pTmpRsp->u           += cbToAdd;
    20472200    else if (pVCpu->cpum.GstCtx.ss.Attr.n.u1DefBig)
     
    20632216DECLINLINE(void) iemRegSubFromRspEx(PCVMCPU pVCpu, PRTUINT64U pTmpRsp, uint16_t cbToSub) RT_NOEXCEPT
    20642217{
    2065     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     2218    if (IEM_IS_64BIT_CODE(pVCpu))
    20662219        pTmpRsp->u          -= cbToSub;
    20672220    else if (pVCpu->cpum.GstCtx.ss.Attr.n.u1DefBig)
     
    20872240    uTmpRsp.u = pVCpu->cpum.GstCtx.rsp;
    20882241
    2089     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     2242    if (IEM_IS_64BIT_CODE(pVCpu))
    20902243        GCPtrTop = uTmpRsp.u            -= cbItem;
    20912244    else if (pVCpu->cpum.GstCtx.ss.Attr.n.u1DefBig)
     
    21132266    uTmpRsp.u = pVCpu->cpum.GstCtx.rsp;
    21142267
    2115     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     2268    if (IEM_IS_64BIT_CODE(pVCpu))
    21162269    {
    21172270        GCPtrTop = uTmpRsp.u;
     
    21462299    RTGCPTR GCPtrTop;
    21472300
    2148     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     2301    if (IEM_IS_64BIT_CODE(pVCpu))
    21492302        GCPtrTop = pTmpRsp->u          -= cbItem;
    21502303    else if (pVCpu->cpum.GstCtx.ss.Attr.n.u1DefBig)
     
    21682321{
    21692322    RTGCPTR GCPtrTop;
    2170     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     2323    if (IEM_IS_64BIT_CODE(pVCpu))
    21712324    {
    21722325        GCPtrTop = pTmpRsp->u;
     
    26542807{
    26552808    AssertCompile(X86_CR0_AM == X86_EFL_AC);
    2656     return pVCpu->iem.s.uCpl == 3
     2809    return IEM_GET_CPL(pVCpu) == 3
    26572810        && (((uint32_t)pVCpu->cpum.GstCtx.cr0 & pVCpu->cpum.GstCtx.eflags.u) & X86_CR0_AM);
    26582811}
     
    26762829    IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_SREG_FROM_IDX(iSegReg));
    26772830
    2678     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     2831    if (IEM_IS_64BIT_CODE(pVCpu))
    26792832        *pu64BaseAddr = iSegReg < X86_SREG_FS ? 0 : pHid->u64Base;
    26802833    else
     
    26902843        if (   (   (pHid->Attr.n.u4Type & X86_SEL_TYPE_CODE)
    26912844                || !(pHid->Attr.n.u4Type & X86_SEL_TYPE_WRITE) )
    2692             &&  pVCpu->iem.s.enmCpuMode != IEMMODE_64BIT )
     2845            && !IEM_IS_64BIT_CODE(pVCpu) )
    26932846            return iemRaiseSelectorInvalidAccess(pVCpu, iSegReg, IEM_ACCESS_DATA_W);
    26942847        *pu64BaseAddr = pHid->u64Base;
     
    27162869    IEM_CTX_ASSERT(pVCpu, CPUMCTX_EXTRN_SREG_FROM_IDX(iSegReg));
    27172870
    2718     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     2871    if (IEM_IS_64BIT_CODE(pVCpu))
    27192872        *pu64BaseAddr = iSegReg < X86_SREG_FS ? 0 : pHid->u64Base;
    27202873    else
     
    27612914                                  GCPhysMem,
    27622915                                  RT_BOOL(fAccess & IEM_ACCESS_TYPE_WRITE),
    2763                                   pVCpu->iem.s.fBypassHandlers,
     2916                                  RT_BOOL(pVCpu->iem.s.fExec & IEM_F_BYPASS_HANDLERS),
    27642917                                  ppvMem,
    27652918                                  pLock);
     
    28022955     * 64-bit mode is simpler.
    28032956     */
    2804     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     2957    if (IEM_IS_64BIT_CODE(pVCpu))
    28052958    {
    28062959        if (iSegReg >= X86_SREG_FS && iSegReg != UINT8_MAX)
     
    28803033     * 64-bit mode is simpler.
    28813034     */
    2882     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     3035    if (IEM_IS_64BIT_CODE(pVCpu))
    28833036    {
    28843037        if (iSegReg >= X86_SREG_FS)
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r99988 r100052  
    539539typedef struct IEMTB *PIEMTB;
    540540
     541/** @name IEM_F_XXX - Execution mode flags (IEMCPU::fExec, IEMTB::fFlags).
     542 *
     543 * These flags are set when entering IEM and adjusted as code is executed, such
     544 * that they will always contain the current values as instructions are
     545 * finished.
     546 *
     547 * In recompiled execution mode, (most of) these flags are included in the
     548 * translation block selection key and stored in IEMTB::fFlags alongside the
     549 * IEMTB_F_XXX flags.  The latter flags uses bits 31 thru 24, which are all zero
     550 * in IEMCPU::fExec.
     551 *
     552 * @{ */
     553/** Mode: The block target mode mask. */
     554#define IEM_F_MODE_MASK                     UINT32_C(0x0000001f)
     555/** Mode: The IEMMODE part of the IEMTB_F_MODE_MASK value. */
     556#define IEM_F_MODE_CPUMODE_MASK             UINT32_C(0x00000003)
     557/** X86 Mode: Bit used to indicating pre-386 CPU in 16-bit mode (for eliminating
     558 * conditional in EIP/IP updating), and flat wide open CS, SS DS, and ES in
     559 * 32-bit mode (for simplifying most memory accesses). */
     560#define IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK UINT32_C(0x00000004)
     561/** X86 Mode: Bit indicating protected mode. */
     562#define IEM_F_MODE_X86_PROT_MASK            UINT32_C(0x00000008)
     563/** X86 Mode: Bit used to indicate virtual 8086 mode (only 16-bit). */
     564#define IEM_F_MODE_X86_V86_MASK             UINT32_C(0x00000010)
     565
     566/** X86 Mode: 16-bit on 386 or later. */
     567#define IEM_F_MODE_X86_16BIT                UINT32_C(0x00000000)
     568/** X86 Mode: 80286, 80186 and 8086/88 targetting blocks (EIP update opt). */
     569#define IEM_F_MODE_X86_16BIT_PRE_386        UINT32_C(0x00000004)
     570/** X86 Mode: 16-bit protected mode on 386 or later. */
     571#define IEM_F_MODE_X86_16BIT_PROT           UINT32_C(0x00000008)
     572/** X86 Mode: 16-bit protected mode on 386 or later. */
     573#define IEM_F_MODE_X86_16BIT_PROT_PRE_386   UINT32_C(0x0000000c)
     574/** X86 Mode: 16-bit virtual 8086 protected mode (on 386 or later). */
     575#define IEM_F_MODE_X86_16BIT_PROT_V86       UINT32_C(0x00000018)
     576
     577/** X86 Mode: 32-bit on 386 or later. */
     578#define IEM_F_MODE_X86_32BIT                UINT32_C(0x00000001)
     579/** X86 Mode: 32-bit mode with wide open flat CS, SS, DS and ES. */
     580#define IEM_F_MODE_X86_32BIT_FLAT           UINT32_C(0x00000005)
     581/** X86 Mode: 32-bit protected mode. */
     582#define IEM_F_MODE_X86_32BIT_PROT           UINT32_C(0x00000009)
     583/** X86 Mode: 32-bit protected mode with wide open flat CS, SS, DS and ES. */
     584#define IEM_F_MODE_X86_32BIT_PROT_FLAT      UINT32_C(0x0000000d)
     585
     586/** X86 Mode: 64-bit (includes protected, but not the flat bit). */
     587#define IEM_F_MODE_X86_64BIT                UINT32_C(0x0000000a)
     588
     589
     590/** Bypass access handlers when set. */
     591#define IEM_F_BYPASS_HANDLERS               UINT32_C(0x00010000)
     592/** Have pending hardware instruction breakpoints.   */
     593#define IEM_F_PENDING_BRK_INSTR             UINT32_C(0x00020000)
     594/** Have pending hardware data breakpoints.   */
     595#define IEM_F_PENDING_BRK_DATA              UINT32_C(0x00040000)
     596
     597/** X86: Have pending hardware I/O breakpoints. */
     598#define IEM_F_PENDING_BRK_X86_IO            UINT32_C(0x00000400)
     599/** X86: Disregard the lock prefix (implied or not) when set. */
     600#define IEM_F_X86_DISREGARD_LOCK            UINT32_C(0x00000800)
     601
     602/** Pending breakpoint mask (what iemCalcExecDbgFlags works out). */
     603#define IEM_F_PENDING_BRK_MASK              (IEM_F_PENDING_BRK_INSTR | IEM_F_PENDING_BRK_DATA | IEM_F_PENDING_BRK_X86_IO)
     604
     605/** Caller configurable options. */
     606#define IEM_F_USER_OPTS                     (IEM_F_BYPASS_HANDLERS | IEM_F_X86_DISREGARD_LOCK)
     607
     608/** X86: The current protection level (CPL) shift factor.   */
     609#define IEM_F_X86_CPL_SHIFT                 8
     610/** X86: The current protection level (CPL) mask. */
     611#define IEM_F_X86_CPL_MASK                  UINT32_C(0x00000300)
     612/** X86: The current protection level (CPL) shifted mask. */
     613#define IEM_F_X86_CPL_SMASK                 UINT32_C(0x00000003)
     614
     615/** X86 execution context.
     616 * The IEM_F_X86_CTX_XXX values are individual flags that can be combined (with
     617 * the exception of IEM_F_X86_CTX_NORMAL).  This allows running VMs from SMM
     618 * mode. */
     619#define IEM_F_X86_CTX_MASK                  UINT32_C(0x0000f000)
     620/** X86 context: Plain regular execution context. */
     621#define IEM_F_X86_CTX_NORMAL                UINT32_C(0x00000000)
     622/** X86 context: VT-x enabled. */
     623#define IEM_F_X86_CTX_VMX                   UINT32_C(0x00001000)
     624/** X86 context: AMD-V enabled. */
     625#define IEM_F_X86_CTX_SVM                   UINT32_C(0x00002000)
     626/** X86 context: In AMD-V or VT-x guest mode. */
     627#define IEM_F_X86_CTX_IN_GUEST              UINT32_C(0x00004000)
     628/** X86 context: System management mode (SMM). */
     629#define IEM_F_X86_CTX_SMM                   UINT32_C(0x00008000)
     630
     631/** @todo Add TF+RF+INHIBIT indicator(s), so we can eliminate the conditional in
     632 * iemRegFinishClearingRF() most for most situations (CPUMCTX_DBG_HIT_DRX_MASK
     633 * and CPUMCTX_DBG_DBGF_MASK are covered by the IEM_F_PENDING_BRK_XXX bits
     634 * alread). */
     635
     636/** @todo Add TF+RF+INHIBIT indicator(s), so we can eliminate the conditional in
     637 *        iemRegFinishClearingRF() most for most situations
     638 *        (CPUMCTX_DBG_HIT_DRX_MASK and CPUMCTX_DBG_DBGF_MASK are covered by
     639 *        the IEM_F_PENDING_BRK_XXX bits alread). */
     640
     641/** @} */
     642
     643
     644/** @name IEMTB_F_XXX - Translation block flags (IEMTB::fFlags).
     645 *
     646 * Extends the IEM_F_XXX flags (subject to IEMTB_F_IEM_F_MASK) to make up the
     647 * translation block flags.  The combined flag mask (subject to
     648 * IEMTB_F_KEY_MASK) is used as part of the lookup key for translation blocks.
     649 *
     650 * @{ */
     651/** Mask of IEM_F_XXX flags included in IEMTB_F_XXX. */
     652#define IEMTB_F_IEM_F_MASK              UINT32_C(0x00ffffff)
     653
     654/** Type: The block type mask. */
     655#define IEMTB_F_TYPE_MASK               UINT32_C(0x03000000)
     656/** Type: Purly threaded recompiler (via tables). */
     657#define IEMTB_F_TYPE_THREADED           UINT32_C(0x01000000)
     658/** Type: Native recompilation.  */
     659#define IEMTB_F_TYPE_NATIVE             UINT32_C(0x02000000)
     660
     661/** State mask.  */
     662#define IEMTB_F_STATE_MASK              UINT32_C(0x0c000000)
     663/** State: Compiling. */
     664#define IEMTB_F_STATE_COMPILING         UINT32_C(0x04000000)
     665/** State: Ready.  */
     666#define IEMTB_F_STATE_READY             UINT32_C(0x08000000)
     667/** State: Obsolete, can be deleted when we're sure it's not used any longer. */
     668#define IEMTB_F_STATE_OBSOLETE          UINT32_C(0x0c000000)
     669
     670/** Mask of the IEMTB_F_XXX flags that are part of the TB lookup key.
     671 * @note We don't   */
     672#define IEMTB_F_KEY_MASK                ((UINT32_C(0xffffffff) & ~IEM_F_X86_CTX_MASK) | IEM_F_X86_CTX_SMM)
     673/** @} */
     674
     675AssertCompile( (IEM_F_MODE_X86_16BIT              & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
     676AssertCompile(!(IEM_F_MODE_X86_16BIT              & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
     677AssertCompile(!(IEM_F_MODE_X86_16BIT              & IEM_F_MODE_X86_PROT_MASK));
     678AssertCompile(!(IEM_F_MODE_X86_16BIT              & IEM_F_MODE_X86_V86_MASK));
     679AssertCompile( (IEM_F_MODE_X86_16BIT_PRE_386      & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
     680AssertCompile(  IEM_F_MODE_X86_16BIT_PRE_386      & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
     681AssertCompile(!(IEM_F_MODE_X86_16BIT_PRE_386      & IEM_F_MODE_X86_PROT_MASK));
     682AssertCompile(!(IEM_F_MODE_X86_16BIT_PRE_386      & IEM_F_MODE_X86_V86_MASK));
     683AssertCompile( (IEM_F_MODE_X86_16BIT_PROT         & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
     684AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT         & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
     685AssertCompile(  IEM_F_MODE_X86_16BIT_PROT         & IEM_F_MODE_X86_PROT_MASK);
     686AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT         & IEM_F_MODE_X86_V86_MASK));
     687AssertCompile( (IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
     688AssertCompile(  IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
     689AssertCompile(  IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_X86_PROT_MASK);
     690AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_X86_V86_MASK));
     691AssertCompile(  IEM_F_MODE_X86_16BIT_PROT_V86     & IEM_F_MODE_X86_PROT_MASK);
     692AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT_V86     & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
     693AssertCompile(  IEM_F_MODE_X86_16BIT_PROT_V86     & IEM_F_MODE_X86_V86_MASK);
     694
     695AssertCompile( (IEM_F_MODE_X86_32BIT              & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
     696AssertCompile(!(IEM_F_MODE_X86_32BIT              & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
     697AssertCompile(!(IEM_F_MODE_X86_32BIT              & IEM_F_MODE_X86_PROT_MASK));
     698AssertCompile( (IEM_F_MODE_X86_32BIT_FLAT         & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
     699AssertCompile(  IEM_F_MODE_X86_32BIT_FLAT         & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
     700AssertCompile(!(IEM_F_MODE_X86_32BIT_FLAT         & IEM_F_MODE_X86_PROT_MASK));
     701AssertCompile( (IEM_F_MODE_X86_32BIT_PROT         & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
     702AssertCompile(!(IEM_F_MODE_X86_32BIT_PROT         & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
     703AssertCompile(  IEM_F_MODE_X86_32BIT_PROT         & IEM_F_MODE_X86_PROT_MASK);
     704AssertCompile( (IEM_F_MODE_X86_32BIT_PROT_FLAT    & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
     705AssertCompile(  IEM_F_MODE_X86_32BIT_PROT_FLAT    & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
     706AssertCompile(  IEM_F_MODE_X86_32BIT_PROT_FLAT    & IEM_F_MODE_X86_PROT_MASK);
     707
     708AssertCompile( (IEM_F_MODE_X86_64BIT              & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_64BIT);
     709AssertCompile(  IEM_F_MODE_X86_64BIT              & IEM_F_MODE_X86_PROT_MASK);
     710AssertCompile(!(IEM_F_MODE_X86_64BIT              & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
     711
    541712
    542713/**
     
    551722     * source of these codes will perform appropriate sanity checks. */
    552723    int32_t                 rcPassUp;                                                                       /* 0x00 */
    553 
    554     /** The current CPU execution mode (CS). */
    555     IEMMODE                 enmCpuMode;                                                                     /* 0x04 */
    556     /** The CPL. */
    557     uint8_t                 uCpl;                                                                           /* 0x05 */
    558 
    559     /** Whether to bypass access handlers or not. */
    560     bool                    fBypassHandlers : 1;                                                            /* 0x06.0 */
    561     /** Whether to disregard the lock prefix (implied or not). */
    562     bool                    fDisregardLock : 1;                                                             /* 0x06.1 */
    563     /** Whether there are pending hardware instruction breakpoints. */
    564     bool                    fPendingInstructionBreakpoints : 1;                                             /* 0x06.2 */
    565     /** Whether there are pending hardware data breakpoints. */
    566     bool                    fPendingDataBreakpoints : 1;                                                    /* 0x06.3 */
    567     /** Whether there are pending hardware I/O breakpoints. */
    568     bool                    fPendingIoBreakpoints : 1;                                                      /* 0x06.4 */
    569 
    570     /* Unused/padding */
    571     bool                    fUnused;                                                                        /* 0x07 */
     724    /** Execution flag, IEM_F_XXX. */
     725    uint32_t                fExec;                                                                          /* 0x04 */
    572726
    573727    /** @name Decoder state.
     
    35153669
    35163670/**
     3671 * Gets the CPU mode (from fExec) as a IEMMODE value.
     3672 *
     3673 * @returns IEMMODE
     3674 * @param   a_pVCpu         The cross context virtual CPU structure of the calling thread.
     3675 */
     3676#define IEM_GET_CPU_MODE(a_pVCpu)           ((a_pVCpu)->iem.s.fExec & IEM_F_MODE_CPUMODE_MASK)
     3677
     3678/**
    35173679 * Check if we're currently executing in real or virtual 8086 mode.
    3518  *
    3519  * @returns @c true if it is, @c false if not.
    3520  * @param   a_pVCpu         The IEM state of the current CPU.
    3521  */
    3522 #define IEM_IS_REAL_OR_V86_MODE(a_pVCpu)    (CPUMIsGuestInRealOrV86ModeEx(IEM_GET_CTX(a_pVCpu)))
    3523 
    3524 /**
    3525  * Check if we're currently executing in virtual 8086 mode.
    35263680 *
    35273681 * @returns @c true if it is, @c false if not.
    35283682 * @param   a_pVCpu         The cross context virtual CPU structure of the calling thread.
    35293683 */
    3530 #define IEM_IS_V86_MODE(a_pVCpu)            (CPUMIsGuestInV86ModeEx(IEM_GET_CTX(a_pVCpu)))
    3531 
    3532 /**
    3533  * Check if we're currently executing in long mode.
     3684#define IEM_IS_REAL_OR_V86_MODE(a_pVCpu)    (CPUMIsGuestInRealOrV86ModeEx(IEM_GET_CTX(a_pVCpu)))
     3685
     3686/**
     3687 * Check if we're currently executing in virtual 8086 mode.
    35343688 *
    35353689 * @returns @c true if it is, @c false if not.
    35363690 * @param   a_pVCpu         The cross context virtual CPU structure of the calling thread.
    35373691 */
    3538 #define IEM_IS_LONG_MODE(a_pVCpu)           (CPUMIsGuestInLongModeEx(IEM_GET_CTX(a_pVCpu)))
    3539 
    3540 /**
    3541  * Check if we're currently executing in a 64-bit code segment.
     3692#define IEM_IS_V86_MODE(a_pVCpu)            (CPUMIsGuestInV86ModeEx(IEM_GET_CTX(a_pVCpu)))
     3693
     3694/**
     3695 * Check if we're currently executing in long mode.
    35423696 *
    35433697 * @returns @c true if it is, @c false if not.
    35443698 * @param   a_pVCpu         The cross context virtual CPU structure of the calling thread.
    35453699 */
    3546 #define IEM_IS_64BIT_CODE(a_pVCpu)          (CPUMIsGuestIn64BitCodeEx(IEM_GET_CTX(a_pVCpu)))
    3547 
    3548 /**
    3549  * Check if we're currently executing in real mode.
     3700#define IEM_IS_LONG_MODE(a_pVCpu)           (CPUMIsGuestInLongModeEx(IEM_GET_CTX(a_pVCpu)))
     3701
     3702/**
     3703 * Check if we're currently executing in a 16-bit code segment.
    35503704 *
    35513705 * @returns @c true if it is, @c false if not.
    35523706 * @param   a_pVCpu         The cross context virtual CPU structure of the calling thread.
    35533707 */
     3708#define IEM_IS_16BIT_CODE(a_pVCpu)          (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_16BIT)
     3709
     3710/**
     3711 * Check if we're currently executing in a 32-bit code segment.
     3712 *
     3713 * @returns @c true if it is, @c false if not.
     3714 * @param   a_pVCpu         The cross context virtual CPU structure of the calling thread.
     3715 */
     3716#define IEM_IS_32BIT_CODE(a_pVCpu)          (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_32BIT)
     3717
     3718/**
     3719 * Check if we're currently executing in a 64-bit code segment.
     3720 *
     3721 * @returns @c true if it is, @c false if not.
     3722 * @param   a_pVCpu         The cross context virtual CPU structure of the calling thread.
     3723 */
     3724#define IEM_IS_64BIT_CODE(a_pVCpu)          (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_64BIT)
     3725
     3726/**
     3727 * Check if we're currently executing in real mode.
     3728 *
     3729 * @returns @c true if it is, @c false if not.
     3730 * @param   a_pVCpu         The cross context virtual CPU structure of the calling thread.
     3731 */
    35543732#define IEM_IS_REAL_MODE(a_pVCpu)           (CPUMIsGuestInRealModeEx(IEM_GET_CTX(a_pVCpu)))
     3733
     3734/**
     3735 * Gets the current protection level (CPL).
     3736 *
     3737 * @returns 0..3
     3738 * @param   a_pVCpu         The cross context virtual CPU structure of the calling thread.
     3739 */
     3740#define IEM_GET_CPL(a_pVCpu)                (((a_pVCpu)->iem.s.fExec >> IEM_F_X86_CPL_SHIFT) & IEM_F_X86_CPL_SMASK)
     3741
     3742/**
     3743 * Sets the current protection level (CPL).
     3744 *
     3745 * @param   a_pVCpu         The cross context virtual CPU structure of the calling thread.
     3746 */
     3747#define IEM_SET_CPL(a_pVCpu, a_uCpl) \
     3748    do { (a_pVCpu)->iem.s.fExec = ((a_pVCpu)->iem.s.fExec & ~IEM_F_X86_CPL_MASK) | ((a_uCpl) << IEM_F_X86_CPL_SHIFT); } while (0)
    35553749
    35563750/**
     
    36383832 */
    36393833#define IEM_GET_EFFECTIVE_VVVV(a_pVCpu) \
    3640     ((a_pVCpu)->iem.s.enmCpuMode == IEMMODE_64BIT ? (a_pVCpu)->iem.s.uVex3rdReg : (a_pVCpu)->iem.s.uVex3rdReg & 7)
     3834    (IEM_IS_64BIT_CODE(a_pVCpu) ? (a_pVCpu)->iem.s.uVex3rdReg : (a_pVCpu)->iem.s.uVex3rdReg & 7)
    36413835
    36423836
     
    38664060/** @} */
    38674061
    3868 void                    iemInitPendingBreakpointsSlow(PVMCPUCC pVCpu);
     4062uint32_t                iemCalcExecDbgFlagsSlow(PVMCPUCC pVCpu);
    38694063
    38704064
  • trunk/src/VBox/VMM/include/IEMMc.h

    r99992 r100052  
    142142#define IEM_MC_RAISE_GP0_IF_CPL_NOT_ZERO() \
    143143    do { \
    144         if (RT_LIKELY(pVCpu->iem.s.uCpl == 0)) { /* probable */ } \
     144        if (RT_LIKELY(IEM_GET_CPL(pVCpu) == 0)) { /* probable */ } \
    145145        else return iemRaiseGeneralProtectionFault0(pVCpu); \
    146146    } while (0)
     
    152152#define IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT() \
    153153    do { \
    154         if (RT_LIKELY(   ((pVCpu->cpum.GstCtx.cr4 & X86_CR4_FSGSBASE) | pVCpu->iem.s.enmCpuMode) \
     154        if (RT_LIKELY(   ((pVCpu->cpum.GstCtx.cr4 & X86_CR4_FSGSBASE) | IEM_GET_CPU_MODE(pVCpu)) \
    155155                      == (X86_CR4_FSGSBASE | IEMMODE_64BIT))) \
    156156        { /* probable */ } \
  • trunk/src/VBox/VMM/include/IEMOpHlp.h

    r99958 r100052  
    346346    do \
    347347    { \
    348         if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT) \
     348        if (!IEM_IS_64BIT_CODE(pVCpu)) \
     349        { /* likely */ } \
     350        else \
    349351            return IEMOP_RAISE_INVALID_OPCODE(); \
    350352    } while (0)
     
    355357    do \
    356358    { \
    357         if (pVCpu->iem.s.enmCpuMode != IEMMODE_64BIT) \
     359        if (IEM_IS_64BIT_CODE(pVCpu)) \
     360        { /* likely */ } \
     361        else \
    358362            return IEMOP_RAISE_INVALID_OPCODE(); \
    359363    } while (0)
     
    363367    do \
    364368    { \
    365         if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT) \
     369        if (IEM_IS_64BIT_CODE(pVCpu)) \
    366370            iemRecalEffOpSize64Default(pVCpu); \
    367371    } while (0)
     
    372376    do \
    373377    { \
    374         if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT) \
     378        if (IEM_IS_64BIT_CODE(pVCpu)) \
    375379            iemRecalEffOpSize64DefaultAndIntelIgnoresOpSizePrefix(pVCpu); \
    376380    } while (0)
     
    380384    do \
    381385    { \
    382         if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT) \
     386        if (IEM_IS_64BIT_CODE(pVCpu)) \
    383387            pVCpu->iem.s.enmEffOpSize = pVCpu->iem.s.enmDefOpSize = IEMMODE_64BIT; \
    384388    } while (0)
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