VirtualBox

Changeset 89976 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
Jun 30, 2021 11:03:22 AM (4 years ago)
Author:
vboxsync
Message:

VMM/HMVMX: Deal with #ACs triggered by split-lock detection on the host. bugref:10052

Location:
trunk/src/VBox/VMM/VMMR0
Files:
2 edited

Legend:

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

    r88099 r89976  
    75077507    HMSVM_VALIDATE_EXIT_HANDLER_PARAMS(pVCpu, pSvmTransient);
    75087508    HMSVM_CHECK_EXIT_DUE_TO_EVENT_DELIVERY(pVCpu, pSvmTransient);
    7509     STAM_COUNTER_INC(&pVCpu->hm.s.StatExitGuestAC);
     7509    STAM_REL_COUNTER_INC(&pVCpu->hm.s.StatExitGuestAC);
    75107510
    75117511    SVMEVENT Event;
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r89781 r89976  
    41064106     * The following exceptions are always intercepted:
    41074107     *
    4108      * #AC - To prevent the guest from hanging the CPU.
     4108     * #AC - To prevent the guest from hanging the CPU and for dealing with
     4109     *       split-lock detecting host configs.
    41094110     * #DB - To maintain the DR6 state even when intercepting DRx reads/writes and
    41104111     *       recursive #DBs can cause a CPU hang.
     
    1413614137{
    1413714138    HMVMX_VALIDATE_EXIT_XCPT_HANDLER_PARAMS(pVCpu, pVmxTransient);
    14138     STAM_COUNTER_INC(&pVCpu->hm.s.StatExitGuestAC);
     14139
     14140    /*
     14141     * Detect #ACs caused by host having enabled split-lock detection.
     14142     * Emulate such instructions.
     14143     */
     14144    int rc = hmR0VmxImportGuestState(pVCpu, pVmxTransient->pVmcsInfo,
     14145                                     CPUMCTX_EXTRN_CR0 | CPUMCTX_EXTRN_RFLAGS | CPUMCTX_EXTRN_SS | CPUMCTX_EXTRN_CS);
     14146    AssertRCReturn(rc, rc);
     14147    /** @todo detect split lock in cpu feature?   */
     14148    if (   /* 1. If 486-style alignment checks aren't enabled, then this must be a split-lock exception */
     14149           !(pVCpu->cpum.GstCtx.cr0 & X86_CR0_AM)
     14150           /* 2. #AC cannot happen in rings 0-2 except for split-lock detection. */
     14151        || CPUMGetGuestCPL(pVCpu) != 3
     14152           /* 3. When the EFLAGS.AC != 0 this can only be a split-lock case. */
     14153        || !(pVCpu->cpum.GstCtx.eflags.u & X86_EFL_AC) )
     14154    {
     14155        STAM_REL_COUNTER_INC(&pVCpu->hm.s.StatExitGuestACSplitLock);
     14156#if 0
     14157        rc = hmR0VmxImportGuestState(pVCpu, pVmxTransient->pVmcsInfo, IEM_CPUMCTX_EXTRN_MUST_MASK);
     14158#else
     14159        rc = hmR0VmxImportGuestState(pVCpu, pVmxTransient->pVmcsInfo, HMVMX_CPUMCTX_EXTRN_ALL);
     14160#endif
     14161        AssertRCReturn(rc, rc);
     14162        Log8Func(("cs:rip=%#04x:%#RX64 rflags=%#RX64 cr0=%#RX64 split-lock #AC?\n", pVCpu->cpum.GstCtx.cs.Sel,
     14163                  pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rflags, pVCpu->cpum.GstCtx.cr0));
     14164
     14165        /** @todo For SMP configs we should do a rendezvous here. */
     14166        VBOXSTRICTRC rcStrict = IEMExecOneIgnoreLock(pVCpu);
     14167        if (rcStrict == VINF_SUCCESS)
     14168#if 0       /** @todo r=bird: This is potentially wrong.  Might have to just do a whole
     14169             *        state sync above and mark everything changed to be safe... */
     14170            ASMAtomicUoOrU64(&pVCpu->hm.s.fCtxChanged,
     14171                               HM_CHANGED_GUEST_RIP
     14172                             | HM_CHANGED_GUEST_RFLAGS
     14173                             | HM_CHANGED_GUEST_GPRS_MASK
     14174                             | HM_CHANGED_GUEST_CS
     14175                             | HM_CHANGED_GUEST_SS);
     14176#else
     14177        ASMAtomicUoOrU64(&pVCpu->hm.s.fCtxChanged, HM_CHANGED_ALL_GUEST);
     14178#endif
     14179        else if (rcStrict == VINF_IEM_RAISED_XCPT)
     14180        {
     14181            ASMAtomicUoOrU64(&pVCpu->hm.s.fCtxChanged, HM_CHANGED_RAISED_XCPT_MASK);
     14182            rcStrict = VINF_SUCCESS;
     14183        }
     14184        return VBOXSTRICTRC_VAL(rcStrict);
     14185    }
     14186
     14187    STAM_REL_COUNTER_INC(&pVCpu->hm.s.StatExitGuestAC);
     14188    Log8Func(("cs:rip=%#04x:%#RX64 rflags=%#RX64 cr0=%#RX64 cpl=%d -> #AC\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.rip,
     14189              pVCpu->cpum.GstCtx.rflags, pVCpu->cpum.GstCtx.cr0, CPUMGetGuestCPL(pVCpu) ));
    1413914190
    1414014191    /* Re-inject it. We'll detect any nesting before getting here. */
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