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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 x86/pcid.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

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;
-- 
2.30.0.478.g8a0d178c01-goog




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux