changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: pc: dont handle pending floating point exception in fpsave thru FPOFF

changeset 4223: 27d6b9ab8cce
parent 4222: 8cd112f650b1
child 4224: f97fb43134f1
author: cinap_lenrek@felloff.net
date: Fri, 23 Jan 2015 14:01:56 +0100
files: sys/src/9/pc/l.s
description: pc: dont handle pending floating point exception in fpsave thru FPOFF

the FPOFF macro that follows the FXSAVE/FSAVE instructions in l.s
used to execute WAIT instruction when the TS flag was not set. this
is wrong and causes pending exceptions to be raised from fpsave which
is called from provsave() which holds up->rlock making it deadlock
when matherror() tries to postnote() to itself.

so making FPOFF non-waiting (just set TS flag).

we handle pending exception when restoring the context.
     1.1--- a/sys/src/9/pc/l.s
     1.2+++ b/sys/src/9/pc/l.s
     1.3@@ -570,15 +570,8 @@ TEXT aamloop(SB), $0
     1.4  * FNxxx variations) so WAIT instructions must be explicitly placed in the
     1.5  * code as necessary.
     1.6  */
     1.7-#define	FPOFF(l)						 ;\
     1.8-	MOVL	CR0, AX 					 ;\
     1.9-	ANDL	$0xC, AX			/* EM, TS */	 ;\
    1.10-	CMPL	AX, $0x8					 ;\
    1.11-	JEQ 	l						 ;\
    1.12-	WAIT							 ;\
    1.13-l:								 ;\
    1.14+#define FPOFF							 ;\
    1.15 	MOVL	CR0, AX						 ;\
    1.16-	ANDL	$~0x4, AX			/* EM=0 */	 ;\
    1.17 	ORL	$0x28, AX			/* NE=1, TS=1 */ ;\
    1.18 	MOVL	AX, CR0
    1.19 
    1.20@@ -586,9 +579,9 @@ l:								 ;\
    1.21 	MOVL	CR0, AX						 ;\
    1.22 	ANDL	$~0xC, AX			/* EM=0, TS=0 */ ;\
    1.23 	MOVL	AX, CR0
    1.24-	
    1.25+
    1.26 TEXT fpoff(SB), $0				/* disable */
    1.27-	FPOFF(l1)
    1.28+	FPOFF
    1.29 	RET
    1.30 
    1.31 TEXT fpinit(SB), $0				/* enable and init */
    1.32@@ -606,10 +599,10 @@ TEXT fpinit(SB), $0				/* enable and ini
    1.33 TEXT fpx87save0(SB), $0				/* save state and disable */
    1.34 	MOVL	p+0(FP), AX
    1.35 	FSAVE	0(AX)				/* no WAIT */
    1.36-	FPOFF(l2)
    1.37+	FPOFF
    1.38 	RET
    1.39 
    1.40-TEXT fpx87restore0(SB), $0				/* enable and restore state */
    1.41+TEXT fpx87restore0(SB), $0			/* enable and restore state */
    1.42 	FPON
    1.43 	MOVL	p+0(FP), AX
    1.44 	FRSTOR	0(AX)
    1.45@@ -628,13 +621,13 @@ TEXT fpenv(SB), $0				/* save state with
    1.46 TEXT fpclear(SB), $0				/* clear pending exceptions */
    1.47 	FPON
    1.48 	FCLEX					/* no WAIT */
    1.49-	FPOFF(l3)
    1.50+	FPOFF
    1.51 	RET
    1.52 
    1.53 TEXT fpssesave0(SB), $0				/* save state and disable */
    1.54 	MOVL	p+0(FP), AX
    1.55 	FXSAVE	0(AX)				/* no WAIT */
    1.56-	FPOFF(l4)
    1.57+	FPOFF
    1.58 	RET
    1.59 
    1.60 TEXT fpsserestore0(SB), $0			/* enable and restore state */