]> xenbits.xensource.com Git - xen.git/commitdiff
x86: correctly report max number of hypervisor leaves
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>
Mon, 2 Jun 2014 08:20:23 +0000 (10:20 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 2 Jun 2014 08:20:23 +0000 (10:20 +0200)
Commit def0bbd31 provided support for changing max number of
hypervisor cpuid leaves (in leaf 0x4000xx00). It also made the
hypervisor incorrectly report this number for guests that
use default value (i.e. don't specify leaf 0x4000xx00 in config
file)

Reported-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
xen/arch/x86/traps.c

index 17229121f93b9da0eab19f34f86c1ad4472d34c6..b82b1b345e67e2d5563c0f1fb517d6682f646f0b 100644 (file)
@@ -692,13 +692,19 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx,
     if ( idx > XEN_CPUID_MAX_NUM_LEAVES )
         return 0; /* Avoid unnecessary pass through domain_cpuid() */
 
-    /* Number of leaves may be user-specified */
     domain_cpuid(d, base, 0, &limit, &dummy, &dummy, &dummy);
-    limit &= 0xff;
-    if ( limit < 2 )
-        limit = 2;
-    else if ( limit > XEN_CPUID_MAX_NUM_LEAVES )
+    if ( limit == 0 )
+        /* Default number of leaves */
         limit = XEN_CPUID_MAX_NUM_LEAVES;
+    else
+    {
+        /* User-specified number of leaves */
+        limit &= 0xff;
+        if ( limit < 2 )
+            limit = 2;
+        else if ( limit > XEN_CPUID_MAX_NUM_LEAVES )
+            limit = XEN_CPUID_MAX_NUM_LEAVES;
+    }
 
     if ( idx > limit ) 
         return 0;