Make the signal code look a bit more like the 32-bit SPARC port's.

This commit is contained in:
thorpej 1998-09-17 04:52:17 +00:00
parent a7e5b3bcce
commit 2eb8e8729b
3 changed files with 146 additions and 50 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: files.sparc64,v 1.12 1998/09/05 17:42:28 pk Exp $
# $NetBSD: files.sparc64,v 1.13 1998/09/17 04:52:17 thorpej Exp $
# @(#)files.sparc64 8.1 (Berkeley) 7/19/93
# sparc64-specific configuration info
@ -184,6 +184,9 @@ include "../../../dev/rcons/files.rcons"
# Compatibility modules
#
# Binary compatiblity with previous NetBSD releases.
file arch/sparc64/sparc64/compat_13_machdep.c compat_13
# NetBSD/sparc Binary compatibility (COMPAT_SPARC32)
include "../../../compat/sparc32/files.sparc32"

View File

@ -0,0 +1,118 @@
/* $NetBSD: compat_13_machdep.c,v 1.1 1998/09/17 04:52:17 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
* NASA Ames Research Center.
*
* 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 the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 THE FOUNDATION OR CONTRIBUTORS
* 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/proc.h>
#include <sys/user.h>
#include <sys/kernel.h>
#include <sys/mount.h>
#include <sys/signal.h>
#include <sys/signalvar.h>
#include <sys/syscallargs.h>
/*
* System call to cleanup state after a signal
* has been taken. Reset signal mask and
* stack state from context left by sendsig (above),
* and return to the given trap frame (if there is one).
* Check carefully to make sure that the user has not
* modified the state to gain improper privileges or to cause
* a machine fault.
*/
/* ARGSUSED */
int
compat_13_sys_sigreturn(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
#ifdef _LP64
panic("compat_13_sys_sigreturn");
#else
struct compat_13_sys_sigreturn_args /* {
syscallarg(struct sigcontext13 *) sigcntxp;
} */ *uap = v;
struct sigcontext13 sc, *scp;
sigset_t mask;
struct trapframe *tf;
/* First ensure consistent stack state (see sendsig). */
write_user_windows();
#if 0
/* Make sure our D$ is not polluted w/bad data */
blast_vcache();
#endif
if (rwindow_save(p))
sigexit(p, SIGILL);
scp = SCARG(uap, sigcntxp);
f ((vaddr_t)scp & 3 || (copyin((caddr_t)scp, &sc, sizeof sc) != 0))
return (EFAULT);
scp = &sc;
tf = p->p_md.md_tf;
/*
* Only the icc bits in the psr are used, so it need not be
* verified. pc and npc must be multiples of 4. This is all
* that is required; if it holds, just do it.
*/
if (((scp->sc_pc | scp->sc_npc) & 3) != 0)
return (EINVAL);
/* take only psr ICC field */
tf->tf_tstate = (int64_t)(tf->tf_tstate & ~TSTATE_CCR) | PSRCC_TO_TSTATE(scp->sc_psr);
tf->tf_pc = scp->sc_pc;
tf->tf_npc = scp->sc_npc;
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 & 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(&scp->sc_mask, &mask);
(void) sigprocmask1(p, SIG_SETMASK, &mask, 0);
return (EJUSTRETURN);
#endif /* _LP64 */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.16 1998/09/13 16:45:43 eeh Exp $ */
/* $NetBSD: machdep.c,v 1.17 1998/09/17 04:52:17 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -592,10 +592,10 @@ sendsig(catcher, sig, mask, code)
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;
struct proc *p = curproc;
struct sigacts *psp = p->p_sigacts;
struct sigframe *fp;
struct trapframe *tf;
vaddr_t addr;
struct rwindow *oldsp, *newsp, /* DEBUG */tmpwin;
struct sigframe sf;
@ -642,20 +642,10 @@ sendsig(catcher, sig, mask, code)
sf.sf_signo = sig;
sf.sf_code = code;
#ifndef _LP64
#ifdef COMPAT_SUNOS
sf.sf_scp = &fp->sf_sc;
#endif
sf.sf_scp = 0;
sf.sf_addr = 0; /* XXX */
#endif
/* 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;
sf.sf_sc.sc_psr = TSTATECCR_TO_PSR(tf->tf_tstate); /* XXX */
sf.sf_sc.sc_g1 = tf->tf_global[1];
sf.sf_sc.sc_o0 = tf->tf_out[0];
/*
* Build the signal context to be used by sigreturn.
*/
@ -670,7 +660,13 @@ sendsig(catcher, sig, mask, code)
*/
native_sigset_to_sigset13(mask, &frame.sf_sc.__sc_mask13);
#endif
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;
sf.sf_sc.sc_psr = TSTATECCR_TO_PSR(tf->tf_tstate); /* XXX */
sf.sf_sc.sc_g1 = tf->tf_global[1];
sf.sf_sc.sc_o0 = tf->tf_out[0];
/*
* Put the stack in a consistent state before we whack away
* at it. Note that write_user_windows may just dump the
@ -717,16 +713,8 @@ sendsig(catcher, sig, mask, code)
* Arrange to continue execution at the code copied out in exec().
* It needs the function to call in %g1, and a new stack pointer.
*/
#ifdef _COMPAT_SUNOS
/* XXXXXXX FIX MEEEEEEE XXXXXXX */
if (psp->ps_usertramp & sigmask(sig)) {
addr = (vaddr_t)catcher; /* user does his own trampolining */
} else
#endif
{
addr = (vaddr_t)psp->ps_sigcode;
tf->tf_global[1] = (vaddr_t)catcher;
}
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;
@ -742,20 +730,6 @@ sendsig(catcher, sig, mask, code)
if (sigdebug & SDB_DDB) Debugger();
}
#endif
/* Remember that we're now on the signal stack. */
if (onstack)
psp->ps_sigstk.ss_flags |= SS_ONSTACK;
}
int compat_13_sys_sigreturn __P((struct proc *, void *, register_t *));
int
compat_13_sys_sigreturn(p, v, retval)
register struct proc *p;
void *v;
register_t *retval;
{
return sys___sigreturn14(p, v, retval);
}
/*
@ -777,8 +751,7 @@ sys___sigreturn14(p, v, retval)
struct sys___sigreturn14_args /* {
syscallarg(struct sigcontext *) sigcntxp;
} */ *uap = v;
struct sigcontext *scp;
struct sigcontext sc;
struct sigcontext sc, *scp;
register struct trapframe *tf;
#ifndef TRAPWIN
int i;
@ -815,6 +788,8 @@ sys___sigreturn14(p, v, retval)
#else
return (EINVAL);
#endif
scp = &sc;
tf = p->p_md.md_tf;
/*
* Only the icc bits in the psr are used, so it need not be
@ -832,12 +807,12 @@ sys___sigreturn14(p, v, retval)
return (EINVAL);
#endif
/* take only psr ICC field */
tf->tf_tstate = (int64_t)(tf->tf_tstate & ~TSTATE_CCR) | PSRCC_TO_TSTATE(sc.sc_psr);
tf->tf_pc = (int64_t)sc.sc_pc;
tf->tf_npc = (int64_t)sc.sc_npc;
tf->tf_global[1] = (int64_t)sc.sc_g1;
tf->tf_out[0] = (int64_t)sc.sc_o0;
tf->tf_out[6] = (int64_t)sc.sc_sp;
tf->tf_tstate = (int64_t)(tf->tf_tstate & ~TSTATE_CCR) | PSRCC_TO_TSTATE(scp->sc_psr);
tf->tf_pc = (int64_t)scp->sc_pc;
tf->tf_npc = (int64_t)scp->sc_npc;
tf->tf_global[1] = (int64_t)scp->sc_g1;
tf->tf_out[0] = (int64_t)scp->sc_o0;
tf->tf_out[6] = (int64_t)scp->sc_sp;
#ifdef DEBUG
if (sigdebug & SDB_FOLLOW) {
printf("sys_sigreturn: return trapframe pc=%p sp=%p tstate=%llx\n",