VirtualBox

Ignore:
Timestamp:
Jan 29, 2014 2:20:00 PM (11 years ago)
Author:
vboxsync
Message:

VMM/HMVMXR0: Fix single-stepping with IRET on real-on-v86 mode while not breaking single-stepping of emulated instructions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r49992 r50270  
    70787078    }
    70797079
    7080     /* Delivery pending debug exception if the guest is single-stepping. Evaluate and set the BS bit. */
    7081     if (   !pVCpu->hm.s.fSingleInstruction
    7082         && !DBGFIsStepping(pVCpu))
    7083     {
    7084         int rc2 = hmR0VmxSaveGuestRflags(pVCpu, pMixedCtx);
    7085         AssertRCReturn(rc2, rc2);
    7086         if (pMixedCtx->eflags.Bits.u1TF)    /* We don't have any IA32_DEBUGCTL MSR for guests. Treat as all bits 0. */
     7080    /* Deliver pending debug exception if the guest is single-stepping. Evaluate and set the BS bit. */
     7081    if (   fBlockSti
     7082        || fBlockMovSS)
     7083    {
     7084        if (   !pVCpu->hm.s.fSingleInstruction
     7085            && !DBGFIsStepping(pVCpu))
     7086        {
     7087            int rc2 = hmR0VmxSaveGuestRflags(pVCpu, pMixedCtx);
     7088            AssertRCReturn(rc2, rc2);
     7089            if (pMixedCtx->eflags.Bits.u1TF)    /* We don't have any IA32_DEBUGCTL MSR for guests. Treat as all bits 0. */
     7090            {
     7091                /*
     7092                 * The pending-debug exceptions field is cleared on all VM-exits except VMX_EXIT_TPR_BELOW_THRESHOLD,
     7093                 * VMX_EXIT_MTF, VMX_EXIT_APIC_WRITE and VMX_EXIT_VIRTUALIZED_EOI.
     7094                 * See Intel spec. 27.3.4 "Saving Non-Register State".
     7095                 */
     7096                rc2 = VMXWriteVmcs32(VMX_VMCS_GUEST_PENDING_DEBUG_EXCEPTIONS, VMX_VMCS_GUEST_DEBUG_EXCEPTIONS_BS);
     7097                AssertRCReturn(rc2, rc2);
     7098            }
     7099        }
     7100        else if (pMixedCtx->eflags.Bits.u1TF)
    70877101        {
    70887102            /*
    7089              * The pending-debug exceptions field is cleared on all VM-exits except VMX_EXIT_TPR_BELOW_THRESHOLD,
    7090              * VMX_EXIT_MTF, VMX_EXIT_APIC_WRITE and VMX_EXIT_VIRTUALIZED_EOI.
    7091              * See Intel spec. 27.3.4 "Saving Non-Register State".
     7103             * We are single-stepping in the hypervisor debugger using EFLAGS.TF. Clear interrupt inhibition as setting the
     7104             * BS bit would mean delivering a #DB to the guest upon VM-entry when it shouldn't be.
    70927105             */
    7093             rc2 = VMXWriteVmcs32(VMX_VMCS_GUEST_PENDING_DEBUG_EXCEPTIONS, VMX_VMCS_GUEST_DEBUG_EXCEPTIONS_BS);
    7094             AssertRCReturn(rc2, rc2);
    7095         }
    7096     }
    7097     else
    7098     {
    7099         /* We are single-stepping in the hypervisor debugger, clear interrupt inhibition as setting the BS bit would mean
    7100            delivering a #DB to the guest upon VM-entry when it shouldn't be. */
    7101         uIntrState = 0;
     7106            Assert(!(pVCpu->CTX_SUFF(pVM)->hm.s.vmx.Msrs.VmxProcCtls.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC_MONITOR_TRAP_FLAG));
     7107            uIntrState = 0;
     7108        }
    71027109    }
    71037110
     
    86008607    int rc = hmR0VmxReadExitInstrLenVmcs(pVmxTransient);
    86018608    rc    |= hmR0VmxSaveGuestRip(pVCpu, pMixedCtx);
     8609    rc    |= hmR0VmxSaveGuestRflags(pVCpu, pMixedCtx);
    86028610    AssertRCReturn(rc, rc);
    86038611
    86048612    pMixedCtx->rip += pVmxTransient->cbInstr;
    86058613    HMCPU_CF_SET(pVCpu, HM_CHANGED_GUEST_RIP);
     8614
     8615    /* Deliver pending debug exception if the guest is single-stepping. */
     8616    if (pMixedCtx->eflags.Bits.u1TF)
     8617    {
     8618        rc = VMXWriteVmcs32(VMX_VMCS_GUEST_PENDING_DEBUG_EXCEPTIONS, VMX_VMCS_GUEST_DEBUG_EXCEPTIONS_BS);
     8619        AssertRCReturn(rc, rc);
     8620    }
     8621
    86068622    return rc;
    86078623}
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