Update freebsd_sigcontext to what FreeBSD currently uses, and save/restore

%fs/%gs as appropriate.

XXX Note that the new sigcontext uses the new sigset_t instead of old
int sc_mask. The new FreeBSD sigcontext doesn't contain any backward
compatibility sc_mask, so basically old FreeBSD application making
use of sigcontext are hosed. This can't be fixed in NetBSD compat code.
This commit is contained in:
jdolecek 2001-10-27 12:26:29 +00:00
parent 4d0bc92582
commit 5d461f21ee
2 changed files with 53 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: freebsd_machdep.c,v 1.28 2001/08/03 00:41:46 thorpej Exp $ */
/* $NetBSD: freebsd_machdep.c,v 1.29 2001/10/27 12:26:30 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -125,6 +125,8 @@ freebsd_sendsig(catcher, sig, mask, code)
/* Save register context. */
#ifdef VM86
if (tf->tf_eflags & PSL_VM) {
frame.sf_sc.sc_gs = tf->tf_vm86_gs;
frame.sf_sc.sc_fs = tf->tf_vm86_fs;
frame.sf_sc.sc_es = tf->tf_vm86_es;
frame.sf_sc.sc_ds = tf->tf_vm86_ds;
frame.sf_sc.sc_eflags = get_vflags(p);
@ -132,9 +134,11 @@ freebsd_sendsig(catcher, sig, mask, code)
} else
#endif
{
frame.sf_sc.sc_gs = tf->tf_gs;
frame.sf_sc.sc_fs = tf->tf_fs;
frame.sf_sc.sc_es = tf->tf_es;
frame.sf_sc.sc_ds = tf->tf_ds;
frame.sf_sc.sc_eflags = tf->tf_eflags;
frame.sf_sc.sc_efl = tf->tf_eflags;
}
frame.sf_sc.sc_edi = tf->tf_edi;
frame.sf_sc.sc_esi = tf->tf_esi;
@ -153,7 +157,8 @@ freebsd_sendsig(catcher, sig, mask, code)
frame.sf_sc.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK;
/* Save signal mask. */
native_sigset_to_sigset13(mask, &frame.sf_sc.sc_mask);
/* XXX freebsd_osigcontext compat? */
frame.sf_sc.sc_mask = *mask;
if (copyout(&frame, fp, sizeof(frame)) != 0) {
/*
@ -218,6 +223,8 @@ freebsd_sys_sigreturn(p, v, retval)
if (context.sc_eflags & PSL_VM) {
void syscall_vm86 __P((struct trapframe));
tf->tf_vm86_gs = context.sc_gs;
tf->tf_vm86_fs = context.sc_fs;
tf->tf_vm86_es = context.sc_es;
tf->tf_vm86_ds = context.sc_ds;
set_vflags(p, context.sc_eflags);
@ -231,13 +238,15 @@ freebsd_sys_sigreturn(p, v, retval)
* automatically and generate a trap on violations. We handle
* the trap, rather than doing all of the checking here.
*/
if (((context.sc_eflags ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
if (((context.sc_efl ^ tf->tf_eflags) & PSL_USERSTATIC) != 0 ||
!USERMODE(context.sc_cs, context.sc_eflags))
return (EINVAL);
tf->tf_gs = context.sc_gs;
tf->tf_fs = context.sc_fs;
tf->tf_es = context.sc_es;
tf->tf_ds = context.sc_ds;
tf->tf_eflags = context.sc_eflags;
tf->tf_eflags = context.sc_efl;
}
tf->tf_edi = context.sc_edi;
tf->tf_esi = context.sc_esi;
@ -259,7 +268,8 @@ freebsd_sys_sigreturn(p, v, retval)
p->p_sigctx.ps_sigstk.ss_flags &= ~SS_ONSTACK;
/* Restore signal mask. */
native_sigset13_to_sigset(&context.sc_mask, &mask);
/* XXX freebsd_osigcontext compat? */
mask = context.sc_mask;
(void) sigprocmask1(p, SIG_SETMASK, &mask, 0);
return (EJUSTRETURN);

View File

@ -1,4 +1,4 @@
/* $NetBSD: freebsd_machdep.h,v 1.3 2000/12/18 23:29:46 thorpej Exp $ */
/* $NetBSD: freebsd_machdep.h,v 1.4 2001/10/27 12:26:29 jdolecek Exp $ */
/*
* Copyright (c) 1986, 1989, 1991, 1993
@ -48,7 +48,7 @@
* signal support
*/
struct freebsd_sigcontext {
struct freebsd_osigcontext {
int sc_onstack; /* sigstack state to restore */
sigset13_t sc_mask; /* signal mask to restore */
int sc_esp; /* machine state */
@ -68,6 +68,41 @@ struct freebsd_sigcontext {
int sc_eax;
};
/*
* The sequence of the fields/registers in struct sigcontext should match
* those in mcontext_t.
*/
struct freebsd_sigcontext {
sigset_t sc_mask; /* signal mask to restore */
int sc_onstack; /* sigstack state to restore */
int sc_gs; /* machine state (struct trapframe): */
int sc_fs;
int sc_es;
int sc_ds;
int sc_edi;
int sc_esi;
int sc_ebp;
int sc_isp;
int sc_ebx;
int sc_edx;
int sc_ecx;
int sc_eax;
int sc_trapno;
int sc_err;
int sc_eip;
int sc_cs;
int sc_efl;
int sc_esp;
int sc_ss;
/*
* XXX FPU state is 27 * 4 bytes h/w, 1 * 4 bytes s/w (probably not
* needed here), or that + 16 * 4 bytes for emulators (probably all
* needed here). The "spare" bytes are mostly not spare.
*/
int sc_fpregs[28]; /* machine state (FPU): */
int sc_spare[17];
};
struct freebsd_sigframe {
int sf_signum;
int sf_code;