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-changelog

[Xen-changelog] [xen-unstable] x86/fpu: create FPU init and destroy func

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86/fpu: create FPU init and destroy functions
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Wed, 11 May 2011 04:40:17 +0100
Delivery-date: Tue, 10 May 2011 20:47:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Wei Huang <wei.huang2@xxxxxxx>
# Date 1304937456 -3600
# Node ID 260c3f760eff2d594b55022cf230097147e5148c
# Parent  f4585056b9ae4a21644d51243491ad5f27fd9373
x86/fpu: create FPU init and destroy functions

Extract FPU initialization and destroy code into two functions. These
functions handle memory allocation/deallocation for FPU context.

Signed-off-by: Wei Huang <wei.huang2@xxxxxxx>
---


diff -r f4585056b9ae -r 260c3f760eff xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Mon May 09 11:37:03 2011 +0100
+++ b/xen/arch/x86/domain.c     Mon May 09 11:37:36 2011 +0100
@@ -420,20 +420,8 @@
 
     v->arch.perdomain_ptes = perdomain_ptes(d, v);
 
-    if ( (rc = xstate_alloc_save_area(v)) != 0 )
+    if ( (rc = vcpu_init_fpu(v)) != 0 )
         return rc;
-    if ( v->arch.xsave_area )
-        v->arch.fpu_ctxt = &v->arch.xsave_area->fpu_sse;
-    else if ( !is_idle_domain(d) )
-    {
-        v->arch.fpu_ctxt = _xmalloc(sizeof(v->arch.xsave_area->fpu_sse), 16);
-        if ( !v->arch.fpu_ctxt )
-        {
-            rc = -ENOMEM;
-            goto done;
-        }
-        memset(v->arch.fpu_ctxt, 0, sizeof(v->arch.xsave_area->fpu_sse));
-    }
 
     if ( is_hvm_domain(d) )
     {
@@ -485,10 +473,8 @@
  done:
     if ( rc )
     {
-        if ( v->arch.xsave_area )
-            xstate_free_save_area(v);
-        else
-            xfree(v->arch.fpu_ctxt);
+        vcpu_destroy_fpu(v);
+
         if ( !is_hvm_domain(d) && standalone_trap_ctxt(v) )
             free_xenheap_page(v->arch.pv_vcpu.trap_ctxt);
     }
@@ -501,10 +487,7 @@
     if ( is_pv_32on64_vcpu(v) )
         release_compat_l4(v);
 
-    if ( v->arch.xsave_area )
-        xstate_free_save_area(v);
-    else
-        xfree(v->arch.fpu_ctxt);
+    vcpu_destroy_fpu(v);
 
     if ( is_hvm_vcpu(v) )
         hvm_vcpu_destroy(v);
diff -r f4585056b9ae -r 260c3f760eff xen/arch/x86/i387.c
--- a/xen/arch/x86/i387.c       Mon May 09 11:37:03 2011 +0100
+++ b/xen/arch/x86/i387.c       Mon May 09 11:37:36 2011 +0100
@@ -184,6 +184,47 @@
     }
 }
 
+/*******************************/
+/*       VCPU FPU Functions    */
+/*******************************/
+/* Initialize FPU's context save area */
+int vcpu_init_fpu(struct vcpu *v)
+{
+    int rc = 0;
+    
+    /* Idle domain doesn't have FPU state allocated */
+    if ( is_idle_vcpu(v) )
+        goto done;
+
+    if ( (rc = xstate_alloc_save_area(v)) != 0 )
+        return rc;
+
+    if ( v->arch.xsave_area )
+        v->arch.fpu_ctxt = &v->arch.xsave_area->fpu_sse;
+    else
+    {
+        v->arch.fpu_ctxt = _xmalloc(sizeof(v->arch.xsave_area->fpu_sse), 16);
+        if ( !v->arch.fpu_ctxt )
+        {
+            rc = -ENOMEM;
+            goto done;
+        }
+        memset(v->arch.fpu_ctxt, 0, sizeof(v->arch.xsave_area->fpu_sse));
+    }
+
+done:
+    return rc;
+}
+
+/* Free FPU's context save area */
+void vcpu_destroy_fpu(struct vcpu *v)
+{
+    if ( v->arch.xsave_area )
+        xstate_free_save_area(v);
+    else
+        xfree(v->arch.fpu_ctxt);
+}
+
 /*
  * Local variables:
  * mode: C
diff -r f4585056b9ae -r 260c3f760eff xen/include/asm-x86/i387.h
--- a/xen/include/asm-x86/i387.h        Mon May 09 11:37:03 2011 +0100
+++ b/xen/include/asm-x86/i387.h        Mon May 09 11:37:36 2011 +0100
@@ -17,4 +17,6 @@
 void setup_fpu(struct vcpu *v);
 void save_init_fpu(struct vcpu *v);
 
+int vcpu_init_fpu(struct vcpu *v);
+void vcpu_destroy_fpu(struct vcpu *v);
 #endif /* __ASM_I386_I387_H */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86/fpu: create FPU init and destroy functions, Xen patchbot-unstable <=