Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jul 2013 07:07:16 +0900
From:      Taku YAMAMOTO <taku@tackymt.homeip.net>
To:        freebsd-acpi@freebsd.org
Subject:   Revisiting FPU context resume on i386
Message-ID:  <20130716070716.15b7282b9dca2cbc8a767631@tackymt.homeip.net>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.

--Multipart=_Tue__16_Jul_2013_07_07_16_+0900_h+CNhL/Y5tSJPtQm
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Hi all,

sys/i386/i386/swtch.s have a big FIX ME in resumectx()
and I have occationally got bitten by it; resulting in SIGFPE disasters.

After cursory looking around FPU context, I think it's the simplest way
to set CR0_TS on resumectx() and to let npxdna() DTRT lazilly.

Attached is the mods that I'm currently using without a problem at the moment.
It at least doesn't interact with normal resume operations badly.

Ah, of cource, we have a choice to throw i386 away and get on amd64,
but at least I won't because I'd miss VOCALOIDs running on wine/i386 :)

-- 
-|-__   YAMAMOTO, Taku
 | __ <     <taku@tackymt.homeip.net>

      - A chicken is an egg's way of producing more eggs. -

--Multipart=_Tue__16_Jul_2013_07_07_16_+0900_h+CNhL/Y5tSJPtQm
Content-Type: text/plain;
 name="i386-resumectx-fpu.patch"
Content-Disposition: attachment;
 filename="i386-resumectx-fpu.patch"
Content-Transfer-Encoding: 7bit

commit 99a24d7c19d624654afbd574e604d8a011ed28b3
Author: Taku YAMAMOTO <taku@tackymt.homeip.net>
Date:   Sun Jul 14 07:36:29 2013 +0900

    i386: defer FPU context resume from resumectx() to npxdna() by CR0_TS.

diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s
index 80aa6c4..71efae1 100644
--- a/sys/i386/i386/swtch.s
+++ b/sys/i386/i386/swtch.s
@@ -36,6 +36,7 @@
 #include "opt_sched.h"
 
 #include <machine/asmacros.h>
+#include <machine/specialreg.h>
 
 #include "assym.s"
 
@@ -487,6 +488,10 @@ ENTRY(resumectx)
 	movl	PCB_CR3(%ecx),%eax
 	movl	%eax,%cr3
 	movl	PCB_CR0(%ecx),%eax
+#ifdef DEV_NPX
+	/* Let npxdna() restore the FPU context lazily. */
+	orl	$CR0_TS,%eax
+#endif
 	movl	%eax,%cr0
 	jmp	1f
 1:
@@ -519,10 +524,6 @@ ENTRY(resumectx)
 	movl	PCB_DR7(%ecx),%eax
 	movl	%eax,%dr7
 
-#ifdef DEV_NPX
-	/* XXX FIX ME */
-#endif
-
 	/* Restore other registers */
 	movl	PCB_EDI(%ecx),%edi
 	movl	PCB_ESI(%ecx),%esi

--Multipart=_Tue__16_Jul_2013_07_07_16_+0900_h+CNhL/Y5tSJPtQm--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130716070716.15b7282b9dca2cbc8a767631>