WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Fix PV CPUID virtualization of XSave

To: Keir Fraser <keir@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] Fix PV CPUID virtualization of XSave
From: Haitao Shan <maillists.shan@xxxxxxxxx>
Date: Fri, 16 Sep 2011 08:46:52 +0800
Cc:
Delivery-date: Thu, 15 Sep 2011 17:47:41 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=WPtrzp3EiqZ+A90P9YT/NMCKdQgnV92m2HsYsdrwdDs=; b=Jc7PBWAz+66wdOdJUv9xr8pA3dCj+ou7orleA4lbrDc65AhbWeOUG8B3q07Qg/0oMo HN+jALaoFB0PBRy+ilPfdP21TFYraSQ5DfCdBk1uUkF6NZ76JJmUmQCeekJnvn9CO3mS J9TIyWnN/RZSxsUn6Pf7FzGjBJZiTXI7n20aI=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hi, Keir,

The patch will fix XSave CPUID virtualization for PV guests. The XSave
area size returned by CPUID leaf D is changed dynamically depending on
the XCR0. Tools/libxc only assigns a static value. The fix will adjust
xsave area size during runtime.

Note: This fix is already in HVM cpuid virtualization. And Dom0 is not
affected, either.

Signed-off-by:  Shan Haitao <haitao.shan@xxxxxxxxx>

Shan Haitao

diff -r 5fe770c8a8a3 xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c      Tue Sep 06 15:49:40 2011 +0100
+++ b/xen/arch/x86/traps.c      Wed Sep 07 02:09:12 2011 +0800
@@ -770,6 +770,30 @@ static void pv_cpuid(struct cpu_user_reg
     {
         if ( !cpuid_hypervisor_leaves(a, c, &a, &b, &c, &d) )
             domain_cpuid(current->domain, a, c, &a, &b, &c, &d);
+
+        switch ( a )
+        {
+        case 0xd:
+        {
+            unsigned int sub_leaf, _eax, _ebx, _ecx, _edx;
+            /* EBX value of main leaf 0 depends on enabled xsave features */
+            if ( c == 0 && current->arch.xcr0 )
+            {
+                /* reset EBX to default value first */
+                b = XSTATE_AREA_MIN_SIZE;
+                for ( sub_leaf = 2; sub_leaf < 64; sub_leaf++ )
+                {
+                    if ( !(current->arch.xcr0 & (1ULL << sub_leaf)) )
+                        continue;
+                    domain_cpuid(current->domain, a, c, &_eax, &_ebx, &_ecx,
+                                 &_edx);
+                    if ( (_eax + _ebx) > b )
+                        b = _eax + _ebx;
+                }
+            }
+        break;
+        }
+        }
         goto out;
     }

Attachment: pv_xsave_cpuid_fix.patch
Description: Binary data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>