Changeset 48267 in vbox
- Timestamp:
- Sep 4, 2013 2:06:50 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/err.h
r47789 r48267 1905 1905 /** Somebody cleared X86_CR4_VMXE in the CR4 register. */ 1906 1906 #define VERR_VMX_X86_CR4_VMXE_CLEARED (-4012) 1907 /** VT-x features locked or unavailable in MSR. */1908 #define VERR_VMX_MSR_LOCK ED_OR_DISABLED(-4013)1907 /** Failed to enable and lock VT-x features. */ 1908 #define VERR_VMX_MSR_LOCKING_FAILED (-4013) 1909 1909 /** Unable to switch due to invalid guest state. */ 1910 1910 #define VERR_VMX_INVALID_GUEST_STATE (-4014) … … 1933 1933 /** Internal VMX processing error no 1. */ 1934 1934 #define VERR_HMVMX_IPE_5 (-4027) 1935 /** VT-x features for SMX operation disabled by the BIOS. */ 1936 #define VERR_VMX_MSR_SMX_VMXON_DISABLED (-4028) 1937 /** VT-x features disabled by the BIOS. */ 1938 #define VERR_VMX_MSR_VMXON_DISABLED (-4029) 1935 1939 /** @} */ 1936 1940 -
trunk/include/iprt/x86.h
r48151 r48267 950 950 #define MSR_IA32_FEATURE_CONTROL 0x3A 951 951 #define MSR_IA32_FEATURE_CONTROL_LOCK RT_BIT(0) 952 #define MSR_IA32_FEATURE_CONTROL_SMX_VMXON RT_BIT(1) 952 953 #define MSR_IA32_FEATURE_CONTROL_VMXON RT_BIT(2) 953 954 … … 1180 1181 /** K8 FS.base - The 64-bit base FS register. */ 1181 1182 #define MSR_K8_FS_BASE UINT32_C(0xc0000100) 1182 /** K8 GS.base - The 64-bit base GS register. */ 1183 /** K8 GS.base - The 64-bit base GS register. */ 1183 1184 #define MSR_K8_GS_BASE UINT32_C(0xc0000101) 1184 1185 /** K8 KernelGSbase - Used with SWAPGS. */ -
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r48209 r48267 3394 3394 uint32_t fFeaturesECX, fFeaturesEDX, uDummy; 3395 3395 uint32_t uMaxId, uVendorEBX, uVendorECX, uVendorEDX; 3396 uint64_t u64 Value;3396 uint64_t u64FeatMsr; 3397 3397 3398 3398 ASMCpuId(0, &uMaxId, &uVendorEBX, &uVendorECX, &uVendorEDX); … … 3409 3409 ) 3410 3410 { 3411 bool fInSmxMode; 3412 bool fMsrLocked; 3413 bool fSmxVmxAllowed; 3414 bool fVmxAllowed; 3415 3411 3416 /* 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(). 3414 3420 */ 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) 3420 3428 { 3421 3429 VMX_CAPABILITY vtCaps; … … 3432 3440 return VINF_SUCCESS; 3433 3441 } 3434 return VERR_VMX_MSR_LOCKED_OR_DISABLED;3442 return fInSmxMode ? VERR_VMX_MSR_SMX_VMXON_DISABLED : VERR_VMX_MSR_VMXON_DISABLED; 3435 3443 } 3436 3444 return VERR_VMX_NO_VMX; … … 3451 3459 { 3452 3460 /* Check if SVM is disabled */ 3453 u64 Value= ASMRdMsr(MSR_K8_VM_CR);3454 if (!(u64 Value& MSR_K8_VM_CR_SVM_DISABLE))3461 u64FeatMsr = ASMRdMsr(MSR_K8_VM_CR); 3462 if (!(u64FeatMsr & MSR_K8_VM_CR_SVM_DISABLE)) 3455 3463 { 3456 3464 uint32_t fSvmFeatures; -
trunk/src/VBox/VMM/VMMR0/HMR0.cpp
r48230 r48267 799 799 800 800 /** 801 * Worker function used by hmR0PowerCallback and HMR0Init to initalize802 * VT-xon a CPU.801 * Worker function used by hmR0PowerCallback() and HMR0Init() to initalize VT-x 802 * on a CPU. 803 803 * 804 804 * @param idCpu The identifier for the CPU the function is called on. … … 812 812 NOREF(pvUser2); 813 813 814 /*815 * Both the LOCK and VMXON bit must be set; otherwise VMXON will generate a #GP.816 * Once the lock bit is set, this MSR can no longer be modified.817 */818 814 uint64_t fFC = ASMRdMsr(MSR_IA32_FEATURE_CONTROL); 819 if ( !(fFC & (MSR_IA32_FEATURE_CONTROL_VMXON | MSR_IA32_FEATURE_CONTROL_LOCK)) 820 || ( (fFC & (MSR_IA32_FEATURE_CONTROL_VMXON | MSR_IA32_FEATURE_CONTROL_LOCK)) 821 == MSR_IA32_FEATURE_CONTROL_VMXON ) /* Some BIOSes forget to set the locked bit. */ 822 ) 823 { 824 /* MSR is not yet locked; we can change it ourselves here. */ 825 ASMWrMsr(MSR_IA32_FEATURE_CONTROL, 826 g_HvmR0.vmx.Msrs.u64FeatureCtrl | MSR_IA32_FEATURE_CONTROL_VMXON | MSR_IA32_FEATURE_CONTROL_LOCK); 815 bool const fInSmxMode = !!(ASMGetCR4() & X86_CR4_SMXE); 816 bool fMsrLocked = !!(fFC & MSR_IA32_FEATURE_CONTROL_LOCK); 817 bool fSmxVmxAllowed = !!(fFC & MSR_IA32_FEATURE_CONTROL_SMX_VMXON); 818 bool fVmxAllowed = !!(fFC & MSR_IA32_FEATURE_CONTROL_VMXON); 819 820 /* Check if the LOCK bit is set but excludes the required VMXON bit. */ 821 int rc = VERR_HM_IPE_1; 822 if (fMsrLocked) 823 { 824 if (fInSmxMode && !fSmxVmxAllowed) 825 rc = VERR_VMX_MSR_SMX_VMXON_DISABLED; 826 else if (!fVmxAllowed) 827 rc = VERR_VMX_MSR_VMXON_DISABLED; 828 else 829 rc = VINF_SUCCESS; 830 } 831 else 832 { 833 /* 834 * MSR is not yet locked; we can change it ourselves here. 835 * Once the lock bit is set, this MSR can no longer be modified. 836 */ 837 fFC |= MSR_IA32_FEATURE_CONTROL_LOCK; 838 if (fInSmxMode) 839 fFC |= MSR_IA32_FEATURE_CONTROL_SMX_VMXON; 840 else 841 fFC |= MSR_IA32_FEATURE_CONTROL_VMXON; 842 843 ASMWrMsr(MSR_IA32_FEATURE_CONTROL, fFC); 844 845 /* Verify. */ 827 846 fFC = ASMRdMsr(MSR_IA32_FEATURE_CONTROL); 828 } 829 830 int rc; 831 if ((fFC & (MSR_IA32_FEATURE_CONTROL_VMXON | MSR_IA32_FEATURE_CONTROL_LOCK)) 832 == (MSR_IA32_FEATURE_CONTROL_VMXON | MSR_IA32_FEATURE_CONTROL_LOCK)) 833 { 834 rc = VINF_SUCCESS; 835 } 836 else 837 rc = VERR_VMX_MSR_LOCKED_OR_DISABLED; 847 fMsrLocked = !!(fFC & MSR_IA32_FEATURE_CONTROL_LOCK); 848 fSmxVmxAllowed = fMsrLocked && !!(fFC & MSR_IA32_FEATURE_CONTROL_SMX_VMXON); 849 fVmxAllowed = fMsrLocked && !!(fFC & MSR_IA32_FEATURE_CONTROL_VMXON); 850 851 if ( (fInSmxMode && fSmxVmxAllowed) 852 || fVmxAllowed) 853 { 854 rc = VINF_SUCCESS; 855 } 856 else 857 rc = VERR_VMX_MSR_LOCKING_FAILED; 858 } 838 859 839 860 hmR0FirstRcSetStatus(pFirstRc, rc); … … 929 950 930 951 /** 931 * Worker function passed to RTMpOnAll, RTMpOnOthers and RTMpOnSpecific that 932 * is to be called on the target cpus. 952 * Worker function passed to RTMpOnAll() that is to be called on all CPUs. 933 953 * 934 954 * @param idCpu The identifier for the CPU the function is called on. -
trunk/src/VBox/VMM/VMMR3/HM.cpp
r48262 r48267 504 504 break; 505 505 506 case VERR_VMX_MSR_LOCKED_OR_DISABLED: 507 pszMsg = "VT-x is disabled in the BIOS (or by the host OS)."; 506 case VERR_VMX_MSR_VMXON_DISABLED: 507 pszMsg = "VT-x is disabled in the BIOS."; 508 break; 509 510 case VERR_VMX_MSR_SMX_VMXON_DISABLED: 511 pszMsg = "VT-x is disabled in the BIOS for Safer-Mode/Trusted Extensions."; 512 break; 513 514 case VERR_VMX_MSR_LOCKING_FAILED: 515 pszMsg = "Failed to enable and lock VT-x features."; 508 516 break; 509 517 … … 906 914 case VERR_VMX_NO_VMX: 907 915 return VM_SET_ERROR(pVM, VERR_VMX_NO_VMX, "VT-x is not available."); 908 case VERR_VMX_MSR_LOCKED_OR_DISABLED: 909 return VM_SET_ERROR(pVM, VERR_VMX_NO_VMX, "VT-x is disabled in the BIOS (or by the host OS)."); 916 case VERR_VMX_MSR_VMXON_DISABLED: 917 return VM_SET_ERROR(pVM, VERR_VMX_NO_VMX, "VT-x is disabled in the BIOS."); 918 case VERR_VMX_MSR_SMX_VMXON_DISABLED: 919 return VM_SET_ERROR(pVM, VERR_VMX_NO_VMX, "VT-x is disabled in the BIOS for Safer-Mode/Trusted Extensions."); 920 case VERR_VMX_MSR_LOCKING_FAILED: 921 return VM_SET_ERROR(pVM, VERR_VMX_NO_VMX, "Failed to enable and lock VT-x features."); 910 922 911 923 case VERR_SVM_IN_USE:
Note:
See TracChangeset
for help on using the changeset viewer.