Make signal delivery work again.
This commit is contained in:
parent
1a5b3601cb
commit
c7d391b23c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore.s,v 1.8 1998/09/09 00:07:50 thorpej Exp $ */
|
||||
/* $NetBSD: locore.s,v 1.9 1998/09/13 09:15:51 thorpej Exp $ */
|
||||
/* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */
|
||||
|
||||
/*
|
||||
@ -1304,7 +1304,7 @@ _C_LABEL(sigcode):
|
||||
addi 1,1,-16 /* reserved space for callee */
|
||||
blrl
|
||||
addi 3,1,16+8 /* compute &sf_sc */
|
||||
li 0,SYS_sigreturn
|
||||
li 0,SYS___sigreturn14
|
||||
sc /* sigreturn(scp) */
|
||||
li 0,SYS_exit
|
||||
sc /* exit(errno) */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.22 1998/08/24 01:40:27 sakamoto Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.23 1998/09/13 09:15:51 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -31,6 +31,7 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "opt_compat_netbsd.h"
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ccitt.h"
|
||||
@ -831,44 +832,65 @@ setregs(p, pack, stack)
|
||||
void
|
||||
sendsig(catcher, sig, mask, code)
|
||||
sig_t catcher;
|
||||
int sig, mask;
|
||||
int sig;
|
||||
sigset_t *mask;
|
||||
u_long code;
|
||||
{
|
||||
struct proc *p = curproc;
|
||||
struct trapframe *tf;
|
||||
struct sigframe *fp, frame;
|
||||
struct sigacts *psp = p->p_sigacts;
|
||||
int oldonstack;
|
||||
|
||||
frame.sf_signum = sig;
|
||||
int onstack;
|
||||
|
||||
tf = trapframe(p);
|
||||
oldonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
|
||||
|
||||
/*
|
||||
* Allocate stack space for signal handler.
|
||||
*/
|
||||
if ((psp->ps_flags & SAS_ALTSTACK)
|
||||
&& !oldonstack
|
||||
&& (psp->ps_sigonstack & sigmask(sig))) {
|
||||
fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp
|
||||
+ psp->ps_sigstk.ss_size);
|
||||
psp->ps_sigstk.ss_flags |= SS_ONSTACK;
|
||||
} else
|
||||
/* Do we need to jump onto the signal stack? */
|
||||
onstack =
|
||||
(psp->ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
|
||||
(psp->ps_sigact[sig].sa_flags & SA_ONSTACK) != 0;
|
||||
|
||||
/* Allocate space for the signal handler context. */
|
||||
if (onstack)
|
||||
fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp +
|
||||
psp->ps_sigstk.ss_size);
|
||||
else
|
||||
fp = (struct sigframe *)tf->fixreg[1];
|
||||
fp = (struct sigframe *)((int)(fp - 1) & ~0xf);
|
||||
|
||||
/* Build stack frame for signal trampoline. */
|
||||
frame.sf_signum = sig;
|
||||
frame.sf_code = code;
|
||||
|
||||
/*
|
||||
* Generate signal context for SYS_sigreturn.
|
||||
*/
|
||||
frame.sf_sc.sc_onstack = oldonstack;
|
||||
frame.sf_sc.sc_mask = mask;
|
||||
/* Save register context. */
|
||||
bcopy(tf, &frame.sf_sc.sc_frame, sizeof *tf);
|
||||
if (copyout(&frame, fp, sizeof frame) != 0)
|
||||
sigexit(p, SIGILL);
|
||||
|
||||
/* Save signal stack. */
|
||||
frame.sf_sc.sc_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
|
||||
|
||||
/* Save signal mask. */
|
||||
frame.sf_sc.sc_mask = *mask;
|
||||
|
||||
#ifdef COMPAT_13
|
||||
/*
|
||||
* XXX We always have to save an old style signal mask because
|
||||
* XXX we might be delivering a signal to a process which will
|
||||
* XXX escape from the signal in a non-standard way and invoke
|
||||
* XXX sigreturn() directly.
|
||||
*/
|
||||
native_sigset_to_sigset13(mask, &frame.sf_sc.__sc_mask13);
|
||||
#endif
|
||||
|
||||
if (copyout(&frame, fp, sizeof frame) != 0) {
|
||||
/*
|
||||
* Process has trashed its stack; give it an illegal
|
||||
* instructoin to halt it in its tracks.
|
||||
*/
|
||||
sigexit(p, SIGILL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Build context to run handler in.
|
||||
*/
|
||||
tf->fixreg[1] = (int)fp;
|
||||
tf->lr = (int)catcher;
|
||||
tf->fixreg[3] = (int)sig;
|
||||
@ -882,30 +904,42 @@ sendsig(catcher, sig, mask, code)
|
||||
* System call to cleanup state after a signal handler returns.
|
||||
*/
|
||||
int
|
||||
sys_sigreturn(p, v, retval)
|
||||
sys___sigreturn14(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct sys_sigreturn_args /* {
|
||||
struct sys___sigreturn14_args /* {
|
||||
syscallarg(struct sigcontext *) sigcntxp;
|
||||
} */ *uap = v;
|
||||
struct sigcontext sc;
|
||||
struct trapframe *tf;
|
||||
int error;
|
||||
|
||||
if (error = copyin(SCARG(uap, sigcntxp), &sc, sizeof sc))
|
||||
return error;
|
||||
/*
|
||||
* The trampoline hands us the context.
|
||||
* It is unsafe to keep track of it ourselves, in the event that a
|
||||
* program jumps out of a signal hander.
|
||||
*/
|
||||
if ((error = copyin(SCARG(uap, sigcntxp), &sc, sizeof sc)) != 0)
|
||||
return (error);
|
||||
|
||||
/* Restore the register context. */
|
||||
tf = trapframe(p);
|
||||
if ((sc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
|
||||
return EINVAL;
|
||||
return (EINVAL);
|
||||
bcopy(&sc.sc_frame, tf, sizeof *tf);
|
||||
if (sc.sc_onstack & 1)
|
||||
|
||||
/* Restore signal stack. */
|
||||
if (sc.sc_onstack & SS_ONSTACK)
|
||||
p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
|
||||
else
|
||||
p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
|
||||
p->p_sigmask = sc.sc_mask & ~sigcantmask;
|
||||
return EJUSTRETURN;
|
||||
|
||||
/* Restore signal mask. */
|
||||
(void) sigprocmask1(p, SIG_SETMASK, &sc.sc_mask, 0);
|
||||
|
||||
return (EJUSTRETURN);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore.S,v 1.6 1998/09/09 00:07:53 thorpej Exp $ */
|
||||
/* $NetBSD: locore.S,v 1.7 1998/09/13 09:15:51 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -1392,7 +1392,7 @@ _C_LABEL(sigcode):
|
||||
addi 1,1,-16 /* reserved space for callee */
|
||||
blrl
|
||||
addi 3,1,16+8 /* compute &sf_sc */
|
||||
li 0,SYS_sigreturn
|
||||
li 0,SYS___sigreturn14
|
||||
sc /* sigreturn(scp) */
|
||||
li 0,SYS_exit
|
||||
sc /* exit(errno) */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.16 1998/08/21 16:13:29 tsubai Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.17 1998/09/13 09:15:51 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -31,6 +31,7 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "opt_compat_netbsd.h"
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_inet.h"
|
||||
#include "opt_atalk.h"
|
||||
@ -714,44 +715,65 @@ setregs(p, pack, stack)
|
||||
void
|
||||
sendsig(catcher, sig, mask, code)
|
||||
sig_t catcher;
|
||||
int sig, mask;
|
||||
int sig;
|
||||
sigset_t *mask;
|
||||
u_long code;
|
||||
{
|
||||
struct proc *p = curproc;
|
||||
struct trapframe *tf;
|
||||
struct sigframe *fp, frame;
|
||||
struct sigacts *psp = p->p_sigacts;
|
||||
int oldonstack;
|
||||
|
||||
frame.sf_signum = sig;
|
||||
int onstack;
|
||||
|
||||
tf = trapframe(p);
|
||||
oldonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
|
||||
|
||||
/*
|
||||
* Allocate stack space for signal handler.
|
||||
*/
|
||||
if ((psp->ps_flags & SAS_ALTSTACK)
|
||||
&& !oldonstack
|
||||
&& (psp->ps_sigonstack & sigmask(sig))) {
|
||||
fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp
|
||||
+ psp->ps_sigstk.ss_size);
|
||||
psp->ps_sigstk.ss_flags |= SS_ONSTACK;
|
||||
} else
|
||||
/* Do we need to jump onto the signal stack? */
|
||||
onstack =
|
||||
(psp->ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
|
||||
(psp->ps_sigact[sig].sa_flags & SA_ONSTACK) != 0;
|
||||
|
||||
/* Allocate space for the signal handler context. */
|
||||
if (onstack)
|
||||
fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp +
|
||||
psp->ps_sigstk.ss_size);
|
||||
else
|
||||
fp = (struct sigframe *)tf->fixreg[1];
|
||||
fp = (struct sigframe *)((int)(fp - 1) & ~0xf);
|
||||
|
||||
/* Build stack frame for signal trampoline. */
|
||||
frame.sf_signum = sig;
|
||||
frame.sf_code = code;
|
||||
|
||||
/*
|
||||
* Generate signal context for SYS_sigreturn.
|
||||
*/
|
||||
frame.sf_sc.sc_onstack = oldonstack;
|
||||
frame.sf_sc.sc_mask = mask;
|
||||
/* Save register context. */
|
||||
bcopy(tf, &frame.sf_sc.sc_frame, sizeof *tf);
|
||||
if (copyout(&frame, fp, sizeof frame) != 0)
|
||||
sigexit(p, SIGILL);
|
||||
|
||||
/* Save signal stack. */
|
||||
frame.sf_sc.sc_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
|
||||
|
||||
/* Save signal mask. */
|
||||
frame.sf_sc.sc_mask = *mask;
|
||||
|
||||
#ifdef COMPAT_13
|
||||
/*
|
||||
* XXX We always have to save an old style signal mask because
|
||||
* XXX we might be delivering a signal to a process which will
|
||||
* XXX escape from the signal in a non-standard way and invoke
|
||||
* XXX sigreturn() directly.
|
||||
*/
|
||||
native_sigset_to_sigset13(mask, &frame.sf_sc.__sc_mask13);
|
||||
#endif
|
||||
|
||||
if (copyout(&frame, fp, sizeof frame) != 0) {
|
||||
/*
|
||||
* Process has trashed its stack; give it an illegal
|
||||
* instructoin to halt it in its tracks.
|
||||
*/
|
||||
sigexit(p, SIGILL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Build context to run handler in.
|
||||
*/
|
||||
tf->fixreg[1] = (int)fp;
|
||||
tf->lr = (int)catcher;
|
||||
tf->fixreg[3] = (int)sig;
|
||||
@ -765,30 +787,42 @@ sendsig(catcher, sig, mask, code)
|
||||
* System call to cleanup state after a signal handler returns.
|
||||
*/
|
||||
int
|
||||
sys_sigreturn(p, v, retval)
|
||||
sys___sigreturn14(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct sys_sigreturn_args /* {
|
||||
struct sys___sigreturn14_args /* {
|
||||
syscallarg(struct sigcontext *) sigcntxp;
|
||||
} */ *uap = v;
|
||||
struct sigcontext sc;
|
||||
struct trapframe *tf;
|
||||
int error;
|
||||
|
||||
if (error = copyin(SCARG(uap, sigcntxp), &sc, sizeof sc))
|
||||
return error;
|
||||
/*
|
||||
* The trampoline hands us the context.
|
||||
* It is unsafe to keep track of it ourselves, in the event that a
|
||||
* program jumps out of a signal hander.
|
||||
*/
|
||||
if ((error = copyin(SCARG(uap, sigcntxp), &sc, sizeof sc)) != 0)
|
||||
return (error);
|
||||
|
||||
/* Restore the register context. */
|
||||
tf = trapframe(p);
|
||||
if ((sc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
|
||||
return EINVAL;
|
||||
return (EINVAL);
|
||||
bcopy(&sc.sc_frame, tf, sizeof *tf);
|
||||
if (sc.sc_onstack & 1)
|
||||
|
||||
/* Restore signal stack. */
|
||||
if (sc.sc_onstack & SS_ONSTACK)
|
||||
p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
|
||||
else
|
||||
p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
|
||||
p->p_sigmask = sc.sc_mask & ~sigcantmask;
|
||||
return EJUSTRETURN;
|
||||
|
||||
/* Restore signal mask. */
|
||||
(void) sigprocmask1(p, SIG_SETMASK, &sc.sc_mask, 0);
|
||||
|
||||
return (EJUSTRETURN);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore.S,v 1.9 1998/09/09 00:07:54 thorpej Exp $ */
|
||||
/* $NetBSD: locore.S,v 1.10 1998/09/13 09:15:51 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -1378,7 +1378,7 @@ _C_LABEL(sigcode):
|
||||
addi 1,1,-16 /* reserved space for callee */
|
||||
blrl
|
||||
addi 3,1,16+8 /* compute &sf_sc */
|
||||
li 0,SYS_sigreturn
|
||||
li 0,SYS___sigreturn14
|
||||
sc /* sigreturn(scp) */
|
||||
li 0,SYS_exit
|
||||
sc /* exit(errno) */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.26 1998/08/26 04:54:18 sakamoto Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.27 1998/09/13 09:15:52 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -31,6 +31,7 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "opt_compat_netbsd.h"
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ccitt.h"
|
||||
@ -666,44 +667,65 @@ setregs(p, pack, stack)
|
||||
void
|
||||
sendsig(catcher, sig, mask, code)
|
||||
sig_t catcher;
|
||||
int sig, mask;
|
||||
int sig;
|
||||
sigset_t *mask;
|
||||
u_long code;
|
||||
{
|
||||
struct proc *p = curproc;
|
||||
struct trapframe *tf;
|
||||
struct sigframe *fp, frame;
|
||||
struct sigacts *psp = p->p_sigacts;
|
||||
int oldonstack;
|
||||
|
||||
frame.sf_signum = sig;
|
||||
int onstack;
|
||||
|
||||
tf = trapframe(p);
|
||||
oldonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
|
||||
|
||||
/*
|
||||
* Allocate stack space for signal handler.
|
||||
*/
|
||||
if ((psp->ps_flags & SAS_ALTSTACK)
|
||||
&& !oldonstack
|
||||
&& (psp->ps_sigonstack & sigmask(sig))) {
|
||||
fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp
|
||||
+ psp->ps_sigstk.ss_size);
|
||||
psp->ps_sigstk.ss_flags |= SS_ONSTACK;
|
||||
} else
|
||||
/* Do we need to jump onto the signal stack? */
|
||||
onstack =
|
||||
(psp->ps_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
|
||||
(psp->ps_sigact[sig].sa_flags & SA_ONSTACK) != 0;
|
||||
|
||||
/* Allocate space for the signal handler context. */
|
||||
if (onstack)
|
||||
fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp +
|
||||
psp->ps_sigstk.ss_size);
|
||||
else
|
||||
fp = (struct sigframe *)tf->fixreg[1];
|
||||
fp = (struct sigframe *)((int)(fp - 1) & ~0xf);
|
||||
|
||||
/* Build stack frame for signal trampoline. */
|
||||
frame.sf_signum = sig;
|
||||
frame.sf_code = code;
|
||||
|
||||
/*
|
||||
* Generate signal context for SYS_sigreturn.
|
||||
*/
|
||||
frame.sf_sc.sc_onstack = oldonstack;
|
||||
frame.sf_sc.sc_mask = mask;
|
||||
/* Save register context. */
|
||||
bcopy(tf, &frame.sf_sc.sc_frame, sizeof *tf);
|
||||
if (copyout(&frame, fp, sizeof frame) != 0)
|
||||
sigexit(p, SIGILL);
|
||||
|
||||
/* Save signal stack. */
|
||||
frame.sf_sc.sc_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
|
||||
|
||||
/* Save signal mask. */
|
||||
frame.sf_sc.sc_mask = *mask;
|
||||
|
||||
#ifdef COMPAT_13
|
||||
/*
|
||||
* XXX We always have to save an old style signal mask because
|
||||
* XXX we might be delivering a signal to a process which will
|
||||
* XXX escape from the signal in a non-standard way and invoke
|
||||
* XXX sigreturn() directly.
|
||||
*/
|
||||
native_sigset_to_sigset13(mask, &frame.sf_sc.__sc_mask13);
|
||||
#endif
|
||||
|
||||
if (copyout(&frame, fp, sizeof frame) != 0) {
|
||||
/*
|
||||
* Process has trashed its stack; give it an illegal
|
||||
* instructoin to halt it in its tracks.
|
||||
*/
|
||||
sigexit(p, SIGILL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Build context to run handler in.
|
||||
*/
|
||||
tf->fixreg[1] = (int)fp;
|
||||
tf->lr = (int)catcher;
|
||||
tf->fixreg[3] = (int)sig;
|
||||
@ -717,30 +739,42 @@ sendsig(catcher, sig, mask, code)
|
||||
* System call to cleanup state after a signal handler returns.
|
||||
*/
|
||||
int
|
||||
sys_sigreturn(p, v, retval)
|
||||
sys___sigreturn14(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct sys_sigreturn_args /* {
|
||||
struct sys___sigreturn14_args /* {
|
||||
syscallarg(struct sigcontext *) sigcntxp;
|
||||
} */ *uap = v;
|
||||
struct sigcontext sc;
|
||||
struct trapframe *tf;
|
||||
int error;
|
||||
|
||||
if (error = copyin(SCARG(uap, sigcntxp), &sc, sizeof sc))
|
||||
return error;
|
||||
/*
|
||||
* The trampoline hands us the context.
|
||||
* It is unsafe to keep track of it ourselves, in the event that a
|
||||
* program jumps out of a signal hander.
|
||||
*/
|
||||
if ((error = copyin(SCARG(uap, sigcntxp), &sc, sizeof sc)) != 0)
|
||||
return (error);
|
||||
|
||||
/* Restore the register context. */
|
||||
tf = trapframe(p);
|
||||
if ((sc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
|
||||
return EINVAL;
|
||||
return (EINVAL);
|
||||
bcopy(&sc.sc_frame, tf, sizeof *tf);
|
||||
if (sc.sc_onstack & 1)
|
||||
|
||||
/* Restore signal stack. */
|
||||
if (sc.sc_onstack & SS_ONSTACK)
|
||||
p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
|
||||
else
|
||||
p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
|
||||
p->p_sigmask = sc.sc_mask & ~sigcantmask;
|
||||
return EJUSTRETURN;
|
||||
|
||||
/* Restore signal mask. */
|
||||
(void) sigprocmask1(p, SIG_SETMASK, &sc.sc_mask, 0);
|
||||
|
||||
return (EJUSTRETURN);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: files.powerpc,v 1.8 1998/05/28 08:19:49 sakamoto Exp $
|
||||
# $Id: files.powerpc,v 1.9 1998/09/13 09:15:52 thorpej Exp $
|
||||
|
||||
file arch/powerpc/powerpc/Locore.c
|
||||
file arch/powerpc/powerpc/bcopy.c
|
||||
@ -24,3 +24,6 @@ file arch/powerpc/powerpc/db_memrw.c ddb
|
||||
file arch/powerpc/powerpc/db_disasm.c ddb
|
||||
file arch/powerpc/powerpc/db_interface.c ddb
|
||||
file arch/powerpc/powerpc/db_trace.c ddb
|
||||
|
||||
# Binary compatibility with previous NetBSD releases (COMPAT_XX)
|
||||
file arch/powerpc/powerpc/compat_13_machdep.c compat_13
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: signal.h,v 1.2 1998/05/25 20:59:03 kleink Exp $ */
|
||||
/* $NetBSD: signal.h,v 1.3 1998/09/13 09:15:52 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -39,10 +39,19 @@ typedef int sig_atomic_t;
|
||||
!defined(_XOPEN_SOURCE)
|
||||
#include <machine/frame.h>
|
||||
|
||||
#if defined(__LIBC12_SOURCE__) || defined(_KERNEL)
|
||||
struct sigcontext13 {
|
||||
int sc_onstack; /* saved onstack flag */
|
||||
sigset13_t sc_mask; /* saved signal mask (old style) */
|
||||
struct trapframe sc_frame; /* saved registers */
|
||||
};
|
||||
#endif /* __LIBC12_SOURCE__ || _KERNEL */
|
||||
|
||||
struct sigcontext {
|
||||
int sc_onstack; /* saved onstack flag */
|
||||
int sc_mask; /* saved signal mask */
|
||||
sigset13_t __sc_mask13; /* saved signal mask (old style) */
|
||||
struct trapframe sc_frame; /* saved registers */
|
||||
sigset_t sc_mask; /* saved signal mask (new style) */
|
||||
};
|
||||
|
||||
struct sigframe {
|
||||
|
83
sys/arch/powerpc/powerpc/compat_13_machdep.c
Normal file
83
sys/arch/powerpc/powerpc/compat_13_machdep.c
Normal file
@ -0,0 +1,83 @@
|
||||
/* $NetBSD: compat_13_machdep.c,v 1.1 1998/09/13 09:15:52 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
* Copyright (C) 1995, 1996 TooLs GmbH.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by TooLs GmbH.
|
||||
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/map.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
int
|
||||
compat_13_sys_sigreturn(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct compat_13_sys_sigreturn_args /* {
|
||||
syscallarg(struct sigcontext13 *) sigcntxp;
|
||||
} */ *uap = v;
|
||||
struct sigcontext13 sc;
|
||||
struct trapframe *tf;
|
||||
int error;
|
||||
sigset_t mask;
|
||||
|
||||
/*
|
||||
* The trampoline hands us the context.
|
||||
* It is unsafe to keep track of it ourselves, in the event that a
|
||||
* program jumps out of a signal hander.
|
||||
*/
|
||||
if ((error = copyin(SCARG(uap, sigcntxp), &sc, sizeof sc)) != 0)
|
||||
return (error);
|
||||
|
||||
/* Restore the register context. */
|
||||
tf = trapframe(p);
|
||||
if ((sc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
|
||||
return (EINVAL);
|
||||
bcopy(&sc.sc_frame, tf, sizeof *tf);
|
||||
|
||||
/* Restore signal stack. */
|
||||
if (sc.sc_onstack & SS_ONSTACK)
|
||||
p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
|
||||
else
|
||||
p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
|
||||
|
||||
/* Restore signal mask. */
|
||||
native_sigset13_to_sigset(&sc.sc_mask, &mask);
|
||||
(void) sigprocmask1(p, SIG_SETMASK, &mask, 0);
|
||||
|
||||
return (EJUSTRETURN);
|
||||
}
|
Loading…
Reference in New Issue
Block a user