File 23955-x86-pv-cpuid-xsave.patch of Package xen

# HG changeset patch
# User Shan Haitao <haitao.shan@intel.com>
# Date 1318517935 -3600
# Node ID bbde1453cbd95d6d36febe9c552f9cfa26b5c49e
# Parent  c1bd53fac3d5e5868352894d62dbacd6de0b0e7a
x86: Further fixes for xsave leaf in pv_cpuid().

Signed-off-by: Shan Haitao <haitao.shan@intel.com>
Committed-by: Keir Fraser <keir@xen.org>

--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -766,16 +766,18 @@ static void pv_cpuid(struct cpu_user_reg
 
     if ( current->domain->domain_id != 0 )
     {
+        unsigned int cpuid_leaf = a, sub_leaf = c;
+
         if ( !cpuid_hypervisor_leaves(a, c, &a, &b, &c, &d) )
             domain_cpuid(current->domain, a, c, &a, &b, &c, &d);
 
-        switch ( a )
+        switch ( cpuid_leaf )
         {
         case 0xd:
         {
-            unsigned int sub_leaf, _eax, _ebx, _ecx, _edx;
+            unsigned int _eax, _ebx, _ecx, _edx;
             /* EBX value of main leaf 0 depends on enabled xsave features */
-            if ( c == 0 && current->arch.xcr0 )
+            if ( sub_leaf == 0 && current->arch.xcr0 )
             {
                 /* reset EBX to default value first */
                 b = XSAVE_AREA_MIN_SIZE;
@@ -783,8 +785,8 @@ static void pv_cpuid(struct cpu_user_reg
                 {
                     if ( !(current->arch.xcr0 & (1ULL << sub_leaf)) )
                         continue;
-                    domain_cpuid(current->domain, a, c, &_eax, &_ebx, &_ecx,
-                                 &_edx);
+                    domain_cpuid(current->domain, cpuid_leaf, sub_leaf,
+                                 &_eax, &_ebx, &_ecx, &_edx);
                     if ( (_eax + _ebx) > b )
                         b = _eax + _ebx;
                 }
openSUSE Build Service is sponsored by