VirtualBox

Ignore:
Timestamp:
Feb 21, 2014 12:51:57 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92390
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
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