Add support for Linux SA_RESTORER on amd64.
This commit is contained in:
parent
5888b16eef
commit
53fb6703e5
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_signal.h,v 1.4 2002/11/26 18:43:20 christos Exp $ */
|
||||
/* $NetBSD: linux_signal.h,v 1.5 2005/05/19 21:16:29 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -97,12 +97,13 @@
|
||||
#define LINUX_SA_RESETHAND 0x00000010
|
||||
#define LINUX_SA_NOCLDWAIT 0x00000020
|
||||
#define LINUX_SA_SIGINFO 0x00000040
|
||||
#define LINUX_SA_RESTORER 0x04000000
|
||||
|
||||
#define LINUX_SA_NOMASK LINUX_SA_NODEFER
|
||||
#define LINUX_SA_ONESHOT LINUX_SA_RESETHAND
|
||||
#define LINUX_SA_INTERRUPT 0x20000000 /* Ignore this */
|
||||
|
||||
#define LINUX_SA_ALLBITS 0x2000007f
|
||||
#define LINUX_SA_ALLBITS 0x2400007f
|
||||
|
||||
#define LINUX_SIG_BLOCK 1
|
||||
#define LINUX_SIG_UNBLOCK 2
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_machdep.c,v 1.2 2005/05/15 21:43:08 fvdl Exp $ */
|
||||
/* $NetBSD: linux_machdep.c,v 1.3 2005/05/19 21:16:29 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.2 2005/05/15 21:43:08 fvdl Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.3 2005/05/19 21:16:29 manu Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
@ -184,7 +184,10 @@ linux_sendsig(ksi, mask)
|
||||
sfp = (struct linux_rt_sigframe *)sp;
|
||||
|
||||
bzero(&sigframe, sizeof(sigframe));
|
||||
sigframe.pretcode = (char *)ps->sa_sigdesc[sig].sd_tramp;
|
||||
if (ps->sa_sigdesc[sig].sd_vers != 0)
|
||||
sigframe.pretcode = (char *)ps->sa_sigdesc[sig].sd_tramp;
|
||||
else
|
||||
sigframe.pretcode = NULL;
|
||||
|
||||
/*
|
||||
* The user context
|
||||
@ -272,8 +275,11 @@ linux_sendsig(ksi, mask)
|
||||
|
||||
/*
|
||||
* Setup registers
|
||||
* XXX for an unknown reason, the stack is shifted of 24 bytes
|
||||
* when the signal handler is called. The +24 below is a dirty
|
||||
* workaround, and the real problem should be fixed.
|
||||
*/
|
||||
buildcontext(l, catcher, sp);
|
||||
buildcontext(l, catcher, sp + 24);
|
||||
tf->tf_rdi = sigframe.info.lsi_signo;
|
||||
tf->tf_rax = 0;
|
||||
tf->tf_rsi = (long)&sfp->info;
|
||||
|
101
sys/compat/linux/arch/amd64/linux_sigarray.c
Normal file
101
sys/compat/linux/arch/amd64/linux_sigarray.c
Normal file
@ -0,0 +1,101 @@
|
||||
/* $NetBSD: linux_sigarray.c,v 1.1 2005/05/19 21:16:29 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
|
||||
*
|
||||
* 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 Emmanuel Dreyfus
|
||||
* 4. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
__KERNEL_RCSID(1, "$NetBSD: linux_sigarray.c,v 1.1 2005/05/19 21:16:29 manu Exp $");
|
||||
|
||||
const int linux_to_native_signo[LINUX__NSIG] = {
|
||||
0, /* 0 */
|
||||
SIGHUP, /* 1 */
|
||||
SIGINT, /* 2 */
|
||||
SIGQUIT, /* 3 */
|
||||
SIGILL, /* 4 */
|
||||
SIGTRAP, /* 5 */
|
||||
SIGABRT, /* 6 */
|
||||
SIGBUS, /* 7 */
|
||||
SIGFPE, /* 8 */
|
||||
SIGKILL, /* 9 */
|
||||
SIGUSR1, /* 10 */
|
||||
SIGSEGV, /* 11 */
|
||||
SIGUSR2, /* 12 */
|
||||
SIGPIPE, /* 13 */
|
||||
SIGALRM, /* 14 */
|
||||
SIGTERM, /* 15 */
|
||||
0, /* 16 SIGSTKFLT */
|
||||
SIGCHLD, /* 17 */
|
||||
SIGCONT, /* 18 */
|
||||
SIGSTOP, /* 19 */
|
||||
SIGTSTP, /* 20 */
|
||||
SIGTTIN, /* 21 */
|
||||
SIGTTOU, /* 22 */
|
||||
SIGURG, /* 23 */
|
||||
SIGXCPU, /* 24 */
|
||||
SIGXFSZ, /* 25 */
|
||||
SIGVTALRM, /* 26 */
|
||||
SIGPROF, /* 27 */
|
||||
SIGWINCH, /* 28 */
|
||||
SIGIO, /* 29 */
|
||||
SIGPWR, /* 30 */
|
||||
SIGSYS, /* 31 */
|
||||
SIGRTMIN + 0, /* 32 */
|
||||
SIGRTMIN + 1, /* 33 */
|
||||
SIGRTMIN + 2, /* 34 */
|
||||
SIGRTMIN + 3, /* 35 */
|
||||
SIGRTMIN + 4, /* 36 */
|
||||
SIGRTMIN + 5, /* 37 */
|
||||
SIGRTMIN + 6, /* 38 */
|
||||
SIGRTMIN + 7, /* 39 */
|
||||
SIGRTMIN + 8, /* 40 */
|
||||
SIGRTMIN + 9, /* 41 */
|
||||
SIGRTMIN + 10, /* 42 */
|
||||
SIGRTMIN + 11, /* 43 */
|
||||
SIGRTMIN + 12, /* 44 */
|
||||
SIGRTMIN + 13, /* 45 */
|
||||
SIGRTMIN + 14, /* 46 */
|
||||
SIGRTMIN + 15, /* 47 */
|
||||
SIGRTMIN + 16, /* 48 */
|
||||
SIGRTMIN + 17, /* 49 */
|
||||
SIGRTMIN + 18, /* 50 */
|
||||
SIGRTMIN + 19, /* 51 */
|
||||
SIGRTMIN + 20, /* 52 */
|
||||
SIGRTMIN + 21, /* 53 */
|
||||
SIGRTMIN + 22, /* 54 */
|
||||
SIGRTMIN + 23, /* 55 */
|
||||
SIGRTMIN + 24, /* 56 */
|
||||
SIGRTMIN + 25, /* 57 */
|
||||
SIGRTMIN + 26, /* 58 */
|
||||
SIGRTMIN + 27, /* 59 */
|
||||
SIGRTMIN + 28, /* 60 */
|
||||
SIGRTMIN + 29, /* 61 */
|
||||
SIGRTMIN + 30, /* 62 */
|
||||
0 /* 63 */
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_signal.h,v 1.1 2005/05/03 16:26:30 manu Exp $ */
|
||||
/* $NetBSD: linux_signal.h,v 1.2 2005/05/19 21:16:29 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
|
||||
@ -76,11 +76,12 @@
|
||||
#define LINUX_SA_NOCLDSTOP 0x00000001
|
||||
#define LINUX_SA_NOCLDWAIT 0x00000002
|
||||
#define LINUX_SA_SIGINFO 0x00000004
|
||||
#define LINUX_SA_RESTORER 0x04000000
|
||||
#define LINUX_SA_ONSTACK 0x08000000
|
||||
#define LINUX_SA_RESTART 0x10000000
|
||||
#define LINUX_SA_NOMASK 0x40000000
|
||||
#define LINUX_SA_ONESHOT 0x80000000
|
||||
#define LINUX_SA_ALLBITS 0xd8000007
|
||||
#define LINUX_SA_ALLBITS 0xdc000007
|
||||
|
||||
#define LINUX_SIG_BLOCK 0
|
||||
#define LINUX_SIG_UNBLOCK 1
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_signal.h,v 1.4 2002/11/26 18:43:21 christos Exp $ */
|
||||
/* $NetBSD: linux_signal.h,v 1.5 2005/05/19 21:16:29 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
@ -90,12 +90,13 @@
|
||||
#define LINUX_SA_NOCLDSTOP 0x00000001
|
||||
#define LINUX_SA_NOCLDWAIT 0x00000002
|
||||
#define LINUX_SA_SIGINFO 0x00000004
|
||||
#define LINUX_SA_RESTORER 0x04000000
|
||||
#define LINUX_SA_ONSTACK 0x08000000
|
||||
#define LINUX_SA_RESTART 0x10000000
|
||||
#define LINUX_SA_INTERRUPT 0x20000000
|
||||
#define LINUX_SA_NOMASK 0x40000000
|
||||
#define LINUX_SA_ONESHOT 0x80000000
|
||||
#define LINUX_SA_ALLBITS 0xf8000001
|
||||
#define LINUX_SA_ALLBITS 0xfc000007
|
||||
|
||||
typedef void (*linux_handler_t) __P((int));
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_signal.h,v 1.6 2005/02/26 23:10:19 perry Exp $ */
|
||||
/* $NetBSD: linux_signal.h,v 1.7 2005/05/19 21:16:29 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998, 2001 The NetBSD Foundation, Inc.
|
||||
@ -95,6 +95,7 @@
|
||||
#define LINUX_SA_NOCLDSTOP 0x00000001
|
||||
#define LINUX_SA_NOCLDWAIT 0x00000002
|
||||
#define LINUX_SA_SIGINFO 0x00000004
|
||||
#define LINUX_SA_RESTORER 0x04000000
|
||||
#define LINUX_SA_ONSTACK 0x08000000
|
||||
#define LINUX_SA_RESTART 0x10000000
|
||||
#define LINUX_SA_INTERRUPT 0x20000000
|
||||
@ -102,7 +103,7 @@
|
||||
#define LINUX_SA_RESETHAND 0x80000000
|
||||
#define LINUX_SA_NOMASK LINUX_SA_NODEFER
|
||||
#define LINUX_SA_ONESHOT LINUX_SA_RESETHAND
|
||||
#define LINUX_SA_ALLBITS 0xf8000001 /* XXX from i386, not in ppc. */
|
||||
#define LINUX_SA_ALLBITS 0xfc000007
|
||||
|
||||
typedef void (*linux_handler_t) __P((int));
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_signal.c,v 1.45 2005/05/16 16:00:31 fvdl Exp $ */
|
||||
/* $NetBSD: linux_signal.c,v 1.46 2005/05/19 21:16:29 manu Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@ -54,7 +54,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.45 2005/05/16 16:00:31 fvdl Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.46 2005/05/19 21:16:29 manu Exp $");
|
||||
|
||||
#define COMPAT_LINUX 1
|
||||
|
||||
@ -219,8 +219,7 @@ linux_to_native_sigflags(lsf)
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert between Linux and BSD sigaction structures. Linux sometimes
|
||||
* has one extra field (sa_restorer) which we don't support.
|
||||
* Convert between Linux and BSD sigaction structures.
|
||||
*/
|
||||
void
|
||||
linux_old_to_native_sigaction(bsa, lsa)
|
||||
@ -230,14 +229,6 @@ linux_old_to_native_sigaction(bsa, lsa)
|
||||
bsa->sa_handler = lsa->linux_sa_handler;
|
||||
linux_old_to_native_sigset(&bsa->sa_mask, &lsa->linux_sa_mask);
|
||||
bsa->sa_flags = linux_to_native_sigflags(lsa->linux_sa_flags);
|
||||
#ifndef __alpha__
|
||||
/*
|
||||
* XXX: On the alpha sa_restorer is elsewhere.
|
||||
*/
|
||||
if (lsa->linux_sa_restorer != NULL)
|
||||
DPRINTF(("linux_old_to_native_sigaction: "
|
||||
"sa_restorer ignored\n"));
|
||||
#endif /* !__alpha__ */
|
||||
}
|
||||
|
||||
void
|
||||
@ -262,10 +253,6 @@ linux_to_native_sigaction(bsa, lsa)
|
||||
bsa->sa_handler = lsa->linux_sa_handler;
|
||||
linux_to_native_sigset(&bsa->sa_mask, &lsa->linux_sa_mask);
|
||||
bsa->sa_flags = linux_to_native_sigflags(lsa->linux_sa_flags);
|
||||
#ifndef __alpha__
|
||||
if (lsa->linux_sa_restorer != 0)
|
||||
DPRINTF(("linux_to_native_sigaction: sa_restorer ignored\n"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -304,6 +291,11 @@ linux_sys_rt_sigaction(l, v, retval)
|
||||
struct linux_sigaction nlsa, olsa;
|
||||
struct sigaction nbsa, obsa;
|
||||
int error, sig;
|
||||
#if defined __amd64__
|
||||
void *tramp = NULL;
|
||||
int vers = 0;
|
||||
struct sigacts *ps = p->p_sigacts;
|
||||
#endif
|
||||
|
||||
if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t))
|
||||
return (EINVAL);
|
||||
@ -314,6 +306,7 @@ linux_sys_rt_sigaction(l, v, retval)
|
||||
return (error);
|
||||
linux_to_native_sigaction(&nbsa, &nlsa);
|
||||
}
|
||||
|
||||
sig = SCARG(uap, signum);
|
||||
if (sig < 0 || sig >= LINUX__NSIG)
|
||||
return (EINVAL);
|
||||
@ -323,15 +316,30 @@ linux_sys_rt_sigaction(l, v, retval)
|
||||
sigemptyset(&obsa.sa_mask);
|
||||
obsa.sa_flags = 0;
|
||||
} else {
|
||||
#if defined __amd64__
|
||||
if (nlsa.linux_sa_flags & LINUX_SA_RESTORER) {
|
||||
if ((tramp = nlsa.linux_sa_restorer) != NULL)
|
||||
vers = 2; /* XXX arch dependant */
|
||||
}
|
||||
#endif
|
||||
|
||||
error = sigaction1(p, linux_to_native_signo[sig],
|
||||
SCARG(uap, nsa) ? &nbsa : NULL,
|
||||
SCARG(uap, osa) ? &obsa : NULL,
|
||||
NULL, 0);
|
||||
tramp, vers);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
if (SCARG(uap, osa)) {
|
||||
native_to_linux_sigaction(&olsa, &obsa);
|
||||
|
||||
#if defined __amd64__
|
||||
if (ps->sa_sigdesc[sig].sd_vers != 0) {
|
||||
olsa.linux_sa_restorer = ps->sa_sigdesc[sig].sd_tramp;
|
||||
olsa.linux_sa_flags |= LINUX_SA_RESTORER;
|
||||
}
|
||||
#endif
|
||||
|
||||
error = copyout(&olsa, SCARG(uap, osa), sizeof(olsa));
|
||||
if (error)
|
||||
return (error);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: linux_signo.c,v 1.3 2002/04/03 17:18:21 christos Exp $ */
|
||||
/* $NetBSD: linux_signo.c,v 1.4 2005/05/19 21:16:29 manu Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_signo.c,v 1.3 2002/04/03 17:18:21 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_signo.c,v 1.4 2005/05/19 21:16:29 manu Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/signal.h>
|
||||
@ -136,6 +136,8 @@ const int native_to_linux_signo[NSIG];
|
||||
#include <compat/linux/arch/mips/linux_sigarray.c>
|
||||
#elif defined(__arm__)
|
||||
#include <compat/linux/arch/arm/linux_sigarray.c>
|
||||
#elif defined(__amd64__)
|
||||
#include <compat/linux/arch/amd64/linux_sigarray.c>
|
||||
#else
|
||||
const int linux_to_native_signo[NSIG];
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user