Update these for signal handling changes.

XXX Not tested yet.
This commit is contained in:
mycroft 1998-09-13 12:13:49 +00:00
parent 7b15b3b56d
commit 4e4f120db9
5 changed files with 112 additions and 47 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: svr4_machdep.h,v 1.6 1998/09/13 11:34:04 pk Exp $ */
/* $NetBSD: svr4_machdep.h,v 1.7 1998/09/13 12:13:49 mycroft Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@ -107,8 +107,7 @@ typedef struct {
struct svr4_ucontext;
void svr4_getcontext __P((struct proc *, struct svr4_ucontext *,
sigset_t *));
void svr4_getcontext __P((struct proc *, struct svr4_ucontext *, sigset_t *));
int svr4_setcontext __P((struct proc *p, struct svr4_ucontext *));
void svr4_sendsig __P((sig_t, int, sigset_t *, u_long));
int svr4_trap __P((int, struct proc *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.124 1998/09/07 22:56:46 pk Exp $ */
/* $NetBSD: machdep.c,v 1.125 1998/09/13 12:13:50 mycroft Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -573,31 +573,33 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
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 sigacts *psp = p->p_sigacts;
struct sigframe *fp;
struct trapframe *tf;
int addr, oonstack, oldsp, newsp;
int addr, onstack, oldsp, newsp;
struct sigframe sf;
extern char sigcode[], esigcode[];
#define szsigcode (esigcode - sigcode)
tf = p->p_md.md_tf;
oldsp = tf->tf_out[6];
oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
/* 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;
/*
* Compute new user stack addresses, subtract off
* one signal frame, and align.
*/
if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack &&
(psp->ps_sigonstack & sigmask(sig))) {
if (onstack)
fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp +
psp->ps_sigstk.ss_size);
psp->ps_sigstk.ss_flags |= SS_ONSTACK;
} else
else
fp = (struct sigframe *)oldsp;
fp = (struct sigframe *)((int)(fp - 1) & ~7);
@ -606,6 +608,7 @@ sendsig(catcher, sig, mask, code)
printf("sendsig: %s[%d] sig %d newusp %p scp %p\n",
p->p_comm, p->p_pid, sig, fp, &fp->sf_sc);
#endif
/*
* Now set up the signal frame. We build it in kernel space
* and then copy it out. We probably ought to just build it
@ -618,11 +621,7 @@ sendsig(catcher, sig, mask, code)
#endif
sf.sf_addr = 0; /* XXX */
/*
* Build the signal context to be used by sigreturn.
*/
sf.sf_sc.sc_onstack = oonstack;
sf.sf_sc.sc_mask = mask;
/* Save register context. */
sf.sf_sc.sc_sp = oldsp;
sf.sf_sc.sc_pc = tf->tf_pc;
sf.sf_sc.sc_npc = tf->tf_npc;
@ -630,6 +629,22 @@ sendsig(catcher, sig, mask, code)
sf.sf_sc.sc_g1 = tf->tf_global[1];
sf.sf_sc.sc_o0 = tf->tf_out[0];
/* 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
/*
* Put the stack in a consistent state before we whack away
* at it. Note that write_user_windows may just dump the
@ -654,11 +669,13 @@ sendsig(catcher, sig, mask, code)
sigexit(p, SIGILL);
/* NOTREACHED */
}
#ifdef DEBUG
if (sigdebug & SDB_FOLLOW)
printf("sendsig: %s[%d] sig %d scp %p\n",
p->p_comm, p->p_pid, sig, &fp->sf_sc);
#endif
/*
* Arrange to continue execution at the code copied out in exec().
* It needs the function to call in %g1, and a new stack pointer.
@ -669,12 +686,17 @@ sendsig(catcher, sig, mask, code)
} else
#endif
{
addr = (int)PS_STRINGS - szsigcode;
addr = (int)psp->ps_sigcode;
tf->tf_global[1] = (int)catcher;
}
tf->tf_pc = addr;
tf->tf_npc = addr + 4;
tf->tf_out[6] = newsp;
/* Remember that we're now on the signal stack. */
if (onstack)
psp->ps_sigstk.ss_flags |= SS_ONSTACK;
#ifdef DEBUG
if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
printf("sendsig: about to return to catcher\n");
@ -730,11 +752,16 @@ sys_sigreturn(p, v, retval)
tf->tf_global[1] = scp->sc_g1;
tf->tf_out[0] = scp->sc_o0;
tf->tf_out[6] = scp->sc_sp;
if (scp->sc_onstack & 1)
/* Restore signal stack. */
if (scp->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 = scp->sc_mask & ~sigcantmask;
/* Restore signal mask. */
(void) sigprocmask1(p, SIG_SETMASK, &scp->sc_mask, 0);
return (EJUSTRETURN);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: signal.h,v 1.1.1.1 1998/06/20 04:58:52 eeh Exp $ */
/* $NetBSD: signal.h,v 1.2 1998/09/13 12:13:50 mycroft Exp $ */
/*
* Copyright (c) 1992, 1993
@ -64,7 +64,8 @@ typedef int sig_atomic_t;
*
* All machines must have an sc_onstack and sc_mask.
*/
struct sigcontext {
#if defined(__LIBC12_SOURCE__) || (defined(_KERNEL) && defined(COMPAT_13))
struct sigcontext13 {
int sc_onstack; /* sigstack state to restore */
int sc_mask; /* signal mask to restore */
/* begin machine dependent portion */
@ -75,6 +76,19 @@ struct sigcontext {
int sc_g1; /* %g1 to restore */
int sc_o0; /* %o0 to restore */
};
#endif /* __LIBC12_SOURCE__ || (_KERNEL && COMPAT_13) */
struct sigcontext {
int sc_onstack; /* sigstack state to restore */
int __sc_mask13; /* signal mask to restore (old style) */
/* begin machine dependent portion */
int sc_sp; /* %sp to restore */
int sc_pc; /* pc to restore */
int sc_npc; /* npc to restore */
int sc_psr; /* psr to restore */
int sc_g1; /* %g1 to restore */
int sc_o0; /* %o0 to restore */
sigset_t sc_mask; /* signal mask to restore (new style) */
};
#else /* _LOCORE */
#define SC_SP_OFFSET 8
#define SC_PC_OFFSET 12

View File

@ -1,4 +1,4 @@
/* $NetBSD: svr4_machdep.h,v 1.2 1998/09/05 15:28:09 christos Exp $ */
/* $NetBSD: svr4_machdep.h,v 1.3 1998/09/13 12:13:50 mycroft Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@ -107,10 +107,9 @@ typedef struct {
struct svr4_ucontext;
void svr4_getcontext __P((struct proc *, struct svr4_ucontext *,
int, int));
void svr4_getcontext __P((struct proc *, struct svr4_ucontext *, sigset_t *));
int svr4_setcontext __P((struct proc *p, struct svr4_ucontext *));
void svr4_sendsig __P((sig_t, int, int, u_long));
void svr4_sendsig __P((sig_t, int, sigset_t *, u_long));
int svr4_trap __P((int, struct proc *));
#endif /* !_SPARC_SVR4_MACHDEP_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.12 1998/09/11 00:16:59 eeh Exp $ */
/* $NetBSD: machdep.c,v 1.13 1998/09/13 12:13:51 mycroft Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -586,18 +586,17 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
void
sendsig(catcher, sig, mask, code)
sig_t catcher;
int sig, mask;
int sig;
sigset_t *mask;
u_long code;
{
register struct proc *p = curproc;
register struct sigacts *psp = p->p_sigacts;
register struct sigframe *fp;
register struct trapframe *tf;
vaddr_t addr, oonstack;
vaddr_t addr, onstack;
struct rwindow *oldsp, *newsp, /* DEBUG */tmpwin;
struct sigframe sf;
extern char sigcode[], esigcode[];
#define szsigcode (esigcode - sigcode)
#if 0
/* Make sure our D$ is not polluted w/bad data */
@ -606,17 +605,20 @@ sendsig(catcher, sig, mask, code)
tf = p->p_md.md_tf;
oldsp = (struct rwindow *)(tf->tf_out[6] + STACK_OFFSET);
oonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
/* 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;
/*
* Compute new user stack addresses, subtract off
* one signal frame, and align.
*/
if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack &&
(psp->ps_sigonstack & sigmask(sig))) {
fp = (struct sigframe *)(psp->ps_sigstk.ss_sp +
psp->ps_sigstk.ss_size);
psp->ps_sigstk.ss_flags |= SS_ONSTACK;
} else
if (onstack)
fp = (struct sigframe *)((caddr_t)psp->ps_sigstk.ss_sp +
psp->ps_sigstk.ss_size);
else
fp = (struct sigframe *)oldsp;
fp = (struct sigframe *)((long)(fp - 1) & ~0x0f);
@ -628,6 +630,7 @@ sendsig(catcher, sig, mask, code)
if (sigdebug & SDB_DDB) Debugger();
}
#endif
/*
* Now set up the signal frame. We build it in kernel space
* and then copy it out. We probably ought to just build it
@ -642,11 +645,7 @@ sendsig(catcher, sig, mask, code)
sf.sf_addr = 0; /* XXX */
#endif
/*
* Build the signal context to be used by sigreturn.
*/
sf.sf_sc.sc_onstack = oonstack;
sf.sf_sc.sc_mask = mask;
/* Save register context. */
sf.sf_sc.sc_sp = (long)tf->tf_out[6];
sf.sf_sc.sc_pc = tf->tf_pc;
sf.sf_sc.sc_npc = tf->tf_npc;
@ -654,6 +653,22 @@ sendsig(catcher, sig, mask, code)
sf.sf_sc.sc_g1 = tf->tf_global[1];
sf.sf_sc.sc_o0 = tf->tf_out[0];
/* 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
/*
* Put the stack in a consistent state before we whack away
* at it. Note that write_user_windows may just dump the
@ -695,6 +710,7 @@ sendsig(catcher, sig, mask, code)
p->p_comm, p->p_pid, sig, &fp->sf_sc);
}
#endif
/*
* Arrange to continue execution at the code copied out in exec().
* It needs the function to call in %g1, and a new stack pointer.
@ -705,12 +721,17 @@ sendsig(catcher, sig, mask, code)
} else
#endif
{
addr = (vaddr_t)PS_STRINGS - szsigcode;
addr = (vaddr_t)psp->ps_sigcode;
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;
/* Remember that we're now on the signal stack. */
if (onstack)
psp->ps_sigstk.ss_flags |= SS_ONSTACK;
#ifdef DEBUG
if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) {
printf("sendsig: about to return to catcher %p thru %p\n",
@ -807,11 +828,16 @@ sys_sigreturn(p, v, retval)
if (sigdebug & SDB_DDB) Debugger();
}
#endif
if (sc.sc_onstack & 1)
/* Restore signal stack. */
if (scp->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;
/* Restore signal mask. */
(void) sigprocmask1(p, SIG_SETMASK, &scp->sc_mask, 0);
return (EJUSTRETURN);
}