diff mbox series

[kvm-unit-tests,2/4] x86: Iterate over all INVPCID types in the enabled test

Message ID 20210212010606.1118184-3-seanjc@google.com (mailing list archive)
State New, archived
Headers show
Series x86: PCID test adjustments | expand

Commit Message

Sean Christopherson Feb. 12, 2021, 1:06 a.m. UTC
Verify that INVPCID works with all types, even those that take a PCID,
when CR4.PCIDE=0.  So long as the target PCID=0, INVPCID is legal even
if CR4.PCIDE=0.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/pcid.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/x86/pcid.c b/x86/pcid.c
index ee0b726..64efd05 100644
--- a/x86/pcid.c
+++ b/x86/pcid.c
@@ -70,24 +70,28 @@  report:
 
 static void test_invpcid_enabled(void)
 {
-    int passed = 0;
+    int passed = 0, i;
     ulong cr4 = read_cr4();
     struct invpcid_desc desc;
     desc.rsv = 0;
 
-    /* try executing invpcid when CR4.PCIDE=0, desc.pcid=0 and type=1
+    /* try executing invpcid when CR4.PCIDE=0, desc.pcid=0 and type=0..3
      * no exception expected
      */
     desc.pcid = 0;
-    if (invpcid_checking(1, &desc) != 0)
-        goto report;
+    for (i = 0; i < 4; i++) {
+        if (invpcid_checking(i, &desc) != 0)
+            goto report;
+    }
 
-    /* try executing invpcid when CR4.PCIDE=0, desc.pcid=1 and type=1
+    /* try executing invpcid when CR4.PCIDE=0, desc.pcid=1 and type=0..1
      * #GP expected
      */
     desc.pcid = 1;
-    if (invpcid_checking(1, &desc) != GP_VECTOR)
-        goto report;
+    for (i = 0; i < 2; i++) {
+        if (invpcid_checking(i, &desc) != GP_VECTOR)
+            goto report;
+    }
 
     if (write_cr4_checking(cr4 | X86_CR4_PCIDE) != 0)
         goto report;