Skip to contentSkip to conversation

nVMX: Add testcase to cover VMWRITE to nonexistent CR3-target values

PATCH In review Sean Christopherson 3 participants 4 messages Apr 16, 2020 – Apr 17, 2020 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nVMX: Add testcase to cover VMWRITE to nonexistent CR3-target values

Enhance test_cr3_targets() to verify that attempting to write CR3-target value fields beyond the reported number of supported targets fails.

---
 x86/vmx_tests.c | 4 ++++
 1 file changed, 4 insertions(+)
x86/vmx_tests.c +4 -0
index 1f97fe3..f5c72e6 100644
@@ -3570,6 +3570,10 @@ static void test_cr3_targets(void)
 	for (i = 0; i <= supported_targets + 1; i++)
 		try_cr3_target_count(i, supported_targets);
 	vmcs_write(CR3_TARGET_COUNT, cr3_targets);
+
+	/* VMWRITE to nonexistent target fields should fail. */
+	for (i = supported_targets; i < 256; i++)
+		TEST_ASSERT(vmcs_write(CR3_TARGET_0 + i*2, 0));
 }
 
 /*
Signature · 1 line
2.26.0
#1 lore raw
Quoted 13 lines · Sean Christopherson

Enhance test_cr3_targets() to verify that attempting to write CR3-target value fields beyond the reported number of supported targets fails.

---
  x86/vmx_tests.c | 4 ++++
  1 file changed, 4 insertions(+)
x86/vmx_tests.c +0 -0
index 1f97fe3..f5c72e6 100644

x86/vmx_tests.c static void test_cr3_targets(void) · line 3579

Quoted 10 lines
x86/vmx_tests.c +4 -0
@@ -3570,6 +3570,10 @@ static void test_cr3_targets(void)
  	for (i = 0; i <= supported_targets + 1; i++)
  		try_cr3_target_count(i, supported_targets);
  	vmcs_write(CR3_TARGET_COUNT, cr3_targets);
+
+	/* VMWRITE to nonexistent target fields should fail. */
+	for (i = supported_targets; i < 256; i++)
+		TEST_ASSERT(vmcs_write(CR3_TARGET_0 + i*2, 0));
  }
 
  /*

We don't need VMREAD testing ?

maintainer
#2 lore raw
Quoted 10 lines · Krish Sadhukhan
Quoted 8 lines · Sean Christopherson

Enhance test_cr3_targets() to verify that attempting to write CR3-target value fields beyond the reported number of supported targets fails.

---
  x86/vmx_tests.c | 4 ++++

  1 file changed, 4 insertions(+)
Quoted 15 lines
Quoted 5 lines
x86/vmx_tests.c +0 -0
index 1f97fe3..f5c72e6 100644

x86/vmx_tests.c static void test_cr3_targets(void) · line 3578

Quoted 9 lines
x86/vmx_tests.c +4 -0
@@ -3570,6 +3570,10 @@ static void test_cr3_targets(void)
       for (i = 0; i <= supported_targets + 1; i++)
           try_cr3_target_count(i, supported_targets);
       vmcs_write(CR3_TARGET_COUNT, cr3_targets);
+
+    /* VMWRITE to nonexistent target fields should fail. */
+    for (i = supported_targets; i < 256; i++)
+        TEST_ASSERT(vmcs_write(CR3_TARGET_0 + i*2, 0));
   }
     /*

We don't need VMREAD testing ?

Patches are welcome. :D

Paolo

Reviewed-by
#3 lore raw
Quoted 25 lines · Paolo Bonzini
Quoted 9 lines · Krish Sadhukhan
Quoted 8 lines · Sean Christopherson

Enhance test_cr3_targets() to verify that attempting to write CR3-target value fields beyond the reported number of supported targets fails.

---
   x86/vmx_tests.c | 4 ++++
   1 file changed, 4 insertions(+)
Quoted 15 lines
Quoted 5 lines
x86/vmx_tests.c +0 -0
index 1f97fe3..f5c72e6 100644

x86/vmx_tests.c static void test_cr3_targets(void) · line 3578

Quoted 9 lines
x86/vmx_tests.c +4 -0
@@ -3570,6 +3570,10 @@ static void test_cr3_targets(void)
       for (i = 0; i <= supported_targets + 1; i++)
           try_cr3_target_count(i, supported_targets);
       vmcs_write(CR3_TARGET_COUNT, cr3_targets);
+
+    /* VMWRITE to nonexistent target fields should fail. */
+    for (i = supported_targets; i < 256; i++)
+        TEST_ASSERT(vmcs_write(CR3_TARGET_0 + i*2, 0));
   }
     /*

We don't need VMREAD testing ?

Quoted 4 lines

Patches are welcome. :D

Paolo

OK, I will send it along with my next test patch :-)