Thu May 27 13:32:54 2021 UTC ()
Print the CP0 status register too in the debug trap code.


(simonb)
diff -r1.27 -r1.28 src/sys/arch/mips/mips/mips_emul.c

cvs diff -r1.27 -r1.28 src/sys/arch/mips/mips/mips_emul.c (expand / switch to unified diff)

--- src/sys/arch/mips/mips/mips_emul.c 2019/04/06 03:06:26 1.27
+++ src/sys/arch/mips/mips/mips_emul.c 2021/05/27 13:32:54 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mips_emul.c,v 1.27 2019/04/06 03:06:26 thorpej Exp $ */ 1/* $NetBSD: mips_emul.c,v 1.28 2021/05/27 13:32:54 simonb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999 Shuichiro URATA. All rights reserved. 4 * Copyright (c) 1999 Shuichiro URATA. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products 14 * 3. The name of the author may not be used to endorse or promote products
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: mips_emul.c,v 1.27 2019/04/06 03:06:26 thorpej Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: mips_emul.c,v 1.28 2021/05/27 13:32:54 simonb Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/systm.h> 33#include <sys/systm.h>
34#include <sys/cpu.h> 34#include <sys/cpu.h>
35#include <sys/proc.h> 35#include <sys/proc.h>
36 36
37#include <mips/locore.h> 37#include <mips/locore.h>
38#include <mips/mips_opcode.h> 38#include <mips/mips_opcode.h>
39 39
40#include <mips/reg.h> 40#include <mips/reg.h>
41#include <mips/regnum.h> /* symbolic register indices */ 41#include <mips/regnum.h> /* symbolic register indices */
42#include <mips/pcb.h> 42#include <mips/pcb.h>
43#include <mips/vmparam.h> /* for VM_MAX_ADDRESS */ 43#include <mips/vmparam.h> /* for VM_MAX_ADDRESS */
@@ -230,27 +230,30 @@ mips_emul_inst(uint32_t status, uint32_t @@ -230,27 +230,30 @@ mips_emul_inst(uint32_t status, uint32_t
230 mips_emul_swc1(inst, tf, cause); 230 mips_emul_swc1(inst, tf, cause);
231 break; 231 break;
232#endif 232#endif
233 case OP_SDC1: 233 case OP_SDC1:
234#if defined(FPEMUL) 234#if defined(FPEMUL)
235 mips_emul_sdc1(inst, tf, cause); 235 mips_emul_sdc1(inst, tf, cause);
236 break; 236 break;
237#else 237#else
238 code = ILL_COPROC; 238 code = ILL_COPROC;
239 /* FALLTHROUGH */ 239 /* FALLTHROUGH */
240#endif 240#endif
241 default: 241 default:
242#ifdef DEBUG 242#ifdef DEBUG
243 printf("pid %d (%s): trap: bad insn @ %#"PRIxVADDR" cause %#x insn %#x code %d\n", curproc->p_pid, curproc->p_comm, opc, cause, inst, code); 243 printf("pid %d (%s): trap: bad insn @ %#"PRIxVADDR
 244 " cause %#x status %#"PRIxREGISTER" insn %#x code %d\n",
 245 curproc->p_pid, curproc->p_comm, opc,
 246 cause, tf->tf_regs[_R_SR], inst, code);
244#endif 247#endif
245 tf->tf_regs[_R_CAUSE] = cause; 248 tf->tf_regs[_R_CAUSE] = cause;
246 tf->tf_regs[_R_BADVADDR] = opc; 249 tf->tf_regs[_R_BADVADDR] = opc;
247 KSI_INIT_TRAP(&ksi); 250 KSI_INIT_TRAP(&ksi);
248 ksi.ksi_signo = SIGILL; 251 ksi.ksi_signo = SIGILL;
249 ksi.ksi_trap = cause; /* XXX */ 252 ksi.ksi_trap = cause; /* XXX */
250 ksi.ksi_code = code; 253 ksi.ksi_code = code;
251 ksi.ksi_addr = (void *)opc; 254 ksi.ksi_addr = (void *)opc;
252 (*curproc->p_emul->e_trapsignal)(curlwp, &ksi); 255 (*curproc->p_emul->e_trapsignal)(curlwp, &ksi);
253 break; 256 break;
254 } 257 }
255} 258}
256 259