Don't use trapframe in sigcontext. Instead define a new structure
utrapframe that fixed in size (and the same size as the trapframe in NetBSD 1.5). This preserves binary compatibility for those programs that dealt looked at sigcontexts.
This commit is contained in:
parent
a643d6a63e
commit
a25898cf6e
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: frame.h,v 1.13 2003/02/02 20:43:23 matt Exp $ */
|
||||
/* $NetBSD: frame.h,v 1.14 2003/02/03 21:48:01 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -45,6 +45,19 @@
|
||||
*
|
||||
* Change ordering to cluster together these register_t's. XXX
|
||||
*/
|
||||
struct utrapframe {
|
||||
register_t fixreg[32];
|
||||
register_t lr;
|
||||
int cr;
|
||||
int xer;
|
||||
register_t ctr;
|
||||
register_t srr0;
|
||||
register_t srr1;
|
||||
int vrsave;
|
||||
int mq;
|
||||
int spare;
|
||||
};
|
||||
|
||||
struct trapframe {
|
||||
register_t fixreg[32];
|
||||
register_t lr;
|
||||
@ -68,7 +81,7 @@ struct trapframe {
|
||||
|
||||
#if defined(_KERNEL) || defined(_LKM)
|
||||
#ifdef _LP64
|
||||
struct trapframe32 {
|
||||
struct utrapframe {
|
||||
register32_t fixreg[32];
|
||||
register32_t lr;
|
||||
int cr;
|
||||
@ -76,11 +89,9 @@ struct trapframe32 {
|
||||
register32_t ctr;
|
||||
register32_t srr0;
|
||||
register32_t srr1;
|
||||
register32_t dar; /* dar & dsisr are only filled on a DSI trap */
|
||||
int dsisr;
|
||||
int exc;
|
||||
uint32_t vrsave;
|
||||
uint32_t mq;
|
||||
int vrsave;
|
||||
int mq;
|
||||
int spare;
|
||||
};
|
||||
#endif
|
||||
#endif /* _KERNEL || _LKM */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: signal.h,v 1.9 2003/01/20 00:53:56 matt Exp $ */
|
||||
/* $NetBSD: signal.h,v 1.10 2003/02/03 21:48:01 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -43,14 +43,14 @@ typedef int sig_atomic_t;
|
||||
struct sigcontext13 {
|
||||
int sc_onstack; /* saved onstack flag */
|
||||
int sc_mask; /* saved signal mask (old style) */
|
||||
struct trapframe sc_frame; /* saved registers */
|
||||
struct utrapframe sc_frame; /* saved registers */
|
||||
};
|
||||
#endif /* __LIBC12_SOURCE__ || _KERNEL */
|
||||
|
||||
struct sigcontext {
|
||||
int sc_onstack; /* saved onstack flag */
|
||||
int __sc_mask13; /* saved signal mask (old style) */
|
||||
struct trapframe sc_frame; /* saved registers */
|
||||
struct utrapframe sc_frame; /* saved registers */
|
||||
sigset_t sc_mask; /* saved signal mask (new style) */
|
||||
};
|
||||
|
||||
@ -70,10 +70,9 @@ do { \
|
||||
(sc)->sc_frame.srr1 = (uc)->uc_mcontext.__gregs[_REG_MSR]; \
|
||||
(sc)->sc_frame.ctr = (uc)->uc_mcontext.__gregs[_REG_CTR]; \
|
||||
(sc)->sc_frame.xer = (uc)->uc_mcontext.__gregs[_REG_XER]; \
|
||||
(sc)->sc_frame.dar = 0; \
|
||||
(sc)->sc_frame.dsisr = 0; \
|
||||
(sc)->sc_frame.exc = 0; \
|
||||
(sc)->sc_frame.mq = 0; \
|
||||
(sc)->sc_frame.vrsave = (uc)->uc_mcontext.__vrf.__vrsave; \
|
||||
(sc)->sc_frame.spare = 0; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define _SIGCONTEXT_TO_MCONTEXT(sc, uc) \
|
||||
@ -86,11 +85,13 @@ do { \
|
||||
(uc)->uc_mcontext.__gregs[_REG_MSR] = (sc)->sc_frame.srr1; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_CTR] = (sc)->sc_frame.ctr; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_XER] = (sc)->sc_frame.xer; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_MQ] = (sc)->sc_frame.mq; \
|
||||
(uc)->uc_mcontext.__vrf.__vrsave = (sc)->sc_frame.vrsave; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
struct sigframe {
|
||||
struct sigcontext sf_sc;
|
||||
};
|
||||
|
||||
#endif /* !_ANSI_SOURCE && !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
|
||||
#endif /* !_POWERPC_SIGNAL_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: compat_13_machdep.c,v 1.5 2003/01/18 06:23:32 thorpej Exp $ */
|
||||
/* $NetBSD: compat_13_machdep.c,v 1.6 2003/02/03 21:48:02 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -31,6 +31,8 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "opt_ppcarch.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/signalvar.h>
|
||||
@ -68,7 +70,21 @@ compat_13_sys_sigreturn(l, v, retval)
|
||||
tf = trapframe(l);
|
||||
if ((sc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
|
||||
return (EINVAL);
|
||||
*tf = sc.sc_frame;
|
||||
|
||||
/* Restore register context. */
|
||||
memcpy(tf->fixreg, sc.sc_frame.fixreg, sizeof(tf->fixreg));
|
||||
tf->lr = sc.sc_frame.lr;
|
||||
tf->cr = sc.sc_frame.cr;
|
||||
tf->xer = sc.sc_frame.xer;
|
||||
tf->ctr = sc.sc_frame.ctr;
|
||||
tf->srr0 = sc.sc_frame.srr0;
|
||||
tf->srr1 = sc.sc_frame.srr1;
|
||||
#ifdef PPC_OEA
|
||||
tf->tf_xtra[TF_VRSAVE] = sc.sc_frame.vrsave;
|
||||
tf->tf_xtra[TF_MQ] = sc.sc_frame.mq;
|
||||
#endif
|
||||
|
||||
/* Restore signal stack. */
|
||||
|
||||
/* Restore signal stack. */
|
||||
if (sc.sc_onstack & SS_ONSTACK)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sig_machdep.c,v 1.10 2003/01/20 05:26:47 matt Exp $ */
|
||||
/* $NetBSD: sig_machdep.c,v 1.11 2003/02/03 21:48:02 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -58,8 +58,9 @@ sendsig(sig, mask, code)
|
||||
struct lwp *l = curlwp;
|
||||
struct proc *p = l->l_proc;
|
||||
struct sigacts *ps = p->p_sigacts;
|
||||
struct trapframe *tf;
|
||||
struct sigframe *fp, frame;
|
||||
struct trapframe *tf;
|
||||
struct utrapframe *utf = &frame.sf_sc.sc_frame;
|
||||
int onstack;
|
||||
sig_t catcher = SIGACTION(p, sig).sa_handler;
|
||||
|
||||
@ -79,7 +80,17 @@ sendsig(sig, mask, code)
|
||||
fp = (struct sigframe *)((uintptr_t)(fp - 1) & ~0xf);
|
||||
|
||||
/* Save register context. */
|
||||
frame.sf_sc.sc_frame = *tf;
|
||||
memcpy(utf->fixreg, tf->fixreg, sizeof(utf->fixreg));
|
||||
utf->lr = tf->lr;
|
||||
utf->cr = tf->cr;
|
||||
utf->xer = tf->xer;
|
||||
utf->ctr = tf->ctr;
|
||||
utf->srr0 = tf->srr0;
|
||||
utf->srr1 = tf->srr1;
|
||||
#ifdef PPC_OEA
|
||||
utf->vrsave = tf->tf_xtra[TF_VRSAVE];
|
||||
utf->mq = tf->tf_xtra[TF_MQ];
|
||||
#endif
|
||||
|
||||
/* Save signal stack. */
|
||||
frame.sf_sc.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK;
|
||||
@ -156,6 +167,7 @@ sys___sigreturn14(l, v, retval)
|
||||
struct proc *p = l->l_proc;
|
||||
struct sigcontext sc;
|
||||
struct trapframe *tf;
|
||||
struct utrapframe * const utf = &sc.sc_frame;
|
||||
int error;
|
||||
|
||||
/*
|
||||
@ -170,7 +182,19 @@ sys___sigreturn14(l, v, retval)
|
||||
tf = trapframe(l);
|
||||
if ((sc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
|
||||
return (EINVAL);
|
||||
*tf = sc.sc_frame;
|
||||
|
||||
/* Restore register context. */
|
||||
memcpy(tf->fixreg, utf->fixreg, sizeof(tf->fixreg));
|
||||
tf->lr = utf->lr;
|
||||
tf->cr = utf->cr;
|
||||
tf->xer = utf->xer;
|
||||
tf->ctr = utf->ctr;
|
||||
tf->srr0 = utf->srr0;
|
||||
tf->srr1 = utf->srr1;
|
||||
#ifdef PPC_OEA
|
||||
tf->tf_xtra[TF_VRSAVE] = utf->vrsave;
|
||||
tf->tf_xtra[TF_MQ] = utf->mq;
|
||||
#endif
|
||||
|
||||
/* Restore signal stack. */
|
||||
if (sc.sc_onstack & SS_ONSTACK)
|
||||
@ -204,7 +228,11 @@ cpu_getmcontext(l, mcp, flagp)
|
||||
gr[_REG_MSR] = tf->srr1;
|
||||
gr[_REG_CTR] = tf->ctr;
|
||||
gr[_REG_XER] = tf->xer;
|
||||
gr[_REG_MQ] = 0; /* For now. */
|
||||
#ifdef PPC_OEA
|
||||
gr[_REG_MQ] = tf->tf_xtra[TF_MQ];
|
||||
#else
|
||||
gr[_REG_MQ] = 0;
|
||||
#endif
|
||||
*flagp |= _UC_CPU;
|
||||
|
||||
#ifdef PPC_HAVE_FPU
|
||||
@ -252,7 +280,9 @@ cpu_setmcontext(l, mcp, flags)
|
||||
tf->srr1 = gr[_REG_MSR];
|
||||
tf->ctr = gr[_REG_CTR];
|
||||
tf->xer = gr[_REG_XER];
|
||||
/* unused = gr[_REG_MQ]; */
|
||||
#ifdef PPC_OEA
|
||||
tf->tf_xtra[TF_MQ] = gr[_REG_MQ];
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PPC_HAVE_FPU
|
||||
|
Loading…
Reference in New Issue
Block a user