VirtualBox

Changeset 72065 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Apr 30, 2018 6:27:34 AM (7 years ago)
Author:
vboxsync
Message:

VMM/SVM: Interrupt injection fixes.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r70948 r72065  
    25682568    Assert(pCtx->hwvirt.fGif);
    25692569
    2570     if (!pCtx->hwvirt.svm.fHMCachedVmcb)
    2571     {
    2572         PCSVMVMCBCTRL pVmcbCtrl = &pCtx->hwvirt.svm.CTX_SUFF(pVmcb)->ctrl;
    2573         X86EFLAGS fEFlags;
    2574         if (pVmcbCtrl->IntCtrl.n.u1VIntrMasking)
    2575             fEFlags.u = pCtx->hwvirt.svm.HostState.rflags.u;
    2576         else
    2577             fEFlags.u = pCtx->eflags.u;
    2578 
    2579         return fEFlags.Bits.u1IF;
    2580     }
    2581 
    2582     return HMCanSvmNstGstTakePhysIntr(pVCpu, pCtx);
     2570    X86EFLAGS fEFlags;
     2571    if (CPUMIsGuestSvmVirtIntrMasking(pVCpu, pCtx))
     2572        fEFlags.u = pCtx->hwvirt.svm.HostState.rflags.u;
     2573    else
     2574        fEFlags.u = pCtx->eflags.u;
     2575
     2576    return fEFlags.Bits.u1IF;
    25832577#endif
    25842578}
     
    26042598    Assert(pCtx->hwvirt.fGif);
    26052599
    2606     /*
    2607      * Although at present, the V_TPR and V_INTR_PRIO fields are not modified
    2608      * by SVM R0 code and we could inspect them directly here, we play it
    2609      * safe and ask HM if it has cached the VMCB.
    2610      */
    2611     if (!pCtx->hwvirt.svm.fHMCachedVmcb)
    2612     {
    2613         PCSVMVMCBCTRL pVmcbCtrl = &pCtx->hwvirt.svm.CTX_SUFF(pVmcb)->ctrl;
    2614         if (   !pVmcbCtrl->IntCtrl.n.u1IgnoreTPR
    2615             &&  pVmcbCtrl->IntCtrl.n.u4VIntrPrio <= pVmcbCtrl->IntCtrl.n.u8VTPR)
    2616             return false;
    2617 
    2618         X86EFLAGS fEFlags;
    2619         if (pVmcbCtrl->IntCtrl.n.u1VIntrMasking)
    2620             fEFlags.u = pCtx->eflags.u;
    2621         else
    2622             fEFlags.u = pCtx->hwvirt.svm.HostState.rflags.u;
    2623 
    2624         return fEFlags.Bits.u1IF;
    2625     }
    2626 
    2627     return HMCanSvmNstGstTakeVirtIntr(pVCpu, pCtx);
     2600    PCSVMVMCBCTRL pVmcbCtrl    = &pCtx->hwvirt.svm.CTX_SUFF(pVmcb)->ctrl;
     2601    PCSVMINTCTRL  pVmcbIntCtrl = &pVmcbCtrl->IntCtrl;
     2602    if (   !pVmcbIntCtrl->n.u1IgnoreTPR
     2603        &&  pVmcbIntCtrl->n.u4VIntrPrio <= pVmcbIntCtrl->n.u8VTPR)
     2604        return false;
     2605
     2606    X86EFLAGS fEFlags;
     2607    if (CPUMIsGuestSvmVirtIntrMasking(pVCpu, pCtx))
     2608        fEFlags.u = pCtx->eflags.u;
     2609    else
     2610        fEFlags.u = pCtx->hwvirt.svm.HostState.rflags.u;
     2611
     2612    return fEFlags.Bits.u1IF;
    26282613#endif
    26292614}
     
    26442629    PCSVMVMCBCTRL pVmcbCtrl = &pCtx->hwvirt.svm.CTX_SUFF(pVmcb)->ctrl;
    26452630    return pVmcbCtrl->IntCtrl.n.u8VIntrVector;
     2631#endif
     2632}
     2633
     2634
     2635/**
     2636 * Gets the SVM nested-guest virtual GIF.
     2637 *
     2638 * @returns The nested-guest virtual GIF.
     2639 * @param   pCtx            The guest-CPU context.
     2640 */
     2641VMM_INT_DECL(bool) CPUMGetSvmNstGstVGif(PCCPUMCTX pCtx)
     2642{
     2643#ifdef IN_RC
     2644    RT_NOREF(pCtx);
     2645    AssertReleaseFailedReturn(false);
     2646#else
     2647    PCSVMVMCBCTRL pVmcbCtrl    = &pCtx->hwvirt.svm.CTX_SUFF(pVmcb)->ctrl;
     2648    PCSVMINTCTRL  pVmcbIntCtrl = &pVmcbCtrl->IntCtrl;
     2649    if (pVmcbIntCtrl->n.u1VGifEnable)
     2650        return pVmcbIntCtrl->n.u1VGif;
     2651    return true;
    26462652#endif
    26472653}
  • trunk/src/VBox/VMM/VMMAll/HMSVMAll.cpp

    r71966 r72065  
    577577}
    578578
    579 
    580 /**
    581  * Checks whether the SVM nested-guest is in a state to receive physical (APIC)
    582  * interrupts.
    583  *
    584  * @returns true if it's ready, false otherwise.
    585  * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
    586  * @param   pCtx        The guest-CPU context.
    587  *
    588  * @remarks This function looks at the VMCB cache rather than directly at the
    589  *          nested-guest VMCB. The latter may have been modified for executing
    590  *          using hardware-assisted SVM.
    591  *
    592  * @sa      CPUMCanSvmNstGstTakePhysIntr.
    593  */
    594 VMM_INT_DECL(bool) HMCanSvmNstGstTakePhysIntr(PVMCPU pVCpu, PCCPUMCTX pCtx)
    595 {
    596     Assert(pCtx->hwvirt.svm.fHMCachedVmcb);
    597     Assert(pCtx->hwvirt.fGif);
    598     PCSVMNESTEDVMCBCACHE pVmcbNstGstCache = &pVCpu->hm.s.svm.NstGstVmcbCache;
    599     X86EFLAGS fEFlags;
    600     if (pVmcbNstGstCache->fVIntrMasking)
    601         fEFlags.u = pCtx->hwvirt.svm.HostState.rflags.u;
    602     else
    603         fEFlags.u = pCtx->eflags.u;
    604     return fEFlags.Bits.u1IF;
    605 }
    606 
    607 
    608 /**
    609  * Checks whether the SVM nested-guest is in a state to receive virtual (setup
    610  * for injection by VMRUN instruction) interrupts.
    611  *
    612  * @returns true if it's ready, false otherwise.
    613  * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
    614  * @param   pCtx        The guest-CPU context.
    615  *
    616  * @remarks This function looks at the VMCB cache rather than directly at the
    617  *          nested-guest VMCB. The latter may have been modified for executing
    618  *          using hardware-assisted SVM.
    619  *
    620  * @sa      CPUMCanSvmNstGstTakeVirtIntr.
    621  */
    622 VMM_INT_DECL(bool) HMCanSvmNstGstTakeVirtIntr(PVMCPU pVCpu, PCCPUMCTX pCtx)
    623 {
    624 #ifdef IN_RC
    625     RT_NOREF2(pVCpu, pCtx);
    626     AssertReleaseFailedReturn(false);
    627 #else
    628     Assert(pCtx->hwvirt.svm.fHMCachedVmcb);
    629     Assert(pCtx->hwvirt.fGif);
    630     PCSVMNESTEDVMCBCACHE pVmcbNstGstCache = &pVCpu->hm.s.svm.NstGstVmcbCache;
    631 
    632     PCSVMVMCBCTRL pVmcbCtrl = &pCtx->hwvirt.svm.CTX_SUFF(pVmcb)->ctrl;
    633     if (   !pVmcbCtrl->IntCtrl.n.u1IgnoreTPR
    634         &&  pVmcbCtrl->IntCtrl.n.u4VIntrPrio <= pVmcbCtrl->IntCtrl.n.u8VTPR)
    635         return false;
    636 
    637     X86EFLAGS fEFlags;
    638     if (pVmcbNstGstCache->fVIntrMasking)
    639         fEFlags.u = pCtx->eflags.u;
    640     else
    641         fEFlags.u = pCtx->hwvirt.svm.HostState.rflags.u;
    642     return fEFlags.Bits.u1IF;
    643 #endif
    644 }
    645 
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplSvmInstr.cpp.h

    r71970 r72065  
    174174             *
    175175             *   - V_IRQ: Tracked using VMCPU_FF_INTERRUPT_NESTED_GUEST force-flag and updated below.
    176              *   - V_TPR: Already updated by iemCImpl_load_CrX or by the physical CPU for
    177              *     hardware-assisted SVM execution.
     176             *   - V_TPR: Updated by iemCImpl_load_CrX or by the physical CPU for hardware-assisted
     177             *     SVM execution.
    178178             *   - Interrupt shadow: Tracked using VMCPU_FF_INHIBIT_INTERRUPTS and RIP.
    179179             */
    180180            PSVMVMCBCTRL pVmcbMemCtrl = &pVmcbMem->ctrl;
    181             if (VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_INTERRUPT_NESTED_GUEST))        /* V_IRQ. */
     181            if (!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_INTERRUPT_NESTED_GUEST))       /* V_IRQ. */
     182                pVmcbMemCtrl->IntCtrl.n.u1VIrqPending = 0;
     183            else
    182184            {
    183185                Assert(pVmcbCtrl->IntCtrl.n.u1VIrqPending);
    184                 pVmcbMemCtrl->IntCtrl.n.u1VIrqPending = 1;
    185186                VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_NESTED_GUEST);
    186187            }
    187             else
    188                 pVmcbMemCtrl->IntCtrl.n.u1VIrqPending = 0;
    189188
    190189            pVmcbMemCtrl->IntCtrl.n.u8VTPR = pVmcbCtrl->IntCtrl.n.u8VTPR;           /* V_TPR. */
     
    439438
    440439        /* Virtual GIF. */
    441         if (   pVmcbCtrl->IntCtrl.n.u1VGifEnable
    442             && pVM->cpum.ro.GuestFeatures.fSvmVGif)
     440        if (    pVmcbCtrl->IntCtrl.n.u1VGifEnable
     441            && !pVM->cpum.ro.GuestFeatures.fSvmVGif)
    443442        {
    444443            Log(("iemSvmVmrun: Virtual GIF not supported -> Disabling\n"));
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