]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cputest: Fix comparison in checkCPUIDFeature in cpu-cpuid.py
authorJiri Denemark <jdenemar@redhat.com>
Mon, 1 Apr 2019 16:26:38 +0000 (18:26 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 12 Apr 2019 20:53:39 +0000 (22:53 +0200)
leaf["eax"] & eax > 0 check works correctly only if there's at most 1
bit set in eax. Luckily that's been always the case, but fixing this
could save us from future surprises.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/cputestdata/cpu-cpuid.py

index 866c8047cd54e4c465d6d8481d7e04bac28873ca..0a2710689db3d6b372db10908778786a946c1387 100755 (executable)
@@ -15,12 +15,12 @@ def checkFeature(cpuid, feature):
 
     if in_eax not in cpuid or in_ecx not in cpuid[in_eax]:
         return False
-    else:
-        leaf = cpuid[in_eax][in_ecx]
-        return ((eax > 0 and leaf["eax"] & eax > 0) or
-                (ebx > 0 and leaf["ebx"] & ebx > 0) or
-                (ecx > 0 and leaf["ecx"] & ecx > 0) or
-                (edx > 0 and leaf["edx"] & edx > 0))
+
+    leaf = cpuid[in_eax][in_ecx]
+    return ((eax > 0 and leaf["eax"] & eax == eax) or
+            (ebx > 0 and leaf["ebx"] & ebx == ebx) or
+            (ecx > 0 and leaf["ecx"] & ecx == ecx) or
+            (edx > 0 and leaf["edx"] & edx == edx))
 
 
 def addFeature(cpuid, feature):