mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-04 09:09:56 +00:00
- 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
This commit is contained in:
parent
401dafd6b0
commit
7035694536
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=157445
@ -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 ||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user