NetBSD Problem Report #35326

From martin@duskware.de  Wed Dec 27 00:38:10 2006
Return-Path: <martin@duskware.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 26A7963B8C9
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 27 Dec 2006 00:38:10 +0000 (UTC)
Message-Id: <20061226234117.2626933A82@mail.duskware.de>
Date: Wed, 27 Dec 2006 00:41:17 +0100 (CET)
From: martin@duskware.de
Reply-To: martin@duskware.de
To: gnats-bugs@NetBSD.org
Subject: wrong FPU exception
X-Send-Pr-Version: 3.95

>Number:         35326
>Category:       port-mips
>Synopsis:       wrong FPU exception
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    tsutsui
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 27 00:40:00 +0000 2006
>Closed-Date:    Sun Mar 04 05:56:55 +0000 2012
>Last-Modified:  Sun Mar 04 05:56:55 +0000 2012
>Originator:     Martin Husemann
>Release:        NetBSD 4.99.7
>Organization:
>Environment:
System: NetBSD tequila-sunrise.duskware.de 4.99.7 NetBSD 4.99.7 (GENERIC32_IP3x) #6: Wed Dec 27 00:05:39 CET 2006 martin@night-porter.duskware.de:/usr/src/sys/arch/sgimips/compile/GENERIC32_IP3x sgimips
Architecture: mipseb
Machine: sgimips
>Description:

The regress/lib/libc/ieeefp/except test runs a function

/* trip underflow */
static void
ufl()
{

	x = tiny * tiny;
}

which is supposed (tiny is FLT_MIN or DBL_MIN) to trigger a SIGFPE with
code = FPE_FLTUND - but causes a FPE_INTDIV code. This probably happens
via fpemul_trapsignal(), which hardcodes a code of 1 (instead of
mips_fpuexcept, which does the right thing).

>How-To-Repeat:
s/a

>Fix:
n/a

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: port-mips-maintainer->tsutsui
Responsible-Changed-By: tsutsui@NetBSD.org
Responsible-Changed-When: Fri, 28 Jan 2011 18:21:07 +0900
Responsible-Changed-Why:


State-Changed-From-To: open->analyzed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Fri, 28 Jan 2011 18:21:07 +0900
State-Changed-Why:
MachEmulateFP() should invoke mips_fpuillinst() or mips_fpuexcept()
with proper args rather than fpemul_trapsignal().


From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: port-mips/35326 (wrong FPU exception)
Date: Sat, 29 Jan 2011 05:02:04 +0900

 > Synopsis: wrong FPU exception
  :
 > MachEmulateFP() should invoke mips_fpuillinst() or mips_fpuexcept()
 > with proper args rather than fpemul_trapsignal().

 It looks if an instruction "mul.d $f0,$f0,$f2" causes underflow
 (as ufl() op in regress/lib/libc/ieeefp/except/except.c does)
 MIPS_FPU_EXCEPTION_UNIMPL occurs instead of MIPS_FPU_EXCEPTION_UNDERFLOW
 so MachEmulateFP() is called from MachFPTrap() in locore.S.

 On the other hand overflow caused by the same mul.d proplery triggers
 MIPS_FPU_EXCEPTION_OVERFLOW and MachFPTrap() calls mips_fpuexcept().

 I wonder if this is expected behavior on R4400 and R5000 CPUs...

 ---
 Izumi Tsutsui

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/35327 CVS commit: src/sys/arch/mips/mips
Date: Thu, 24 Feb 2011 16:49:16 +0000

 Module Name:	src
 Committed By:	tsutsui
 Date:		Thu Feb 24 16:49:15 UTC 2011

 Modified Files:
 	src/sys/arch/mips/mips: fp.S

 Log Message:
 Resurrect silently removed lines in rev 1.37 that update FPU_CSR
 in double's inexact or overflow cases.

 Now the following tests are passed:
 ---
 tp-start: t_except, 6
 tc-start: masked_double
 tc-end: masked_double, passed
  :
 tc-start: masked_long_double
 tc-end: masked_long_double, passed
  :
 tp-start: t_subnormal, 2
 tc-start: test_double
 tc-end: test_double, passed
 ---

 The following ones still fail:
 ---
 tp-start: t_except, 6
  :
 tc-start: unmasked_double
 tc-se:*** Check failed: /usr/src/tests/lib/libc/ieeefp/t_except.c:269: sicode != t->sicode
 tc-end: unmasked_double, failed, 1 checks failed; see output for more details
 tc-start: unmasked_float
 tc-se:*** Check failed: /usr/src/tests/lib/libc/ieeefp/t_except.c:269: sicode != t->sicode
 tc-end: unmasked_float, failed, 1 checks failed; see output for more details
 tc-start: unmasked_long_double
 tc-se:*** Check failed: /usr/src/tests/lib/libc/ieeefp/t_except.c:269: sicode != t->sicode
 tc-end: unmasked_long_double, failed, 1 checks failed; see output for more details
 tp-end: t_except
  :
 tp-start: t_subnormal, 2
  :
 tc-start: test_float
 tc-end: test_float, failed, Test program received signal 4 (core dumped)
 tp-end: t_subnormal
 ---

 - t_except unmasked failures are mentioned in PR port-mips/35327.
 - t_subnormal float failure seems trap caused by a FP insn in BDslot
   (I'm not sure if we can use TF_REG_CAUSE in trapframe to see BD bit)


 To generate a diff of this commit:
 cvs rdiff -u -r1.38 -r1.39 src/sys/arch/mips/mips/fp.S

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/35326 CVS commit: src/sys/arch/mips/mips
Date: Sat, 26 Feb 2011 15:41:33 +0000

 Module Name:	src
 Committed By:	tsutsui
 Date:		Sat Feb 26 15:41:32 UTC 2011

 Modified Files:
 	src/sys/arch/mips/mips: fp.S mips_fputrap.c

 Log Message:
 Use mips_fpexcept() instead of fpemul_trapsignal() to deliver SIGFPE,
 and remove now unused fpemul_trapsignal() introduced for PR port-mips/26410.

 Fixes PR port-mips/35326 and now t_except unmasked tests in
 /usr/tests/lib/libc/ieeefp pass.

 Note t_subnormal double test still fails as mentioned in PR port-mips/44639.


 To generate a diff of this commit:
 cvs rdiff -u -r1.42 -r1.43 src/sys/arch/mips/mips/fp.S
 cvs rdiff -u -r1.9 -r1.10 src/sys/arch/mips/mips/mips_fputrap.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: analyzed->pending-pullups
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sat, 05 Mar 2011 20:48:57 +0900
State-Changed-Why:
Fixed in HEAD. Needs more work for netbsd-5.


State-Changed-From-To: pending-pullups->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 04 Mar 2012 14:56:55 +0900
State-Changed-Why:
No motivation to prepare patch unless 5.2 is scheduled.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.