1999-12-14 22:35:36 +00:00
|
|
|
/* $NetBSD: osf1_signal.c,v 1.4 1998/05/20 16:35:01 chs Exp $
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1998-1999 Andrew Gallatin
|
|
|
|
*
|
|
|
|
* Taken from NetBSD's sys/compat/osf1/osf1_signal.c, which at the
|
|
|
|
* time *had no copyright*!
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* in this position and unchanged.
|
|
|
|
* 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. The name of the author may not be used to endorse or promote products
|
2002-06-02 20:05:59 +00:00
|
|
|
* derived from this software without specific prior written permission
|
1999-12-14 22:35:36 +00:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
2002-10-25 19:10:58 +00:00
|
|
|
#include "opt_compat.h"
|
|
|
|
#ifndef COMPAT_43
|
|
|
|
#error "COMPAT_OSF1 requires COMPAT_43"
|
|
|
|
#endif
|
|
|
|
|
1999-12-14 22:35:36 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/sysproto.h>
|
|
|
|
#include <sys/signalvar.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/reboot.h>
|
2000-05-05 09:59:14 +00:00
|
|
|
#include <sys/bio.h>
|
1999-12-14 22:35:36 +00:00
|
|
|
#include <sys/buf.h>
|
2000-12-08 22:11:23 +00:00
|
|
|
#include <sys/bus.h>
|
1999-12-14 22:35:36 +00:00
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/vmmeter.h>
|
|
|
|
#include <sys/msgbuf.h>
|
|
|
|
#include <sys/exec.h>
|
2003-04-22 18:23:49 +00:00
|
|
|
#include <sys/syscallsubr.h>
|
1999-12-14 22:35:36 +00:00
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <net/netisr.h>
|
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_kern.h>
|
|
|
|
#include <vm/vm_page.h>
|
|
|
|
#include <vm/vm_map.h>
|
|
|
|
#include <vm/vm_extern.h>
|
|
|
|
#include <vm/vm_object.h>
|
|
|
|
#include <vm/vm_pager.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/ptrace.h>
|
2003-02-20 20:54:45 +00:00
|
|
|
#include <sys/cons.h>
|
1999-12-14 22:35:36 +00:00
|
|
|
#include <machine/clock.h>
|
|
|
|
#include <machine/md_var.h>
|
|
|
|
#include <machine/reg.h>
|
|
|
|
#include <machine/pal.h>
|
|
|
|
#include <machine/cpuconf.h>
|
|
|
|
#include <machine/bootinfo.h>
|
|
|
|
#include <machine/rpb.h>
|
|
|
|
#include <machine/prom.h>
|
|
|
|
#include <machine/chipset.h>
|
|
|
|
#include <machine/vmparam.h>
|
|
|
|
#include <machine/elf.h>
|
|
|
|
#include <ddb/ddb.h>
|
|
|
|
#include <alpha/alpha/db_instruction.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
|
|
|
|
#include <alpha/osf1/osf1_signal.h>
|
|
|
|
#include <alpha/osf1/osf1_proto.h>
|
|
|
|
#include <alpha/osf1/osf1_syscall.h>
|
|
|
|
#include <alpha/osf1/osf1_util.h>
|
|
|
|
#include <alpha/osf1/osf1.h>
|
|
|
|
#include <sys/sysproto.h>
|
|
|
|
|
|
|
|
#define DPRINTF uprintf
|
|
|
|
int osf1_sigdbg = 0;
|
|
|
|
|
2002-03-20 18:58:47 +00:00
|
|
|
static void bsd_to_osf1_sigaction(const struct sigaction *bsa,
|
|
|
|
struct osf1_sigaction *osa);
|
|
|
|
static void osf1_to_bsd_sigaction(const struct osf1_sigaction *osa,
|
|
|
|
struct sigaction *bsa);
|
1999-12-14 22:35:36 +00:00
|
|
|
|
|
|
|
#define sigemptyset(s) SIGEMPTYSET(*(s))
|
|
|
|
#define sigismember(s, n) SIGISMEMBER(*(s), n)
|
|
|
|
#define sigaddset(s, n) SIGADDSET(*(s), n)
|
|
|
|
|
|
|
|
#define osf1_sigmask(n) (1 << ((n) - 1))
|
|
|
|
#define osf1_sigemptyset(s) memset((s), 0, sizeof(*(s)))
|
|
|
|
#define osf1_sigfillset(s) memset((s), 0xffffffff, sizeof(*(s)))
|
|
|
|
#define osf1_sigismember(s, n) (*(s) & sigmask(n))
|
|
|
|
#define osf1_sigaddset(s, n) (*(s) |= sigmask(n))
|
|
|
|
|
|
|
|
void
|
|
|
|
osf1_to_bsd_sigset(oss, bss)
|
|
|
|
const osf1_sigset_t *oss;
|
|
|
|
sigset_t *bss;
|
|
|
|
{
|
2000-11-10 23:00:54 +00:00
|
|
|
const u_int32_t *obits;
|
1999-12-14 22:35:36 +00:00
|
|
|
|
|
|
|
SIGEMPTYSET(*bss);
|
2000-11-10 23:00:54 +00:00
|
|
|
obits = (const u_int32_t *)oss;
|
|
|
|
bss->__bits[0] = obits[0];
|
|
|
|
bss->__bits[1] = obits[1];
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bsd_to_osf1_sigset(bss, oss)
|
|
|
|
const sigset_t *bss;
|
|
|
|
osf1_sigset_t *oss;
|
|
|
|
{
|
2000-11-10 23:00:54 +00:00
|
|
|
u_int32_t *obits;
|
1999-12-14 22:35:36 +00:00
|
|
|
|
|
|
|
osf1_sigemptyset(oss);
|
2000-11-10 23:00:54 +00:00
|
|
|
obits = (u_int32_t *)oss;
|
|
|
|
obits[0] = bss->__bits[0];
|
|
|
|
obits[1] = bss->__bits[1];
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: Only a subset of the flags is currently implemented.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
osf1_to_bsd_sigaction(osa, bsa)
|
|
|
|
const struct osf1_sigaction *osa;
|
|
|
|
struct sigaction *bsa;
|
|
|
|
{
|
|
|
|
|
|
|
|
bsa->sa_handler = osa->osa_handler;
|
|
|
|
if (osf1_sigdbg)
|
|
|
|
uprintf("%s(%d): handler @0x%lx \n", __FILE__, __LINE__,
|
|
|
|
(unsigned long)osa->osa_handler);
|
|
|
|
osf1_to_bsd_sigset(&osa->osa_mask, &bsa->sa_mask);
|
|
|
|
bsa->sa_flags = 0;
|
|
|
|
if ((osa->osa_flags & OSF1_SA_ONSTACK) != 0)
|
|
|
|
bsa->sa_flags |= SA_ONSTACK;
|
|
|
|
if ((osa->osa_flags & OSF1_SA_RESTART) != 0)
|
|
|
|
bsa->sa_flags |= SA_RESTART;
|
|
|
|
if ((osa->osa_flags & OSF1_SA_RESETHAND) != 0)
|
|
|
|
bsa->sa_flags |= SA_RESETHAND;
|
|
|
|
if ((osa->osa_flags & OSF1_SA_NOCLDSTOP) != 0)
|
|
|
|
bsa->sa_flags |= SA_NOCLDSTOP;
|
|
|
|
if ((osa->osa_flags & OSF1_SA_NODEFER) != 0)
|
|
|
|
bsa->sa_flags |= SA_NODEFER;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bsd_to_osf1_sigaction(bsa, osa)
|
|
|
|
const struct sigaction *bsa;
|
|
|
|
struct osf1_sigaction *osa;
|
|
|
|
{
|
|
|
|
|
|
|
|
osa->osa_handler = bsa->sa_handler;
|
|
|
|
bsd_to_osf1_sigset(&bsa->sa_mask, &osa->osa_mask);
|
|
|
|
osa->osa_flags = 0;
|
|
|
|
if ((bsa->sa_flags & SA_ONSTACK) != 0)
|
|
|
|
osa->osa_flags |= SA_ONSTACK;
|
|
|
|
if ((bsa->sa_flags & SA_RESTART) != 0)
|
|
|
|
osa->osa_flags |= SA_RESTART;
|
|
|
|
if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
|
|
|
|
osa->osa_flags |= SA_NOCLDSTOP;
|
|
|
|
if ((bsa->sa_flags & SA_NODEFER) != 0)
|
|
|
|
osa->osa_flags |= SA_NODEFER;
|
|
|
|
if ((bsa->sa_flags & SA_RESETHAND) != 0)
|
|
|
|
osa->osa_flags |= SA_RESETHAND;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
osf1_to_bsd_sigaltstack(oss, bss)
|
|
|
|
const struct osf1_sigaltstack *oss;
|
|
|
|
struct sigaltstack *bss;
|
|
|
|
{
|
|
|
|
|
|
|
|
bss->ss_sp = oss->ss_sp;
|
|
|
|
bss->ss_size = oss->ss_size;
|
|
|
|
bss->ss_flags = 0;
|
|
|
|
|
|
|
|
if ((oss->ss_flags & OSF1_SS_DISABLE) != 0)
|
|
|
|
bss->ss_flags |= SS_DISABLE;
|
|
|
|
if ((oss->ss_flags & OSF1_SS_ONSTACK) != 0)
|
|
|
|
bss->ss_flags |= SS_ONSTACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bsd_to_osf1_sigaltstack(bss, oss)
|
|
|
|
const struct sigaltstack *bss;
|
|
|
|
struct osf1_sigaltstack *oss;
|
|
|
|
{
|
|
|
|
|
|
|
|
oss->ss_sp = bss->ss_sp;
|
|
|
|
oss->ss_size = bss->ss_size;
|
|
|
|
oss->ss_flags = 0;
|
|
|
|
|
|
|
|
if ((bss->ss_flags & SS_DISABLE) != 0)
|
|
|
|
oss->ss_flags |= OSF1_SS_DISABLE;
|
|
|
|
if ((bss->ss_flags & SS_ONSTACK) != 0)
|
|
|
|
oss->ss_flags |= OSF1_SS_ONSTACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-20 04:56:42 +00:00
|
|
|
osf1_sigaction(td, uap)
|
|
|
|
struct thread *td;
|
1999-12-14 22:35:36 +00:00
|
|
|
struct osf1_sigaction_args *uap;
|
|
|
|
{
|
2003-04-22 18:23:49 +00:00
|
|
|
struct osf1_sigaction osa;
|
|
|
|
struct sigaction nbsa, obsa;
|
|
|
|
struct sigaction *nbsap;
|
1999-12-14 22:35:36 +00:00
|
|
|
int error;
|
2003-04-22 18:23:49 +00:00
|
|
|
|
1999-12-14 22:35:36 +00:00
|
|
|
if (osf1_sigdbg && uap->sigtramp)
|
|
|
|
uprintf("osf1_sigaction: trampoline handler at %p\n",
|
|
|
|
uap->sigtramp);
|
2003-04-22 18:23:49 +00:00
|
|
|
td->td_md.osf_sigtramp = uap->sigtramp;
|
|
|
|
if (uap->nsa != NULL) {
|
|
|
|
if ((error = copyin(uap->nsa, &osa, sizeof(osa))) != 0)
|
|
|
|
return (error);
|
|
|
|
osf1_to_bsd_sigaction(&osa, &nbsa);
|
|
|
|
nbsap = &nbsa;
|
1999-12-14 22:35:36 +00:00
|
|
|
} else
|
2003-04-22 18:23:49 +00:00
|
|
|
nbsap = NULL;
|
|
|
|
error = kern_sigaction(td, uap->signum, &nbsa, &obsa, 0);
|
1999-12-14 22:35:36 +00:00
|
|
|
|
2003-04-22 18:23:49 +00:00
|
|
|
if (error == 0 && uap->osa != NULL) {
|
|
|
|
bsd_to_osf1_sigaction(&obsa, &osa);
|
|
|
|
error = copyout(&osa, uap->osa, sizeof(osa));
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
2003-04-22 18:23:49 +00:00
|
|
|
return (error);
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-20 04:56:42 +00:00
|
|
|
osf1_sigaltstack(td, uap)
|
|
|
|
register struct thread *td;
|
1999-12-14 22:35:36 +00:00
|
|
|
struct osf1_sigaltstack_args *uap;
|
|
|
|
{
|
2003-04-22 18:23:49 +00:00
|
|
|
struct osf1_sigaltstack oss;
|
|
|
|
struct sigaltstack nbss, obss, *nbssp;
|
1999-12-14 22:35:36 +00:00
|
|
|
int error;
|
|
|
|
|
2003-04-22 18:23:49 +00:00
|
|
|
if (uap->nss != NULL) {
|
|
|
|
if ((error = copyin(uap->nss, &oss, sizeof(oss))) != 0)
|
|
|
|
return (error);
|
|
|
|
osf1_to_bsd_sigaltstack(&oss, &nbss);
|
|
|
|
nbssp = &nbss;
|
|
|
|
} else
|
|
|
|
nbssp = NULL;
|
|
|
|
error = kern_sigaltstack(td, nbssp, &obss);
|
|
|
|
if (error == 0 && uap->oss != NULL) {
|
|
|
|
bsd_to_osf1_sigaltstack(&obss, &oss);
|
|
|
|
error = copyout(&oss, uap->oss, sizeof(oss));
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
2003-04-22 18:23:49 +00:00
|
|
|
return (error);
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-20 04:56:42 +00:00
|
|
|
osf1_signal(td, uap)
|
|
|
|
register struct thread *td;
|
1999-12-14 22:35:36 +00:00
|
|
|
struct osf1_signal_args *uap;
|
|
|
|
{
|
2001-09-20 04:56:42 +00:00
|
|
|
struct proc *p;
|
1999-12-14 22:35:36 +00:00
|
|
|
int error, signum;
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
signum = OSF1_SIGNO(uap->signum);
|
1999-12-14 22:35:36 +00:00
|
|
|
if (signum <= 0 || signum > OSF1_NSIG) {
|
2002-12-14 01:56:26 +00:00
|
|
|
if (OSF1_SIGCALL(uap->signum) == OSF1_SIGNAL_MASK ||
|
|
|
|
OSF1_SIGCALL(uap->signum) == OSF1_SIGDEFER_MASK)
|
2001-09-20 04:56:42 +00:00
|
|
|
td->td_retval[0] = -1;
|
1999-12-14 22:35:36 +00:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
switch (OSF1_SIGCALL(uap->signum)) {
|
1999-12-14 22:35:36 +00:00
|
|
|
case OSF1_SIGDEFER_MASK:
|
|
|
|
/*
|
|
|
|
* sigset is identical to signal() except
|
|
|
|
* that SIG_HOLD is allowed as
|
|
|
|
* an action.
|
|
|
|
*/
|
2003-04-22 18:23:49 +00:00
|
|
|
if ((u_long)uap->handler == OSF1_SIG_HOLD) {
|
1999-12-14 22:35:36 +00:00
|
|
|
sigset_t mask;
|
|
|
|
|
|
|
|
SIGEMPTYSET(mask);
|
|
|
|
SIGADDSET(mask, signum);
|
2003-04-22 18:23:49 +00:00
|
|
|
return (kern_sigprocmask(td, SIG_BLOCK, &mask, NULL,
|
|
|
|
0));
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
|
|
|
case OSF1_SIGNAL_MASK:
|
|
|
|
{
|
2003-04-22 18:23:49 +00:00
|
|
|
struct sigaction nbsa, obsa;
|
1999-12-14 22:35:36 +00:00
|
|
|
|
2003-04-22 18:23:49 +00:00
|
|
|
nbsa.sa_handler = uap->handler;
|
|
|
|
SIGEMPTYSET(nbsa.sa_mask);
|
|
|
|
nbsa.sa_flags = 0;
|
1999-12-14 22:35:36 +00:00
|
|
|
#if 0
|
|
|
|
if (signum != SIGALRM)
|
2003-04-22 18:23:49 +00:00
|
|
|
nbsa.sa_flags = SA_RESTART;
|
1999-12-14 22:35:36 +00:00
|
|
|
#endif
|
2003-04-22 18:23:49 +00:00
|
|
|
error = kern_sigaction(td, signum, &nbsa, &obsa, 0);
|
|
|
|
if (error != 0) {
|
1999-12-14 22:35:36 +00:00
|
|
|
DPRINTF("signal: sigaction failed: %d\n",
|
|
|
|
error);
|
2001-09-20 04:56:42 +00:00
|
|
|
td->td_retval[0] = -1;
|
2003-04-22 18:23:49 +00:00
|
|
|
return (error);
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
2003-04-22 18:23:49 +00:00
|
|
|
td->td_retval[0] = (long)obsa.sa_handler;
|
1999-12-14 22:35:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case OSF1_SIGHOLD_MASK:
|
|
|
|
{
|
|
|
|
sigset_t set;
|
|
|
|
|
|
|
|
SIGEMPTYSET(set);
|
|
|
|
SIGADDSET(set, signum);
|
2003-04-22 18:23:49 +00:00
|
|
|
return (kern_sigprocmask(td, SIG_BLOCK, &set, NULL, 0));
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case OSF1_SIGRELSE_MASK:
|
|
|
|
{
|
|
|
|
sigset_t set;
|
|
|
|
|
|
|
|
SIGEMPTYSET(set);
|
|
|
|
SIGADDSET(set, signum);
|
2003-04-22 18:23:49 +00:00
|
|
|
return (kern_sigprocmask(td, SIG_UNBLOCK, &set, NULL,
|
|
|
|
0));
|
1999-12-14 22:35:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case OSF1_SIGIGNORE_MASK:
|
|
|
|
{
|
2003-04-22 18:23:49 +00:00
|
|
|
struct sigaction sa;
|
1999-12-14 22:35:36 +00:00
|
|
|
|
|
|
|
sa.sa_handler = SIG_IGN;
|
|
|
|
SIGEMPTYSET(sa.sa_mask);
|
|
|
|
sa.sa_flags = 0;
|
2003-04-22 18:23:49 +00:00
|
|
|
error = kern_sigaction(td, signum, &sa, NULL, 0);
|
|
|
|
if (error != 0)
|
1999-12-14 22:35:36 +00:00
|
|
|
DPRINTF(("sigignore: sigaction failed\n"));
|
2003-04-22 18:23:49 +00:00
|
|
|
return (error);
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case OSF1_SIGPAUSE_MASK:
|
|
|
|
{
|
2003-04-22 18:23:49 +00:00
|
|
|
sigset_t mask;
|
1999-12-14 22:35:36 +00:00
|
|
|
|
2003-04-22 18:23:49 +00:00
|
|
|
p = td->td_proc;
|
2001-01-24 10:27:11 +00:00
|
|
|
PROC_LOCK(p);
|
2003-04-22 18:23:49 +00:00
|
|
|
mask = td->td_sigmask;
|
2001-01-24 10:27:11 +00:00
|
|
|
PROC_UNLOCK(p);
|
2003-04-22 18:23:49 +00:00
|
|
|
SIGDELSET(mask, signum);
|
|
|
|
return kern_sigsuspend(td, mask);
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return ENOSYS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-20 04:56:42 +00:00
|
|
|
osf1_sigprocmask(td, uap)
|
|
|
|
register struct thread *td;
|
1999-12-14 22:35:36 +00:00
|
|
|
struct osf1_sigprocmask_args /* {
|
|
|
|
syscallarg(int) how;
|
|
|
|
syscallarg(osf1_sigset_t *) set;
|
|
|
|
} */ *uap;
|
|
|
|
{
|
|
|
|
osf1_sigset_t oss;
|
2003-04-22 18:23:49 +00:00
|
|
|
sigset_t obss, nbss;
|
|
|
|
int error;
|
1999-12-14 22:35:36 +00:00
|
|
|
|
2003-04-22 18:23:49 +00:00
|
|
|
/* OSF/1 sigprocmask flag values match FreeBSD flag values. */
|
|
|
|
osf1_to_bsd_sigset(&uap->mask, &nbss);
|
|
|
|
error = kern_sigprocmask(td, uap->how, &nbss, &obss, 0);
|
|
|
|
if (error == 0) {
|
|
|
|
bsd_to_osf1_sigset(&obss, &oss);
|
|
|
|
td->td_retval[0] = oss;
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
2003-04-22 18:23:49 +00:00
|
|
|
return (error);
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-20 04:56:42 +00:00
|
|
|
osf1_sigpending(td, uap)
|
|
|
|
register struct thread *td;
|
1999-12-14 22:35:36 +00:00
|
|
|
struct osf1_sigpending_args /* {
|
|
|
|
syscallarg(osf1_sigset_t *) mask;
|
|
|
|
} */ *uap;
|
|
|
|
{
|
2001-09-20 04:56:42 +00:00
|
|
|
struct proc *p;
|
1999-12-14 22:35:36 +00:00
|
|
|
osf1_sigset_t oss;
|
|
|
|
sigset_t bss;
|
|
|
|
|
2001-09-20 04:56:42 +00:00
|
|
|
p = td->td_proc;
|
2001-01-24 10:27:11 +00:00
|
|
|
PROC_LOCK(p);
|
2003-03-31 22:49:17 +00:00
|
|
|
bss = td->td_siglist;
|
|
|
|
SIGSETOR(bss, p->p_siglist);
|
|
|
|
SIGSETAND(bss, td->td_sigmask);
|
2001-01-24 10:27:11 +00:00
|
|
|
PROC_UNLOCK(p);
|
1999-12-14 22:35:36 +00:00
|
|
|
bsd_to_osf1_sigset(&bss, &oss);
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
return copyout(&oss, uap->mask, sizeof(oss));
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-20 04:56:42 +00:00
|
|
|
osf1_sigsuspend(td, uap)
|
|
|
|
register struct thread *td;
|
1999-12-14 22:35:36 +00:00
|
|
|
struct osf1_sigsuspend_args /* {
|
|
|
|
syscallarg(osf1_sigset_t *) ss;
|
|
|
|
} */ *uap;
|
|
|
|
{
|
|
|
|
osf1_sigset_t oss;
|
|
|
|
sigset_t bss;
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
oss = uap->ss;
|
1999-12-14 22:35:36 +00:00
|
|
|
osf1_to_bsd_sigset(&oss, &bss);
|
2003-04-22 18:23:49 +00:00
|
|
|
return kern_sigsuspend(td, bss);
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-20 04:56:42 +00:00
|
|
|
osf1_kill(td, uap)
|
|
|
|
register struct thread *td;
|
1999-12-14 22:35:36 +00:00
|
|
|
struct osf1_kill_args /* {
|
|
|
|
syscallarg(int) pid;
|
|
|
|
syscallarg(int) signum;
|
|
|
|
} */ *uap;
|
|
|
|
{
|
|
|
|
struct kill_args ka;
|
|
|
|
|
2002-12-14 01:56:26 +00:00
|
|
|
ka.pid = uap->pid;
|
|
|
|
ka.signum = uap->signum;
|
2001-09-20 04:56:42 +00:00
|
|
|
return kill(td, &ka);
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send an interrupt to process.
|
|
|
|
*
|
|
|
|
* Stack is set up to allow sigcode stored at top to call routine,
|
|
|
|
* followed by kcall to sigreturn routine below. After sigreturn resets
|
|
|
|
* the signal mask, the stack, and the frame pointer, it returns to the
|
|
|
|
* user specified pc, psl.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
osf1_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
|
|
|
{
|
|
|
|
int fsize, oonstack, rndfsize;
|
2001-09-20 04:56:42 +00:00
|
|
|
struct thread *td;
|
1999-12-14 22:35:36 +00:00
|
|
|
struct proc *p;
|
|
|
|
osiginfo_t *sip, ksi;
|
|
|
|
struct trapframe *frame;
|
|
|
|
struct sigacts *psp;
|
|
|
|
|
2001-09-20 04:56:42 +00:00
|
|
|
td = curthread;
|
|
|
|
p = td->td_proc;
|
2001-09-23 06:16:01 +00:00
|
|
|
PROC_LOCK_ASSERT(p, MA_OWNED);
|
1999-12-14 22:35:36 +00:00
|
|
|
psp = p->p_sigacts;
|
|
|
|
|
2001-09-20 04:56:42 +00:00
|
|
|
frame = td->td_frame;
|
2000-11-30 05:23:49 +00:00
|
|
|
oonstack = sigonstack(alpha_pal_rdusp());
|
1999-12-14 22:35:36 +00:00
|
|
|
fsize = sizeof ksi;
|
|
|
|
rndfsize = ((fsize + 15) / 16) * 16;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate and validate space for the signal handler context.
|
|
|
|
* Note that if the stack is in P0 space, the call to grow() is a nop,
|
|
|
|
* and the useracc() check will fail if the process has not already
|
|
|
|
* allocated the space with a `brk'.
|
|
|
|
*/
|
|
|
|
if ((p->p_flag & P_ALTSTACK) && !oonstack &&
|
|
|
|
SIGISMEMBER(psp->ps_sigonstack, sig)) {
|
|
|
|
sip = (osiginfo_t *)((caddr_t)p->p_sigstk.ss_sp +
|
|
|
|
p->p_sigstk.ss_size - rndfsize);
|
|
|
|
p->p_sigstk.ss_flags |= SS_ONSTACK;
|
|
|
|
} else
|
|
|
|
sip = (osiginfo_t *)(alpha_pal_rdusp() - rndfsize);
|
2001-01-24 10:27:11 +00:00
|
|
|
PROC_UNLOCK(p);
|
1999-12-14 22:35:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Build the signal context to be used by sigreturn.
|
|
|
|
*/
|
2000-11-30 05:23:49 +00:00
|
|
|
ksi.si_sc.sc_onstack = (oonstack) ? 1 : 0;
|
2000-11-10 23:00:54 +00:00
|
|
|
bsd_to_osf1_sigset(mask, &ksi.si_sc.sc_mask);
|
1999-12-14 22:35:36 +00:00
|
|
|
ksi.si_sc.sc_pc = frame->tf_regs[FRAME_PC];
|
|
|
|
ksi.si_sc.sc_ps = frame->tf_regs[FRAME_PS];
|
|
|
|
|
|
|
|
/* copy the registers. */
|
2001-09-20 04:56:42 +00:00
|
|
|
fill_regs(td, (struct reg *)ksi.si_sc.sc_regs);
|
1999-12-14 22:35:36 +00:00
|
|
|
ksi.si_sc.sc_regs[R_ZERO] = 0xACEDBADE; /* magic number */
|
|
|
|
ksi.si_sc.sc_regs[R_SP] = alpha_pal_rdusp();
|
|
|
|
|
|
|
|
/* save the floating-point state, if necessary, then copy it. */
|
2001-09-20 04:56:42 +00:00
|
|
|
alpha_fpstate_save(td, 1); /* XXX maybe write=0 */
|
2002-07-31 19:37:03 +00:00
|
|
|
ksi.si_sc.sc_ownedfp = td->td_md.md_flags & MDTD_FPUSED;
|
2001-09-20 04:56:42 +00:00
|
|
|
bcopy(&td->td_pcb->pcb_fp, (struct fpreg *)ksi.si_sc.sc_fpregs,
|
1999-12-14 22:35:36 +00:00
|
|
|
sizeof(struct fpreg));
|
2001-09-20 04:56:42 +00:00
|
|
|
ksi.si_sc.sc_fp_control = td->td_pcb->pcb_fp_control;
|
1999-12-14 22:35:36 +00:00
|
|
|
bzero(ksi.si_sc.sc_reserved, sizeof ksi.si_sc.sc_reserved); /* XXX */
|
|
|
|
ksi.si_sc.sc_xxx1[0] = 0; /* XXX */
|
|
|
|
ksi.si_sc.sc_xxx1[1] = 0; /* XXX */
|
|
|
|
ksi.si_sc.sc_traparg_a0 = frame->tf_regs[FRAME_TRAPARG_A0];
|
|
|
|
ksi.si_sc.sc_traparg_a1 = frame->tf_regs[FRAME_TRAPARG_A1];
|
|
|
|
ksi.si_sc.sc_traparg_a2 = frame->tf_regs[FRAME_TRAPARG_A2];
|
|
|
|
ksi.si_sc.sc_xxx2[0] = 0; /* XXX */
|
|
|
|
ksi.si_sc.sc_xxx2[1] = 0; /* XXX */
|
|
|
|
ksi.si_sc.sc_xxx2[2] = 0; /* XXX */
|
|
|
|
/* Fill in POSIX parts */
|
|
|
|
ksi.si_signo = sig;
|
|
|
|
ksi.si_code = code;
|
|
|
|
ksi.si_value.sigval_ptr = NULL; /* XXX */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* copy the frame out to userland.
|
|
|
|
*/
|
2002-04-05 00:52:15 +00:00
|
|
|
if (copyout((caddr_t)&ksi, (caddr_t)sip, fsize) != 0) {
|
|
|
|
/*
|
|
|
|
* Process has trashed its stack; give it an illegal
|
|
|
|
* instruction to halt it in its tracks.
|
|
|
|
*/
|
|
|
|
PROC_LOCK(p);
|
2003-03-31 21:40:47 +00:00
|
|
|
sigexit(td, SIGILL);
|
2002-04-05 00:52:15 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-12-14 22:35:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the registers to return to sigcode.
|
|
|
|
*/
|
|
|
|
if (osf1_sigdbg)
|
|
|
|
uprintf("attempting to call osf1 sigtramp\n");
|
2001-09-20 04:56:42 +00:00
|
|
|
frame->tf_regs[FRAME_PC] = (u_int64_t)td->td_md.osf_sigtramp;
|
1999-12-14 22:35:36 +00:00
|
|
|
frame->tf_regs[FRAME_A0] = sig;
|
|
|
|
frame->tf_regs[FRAME_A1] = code;
|
|
|
|
frame->tf_regs[FRAME_A2] = (u_int64_t)sip;
|
|
|
|
frame->tf_regs[FRAME_A3] = (u_int64_t)catcher; /* a3 is pv */
|
2001-02-21 18:48:06 +00:00
|
|
|
frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */
|
1999-12-14 22:35:36 +00:00
|
|
|
alpha_pal_wrusp((unsigned long)sip);
|
2001-09-06 22:20:41 +00:00
|
|
|
PROC_LOCK(p);
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* System call to cleanup state after a signal has been taken. Reset signal
|
|
|
|
* mask and stack state from context left by sendsig (above). Return to
|
|
|
|
* previous pc and psl as specified by context left by sendsig. Check
|
|
|
|
* carefully to make sure that the user has not modified the state to gain
|
|
|
|
* improper privileges.
|
|
|
|
*/
|
|
|
|
int
|
2001-09-20 04:56:42 +00:00
|
|
|
osf1_sigreturn(struct thread *td,
|
1999-12-14 22:35:36 +00:00
|
|
|
struct osf1_sigreturn_args /* {
|
|
|
|
struct osigcontext *sigcntxp;
|
|
|
|
} */ *uap)
|
|
|
|
{
|
|
|
|
struct osigcontext ksc, *scp;
|
2001-09-20 04:56:42 +00:00
|
|
|
struct proc *p;
|
1999-12-14 22:35:36 +00:00
|
|
|
|
2001-09-20 04:56:42 +00:00
|
|
|
p = td->td_proc;
|
1999-12-14 22:35:36 +00:00
|
|
|
scp = uap->sigcntxp;
|
2003-04-29 06:33:03 +00:00
|
|
|
|
1999-12-14 22:35:36 +00:00
|
|
|
/*
|
2003-04-29 06:33:03 +00:00
|
|
|
* Fetch the entire context structure at once for speed.
|
1999-12-14 22:35:36 +00:00
|
|
|
*/
|
2003-04-29 06:33:03 +00:00
|
|
|
if (copyin((caddr_t)scp, (caddr_t)&ksc, sizeof ksc))
|
1999-12-14 22:35:36 +00:00
|
|
|
return (EFAULT);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore the user-supplied information.
|
|
|
|
*/
|
2001-01-24 10:27:11 +00:00
|
|
|
PROC_LOCK(p);
|
1999-12-14 22:35:36 +00:00
|
|
|
if (ksc.sc_onstack)
|
|
|
|
p->p_sigstk.ss_flags |= SS_ONSTACK;
|
|
|
|
else
|
|
|
|
p->p_sigstk.ss_flags &= ~SS_ONSTACK;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* longjmp is still implemented by calling osigreturn. The new
|
|
|
|
* sigmask is stored in sc_reserved, sc_mask is only used for
|
|
|
|
* backward compatibility.
|
|
|
|
*/
|
2003-03-31 22:49:17 +00:00
|
|
|
osf1_to_bsd_sigset(&ksc.sc_mask, &td->td_sigmask);
|
|
|
|
SIG_CANTMASK(td->td_sigmask);
|
|
|
|
signotify(td);
|
2001-01-24 10:27:11 +00:00
|
|
|
PROC_UNLOCK(p);
|
1999-12-14 22:35:36 +00:00
|
|
|
|
2001-09-20 04:56:42 +00:00
|
|
|
set_regs(td, (struct reg *)ksc.sc_regs);
|
|
|
|
td->td_frame->tf_regs[FRAME_PC] = ksc.sc_pc;
|
|
|
|
td->td_frame->tf_regs[FRAME_PS] =
|
1999-12-14 22:35:36 +00:00
|
|
|
(ksc.sc_ps | ALPHA_PSL_USERSET) & ~ALPHA_PSL_USERCLR;
|
2001-09-20 04:56:42 +00:00
|
|
|
td->td_frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */
|
1999-12-14 22:35:36 +00:00
|
|
|
|
|
|
|
alpha_pal_wrusp(ksc.sc_regs[R_SP]);
|
|
|
|
|
|
|
|
/* XXX ksc.sc_ownedfp ? */
|
2001-09-20 04:56:42 +00:00
|
|
|
alpha_fpstate_drop(td);
|
|
|
|
bcopy((struct fpreg *)ksc.sc_fpregs, &td->td_pcb->pcb_fp,
|
1999-12-14 22:35:36 +00:00
|
|
|
sizeof(struct fpreg));
|
2001-09-20 04:56:42 +00:00
|
|
|
td->td_pcb->pcb_fp_control = ksc.sc_fp_control;
|
1999-12-14 22:35:36 +00:00
|
|
|
return (EJUSTRETURN);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-20 04:56:42 +00:00
|
|
|
osf1_osigstack(td, uap)
|
|
|
|
register struct thread *td;
|
1999-12-14 22:35:36 +00:00
|
|
|
struct osf1_osigstack_args /* {
|
|
|
|
struct sigstack *nss;
|
|
|
|
struct sigstack *oss;
|
|
|
|
} */ *uap;
|
|
|
|
{
|
|
|
|
|
|
|
|
/* uprintf("osf1_osigstack: oss = %p, nss = %p",uap->oss, uap->nss);
|
|
|
|
uprintf(" stack ptr = %p\n",p->p_sigacts->ps_sigstk.ss_sp);*/
|
2002-10-25 19:10:58 +00:00
|
|
|
return(osigstack(td, (struct osigstack_args *)uap));
|
1999-12-14 22:35:36 +00:00
|
|
|
}
|