Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc/ibm4xx Treat trap instruction from userland...
details: https://anonhg.NetBSD.org/src/rev/52baad0f4009
branches: trunk
changeset: 935986:52baad0f4009
user: rin <rin%NetBSD.org@localhost>
date: Wed Jul 15 08:48:40 2020 +0000
description:
Treat trap instruction from userland correctly in EXC_PGM handler;
raise SIGTRAP with TRAP_BRKPT instead of SIGILL.
diffstat:
sys/arch/powerpc/ibm4xx/trap.c | 51 +++++++++++++++++++++++++----------------
1 files changed, 31 insertions(+), 20 deletions(-)
diffs (75 lines):
diff -r 01f22fa47d84 -r 52baad0f4009 sys/arch/powerpc/ibm4xx/trap.c
--- a/sys/arch/powerpc/ibm4xx/trap.c Wed Jul 15 08:29:07 2020 +0000
+++ b/sys/arch/powerpc/ibm4xx/trap.c Wed Jul 15 08:48:40 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.83 2020/07/06 10:41:43 rin Exp $ */
+/* $NetBSD: trap.c,v 1.84 2020/07/15 08:48:40 rin Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -69,7 +69,7 @@
#define __UFETCHSTORE_PRIVATE
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.83 2020/07/06 10:41:43 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.84 2020/07/15 08:48:40 rin Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -309,27 +309,38 @@
break;
case EXC_PGM|EXC_USER:
- /*
- * Illegal insn:
- *
- * let's try to see if its FPU and can be emulated.
- */
curcpu()->ci_data.cpu_ntrap++;
- pcb = lwp_getpcb(l);
+
+ KSI_INIT_TRAP(&ksi);
+ ksi.ksi_trap = EXC_PGM;
+ ksi.ksi_addr = (void *)tf->tf_srr0;
- if (__predict_false(!fpu_used_p(l))) {
- memset(&pcb->pcb_fpu, 0, sizeof(pcb->pcb_fpu));
- fpu_mark_used(l);
- }
+ if (tf->tf_esr & ESR_PTR) {
+sigtrap:
+ if (p->p_raslist != NULL &&
+ ras_lookup(p, (void *)tf->tf_srr0) != (void *) -1) {
+ tf->tf_srr1 += 4;
+ break;
+ }
+ ksi.ksi_code = TRAP_BRKPT;
+ ksi.ksi_signo = SIGTRAP;
+ } else {
+ pcb = lwp_getpcb(l);
- if (fpu_emulate(tf, &pcb->pcb_fpu, &ksi)) {
- if (ksi.ksi_signo == 0) /* was emulated */
- break;
- } else {
- ksi.ksi_signo = SIGILL;
- ksi.ksi_code = ILL_ILLOPC;
- ksi.ksi_trap = EXC_PGM;
- ksi.ksi_addr = (void *)tf->tf_srr0;
+ if (__predict_false(!fpu_used_p(l))) {
+ memset(&pcb->pcb_fpu, 0, sizeof(pcb->pcb_fpu));
+ fpu_mark_used(l);
+ }
+
+ if (fpu_emulate(tf, &pcb->pcb_fpu, &ksi)) {
+ if (ksi.ksi_signo == 0) /* was emulated */
+ break;
+ else if (ksi.ksi_signo == SIGTRAP)
+ goto sigtrap; /* XXX H/W bug? */
+ } else {
+ ksi.ksi_code = ILL_ILLOPC;
+ ksi.ksi_signo = SIGILL;
+ }
}
trapsignal(l, &ksi);
Home |
Main Index |
Thread Index |
Old Index