Changeset 49178 in vbox for trunk/src/VBox/HostDrivers/Support
- Timestamp:
- Oct 18, 2013 12:17:21 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r48328 r49178 3413 3413 ) 3414 3414 { 3415 bool fInSmxMode; 3416 bool fMsrLocked; 3417 bool fSmxVmxAllowed; 3418 bool fVmxAllowed; 3419 bool fAllowed; 3420 3421 /* 3422 * We require the lock bit and the appropriate VMXON bit to be set otherwise VMXON will generate a #GP 3423 * This is a simplified check (assumes BIOS does it job and properly locks the control bit). For the more 3424 * extensive procedure see hmR0InitIntelCpu(). 3425 */ 3426 u64FeatMsr = ASMRdMsr(MSR_IA32_FEATURE_CONTROL); 3427 fInSmxMode = !!(ASMGetCR4() & X86_CR4_SMXE); 3428 fMsrLocked = !!(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK); 3429 fSmxVmxAllowed = fMsrLocked && !!(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON); 3430 fVmxAllowed = fMsrLocked && !!(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON); 3431 fAllowed = fInSmxMode ? fSmxVmxAllowed : fVmxAllowed; 3432 if (fAllowed) 3415 /** @todo Unify code with hmR0InitIntelCpu(). */ 3416 uint64_t u64FeatMsr = ASMRdMsr(MSR_IA32_FEATURE_CONTROL); 3417 bool const fInSmxMode = RT_BOOL(ASMGetCR4() & X86_CR4_SMXE); 3418 bool fMsrLocked = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK); 3419 bool fSmxVmxAllowed = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON); 3420 bool fVmxAllowed = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON); 3421 3422 /* Check if the LOCK bit is set but excludes the required VMXON bit. */ 3423 int rc = VERR_HM_IPE_1; 3424 if (fMsrLocked) 3425 { 3426 if (fInSmxMode && !fSmxVmxAllowed) 3427 rc = VERR_VMX_MSR_SMX_VMXON_DISABLED; 3428 else if (!fVmxAllowed) 3429 rc = VERR_VMX_MSR_VMXON_DISABLED; 3430 else 3431 rc = VINF_SUCCESS; 3432 } 3433 else 3434 { 3435 /* 3436 * MSR is not yet locked; we can change it ourselves here. 3437 * Once the lock bit is set, this MSR can no longer be modified. 3438 */ 3439 bool fAllowed; 3440 u64FeatMsr |= MSR_IA32_FEATURE_CONTROL_LOCK; 3441 if (fInSmxMode) 3442 u64FeatMsr |= MSR_IA32_FEATURE_CONTROL_SMX_VMXON; 3443 else 3444 u64FeatMsr |= MSR_IA32_FEATURE_CONTROL_VMXON; 3445 3446 ASMWrMsr(MSR_IA32_FEATURE_CONTROL, u64FeatMsr); 3447 3448 /* Verify. */ 3449 u64FeatMsr = ASMRdMsr(MSR_IA32_FEATURE_CONTROL); 3450 fMsrLocked = RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_LOCK); 3451 fSmxVmxAllowed = fMsrLocked && RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_SMX_VMXON); 3452 fVmxAllowed = fMsrLocked && RT_BOOL(u64FeatMsr & MSR_IA32_FEATURE_CONTROL_VMXON); 3453 fAllowed = fInSmxMode ? fSmxVmxAllowed : fVmxAllowed; 3454 if (fAllowed) 3455 rc = VINF_SUCCESS; 3456 else 3457 rc = VERR_VMX_MSR_LOCKING_FAILED; 3458 } 3459 3460 if (rc == VINF_SUCCESS) 3433 3461 { 3434 3462 VMX_CAPABILITY vtCaps; … … 3445 3473 return VINF_SUCCESS; 3446 3474 } 3447 return fInSmxMode ? VERR_VMX_MSR_SMX_VMXON_DISABLED : VERR_VMX_MSR_VMXON_DISABLED;3475 return rc; 3448 3476 } 3449 3477 return VERR_VMX_NO_VMX;
Note:
See TracChangeset
for help on using the changeset viewer.