Source-Changes-HG archive

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

[src/netbsd-7]: src/sys/arch/powerpc/fpu Pull up following revision(s) (reque...



details:   https://anonhg.NetBSD.org/src/rev/701418a6f3bd
branches:  netbsd-7
changeset: 800104:701418a6f3bd
user:      snj <snj%NetBSD.org@localhost>
date:      Tue Jan 03 06:19:21 2017 +0000

description:
Pull up following revision(s) (requested by rin in ticket #1341):
        sys/arch/powerpc/fpu/fpu_emu.c: revision 1.19
        sys/arch/powerpc/fpu/fpu_explode.c: revision 1.7
- add missing default from FreeBSD
- remove duplicate panic pointed out by matt
--
PR port-powerpc/51368: powerpc FPU emulation fails for single precision
floating point arithmetic
For single precision instruction, calculate first in double precision,
and then round it. With this fix, single precision arithmetic gets sane
on ibm4xx and booke.
Taken from FreeBSD commit r258250:
   https://svnweb.freebsd.org/base?view=revision&revision=258250
Ok matt and simonb.

diffstat:

 sys/arch/powerpc/fpu/fpu_emu.c     |  19 ++++++++++++++-----
 sys/arch/powerpc/fpu/fpu_explode.c |   6 +++---
 2 files changed, 17 insertions(+), 8 deletions(-)

diffs (74 lines):

diff -r d25c368a78f7 -r 701418a6f3bd sys/arch/powerpc/fpu/fpu_emu.c
--- a/sys/arch/powerpc/fpu/fpu_emu.c    Sat Dec 31 07:43:21 2016 +0000
+++ b/sys/arch/powerpc/fpu/fpu_emu.c    Tue Jan 03 06:19:21 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu_emu.c,v 1.16 2012/07/23 04:13:06 matt Exp $ */
+/*     $NetBSD: fpu_emu.c,v 1.16.14.1 2017/01/03 06:19:21 snj Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu_emu.c,v 1.16 2012/07/23 04:13:06 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_emu.c,v 1.16.14.1 2017/01/03 06:19:21 snj Exp $");
 
 #include "opt_ddb.h"
 
@@ -626,9 +626,11 @@
                        rb = instr.i_a.i_frb;
                        rc = instr.i_a.i_frc;
 
-                       type = FTYPE_SNG;
-                       if (instr.i_any.i_opcd & 0x4)
-                               type = FTYPE_DBL;
+                       /*
+                        * All arithmetic operations work on registers, which
+                        * are stored as doubles.
+                        */
+                       type = FTYPE_DBL;
                        switch ((unsigned int)instr.i_a.i_xo) {
                        case    OPC59_FDIVS:
                                FPU_EMU_EVCNT_INCR(fdiv);
@@ -745,6 +747,13 @@
                                return (NOTFPU);
                                break;
                        }
+
+                       /* If the instruction was single precision, round */
+                       if (!(instr.i_any.i_opcd & 0x4)) {
+                               fpu_implode(fe, fp, FTYPE_SNG, 
+                                       (u_int *)&fs->fpreg[rt]);
+                               fpu_explode(fe, fp = &fe->fe_f1, FTYPE_SNG, rt);
+                       }
                }
        } else {
                return (NOTFPU);
diff -r d25c368a78f7 -r 701418a6f3bd sys/arch/powerpc/fpu/fpu_explode.c
--- a/sys/arch/powerpc/fpu/fpu_explode.c        Sat Dec 31 07:43:21 2016 +0000
+++ b/sys/arch/powerpc/fpu/fpu_explode.c        Tue Jan 03 06:19:21 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu_explode.c,v 1.6 2005/12/11 12:18:42 christos Exp $ */
+/*     $NetBSD: fpu_explode.c,v 1.6.140.1 2017/01/03 06:19:21 snj Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu_explode.c,v 1.6 2005/12/11 12:18:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_explode.c,v 1.6.140.1 2017/01/03 06:19:21 snj Exp $");
 
 #include <sys/types.h>
 #include <sys/systm.h>
@@ -235,7 +235,7 @@
                s = fpu_dtof(fp, s, space[1]);
                break;
 
-               panic("fpu_explode");
+       default:
                panic("fpu_explode: invalid type %d", type);
        }
 



Home | Main Index | Thread Index | Old Index