VirtualBox

Changeset 82159 in vbox


Ignore:
Timestamp:
Nov 25, 2019 10:18:41 AM (5 years ago)
Author:
vboxsync
Message:

VMM/HMVMXR0: Fix single-stepping in the hypervisor debugger using MTF when the guest is also single-stepping (using EFLAGS.TF).

File:
1 edited

Legend:

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

    r82026 r82159  
    58055805         * executing guest code so they'll trigger at the right time.
    58065806         */
     5807        HMVMX_CPUMCTX_ASSERT(pVCpu, CPUMCTX_EXTRN_DR7);
    58075808        if (pVCpu->cpum.GstCtx.dr[7] & (X86_DR7_ENABLED_MASK | X86_DR7_GD))
    58085809        {
     
    88208821            AssertRC(rc);
    88218822        }
    8822         else if (pVCpu->cpum.GstCtx.eflags.u32 & X86_EFL_TF)
     8823        else
    88238824        {
    88248825            /*
    8825              * We must not deliver a debug exception when single-stepping in the hypervisor debugger
    8826              * using EFLAGS.T. Instead, clear interrupt inhibition.
     8826             * We must not deliver a debug exception when single-stepping over STI/Mov-SS in the
     8827             * hypervisor debugger using EFLAGS.TF but rather clear interrupt inhibition. However,
     8828             * we take care of this case in hmR0VmxExportSharedDebugState and also the case if
     8829             * we use MTF, so just make sure it's called before executing guest-code.
    88278830             */
    8828             Assert(!(pVCpu->CTX_SUFF(pVM)->hm.s.vmx.Msrs.ProcCtls.n.allowed1 & VMX_PROC_CTLS_MONITOR_TRAP_FLAG));
    8829             fIntrState = 0;
     8831            ASMAtomicUoOrU64(&pVCpu->hm.s.fCtxChanged, HM_CHANGED_GUEST_DR_MASK);
    88308832        }
    88318833    }
     
    1082810830            hmR0VmxReadAllRoFieldsVmcs(pVmxTransient);
    1082910831#endif
    10830 #if defined(HMVMX_ALWAYS_SYNC_FULL_GUEST_STATE) || defined(HMVMX_ALWAYS_SAVE_FULL_GUEST_STATE)
    10831             rc = hmR0VmxImportGuestState(pVCpu, pVmcsInfo, HMVMX_CPUMCTX_EXTRN_ALL);
    10832             AssertRC(rc);
    10833 #elif defined(HMVMX_ALWAYS_SAVE_GUEST_RFLAGS)
    10834             rc = hmR0VmxImportGuestState(pVCpu, pVmcsInfo, HMVMX_CPUMCTX_EXTRN_RFLAGS);
    10835             AssertRC(rc);
    10836 #else
     10832
    1083710833            /*
    1083810834             * Import the guest-interruptibility state always as we need it while evaluating
     
    1084310839             * mode changes wrt CR0 are intercepted.
    1084410840             */
    10845             rc = hmR0VmxImportGuestState(pVCpu, pVmcsInfo, CPUMCTX_EXTRN_HM_VMX_INT_STATE);
     10841            uint64_t const fImportMask = CPUMCTX_EXTRN_HM_VMX_INT_STATE
     10842#if defined(HMVMX_ALWAYS_SYNC_FULL_GUEST_STATE) || defined(HMVMX_ALWAYS_SAVE_FULL_GUEST_STATE)
     10843                                       | HMVMX_CPUMCTX_EXTRN_ALL
     10844#elif defined(HMVMX_ALWAYS_SAVE_GUEST_RFLAGS)
     10845                                       | CPUMCTX_EXTRN_RFLAGS
     10846#endif
     10847                                       ;
     10848            rc = hmR0VmxImportGuestState(pVCpu, pVmcsInfo, fImportMask);
    1084610849            AssertRC(rc);
    10847 #endif
    1084810850
    1084910851            /*
     
    1374013742    PCPUMCTX pCtx = &pVCpu->cpum.GstCtx;
    1374113743    if (!pVmxTransient->fIsNestedGuest)
     13744    {
    1374213745        rc = DBGFRZTrap01Handler(pVCpu->CTX_SUFF(pVM), pVCpu, CPUMCTX2CORE(pCtx), uDR6, pVCpu->hm.s.fSingleInstruction);
     13746
     13747        /*
     13748         * Prevents stepping twice over the same instruction when the guest is stepping using
     13749         * EFLAGS.TF and the hypervisor debugger is stepping using MTF.
     13750         * Testcase: DOSQEMM, break (using "ba x 1") at cs:rip 0x70:0x774 and step (using "t").
     13751         */
     13752        if (   rc == VINF_EM_DBG_STEPPED
     13753            && (pVmxTransient->pVmcsInfo->u32ProcCtls & VMX_PROC_CTLS_MONITOR_TRAP_FLAG))
     13754        {
     13755            Assert(pVCpu->hm.s.fSingleInstruction);
     13756            rc = VINF_EM_RAW_GUEST_TRAP;
     13757        }
     13758    }
    1374313759    else
    1374413760        rc = VINF_EM_RAW_GUEST_TRAP;
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