summaryrefslogtreecommitdiffstats
path: root/sys/sparc64
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2006-04-03 21:27:01 +0000
committermarius <marius@FreeBSD.org>2006-04-03 21:27:01 +0000
commit6a5bc8bdd6b582ad15197e894cf2a8890445b283 (patch)
tree3c86b133432f5a212fe7ff5e63e114dc98a13f8b /sys/sparc64
parent3be39fdbda315b35fd61c5da6548b6d372a27c20 (diff)
downloadFreeBSD-src-6a5bc8bdd6b582ad15197e894cf2a8890445b283.zip
FreeBSD-src-6a5bc8bdd6b582ad15197e894cf2a8890445b283.tar.gz
- s,tramoline,trampoline, in a comment.
- Use FBSDID in trap.c - Make the global trap_sig[] static as it's not used outside of trap.c. - In sendsig() remove an unused variable. - In trap() sync with the other archs; for fast data access MMU miss and data access protection traps set ksi_addr to the SFAR reg which contains the faulting address and otherwise to the TPC reg. Generally the TCP reg contains the address of the instruction that caused the exception, except for fast instruction access traps (and some others; more refinement may be needed here) it also contains the faulting address. Previously sendsig() always set si_addr to the SFAR reg which is wrong for most traps. - In sendsig() add support for FreeBSD old-style signals. These changes are inspired by kmacy's sun4v changes and allow libsigsegv to build on FreeBSD/sparc64, but it doesn't pass all checks and tests it actually should, yet. MFC after: 5 days
Diffstat (limited to 'sys/sparc64')
-rw-r--r--sys/sparc64/sparc64/machdep.c20
-rw-r--r--sys/sparc64/sparc64/trap.c12
2 files changed, 22 insertions, 10 deletions
diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c
index e5248b7..60f271a 100644
--- a/sys/sparc64/sparc64/machdep.c
+++ b/sys/sparc64/sparc64/machdep.c
@@ -464,14 +464,12 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
int oonstack;
u_long sp;
int sig;
- int code;
oonstack = 0;
td = curthread;
p = td->td_proc;
PROC_LOCK_ASSERT(p, MA_OWNED);
sig = ksi->ksi_signo;
- code = ksi->ksi_code;
psp = p->p_sigacts;
mtx_assert(&psp->ps_mtx, MA_OWNED);
tf = td->td_frame;
@@ -484,7 +482,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/* Make sure we have a signal trampoline to return to. */
if (p->p_md.md_sigtramp == NULL) {
/*
- * No signal tramoline... kill the process.
+ * No signal trampoline... kill the process.
*/
CTR0(KTR_SIG, "sendsig: no sigtramp");
printf("sendsig: %s is too old, rebuild it\n", p->p_comm);
@@ -518,12 +516,20 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/* Build the argument list for the signal handler. */
tf->tf_out[0] = sig;
- tf->tf_out[1] = (register_t)&sfp->sf_si;
tf->tf_out[2] = (register_t)&sfp->sf_uc;
tf->tf_out[4] = (register_t)catcher;
- /* Fill siginfo structure. */
- sf.sf_si = ksi->ksi_info;
- sf.sf_si.si_addr = (void *)tf->tf_sfar; /* XXX */
+ if (SIGISMEMBER(psp->ps_siginfo, sig)) {
+ /* Signal handler installed with SA_SIGINFO. */
+ tf->tf_out[1] = (register_t)&sfp->sf_si;
+
+ /* Fill in POSIX parts. */
+ sf.sf_si = ksi->ksi_info;
+ sf.sf_si.si_signo = sig; /* maybe a translated signal */
+ } else {
+ /* Old FreeBSD-style arguments. */
+ tf->tf_out[1] = ksi->ksi_code;
+ tf->tf_out[3] = (register_t)ksi->ksi_addr;
+ }
/* Copy the sigframe out to the user's stack. */
if (rwindow_save(td) != 0 || copyout(&sf, sfp, sizeof(*sfp)) != 0 ||
diff --git a/sys/sparc64/sparc64/trap.c b/sys/sparc64/sparc64/trap.c
index 72ddf9a..4cbbbad 100644
--- a/sys/sparc64/sparc64/trap.c
+++ b/sys/sparc64/sparc64/trap.c
@@ -37,9 +37,11 @@
*
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
* from: FreeBSD: src/sys/i386/i386/trap.c,v 1.197 2001/07/19
- * $FreeBSD$
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include "opt_ddb.h"
#include "opt_ktr.h"
#include "opt_ktrace.h"
@@ -165,7 +167,7 @@ const char *trap_msg[] = {
"kernel stack fault",
};
-const int trap_sig[] = {
+static const int trap_sig[] = {
SIGILL, /* reserved */
SIGILL, /* instruction access exception */
SIGILL, /* instruction access error */
@@ -233,6 +235,7 @@ trap(struct trapframe *tf)
struct proc *p;
int error;
int sig;
+ register_t addr;
ksiginfo_t ksi;
td = PCPU_GET(curthread);
@@ -250,12 +253,15 @@ trap(struct trapframe *tf)
p = td->td_proc;
td->td_pticks = 0;
td->td_frame = tf;
+ addr = tf->tf_tpc;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
switch (tf->tf_type) {
case T_DATA_MISS:
case T_DATA_PROTECTION:
+ addr = tf->tf_sfar;
+ /* FALLTHROUGH */
case T_INSTRUCTION_MISS:
sig = trap_pfault(td, tf);
break;
@@ -288,7 +294,7 @@ trap(struct trapframe *tf)
ksiginfo_init_trap(&ksi);
ksi.ksi_signo = sig;
ksi.ksi_code = (int)tf->tf_type; /* XXX not POSIX */
- /* ksi.ksi_addr = ? */
+ ksi.ksi_addr = (void *)addr;
ksi.ksi_trapno = (int)tf->tf_type;
trapsignal(td, &ksi);
}
OpenPOWER on IntegriCloud