VirtualBox

Ignore:
Timestamp:
Sep 4, 2013 2:06:50 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
88682
Message:

VMM: Allow VT-x to be used in SMX mode, more granular error checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r48209 r48267  
    33943394        uint32_t fFeaturesECX, fFeaturesEDX, uDummy;
    33953395        uint32_t uMaxId, uVendorEBX, uVendorECX, uVendorEDX;
    3396         uint64_t u64Value;
     3396        uint64_t u64FeatMsr;
    33973397
    33983398        ASMCpuId(0, &uMaxId, &uVendorEBX, &uVendorECX, &uVendorEDX);
     
    34093409               )
    34103410            {
     3411                bool fInSmxMode;
     3412                bool fMsrLocked;
     3413                bool fSmxVmxAllowed;
     3414                bool fVmxAllowed;
     3415
    34113416                /*
    3412                  * Both the LOCK and VMXON bit must be set; otherwise VMXON will generate a #GP.
    3413                  * Once the lock bit is set, this MSR can no longer be modified.
     3417                 * We require the lock bit and the appropriate VMXON bit to be set otherwise VMXON will generate a #GP
     3418                 * This is a simplified check (assumes BIOS does it job and properly locks the control bit). For the more
     3419                 * extensive procedure see hmR0InitIntelCpu().
    34143420                 */
    3415                 u64Value = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
    3416                 if (      (u64Value & (MSR_IA32_FEATURE_CONTROL_VMXON | MSR_IA32_FEATURE_CONTROL_LOCK))
    3417                        ==             (MSR_IA32_FEATURE_CONTROL_VMXON | MSR_IA32_FEATURE_CONTROL_LOCK) /* enabled and locked */
    3418                     || !(u64Value & MSR_IA32_FEATURE_CONTROL_LOCK) /* not enabled, but not locked either */
    3419                    )
     3421                u64FeatMsr     = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
     3422                fInSmxMode     = !!(ASMGetCR4() & X86_CR4_SMXE);
     3423                fMsrLocked     = !!(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK);
     3424                fSmxVmxAllowed = fMsrLocked && !!(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON);
     3425                fVmxAllowed    = fMsrLocked && !!(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON);
     3426                if (   (fInSmxMode && fSmxVmxAllowed)
     3427                    || fVmxAllowed)
    34203428                {
    34213429                    VMX_CAPABILITY vtCaps;
     
    34323440                    return VINF_SUCCESS;
    34333441                }
    3434                 return VERR_VMX_MSR_LOCKED_OR_DISABLED;
     3442                return fInSmxMode ? VERR_VMX_MSR_SMX_VMXON_DISABLED : VERR_VMX_MSR_VMXON_DISABLED;
    34353443            }
    34363444            return VERR_VMX_NO_VMX;
     
    34513459            {
    34523460                /* Check if SVM is disabled */
    3453                 u64Value = ASMRdMsr(MSR_K8_VM_CR);
    3454                 if (!(u64Value & MSR_K8_VM_CR_SVM_DISABLE))
     3461                u64FeatMsr = ASMRdMsr(MSR_K8_VM_CR);
     3462                if (!(u64FeatMsr & MSR_K8_VM_CR_SVM_DISABLE))
    34553463                {
    34563464                    uint32_t fSvmFeatures;
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