VirtualBox

Changeset 50540 in vbox


Ignore:
Timestamp:
Feb 21, 2014 12:51:57 PM (11 years ago)
Author:
vboxsync
Message:

VMM/HM: Ignore SMX mode and proceed with a warning.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/err.h

    r49893 r50540  
    19471947/** Internal VMX processing error no 1. */
    19481948#define VERR_HMVMX_IPE_5                            (-4027)
    1949 /** VT-x features for SMX operation disabled by the BIOS. */
    1950 #define VERR_VMX_MSR_SMX_VMXON_DISABLED             (-4028)
     1949/** VT-x features for all modes (SMX and non-SMX) disabled by the BIOS. */
     1950#define VERR_VMX_MSR_ALL_VMXON_DISABLED             (-4028)
    19511951/** VT-x features disabled by the BIOS. */
    19521952#define VERR_VMX_MSR_VMXON_DISABLED                 (-4029)
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r50333 r50540  
    33943394 * @returns VBox status code.
    33953395 * @retval  VERR_VMX_NO_VMX
    3396  * @retval  VERR_VMX_MSR_SMX_VMXON_DISABLED
     3396 * @retval  VERR_VMX_MSR_ALL_VMXON_DISABLED
    33973397 * @retval  VERR_VMX_MSR_VMXON_DISABLED
    33983398 * @retval  VERR_VMX_MSR_LOCKING_FAILED
     
    34073407SUPR0DECL(int) SUPR0QueryVTCaps(PSUPDRVSESSION pSession, uint32_t *pfCaps)
    34083408{
    3409     int rc = VERR_UNSUPPORTED_CPU;
     3409    int  rc = VERR_UNSUPPORTED_CPU;
     3410    bool fIsSmxModeAmbiguous = false;
    34103411    RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER;
    34113412
     
    34393440                /** @todo Unify code with hmR0InitIntelCpu(). */
    34403441                uint64_t   u64FeatMsr     = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
    3441                 bool const fInSmxMode     = RT_BOOL(ASMGetCR4() & X86_CR4_SMXE);
     3442                bool const fMaybeSmxMode  = RT_BOOL(ASMGetCR4() & X86_CR4_SMXE);
    34423443                bool       fMsrLocked     = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK);
    34433444                bool       fSmxVmxAllowed = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON);
     
    34473448                if (fMsrLocked)
    34483449                {
    3449                     if (fInSmxMode && !fSmxVmxAllowed)
    3450                         rc = VERR_VMX_MSR_SMX_VMXON_DISABLED;
    3451                     else if (!fInSmxMode && !fVmxAllowed)
    3452                         rc = VERR_VMX_MSR_VMXON_DISABLED;
     3450                    if (fVmxAllowed && fSmxVmxAllowed)
     3451                        rc = VINF_SUCCESS;
     3452                    else if (!fVmxAllowed && !fSmxVmxAllowed)
     3453                        rc = VERR_VMX_MSR_ALL_VMXON_DISABLED;
     3454                    else if (!fMaybeSmxMode)
     3455                    {
     3456                        if (fVmxAllowed)
     3457                            rc = VINF_SUCCESS;
     3458                        else
     3459                            rc = VERR_VMX_MSR_VMXON_DISABLED;
     3460                    }
    34533461                    else
     3462                    {
     3463                        /*
     3464                         * CR4.SMXE is set but this doesn't mean the CPU is necessarily in SMX mode. We shall assume
     3465                         * that it is -not- and that it is a stupid BIOS/OS setting CR4.SMXE for no good reason.
     3466                         * See @bugref{6873}.
     3467                         */
     3468                        Assert(fMaybeSmxMode == true);
     3469                        fIsSmxModeAmbiguous = true;
    34543470                        rc = VINF_SUCCESS;
     3471                    }
    34553472                }
    34563473                else
     
    34593476                     * MSR is not yet locked; we can change it ourselves here.
    34603477                     * Once the lock bit is set, this MSR can no longer be modified.
     3478                     *
     3479                     * Set both the VMXON and SMX_VMXON bits as we can't determine SMX mode
     3480                     * accurately. See @bugref{6873}.
    34613481                     */
    3462                     bool fAllowed;
    3463                     u64FeatMsr |= MSR_IA32_FEATURE_CONTROL_LOCK;
    3464                     if (fInSmxMode)
    3465                         u64FeatMsr |= MSR_IA32_FEATURE_CONTROL_SMX_VMXON;
    3466                     else
    3467                         u64FeatMsr |= MSR_IA32_FEATURE_CONTROL_VMXON;
    3468 
     3482                    u64FeatMsr |=   MSR_IA32_FEATURE_CONTROL_LOCK
     3483                                  | MSR_IA32_FEATURE_CONTROL_SMX_VMXON
     3484                                  | MSR_IA32_FEATURE_CONTROL_VMXON;
    34693485                    ASMWrMsr(MSR_IA32_FEATURE_CONTROL, u64FeatMsr);
    34703486
     
    34743490                    fSmxVmxAllowed = fMsrLocked && RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON);
    34753491                    fVmxAllowed    = fMsrLocked && RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON);
    3476                     fAllowed       = fInSmxMode ? fSmxVmxAllowed : fVmxAllowed;
    3477                     if (fAllowed)
     3492                    if (fSmxVmxAllowed && fVmxAllowed)
    34783493                        rc = VINF_SUCCESS;
    34793494                    else
     
    35353550
    35363551    RTThreadPreemptRestore(&PreemptState);
     3552    if (fIsSmxModeAmbiguous)
     3553        SUPR0Printf(("Warning!!! CR4 hints SMX mode but your CPU is too secretive. Proceeding anyway... Wish us luck!\n"));
    35373554    return rc;
    35383555}
  • trunk/src/VBox/VMM/VMMR0/HMR0.cpp

    r50333 r50540  
    797797    NOREF(idCpu); NOREF(pvUser2);
    798798
    799     uint64_t   fFC            = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
    800     bool const fInSmxMode     = RT_BOOL(ASMGetCR4() & X86_CR4_SMXE);
    801     bool       fMsrLocked     = RT_BOOL(fFC & MSR_IA32_FEATURE_CONTROL_LOCK);
    802     bool       fSmxVmxAllowed = RT_BOOL(fFC & MSR_IA32_FEATURE_CONTROL_SMX_VMXON);
    803     bool       fVmxAllowed    = RT_BOOL(fFC & MSR_IA32_FEATURE_CONTROL_VMXON);
     799    uint64_t   u64FeatMsr     = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
     800    bool const fMaybeSmxMode  = RT_BOOL(ASMGetCR4() & X86_CR4_SMXE);
     801    bool       fMsrLocked     = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK);
     802    bool       fSmxVmxAllowed = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON);
     803    bool       fVmxAllowed    = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON);
    804804
    805805    /* Check if the LOCK bit is set but excludes the required VMXON bit. */
     
    807807    if (fMsrLocked)
    808808    {
    809         if (fInSmxMode && !fSmxVmxAllowed)
    810             rc = VERR_VMX_MSR_SMX_VMXON_DISABLED;
    811         else if (!fInSmxMode && !fVmxAllowed)
    812             rc = VERR_VMX_MSR_VMXON_DISABLED;
     809        if (fVmxAllowed && fSmxVmxAllowed)
     810            rc = VINF_SUCCESS;
     811        else if (!fVmxAllowed && !fSmxVmxAllowed)
     812            rc = VERR_VMX_MSR_ALL_VMXON_DISABLED;
     813        else if (!fMaybeSmxMode)
     814        {
     815            if (fVmxAllowed)
     816                rc = VINF_SUCCESS;
     817            else
     818                rc = VERR_VMX_MSR_VMXON_DISABLED;
     819        }
    813820        else
     821        {
     822            /*
     823             * CR4.SMXE is set but this doesn't mean the CPU is necessarily in SMX mode. We shall assume
     824             * that it is -not- and that it is a stupid BIOS/OS setting CR4.SMXE for no good reason.
     825             * See @bugref{6873}.
     826             */
     827            Assert(fMaybeSmxMode == true);
    814828            rc = VINF_SUCCESS;
     829        }
    815830    }
    816831    else
     
    819834         * MSR is not yet locked; we can change it ourselves here.
    820835         * Once the lock bit is set, this MSR can no longer be modified.
     836         *
     837         * Set both the VMXON and SMX_VMXON bits as we can't determine SMX mode
     838         * accurately. See @bugref{6873}.
    821839         */
    822         fFC |= MSR_IA32_FEATURE_CONTROL_LOCK;
    823         if (fInSmxMode)
    824             fFC |= MSR_IA32_FEATURE_CONTROL_SMX_VMXON;
    825         else
    826             fFC |= MSR_IA32_FEATURE_CONTROL_VMXON;
    827 
    828         ASMWrMsr(MSR_IA32_FEATURE_CONTROL, fFC);
     840        u64FeatMsr |=   MSR_IA32_FEATURE_CONTROL_LOCK
     841                      | MSR_IA32_FEATURE_CONTROL_SMX_VMXON
     842                      | MSR_IA32_FEATURE_CONTROL_VMXON;
     843        ASMWrMsr(MSR_IA32_FEATURE_CONTROL, u64FeatMsr);
    829844
    830845        /* Verify. */
    831         fFC                 = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
    832         fMsrLocked          = RT_BOOL(fFC & MSR_IA32_FEATURE_CONTROL_LOCK);
    833         fSmxVmxAllowed      = fMsrLocked && RT_BOOL(fFC & MSR_IA32_FEATURE_CONTROL_SMX_VMXON);
    834         fVmxAllowed         = fMsrLocked && RT_BOOL(fFC & MSR_IA32_FEATURE_CONTROL_VMXON);
    835         bool const fAllowed = fInSmxMode ? fSmxVmxAllowed : fVmxAllowed;
    836         if (fAllowed)
     846        u64FeatMsr     = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
     847        fMsrLocked     = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK);
     848        fSmxVmxAllowed = fMsrLocked && RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON);
     849        fVmxAllowed    = fMsrLocked && RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON);
     850        if (fSmxVmxAllowed && fVmxAllowed)
    837851            rc = VINF_SUCCESS;
    838852        else
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r49925 r50540  
    508508                    break;
    509509
    510                 case VERR_VMX_MSR_SMX_VMXON_DISABLED:
    511                     pszMsg = "VT-x is disabled in the BIOS for Safer-Mode/Trusted Extensions.";
     510                case VERR_VMX_MSR_ALL_VMXON_DISABLED:
     511                    pszMsg = "VT-x is disabled in the BIOS for all CPU modes.";
    512512                    break;
    513513
     
    917917            case VERR_VMX_MSR_VMXON_DISABLED:
    918918                return VM_SET_ERROR(pVM, VERR_VMX_NO_VMX, "VT-x is disabled in the BIOS.");
    919             case VERR_VMX_MSR_SMX_VMXON_DISABLED:
    920                 return VM_SET_ERROR(pVM, VERR_VMX_NO_VMX, "VT-x is disabled in the BIOS for Safer-Mode/Trusted Extensions.");
     919            case VERR_VMX_MSR_ALL_VMXON_DISABLED:
     920                return VM_SET_ERROR(pVM, VERR_VMX_NO_VMX, "VT-x is disabled in the BIOS for all CPU modes.");
    921921            case VERR_VMX_MSR_LOCKING_FAILED:
    922922                return VM_SET_ERROR(pVM, VERR_VMX_NO_VMX, "Failed to enable and lock VT-x features.");
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