summaryrefslogtreecommitdiff
path: root/sys/arch/vax
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2012-12-02 07:03:33 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2012-12-02 07:03:33 +0000
commit15c7623306062239f832ef81bd0bdfc804b4d186 (patch)
treed4c341f7fa4f162d4c4cd1ede1db5c9089f0afb6 /sys/arch/vax
parentb02dfe0ab7aae6700f0c15419373891118eab134 (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/vax')
-rw-r--r--sys/arch/vax/include/cpu.h3
-rw-r--r--sys/arch/vax/include/signal.h4
-rw-r--r--sys/arch/vax/vax/machdep.c17
3 files changed, 8 insertions, 16 deletions
diff --git a/sys/arch/vax/include/cpu.h b/sys/arch/vax/include/cpu.h
index d16676d7ad5..aa30873fdd4 100644
--- a/sys/arch/vax/include/cpu.h
+++ b/sys/arch/vax/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.40 2011/09/15 00:48:24 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.41 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.41 1999/10/21 20:01:36 ragge Exp $ */
/*
@@ -123,6 +123,7 @@ extern int want_resched; /* resched() was called */
* This is used during profiling to integrate system time.
*/
#define PROC_PC(p) (((struct trapframe *)((p)->p_addr->u_pcb.framep))->pc)
+#define PROC_STACK(p) (((struct trapframe *)((p)->p_addr->u_pcb.framep))->sp)
/*
* Give a profiling tick to the current process when the user profiling
diff --git a/sys/arch/vax/include/signal.h b/sys/arch/vax/include/signal.h
index 65f8a520838..59f306b9887 100644
--- a/sys/arch/vax/include/signal.h
+++ b/sys/arch/vax/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.7 2011/03/23 16:54:37 pirofti Exp $ */
+/* $OpenBSD: signal.h,v 1.8 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: signal.h,v 1.4 1995/01/10 19:01:52 jtc Exp $ */
/*
@@ -50,7 +50,7 @@ typedef int sig_atomic_t;
* a non-standard exit is performed.
*/
struct sigcontext {
- int sc_onstack; /* sigstack state to restore */
+ int __sc_unused;
int sc_mask; /* signal mask to restore */
int sc_sp; /* sp to restore */
int sc_fp; /* fp to restore */
diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c
index fd8ea7d88ee..8c043067dc5 100644
--- a/sys/arch/vax/vax/machdep.c
+++ b/sys/arch/vax/vax/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.122 2012/10/08 21:47:50 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.123 2012/12/02 07:03:32 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.108 2000/09/13 15:00:23 thorpej Exp $ */
/*
@@ -346,7 +346,7 @@ consinit()
* Old sigcontext structure, still used by userland until setjmp is fixed.
*/
struct osigcontext {
- int sc_onstack; /* sigstack state to restore */
+ int __sc_unused;
int sc_mask; /* signal mask to restore */
int sc_sp; /* sp to restore */
int sc_fp; /* fp to restore */
@@ -394,10 +394,6 @@ sys_sigreturn(p, v, retval)
(ksc.sc_ps & PSL_CM)) {
return (EINVAL);
}
- if (ksc.sc_onstack & 01)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
/* Restore signal mask. */
p->p_sigmask = ksc.sc_mask & ~sigcantmask;
@@ -450,13 +446,12 @@ sendsig(catcher, sig, mask, code, type, val)
struct trapframe *syscf;
struct sigframe *sigf, gsigf;
unsigned int cursp;
- int onstack;
syscf = p->p_addr->u_pcb.framep;
- onstack = p->p_sigstk.ss_flags & SS_ONSTACK;
/* Allocate space for the signal handler context. */
- if (onstack)
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(syscf->sp) && (psp->ps_sigonstack & sigmask(sig)))
cursp = ((int)p->p_sigstk.ss_sp + p->p_sigstk.ss_size);
else
cursp = syscf->sp;
@@ -475,7 +470,6 @@ sendsig(catcher, sig, mask, code, type, val)
initsiginfo(&gsigf.sf_si, sig, code, type, val);
}
- gsigf.sf_sc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK;
gsigf.sf_sc.sc_mask = mask;
gsigf.sf_sc.sc_sp = syscf->sp;
gsigf.sf_sc.sc_fp = syscf->fp;
@@ -508,9 +502,6 @@ sendsig(catcher, sig, mask, code, type, val)
*/
syscf->sp = (unsigned)sigf;
syscf->ap = (unsigned)sigf + offsetof(struct sigframe, sf_pc);
-
- if (onstack)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
}
int waittime = -1;