From 663f148514e167ab452351a757b007a17a0dc871 Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Mon, 14 Nov 1994 14:59:06 +0000 Subject: [PATCH] Log processes that exit with an masked npx exception that would trap with the current default exception (un)mask. There should be no such processes unless you change the mask. Someday the mask should be changed to the IEEE default of everything masked. The npx state gets saved so that it can be checked and this may have the side effect of fixing a bug that was reported for 1.1.5. (npx exceptions may sometimes leak across exits and clobber another process. I can't see how this can happen.) Get some missing/wrong declarations from headers now that the headers have them. --- sys/amd64/amd64/fpu.c | 29 +++++++++++++++++++++-------- sys/amd64/isa/npx.c | 29 +++++++++++++++++++++-------- sys/i386/isa/npx.c | 29 +++++++++++++++++++++-------- 3 files changed, 63 insertions(+), 24 deletions(-) diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c index 35b3af67ef0f..0f703fad6df7 100644 --- a/sys/amd64/amd64/fpu.c +++ b/sys/amd64/amd64/fpu.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 - * $Id: npx.c,v 1.15 1994/10/23 21:27:32 wollman Exp $ + * $Id: npx.c,v 1.16 1994/11/06 00:58:06 bde Exp $ */ #include "npx.h" @@ -45,10 +45,13 @@ #include #include #include +#include +#include #include #include #include +#include #include #include @@ -92,8 +95,6 @@ void stop_emulating __P((void)); typedef u_char bool_t; -extern struct gate_descriptor idt[]; - static int npxattach __P((struct isa_device *dvp)); static int npxprobe __P((struct isa_device *dvp)); static int npxprobe1 __P((struct isa_device *dvp)); @@ -119,7 +120,7 @@ static volatile u_int npx_traps_while_probing; * interrupts. We'll still need a special exception 16 handler. The busy * latch stuff in probintr() can be moved to npxprobe(). */ -void probeintr(void); +inthand_t probeintr; asm (" .text @@ -136,7 +137,7 @@ _probeintr: iret "); -void probetrap(void); +inthand_t probetrap; asm (" .text @@ -374,9 +375,21 @@ npxexit(p) struct proc *p; { - if (p == npxproc) { - start_emulating(); - npxproc = NULL; + if (p == npxproc) + npxsave(&curpcb->pcb_savefpu); + if (npx_exists) { + u_int masked_exceptions; + + masked_exceptions = curpcb->pcb_savefpu.sv_env.en_cw + & curpcb->pcb_savefpu.sv_env.en_sw & 0x7f; + /* + * Overflow, divde by 0, and invalid operand would have + * caused a trap in 1.1.5. + */ + if (masked_exceptions & 0x0d) + log(LOG_ERR, + "pid %d (%s) exited with masked floating point exceptions 0x%02x\n", + p->p_pid, p->p_comm, masked_exceptions); } } diff --git a/sys/amd64/isa/npx.c b/sys/amd64/isa/npx.c index 35b3af67ef0f..0f703fad6df7 100644 --- a/sys/amd64/isa/npx.c +++ b/sys/amd64/isa/npx.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 - * $Id: npx.c,v 1.15 1994/10/23 21:27:32 wollman Exp $ + * $Id: npx.c,v 1.16 1994/11/06 00:58:06 bde Exp $ */ #include "npx.h" @@ -45,10 +45,13 @@ #include #include #include +#include +#include #include #include #include +#include #include #include @@ -92,8 +95,6 @@ void stop_emulating __P((void)); typedef u_char bool_t; -extern struct gate_descriptor idt[]; - static int npxattach __P((struct isa_device *dvp)); static int npxprobe __P((struct isa_device *dvp)); static int npxprobe1 __P((struct isa_device *dvp)); @@ -119,7 +120,7 @@ static volatile u_int npx_traps_while_probing; * interrupts. We'll still need a special exception 16 handler. The busy * latch stuff in probintr() can be moved to npxprobe(). */ -void probeintr(void); +inthand_t probeintr; asm (" .text @@ -136,7 +137,7 @@ _probeintr: iret "); -void probetrap(void); +inthand_t probetrap; asm (" .text @@ -374,9 +375,21 @@ npxexit(p) struct proc *p; { - if (p == npxproc) { - start_emulating(); - npxproc = NULL; + if (p == npxproc) + npxsave(&curpcb->pcb_savefpu); + if (npx_exists) { + u_int masked_exceptions; + + masked_exceptions = curpcb->pcb_savefpu.sv_env.en_cw + & curpcb->pcb_savefpu.sv_env.en_sw & 0x7f; + /* + * Overflow, divde by 0, and invalid operand would have + * caused a trap in 1.1.5. + */ + if (masked_exceptions & 0x0d) + log(LOG_ERR, + "pid %d (%s) exited with masked floating point exceptions 0x%02x\n", + p->p_pid, p->p_comm, masked_exceptions); } } diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c index 35b3af67ef0f..0f703fad6df7 100644 --- a/sys/i386/isa/npx.c +++ b/sys/i386/isa/npx.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 - * $Id: npx.c,v 1.15 1994/10/23 21:27:32 wollman Exp $ + * $Id: npx.c,v 1.16 1994/11/06 00:58:06 bde Exp $ */ #include "npx.h" @@ -45,10 +45,13 @@ #include #include #include +#include +#include #include #include #include +#include #include #include @@ -92,8 +95,6 @@ void stop_emulating __P((void)); typedef u_char bool_t; -extern struct gate_descriptor idt[]; - static int npxattach __P((struct isa_device *dvp)); static int npxprobe __P((struct isa_device *dvp)); static int npxprobe1 __P((struct isa_device *dvp)); @@ -119,7 +120,7 @@ static volatile u_int npx_traps_while_probing; * interrupts. We'll still need a special exception 16 handler. The busy * latch stuff in probintr() can be moved to npxprobe(). */ -void probeintr(void); +inthand_t probeintr; asm (" .text @@ -136,7 +137,7 @@ _probeintr: iret "); -void probetrap(void); +inthand_t probetrap; asm (" .text @@ -374,9 +375,21 @@ npxexit(p) struct proc *p; { - if (p == npxproc) { - start_emulating(); - npxproc = NULL; + if (p == npxproc) + npxsave(&curpcb->pcb_savefpu); + if (npx_exists) { + u_int masked_exceptions; + + masked_exceptions = curpcb->pcb_savefpu.sv_env.en_cw + & curpcb->pcb_savefpu.sv_env.en_sw & 0x7f; + /* + * Overflow, divde by 0, and invalid operand would have + * caused a trap in 1.1.5. + */ + if (masked_exceptions & 0x0d) + log(LOG_ERR, + "pid %d (%s) exited with masked floating point exceptions 0x%02x\n", + p->p_pid, p->p_comm, masked_exceptions); } }