1995-06-25 17:32:43 +00:00
|
|
|
/*-
|
2018-02-16 15:00:14 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2017-11-27 15:13:23 +00:00
|
|
|
*
|
2012-01-15 13:23:18 +00:00
|
|
|
* Copyright (c) 1994-1995 Søren Schmidt
|
1995-06-25 17:32:43 +00:00
|
|
|
* 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
|
2018-02-16 15:00:14 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
1995-06-25 17:32:43 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2018-02-16 15:00:14 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY 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.
|
1995-06-25 17:32:43 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-10 21:29:12 +00:00
|
|
|
#include <sys/cdefs.h>
|
2005-02-13 19:50:57 +00:00
|
|
|
__FBSDID("$FreeBSD$");
|
2003-06-10 21:29:12 +00:00
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
2006-08-19 15:13:01 +00:00
|
|
|
#include <sys/sx.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/signalvar.h>
|
2002-09-01 22:30:27 +00:00
|
|
|
#include <sys/syscallsubr.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/sysproto.h>
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2008-10-19 10:02:26 +00:00
|
|
|
#include <security/audit/audit.h>
|
|
|
|
|
2006-03-19 11:10:33 +00:00
|
|
|
#include "opt_compat.h"
|
|
|
|
|
2005-01-14 04:44:56 +00:00
|
|
|
#ifdef COMPAT_LINUX32
|
2004-08-16 07:28:16 +00:00
|
|
|
#include <machine/../linux32/linux.h>
|
|
|
|
#include <machine/../linux32/linux32_proto.h>
|
2005-01-14 04:44:56 +00:00
|
|
|
#else
|
|
|
|
#include <machine/../linux/linux.h>
|
|
|
|
#include <machine/../linux/linux_proto.h>
|
2004-08-16 07:28:16 +00:00
|
|
|
#endif
|
2021-06-07 02:55:34 +00:00
|
|
|
#include <compat/linux/linux_mib.h>
|
2000-08-22 01:49:54 +00:00
|
|
|
#include <compat/linux/linux_signal.h>
|
2021-06-07 02:35:35 +00:00
|
|
|
#include <compat/linux/linux_timer.h>
|
2000-08-22 01:49:54 +00:00
|
|
|
#include <compat/linux/linux_util.h>
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#include <compat/linux/linux_emul.h>
|
2015-05-24 14:53:16 +00:00
|
|
|
#include <compat/linux/linux_misc.h>
|
|
|
|
|
|
|
|
static int linux_do_tkill(struct thread *td, struct thread *tdt,
|
|
|
|
ksiginfo_t *ksi);
|
2015-05-24 14:58:30 +00:00
|
|
|
static void sicode_to_lsicode(int si_code, int *lsi_code);
|
2021-06-10 11:51:30 +00:00
|
|
|
static int linux_common_rt_sigtimedwait(struct thread *,
|
|
|
|
l_sigset_t *, struct timespec *, l_siginfo_t *,
|
|
|
|
l_size_t);
|
2015-05-24 14:58:30 +00:00
|
|
|
|
1996-03-02 21:00:11 +00:00
|
|
|
static void
|
2001-09-08 19:07:04 +00:00
|
|
|
linux_to_bsd_sigaction(l_sigaction_t *lsa, struct sigaction *bsa)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2020-06-27 15:50:35 +00:00
|
|
|
unsigned long flags;
|
1999-09-29 15:12:18 +00:00
|
|
|
|
|
|
|
linux_to_bsd_sigset(&lsa->lsa_mask, &bsa->sa_mask);
|
2004-08-16 07:28:16 +00:00
|
|
|
bsa->sa_handler = PTRIN(lsa->lsa_handler);
|
1999-09-29 15:12:18 +00:00
|
|
|
bsa->sa_flags = 0;
|
2020-06-27 15:50:35 +00:00
|
|
|
|
|
|
|
flags = lsa->lsa_flags;
|
|
|
|
if (lsa->lsa_flags & LINUX_SA_NOCLDSTOP) {
|
|
|
|
flags &= ~LINUX_SA_NOCLDSTOP;
|
1999-09-29 15:12:18 +00:00
|
|
|
bsa->sa_flags |= SA_NOCLDSTOP;
|
2020-06-27 15:50:35 +00:00
|
|
|
}
|
|
|
|
if (lsa->lsa_flags & LINUX_SA_NOCLDWAIT) {
|
|
|
|
flags &= ~LINUX_SA_NOCLDWAIT;
|
1999-09-29 15:12:18 +00:00
|
|
|
bsa->sa_flags |= SA_NOCLDWAIT;
|
2020-06-27 15:50:35 +00:00
|
|
|
}
|
|
|
|
if (lsa->lsa_flags & LINUX_SA_SIGINFO) {
|
|
|
|
flags &= ~LINUX_SA_SIGINFO;
|
1999-09-29 15:12:18 +00:00
|
|
|
bsa->sa_flags |= SA_SIGINFO;
|
2020-06-27 15:50:35 +00:00
|
|
|
#ifdef notyet
|
|
|
|
/*
|
|
|
|
* XXX: We seem to be missing code to convert
|
|
|
|
* some of the fields in ucontext_t.
|
|
|
|
*/
|
|
|
|
linux_msg(curthread,
|
|
|
|
"partially unsupported sigaction flag SA_SIGINFO");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
if (lsa->lsa_flags & LINUX_SA_RESTORER) {
|
|
|
|
flags &= ~LINUX_SA_RESTORER;
|
2021-07-13 09:38:08 +00:00
|
|
|
/*
|
|
|
|
* We ignore the lsa_restorer and always use our own signal
|
|
|
|
* trampoline instead. It looks like SA_RESTORER is obsolete
|
|
|
|
* in Linux too - it doesn't seem to be used at all on arm64.
|
|
|
|
* In any case: see Linux sigreturn(2).
|
|
|
|
*/
|
2020-06-27 15:50:35 +00:00
|
|
|
}
|
|
|
|
if (lsa->lsa_flags & LINUX_SA_ONSTACK) {
|
|
|
|
flags &= ~LINUX_SA_ONSTACK;
|
1999-09-29 15:12:18 +00:00
|
|
|
bsa->sa_flags |= SA_ONSTACK;
|
2020-06-27 15:50:35 +00:00
|
|
|
}
|
|
|
|
if (lsa->lsa_flags & LINUX_SA_RESTART) {
|
|
|
|
flags &= ~LINUX_SA_RESTART;
|
1999-09-29 15:12:18 +00:00
|
|
|
bsa->sa_flags |= SA_RESTART;
|
2020-06-27 15:50:35 +00:00
|
|
|
}
|
2020-06-30 16:18:09 +00:00
|
|
|
if (lsa->lsa_flags & LINUX_SA_INTERRUPT) {
|
|
|
|
flags &= ~LINUX_SA_INTERRUPT;
|
|
|
|
/* Documented to be a "historical no-op". */
|
|
|
|
}
|
2020-06-27 15:50:35 +00:00
|
|
|
if (lsa->lsa_flags & LINUX_SA_ONESHOT) {
|
|
|
|
flags &= ~LINUX_SA_ONESHOT;
|
1999-09-29 15:12:18 +00:00
|
|
|
bsa->sa_flags |= SA_RESETHAND;
|
2020-06-27 15:50:35 +00:00
|
|
|
}
|
|
|
|
if (lsa->lsa_flags & LINUX_SA_NOMASK) {
|
|
|
|
flags &= ~LINUX_SA_NOMASK;
|
1999-09-29 15:12:18 +00:00
|
|
|
bsa->sa_flags |= SA_NODEFER;
|
2020-06-27 15:50:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flags != 0)
|
|
|
|
linux_msg(curthread, "unsupported sigaction flag %#lx", flags);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
1996-03-02 21:00:11 +00:00
|
|
|
static void
|
2001-09-08 19:07:04 +00:00
|
|
|
bsd_to_linux_sigaction(struct sigaction *bsa, l_sigaction_t *lsa)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
1999-09-29 15:12:18 +00:00
|
|
|
|
|
|
|
bsd_to_linux_sigset(&bsa->sa_mask, &lsa->lsa_mask);
|
2005-01-14 04:44:56 +00:00
|
|
|
#ifdef COMPAT_LINUX32
|
2004-08-16 07:28:16 +00:00
|
|
|
lsa->lsa_handler = (uintptr_t)bsa->sa_handler;
|
|
|
|
#else
|
1999-09-29 15:12:18 +00:00
|
|
|
lsa->lsa_handler = bsa->sa_handler;
|
2004-08-16 07:28:16 +00:00
|
|
|
#endif
|
|
|
|
lsa->lsa_restorer = 0; /* unsupported */
|
1999-09-29 15:12:18 +00:00
|
|
|
lsa->lsa_flags = 0;
|
|
|
|
if (bsa->sa_flags & SA_NOCLDSTOP)
|
|
|
|
lsa->lsa_flags |= LINUX_SA_NOCLDSTOP;
|
|
|
|
if (bsa->sa_flags & SA_NOCLDWAIT)
|
|
|
|
lsa->lsa_flags |= LINUX_SA_NOCLDWAIT;
|
|
|
|
if (bsa->sa_flags & SA_SIGINFO)
|
|
|
|
lsa->lsa_flags |= LINUX_SA_SIGINFO;
|
|
|
|
if (bsa->sa_flags & SA_ONSTACK)
|
|
|
|
lsa->lsa_flags |= LINUX_SA_ONSTACK;
|
|
|
|
if (bsa->sa_flags & SA_RESTART)
|
|
|
|
lsa->lsa_flags |= LINUX_SA_RESTART;
|
|
|
|
if (bsa->sa_flags & SA_RESETHAND)
|
|
|
|
lsa->lsa_flags |= LINUX_SA_ONESHOT;
|
|
|
|
if (bsa->sa_flags & SA_NODEFER)
|
|
|
|
lsa->lsa_flags |= LINUX_SA_NOMASK;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2000-08-22 01:49:54 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_do_sigaction(struct thread *td, int linux_sig, l_sigaction_t *linux_nsa,
|
2001-09-08 19:07:04 +00:00
|
|
|
l_sigaction_t *linux_osa)
|
1999-08-14 17:28:46 +00:00
|
|
|
{
|
2002-09-01 22:30:27 +00:00
|
|
|
struct sigaction act, oact, *nsa, *osa;
|
|
|
|
int error, sig;
|
1999-09-29 15:12:18 +00:00
|
|
|
|
2006-10-15 12:51:43 +00:00
|
|
|
if (!LINUX_SIG_VALID(linux_sig))
|
1999-09-29 15:12:18 +00:00
|
|
|
return (EINVAL);
|
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
osa = (linux_osa != NULL) ? &oact : NULL;
|
1999-09-29 15:12:18 +00:00
|
|
|
if (linux_nsa != NULL) {
|
2002-09-01 22:30:27 +00:00
|
|
|
nsa = &act;
|
1999-11-30 15:02:28 +00:00
|
|
|
linux_to_bsd_sigaction(linux_nsa, nsa);
|
2002-09-01 22:30:27 +00:00
|
|
|
} else
|
1999-09-29 15:12:18 +00:00
|
|
|
nsa = NULL;
|
2015-05-24 17:47:20 +00:00
|
|
|
sig = linux_to_bsd_signal(linux_sig);
|
1999-09-29 15:12:18 +00:00
|
|
|
|
2002-09-01 22:30:27 +00:00
|
|
|
error = kern_sigaction(td, sig, nsa, osa, 0);
|
1999-08-14 17:28:46 +00:00
|
|
|
if (error)
|
1999-09-29 15:12:18 +00:00
|
|
|
return (error);
|
|
|
|
|
1999-11-30 15:02:28 +00:00
|
|
|
if (linux_osa != NULL)
|
|
|
|
bsd_to_linux_sigaction(osa, linux_osa);
|
1999-08-14 17:28:46 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
return (0);
|
1999-08-14 17:28:46 +00:00
|
|
|
}
|
|
|
|
|
2015-05-24 15:43:53 +00:00
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_signal(struct thread *td, struct linux_signal_args *args)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
l_sigaction_t nsa, osa;
|
1999-09-29 15:12:18 +00:00
|
|
|
int error;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
nsa.lsa_handler = args->handler;
|
|
|
|
nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK;
|
|
|
|
LINUX_SIGEMPTYSET(nsa.lsa_mask);
|
1999-08-14 17:28:46 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
error = linux_do_sigaction(td, args->sig, &nsa, &osa);
|
2004-08-16 07:28:16 +00:00
|
|
|
td->td_retval[0] = (int)(intptr_t)osa.lsa_handler;
|
1999-08-14 17:28:46 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
return (error);
|
1999-08-14 17:28:46 +00:00
|
|
|
}
|
2015-05-24 15:43:53 +00:00
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
1999-08-14 17:28:46 +00:00
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_rt_sigaction(struct thread *td, struct linux_rt_sigaction_args *args)
|
1999-08-14 17:28:46 +00:00
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
l_sigaction_t nsa, osa;
|
1999-09-29 15:12:18 +00:00
|
|
|
int error;
|
1999-08-14 17:28:46 +00:00
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
if (args->sigsetsize != sizeof(l_sigset_t))
|
1999-09-29 15:12:18 +00:00
|
|
|
return (EINVAL);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
if (args->act != NULL) {
|
2001-09-08 19:07:04 +00:00
|
|
|
error = copyin(args->act, &nsa, sizeof(l_sigaction_t));
|
1999-09-29 15:12:18 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
}
|
1999-08-14 17:28:46 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
error = linux_do_sigaction(td, args->sig,
|
1999-09-29 15:12:18 +00:00
|
|
|
args->act ? &nsa : NULL,
|
|
|
|
args->oact ? &osa : NULL);
|
1999-08-14 17:28:46 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
if (args->oact != NULL && !error) {
|
2001-09-08 19:07:04 +00:00
|
|
|
error = copyout(&osa, args->oact, sizeof(l_sigaction_t));
|
1999-09-29 15:12:18 +00:00
|
|
|
}
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
return (error);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
1999-08-14 17:28:46 +00:00
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_do_sigprocmask(struct thread *td, int how, l_sigset_t *new,
|
2001-09-08 19:07:04 +00:00
|
|
|
l_sigset_t *old)
|
1999-08-14 17:28:46 +00:00
|
|
|
{
|
2003-04-22 18:23:49 +00:00
|
|
|
sigset_t omask, nmask;
|
|
|
|
sigset_t *nmaskp;
|
2000-12-15 19:41:27 +00:00
|
|
|
int error;
|
1999-09-29 15:12:18 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] = 0;
|
1999-09-29 15:12:18 +00:00
|
|
|
|
2003-04-25 19:26:18 +00:00
|
|
|
switch (how) {
|
|
|
|
case LINUX_SIG_BLOCK:
|
|
|
|
how = SIG_BLOCK;
|
|
|
|
break;
|
|
|
|
case LINUX_SIG_UNBLOCK:
|
|
|
|
how = SIG_UNBLOCK;
|
|
|
|
break;
|
|
|
|
case LINUX_SIG_SETMASK:
|
|
|
|
how = SIG_SETMASK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
1999-09-29 15:12:18 +00:00
|
|
|
if (new != NULL) {
|
2003-04-22 18:23:49 +00:00
|
|
|
linux_to_bsd_sigset(new, &nmask);
|
|
|
|
nmaskp = &nmask;
|
|
|
|
} else
|
|
|
|
nmaskp = NULL;
|
2003-04-25 19:26:18 +00:00
|
|
|
error = kern_sigprocmask(td, how, nmaskp, &omask, 0);
|
2003-04-28 19:43:11 +00:00
|
|
|
if (error == 0 && old != NULL)
|
2003-04-22 18:23:49 +00:00
|
|
|
bsd_to_linux_sigset(&omask, old);
|
1999-08-14 17:28:46 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
return (error);
|
1999-08-14 17:28:46 +00:00
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2015-05-24 15:43:53 +00:00
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
1995-06-25 17:32:43 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_sigprocmask(struct thread *td, struct linux_sigprocmask_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
l_osigset_t mask;
|
|
|
|
l_sigset_t set, oset;
|
1999-09-29 15:12:18 +00:00
|
|
|
int error;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
if (args->mask != NULL) {
|
2001-09-08 19:07:04 +00:00
|
|
|
error = copyin(args->mask, &mask, sizeof(l_osigset_t));
|
1999-09-29 15:12:18 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
LINUX_SIGEMPTYSET(set);
|
2015-05-24 17:47:20 +00:00
|
|
|
set.__mask = mask;
|
1999-09-29 15:12:18 +00:00
|
|
|
}
|
1999-08-14 17:28:46 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
error = linux_do_sigprocmask(td, args->how,
|
1999-09-29 15:12:18 +00:00
|
|
|
args->mask ? &set : NULL,
|
|
|
|
args->omask ? &oset : NULL);
|
1999-08-14 17:28:46 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
if (args->omask != NULL && !error) {
|
2015-05-24 17:47:20 +00:00
|
|
|
mask = oset.__mask;
|
2001-09-08 19:07:04 +00:00
|
|
|
error = copyout(&mask, args->omask, sizeof(l_osigset_t));
|
1999-09-29 15:12:18 +00:00
|
|
|
}
|
1999-08-14 17:28:46 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
return (error);
|
1999-08-14 17:28:46 +00:00
|
|
|
}
|
2015-05-24 15:43:53 +00:00
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
1999-08-14 17:28:46 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_rt_sigprocmask(struct thread *td, struct linux_rt_sigprocmask_args *args)
|
1999-08-14 17:28:46 +00:00
|
|
|
{
|
2001-09-08 19:07:04 +00:00
|
|
|
l_sigset_t set, oset;
|
1999-09-29 15:12:18 +00:00
|
|
|
int error;
|
1999-08-14 17:28:46 +00:00
|
|
|
|
2001-09-08 19:07:04 +00:00
|
|
|
if (args->sigsetsize != sizeof(l_sigset_t))
|
2018-03-12 15:35:24 +00:00
|
|
|
return (EINVAL);
|
1999-08-14 17:28:46 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
if (args->mask != NULL) {
|
2001-09-08 19:07:04 +00:00
|
|
|
error = copyin(args->mask, &set, sizeof(l_sigset_t));
|
1999-09-29 15:12:18 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
error = linux_do_sigprocmask(td, args->how,
|
1999-09-29 15:12:18 +00:00
|
|
|
args->mask ? &set : NULL,
|
|
|
|
args->omask ? &oset : NULL);
|
1999-08-14 17:28:46 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
if (args->omask != NULL && !error) {
|
2001-09-08 19:07:04 +00:00
|
|
|
error = copyout(&oset, args->omask, sizeof(l_sigset_t));
|
1999-09-29 15:12:18 +00:00
|
|
|
}
|
1999-08-14 17:28:46 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
return (error);
|
1995-06-25 17:32:43 +00:00
|
|
|
}
|
|
|
|
|
2015-05-24 15:43:53 +00:00
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
1995-06-25 17:32:43 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_sgetmask(struct thread *td, struct linux_sgetmask_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
struct proc *p = td->td_proc;
|
2001-09-08 19:07:04 +00:00
|
|
|
l_sigset_t mask;
|
1999-09-29 15:12:18 +00:00
|
|
|
|
2000-12-15 19:41:27 +00:00
|
|
|
PROC_LOCK(p);
|
2003-03-31 22:49:17 +00:00
|
|
|
bsd_to_linux_sigset(&td->td_sigmask, &mask);
|
2000-12-15 19:41:27 +00:00
|
|
|
PROC_UNLOCK(p);
|
2015-05-24 17:47:20 +00:00
|
|
|
td->td_retval[0] = mask.__mask;
|
1999-09-29 15:12:18 +00:00
|
|
|
return (0);
|
1995-06-25 17:32:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_ssetmask(struct thread *td, struct linux_ssetmask_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
struct proc *p = td->td_proc;
|
2001-09-08 19:07:04 +00:00
|
|
|
l_sigset_t lset;
|
1999-09-29 15:12:18 +00:00
|
|
|
sigset_t bset;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2000-12-15 19:41:27 +00:00
|
|
|
PROC_LOCK(p);
|
2003-03-31 22:49:17 +00:00
|
|
|
bsd_to_linux_sigset(&td->td_sigmask, &lset);
|
2015-05-24 17:47:20 +00:00
|
|
|
td->td_retval[0] = lset.__mask;
|
1999-09-29 15:12:18 +00:00
|
|
|
LINUX_SIGEMPTYSET(lset);
|
2015-05-24 17:47:20 +00:00
|
|
|
lset.__mask = args->mask;
|
1999-09-29 15:12:18 +00:00
|
|
|
linux_to_bsd_sigset(&lset, &bset);
|
2003-03-31 22:49:17 +00:00
|
|
|
td->td_sigmask = bset;
|
|
|
|
SIG_CANTMASK(td->td_sigmask);
|
|
|
|
signotify(td);
|
2000-12-15 19:41:27 +00:00
|
|
|
PROC_UNLOCK(p);
|
1999-09-29 15:12:18 +00:00
|
|
|
return (0);
|
1995-06-25 17:32:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_sigpending(struct thread *td, struct linux_sigpending_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
struct proc *p = td->td_proc;
|
1999-09-29 15:12:18 +00:00
|
|
|
sigset_t bset;
|
2001-09-08 19:07:04 +00:00
|
|
|
l_sigset_t lset;
|
|
|
|
l_osigset_t mask;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2000-12-15 19:41:27 +00:00
|
|
|
PROC_LOCK(p);
|
2002-10-01 17:15:53 +00:00
|
|
|
bset = p->p_siglist;
|
2003-03-31 22:49:17 +00:00
|
|
|
SIGSETOR(bset, td->td_siglist);
|
|
|
|
SIGSETAND(bset, td->td_sigmask);
|
2000-12-15 19:41:27 +00:00
|
|
|
PROC_UNLOCK(p);
|
2003-04-17 22:07:56 +00:00
|
|
|
bsd_to_linux_sigset(&bset, &lset);
|
2015-05-24 17:47:20 +00:00
|
|
|
mask = lset.__mask;
|
1999-09-29 15:12:18 +00:00
|
|
|
return (copyout(&mask, args->mask, sizeof(mask)));
|
1995-06-25 17:32:43 +00:00
|
|
|
}
|
2015-05-24 15:43:53 +00:00
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
2006-05-10 18:17:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
linux_rt_sigpending(struct thread *td, struct linux_rt_sigpending_args *args)
|
|
|
|
{
|
|
|
|
struct proc *p = td->td_proc;
|
|
|
|
sigset_t bset;
|
|
|
|
l_sigset_t lset;
|
|
|
|
|
|
|
|
if (args->sigsetsize > sizeof(lset))
|
2018-03-12 15:35:24 +00:00
|
|
|
return (EINVAL);
|
2006-05-10 18:17:29 +00:00
|
|
|
/* NOT REACHED */
|
|
|
|
|
|
|
|
PROC_LOCK(p);
|
|
|
|
bset = p->p_siglist;
|
|
|
|
SIGSETOR(bset, td->td_siglist);
|
|
|
|
SIGSETAND(bset, td->td_sigmask);
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
bsd_to_linux_sigset(&bset, &lset);
|
|
|
|
return (copyout(&lset, args->set, args->sigsetsize));
|
|
|
|
}
|
1995-06-25 17:32:43 +00:00
|
|
|
|
2006-12-31 13:16:00 +00:00
|
|
|
int
|
|
|
|
linux_rt_sigtimedwait(struct thread *td,
|
|
|
|
struct linux_rt_sigtimedwait_args *args)
|
|
|
|
{
|
|
|
|
struct timespec ts, *tsa;
|
2021-06-07 02:35:35 +00:00
|
|
|
struct l_timespec lts;
|
2021-06-10 11:51:30 +00:00
|
|
|
int error;
|
2006-12-31 13:16:00 +00:00
|
|
|
|
|
|
|
if (args->timeout) {
|
2021-06-07 02:35:35 +00:00
|
|
|
if ((error = copyin(args->timeout, <s, sizeof(lts))))
|
|
|
|
return (error);
|
|
|
|
error = linux_to_native_timespec(&ts, <s);
|
|
|
|
if (error != 0)
|
2006-12-31 13:16:00 +00:00
|
|
|
return (error);
|
|
|
|
tsa = &ts;
|
2021-06-07 02:35:35 +00:00
|
|
|
} else
|
|
|
|
tsa = NULL;
|
|
|
|
|
2021-06-10 11:51:30 +00:00
|
|
|
return (linux_common_rt_sigtimedwait(td, args->mask, tsa,
|
|
|
|
args->ptr, args->sigsetsize));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
linux_common_rt_sigtimedwait(struct thread *td, l_sigset_t *mask,
|
|
|
|
struct timespec *tsa, l_siginfo_t *ptr, l_size_t sigsetsize)
|
|
|
|
{
|
|
|
|
int error, sig;
|
|
|
|
l_sigset_t lset;
|
|
|
|
sigset_t bset;
|
|
|
|
l_siginfo_t lsi;
|
|
|
|
ksiginfo_t ksi;
|
|
|
|
|
|
|
|
if (sigsetsize != sizeof(l_sigset_t))
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
if ((error = copyin(mask, &lset, sizeof(lset))))
|
|
|
|
return (error);
|
|
|
|
linux_to_bsd_sigset(&lset, &bset);
|
|
|
|
|
|
|
|
ksiginfo_init(&ksi);
|
2021-06-07 03:06:17 +00:00
|
|
|
error = kern_sigtimedwait(td, bset, &ksi, tsa);
|
2006-12-31 13:16:00 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
2021-06-07 03:06:17 +00:00
|
|
|
sig = bsd_to_linux_signal(ksi.ksi_signo);
|
2011-02-15 21:42:48 +00:00
|
|
|
|
2021-06-10 11:51:30 +00:00
|
|
|
if (ptr) {
|
2021-06-07 03:06:17 +00:00
|
|
|
memset(&lsi, 0, sizeof(lsi));
|
|
|
|
siginfo_to_lsiginfo(&ksi.ksi_info, &lsi, sig);
|
2021-06-10 11:51:30 +00:00
|
|
|
error = copyout(&lsi, ptr, sizeof(lsi));
|
2006-12-31 13:16:00 +00:00
|
|
|
}
|
2011-02-15 21:42:48 +00:00
|
|
|
if (error == 0)
|
2018-02-05 17:29:12 +00:00
|
|
|
td->td_retval[0] = sig;
|
2006-12-31 13:16:00 +00:00
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2021-06-10 11:51:30 +00:00
|
|
|
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
|
|
|
|
int
|
|
|
|
linux_rt_sigtimedwait_time64(struct thread *td,
|
|
|
|
struct linux_rt_sigtimedwait_time64_args *args)
|
|
|
|
{
|
|
|
|
struct timespec ts, *tsa;
|
|
|
|
struct l_timespec64 lts;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (args->timeout) {
|
|
|
|
if ((error = copyin(args->timeout, <s, sizeof(lts))))
|
|
|
|
return (error);
|
|
|
|
error = linux_to_native_timespec64(&ts, <s);
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
tsa = &ts;
|
|
|
|
} else
|
|
|
|
tsa = NULL;
|
|
|
|
|
|
|
|
return (linux_common_rt_sigtimedwait(td, args->mask, tsa,
|
|
|
|
args->ptr, args->sigsetsize));
|
|
|
|
}
|
|
|
|
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
|
|
|
|
|
1995-06-25 17:32:43 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
linux_kill(struct thread *td, struct linux_kill_args *args)
|
1995-06-25 17:32:43 +00:00
|
|
|
{
|
2019-12-13 18:44:02 +00:00
|
|
|
int l_signum;
|
1995-06-25 17:32:43 +00:00
|
|
|
|
1999-09-29 15:12:18 +00:00
|
|
|
/*
|
|
|
|
* Allow signal 0 as a means to check for privileges
|
|
|
|
*/
|
2006-10-15 14:34:03 +00:00
|
|
|
if (!LINUX_SIG_VALID(args->signum) && args->signum != 0)
|
2011-01-23 09:50:39 +00:00
|
|
|
return (EINVAL);
|
1999-09-29 15:12:18 +00:00
|
|
|
|
2015-05-24 17:47:20 +00:00
|
|
|
if (args->signum > 0)
|
2019-12-13 18:44:02 +00:00
|
|
|
l_signum = linux_to_bsd_signal(args->signum);
|
1999-09-29 15:12:18 +00:00
|
|
|
else
|
2019-12-13 18:44:02 +00:00
|
|
|
l_signum = 0;
|
1999-09-29 15:12:18 +00:00
|
|
|
|
2019-12-13 18:44:02 +00:00
|
|
|
return (kern_kill(td, args->pid, l_signum));
|
1995-06-25 17:32:43 +00:00
|
|
|
}
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
|
2008-10-19 10:02:26 +00:00
|
|
|
static int
|
2015-05-24 14:53:16 +00:00
|
|
|
linux_do_tkill(struct thread *td, struct thread *tdt, ksiginfo_t *ksi)
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
{
|
|
|
|
struct proc *p;
|
2008-10-19 10:02:26 +00:00
|
|
|
int error;
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
|
2015-05-24 14:53:16 +00:00
|
|
|
p = tdt->td_proc;
|
|
|
|
AUDIT_ARG_SIGNUM(ksi->ksi_signo);
|
|
|
|
AUDIT_ARG_PID(p->p_pid);
|
2009-06-27 13:58:44 +00:00
|
|
|
AUDIT_ARG_PROCESS(p);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
|
2015-05-24 14:53:16 +00:00
|
|
|
error = p_cansignal(td, p, ksi->ksi_signo);
|
|
|
|
if (error != 0 || ksi->ksi_signo == 0)
|
2008-10-19 10:02:26 +00:00
|
|
|
goto out;
|
|
|
|
|
2015-05-24 14:53:16 +00:00
|
|
|
tdksignal(tdt, ksi->ksi_signo, ksi);
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
|
2008-10-19 10:02:26 +00:00
|
|
|
out:
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_tgkill(struct thread *td, struct linux_tgkill_args *args)
|
|
|
|
{
|
2015-05-24 14:53:16 +00:00
|
|
|
struct thread *tdt;
|
|
|
|
ksiginfo_t ksi;
|
|
|
|
int sig;
|
2008-10-19 10:02:26 +00:00
|
|
|
|
|
|
|
if (args->pid <= 0 || args->tgid <=0)
|
|
|
|
return (EINVAL);
|
|
|
|
|
2015-05-24 14:53:16 +00:00
|
|
|
/*
|
|
|
|
* Allow signal 0 as a means to check for privileges
|
|
|
|
*/
|
|
|
|
if (!LINUX_SIG_VALID(args->sig) && args->sig != 0)
|
|
|
|
return (EINVAL);
|
|
|
|
|
2015-05-24 17:47:20 +00:00
|
|
|
if (args->sig > 0)
|
|
|
|
sig = linux_to_bsd_signal(args->sig);
|
2015-05-24 14:53:16 +00:00
|
|
|
else
|
2015-05-24 17:47:20 +00:00
|
|
|
sig = 0;
|
2015-05-24 14:53:16 +00:00
|
|
|
|
|
|
|
tdt = linux_tdfind(td, args->pid, args->tgid);
|
|
|
|
if (tdt == NULL)
|
|
|
|
return (ESRCH);
|
|
|
|
|
|
|
|
ksiginfo_init(&ksi);
|
|
|
|
ksi.ksi_signo = sig;
|
2015-05-24 14:58:30 +00:00
|
|
|
ksi.ksi_code = SI_LWP;
|
2015-05-24 14:53:16 +00:00
|
|
|
ksi.ksi_errno = 0;
|
|
|
|
ksi.ksi_pid = td->td_proc->p_pid;
|
|
|
|
ksi.ksi_uid = td->td_proc->p_ucred->cr_ruid;
|
|
|
|
return (linux_do_tkill(td, tdt, &ksi));
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
}
|
|
|
|
|
2015-05-24 14:53:16 +00:00
|
|
|
/*
|
|
|
|
* Deprecated since 2.5.75. Replaced by tgkill().
|
|
|
|
*/
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
int
|
|
|
|
linux_tkill(struct thread *td, struct linux_tkill_args *args)
|
|
|
|
{
|
2015-05-24 14:53:16 +00:00
|
|
|
struct thread *tdt;
|
|
|
|
ksiginfo_t ksi;
|
|
|
|
int sig;
|
|
|
|
|
2008-10-19 10:02:26 +00:00
|
|
|
if (args->tid <= 0)
|
|
|
|
return (EINVAL);
|
|
|
|
|
2015-05-24 14:53:16 +00:00
|
|
|
if (!LINUX_SIG_VALID(args->sig))
|
|
|
|
return (EINVAL);
|
|
|
|
|
2015-05-24 17:47:20 +00:00
|
|
|
sig = linux_to_bsd_signal(args->sig);
|
2015-05-24 14:53:16 +00:00
|
|
|
|
|
|
|
tdt = linux_tdfind(td, args->tid, -1);
|
|
|
|
if (tdt == NULL)
|
|
|
|
return (ESRCH);
|
|
|
|
|
|
|
|
ksiginfo_init(&ksi);
|
|
|
|
ksi.ksi_signo = sig;
|
2015-05-24 14:58:30 +00:00
|
|
|
ksi.ksi_code = SI_LWP;
|
2015-05-24 14:53:16 +00:00
|
|
|
ksi.ksi_errno = 0;
|
|
|
|
ksi.ksi_pid = td->td_proc->p_pid;
|
|
|
|
ksi.ksi_uid = td->td_proc->p_ucred->cr_ruid;
|
|
|
|
return (linux_do_tkill(td, tdt, &ksi));
|
2008-10-19 10:02:26 +00:00
|
|
|
}
|
|
|
|
|
2015-05-24 14:58:30 +00:00
|
|
|
static void
|
|
|
|
sicode_to_lsicode(int si_code, int *lsi_code)
|
|
|
|
{
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
|
2015-05-24 14:58:30 +00:00
|
|
|
switch (si_code) {
|
|
|
|
case SI_USER:
|
|
|
|
*lsi_code = LINUX_SI_USER;
|
|
|
|
break;
|
|
|
|
case SI_KERNEL:
|
|
|
|
*lsi_code = LINUX_SI_KERNEL;
|
|
|
|
break;
|
|
|
|
case SI_QUEUE:
|
|
|
|
*lsi_code = LINUX_SI_QUEUE;
|
2008-10-19 10:02:26 +00:00
|
|
|
break;
|
2015-05-24 14:58:30 +00:00
|
|
|
case SI_TIMER:
|
|
|
|
*lsi_code = LINUX_SI_TIMER;
|
2008-10-19 10:02:26 +00:00
|
|
|
break;
|
2015-05-24 14:58:30 +00:00
|
|
|
case SI_MESGQ:
|
|
|
|
*lsi_code = LINUX_SI_MESGQ;
|
|
|
|
break;
|
|
|
|
case SI_ASYNCIO:
|
|
|
|
*lsi_code = LINUX_SI_ASYNCIO;
|
|
|
|
break;
|
|
|
|
case SI_LWP:
|
|
|
|
*lsi_code = LINUX_SI_TKILL;
|
2008-10-19 10:02:26 +00:00
|
|
|
break;
|
|
|
|
default:
|
2015-05-24 14:58:30 +00:00
|
|
|
*lsi_code = si_code;
|
2008-10-19 10:02:26 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-05-24 14:58:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
siginfo_to_lsiginfo(const siginfo_t *si, l_siginfo_t *lsi, l_int sig)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* sig alredy converted */
|
|
|
|
lsi->lsi_signo = sig;
|
|
|
|
sicode_to_lsicode(si->si_code, &lsi->lsi_code);
|
|
|
|
|
|
|
|
switch (si->si_code) {
|
|
|
|
case SI_LWP:
|
|
|
|
lsi->lsi_pid = si->si_pid;
|
|
|
|
lsi->lsi_uid = si->si_uid;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SI_TIMER:
|
|
|
|
lsi->lsi_int = si->si_value.sival_int;
|
|
|
|
lsi->lsi_ptr = PTROUT(si->si_value.sival_ptr);
|
|
|
|
lsi->lsi_tid = si->si_timerid;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SI_QUEUE:
|
|
|
|
lsi->lsi_pid = si->si_pid;
|
|
|
|
lsi->lsi_uid = si->si_uid;
|
|
|
|
lsi->lsi_ptr = PTROUT(si->si_value.sival_ptr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SI_ASYNCIO:
|
|
|
|
lsi->lsi_int = si->si_value.sival_int;
|
|
|
|
lsi->lsi_ptr = PTROUT(si->si_value.sival_ptr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
switch (sig) {
|
|
|
|
case LINUX_SIGPOLL:
|
|
|
|
/* XXX si_fd? */
|
|
|
|
lsi->lsi_band = si->si_band;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LINUX_SIGCHLD:
|
|
|
|
lsi->lsi_errno = 0;
|
|
|
|
lsi->lsi_pid = si->si_pid;
|
|
|
|
lsi->lsi_uid = si->si_uid;
|
|
|
|
|
|
|
|
if (si->si_code == CLD_STOPPED)
|
2015-05-24 17:47:20 +00:00
|
|
|
lsi->lsi_status = bsd_to_linux_signal(si->si_status);
|
2015-05-24 14:58:30 +00:00
|
|
|
else if (si->si_code == CLD_CONTINUED)
|
2015-05-24 17:47:20 +00:00
|
|
|
lsi->lsi_status = bsd_to_linux_signal(SIGCONT);
|
2015-05-24 14:58:30 +00:00
|
|
|
else
|
|
|
|
lsi->lsi_status = si->si_status;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LINUX_SIGBUS:
|
|
|
|
case LINUX_SIGILL:
|
|
|
|
case LINUX_SIGFPE:
|
|
|
|
case LINUX_SIGSEGV:
|
|
|
|
lsi->lsi_addr = PTROUT(si->si_addr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
lsi->lsi_pid = si->si_pid;
|
|
|
|
lsi->lsi_uid = si->si_uid;
|
|
|
|
if (sig >= LINUX_SIGRTMIN) {
|
|
|
|
lsi->lsi_int = si->si_value.sival_int;
|
|
|
|
lsi->lsi_ptr = PTROUT(si->si_value.sival_ptr);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2011-02-15 21:46:36 +00:00
|
|
|
}
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
}
|
2015-05-24 15:11:32 +00:00
|
|
|
|
2021-06-07 02:55:34 +00:00
|
|
|
int
|
|
|
|
lsiginfo_to_siginfo(struct thread *td, const l_siginfo_t *lsi,
|
|
|
|
siginfo_t *si, int sig)
|
2015-05-24 15:11:32 +00:00
|
|
|
{
|
|
|
|
|
2021-06-07 02:55:34 +00:00
|
|
|
switch (lsi->lsi_code) {
|
|
|
|
case LINUX_SI_TKILL:
|
|
|
|
if (linux_kernver(td) >= LINUX_KERNVER_2006039) {
|
|
|
|
linux_msg(td, "SI_TKILL forbidden since 2.6.39");
|
|
|
|
return (EPERM);
|
|
|
|
}
|
|
|
|
si->si_code = SI_LWP;
|
|
|
|
case LINUX_SI_QUEUE:
|
|
|
|
si->si_code = SI_QUEUE;
|
|
|
|
break;
|
|
|
|
case LINUX_SI_TIMER:
|
|
|
|
si->si_code = SI_TIMER;
|
|
|
|
break;
|
|
|
|
case LINUX_SI_MESGQ:
|
|
|
|
si->si_code = SI_MESGQ;
|
|
|
|
break;
|
|
|
|
case LINUX_SI_ASYNCIO:
|
|
|
|
si->si_code = SI_ASYNCIO;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
si->si_code = lsi->lsi_code;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
si->si_signo = sig;
|
|
|
|
si->si_pid = td->td_proc->p_pid;
|
|
|
|
si->si_uid = td->td_ucred->cr_ruid;
|
|
|
|
si->si_value.sival_ptr = PTRIN(lsi->lsi_value.sival_ptr);
|
|
|
|
return (0);
|
2015-05-24 15:11:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_rt_sigqueueinfo(struct thread *td, struct linux_rt_sigqueueinfo_args *args)
|
|
|
|
{
|
|
|
|
l_siginfo_t linfo;
|
|
|
|
struct proc *p;
|
|
|
|
ksiginfo_t ksi;
|
|
|
|
int error;
|
|
|
|
int sig;
|
|
|
|
|
|
|
|
if (!LINUX_SIG_VALID(args->sig))
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
error = copyin(args->info, &linfo, sizeof(linfo));
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
if (linfo.lsi_code >= 0)
|
2021-06-07 02:55:34 +00:00
|
|
|
/* SI_USER, SI_KERNEL */
|
2015-05-24 15:11:32 +00:00
|
|
|
return (EPERM);
|
|
|
|
|
2015-05-24 17:47:20 +00:00
|
|
|
sig = linux_to_bsd_signal(args->sig);
|
2021-06-07 02:55:34 +00:00
|
|
|
ksiginfo_init(&ksi);
|
|
|
|
error = lsiginfo_to_siginfo(td, &linfo, &ksi.ksi_info, sig);
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
2015-05-24 15:11:32 +00:00
|
|
|
|
|
|
|
error = ESRCH;
|
2017-11-11 18:10:09 +00:00
|
|
|
if ((p = pfind_any(args->pid)) != NULL) {
|
2015-05-24 15:11:32 +00:00
|
|
|
error = p_cansignal(td, p, sig);
|
|
|
|
if (error != 0) {
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
error = tdsendsignal(p, NULL, sig, &ksi);
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
2017-02-19 07:38:11 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
linux_rt_tgsigqueueinfo(struct thread *td, struct linux_rt_tgsigqueueinfo_args *args)
|
|
|
|
{
|
|
|
|
l_siginfo_t linfo;
|
|
|
|
struct thread *tds;
|
|
|
|
ksiginfo_t ksi;
|
|
|
|
int error;
|
|
|
|
int sig;
|
|
|
|
|
|
|
|
if (!LINUX_SIG_VALID(args->sig))
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
error = copyin(args->uinfo, &linfo, sizeof(linfo));
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
if (linfo.lsi_code >= 0)
|
|
|
|
return (EPERM);
|
|
|
|
|
2021-06-07 02:55:34 +00:00
|
|
|
sig = linux_to_bsd_signal(args->sig);
|
|
|
|
ksiginfo_init(&ksi);
|
|
|
|
error = lsiginfo_to_siginfo(td, &linfo, &ksi.ksi_info, sig);
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
|
2017-02-19 07:38:11 +00:00
|
|
|
tds = linux_tdfind(td, args->tid, args->tgid);
|
|
|
|
if (tds == NULL)
|
|
|
|
return (ESRCH);
|
|
|
|
|
|
|
|
return (linux_do_tkill(td, tds, &ksi));
|
|
|
|
}
|
2021-07-23 20:11:06 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
linux_rt_sigsuspend(struct thread *td, struct linux_rt_sigsuspend_args *uap)
|
|
|
|
{
|
|
|
|
l_sigset_t lmask;
|
|
|
|
sigset_t sigmask;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (uap->sigsetsize != sizeof(l_sigset_t))
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
error = copyin(uap->newset, &lmask, sizeof(l_sigset_t));
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
linux_to_bsd_sigset(&lmask, &sigmask);
|
|
|
|
return (kern_sigsuspend(td, sigmask));
|
|
|
|
}
|