diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-12-02 07:03:33 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-12-02 07:03:33 +0000 |
commit | 15c7623306062239f832ef81bd0bdfc804b4d186 (patch) | |
tree | d4c341f7fa4f162d4c4cd1ede1db5c9089f0afb6 /sys/arch/sh | |
parent | b02dfe0ab7aae6700f0c15419373891118eab134 (diff) |
Determine whether we're currently on the alternative signal stack
dynamically, by comparing the stack pointer against the altstack
base and size, so that you get the correct answer if you longjmp
out of the signal handler, as tested by regress/sys/kern/stackjmp/.
Also, fix alt stack handling on vax, where it was completely broken.
Testing and corrections by miod@, krw@, tobiasu@, pirofti@
Diffstat (limited to 'sys/arch/sh')
-rw-r--r-- | sys/arch/sh/include/cpu.h | 6 | ||||
-rw-r--r-- | sys/arch/sh/include/signal.h | 4 | ||||
-rw-r--r-- | sys/arch/sh/sh/sh_machdep.c | 18 |
3 files changed, 10 insertions, 18 deletions
diff --git a/sys/arch/sh/include/cpu.h b/sys/arch/sh/include/cpu.h index 2963065e1f5..021ab7203ff 100644 --- a/sys/arch/sh/include/cpu.h +++ b/sys/arch/sh/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.21 2010/09/28 20:27:55 miod Exp $ */ +/* $OpenBSD: cpu.h,v 1.22 2012/12/02 07:03:31 guenther Exp $ */ /* $NetBSD: cpu.h,v 1.41 2006/01/21 04:24:12 uwe Exp $ */ /*- @@ -97,8 +97,8 @@ struct clockframe { * This is used during profiling to integrate system time. It can safely * assume that the process is resident. */ -#define PROC_PC(p) \ - (((struct trapframe *)(p)->p_md.md_regs)->tf_spc) +#define PROC_PC(p) ((p)->p_md.md_regs->tf_spc) +#define PROC_STACK(p) ((p)->p_md.md_regs->tf_r15) /* * Preempt the current process if in interrupt from user mode, diff --git a/sys/arch/sh/include/signal.h b/sys/arch/sh/include/signal.h index 7f123772a2d..e5152d73cf2 100644 --- a/sys/arch/sh/include/signal.h +++ b/sys/arch/sh/include/signal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: signal.h,v 1.5 2012/04/27 17:39:47 pirofti Exp $ */ +/* $OpenBSD: signal.h,v 1.6 2012/12/02 07:03:31 guenther Exp $ */ /* $NetBSD: signal.h,v 1.12 2005/12/11 12:18:58 christos Exp $ */ /* @@ -52,7 +52,7 @@ struct sigcontext { int sc_reg[21]; int sc_fpreg[34]; - int sc_onstack; /* sigstack state to restore */ + int __sc_unused; int sc_expevt; /* XXX should be above */ int sc_err; diff --git a/sys/arch/sh/sh/sh_machdep.c b/sys/arch/sh/sh/sh_machdep.c index 28d96a9a250..99342ff17c5 100644 --- a/sys/arch/sh/sh/sh_machdep.c +++ b/sys/arch/sh/sh/sh_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sh_machdep.c,v 1.32 2012/04/13 18:09:01 miod Exp $ */ +/* $OpenBSD: sh_machdep.c,v 1.33 2012/12/02 07:03:31 guenther Exp $ */ /* $NetBSD: sh3_machdep.c,v 1.59 2006/03/04 01:13:36 uwe Exp $ */ /* @@ -462,15 +462,13 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, struct trapframe *tf = p->p_md.md_regs; struct sigacts *psp = p->p_sigacts; siginfo_t *sip; - int onstack; - onstack = p->p_sigstk.ss_flags & SS_ONSTACK; - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && onstack == 0 && - (psp->ps_sigonstack & sigmask(sig))) { + if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && + !sigonstack(p->p_md.md_regs->tf_r15) && + (psp->ps_sigonstack & sigmask(sig))) fp = (struct sigframe *)((vaddr_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size); - p->p_sigstk.ss_flags |= SS_ONSTACK; - } else + else fp = (void *)p->p_md.md_regs->tf_r15; --fp; @@ -490,7 +488,6 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type, fpu_save((struct fpreg *)&frame.sf_uc.sc_fpreg); #endif - frame.sf_uc.sc_onstack = onstack; frame.sf_uc.sc_expevt = tf->tf_expevt; /* frame.sf_uc.sc_err = 0; */ frame.sf_uc.sc_mask = mask; @@ -555,11 +552,6 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval) fpu_restore((struct fpreg *)&context.sc_fpreg); #endif - /* Restore signal stack. */ - if (context.sc_onstack) - p->p_sigstk.ss_flags |= SS_ONSTACK; - else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; /* Restore signal mask. */ p->p_sigmask = context.sc_mask & ~sigcantmask; |