Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/powerpc/fpu Do not raise SIGFPE unless MSR[FE0] or ...



details:   https://anonhg.NetBSD.org/src/rev/cf85a4283afb
branches:  trunk
changeset: 935990:cf85a4283afb
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Jul 15 09:16:35 2020 +0000

description:
Do not raise SIGFPE unless MSR[FE0] or MSR[FE1] is set via fenv(3).

diffstat:

 sys/arch/powerpc/fpu/fpu_emu.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (51 lines):

diff -r d8dcde02d92e -r cf85a4283afb sys/arch/powerpc/fpu/fpu_emu.c
--- a/sys/arch/powerpc/fpu/fpu_emu.c    Wed Jul 15 09:10:14 2020 +0000
+++ b/sys/arch/powerpc/fpu/fpu_emu.c    Wed Jul 15 09:16:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu_emu.c,v 1.29 2020/07/15 08:29:07 rin Exp $ */
+/*     $NetBSD: fpu_emu.c,v 1.30 2020/07/15 09:16:35 rin Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu_emu.c,v 1.29 2020/07/15 08:29:07 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_emu.c,v 1.30 2020/07/15 09:16:35 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -92,6 +92,8 @@
 #include <sys/syslog.h>
 
 #include <powerpc/instr.h>
+#include <powerpc/psl.h>
+
 #include <machine/fpu.h>
 #include <machine/reg.h>
 #include <machine/trap.h>
@@ -191,6 +193,7 @@
 bool
 fpu_emulate(struct trapframe *tf, struct fpreg *fpf, ksiginfo_t *ksi)
 {
+       struct pcb *pcb;
        union instr insn;
        struct fpemu fe;
 
@@ -229,11 +232,15 @@
        }
        switch (fpu_execute(tf, &fe, &insn)) {
        case 0:
+success:
                DPRINTF(FPE_EX, ("fpu_emulate: success\n"));
                tf->tf_srr0 += 4;
                return true;
 
        case FPE:
+               pcb = lwp_getpcb(curlwp);
+               if ((pcb->pcb_flags & PSL_FE_PREC) == 0)
+                       goto success;
                DPRINTF(FPE_EX, ("fpu_emulate: SIGFPE\n"));
                ksi->ksi_signo = SIGFPE;
                ksi->ksi_trap = EXC_PGM;



Home | Main Index | Thread Index | Old Index