Skip to content

Commit 041bd59

Browse files
shiqinggwenlingz
authored andcommitted
hv: improve the readability of ept_cap_detect
- improve the readability of ept_cap_detect right shift 32 bits of msr_val to check bits 63:32 of msr_val Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent bacfc9b commit 041bd59

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,20 @@ static void ept_cap_detect(void)
776776
/* Read primary processor based VM control. */
777777
msr_val = msr_read(MSR_IA32_VMX_PROCBASED_CTLS);
778778

779+
/*
780+
* According to SDM A.3.2 Primary Processor-Based VM-Execution Controls:
781+
* The IA32_VMX_PROCBASED_CTLS MSR (index 482H) reports on the allowed
782+
* settings of most of the primary processor-based VM-execution controls
783+
* (see Section 24.6.2):
784+
* Bits 63:32 indicate the allowed 1-settings of these controls.
785+
* VM entry allows control X to be 1 if bit 32+X in the MSR is set to 1;
786+
* if bit 32+X in the MSR is cleared to 0, VM entry fails if control X
787+
* is 1.
788+
*/
789+
msr_val = msr_val >> 32U;
790+
779791
/* Check if secondary processor based VM control is available. */
780-
if ((msr_val & (((uint64_t)VMX_PROCBASED_CTLS_SECONDARY) << 32)) == 0U)
792+
if ((msr_val & VMX_PROCBASED_CTLS_SECONDARY) == 0UL)
781793
return;
782794

783795
/* Read secondary processor based VM control. */

0 commit comments

Comments
 (0)