Changeset 50540 in vbox
- Timestamp:
- Feb 21, 2014 12:51:57 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/err.h
r49893 r50540 1947 1947 /** Internal VMX processing error no 1. */ 1948 1948 #define VERR_HMVMX_IPE_5 (-4027) 1949 /** VT-x features for SMX operationdisabled 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) 1951 1951 /** VT-x features disabled by the BIOS. */ 1952 1952 #define VERR_VMX_MSR_VMXON_DISABLED (-4029) -
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r50333 r50540 3394 3394 * @returns VBox status code. 3395 3395 * @retval VERR_VMX_NO_VMX 3396 * @retval VERR_VMX_MSR_ SMX_VMXON_DISABLED3396 * @retval VERR_VMX_MSR_ALL_VMXON_DISABLED 3397 3397 * @retval VERR_VMX_MSR_VMXON_DISABLED 3398 3398 * @retval VERR_VMX_MSR_LOCKING_FAILED … … 3407 3407 SUPR0DECL(int) SUPR0QueryVTCaps(PSUPDRVSESSION pSession, uint32_t *pfCaps) 3408 3408 { 3409 int rc = VERR_UNSUPPORTED_CPU; 3409 int rc = VERR_UNSUPPORTED_CPU; 3410 bool fIsSmxModeAmbiguous = false; 3410 3411 RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER; 3411 3412 … … 3439 3440 /** @todo Unify code with hmR0InitIntelCpu(). */ 3440 3441 uint64_t u64FeatMsr = ASMRdMsr(MSR_IA32_FEATURE_CONTROL); 3441 bool const f InSmxMode= RT_BOOL(ASMGetCR4() & X86_CR4_SMXE);3442 bool const fMaybeSmxMode = RT_BOOL(ASMGetCR4() & X86_CR4_SMXE); 3442 3443 bool fMsrLocked = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK); 3443 3444 bool fSmxVmxAllowed = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON); … … 3447 3448 if (fMsrLocked) 3448 3449 { 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 } 3453 3461 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; 3454 3470 rc = VINF_SUCCESS; 3471 } 3455 3472 } 3456 3473 else … … 3459 3476 * MSR is not yet locked; we can change it ourselves here. 3460 3477 * 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}. 3461 3481 */ 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; 3469 3485 ASMWrMsr(MSR_IA32_FEATURE_CONTROL, u64FeatMsr); 3470 3486 … … 3474 3490 fSmxVmxAllowed = fMsrLocked && RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON); 3475 3491 fVmxAllowed = fMsrLocked && RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON); 3476 fAllowed = fInSmxMode ? fSmxVmxAllowed : fVmxAllowed; 3477 if (fAllowed) 3492 if (fSmxVmxAllowed && fVmxAllowed) 3478 3493 rc = VINF_SUCCESS; 3479 3494 else … … 3535 3550 3536 3551 RTThreadPreemptRestore(&PreemptState); 3552 if (fIsSmxModeAmbiguous) 3553 SUPR0Printf(("Warning!!! CR4 hints SMX mode but your CPU is too secretive. Proceeding anyway... Wish us luck!\n")); 3537 3554 return rc; 3538 3555 } -
trunk/src/VBox/VMM/VMMR0/HMR0.cpp
r50333 r50540 797 797 NOREF(idCpu); NOREF(pvUser2); 798 798 799 uint64_t fFC= ASMRdMsr(MSR_IA32_FEATURE_CONTROL);800 bool const f InSmxMode= 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); 804 804 805 805 /* Check if the LOCK bit is set but excludes the required VMXON bit. */ … … 807 807 if (fMsrLocked) 808 808 { 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 } 813 820 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); 814 828 rc = VINF_SUCCESS; 829 } 815 830 } 816 831 else … … 819 834 * MSR is not yet locked; we can change it ourselves here. 820 835 * 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}. 821 839 */ 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); 829 844 830 845 /* 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) 837 851 rc = VINF_SUCCESS; 838 852 else -
trunk/src/VBox/VMM/VMMR3/HM.cpp
r49925 r50540 508 508 break; 509 509 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."; 512 512 break; 513 513 … … 917 917 case VERR_VMX_MSR_VMXON_DISABLED: 918 918 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."); 921 921 case VERR_VMX_MSR_LOCKING_FAILED: 922 922 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.