Subject: Re: port-mips/26410: fp.S not updated for siginfo
To: None <port-mips@NetBSD.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: port-mips
Date: 03/25/2006 01:25:58
In article <Pine.BSF.4.51.0407231351310.74810@vegeta.city-net.com>
darkstar@city-net.com wrote:

> On 2004-07-23 simonb@wasabisystems.com wrote:
> 
> > Is this easily reproducable?  If so, can you see if the patches in
> >
> >    http://mail-index.netbsd.org/port-mips/2004/07/03/0002.html
> >
> > from Matthias Drochner fixes your problem?
> 
>   Doh.  I even saved that message, but forgot all about it when I
> encountered the bug :(.
> 
>   It is actually reproducible.  I'll send another PR for that.  Presumably
> this is a SOFTFLOAT bug.  I am doing:
> ftp -o /dev/null ftp://192.168.0.51/stuff
> then cancelling the transfer (^C twice).
> 
>   It seems mips_fputrap.c is not built for SOFTFLOAT.  Moving that code to
> trap.c makes it work as expected.

Any progress on this PR?
Is it okay to commit the attached patch to close it?
---
Izumi Tsutsui


Index: arch/mips/conf/files.mips
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/conf/files.mips,v
retrieving revision 1.53
diff -u -r1.53 files.mips
--- arch/mips/conf/files.mips	11 Dec 2005 12:18:09 -0000	1.53
+++ arch/mips/conf/files.mips	24 Mar 2006 16:24:40 -0000
@@ -55,7 +55,7 @@
 file	arch/mips/mips/in_cksum.c		inet
 file	netns/ns_cksum.c			ns
 
-file	arch/mips/mips/mips_fputrap.c		!softfloat & !nofpu
+file	arch/mips/mips/mips_fputrap.c		softfloat | !nofpu
 file	arch/mips/mips/mips_emul.c
 file	arch/mips/mips/fp.S			softfloat | !nofpu
 
Index: arch/mips/mips/fp.S
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/fp.S,v
retrieving revision 1.30
diff -u -r1.30 fp.S
--- arch/mips/mips/fp.S	23 Mar 2006 16:16:46 -0000	1.30
+++ arch/mips/mips/fp.S	24 Mar 2006 16:24:41 -0000
@@ -4967,7 +4967,7 @@
 	move	a2, a0				# code = instruction
 	lw	a0, _C_LABEL(curlwp)		# get current process
 	li	a1, SIGILL
-	j	_C_LABEL(trapsignal)
+	j	_C_LABEL(fpemul_trapsignal)
 END(fpemul_sigill)
 
 STATIC_LEAF(fpemul_sigfpe)
@@ -4981,7 +4981,7 @@
 	move	a2, a0				# code = instruction
 	lw	a0, _C_LABEL(curlwp)		# get current process
 	li	a1, SIGFPE
-	j	_C_LABEL(trapsignal)
+	j	_C_LABEL(fpemul_trapsignal)
 END(fpemul_sigfpe)
 
 #ifdef SOFTFLOAT
@@ -4996,6 +4996,6 @@
 	move	a2, a0				# code = instruction
 	lw	a0, _C_LABEL(curlwp)		# get current process
 	li	a1, SIGFPE
-	j	_C_LABEL(trapsignal)
+	j	_C_LABEL(fpemul_trapsignal)
 END(bcemul_sigfpe)
 #endif
Index: arch/mips/mips/mips_fputrap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/mips_fputrap.c,v
retrieving revision 1.2
diff -u -r1.2 mips_fputrap.c
--- arch/mips/mips/mips_fputrap.c	11 Dec 2005 12:18:09 -0000	1.2
+++ arch/mips/mips/mips_fputrap.c	24 Mar 2006 16:24:41 -0000
@@ -33,6 +33,7 @@
 #include <sys/siginfo.h>
 #include <mips/cpuregs.h>
 
+#ifndef SOFTFLOAT
 void mips_fpuexcept(struct lwp *, unsigned int);
 void mips_fpuillinst(struct lwp *, unsigned int, unsigned long);
 static int fpustat2sicode(unsigned int);
@@ -84,3 +85,20 @@
 			return (fpecodes[i].code);
 	return (FPE_FLTINV);
 }
+#endif /* !SOFTFLOAT */
+
+void fpemul_trapsignal(struct lwp *, unsigned int, unsigned int);
+
+void
+fpemul_trapsignal(struct lwp *l, unsigned int sig, unsigned int code)
+{
+	ksiginfo_t ksi;
+
+	printf("emul_trapsignal(%x,%x)\n", sig, code);
+
+	KSI_INIT_TRAP(&ksi);
+	ksi.ksi_signo = sig;
+	ksi.ksi_code = 1; /* XXX */
+	ksi.ksi_trap = code;
+	(*l->l_proc->p_emul->e_trapsignal)(l, &ksi);
+}