VirtualBox

Changeset 79096 in vbox


Ignore:
Timestamp:
Jun 12, 2019 7:22:59 AM (5 years ago)
Author:
vboxsync
Message:

VMM/CPUM: Nested VMX: bugref:9180 Add CPUMSetGuestNmiBlocking for upcoming changes.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/cpum.h

    r79073 r79096  
    23962396     */
    23972397    RT_NOREF(pVCpu);
     2398    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
    23982399    Assert(CPUMIsGuestVmxPinCtlsSet(pVCpu, pCtx, VMX_PIN_CTLS_VIRT_NMI));
    23992400    return pCtx->hwvirt.vmx.fVirtNmiBlocking;
     2401#endif
     2402}
     2403
     2404/**
     2405 * Sets or clears VMX nested-guest virtual-NMI blocking.
     2406 *
     2407 * @param   pVCpu       The cross context virtual CPU structure of the calling EMT.
     2408 * @param   pCtx        The guest-CPU context.
     2409 * @param   fBlocking   Whether virtual-NMI blocking is in effect or not.
     2410 */
     2411DECLINLINE(void) CPUMSetGuestVmxVirtNmiBlocking(PCVMCPU pVCpu, PCPUMCTX pCtx, bool fBlocking)
     2412{
     2413#ifdef IN_RC
     2414    RT_NOREF3(pVCpu, pCtx, fBlocking);
     2415    AssertReleaseFailedReturnVoid();
     2416#else
     2417    RT_NOREF(pVCpu);
     2418    Assert(CPUMIsGuestInVmxNonRootMode(pCtx));
     2419    Assert(CPUMIsGuestVmxPinCtlsSet(pVCpu, pCtx, VMX_PIN_CTLS_VIRT_NMI));
     2420    pCtx->hwvirt.vmx.fVirtNmiBlocking = fBlocking;
    24002421#endif
    24012422}
     
    25802601VMM_INT_DECL(CPUMINTERRUPTIBILITY) CPUMGetGuestInterruptibility(PVMCPU pVCpu);
    25812602VMM_INT_DECL(bool)                 CPUMIsGuestNmiBlocking(PVMCPU pVCpu);
    2582 
     2603VMM_INT_DECL(void)                 CPUMSetGuestNmiBlocking(PVMCPU pVCpu, bool fBlock);
    25832604
    25842605/** @name Typical scalable bus frequency values.
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r78981 r79096  
    28142814
    28152815/**
     2816 * Sets blocking delivery of NMIs to the guest.
     2817 *
     2818 * @param   pVCpu   The cross context virtual CPU structure.
     2819 * @param   fBlock  Whether NMIs are blocked or not.
     2820 */
     2821VMM_INT_DECL(void) CPUMSetGuestNmiBlocking(PVMCPU pVCpu, bool fBlock)
     2822{
     2823#ifndef IN_RC
     2824    /*
     2825     * Set the state of guest-NMI blocking in any of the following cases:
     2826     *   - We're not executing a nested-guest.
     2827     *   - We're executing an SVM nested-guest[1].
     2828     *   - We're executing a VMX nested-guest without virtual-NMIs enabled.
     2829     *
     2830     * [1] -- SVM does not support virtual-NMIs or virtual-NMI blocking.
     2831     *        SVM hypervisors must track NMI blocking themselves by intercepting
     2832     *        the IRET instruction after injection of an NMI.
     2833     */
     2834    PCPUMCTX pCtx = &pVCpu->cpum.s.Guest;
     2835    if (   !CPUMIsGuestInNestedHwvirtMode(pCtx)
     2836        ||  CPUMIsGuestInSvmNestedHwVirtMode(pCtx)
     2837        || !CPUMIsGuestVmxPinCtlsSet(pVCpu, pCtx, VMX_PIN_CTLS_VIRT_NMI))
     2838    {
     2839        if (fBlock)
     2840        {
     2841            if (!VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_BLOCK_NMIS))
     2842                VMCPU_FF_SET(pVCpu, VMCPU_FF_BLOCK_NMIS);
     2843        }
     2844        else
     2845        {
     2846            if (VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_BLOCK_NMIS))
     2847                VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_BLOCK_NMIS);
     2848        }
     2849        return;
     2850    }
     2851
     2852    /*
     2853     * Set the state of virtual-NMI blocking, if we are executing a
     2854     * VMX nested-guest with virtual-NMIs enabled.
     2855     */
     2856    return CPUMSetGuestVmxVirtNmiBlocking(pVCpu, pCtx, fBlock);
     2857#else
     2858    if (fBlock)
     2859        VMCPU_FF_SET(pVCpu, VMCPU_FF_BLOCK_NMIS);
     2860    else
     2861        VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_BLOCK_NMIS);
     2862#endif
     2863}
     2864
     2865
     2866/**
    28162867 * Checks whether the SVM nested-guest has physical interrupts enabled.
    28172868 *
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