VirtualBox

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


Ignore:
Timestamp:
Oct 17, 2022 9:06:03 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154153
Message:

VMM/CPUM,EM,HM,IEM,++: Moved VMCPU_FF_INHIBIT_INTERRUPTS and VMCPU_FF_BLOCK_NMIS to CPUMCTX::fInhibit. Moved ldtr and tr up to the CPUMCTXCORE area in hope for better cache alignment of rip, rflags and crX register fields. bugref:9941

File:
1 edited

Legend:

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

    r96811 r97178  
    26922692
    26932693        if (fWhat & CPUMCTX_EXTRN_INHIBIT_INT)
    2694         {
    2695             if (pVmcbCtrl->IntShadow.n.u1IntShadow)
    2696                 EMSetInhibitInterruptsPC(pVCpu, pVmcbGuest->u64RIP);
    2697             else if (VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS))
    2698                 VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS);
    2699         }
     2694            CPUMUpdateInterruptShadowEx(pCtx, pVmcbCtrl->IntShadow.n.u1IntShadow, pVmcbGuest->u64RIP);
    27002695
    27012696        if (fWhat & CPUMCTX_EXTRN_RIP)
     
    35043499
    35053500/**
    3506  * Checks if the guest (or nested-guest) has an interrupt shadow active right
    3507  * now.
    3508  *
    3509  * @returns @c true if the interrupt shadow is active, @c false otherwise.
    3510  * @param   pVCpu   The cross context virtual CPU structure.
    3511  *
    3512  * @remarks No-long-jump zone!!!
    3513  * @remarks Has side-effects with VMCPU_FF_INHIBIT_INTERRUPTS force-flag.
    3514  */
    3515 static bool hmR0SvmIsIntrShadowActive(PVMCPUCC pVCpu)
    3516 {
    3517     /*
    3518      * Instructions like STI and MOV SS inhibit interrupts till the next instruction
    3519      * completes. Check if we should inhibit interrupts or clear any existing
    3520      * interrupt inhibition.
    3521      */
    3522     if (VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS))
    3523     {
    3524         if (pVCpu->cpum.GstCtx.rip != EMGetInhibitInterruptsPC(pVCpu))
    3525         {
    3526             /*
    3527              * We can clear the inhibit force flag as even if we go back to the recompiler
    3528              * without executing guest code in AMD-V, the flag's condition to be cleared is
    3529              * met and thus the cleared state is correct.
    3530              */
    3531             VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS);
    3532             return false;
    3533         }
    3534         return true;
    3535     }
    3536     return false;
    3537 }
    3538 
    3539 
    3540 /**
    35413501 * Sets the virtual interrupt intercept control in the VMCB.
    35423502 *
     
    36123572
    36133573    bool const fGif        = CPUMGetGuestGif(pCtx);
    3614     bool const fIntShadow  = hmR0SvmIsIntrShadowActive(pVCpu);
    3615     bool const fBlockNmi   = VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_BLOCK_NMIS);
     3574    bool const fIntShadow  = CPUMIsInInterruptShadowWithUpdate(pCtx);
     3575    bool const fBlockNmi   = CPUMAreInterruptsInhibitedByNmi(pCtx);
    36163576
    36173577    Log4Func(("fGif=%RTbool fBlockNmi=%RTbool fIntShadow=%RTbool fIntPending=%RTbool fNmiPending=%RTbool\n",
     
    37343694    Assert(!VMMRZCallRing3IsEnabled(pVCpu));
    37353695
    3736     bool const fIntShadow = hmR0SvmIsIntrShadowActive(pVCpu);
     3696    bool const fIntShadow = CPUMIsInInterruptShadowWithUpdate(&pVCpu->cpum.GstCtx);
    37373697#ifdef VBOX_STRICT
    37383698    PCCPUMCTX  pCtx       = &pVCpu->cpum.GstCtx;
     
    37823742         * VM-exit to determine the state.
    37833743         */
    3784         if (    Event.n.u3Type   == SVM_EVENT_NMI
    3785             &&  Event.n.u8Vector == X86_XCPT_NMI
    3786             && !VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_BLOCK_NMIS))
    3787         {
    3788             VMCPU_FF_SET(pVCpu, VMCPU_FF_BLOCK_NMIS);
    3789         }
     3744        if (   Event.n.u3Type   == SVM_EVENT_NMI
     3745            && Event.n.u8Vector == X86_XCPT_NMI)
     3746            CPUMSetInterruptInhibitingByNmi(&pVCpu->cpum.GstCtx);
    37903747
    37913748        /*
     
    38093766     * but we still need to intercept IRET in order to eventually clear NMI inhibition.
    38103767     */
    3811     if (VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_BLOCK_NMIS))
     3768    if (CPUMAreInterruptsInhibitedByNmi(&pVCpu->cpum.GstCtx))
    38123769        hmR0SvmSetCtrlIntercept(pVmcb, SVM_CTRL_INTERCEPT_IRET);
    38133770
     
    67116668                    /* If we are re-injecting an NMI, clear NMI blocking. */
    67126669                    if (pVmcb->ctrl.ExitIntInfo.n.u3Type == SVM_EVENT_NMI)
    6713                         VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_BLOCK_NMIS);
     6670                        CPUMClearInterruptInhibitingByNmi(&pVCpu->cpum.GstCtx);
    67146671
    67156672                    /* Determine a vectoring #PF condition, see comment in hmR0SvmExitXcptPF(). */
     
    68026759DECLINLINE(void) hmR0SvmAdvanceRip(PVMCPUCC pVCpu, uint32_t cb)
    68036760{
    6804     PCPUMCTX pCtx = &pVCpu->cpum.GstCtx;
    6805     pCtx->rip += cb;
    6806 
    6807     /* Update interrupt shadow. */
    6808     if (   VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS)
    6809         && pCtx->rip != EMGetInhibitInterruptsPC(pVCpu))
    6810         VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INHIBIT_INTERRUPTS);
     6761    pVCpu->cpum.GstCtx.rip += cb;
     6762    CPUMClearInterruptShadow(&pVCpu->cpum.GstCtx);
     6763    /** @todo clear RF. */
    68116764}
    68126765
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette