Skip to contentSkip to conversation

x86/vmx: Skip LAM CR3 bits in 32-bit guest reserved bit tests

PATCH Applied Xudong Hao 3 participants 3 messages Jul 7 – Sep 8 KVM

lore
Share & tools
lore

Xudong Hao

author
#0 lore raw

PATCH 1/1 x86/vmx: Skip LAM CR3 bits in 32-bit guest reserved bit tests

According to Intel SDM 4.4.1 "Linear-Address Masking" (LAM), CR3 bits 61 (LAM_U57) and 62 (LAM_U48) are LAM control bits, not reserved. Skip the LAM control bits in the CR3 reserved-bit loops when LAM is supported for vmx_pae_test and vmx_pse_test.

Fixes 55b77db1 ("vmx: add a test for 32-bit guest PAE paging PDPTEs")
Fixes feef9d92 ("vmx: add test for 32-bit non-PAE guest")
---
 x86/vmx_tests.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
x86/vmx_tests.c +10 -0
index 16f8a648..2c0feca0 100644
@@ -5896,6 +5896,11 @@ static void test_vmx_guest_pdptes(u64 cr3, u64 *pdpt)
 	}
 
 	for (b = cpuid_maxphyaddr(); b < 64; b++) {
+		/* CR3 bits 61 and 62 are LAM control bits, not reserved. */
+		if (this_cpu_has(X86_FEATURE_LAM) &&
+		    (b == X86_CR3_LAM_U57_BIT || b == X86_CR3_LAM_U48_BIT))
+			continue;
+
 		vmx_32bit_guest_init_common(cr3 | (1ull << b), pdpt);
 		test_guest_state("CR3 reserved bit", true, (1ull << b), "bit");
 	}
@@ -5979,6 +5984,11 @@ static void vmx_pse_test(void)
 	}
 
 	for (b = cpuid_maxphyaddr(); b < 64; b++) {
+		/* CR3 bits 61 and 62 are LAM control bits, not reserved. */
+		if (this_cpu_has(X86_FEATURE_LAM) &&
+		    (b == X86_CR3_LAM_U57_BIT || b == X86_CR3_LAM_U48_BIT))
+			continue;
+
 		vmx_32bit_guest_init_common(cr3 | (1ull << b), NULL);
 		test_guest_state("CR3 reserved bit", true, (1ull << b), "bit");
 	}
Signature · 1 line
2.52.0
#1 lore raw
Quoted 31 lines · Xudong Hao

According to Intel SDM 4.4.1 "Linear-Address Masking" (LAM), CR3 bits 61 (LAM_U57) and 62 (LAM_U48) are LAM control bits, not reserved. Skip the LAM control bits in the CR3 reserved-bit loops when LAM is supported for vmx_pae_test and vmx_pse_test.

Fixes 55b77db1 ("vmx: add a test for 32-bit guest PAE paging PDPTEs")
Fixes feef9d92 ("vmx: add test for 32-bit non-PAE guest")
---
  x86/vmx_tests.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
x86/vmx_tests.c +5 -0
index 16f8a648..2c0feca0 100644
@@ -5896,6 +5896,11 @@ static void test_vmx_guest_pdptes(u64 cr3, u64 *pdpt)
  	}
 
  	for (b = cpuid_maxphyaddr(); b < 64; b++) {
+		/* CR3 bits 61 and 62 are LAM control bits, not reserved. */
+		if (this_cpu_has(X86_FEATURE_LAM) &&
+		    (b == X86_CR3_LAM_U57_BIT || b == X86_CR3_LAM_U48_BIT))
+			continue;
+
  		vmx_32bit_guest_init_common(cr3 | (1ull << b), pdpt);
  		test_guest_state("CR3 reserved bit", true, (1ull << b), "bit");
  	}
@@ -5979,6 +5984,11 @@ static void vmx_pse_test(void)
  	}

x86/vmx_tests.c static void vmx_pse_test(void) · line 5994

Quoted 10 lines
x86/vmx_tests.c +5 -0
 
  	for (b = cpuid_maxphyaddr(); b < 64; b++) {
+		/* CR3 bits 61 and 62 are LAM control bits, not reserved. */
+		if (this_cpu_has(X86_FEATURE_LAM) &&
+		    (b == X86_CR3_LAM_U57_BIT || b == X86_CR3_LAM_U48_BIT))
+			continue;
+
  		vmx_32bit_guest_init_common(cr3 | (1ull << b), NULL);
  		test_guest_state("CR3 reserved bit", true, (1ull << b), "bit");
  	}

Hi Paolo,

Can you help to review this patch?

-Xudong

maintainer Applied
#2 lore raw
In reply to Xudong Hao
Quoted 10 lines · Xudong Hao

According to Intel SDM 4.4.1 "Linear-Address Masking" (LAM), CR3 bits 61 (LAM_U57) and 62 (LAM_U48) are LAM control bits, not reserved. Skip the LAM control bits in the CR3 reserved-bit loops when LAM is supported for vmx_pae_test and vmx_pse_test.

Fixes 55b77db1 ("vmx: add a test for 32-bit guest PAE paging PDPTEs")
Fixes feef9d92 ("vmx: add test for 32-bit non-PAE guest")

Applied, thanks.

Paolo

Quoted 35 lines
---
 x86/vmx_tests.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
x86/vmx_tests.c +10 -1
index 16f8a648..2c0feca0 100644
@@ -5896,6 +5896,11 @@ static void test_vmx_guest_pdptes(u64 cr3, u64 *pdpt)
        }
 
        for (b = cpuid_maxphyaddr(); b < 64; b++) {
+               /* CR3 bits 61 and 62 are LAM control bits, not reserved. */
+               if (this_cpu_has(X86_FEATURE_LAM) &&
+                   (b == X86_CR3_LAM_U57_BIT || b == X86_CR3_LAM_U48_BIT))
+                       continue;
+
                vmx_32bit_guest_init_common(cr3 | (1ull << b), pdpt);
                test_guest_state("CR3 reserved bit", true, (1ull << b), "bit");
        }
@@ -5979,6 +5984,11 @@ static void vmx_pse_test(void)
        }
 
        for (b = cpuid_maxphyaddr(); b < 64; b++) {
+               /* CR3 bits 61 and 62 are LAM control bits, not reserved. */
+               if (this_cpu_has(X86_FEATURE_LAM) &&
+                   (b == X86_CR3_LAM_U57_BIT || b == X86_CR3_LAM_U48_BIT))
+                       continue;
+
                vmx_32bit_guest_init_common(cr3 | (1ull << b), NULL);
                test_guest_state("CR3 reserved bit", true, (1ull << b), "bit");
        }
--

2.52.0