Subject: Re: port-xen/30977: FPU troubles
To: Paul Ripke <stix@stix.id.au>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: port-xen
Date: 01/03/2006 21:23:43
--+HP7ph2BbKc20aGI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Jan 03, 2006 at 09:21:52PM +0100, Manuel Bouyer wrote:
> On Mon, Dec 19, 2005 at 09:34:01AM +1100, Paul Ripke wrote:
> > OK, I've had a closer look at this, and come up with the included patch,
> > which appears to work fine for me, with threaded and non-threaded 
> > programs.
> > I can't repeat the behaviour of the FPU state being not being restored,
> > restored to the wrong thread, or wiped.
> 
> This is great, many thanks ! I commited the attached patch, which

 here is the patch

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--

--+HP7ph2BbKc20aGI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="xen.diff"

Index: npx.c
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/i386/npx.c,v
retrieving revision 1.6
diff -u -r1.6 npx.c
--- i386/npx.c	24 Dec 2005 20:07:48 -0000	1.6
+++ i386/npx.c	3 Jan 2006 19:09:33 -0000
@@ -146,7 +146,7 @@
 #define	stts()			lcr0(rcr0() | CR0_TS)
 #else
 #define	clts()
-#define	stts()			HYPERVISOR_fpu_taskswitch()
+#define	stts()
 #endif
 
 int npxdna(struct cpu_info *);
@@ -749,7 +749,7 @@
 
 	oci = l->l_addr->u_pcb.pcb_fpcpu;
 	if (oci == NULL)
-		return;
+		goto end;
 
 	IPRINTF(("%s: fp %s lwp %p\n", ci->ci_dev->dv_xname,
 	    save? "save" : "flush", l));
@@ -792,4 +792,6 @@
 	KASSERT(ci->ci_fpcurlwp == l);
 	npxsave_cpu(ci, save);
 #endif
+end:
+	HYPERVISOR_fpu_taskswitch();
 }

--+HP7ph2BbKc20aGI--