]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Improvements to the cpuid utility
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 14 Nov 2016 10:03:58 +0000 (10:03 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 16 Nov 2016 12:46:39 +0000 (12:46 +0000)
 * Enable viridian for HVM guests to expose more leaves
 * Identify the Xen leaves, and add subleaf logic

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
tests/cpuid/Makefile
tests/cpuid/extra.cfg.in [new file with mode: 0644]
tests/cpuid/main.c

index a6a66b3dcc829d41732c257b60e195ca44e6812e..6cf92a37a9a39b57193f40c4aec79b77fce99d28 100644 (file)
@@ -4,6 +4,8 @@ NAME      := cpuid
 CATEGORY  := utility
 TEST-ENVS := $(ALL_ENVIRONMENTS)
 
+TEST-EXTRA-CFG := extra.cfg.in
+
 obj-perenv += main.o
 
 include $(ROOT)/build/gen.mk
diff --git a/tests/cpuid/extra.cfg.in b/tests/cpuid/extra.cfg.in
new file mode 100644 (file)
index 0000000..95999d9
--- /dev/null
@@ -0,0 +1,2 @@
+# Enable viridian for HVM domains
+viridian = 1
index f3e59608d4c47bd3919198c775affc1d3e575095..db638d1a11d8c84c5d1751b84abcc49527a41088 100644 (file)
@@ -18,6 +18,7 @@ static void dump_leaves(cpuid_count_fn_t cpuid_fn)
     uint64_t valid_xstate_leaves = 0;
     uint32_t max_leaf = 0, max_l7_subleaf = 0,
         max_hv_leaf = 0, max_hv2_leaf = 0, max_extd_leaf = 0;
+    uint32_t xen_first_leaf = ~0, xen_last_leaf = 0;
 
     for ( ;; )
     {
@@ -62,10 +63,28 @@ static void dump_leaves(cpuid_count_fn_t cpuid_fn)
 
         case 0x40000000U:
             max_hv_leaf = eax;
+
+            if ( ebx == XEN_CPUID_SIGNATURE_EBX &&
+                 ecx == XEN_CPUID_SIGNATURE_ECX &&
+                 edx == XEN_CPUID_SIGNATURE_EDX )
+            {
+                xen_first_leaf = leaf;
+                xen_last_leaf = eax;
+            }
+
             break;
 
         case 0x40000100U:
             max_hv2_leaf = eax;
+
+            if ( ebx == XEN_CPUID_SIGNATURE_EBX &&
+                 ecx == XEN_CPUID_SIGNATURE_ECX &&
+                 edx == XEN_CPUID_SIGNATURE_EDX )
+            {
+                xen_first_leaf = leaf;
+                xen_last_leaf = eax;
+            }
+
             break;
 
         case 0x80000000U:
@@ -73,6 +92,25 @@ static void dump_leaves(cpuid_count_fn_t cpuid_fn)
             break;
         }
 
+        if ( leaf >= xen_first_leaf && leaf <= xen_last_leaf )
+        {
+            /* The Xen leaves have no documented identification of max leaf. */
+
+            switch ( leaf - xen_first_leaf )
+            {
+            case 3:
+                if ( subleaf < 2 ) /* Max leaf hardcoded. */
+                {
+                    subleaf++;
+                    continue;
+                }
+                break;
+
+            case 4: /* Leaf semantics, but ??? */
+                break;
+            }
+        }
+
         leaf++;
         if ( (leaf > 0) && (leaf < 0x40000000U) && (leaf > max_leaf) )
             leaf = 0x40000000U;
@@ -87,7 +125,9 @@ static void dump_leaves(cpuid_count_fn_t cpuid_fn)
             break;
 
         subleaf = ~0;
-        if ( leaf == 4 || leaf == 7 || leaf == 0xd )
+        if ( leaf == 4 || leaf == 7 || leaf == 0xd ||
+             ((leaf >= xen_first_leaf && leaf <= xen_last_leaf) &&
+              ((leaf - xen_first_leaf) == 3 || (leaf - xen_first_leaf) == 4)) )
             subleaf = 0;
     }
 }