Changeset 50540 in vbox for trunk/src/VBox/HostDrivers/Support
- 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/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 }
Note:
See TracChangeset
for help on using the changeset viewer.