Make struct sigcontext consistent with other regstate-holding structures.
This commit is contained in:
parent
76c4d78af3
commit
c5eb2581e1
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: frame.h,v 1.7 2003/01/26 14:12:10 fvdl Exp $ */
|
||||
/* $NetBSD: frame.h,v 1.8 2003/03/15 23:41:25 fvdl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -176,7 +176,6 @@ struct switchframe {
|
||||
struct sigframe {
|
||||
uint64_t sf_ra;
|
||||
struct sigcontext sf_sc;
|
||||
struct fxsave64 sf_fp;
|
||||
};
|
||||
|
||||
#endif /* _X86_64FRAME_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: signal.h,v 1.4 2003/01/26 00:05:38 fvdl Exp $ */
|
||||
/* $NetBSD: signal.h,v 1.5 2003/03/15 23:41:25 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California.
|
||||
@ -47,6 +47,7 @@ typedef int sig_atomic_t;
|
||||
*/
|
||||
#include <machine/trap.h>
|
||||
#include <machine/fpu.h>
|
||||
#include <machine/mcontext.h>
|
||||
|
||||
/*
|
||||
* Information pushed on stack when a signal is delivered.
|
||||
@ -56,100 +57,33 @@ typedef int sig_atomic_t;
|
||||
* a non-standard exit is performed.
|
||||
*/
|
||||
struct sigcontext {
|
||||
int sc_gs;
|
||||
int sc_fs;
|
||||
int sc_es;
|
||||
int sc_ds;
|
||||
u_int64_t sc_r8;
|
||||
u_int64_t sc_r9;
|
||||
u_int64_t sc_r10;
|
||||
u_int64_t sc_r11;
|
||||
u_int64_t sc_r12;
|
||||
u_int64_t sc_r13;
|
||||
u_int64_t sc_r14;
|
||||
u_int64_t sc_r15;
|
||||
u_int64_t sc_rdi;
|
||||
u_int64_t sc_rsi;
|
||||
u_int64_t sc_rbp;
|
||||
u_int64_t sc_rbx;
|
||||
u_int64_t sc_rdx;
|
||||
u_int64_t sc_rcx;
|
||||
u_int64_t sc_rax;
|
||||
u_int64_t sc_trapno;
|
||||
u_int64_t sc_err;
|
||||
u_int64_t sc_rip;
|
||||
int sc_cs;
|
||||
int sc_pad0;
|
||||
u_int64_t sc_rflags;
|
||||
u_int64_t sc_rsp_onsig;
|
||||
struct fxsave64 *sc_fpstate; /* XXXfvdl compat with Linux, but.. */
|
||||
int sc_ss;
|
||||
int sc_pad1;
|
||||
|
||||
sigset_t sc_mask; /* signal mask to restore (new style) */
|
||||
u_int64_t sc_onstack; /* sigstack state to restore */
|
||||
|
||||
u_int64_t sc_rsp;
|
||||
struct fxsave64 *sc_fpstate;
|
||||
u_int64_t sc_onstack;
|
||||
sigset_t sc_mask;
|
||||
u_int64_t sc_pad0;
|
||||
mcontext_t sc_mcontext;
|
||||
};
|
||||
|
||||
#define _MCONTEXT_TO_SIGCONTEXT(uc, sc) \
|
||||
do { \
|
||||
(sc)->sc_gs = (uc)->uc_mcontext.__gregs[_REG_GS]; \
|
||||
(sc)->sc_fs = (uc)->uc_mcontext.__gregs[_REG_FS]; \
|
||||
(sc)->sc_es = (uc)->uc_mcontext.__gregs[_REG_ES]; \
|
||||
(sc)->sc_ds = (uc)->uc_mcontext.__gregs[_REG_DS]; \
|
||||
(sc)->sc_r8 = (uc)->uc_mcontext.__gregs[_REG_R8]; \
|
||||
(sc)->sc_r9 = (uc)->uc_mcontext.__gregs[_REG_R9]; \
|
||||
(sc)->sc_r10 = (uc)->uc_mcontext.__gregs[_REG_R10]; \
|
||||
(sc)->sc_r11 = (uc)->uc_mcontext.__gregs[_REG_R11]; \
|
||||
(sc)->sc_r12 = (uc)->uc_mcontext.__gregs[_REG_R12]; \
|
||||
(sc)->sc_r13 = (uc)->uc_mcontext.__gregs[_REG_R13]; \
|
||||
(sc)->sc_r14 = (uc)->uc_mcontext.__gregs[_REG_R14]; \
|
||||
(sc)->sc_r15 = (uc)->uc_mcontext.__gregs[_REG_R15]; \
|
||||
(sc)->sc_rdi = (uc)->uc_mcontext.__gregs[_REG_RDI]; \
|
||||
(sc)->sc_rsi = (uc)->uc_mcontext.__gregs[_REG_RSI]; \
|
||||
(sc)->sc_rbp = (uc)->uc_mcontext.__gregs[_REG_RBP]; \
|
||||
(sc)->sc_rbx = (uc)->uc_mcontext.__gregs[_REG_RBX]; \
|
||||
(sc)->sc_rdx = (uc)->uc_mcontext.__gregs[_REG_RDX]; \
|
||||
(sc)->sc_rcx = (uc)->uc_mcontext.__gregs[_REG_RCX]; \
|
||||
(sc)->sc_rax = (uc)->uc_mcontext.__gregs[_REG_RAX]; \
|
||||
(sc)->sc_trapno = (uc)->uc_mcontext.__gregs[_REG_TRAPNO]; \
|
||||
(sc)->sc_err = (uc)->uc_mcontext.__gregs[_REG_ERR]; \
|
||||
(sc)->sc_rip = (uc)->uc_mcontext.__gregs[_REG_RIP]; \
|
||||
(sc)->sc_cs = (uc)->uc_mcontext.__gregs[_REG_CS]; \
|
||||
(sc)->sc_rflags = (uc)->uc_mcontext.__gregs[_REG_RFL]; \
|
||||
(sc)->sc_ss = (uc)->uc_mcontext.__gregs[_REG_SS]; \
|
||||
(sc)->sc_rsp = (uc)->uc_mcontext.__gregs[_REG_URSP]; \
|
||||
memcpy(&(sc)->sc_mcontext.__gregs, &(uc)->uc_mcontext.__gregs, \
|
||||
sizeof ((uc)->uc_mcontext.__gregs)); \
|
||||
if ((uc)->uc_flags & _UC_FPU) { \
|
||||
memcpy(&(sc)->sc_mcontext.__fpregs, \
|
||||
&(uc)->uc_mcontext.__fpregs, \
|
||||
sizeof ((uc)->uc_mcontext.__fpregs)); \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define _SIGCONTEXT_TO_MCONTEXT(sc, uc) \
|
||||
do { \
|
||||
(uc)->uc_mcontext.__gregs[_REG_GS] = (sc)->sc_gs; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_FS] = (sc)->sc_fs; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_ES] = (sc)->sc_es; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_DS] = (sc)->sc_ds; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_R8] = (sc)->sc_r8; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_R9] = (sc)->sc_r9; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_R10] = (sc)->sc_r10; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_R11] = (sc)->sc_r11; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_R12] = (sc)->sc_r12; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_R13] = (sc)->sc_r13; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_R14] = (sc)->sc_r14; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_R15] = (sc)->sc_r15; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_RDI] = (sc)->sc_rdi; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_RSI] = (sc)->sc_rsi; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_RBP] = (sc)->sc_rbp; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_RBX] = (sc)->sc_rbx; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_RDX] = (sc)->sc_rdx; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_RCX] = (sc)->sc_rcx; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_RAX] = (sc)->sc_rax; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_TRAPNO] = (sc)->sc_trapno; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_ERR] = (sc)->sc_err; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_RIP] = (sc)->sc_rip; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_CS] = (sc)->sc_cs; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_RFL] = (sc)->sc_rflags; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_SS] = (sc)->sc_ss; \
|
||||
(uc)->uc_mcontext.__gregs[_REG_URSP] = (sc)->sc_rsp; \
|
||||
memcpy(&(uc)->uc_mcontext.__gregs, &(sc)->sc_mcontext.__gregs, \
|
||||
sizeof ((uc)->uc_mcontext.__gregs)); \
|
||||
if ((uc)->uc_flags & _UC_FPU) { \
|
||||
memcpy(&(uc)->uc_mcontext.__fpregs, \
|
||||
&(sc)->sc_mcontext.__fpregs, \
|
||||
sizeof ((uc)->uc_mcontext.__fpregs)); \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#endif /* !_ANSI_SOURCE && !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: genassym.cf,v 1.12 2003/03/05 23:56:08 fvdl Exp $
|
||||
# $NetBSD: genassym.cf,v 1.13 2003/03/15 23:41:26 fvdl Exp $
|
||||
|
||||
#
|
||||
# Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -203,10 +203,6 @@ define TF_SS offsetof(struct trapframe, tf_ss)
|
||||
|
||||
define FRAMESIZE sizeof(struct trapframe)
|
||||
|
||||
define SC_FS offsetof(struct sigcontext, sc_fs)
|
||||
define SC_GS offsetof(struct sigcontext, sc_gs)
|
||||
define SC_RFLAGS offsetof(struct sigcontext, sc_rflags)
|
||||
|
||||
define CPU_INFO_SCRATCH offsetof(struct cpu_info, ci_scratch)
|
||||
define CPU_INFO_SELF offsetof(struct cpu_info, ci_self)
|
||||
define CPU_INFO_RESCHED offsetof(struct cpu_info, ci_want_resched)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.31 2003/03/06 00:47:00 fvdl Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.32 2003/03/15 23:41:26 fvdl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
|
||||
@ -519,13 +519,16 @@ sendsig(sig, mask, code)
|
||||
fp = (struct sigframe *)sp - 1;
|
||||
|
||||
if (l->l_md.md_flags & MDP_USEDFPU) {
|
||||
frame.sf_sc.sc_fpstate = &fp->sf_fp;
|
||||
memcpy(&frame.sf_fp, &l->l_addr->u_pcb.pcb_savefpu.fp_fxsave,
|
||||
frame.sf_sc.sc_fpstate =
|
||||
(struct fxsave64 *)&fp->sf_sc.sc_mcontext.__fpregs;
|
||||
memcpy(&frame.sf_sc.sc_mcontext.__fpregs,
|
||||
&l->l_addr->u_pcb.pcb_savefpu.fp_fxsave,
|
||||
sizeof (struct fxsave64));
|
||||
tocopy = sizeof (struct sigframe);
|
||||
} else {
|
||||
frame.sf_sc.sc_fpstate = NULL;
|
||||
tocopy = sizeof (struct sigframe) - sizeof (struct fxsave64);
|
||||
tocopy = sizeof (struct sigframe) -
|
||||
sizeof (fp->sf_sc.sc_mcontext.__fpregs);
|
||||
}
|
||||
|
||||
/* Build stack frame for signal trampoline. */
|
||||
@ -546,32 +549,7 @@ sendsig(sig, mask, code)
|
||||
}
|
||||
|
||||
/* Save register context. */
|
||||
frame.sf_sc.sc_es = tf->tf_es;
|
||||
frame.sf_sc.sc_ds = tf->tf_ds;
|
||||
frame.sf_sc.sc_fs = tf->tf_fs;
|
||||
frame.sf_sc.sc_gs = tf->tf_gs;
|
||||
frame.sf_sc.sc_rflags = tf->tf_rflags;
|
||||
frame.sf_sc.sc_r15 = tf->tf_r15;
|
||||
frame.sf_sc.sc_r14 = tf->tf_r14;
|
||||
frame.sf_sc.sc_r13 = tf->tf_r13;
|
||||
frame.sf_sc.sc_r12 = tf->tf_r12;
|
||||
frame.sf_sc.sc_r11 = tf->tf_r11;
|
||||
frame.sf_sc.sc_r10 = tf->tf_r10;
|
||||
frame.sf_sc.sc_r9 = tf->tf_r9;
|
||||
frame.sf_sc.sc_r8 = tf->tf_r8;
|
||||
frame.sf_sc.sc_rdi = tf->tf_rdi;
|
||||
frame.sf_sc.sc_rsi = tf->tf_rsi;
|
||||
frame.sf_sc.sc_rbp = tf->tf_rbp;
|
||||
frame.sf_sc.sc_rbx = tf->tf_rbx;
|
||||
frame.sf_sc.sc_rdx = tf->tf_rdx;
|
||||
frame.sf_sc.sc_rcx = tf->tf_rcx;
|
||||
frame.sf_sc.sc_rax = tf->tf_rax;
|
||||
frame.sf_sc.sc_rip = tf->tf_rip;
|
||||
frame.sf_sc.sc_cs = tf->tf_cs;
|
||||
frame.sf_sc.sc_rsp = tf->tf_rsp;
|
||||
frame.sf_sc.sc_ss = tf->tf_ss;
|
||||
frame.sf_sc.sc_trapno = tf->tf_trapno;
|
||||
frame.sf_sc.sc_err = tf->tf_err;
|
||||
memcpy(&frame.sf_sc.sc_mcontext.__gregs, tf, sizeof (*tf));
|
||||
|
||||
/* Save signal stack. */
|
||||
frame.sf_sc.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK;
|
||||
@ -666,6 +644,7 @@ sys___sigreturn14(l, v, retval)
|
||||
struct proc *p = l->l_proc;
|
||||
struct sigcontext *scp, context;
|
||||
struct trapframe *tf;
|
||||
uint64_t rflags;
|
||||
|
||||
/*
|
||||
* The trampoline code hands us the context.
|
||||
@ -674,7 +653,7 @@ sys___sigreturn14(l, v, retval)
|
||||
*/
|
||||
scp = SCARG(uap, sigcntxp);
|
||||
if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0)
|
||||
return (EFAULT);
|
||||
return EFAULT;
|
||||
|
||||
/* Restore register context. */
|
||||
tf = l->l_md.md_regs;
|
||||
@ -684,34 +663,12 @@ sys___sigreturn14(l, v, retval)
|
||||
* automatically and generate a trap on violations. We handle
|
||||
* the trap, rather than doing all of the checking here.
|
||||
*/
|
||||
if (((context.sc_rflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 ||
|
||||
!USERMODE(context.sc_cs, context.sc_rflags))
|
||||
return (EINVAL);
|
||||
rflags = context.sc_mcontext.__gregs[_REG_RFL];
|
||||
if (((rflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 ||
|
||||
!USERMODE(context.sc_mcontext.__gregs[_REG_CS], rflags))
|
||||
return EINVAL;
|
||||
|
||||
tf->tf_ds = context.sc_ds;
|
||||
tf->tf_es = context.sc_es;
|
||||
tf->tf_fs = context.sc_fs;
|
||||
tf->tf_gs = context.sc_gs;
|
||||
tf->tf_rflags = context.sc_rflags;
|
||||
tf->tf_r15 = context.sc_r15;
|
||||
tf->tf_r14 = context.sc_r14;
|
||||
tf->tf_r13 = context.sc_r13;
|
||||
tf->tf_r12 = context.sc_r12;
|
||||
tf->tf_r11 = context.sc_r11;
|
||||
tf->tf_r10 = context.sc_r10;
|
||||
tf->tf_r9 = context.sc_r9;
|
||||
tf->tf_r8 = context.sc_r8;
|
||||
tf->tf_rdi = context.sc_rdi;
|
||||
tf->tf_rsi = context.sc_rsi;
|
||||
tf->tf_rbp = context.sc_rbp;
|
||||
tf->tf_rbx = context.sc_rbx;
|
||||
tf->tf_rdx = context.sc_rdx;
|
||||
tf->tf_rcx = context.sc_rcx;
|
||||
tf->tf_rax = context.sc_rax;
|
||||
tf->tf_rip = context.sc_rip;
|
||||
tf->tf_cs = context.sc_cs;
|
||||
tf->tf_rsp = context.sc_rsp;
|
||||
tf->tf_ss = context.sc_ss;
|
||||
memcpy(tf, &context.sc_mcontext.__gregs, sizeof (*tf));
|
||||
|
||||
/* Restore (possibly fixed up) FP state and force it to be reloaded */
|
||||
if (l->l_md.md_flags & MDP_USEDFPU) {
|
||||
@ -731,7 +688,7 @@ sys___sigreturn14(l, v, retval)
|
||||
/* Restore signal mask. */
|
||||
(void) sigprocmask1(p, SIG_SETMASK, &context.sc_mask, 0);
|
||||
|
||||
return (EJUSTRETURN);
|
||||
return EJUSTRETURN;
|
||||
}
|
||||
|
||||
int waittime = -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user