summaryrefslogtreecommitdiff
path: root/sys/arch
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
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')
-rw-r--r--sys/arch/alpha/alpha/machdep.c26
-rw-r--r--sys/arch/alpha/include/cpu.h3
-rw-r--r--sys/arch/alpha/include/signal.h4
-rw-r--r--sys/arch/amd64/amd64/machdep.c18
-rw-r--r--sys/arch/amd64/include/cpu.h3
-rw-r--r--sys/arch/amd64/include/signal.h4
-rw-r--r--sys/arch/arm/arm/sig_machdep.c46
-rw-r--r--sys/arch/arm/include/cpu.h3
-rw-r--r--sys/arch/arm/include/signal.h4
-rw-r--r--sys/arch/hppa/hppa/machdep.c16
-rw-r--r--sys/arch/hppa/include/cpu.h3
-rw-r--r--sys/arch/hppa/include/signal.h4
-rw-r--r--sys/arch/hppa64/hppa64/machdep.c16
-rw-r--r--sys/arch/hppa64/include/cpu.h5
-rw-r--r--sys/arch/hppa64/include/signal.h4
-rw-r--r--sys/arch/i386/i386/machdep.c16
-rw-r--r--sys/arch/i386/include/cpu.h3
-rw-r--r--sys/arch/i386/include/signal.h4
-rw-r--r--sys/arch/m68k/include/cpu.h3
-rw-r--r--sys/arch/m68k/include/signal.h4
-rw-r--r--sys/arch/m68k/m68k/sig_machdep.c22
-rw-r--r--sys/arch/m88k/include/cpu.h3
-rw-r--r--sys/arch/m88k/include/signal.h6
-rw-r--r--sys/arch/m88k/m88k/sig_machdep.c20
-rw-r--r--sys/arch/macppc/macppc/machdep.c19
-rw-r--r--sys/arch/mips64/include/cpu.h3
-rw-r--r--sys/arch/mips64/include/signal.h4
-rw-r--r--sys/arch/mips64/mips64/sendsig.c20
-rw-r--r--sys/arch/powerpc/include/cpu.h3
-rw-r--r--sys/arch/powerpc/include/signal.h4
-rw-r--r--sys/arch/sh/include/cpu.h6
-rw-r--r--sys/arch/sh/include/signal.h4
-rw-r--r--sys/arch/sh/sh/sh_machdep.c18
-rw-r--r--sys/arch/socppc/socppc/machdep.c19
-rw-r--r--sys/arch/solbourne/solbourne/machdep.c19
-rw-r--r--sys/arch/sparc/include/cpu.h3
-rw-r--r--sys/arch/sparc/include/signal.h6
-rw-r--r--sys/arch/sparc/sparc/machdep.c19
-rw-r--r--sys/arch/sparc64/include/cpu.h3
-rw-r--r--sys/arch/sparc64/include/signal.h6
-rw-r--r--sys/arch/sparc64/sparc64/machdep.c29
-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
44 files changed, 163 insertions, 286 deletions
diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c
index 264180a6993..a66a81c01d0 100644
--- a/sys/arch/alpha/alpha/machdep.c
+++ b/sys/arch/alpha/alpha/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.139 2012/11/01 21:09:17 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.140 2012/12/02 07:03:30 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.210 2000/06/01 17:12:38 thorpej Exp $ */
/*-
@@ -1431,11 +1431,12 @@ sendsig(catcher, sig, mask, code, type, val)
struct fpreg *fpregs = (struct fpreg *)&ksc.sc_fpregs;
struct trapframe *frame;
struct sigacts *psp = p->p_sigacts;
- int oonstack, fsize, rndfsize, kscsize;
+ unsigned long oldsp;
+ int fsize, rndfsize, kscsize;
siginfo_t *sip, ksi;
+ oldsp = alpha_pal_rdusp();
frame = p->p_md.md_tf;
- oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
fsize = sizeof ksc;
rndfsize = ((fsize + 15) / 16) * 16;
kscsize = rndfsize;
@@ -1451,25 +1452,24 @@ sendsig(catcher, sig, mask, code, type, val)
* will fail if the process has not already allocated
* the space with a `brk'.
*/
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack &&
- (psp->ps_sigonstack & sigmask(sig))) {
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(oldsp) && (psp->ps_sigonstack & sigmask(sig)))
scp = (struct sigcontext *)(p->p_sigstk.ss_sp +
p->p_sigstk.ss_size - rndfsize);
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
- scp = (struct sigcontext *)(alpha_pal_rdusp() - rndfsize);
+ else
+ scp = (struct sigcontext *)(oldsp - rndfsize);
if ((u_long)scp <= USRSTACK - ptoa(p->p_vmspace->vm_ssize))
(void)uvm_grow(p, (u_long)scp);
#ifdef DEBUG
if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
printf("sendsig(%d): sig %d ssp %p usp %p\n", p->p_pid,
- sig, &oonstack, scp);
+ sig, &ksc, scp);
#endif
/*
* Build the signal context to be used by sigreturn.
*/
- ksc.sc_onstack = oonstack;
+ bzero(&ksc, sizeof(ksc));
ksc.sc_mask = mask;
ksc.sc_pc = frame->tf_regs[FRAME_PC];
ksc.sc_ps = frame->tf_regs[FRAME_PS];
@@ -1477,7 +1477,7 @@ sendsig(catcher, sig, mask, code, type, val)
/* copy the registers. */
frametoreg(frame, (struct reg *)ksc.sc_regs);
ksc.sc_regs[R_ZERO] = 0xACEDBADE; /* magic number */
- ksc.sc_regs[R_SP] = alpha_pal_rdusp();
+ ksc.sc_regs[R_SP] = oldsp;
/* save the floating-point state, if necessary, then copy it. */
if (p->p_addr->u_pcb.pcb_fpcpu != NULL)
@@ -1588,10 +1588,6 @@ sys_sigreturn(p, v, retval)
/*
* Restore the user-supplied information
*/
- if (ksc.sc_onstack)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = ksc.sc_mask &~ sigcantmask;
p->p_md.md_tf->tf_regs[FRAME_PC] = ksc.sc_pc;
diff --git a/sys/arch/alpha/include/cpu.h b/sys/arch/alpha/include/cpu.h
index 24c3f2c755f..689df5d258a 100644
--- a/sys/arch/alpha/include/cpu.h
+++ b/sys/arch/alpha/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.45 2012/11/01 21:09:17 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.46 2012/12/02 07:03:30 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.45 2000/08/21 02:03:12 thorpej Exp $ */
/*-
@@ -275,6 +275,7 @@ struct clockframe {
* This is used during profiling to integrate system time.
*/
#define PROC_PC(p) ((p)->p_md.md_tf->tf_regs[FRAME_PC])
+#define PROC_STACK(p) (alpha_pal_rdusp()) /*XXX only works for curproc */
/*
* Preempt the current process if in interrupt from user mode,
diff --git a/sys/arch/alpha/include/signal.h b/sys/arch/alpha/include/signal.h
index 1f446e22e1b..a5bf019502b 100644
--- a/sys/arch/alpha/include/signal.h
+++ b/sys/arch/alpha/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.7 2011/03/23 16:54:34 pirofti Exp $ */
+/* $OpenBSD: signal.h,v 1.8 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: signal.h,v 1.2 1995/02/16 03:08:08 cgd Exp $ */
/*
@@ -47,7 +47,7 @@ typedef int sig_atomic_t;
* representations of 'struct reg' and 'struct fpreg', respectively.
*/
struct sigcontext {
- long sc_onstack; /* sigstack state to restore */
+ long __sc_ununsed;
long sc_mask; /* signal mask to restore */
long sc_pc; /* pc to restore */
long sc_ps; /* ps to restore */
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 636b066b12f..2a2c72336cb 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.158 2012/10/19 16:38:30 mlarkin Exp $ */
+/* $OpenBSD: machdep.c,v 1.159 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -557,16 +557,14 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
#endif
bcopy(tf, &ksc, sizeof(*tf));
- ksc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK;
+ bzero((char *)&ksc + sizeof(*tf), sizeof(ksc) - sizeof(*tf));
ksc.sc_mask = mask;
- ksc.sc_fpstate = NULL;
/* Allocate space for the signal handler context. */
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !ksc.sc_onstack &&
- (psp->ps_sigonstack & sigmask(sig))) {
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(tf->tf_rsp) && (psp->ps_sigonstack & sigmask(sig)))
sp = (register_t)p->p_sigstk.ss_sp + p->p_sigstk.ss_size;
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
+ else
sp = tf->tf_rsp - 128;
sp &= ~15ULL; /* just in case */
@@ -672,11 +670,7 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
ksc.sc_err = tf->tf_err;
bcopy(&ksc, tf, sizeof(*tf));
- /* Restore signal stack. */
- if (ksc.sc_onstack)
- 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;
/*
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index 60a095eed9e..8c86a9e1f55 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.75 2012/11/10 09:45:05 mglocker Exp $ */
+/* $OpenBSD: cpu.h,v 1.76 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -146,6 +146,7 @@ struct cpu_info {
#define CPUF_GO 0x8000 /* CPU should start running */
#define PROC_PC(p) ((p)->p_md.md_regs->tf_rip)
+#define PROC_STACK(p) ((p)->p_md.md_regs->tf_rsp)
extern struct cpu_info cpu_info_primary;
extern struct cpu_info *cpu_info_list;
diff --git a/sys/arch/amd64/include/signal.h b/sys/arch/amd64/include/signal.h
index 88dfc97cecf..f1f310048d2 100644
--- a/sys/arch/amd64/include/signal.h
+++ b/sys/arch/amd64/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.6 2011/03/23 16:54:34 pirofti Exp $ */
+/* $OpenBSD: signal.h,v 1.7 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: signal.h,v 1.2 2003/04/28 23:16:17 bjh21 Exp $ */
/*
@@ -81,7 +81,7 @@ struct sigcontext {
long sc_ss;
struct fxsave64 *sc_fpstate;
- int sc_onstack;
+ int __sc_unused;
int sc_mask;
};
#endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */
diff --git a/sys/arch/arm/arm/sig_machdep.c b/sys/arch/arm/arm/sig_machdep.c
index 13b9bfc113f..22ec82356ca 100644
--- a/sys/arch/arm/arm/sig_machdep.c
+++ b/sys/arch/arm/arm/sig_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sig_machdep.c,v 1.7 2011/09/20 22:02:11 miod Exp $ */
+/* $OpenBSD: sig_machdep.c,v 1.8 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: sig_machdep.c,v 1.22 2003/10/08 00:28:41 thorpej Exp $ */
/*
@@ -65,9 +65,6 @@ process_frame(struct proc *p)
return p->p_addr->u_pcb.pcb_tf;
}
-void *getframe(struct proc *p, int sig, int *onstack);
-
-
/*
* Send an interrupt to process.
*
@@ -85,21 +82,19 @@ sendsig(sig_t catcher, int sig, int returnmask, u_long code, int type,
struct trapframe *tf;
struct sigframe *fp, frame;
struct sigacts *psp = p->p_sigacts;
- int oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
- int onstack = 0;
tf = process_frame(p);
/* Do we need to jump onto the signal stack? */
/* Allocate space for the signal handler context. */
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack &&
- (psp->ps_sigonstack & sigmask(sig))) {
- onstack = 1;
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(tf->tf_usr_sp) && (psp->ps_sigonstack & sigmask(sig)))
fp = (struct sigframe *)((caddr_t)p->p_sigstk.ss_sp +
p->p_sigstk.ss_size);
- } else
+ else
fp = (struct sigframe *)tf->tf_usr_sp;
+
/* make room on the stack */
fp--;
@@ -107,6 +102,7 @@ sendsig(sig_t catcher, int sig, int returnmask, u_long code, int type,
fp = (void *)STACKALIGN(fp);
/* Build stack frame for signal trampoline. */
+ bzero(&frame, sizeof(frame));
frame.sf_signum = sig;
frame.sf_sip = NULL;
frame.sf_scp = &fp->sf_sc;
@@ -132,9 +128,6 @@ sendsig(sig_t catcher, int sig, int returnmask, u_long code, int type,
frame.sf_sc.sc_pc = tf->tf_pc;
frame.sf_sc.sc_spsr = tf->tf_spsr;
- /* Save signal stack. */
- frame.sf_sc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK;
-
/* Save signal mask. */
frame.sf_sc.sc_mask = returnmask;
@@ -172,28 +165,7 @@ sendsig(sig_t catcher, int sig, int returnmask, u_long code, int type,
tf->tf_usr_lr = (int)p->p_sigcode;
/* XXX This should not be needed. */
cpu_icache_sync_all();
-
- /* Remember that we're now on the signal stack. */
- if (onstack)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
-}
-
-#if 0
-void *
-getframe(struct proc *p, int sig, int *onstack)
-{
- struct sigctx *ctx = &p->p_sigctx;
- struct trapframe *tf = process_frame(l);
-
- /* Do we need to jump onto the signal stack? */
- *onstack = (ctx->ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0
- && (SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
- if (*onstack)
- return (char *)ctx->ps_sigstk.ss_sp + ctx->ps_sigstk.ss_size;
- return (void *)tf->tf_usr_sp;
}
-#endif
-
/*
* System call to cleanup state after a signal
@@ -259,12 +231,6 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
tf->tf_pc = context.sc_pc;
tf->tf_spsr = context.sc_spsr;
- /* Restore signal stack. */
- if (context.sc_onstack & SS_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;
diff --git a/sys/arch/arm/include/cpu.h b/sys/arch/arm/include/cpu.h
index b9260fd852f..155a2a2a57e 100644
--- a/sys/arch/arm/include/cpu.h
+++ b/sys/arch/arm/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.30 2011/11/16 20:50:18 deraadt Exp $ */
+/* $OpenBSD: cpu.h,v 1.31 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */
/*
@@ -154,6 +154,7 @@ extern int current_intr_depth;
* PROC_PC: Find out the program counter for the given process.
*/
#define PROC_PC(p) ((p)->p_addr->u_pcb.pcb_tf->tf_pc)
+#define PROC_STACK(p) ((p)->p_addr->u_pcb.pcb_tf->tf_usr_sp)
/* The address of the vector page. */
extern vaddr_t vector_page;
diff --git a/sys/arch/arm/include/signal.h b/sys/arch/arm/include/signal.h
index 5af8396e380..564ea4f5bfc 100644
--- a/sys/arch/arm/include/signal.h
+++ b/sys/arch/arm/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.7 2011/09/20 22:02:13 miod Exp $ */
+/* $OpenBSD: signal.h,v 1.8 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: signal.h,v 1.5 2003/10/18 17:57:21 briggs Exp $ */
/*
@@ -61,7 +61,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 (old style) */
unsigned int sc_spsr;
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c
index 9dfc4d6a738..6b4e04a6eb8 100644
--- a/sys/arch/hppa/hppa/machdep.c
+++ b/sys/arch/hppa/hppa/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.209 2012/10/26 12:32:48 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.210 2012/12/02 07:03:31 guenther Exp $ */
/*
* Copyright (c) 1999-2003 Michael Shalayeff
@@ -1226,16 +1226,13 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
/* Save the FPU context first. */
fpu_proc_save(p);
- ksc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK;
-
/*
* Allocate space for the signal handler context.
*/
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !ksc.sc_onstack &&
- (psp->ps_sigonstack & sigmask(sig))) {
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(tf->tf_sp) && (psp->ps_sigonstack & sigmask(sig)))
scp = (register_t)p->p_sigstk.ss_sp;
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
+ else
scp = (tf->tf_sp + 63) & ~63;
sss = (sizeof(ksc) + 63) & ~63;
@@ -1251,6 +1248,7 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
tf->tf_iioq_head, tf->tf_iioq_tail, tf->tf_ipsw, PSL_BITS);
#endif
+ bzero(&ksc, sizeof(ksc));
ksc.sc_mask = mask;
ksc.sc_fp = scp + sss;
ksc.sc_ps = tf->tf_ipsw;
@@ -1353,10 +1351,6 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
if ((ksc.sc_ps & (PSL_MBS|PSL_MBZ)) != PSL_MBS)
return (EINVAL);
- if (ksc.sc_onstack)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = ksc.sc_mask &~ sigcantmask;
tf->tf_t1 = ksc.sc_regs[0]; /* r22 */
diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h
index 62cbd5aae30..c74038cd926 100644
--- a/sys/arch/hppa/include/cpu.h
+++ b/sys/arch/hppa/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.80 2011/09/20 21:44:09 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.81 2012/12/02 07:03:31 guenther Exp $ */
/*
* Copyright (c) 2000-2004 Michael Shalayeff
@@ -202,6 +202,7 @@ extern int cpu_hvers;
#define need_proftick(p) setsoftast(p)
#define PROC_PC(p) ((p)->p_md.md_regs->tf_iioq_head)
+#define PROC_STACK(p) ((p)->p_md.md_regs->tf_sp)
#ifndef _LOCORE
#ifdef _KERNEL
diff --git a/sys/arch/hppa/include/signal.h b/sys/arch/hppa/include/signal.h
index e44a2cca195..80beef1253e 100644
--- a/sys/arch/hppa/include/signal.h
+++ b/sys/arch/hppa/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.9 2011/11/14 14:29:53 deraadt Exp $ */
+/* $OpenBSD: signal.h,v 1.10 2012/12/02 07:03:31 guenther Exp $ */
/*
* Copyright (c) 1994, The University of Utah and
@@ -47,7 +47,7 @@ typedef int sig_atomic_t;
* a non-standard exit is performed.
*/
struct sigcontext {
- unsigned long sc_onstack; /* sigstack state to restore */
+ unsigned long __sc_unused;
unsigned long sc_mask; /* signal mask to restore */
unsigned long sc_ps; /* psl to restore */
unsigned long sc_fp; /* fp to restore */
diff --git a/sys/arch/hppa64/hppa64/machdep.c b/sys/arch/hppa64/hppa64/machdep.c
index 9262ad7ee40..4c290279303 100644
--- a/sys/arch/hppa64/hppa64/machdep.c
+++ b/sys/arch/hppa64/hppa64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.49 2012/10/08 21:47:48 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.50 2012/12/02 07:03:31 guenther Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
@@ -854,16 +854,13 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
/* Save the FPU context first. */
fpu_proc_save(p);
- ksc.sc_onstack = p->p_sigstk.ss_flags & SS_ONSTACK;
-
/*
* Allocate space for the signal handler context.
*/
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !ksc.sc_onstack &&
- (psp->ps_sigonstack & sigmask(sig))) {
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(tf->tf_sp) && (psp->ps_sigonstack & sigmask(sig)))
scp = (register_t)p->p_sigstk.ss_sp;
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
+ else
scp = (tf->tf_sp + 63) & ~63;
sss = (sizeof(ksc) + 63) & ~63;
@@ -879,6 +876,7 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
tf->tf_iioq[0], tf->tf_iioq[1], tf->tf_ipsw, PSL_BITS);
#endif
+ bzero(&ksc, sizeof(ksc));
ksc.sc_mask = mask;
ksc.sc_fp = scp + sss;
ksc.sc_ps = tf->tf_ipsw;
@@ -951,10 +949,6 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
if ((ksc.sc_ps & (PSL_MBS|PSL_MBZ)) != PSL_MBS)
return (EINVAL);
- if (ksc.sc_onstack)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = ksc.sc_mask &~ sigcantmask;
tf->tf_sar = ksc.sc_regs[0];
diff --git a/sys/arch/hppa64/include/cpu.h b/sys/arch/hppa64/include/cpu.h
index 6073089cccd..66ff94f697c 100644
--- a/sys/arch/hppa64/include/cpu.h
+++ b/sys/arch/hppa64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.27 2011/08/16 17:36:37 kettenis Exp $ */
+/* $OpenBSD: cpu.h,v 1.28 2012/12/02 07:03:31 guenther Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
@@ -163,6 +163,9 @@ extern int cpu_hvers;
#define clear_resched(ci) want_resched = 0
#define need_proftick(p) setsoftast()
+#define PROC_PC(p) ((p)->p_md.md_regs->tf_iioq[0])
+#define PROC_STACK(p) ((p)->p_md.md_regs->tf_sp)
+
#ifndef _LOCORE
#ifdef _KERNEL
diff --git a/sys/arch/hppa64/include/signal.h b/sys/arch/hppa64/include/signal.h
index baaf5902d46..d2e8d316eb8 100644
--- a/sys/arch/hppa64/include/signal.h
+++ b/sys/arch/hppa64/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.4 2011/03/23 16:54:35 pirofti Exp $ */
+/* $OpenBSD: signal.h,v 1.5 2012/12/02 07:03:31 guenther Exp $ */
/*
* Copyright (c) 1994, The University of Utah and
@@ -47,7 +47,7 @@ typedef int sig_atomic_t;
* a non-standard exit is performed.
*/
struct sigcontext {
- unsigned long sc_onstack; /* sigstack state to restore */
+ unsigned long __sc_unused;
unsigned long sc_mask; /* signal mask to restore */
unsigned long sc_ps; /* psl to restore */
unsigned long sc_fp; /* fp to restore */
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 00305d9d766..caab972c8d9 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.517 2012/11/10 09:45:05 mglocker Exp $ */
+/* $OpenBSD: machdep.c,v 1.518 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -2315,21 +2315,20 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
struct sigframe *fp, frame;
struct sigacts *psp = p->p_sigacts;
register_t sp;
- int oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
/*
* Build the argument list for the signal handler.
*/
+ bzero(&frame, sizeof(frame));
frame.sf_signum = sig;
/*
* Allocate space for the signal handler context.
*/
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack &&
- (psp->ps_sigonstack & sigmask(sig))) {
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(tf->tf_esp) && (psp->ps_sigonstack & sigmask(sig)))
sp = (long)p->p_sigstk.ss_sp + p->p_sigstk.ss_size;
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
+ else
sp = tf->tf_esp;
frame.sf_sc.sc_fpstate = NULL;
@@ -2356,7 +2355,6 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
*/
frame.sf_sc.sc_err = tf->tf_err;
frame.sf_sc.sc_trapno = tf->tf_trapno;
- frame.sf_sc.sc_onstack = oonstack;
frame.sf_sc.sc_mask = mask;
#ifdef VM86
if (tf->tf_eflags & PSL_VM) {
@@ -2502,10 +2500,6 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
p->p_md.md_flags |= MDP_USEDFPU;
}
- if (context.sc_onstack & 01)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = context.sc_mask & ~sigcantmask;
return (EJUSTRETURN);
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h
index b87b89aee46..a822caa3fc5 100644
--- a/sys/arch/i386/include/cpu.h
+++ b/sys/arch/i386/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.124 2012/11/10 09:45:05 mglocker Exp $ */
+/* $OpenBSD: cpu.h,v 1.125 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@@ -248,6 +248,7 @@ extern void need_resched(struct cpu_info *);
* This is used during profiling to integrate system time.
*/
#define PROC_PC(p) ((p)->p_md.md_regs->tf_eip)
+#define PROC_STACK(p) ((p)->p_md.md_regs->tf_esp)
/*
* Give a profiling tick to the current process when the user profiling
diff --git a/sys/arch/i386/include/signal.h b/sys/arch/i386/include/signal.h
index b006e83c164..660f7723b83 100644
--- a/sys/arch/i386/include/signal.h
+++ b/sys/arch/i386/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.8 2011/03/23 16:54:35 pirofti Exp $ */
+/* $OpenBSD: signal.h,v 1.9 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: signal.h,v 1.6 1996/01/08 13:51:43 mycroft Exp $ */
/*
@@ -73,7 +73,7 @@ struct sigcontext {
int sc_esp;
int sc_ss;
- int sc_onstack; /* sigstack state to restore */
+ int __sc_unused;
int sc_mask; /* signal mask to restore */
int sc_trapno; /* XXX should be above */
diff --git a/sys/arch/m68k/include/cpu.h b/sys/arch/m68k/include/cpu.h
index c88366858b8..4a3df3f5514 100644
--- a/sys/arch/m68k/include/cpu.h
+++ b/sys/arch/m68k/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.25 2011/11/16 20:50:18 deraadt Exp $ */
+/* $OpenBSD: cpu.h,v 1.26 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.3 1997/02/02 06:56:57 thorpej Exp $ */
/*
@@ -253,6 +253,7 @@ int cachectl(struct proc *, int, vaddr_t, int);
* This is used during profiling to integrate system time.
*/
#define PROC_PC(p) (((struct trapframe *)((p)->p_md.md_regs))->tf_pc)
+#define PROC_STACK(p) (((struct trapframe *)((p)->p_md.md_regs))->tf_regs[15])
#define cpu_idle_enter() do { /* nothing */ } while (0)
#define cpu_idle_leave() do { /* nothing */ } while (0)
diff --git a/sys/arch/m68k/include/signal.h b/sys/arch/m68k/include/signal.h
index 731b01b0a50..9115367cfcb 100644
--- a/sys/arch/m68k/include/signal.h
+++ b/sys/arch/m68k/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.5 2006/01/08 14:20:17 millert Exp $ */
+/* $OpenBSD: signal.h,v 1.6 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: signal.h,v 1.4 1995/01/10 19:01:31 jtc Exp $ */
/*
@@ -55,7 +55,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/m68k/m68k/sig_machdep.c b/sys/arch/m68k/m68k/sig_machdep.c
index eae3162703f..f3933fdf9d4 100644
--- a/sys/arch/m68k/m68k/sig_machdep.c
+++ b/sys/arch/m68k/m68k/sig_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sig_machdep.c,v 1.26 2012/08/22 13:33:32 okan Exp $ */
+/* $OpenBSD: sig_machdep.c,v 1.27 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: sig_machdep.c,v 1.3 1997/04/30 23:28:03 gwr Exp $ */
/*
@@ -131,11 +131,10 @@ sendsig(catcher, sig, mask, code, type, val)
struct frame *frame;
struct sigacts *psp = p->p_sigacts;
short ft;
- int oonstack, fsize;
+ int fsize;
frame = (struct frame *)p->p_md.md_regs;
ft = frame->f_format;
- oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
/*
* Allocate and validate space for the signal handler
@@ -145,22 +144,22 @@ sendsig(catcher, sig, mask, code, type, val)
* the space with a `brk'.
*/
fsize = sizeof(struct sigframe);
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack &&
- (psp->ps_sigonstack & sigmask(sig))) {
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(frame->f_regs[SP]) &&
+ (psp->ps_sigonstack & sigmask(sig)))
fp = (struct sigframe *)(p->p_sigstk.ss_sp +
p->p_sigstk.ss_size - fsize);
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
+ else
fp = (struct sigframe *)(frame->f_regs[SP] - fsize);
if ((unsigned)fp <= USRSTACK - ptoa(p->p_vmspace->vm_ssize))
(void)uvm_grow(p, (unsigned)fp);
#ifdef DEBUG
if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
printf("sendsig(%d): sig %d ssp %p usp %p scp %p ft %d\n",
- p->p_pid, sig, &oonstack, fp, &fp->sf_sc, ft);
+ p->p_pid, sig, &fsize, fp, &fp->sf_sc, ft);
#endif
kfp = (struct sigframe *)malloc((u_long)fsize, M_TEMP,
- M_WAITOK | M_CANFAIL);
+ M_WAITOK | M_CANFAIL | M_ZERO);
if (kfp == NULL) {
/* Better halt the process in its track than panicing */
sigexit(p, SIGILL);
@@ -226,7 +225,6 @@ sendsig(catcher, sig, mask, code, type, val)
/*
* Build the signal context to be used by sigreturn.
*/
- kfp->sf_sc.sc_onstack = oonstack;
kfp->sf_sc.sc_mask = mask;
kfp->sf_sc.sc_sp = frame->f_regs[SP];
kfp->sf_sc.sc_fp = frame->f_regs[A6];
@@ -320,10 +318,6 @@ sys_sigreturn(p, v, retval)
/*
* Restore the user supplied information
*/
- if (scp->sc_onstack & 1)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = scp->sc_mask &~ sigcantmask;
frame = (struct frame *) p->p_md.md_regs;
frame->f_regs[SP] = scp->sc_sp;
diff --git a/sys/arch/m88k/include/cpu.h b/sys/arch/m88k/include/cpu.h
index 881fff2069b..fadaa543137 100644
--- a/sys/arch/m88k/include/cpu.h
+++ b/sys/arch/m88k/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.54 2011/10/25 18:38:06 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.55 2012/12/02 07:03:31 guenther Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* Copyright (c) 1992, 1993
@@ -266,6 +266,7 @@ struct clockframe {
((regs)->snip & NIP_V ? (regs)->snip & NIP_ADDR : \
(regs)->sfip & FIP_ADDR)))
#define PROC_PC(p) PC_REGS((struct reg *)((p)->p_md.md_tf))
+#define PROC_STACK(p) ((p)->p_md.md_tf->tf_sp)
#define clear_resched(ci) (ci)->ci_want_resched = 0
diff --git a/sys/arch/m88k/include/signal.h b/sys/arch/m88k/include/signal.h
index 2303835c934..ebc9d1b230e 100644
--- a/sys/arch/m88k/include/signal.h
+++ b/sys/arch/m88k/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.6 2012/05/09 21:25:33 miod Exp $ */
+/* $OpenBSD: signal.h,v 1.7 2012/12/02 07:03:31 guenther Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* All rights reserved.
@@ -45,11 +45,9 @@ typedef int sig_atomic_t;
* execution of the signal handler. It is also made available
* to the handler to allow it to restore state properly if
* a non-standard exit is performed.
- *
- * All machines must have an sc_onstack and sc_mask.
*/
struct sigcontext {
- int sc_onstack; /* sigstack state to restore */
+ int __sc_unused;
int sc_mask; /* signal mask to restore */
/* begin machine dependent portion */
unsigned int sc_regs[32 + 25];
diff --git a/sys/arch/m88k/m88k/sig_machdep.c b/sys/arch/m88k/m88k/sig_machdep.c
index fdc7f2f3109..e634fbdfa18 100644
--- a/sys/arch/m88k/m88k/sig_machdep.c
+++ b/sys/arch/m88k/m88k/sig_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sig_machdep.c,v 1.15 2012/08/22 13:33:32 okan Exp $ */
+/* $OpenBSD: sig_machdep.c,v 1.16 2012/12/02 07:03:31 guenther Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -90,12 +90,12 @@ sendsig(sig_t catcher, int sig, int mask, unsigned long code, int type,
struct trapframe *tf;
struct sigacts *psp = p->p_sigacts;
struct sigframe *fp;
- int oonstack, fsize;
+ int fsize;
struct sigframe sf;
vaddr_t addr;
tf = p->p_md.md_tf;
- oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
+
/*
* Allocate and validate space for the signal handler
* context. Note that if the stack is in data space, the
@@ -105,12 +105,10 @@ sendsig(sig_t catcher, int sig, int mask, unsigned long code, int type,
*/
fsize = sizeof(struct sigframe);
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- (p->p_sigstk.ss_flags & SS_ONSTACK) == 0 &&
- (psp->ps_sigonstack & sigmask(sig))) {
+ !sigonstack(tf->tf_r[31]) && (psp->ps_sigonstack & sigmask(sig)))
fp = (struct sigframe *)(p->p_sigstk.ss_sp +
p->p_sigstk.ss_size - fsize);
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
+ else
fp = (struct sigframe *)(tf->tf_r[31] - fsize);
/* make sure the frame is aligned on a 8 byte boundary */
@@ -124,13 +122,13 @@ sendsig(sig_t catcher, int sig, int mask, unsigned long code, int type,
if ((sigdebug & SDB_FOLLOW) ||
((sigdebug & SDB_KSTACK) && p->p_pid == sigpid))
printf("sendsig(%d): sig %d ssp %x usp %x scp %x\n",
- p->p_pid, sig, &oonstack, fp, &fp->sf_sc);
+ p->p_pid, sig, &sf, fp, &fp->sf_sc);
#endif
/*
* Build the signal context to be used by sigreturn.
*/
+ bzero(&sf, sizeof(sf));
sf.sf_scp = &fp->sf_sc;
- sf.sf_sc.sc_onstack = oonstack;
sf.sf_sc.sc_mask = mask;
if (psp->ps_siginfo & sigmask(sig)) {
@@ -222,10 +220,6 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
/*
* Restore the user supplied information
*/
- if (scp->sc_onstack & SS_ONSTACK)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = scp->sc_mask & ~sigcantmask;
/*
diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c
index b040a25ff50..0d29fc391ff 100644
--- a/sys/arch/macppc/macppc/machdep.c
+++ b/sys/arch/macppc/macppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.133 2012/10/08 21:47:48 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.134 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -558,23 +558,21 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
struct trapframe *tf;
struct sigframe *fp, frame;
struct sigacts *psp = p->p_sigacts;
- int oldonstack;
+ bzero(&frame, sizeof(frame));
frame.sf_signum = sig;
tf = trapframe(p);
- oldonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
/*
* Allocate stack space for signal handler.
*/
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0
- && !oldonstack
- && (psp->ps_sigonstack & sigmask(sig))) {
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(tf->fixreg[1]) &&
+ (psp->ps_sigonstack & sigmask(sig)))
fp = (struct sigframe *)(p->p_sigstk.ss_sp
+ p->p_sigstk.ss_size);
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
+ else
fp = (struct sigframe *)tf->fixreg[1];
fp = (struct sigframe *)((int)(fp - 1) & ~0xf);
@@ -582,7 +580,6 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
/*
* Generate signal context for SYS_sigreturn.
*/
- frame.sf_sc.sc_onstack = oldonstack;
frame.sf_sc.sc_mask = mask;
frame.sf_sip = NULL;
bcopy(tf, &frame.sf_sc.sc_frame, sizeof *tf);
@@ -628,10 +625,6 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
if ((sc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
return EINVAL;
bcopy(&sc.sc_frame, tf, sizeof *tf);
- if (sc.sc_onstack & 1)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = sc.sc_mask & ~sigcantmask;
return EJUSTRETURN;
}
diff --git a/sys/arch/mips64/include/cpu.h b/sys/arch/mips64/include/cpu.h
index f562c1f8091..daa8d49dd63 100644
--- a/sys/arch/mips64/include/cpu.h
+++ b/sys/arch/mips64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.90 2012/10/03 11:18:23 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.91 2012/12/02 07:03:31 guenther Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -268,6 +268,7 @@ void cp0_calibrate(struct cpu_info *);
* This is used during profiling to integrate system time.
*/
#define PROC_PC(p) ((p)->p_md.md_regs->pc)
+#define PROC_STACK(p) ((p)->p_md.md_regs->sp)
/*
* Preempt the current process if in interrupt from user mode,
diff --git a/sys/arch/mips64/include/signal.h b/sys/arch/mips64/include/signal.h
index 8061057125a..3dc7627d660 100644
--- a/sys/arch/mips64/include/signal.h
+++ b/sys/arch/mips64/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.9 2011/03/23 16:54:36 pirofti Exp $ */
+/* $OpenBSD: signal.h,v 1.10 2012/12/02 07:03:31 guenther Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -56,7 +56,7 @@ typedef int sig_atomic_t;
* a non-standard exit is performed.
*/
struct sigcontext {
- long sc_onstack; /* sigstack state to restore */
+ long __sc_unused;
long sc_mask; /* signal mask to restore */
__register_t sc_pc; /* pc at time of signal */
__register_t sc_regs[32]; /* processor regs 0 to 31 */
diff --git a/sys/arch/mips64/mips64/sendsig.c b/sys/arch/mips64/mips64/sendsig.c
index 9bae0f3c79d..74c238e5e57 100644
--- a/sys/arch/mips64/mips64/sendsig.c
+++ b/sys/arch/mips64/mips64/sendsig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sendsig.c,v 1.19 2012/10/03 11:18:23 miod Exp $ */
+/* $OpenBSD: sendsig.c,v 1.20 2012/12/02 07:03:31 guenther Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
@@ -112,11 +112,11 @@ sendsig(catcher, sig, mask, code, type, val)
struct sigframe *fp;
struct trap_frame *regs;
struct sigacts *psp = p->p_sigacts;
- int oonstack, fsize;
+ int fsize;
struct sigcontext ksc;
regs = p->p_md.md_regs;
- oonstack = p->p_sigstk.ss_flags & SA_ONSTACK;
+
/*
* Allocate and validate space for the signal handler
* context. Note that if the stack is in data space, the
@@ -128,12 +128,10 @@ sendsig(catcher, sig, mask, code, type, val)
if (!(psp->ps_siginfo & sigmask(sig)))
fsize -= sizeof(siginfo_t);
if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
- (p->p_sigstk.ss_flags & SA_ONSTACK) == 0 &&
- (psp->ps_sigonstack & sigmask(sig))) {
+ !sigonstack(regs->sp) && (psp->ps_sigonstack & sigmask(sig)))
fp = (struct sigframe *)(p->p_sigstk.ss_sp +
p->p_sigstk.ss_size - fsize);
- p->p_sigstk.ss_flags |= SA_ONSTACK;
- } else
+ else
fp = (struct sigframe *)(regs->sp - fsize);
if ((vaddr_t)fp <= USRSTACK - ptoa(p->p_vmspace->vm_ssize))
(void)uvm_grow(p, (vaddr_t)fp);
@@ -141,12 +139,12 @@ sendsig(catcher, sig, mask, code, type, val)
if ((sigdebug & SDB_FOLLOW) ||
((sigdebug & SDB_KSTACK) && (p->p_pid == sigpid)))
printf("sendsig(%d): sig %d ssp %x usp %x scp %x\n",
- p->p_pid, sig, &oonstack, fp, &fp->sf_sc);
+ p->p_pid, sig, &ksc, fp, &fp->sf_sc);
#endif
/*
* Build the signal context to be used by sigreturn.
*/
- ksc.sc_onstack = oonstack;
+ bzero(&ksc, sizeof(ksc));
ksc.sc_mask = mask;
ksc.sc_pc = regs->pc;
ksc.mullo = regs->mullo;
@@ -255,10 +253,6 @@ sys_sigreturn(p, v, retval)
/*
* Restore the user supplied information
*/
- if (scp->sc_onstack & SA_ONSTACK)
- p->p_sigstk.ss_flags |= SA_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SA_ONSTACK;
p->p_sigmask = scp->sc_mask &~ sigcantmask;
regs->pc = scp->sc_pc;
regs->mullo = scp->mullo;
diff --git a/sys/arch/powerpc/include/cpu.h b/sys/arch/powerpc/include/cpu.h
index fe996e04a5e..e8f521b988a 100644
--- a/sys/arch/powerpc/include/cpu.h
+++ b/sys/arch/powerpc/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.46 2010/09/28 20:27:55 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.47 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.1 1996/09/30 16:34:21 ws Exp $ */
/*
@@ -150,6 +150,7 @@ extern struct cpu_info cpu_info[PPC_MAXPROCS];
* This is used during profiling to integrate system time.
*/
#define PROC_PC(p) (trapframe(p)->srr0)
+#define PROC_STACK(p) (trapframe(p)->fixreg[1])
void delay(unsigned);
#define DELAY(n) delay(n)
diff --git a/sys/arch/powerpc/include/signal.h b/sys/arch/powerpc/include/signal.h
index 95340ba7602..7258c5a90df 100644
--- a/sys/arch/powerpc/include/signal.h
+++ b/sys/arch/powerpc/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.7 2006/01/08 14:20:17 millert Exp $ */
+/* $OpenBSD: signal.h,v 1.8 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: signal.h,v 1.1 1996/09/30 16:34:34 ws Exp $ */
/*
@@ -64,7 +64,7 @@ struct trapframe {
};
struct sigcontext {
- int sc_onstack; /* saved onstack flag */
+ int __sc_unused;
int sc_mask; /* saved signal mask */
struct trapframe sc_frame; /* saved registers */
};
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;
diff --git a/sys/arch/socppc/socppc/machdep.c b/sys/arch/socppc/socppc/machdep.c
index ca1a710dae5..292e1fb222d 100644
--- a/sys/arch/socppc/socppc/machdep.c
+++ b/sys/arch/socppc/socppc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.35 2012/10/08 21:47:50 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.36 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -881,23 +881,21 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
struct trapframe *tf;
struct sigframe *fp, frame;
struct sigacts *psp = p->p_sigacts;
- int oldonstack;
+ bzero(&frame, sizeof(frame));
frame.sf_signum = sig;
tf = trapframe(p);
- oldonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
/*
* Allocate stack space for signal handler.
*/
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0
- && !oldonstack
- && (psp->ps_sigonstack & sigmask(sig))) {
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(tf->fixreg[1]) &&
+ (psp->ps_sigonstack & sigmask(sig)))
fp = (struct sigframe *)(p->p_sigstk.ss_sp
+ p->p_sigstk.ss_size);
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
+ else
fp = (struct sigframe *)tf->fixreg[1];
fp = (struct sigframe *)((int)(fp - 1) & ~0xf);
@@ -905,7 +903,6 @@ sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
/*
* Generate signal context for SYS_sigreturn.
*/
- frame.sf_sc.sc_onstack = oldonstack;
frame.sf_sc.sc_mask = mask;
frame.sf_sip = NULL;
bcopy(tf, &frame.sf_sc.sc_frame, sizeof *tf);
@@ -949,10 +946,6 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
if ((sc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
return EINVAL;
bcopy(&sc.sc_frame, tf, sizeof *tf);
- if (sc.sc_onstack & 1)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = sc.sc_mask & ~sigcantmask;
return EJUSTRETURN;
}
diff --git a/sys/arch/solbourne/solbourne/machdep.c b/sys/arch/solbourne/solbourne/machdep.c
index 642df6c28df..6f96ce1a7e4 100644
--- a/sys/arch/solbourne/solbourne/machdep.c
+++ b/sys/arch/solbourne/solbourne/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.24 2012/10/08 21:47:50 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.25 2012/12/02 07:03:31 guenther Exp $ */
/* OpenBSD: machdep.c,v 1.105 2005/04/11 15:13:01 deraadt Exp */
/*
@@ -364,22 +364,21 @@ sendsig(catcher, sig, mask, code, type, val)
struct sigacts *psp = p->p_sigacts;
struct sigframe *fp;
struct trapframe *tf;
- int caddr, oonstack, oldsp, newsp;
+ int caddr, oldsp, newsp;
struct sigframe sf;
tf = p->p_md.md_tf;
oldsp = tf->tf_out[6];
- oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
+
/*
* Compute new user stack addresses, subtract off
* one signal frame, and align.
*/
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack &&
- (psp->ps_sigonstack & sigmask(sig))) {
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(oldsp) && (psp->ps_sigonstack & sigmask(sig)))
fp = (struct sigframe *)(p->p_sigstk.ss_sp +
p->p_sigstk.ss_size);
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
+ else
fp = (struct sigframe *)oldsp;
fp = (struct sigframe *)((int)(fp - 1) & ~7);
@@ -393,13 +392,13 @@ sendsig(catcher, sig, mask, code, type, val)
* and then copy it out. We probably ought to just build it
* directly in user space....
*/
+ bzero(&sf, sizeof(sf));
sf.sf_signo = sig;
sf.sf_sip = NULL;
/*
* Build the signal context to be used by sigreturn.
*/
- sf.sf_sc.sc_onstack = oonstack;
sf.sf_sc.sc_mask = mask;
sf.sf_sc.sc_sp = oldsp;
sf.sf_sc.sc_pc = tf->tf_pc;
@@ -508,10 +507,6 @@ sys_sigreturn(p, v, retval)
tf->tf_global[1] = ksc.sc_g1;
tf->tf_out[0] = ksc.sc_o0;
tf->tf_out[6] = ksc.sc_sp;
- if (ksc.sc_onstack & 1)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = ksc.sc_mask & ~sigcantmask;
return (EJUSTRETURN);
}
diff --git a/sys/arch/sparc/include/cpu.h b/sys/arch/sparc/include/cpu.h
index 1ed4a47830a..37f65648cdf 100644
--- a/sys/arch/sparc/include/cpu.h
+++ b/sys/arch/sparc/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.34 2011/03/23 16:54:37 pirofti Exp $ */
+/* $OpenBSD: cpu.h,v 1.35 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.24 1997/03/15 22:25:15 pk Exp $ */
/*
@@ -106,6 +106,7 @@ extern int want_ast;
* This is used during profiling to integrate system time.
*/
#define PROC_PC(p) ((p)->p_md.md_tf->tf_pc)
+#define PROC_STACK(p) ((p)->p_md.md_tf->tf_out[6])
/*
* Give a profiling tick to the current process when the user profiling
diff --git a/sys/arch/sparc/include/signal.h b/sys/arch/sparc/include/signal.h
index 2193b1cd601..046c44d59dd 100644
--- a/sys/arch/sparc/include/signal.h
+++ b/sys/arch/sparc/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.9 2011/03/23 16:54:37 pirofti Exp $ */
+/* $OpenBSD: signal.h,v 1.10 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: signal.h,v 1.4 1996/02/01 22:32:35 mycroft Exp $ */
/*
@@ -56,11 +56,9 @@ typedef int sig_atomic_t;
* execution of the signal handler. It is also made available
* to the handler to allow it to restore state properly if
* a non-standard exit is performed.
- *
- * All machines must have an sc_onstack and sc_mask.
*/
struct sigcontext {
- int sc_onstack; /* sigstack state to restore */
+ int __sc_unused;
int sc_mask; /* signal mask to restore */
/* begin machine dependent portion */
int sc_sp; /* %sp to restore */
diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c
index 1c4c21164db..69849a338b2 100644
--- a/sys/arch/sparc/sparc/machdep.c
+++ b/sys/arch/sparc/sparc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.143 2012/11/05 13:20:16 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.144 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */
/*
@@ -373,22 +373,21 @@ sendsig(catcher, sig, mask, code, type, val)
struct sigacts *psp = p->p_sigacts;
struct sigframe *fp;
struct trapframe *tf;
- int caddr, oonstack, oldsp, newsp;
+ int caddr, oldsp, newsp;
struct sigframe sf;
tf = p->p_md.md_tf;
oldsp = tf->tf_out[6];
- oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
+
/*
* Compute new user stack addresses, subtract off
* one signal frame, and align.
*/
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !oonstack &&
- (psp->ps_sigonstack & sigmask(sig))) {
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(oldsp) && (psp->ps_sigonstack & sigmask(sig)))
fp = (struct sigframe *)(p->p_sigstk.ss_sp +
p->p_sigstk.ss_size);
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
+ else
fp = (struct sigframe *)oldsp;
fp = (struct sigframe *)((int)(fp - 1) & ~7);
@@ -402,13 +401,13 @@ sendsig(catcher, sig, mask, code, type, val)
* and then copy it out. We probably ought to just build it
* directly in user space....
*/
+ bzero(&sf, sizeof(sf));
sf.sf_signo = sig;
sf.sf_sip = NULL;
/*
* Build the signal context to be used by sigreturn.
*/
- sf.sf_sc.sc_onstack = oonstack;
sf.sf_sc.sc_mask = mask;
sf.sf_sc.sc_sp = oldsp;
sf.sf_sc.sc_pc = tf->tf_pc;
@@ -517,10 +516,6 @@ sys_sigreturn(p, v, retval)
tf->tf_global[1] = ksc.sc_g1;
tf->tf_out[0] = ksc.sc_o0;
tf->tf_out[6] = ksc.sc_sp;
- if (ksc.sc_onstack & 1)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
p->p_sigmask = ksc.sc_mask & ~sigcantmask;
return (EJUSTRETURN);
}
diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h
index 0ef44b2932f..0ca59053ace 100644
--- a/sys/arch/sparc64/include/cpu.h
+++ b/sys/arch/sparc64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.78 2011/07/06 22:26:44 kettenis Exp $ */
+/* $OpenBSD: cpu.h,v 1.79 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */
/*
@@ -238,6 +238,7 @@ extern void need_resched(struct cpu_info *);
* This is used during profiling to integrate system time.
*/
#define PROC_PC(p) ((p)->p_md.md_tf->tf_pc)
+#define PROC_STACK(p) ((p)->p_md.md_tf->tf_out[6] + (2048-1)) /* BIAS */
/*
* Give a profiling tick to the current process when the user profiling
diff --git a/sys/arch/sparc64/include/signal.h b/sys/arch/sparc64/include/signal.h
index 2a67ba7cd71..0333dc1b733 100644
--- a/sys/arch/sparc64/include/signal.h
+++ b/sys/arch/sparc64/include/signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.h,v 1.9 2011/03/23 16:54:37 pirofti Exp $ */
+/* $OpenBSD: signal.h,v 1.10 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: signal.h,v 1.10 2001/05/09 19:50:49 kleink Exp $ */
/*
@@ -56,11 +56,9 @@ typedef int sig_atomic_t;
* execution of the signal handler. It is also made available
* to the handler to allow it to restore state properly if
* a non-standard exit is performed.
- *
- * All machines must have an sc_onstack and sc_mask.
*/
struct sigcontext {
- int sc_onstack; /* sigstack state to restore */
+ int __sc_unused;
int __sc_mask13; /* signal mask to restore (old style) */
/* begin machine dependent portion */
long sc_sp; /* %sp to restore */
diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c
index db837831074..cab22271624 100644
--- a/sys/arch/sparc64/sparc64/machdep.c
+++ b/sys/arch/sparc64/sparc64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.142 2012/10/22 17:27:19 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.143 2012/12/02 07:03:31 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */
/*-
@@ -430,26 +430,21 @@ sendsig(catcher, sig, mask, code, type, val)
struct sigacts *psp = p->p_sigacts;
struct sigframe *fp;
struct trapframe64 *tf;
- vaddr_t addr;
- struct rwindow *oldsp, *newsp;
+ vaddr_t addr, oldsp, newsp;
struct sigframe sf;
- int onstack;
tf = p->p_md.md_tf;
- oldsp = (struct rwindow *)(u_long)(tf->tf_out[6] + STACK_OFFSET);
+ oldsp = tf->tf_out[6] + STACK_OFFSET;
/*
* Compute new user stack addresses, subtract off
* one signal frame, and align.
*/
- onstack = p->p_sigstk.ss_flags & SS_ONSTACK;
-
- if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && !onstack &&
- (psp->ps_sigonstack & sigmask(sig))) {
+ if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 &&
+ !sigonstack(oldsp) && (psp->ps_sigonstack & sigmask(sig)))
fp = (struct sigframe *)((caddr_t)p->p_sigstk.ss_sp +
p->p_sigstk.ss_size);
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else
+ else
fp = (struct sigframe *)oldsp;
/* Allocate an aligned sigframe */
fp = (struct sigframe *)((long)(fp - 1) & ~0x0f);
@@ -459,13 +454,13 @@ sendsig(catcher, sig, mask, code, type, val)
* and then copy it out. We probably ought to just build it
* directly in user space....
*/
+ bzero(&sf, sizeof(sf));
sf.sf_signo = sig;
sf.sf_sip = NULL;
/*
* Build the signal context to be used by sigreturn.
*/
- sf.sf_sc.sc_onstack = onstack;
sf.sf_sc.sc_mask = mask;
/* Save register context. */
sf.sf_sc.sc_sp = (long)tf->tf_out[6];
@@ -489,7 +484,7 @@ sendsig(catcher, sig, mask, code, type, val)
* joins seamlessly with the frame it was in when the signal occurred,
* so that the debugger and _longjmp code can back up through it.
*/
- newsp = (struct rwindow *)((vaddr_t)fp - sizeof(struct rwindow));
+ newsp = (vaddr_t)fp - sizeof(struct rwindow);
write_user_windows();
/* XXX do not copyout siginfo if not needed */
@@ -522,7 +517,7 @@ sendsig(catcher, sig, mask, code, type, val)
tf->tf_global[1] = (vaddr_t)catcher;
tf->tf_pc = addr;
tf->tf_npc = addr + 4;
- tf->tf_out[6] = (vaddr_t)newsp - STACK_OFFSET;
+ tf->tf_out[6] = newsp - STACK_OFFSET;
}
/*
@@ -592,12 +587,6 @@ sys_sigreturn(p, v, retval)
tf->tf_out[0] = (u_int64_t)scp->sc_o0;
tf->tf_out[6] = (u_int64_t)scp->sc_sp;
- /* Restore signal stack. */
- if (sc.sc_onstack & SS_ONSTACK)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
-
/* Restore signal mask. */
p->p_sigmask = scp->sc_mask & ~sigcantmask;
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;