VirtualBox

Changeset 74709 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 9, 2018 9:31:14 AM (6 years ago)
Author:
vboxsync
Message:

VMM/IEM: Nested VMX: bugref:9180 VM-exit bits; Added MWAIT intercept.

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

Legend:

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

    r74683 r74709  
    434434    do { return iemVmxVmexitTaskSwitch((a_pVCpu), (a_enmTaskSwitch), (a_SelNewTss)); } while (0)
    435435
     436/**
     437 * Invokes the VMX VM-exit handler for MWAIT.
     438 */
     439# define IEM_VMX_VMEXIT_MWAIT_RET(a_pVCpu, a_fMonitorArmed, a_cbInstr) \
     440    do { return iemVmxVmexitInstrMwait((a_pVCpu), (a_fMonitorArmed), (a_cbInstr)); } while (0)
     441
    436442#else
    437443# define IEM_VMX_IS_ROOT_MODE(a_pVCpu)                                  (false)
     
    440446# define IEM_VMX_IS_PROCCTLS_SET(a_pVCpu, a_cbInstr)                    (false)
    441447# define IEM_VMX_IS_PROCCTLS2_SET(a_pVCpu, a_cbInstr)                   (false)
    442 # define IEM_VMX_VMEXIT_TASK_SWITCH_RET(a_pVCpu, a_enmTaskSwitch, a_SelNewTss)  do { return VERR_VMX_IPE_1; } while (0)
    443448# define IEM_VMX_VMEXIT_INSTR_RET(a_pVCpu, a_uExitReason, a_cbInstr)            do { return VERR_VMX_IPE_1; } while (0)
    444449# define IEM_VMX_VMEXIT_INSTR_NEEDS_INFO_RET(a_pVCpu, a_uExitReason, a_uInstrId, a_cbInstr)     do { return VERR_VMX_IPE_1; } while (0)
     450# define IEM_VMX_VMEXIT_TASK_SWITCH_RET(a_pVCpu, a_enmTaskSwitch, a_SelNewTss)  do { return VERR_VMX_IPE_1; } while (0)
     451# define IEM_VMX_VMEXIT_MWAIT_RET(a_pVCpu, a_fMonitorArmed, a_cbInstr)          do { return VERR_VMX_IPE_1; } while (0)
    445452
    446453#endif
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp.h

    r74706 r74709  
    71497149    }
    71507150
     7151    /* Check VMX nested-guest intercept. */
     7152    if (   IEM_VMX_IS_NON_ROOT_MODE(pVCpu)
     7153        && IEM_VMX_IS_PROCCTLS_SET(pVCpu, VMX_PROC_CTLS_MWAIT_EXIT))
     7154        IEM_VMX_VMEXIT_MWAIT_RET(pVCpu, EMMonitorIsArmed(pVCpu), cbInstr);
     7155
    71517156    /*
    71527157     * Gather the operands and validate them.
    71537158     */
    7154     uint32_t uEax = pVCpu->cpum.GstCtx.eax;
    7155     uint32_t uEcx = pVCpu->cpum.GstCtx.ecx;
     7159    uint32_t const uEax = pVCpu->cpum.GstCtx.eax;
     7160    uint32_t const uEcx = pVCpu->cpum.GstCtx.ecx;
    71567161    if (uEcx != 0)
    71577162    {
     
    71717176            return iemRaiseGeneralProtectionFault0(pVCpu);
    71727177        }
     7178
     7179#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
     7180        /*
     7181         * If the interrupt-window exiting control is set or a virtual-interrupt is pending
     7182         * for delivery; and interrupts are disabled the processor does not enter its
     7183         * mwait state but rather passes control to the next instruction.
     7184         *
     7185         * See Intel spec. 25.3 "Changes to Instruction Behavior In VMX Non-root Operation".
     7186         */
     7187        if (    IEM_VMX_IS_NON_ROOT_MODE(pVCpu)
     7188            && !pVCpu->cpum.GstCtx.eflags.Bits.u1IF)
     7189        {
     7190            if (   IEM_VMX_IS_PROCCTLS_SET(pVCpu, VMX_PROC_CTLS_INT_WINDOW_EXIT)
     7191                || VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_INTERRUPT_NESTED_GUEST))
     7192            {
     7193                iemRegAddToRipAndClearRF(pVCpu, cbInstr);
     7194                return VINF_SUCCESS;
     7195            }
     7196        }
     7197#endif
    71737198    }
    71747199
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h

    r74706 r74709  
    34763476
    34773477/**
     3478 * VMX VM-exit handler for VM-exits due to MWAIT instruction.
     3479 *
     3480 * @returns VBox strict status code.
     3481 * @param   pVCpu               The cross context virtual CPU structure.
     3482 * @param   fMonitorHwArmed     Whether the address-range monitor hardware is armed.
     3483 * @param   cbInstr             The instruction length in bytes.
     3484 */
     3485IEM_STATIC VBOXSTRICTRC iemVmxVmexitInstrMwait(PVMCPU pVCpu, bool fMonitorHwArmed, uint8_t cbInstr)
     3486{
     3487    VMXVEXITINFO ExitInfo;
     3488    RT_ZERO(ExitInfo);
     3489    ExitInfo.uReason = VMX_EXIT_MWAIT;
     3490    ExitInfo.cbInstr = cbInstr;
     3491    ExitInfo.u64Qual = fMonitorHwArmed;
     3492    return iemVmxVmexitInstrWithInfo(pVCpu, &ExitInfo);
     3493}
     3494
     3495
     3496/**
    34783497 * VMX VM-exit handler for TPR virtualization.
    34793498 *
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