VirtualBox

Ignore:
Timestamp:
Sep 9, 2018 3:51:39 PM (6 years ago)
Author:
vboxsync
Message:

VMM: Nested VMX: bugref:9180 vmlaunch/vmresume bits.

File:
1 edited

Legend:

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

    r74155 r74163  
    28262826
    28272827/**
     2828 * Checks guest RIP and RFLAGS as part of VM-entry.
     2829 *
     2830 * @param   pVCpu           The cross context virtual CPU structure.
     2831 * @param   pszInstr        The VMX instruction name (for logging purposes).
     2832 */
     2833IEM_STATIC int iemVmxVmentryCheckGuestRipRFlags(PVMCPU pVCpu,  const char *pszInstr)
     2834{
     2835    /*
     2836     * RIP and RFLAGS.
     2837     * See Intel spec. 26.3.1.4 "Checks on Guest RIP and RFLAGS".
     2838     */
     2839    PCVMXVVMCS pVmcs = pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pVmcs);
     2840    const char *const pszFailure = "VM-exit";
     2841    bool const fGstInLongMode = RT_BOOL(pVmcs->u32EntryCtls & VMX_ENTRY_CTLS_IA32E_MODE_GUEST);
     2842
     2843    /* RIP. */
     2844    if (IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fLongMode)
     2845    {
     2846        X86DESCATTR CsAttr; CsAttr.u = pVmcs->u32GuestCsAttr;
     2847        if (   !fGstInLongMode
     2848            || !CsAttr.n.u1Long)
     2849        {
     2850            if (!RT_HI_U32(pVmcs->u64GuestRip.u))
     2851            { /* likely */ }
     2852            else
     2853                IEM_VMX_VMENTRY_FAILED_RET(pVCpu, pszInstr, pszFailure, kVmxVDiag_Vmentry_GuestRipRsvd);
     2854        }
     2855
     2856        if (   fGstInLongMode
     2857            && CsAttr.n.u1Long)
     2858        {
     2859            Assert(IEM_GET_GUEST_CPU_FEATURES(pVCpu)->cMaxLinearAddrWidth == 48);   /* Canonical. */
     2860            if (   IEM_GET_GUEST_CPU_FEATURES(pVCpu)->cMaxLinearAddrWidth < 64
     2861                && X86_IS_CANONICAL(pVmcs->u64GuestRip.u))
     2862            { /* likely */ }
     2863            else
     2864                IEM_VMX_VMENTRY_FAILED_RET(pVCpu, pszInstr, pszFailure, kVmxVDiag_Vmentry_GuestRip);
     2865        }
     2866    }
     2867
     2868    /* RFLAGS (bits 63:22 (or 31:22), bits 15, 5, 3 are reserved, bit 1 MB1). */
     2869    uint64_t fMbzMask = IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fLongMode ? UINT64_C(0xffffffffffc08028) : UINT32_C(0xffc08028);
     2870    uint64_t fMb1Mask = X86_EFL_RA1_MASK;
     2871    if (   !(pVmcs->u64GuestRFlags.u & fMbzMask)
     2872        &&  (pVmcs->u64GuestRFlags.u & fMb1Mask) == fMb1Mask)
     2873    { /* likely */ }
     2874    else
     2875        IEM_VMX_VMENTRY_FAILED_RET(pVCpu, pszInstr, pszFailure, kVmxVDiag_Vmentry_GuestRFlagsRsvd);
     2876
     2877    if (   fGstInLongMode
     2878        || !(pVmcs->u64GuestCr0.u & X86_CR0_PE))
     2879    {
     2880        if (!(pVmcs->u64GuestRFlags.u & X86_EFL_VM))
     2881        { /* likely */ }
     2882        else
     2883            IEM_VMX_VMENTRY_FAILED_RET(pVCpu, pszInstr, pszFailure, kVmxVDiag_Vmentry_GuestRFlagsVm);
     2884    }
     2885
     2886    if (   VMX_ENTRY_INT_INFO_IS_VALID(pVmcs->u32EntryIntInfo)
     2887        && VMX_ENTRY_INT_INFO_TYPE(pVmcs->u32EntryIntInfo) == VMX_ENTRY_INT_INFO_TYPE_EXT_INT)
     2888    {
     2889        if (pVmcs->u64GuestRFlags.u & X86_EFL_IF)
     2890        { /* likely */ }
     2891        else
     2892            IEM_VMX_VMENTRY_FAILED_RET(pVCpu, pszInstr, pszFailure, kVmxVDiag_Vmentry_GuestRFlagsIf);
     2893    }
     2894
     2895    NOREF(pszInstr);
     2896    NOREF(pszFailure);
     2897    return VINF_SUCCESS;
     2898}
     2899
     2900
     2901/**
    28282902 * Checks guest-state as part of VM-entry.
    28292903 *
     
    28522926        return rc;
    28532927
     2928    rc = iemVmxVmentryCheckGuestRipRFlags(pVCpu, pszInstr);
     2929    if (rc == VINF_SUCCESS)
     2930    { /* likely */ }
     2931    else
     2932        return rc;
    28542933
    28552934    return VINF_SUCCESS;
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