x86: Further fixes for xsave leaf in pv_cpuid().
authorShan Haitao <haitao.shan@intel.com>
Thu, 13 Oct 2011 14:58:55 +0000 (15:58 +0100)
committerShan Haitao <haitao.shan@intel.com>
Thu, 13 Oct 2011 14:58:55 +0000 (15:58 +0100)
Signed-off-by: Shan Haitao <haitao.shan@intel.com>
Committed-by: Keir Fraser <keir@xen.org>
xen/arch/x86/traps.c

index e22e6d86fc3881ebfda288d288651b9632c8947e..eecdb4d20128800fbe6f036a98049e6fffa97065 100644 (file)
@@ -768,16 +768,18 @@ static void pv_cpuid(struct cpu_user_regs *regs)
 
     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 = XSTATE_AREA_MIN_SIZE;
@@ -785,8 +787,8 @@ static void pv_cpuid(struct cpu_user_regs *regs)
                 {
                     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;
                 }