Changeset 50540 in vbox for trunk/src/VBox/VMM/VMMR0
- Timestamp:
- Feb 21, 2014 12:51:57 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 92390
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.