Subject: Re: please review my MachFPTrap changes
To: Christopher SEKIYA <wileyc@rezrov.net>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: port-mips
Date: 03/05/2004 13:46:13
This is a multipart MIME message.
--==_Exmh_2376834540500
Content-Type: text/plain; charset=us-ascii
wileyc@rezrov.net said:
> status=0x2004fc03, cause=0x8, epc=0x8811d830, vaddr=0x10
> pid=4941 cmd=try usp=0x7fffe348 ksp=0xc3759e00
> Stopped in pid 4941.1 (try) at 0x8811d830: lw
> s4,12(a1)
Dereference of addr 0x10... a1 must be 4 at this point.
Something tries to send a SIGILL using pre-siginfo arguments.
The only place where this still can happen is in the
FPU emulation code mips/fp.S. This isn't converted to
siginfo yet.
In the meantime, I also got a similar trap, with a SIGFPE
sent from the FPU emulator... I thought I had a _real_ FPU.
As said, I don't know much about MIPS processors, no idea
why the emulation code is invoked.
The appended patch is a quick workaround. Somehow sensible
si_code values must be deduced.
best regards
Matthias
--==_Exmh_2376834540500
Content-Type: text/plain ; name="fpemul.txt"; charset=us-ascii
Content-Description: fpemul.txt
Content-Disposition: attachment; filename="fpemul.txt"
Index: mips/fp.S
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/fp.S,v
retrieving revision 1.28
diff -u -r1.28 fp.S
--- mips/fp.S 25 Oct 2003 22:10:34 -0000 1.28
+++ mips/fp.S 5 Mar 2004 12:33:46 -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: mips/mips_fputrap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mips/mips/mips_fputrap.c,v
retrieving revision 1.1
diff -u -r1.1 mips_fputrap.c
--- mips/mips_fputrap.c 4 Mar 2004 20:17:01 -0000 1.1
+++ mips/mips_fputrap.c 5 Mar 2004 12:33:46 -0000
@@ -84,3 +84,19 @@
return (fpecodes[i].code);
return (FPE_FLTINV);
}
+
+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);
+}
--==_Exmh_2376834540500--