From: Andrew Cooper Date: Mon, 14 Nov 2016 10:03:58 +0000 (+0000) Subject: Improvements to the cpuid utility X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b88457eea65b56e8a18dedff43759b020f93b241;p=people%2Fandrewcoop%2Fxen-test-framework.git Improvements to the cpuid utility * Enable viridian for HVM guests to expose more leaves * Identify the Xen leaves, and add subleaf logic Signed-off-by: Andrew Cooper --- diff --git a/tests/cpuid/Makefile b/tests/cpuid/Makefile index a6a66b3..6cf92a3 100644 --- a/tests/cpuid/Makefile +++ b/tests/cpuid/Makefile @@ -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 index 0000000..95999d9 --- /dev/null +++ b/tests/cpuid/extra.cfg.in @@ -0,0 +1,2 @@ +# Enable viridian for HVM domains +viridian = 1 diff --git a/tests/cpuid/main.c b/tests/cpuid/main.c index f3e5960..db638d1 100644 --- a/tests/cpuid/main.c +++ b/tests/cpuid/main.c @@ -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; } }