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-10 08:42:54 +00:00
|
|
|
|
* Copyright (c) 1994-1996 S<EFBFBD>ren Schmidt
|
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
|
|
|
|
* 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
|
2003-03-03 09:17:12 +00:00
|
|
|
|
* notice, this list of conditions and the following disclaimer
|
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
|
|
|
|
* 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
|
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
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-06-02 16:56:40 +00:00
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
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
|
|
|
|
/* XXX we use functions that might not exist. */
|
1997-12-16 17:40:42 +00:00
|
|
|
|
#include "opt_compat.h"
|
|
|
|
|
|
|
|
|
|
#ifndef COMPAT_43
|
|
|
|
|
#error "Unable to compile Linux-emulator due to missing COMPAT_43 option!"
|
|
|
|
|
#endif
|
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
|
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1999-06-28 09:12:46 +00:00
|
|
|
|
#include <sys/systm.h>
|
2003-12-29 06:51:10 +00:00
|
|
|
|
#include <sys/exec.h>
|
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
|
|
|
|
#include <sys/imgact.h>
|
1998-09-14 05:36:51 +00:00
|
|
|
|
#include <sys/imgact_aout.h>
|
1996-03-10 08:42:54 +00:00
|
|
|
|
#include <sys/imgact_elf.h>
|
2003-12-29 06:51:10 +00:00
|
|
|
|
#include <sys/kernel.h>
|
2001-10-11 17:52:20 +00:00
|
|
|
|
#include <sys/lock.h>
|
1996-03-10 08:42:54 +00:00
|
|
|
|
#include <sys/malloc.h>
|
2003-12-29 06:51:10 +00:00
|
|
|
|
#include <sys/module.h>
|
2001-05-19 01:28:09 +00:00
|
|
|
|
#include <sys/mutex.h>
|
2001-05-01 08:13:21 +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/sysent.h>
|
|
|
|
|
#include <sys/sysproto.h>
|
2002-09-07 01:29:21 +00:00
|
|
|
|
#include <sys/vnode.h>
|
2001-05-01 08:13:21 +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
|
|
|
|
#include <vm/vm.h>
|
2002-09-07 01:29:21 +00:00
|
|
|
|
#include <vm/pmap.h>
|
2003-12-29 06:51:10 +00:00
|
|
|
|
#include <vm/vm_extern.h>
|
2002-09-07 01:29:21 +00:00
|
|
|
|
#include <vm/vm_map.h>
|
|
|
|
|
#include <vm/vm_object.h>
|
2003-12-29 06:51:10 +00:00
|
|
|
|
#include <vm/vm_page.h>
|
|
|
|
|
#include <vm/vm_param.h>
|
|
|
|
|
|
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
|
#include <machine/md_var.h>
|
2004-11-27 06:46:45 +00:00
|
|
|
|
#include <machine/pcb.h>
|
2002-09-07 01:29:21 +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
|
|
|
|
#include <i386/linux/linux.h>
|
2000-11-10 21:30:19 +00:00
|
|
|
|
#include <i386/linux/linux_proto.h>
|
2003-03-27 18:18:35 +00:00
|
|
|
|
#include <compat/linux/linux_mib.h>
|
2000-11-16 02:07:05 +00:00
|
|
|
|
#include <compat/linux/linux_signal.h>
|
2000-08-22 05:57:55 +00:00
|
|
|
|
#include <compat/linux/linux_util.h>
|
1996-03-10 08:42:54 +00:00
|
|
|
|
|
2000-05-06 01:36:04 +00:00
|
|
|
|
MODULE_VERSION(linux, 1);
|
2001-01-14 18:16:01 +00:00
|
|
|
|
MODULE_DEPEND(linux, sysvmsg, 1, 1, 1);
|
|
|
|
|
MODULE_DEPEND(linux, sysvsem, 1, 1, 1);
|
|
|
|
|
MODULE_DEPEND(linux, sysvshm, 1, 1, 1);
|
2000-05-06 01:36:04 +00:00
|
|
|
|
|
1999-12-04 11:10:22 +00:00
|
|
|
|
MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures");
|
|
|
|
|
|
2000-04-26 20:58:40 +00:00
|
|
|
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
|
|
|
|
#define SHELLMAGIC 0x2123 /* #! */
|
|
|
|
|
#else
|
|
|
|
|
#define SHELLMAGIC 0x2321
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-09-10 07:00:17 +00:00
|
|
|
|
/*
|
|
|
|
|
* Allow the sendsig functions to use the ldebug() facility
|
|
|
|
|
* even though they are not syscalls themselves. Map them
|
|
|
|
|
* to syscall 0. This is slightly less bogus than using
|
|
|
|
|
* ldebug(sigreturn).
|
|
|
|
|
*/
|
|
|
|
|
#define LINUX_SYS_linux_rt_sendsig 0
|
|
|
|
|
#define LINUX_SYS_linux_sendsig 0
|
|
|
|
|
|
2005-02-06 17:29:20 +00:00
|
|
|
|
#define fldcw(addr) __asm("fldcw %0" : : "m" (*(addr)))
|
|
|
|
|
#define __LINUX_NPXCW__ 0x37f
|
|
|
|
|
|
1999-12-04 11:10:22 +00:00
|
|
|
|
extern char linux_sigcode[];
|
|
|
|
|
extern int linux_szsigcode;
|
|
|
|
|
|
|
|
|
|
extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
|
|
|
|
|
|
2001-06-13 10:58:39 +00:00
|
|
|
|
SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
|
1999-12-04 11:10:22 +00:00
|
|
|
|
|
2002-03-20 07:51:46 +00:00
|
|
|
|
static int linux_fixup(register_t **stack_base,
|
2002-03-24 04:09:05 +00:00
|
|
|
|
struct image_params *iparams);
|
2002-03-20 07:51:46 +00:00
|
|
|
|
static int elf_linux_fixup(register_t **stack_base,
|
2002-03-24 04:09:05 +00:00
|
|
|
|
struct image_params *iparams);
|
|
|
|
|
static void linux_prepsyscall(struct trapframe *tf, int *args, u_int *code,
|
|
|
|
|
caddr_t *params);
|
2002-03-20 07:51:46 +00:00
|
|
|
|
static void linux_sendsig(sig_t catcher, int sig, sigset_t *mask,
|
2002-03-24 04:09:05 +00:00
|
|
|
|
u_long code);
|
2003-05-11 21:51:11 +00:00
|
|
|
|
static void exec_linux_setregs(struct thread *td, u_long entry,
|
|
|
|
|
u_long stack, u_long ps_strings);
|
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
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linux syscalls return negative errno's, we do positive and map them
|
|
|
|
|
*/
|
1998-12-14 18:54:04 +00:00
|
|
|
|
static int bsd_to_linux_errno[ELAST + 1] = {
|
2003-03-03 09:17:12 +00:00
|
|
|
|
-0, -1, -2, -3, -4, -5, -6, -7, -8, -9,
|
|
|
|
|
-10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
|
|
|
|
|
-20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
|
|
|
|
|
-30, -31, -32, -33, -34, -11,-115,-114, -88, -89,
|
|
|
|
|
-90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
|
1996-03-10 08:42:54 +00:00
|
|
|
|
-100,-101,-102,-103,-104,-105,-106,-107,-108,-109,
|
|
|
|
|
-110,-111, -40, -36,-112,-113, -39, -11, -87,-122,
|
|
|
|
|
-116, -66, -6, -6, -6, -6, -6, -37, -38, -9,
|
2003-03-03 09:17:12 +00:00
|
|
|
|
-6, -6, -43, -42, -75, -6, -84
|
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
|
|
|
|
int bsd_to_linux_signal[LINUX_SIGTBLSZ] = {
|
|
|
|
|
LINUX_SIGHUP, LINUX_SIGINT, LINUX_SIGQUIT, LINUX_SIGILL,
|
|
|
|
|
LINUX_SIGTRAP, LINUX_SIGABRT, 0, LINUX_SIGFPE,
|
2003-02-24 16:16:45 +00:00
|
|
|
|
LINUX_SIGKILL, LINUX_SIGBUS, LINUX_SIGSEGV, LINUX_SIGSYS,
|
1999-09-29 15:12:18 +00:00
|
|
|
|
LINUX_SIGPIPE, LINUX_SIGALRM, LINUX_SIGTERM, LINUX_SIGURG,
|
|
|
|
|
LINUX_SIGSTOP, LINUX_SIGTSTP, LINUX_SIGCONT, LINUX_SIGCHLD,
|
|
|
|
|
LINUX_SIGTTIN, LINUX_SIGTTOU, LINUX_SIGIO, LINUX_SIGXCPU,
|
|
|
|
|
LINUX_SIGXFSZ, LINUX_SIGVTALRM, LINUX_SIGPROF, LINUX_SIGWINCH,
|
|
|
|
|
0, LINUX_SIGUSR1, LINUX_SIGUSR2
|
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
|
|
|
|
int linux_to_bsd_signal[LINUX_SIGTBLSZ] = {
|
|
|
|
|
SIGHUP, SIGINT, SIGQUIT, SIGILL,
|
|
|
|
|
SIGTRAP, SIGABRT, SIGBUS, SIGFPE,
|
|
|
|
|
SIGKILL, SIGUSR1, SIGSEGV, SIGUSR2,
|
|
|
|
|
SIGPIPE, SIGALRM, SIGTERM, SIGBUS,
|
|
|
|
|
SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP,
|
|
|
|
|
SIGTTIN, SIGTTOU, SIGURG, SIGXCPU,
|
|
|
|
|
SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH,
|
2003-02-24 16:16:45 +00:00
|
|
|
|
SIGIO, SIGURG, SIGSYS
|
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-11-20 09:39:31 +00:00
|
|
|
|
#define LINUX_T_UNKNOWN 255
|
|
|
|
|
static int _bsd_to_linux_trapcode[] = {
|
|
|
|
|
LINUX_T_UNKNOWN, /* 0 */
|
|
|
|
|
6, /* 1 T_PRIVINFLT */
|
|
|
|
|
LINUX_T_UNKNOWN, /* 2 */
|
|
|
|
|
3, /* 3 T_BPTFLT */
|
|
|
|
|
LINUX_T_UNKNOWN, /* 4 */
|
|
|
|
|
LINUX_T_UNKNOWN, /* 5 */
|
|
|
|
|
16, /* 6 T_ARITHTRAP */
|
|
|
|
|
254, /* 7 T_ASTFLT */
|
|
|
|
|
LINUX_T_UNKNOWN, /* 8 */
|
|
|
|
|
13, /* 9 T_PROTFLT */
|
|
|
|
|
1, /* 10 T_TRCTRAP */
|
|
|
|
|
LINUX_T_UNKNOWN, /* 11 */
|
|
|
|
|
14, /* 12 T_PAGEFLT */
|
|
|
|
|
LINUX_T_UNKNOWN, /* 13 */
|
|
|
|
|
17, /* 14 T_ALIGNFLT */
|
|
|
|
|
LINUX_T_UNKNOWN, /* 15 */
|
|
|
|
|
LINUX_T_UNKNOWN, /* 16 */
|
|
|
|
|
LINUX_T_UNKNOWN, /* 17 */
|
|
|
|
|
0, /* 18 T_DIVIDE */
|
|
|
|
|
2, /* 19 T_NMI */
|
|
|
|
|
4, /* 20 T_OFLOW */
|
|
|
|
|
5, /* 21 T_BOUND */
|
|
|
|
|
7, /* 22 T_DNA */
|
|
|
|
|
8, /* 23 T_DOUBLEFLT */
|
|
|
|
|
9, /* 24 T_FPOPFLT */
|
|
|
|
|
10, /* 25 T_TSSFLT */
|
|
|
|
|
11, /* 26 T_SEGNPFLT */
|
|
|
|
|
12, /* 27 T_STKFLT */
|
|
|
|
|
18, /* 28 T_MCHK */
|
|
|
|
|
19, /* 29 T_XMMFLT */
|
|
|
|
|
15 /* 30 T_RESERVED */
|
|
|
|
|
};
|
|
|
|
|
#define bsd_to_linux_trapcode(code) \
|
|
|
|
|
((code)<sizeof(_bsd_to_linux_trapcode)/sizeof(*_bsd_to_linux_trapcode)? \
|
|
|
|
|
_bsd_to_linux_trapcode[(code)]: \
|
|
|
|
|
LINUX_T_UNKNOWN)
|
|
|
|
|
|
1998-04-28 18:15:08 +00:00
|
|
|
|
/*
|
|
|
|
|
* If FreeBSD & Linux have a difference of opinion about what a trap
|
|
|
|
|
* means, deal with it here.
|
2001-08-30 18:50:57 +00:00
|
|
|
|
*
|
|
|
|
|
* MPSAFE
|
1998-04-28 18:15:08 +00:00
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
translate_traps(int signal, int trap_code)
|
|
|
|
|
{
|
1998-05-07 00:42:25 +00:00
|
|
|
|
if (signal != SIGBUS)
|
|
|
|
|
return signal;
|
|
|
|
|
switch (trap_code) {
|
|
|
|
|
case T_PROTFLT:
|
|
|
|
|
case T_TSSFLT:
|
|
|
|
|
case T_DOUBLEFLT:
|
|
|
|
|
case T_PAGEFLT:
|
|
|
|
|
return SIGSEGV;
|
1998-04-28 18:15:08 +00:00
|
|
|
|
default:
|
|
|
|
|
return signal;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-02-09 06:11:36 +00:00
|
|
|
|
static int
|
1999-12-27 10:42:55 +00:00
|
|
|
|
linux_fixup(register_t **stack_base, struct image_params *imgp)
|
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-12-27 10:42:55 +00:00
|
|
|
|
register_t *argv, *envp;
|
1996-03-10 08:42:54 +00:00
|
|
|
|
|
|
|
|
|
argv = *stack_base;
|
2005-01-29 23:12:00 +00:00
|
|
|
|
envp = *stack_base + (imgp->args->argc + 1);
|
1996-03-10 08:42:54 +00:00
|
|
|
|
(*stack_base)--;
|
1998-08-16 01:21:52 +00:00
|
|
|
|
**stack_base = (intptr_t)(void *)envp;
|
1996-03-10 08:42:54 +00:00
|
|
|
|
(*stack_base)--;
|
1998-08-16 01:21:52 +00:00
|
|
|
|
**stack_base = (intptr_t)(void *)argv;
|
1996-03-10 08:42:54 +00:00
|
|
|
|
(*stack_base)--;
|
2005-01-29 23:12:00 +00:00
|
|
|
|
**stack_base = imgp->args->argc;
|
1996-03-10 08:42:54 +00:00
|
|
|
|
return 0;
|
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
|
|
|
|
}
|
|
|
|
|
|
1998-02-09 06:11:36 +00:00
|
|
|
|
static int
|
1999-12-27 10:42:55 +00:00
|
|
|
|
elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
|
1996-03-10 08:42:54 +00:00
|
|
|
|
{
|
2003-03-21 19:49:34 +00:00
|
|
|
|
Elf32_Auxargs *args;
|
1999-12-27 10:42:55 +00:00
|
|
|
|
register_t *pos;
|
2003-03-03 09:17:12 +00:00
|
|
|
|
|
2003-03-21 19:49:34 +00:00
|
|
|
|
KASSERT(curthread->td_proc == imgp->proc &&
|
2003-06-15 00:31:24 +00:00
|
|
|
|
(curthread->td_proc->p_flag & P_SA) == 0,
|
2003-03-21 19:49:34 +00:00
|
|
|
|
("unsafe elf_linux_fixup(), should be curproc"));
|
|
|
|
|
args = (Elf32_Auxargs *)imgp->auxargs;
|
2005-01-29 23:12:00 +00:00
|
|
|
|
pos = *stack_base + (imgp->args->argc + imgp->args->envc + 2);
|
2003-03-03 09:17:12 +00:00
|
|
|
|
|
2002-10-19 11:57:38 +00:00
|
|
|
|
if (args->trace)
|
1996-03-10 08:42:54 +00:00
|
|
|
|
AUXARGS_ENTRY(pos, AT_DEBUG, 1);
|
2002-10-19 11:57:38 +00:00
|
|
|
|
if (args->execfd != -1)
|
1996-03-10 08:42:54 +00:00
|
|
|
|
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_BASE, args->base);
|
o Merge contents of struct pcred into struct ucred. Specifically, add the
real uid, saved uid, real gid, and saved gid to ucred, as well as the
pcred->pc_uidinfo, which was associated with the real uid, only rename
it to cr_ruidinfo so as not to conflict with cr_uidinfo, which
corresponds to the effective uid.
o Remove p_cred from struct proc; add p_ucred to struct proc, replacing
original macro that pointed.
p->p_ucred to p->p_cred->pc_ucred.
o Universally update code so that it makes use of ucred instead of pcred,
p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo,
cr_{r,sv}{u,g}id instead of p_*, etc.
o Remove pcred0 and its initialization from init_main.c; initialize
cr_ruidinfo there.
o Restruction many credential modification chunks to always crdup while
we figure out locking and optimizations; generally speaking, this
means moving to a structure like this:
newcred = crdup(oldcred);
...
p->p_ucred = newcred;
crfree(oldcred);
It's not race-free, but better than nothing. There are also races
in sys_process.c, all inter-process authorization, fork, exec, and
exit.
o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid;
remove comments indicating that the old arrangement was a problem.
o Restructure exec1() a little to use newcred/oldcred arrangement, and
use improved uid management primitives.
o Clean up exit1() so as to do less work in credential cleanup due to
pcred removal.
o Clean up fork1() so as to do less work in credential cleanup and
allocation.
o Clean up ktrcanset() to take into account changes, and move to using
suser_xxx() instead of performing a direct uid==0 comparision.
o Improve commenting in various kern_prot.c credential modification
calls to better document current behavior. In a couple of places,
current behavior is a little questionable and we need to check
POSIX.1 to make sure it's "right". More commenting work still
remains to be done.
o Update credential management calls, such as crfree(), to take into
account new ruidinfo reference.
o Modify or add the following uid and gid helper routines:
change_euid()
change_egid()
change_ruid()
change_rgid()
change_svuid()
change_svgid()
In each case, the call now acts on a credential not a process, and as
such no longer requires more complicated process locking/etc. They
now assume the caller will do any necessary allocation of an
exclusive credential reference. Each is commented to document its
reference requirements.
o CANSIGIO() is simplified to require only credentials, not processes
and pcreds.
o Remove lots of (p_pcred==NULL) checks.
o Add an XXX to authorization code in nfs_lock.c, since it's
questionable, and needs to be considered carefully.
o Simplify posix4 authorization code to require only credentials, not
processes and pcreds. Note that this authorization, as well as
CANSIGIO(), needs to be updated to use the p_cansignal() and
p_cansched() centralized authorization routines, as they currently
do not take into account some desirable restrictions that are handled
by the centralized routines, as well as being inconsistent with other
similar authorization instances.
o Update libkvm to take these changes into account.
Obtained from: TrustedBSD Project
Reviewed by: green, bde, jhb, freebsd-arch, freebsd-audit
2001-05-25 16:59:11 +00:00
|
|
|
|
AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
|
1996-03-10 08:42:54 +00:00
|
|
|
|
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
2003-03-03 09:17:12 +00:00
|
|
|
|
|
|
|
|
|
free(imgp->auxargs, M_TEMP);
|
1996-03-10 08:42:54 +00:00
|
|
|
|
imgp->auxargs = NULL;
|
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-10 08:42:54 +00:00
|
|
|
|
(*stack_base)--;
|
2005-01-29 23:12:00 +00:00
|
|
|
|
**stack_base = (register_t)imgp->args->argc;
|
1996-03-10 08:42:54 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
extern int _ucodesel, _udatasel;
|
2001-02-25 06:29:04 +00:00
|
|
|
|
extern unsigned long linux_sznonrtsigcode;
|
2000-10-17 00:00:20 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
|
|
|
|
{
|
2003-03-03 09:17:12 +00:00
|
|
|
|
struct thread *td = curthread;
|
|
|
|
|
struct proc *p = td->td_proc;
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
|
struct sigacts *psp;
|
2003-03-03 09:17:12 +00:00
|
|
|
|
struct trapframe *regs;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_rt_sigframe *fp, frame;
|
2000-10-17 00:00:20 +00:00
|
|
|
|
int oonstack;
|
|
|
|
|
|
2001-09-06 22:20:41 +00:00
|
|
|
|
PROC_LOCK_ASSERT(p, MA_OWNED);
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
|
psp = p->p_sigacts;
|
|
|
|
|
mtx_assert(&psp->ps_mtx, MA_OWNED);
|
2001-09-12 08:38:13 +00:00
|
|
|
|
regs = td->td_frame;
|
2000-11-30 05:23:49 +00:00
|
|
|
|
oonstack = sigonstack(regs->tf_esp);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (ldebug(rt_sendsig))
|
2001-02-16 16:40:43 +00:00
|
|
|
|
printf(ARGS(rt_sendsig, "%p, %d, %p, %lu"),
|
|
|
|
|
catcher, sig, (void*)mask, code);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
#endif
|
|
|
|
|
/*
|
|
|
|
|
* Allocate space for the signal handler context.
|
|
|
|
|
*/
|
2004-01-03 02:02:26 +00:00
|
|
|
|
if ((td->td_pflags & TDP_ALTSTACK) && !oonstack &&
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
|
SIGISMEMBER(psp->ps_sigonstack, sig)) {
|
2004-01-03 02:02:26 +00:00
|
|
|
|
fp = (struct l_rt_sigframe *)(td->td_sigstk.ss_sp +
|
|
|
|
|
td->td_sigstk.ss_size - sizeof(struct l_rt_sigframe));
|
2000-11-30 05:23:49 +00:00
|
|
|
|
} else
|
2001-09-08 19:07:04 +00:00
|
|
|
|
fp = (struct l_rt_sigframe *)regs->tf_esp - 1;
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
|
mtx_unlock(&psp->ps_mtx);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Build the argument list for the signal handler.
|
|
|
|
|
*/
|
|
|
|
|
if (p->p_sysent->sv_sigtbl)
|
|
|
|
|
if (sig <= p->p_sysent->sv_sigsize)
|
|
|
|
|
sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)];
|
|
|
|
|
|
2002-11-02 07:41:04 +00:00
|
|
|
|
bzero(&frame, sizeof(frame));
|
|
|
|
|
|
2000-10-17 00:00:20 +00:00
|
|
|
|
frame.sf_handler = catcher;
|
|
|
|
|
frame.sf_sig = sig;
|
|
|
|
|
frame.sf_siginfo = &fp->sf_si;
|
|
|
|
|
frame.sf_ucontext = &fp->sf_sc;
|
2000-11-23 08:55:30 +00:00
|
|
|
|
|
2002-09-07 18:56:18 +00:00
|
|
|
|
/* Fill in POSIX parts */
|
2000-10-17 00:00:20 +00:00
|
|
|
|
frame.sf_si.lsi_signo = sig;
|
|
|
|
|
frame.sf_si.lsi_code = code;
|
|
|
|
|
frame.sf_si.lsi_addr = (void *)regs->tf_err;
|
2000-11-23 08:55:30 +00:00
|
|
|
|
|
2000-10-17 00:00:20 +00:00
|
|
|
|
/*
|
|
|
|
|
* Build the signal context to be used by sigreturn.
|
|
|
|
|
*/
|
2000-11-23 08:55:30 +00:00
|
|
|
|
frame.sf_sc.uc_flags = 0; /* XXX ??? */
|
|
|
|
|
frame.sf_sc.uc_link = NULL; /* XXX ??? */
|
|
|
|
|
|
2004-01-03 02:02:26 +00:00
|
|
|
|
frame.sf_sc.uc_stack.ss_sp = td->td_sigstk.ss_sp;
|
|
|
|
|
frame.sf_sc.uc_stack.ss_size = td->td_sigstk.ss_size;
|
|
|
|
|
frame.sf_sc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK)
|
2000-11-30 05:23:49 +00:00
|
|
|
|
? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE;
|
2001-01-24 00:27:28 +00:00
|
|
|
|
PROC_UNLOCK(p);
|
2000-11-23 08:55:30 +00:00
|
|
|
|
|
|
|
|
|
bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask);
|
|
|
|
|
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__bits[0];
|
2000-10-17 00:00:20 +00:00
|
|
|
|
frame.sf_sc.uc_mcontext.sc_gs = rgs();
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_es = regs->tf_es;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_ds = regs->tf_ds;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_edi = regs->tf_edi;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_esi = regs->tf_esi;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_ebp = regs->tf_ebp;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_ebx = regs->tf_ebx;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_edx = regs->tf_edx;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_ecx = regs->tf_ecx;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_eax = regs->tf_eax;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_eip = regs->tf_eip;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_cs = regs->tf_cs;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_eflags = regs->tf_eflags;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_esp_at_signal = regs->tf_esp;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_ss = regs->tf_ss;
|
|
|
|
|
frame.sf_sc.uc_mcontext.sc_err = regs->tf_err;
|
2001-11-20 09:39:31 +00:00
|
|
|
|
frame.sf_sc.uc_mcontext.sc_trapno = bsd_to_linux_trapcode(code);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (ldebug(rt_sendsig))
|
2001-02-16 16:40:43 +00:00
|
|
|
|
printf(LMSG("rt_sendsig flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x"),
|
2004-01-03 23:31:29 +00:00
|
|
|
|
frame.sf_sc.uc_stack.ss_flags, td->td_sigstk.ss_sp,
|
|
|
|
|
td->td_sigstk.ss_size, frame.sf_sc.uc_mcontext.sc_mask);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (copyout(&frame, fp, sizeof(frame)) != 0) {
|
|
|
|
|
/*
|
|
|
|
|
* Process has trashed its stack; give it an illegal
|
|
|
|
|
* instruction to halt it in its tracks.
|
|
|
|
|
*/
|
2002-03-19 04:54:30 +00:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
if (ldebug(rt_sendsig))
|
|
|
|
|
printf(LMSG("rt_sendsig: bad stack %p, oonstack=%x"),
|
|
|
|
|
fp, oonstack);
|
|
|
|
|
#endif
|
2001-03-07 03:37:06 +00:00
|
|
|
|
PROC_LOCK(p);
|
2001-09-12 08:38:13 +00:00
|
|
|
|
sigexit(td, SIGILL);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Build context to run handler in.
|
|
|
|
|
*/
|
|
|
|
|
regs->tf_esp = (int)fp;
|
2003-03-03 09:17:12 +00:00
|
|
|
|
regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode) +
|
2001-02-25 06:29:04 +00:00
|
|
|
|
linux_sznonrtsigcode;
|
2002-01-10 11:49:55 +00:00
|
|
|
|
regs->tf_eflags &= ~(PSL_T | PSL_VM);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
regs->tf_cs = _ucodesel;
|
|
|
|
|
regs->tf_ds = _udatasel;
|
|
|
|
|
regs->tf_es = _udatasel;
|
|
|
|
|
regs->tf_fs = _udatasel;
|
|
|
|
|
regs->tf_ss = _udatasel;
|
2001-09-06 22:20:41 +00:00
|
|
|
|
PROC_LOCK(p);
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
|
mtx_lock(&psp->ps_mtx);
|
2000-10-17 00:00:20 +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
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Send an interrupt to process.
|
|
|
|
|
*
|
|
|
|
|
* Stack is set up to allow sigcode stored
|
|
|
|
|
* in u. 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.
|
|
|
|
|
*/
|
1998-02-09 06:11:36 +00:00
|
|
|
|
static void
|
1999-09-29 15:12:18 +00:00
|
|
|
|
linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
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
|
|
|
|
{
|
2003-03-03 09:17:12 +00:00
|
|
|
|
struct thread *td = curthread;
|
|
|
|
|
struct proc *p = td->td_proc;
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
|
struct sigacts *psp;
|
2003-03-03 09:17:12 +00:00
|
|
|
|
struct trapframe *regs;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_sigframe *fp, frame;
|
|
|
|
|
l_sigset_t lmask;
|
2000-11-13 20:44:05 +00:00
|
|
|
|
int oonstack, i;
|
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-17 17:22:31 +00:00
|
|
|
|
PROC_LOCK_ASSERT(p, MA_OWNED);
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
|
psp = p->p_sigacts;
|
|
|
|
|
mtx_assert(&psp->ps_mtx, MA_OWNED);
|
|
|
|
|
if (SIGISMEMBER(psp->ps_siginfo, sig)) {
|
2000-11-23 08:55:30 +00:00
|
|
|
|
/* Signal handler installed with SA_SIGINFO. */
|
|
|
|
|
linux_rt_sendsig(catcher, sig, mask, code);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
|
regs = td->td_frame;
|
2000-11-30 05:23:49 +00:00
|
|
|
|
oonstack = sigonstack(regs->tf_esp);
|
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
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-09-08 19:07:04 +00:00
|
|
|
|
if (ldebug(sendsig))
|
2001-02-16 16:40:43 +00:00
|
|
|
|
printf(ARGS(sendsig, "%p, %d, %p, %lu"),
|
|
|
|
|
catcher, sig, (void*)mask, code);
|
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
|
|
|
|
#endif
|
2000-10-17 00:00:20 +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
|
|
|
|
/*
|
|
|
|
|
* Allocate space for the signal handler context.
|
|
|
|
|
*/
|
2004-01-03 02:02:26 +00:00
|
|
|
|
if ((td->td_pflags & TDP_ALTSTACK) && !oonstack &&
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
|
SIGISMEMBER(psp->ps_sigonstack, sig)) {
|
2004-01-03 02:02:26 +00:00
|
|
|
|
fp = (struct l_sigframe *)(td->td_sigstk.ss_sp +
|
|
|
|
|
td->td_sigstk.ss_size - sizeof(struct l_sigframe));
|
2000-11-30 05:23:49 +00:00
|
|
|
|
} else
|
2001-09-08 19:07:04 +00:00
|
|
|
|
fp = (struct l_sigframe *)regs->tf_esp - 1;
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
|
mtx_unlock(&psp->ps_mtx);
|
2001-01-24 00:27:28 +00:00
|
|
|
|
PROC_UNLOCK(p);
|
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
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Build the argument list for the signal handler.
|
|
|
|
|
*/
|
1999-09-29 15:12:18 +00:00
|
|
|
|
if (p->p_sysent->sv_sigtbl)
|
|
|
|
|
if (sig <= p->p_sysent->sv_sigsize)
|
|
|
|
|
sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)];
|
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
|
|
|
|
|
2002-11-02 07:41:04 +00:00
|
|
|
|
bzero(&frame, sizeof(frame));
|
|
|
|
|
|
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
|
|
|
|
frame.sf_handler = catcher;
|
|
|
|
|
frame.sf_sig = sig;
|
|
|
|
|
|
2000-11-23 08:55:30 +00:00
|
|
|
|
bsd_to_linux_sigset(mask, &lmask);
|
|
|
|
|
|
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
|
|
|
|
/*
|
|
|
|
|
* Build the signal context to be used by sigreturn.
|
|
|
|
|
*/
|
2000-11-23 08:55:30 +00:00
|
|
|
|
frame.sf_sc.sc_mask = lmask.__bits[0];
|
1999-04-28 01:04:33 +00:00
|
|
|
|
frame.sf_sc.sc_gs = rgs();
|
|
|
|
|
frame.sf_sc.sc_fs = regs->tf_fs;
|
1997-05-07 20:05:45 +00:00
|
|
|
|
frame.sf_sc.sc_es = regs->tf_es;
|
|
|
|
|
frame.sf_sc.sc_ds = regs->tf_ds;
|
|
|
|
|
frame.sf_sc.sc_edi = regs->tf_edi;
|
|
|
|
|
frame.sf_sc.sc_esi = regs->tf_esi;
|
|
|
|
|
frame.sf_sc.sc_ebp = regs->tf_ebp;
|
|
|
|
|
frame.sf_sc.sc_ebx = regs->tf_ebx;
|
|
|
|
|
frame.sf_sc.sc_edx = regs->tf_edx;
|
|
|
|
|
frame.sf_sc.sc_ecx = regs->tf_ecx;
|
|
|
|
|
frame.sf_sc.sc_eax = regs->tf_eax;
|
|
|
|
|
frame.sf_sc.sc_eip = regs->tf_eip;
|
|
|
|
|
frame.sf_sc.sc_cs = regs->tf_cs;
|
|
|
|
|
frame.sf_sc.sc_eflags = regs->tf_eflags;
|
|
|
|
|
frame.sf_sc.sc_esp_at_signal = regs->tf_esp;
|
|
|
|
|
frame.sf_sc.sc_ss = regs->tf_ss;
|
|
|
|
|
frame.sf_sc.sc_err = regs->tf_err;
|
2001-11-20 09:39:31 +00:00
|
|
|
|
frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(code);
|
2000-11-23 08:55:30 +00:00
|
|
|
|
|
2000-11-13 20:44:05 +00:00
|
|
|
|
for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
|
2000-11-23 08:55:30 +00:00
|
|
|
|
frame.sf_extramask[i] = lmask.__bits[i+1];
|
|
|
|
|
|
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
|
|
|
|
if (copyout(&frame, fp, sizeof(frame)) != 0) {
|
|
|
|
|
/*
|
|
|
|
|
* Process has trashed its stack; give it an illegal
|
|
|
|
|
* instruction to halt it in its tracks.
|
|
|
|
|
*/
|
2001-03-07 03:37:06 +00:00
|
|
|
|
PROC_LOCK(p);
|
2001-09-12 08:38:13 +00:00
|
|
|
|
sigexit(td, SIGILL);
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Build context to run handler in.
|
|
|
|
|
*/
|
1997-05-07 20:05:45 +00:00
|
|
|
|
regs->tf_esp = (int)fp;
|
1998-12-16 16:28:58 +00:00
|
|
|
|
regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
|
2002-01-10 11:49:55 +00:00
|
|
|
|
regs->tf_eflags &= ~(PSL_T | PSL_VM);
|
1997-05-07 20:05:45 +00:00
|
|
|
|
regs->tf_cs = _ucodesel;
|
|
|
|
|
regs->tf_ds = _udatasel;
|
|
|
|
|
regs->tf_es = _udatasel;
|
1999-04-28 01:04:33 +00:00
|
|
|
|
regs->tf_fs = _udatasel;
|
1997-05-07 20:05:45 +00:00
|
|
|
|
regs->tf_ss = _udatasel;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
PROC_LOCK(p);
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
|
mtx_lock(&psp->ps_mtx);
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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
|
|
|
|
|
* psl to gain improper privileges or to cause
|
|
|
|
|
* a machine fault.
|
|
|
|
|
*/
|
|
|
|
|
int
|
2002-10-19 11:57:38 +00:00
|
|
|
|
linux_sigreturn(struct thread *td, struct linux_sigreturn_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-12 08:38:13 +00:00
|
|
|
|
struct proc *p = td->td_proc;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_sigframe frame;
|
2003-03-03 09:17:12 +00:00
|
|
|
|
struct trapframe *regs;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
l_sigset_t lmask;
|
2000-11-13 20:44:05 +00:00
|
|
|
|
int eflags, i;
|
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-12 08:38:13 +00:00
|
|
|
|
regs = td->td_frame;
|
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
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(sigreturn))
|
|
|
|
|
printf(ARGS(sigreturn, "%p"), (void *)args->sfp);
|
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
|
|
|
|
#endif
|
|
|
|
|
/*
|
2000-11-23 08:55:30 +00:00
|
|
|
|
* The trampoline code hands us the sigframe.
|
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
|
|
|
|
* It is unsafe to keep track of it ourselves, in the event that a
|
|
|
|
|
* program jumps out of a signal handler.
|
|
|
|
|
*/
|
2003-03-03 09:14:26 +00:00
|
|
|
|
if (copyin(args->sfp, &frame, sizeof(frame)) != 0)
|
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
|
|
|
|
return (EFAULT);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check for security violations.
|
|
|
|
|
*/
|
|
|
|
|
#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0)
|
2000-11-23 08:55:30 +00:00
|
|
|
|
eflags = frame.sf_sc.sc_eflags;
|
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
|
|
|
|
/*
|
|
|
|
|
* XXX do allow users to change the privileged flag PSL_RF. The
|
|
|
|
|
* cpu sets PSL_RF in tf_eflags for faults. Debuggers should
|
|
|
|
|
* sometimes set it there too. tf_eflags is kept in the signal
|
|
|
|
|
* context during signal handling and there is no other place
|
|
|
|
|
* to remember it, so the PSL_RF bit may be corrupted by the
|
|
|
|
|
* signal handler without us knowing. Corruption of the PSL_RF
|
|
|
|
|
* bit at worst causes one more or one less debugger trap, so
|
|
|
|
|
* allowing it is fairly harmless.
|
|
|
|
|
*/
|
2002-10-19 11:57:38 +00:00
|
|
|
|
if (!EFLAGS_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF))
|
2003-03-03 09:17:12 +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
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Don't allow users to load a valid privileged %cs. Let the
|
|
|
|
|
* hardware check for invalid selectors, excess privilege in
|
|
|
|
|
* other selectors, invalid %eip's and invalid %esp's.
|
|
|
|
|
*/
|
1997-08-21 06:33:04 +00:00
|
|
|
|
#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL)
|
2000-11-23 08:55:30 +00:00
|
|
|
|
if (!CS_SECURE(frame.sf_sc.sc_cs)) {
|
2003-03-31 22:02:38 +00:00
|
|
|
|
trapsignal(td, SIGBUS, T_PROTFLT);
|
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
|
|
|
|
return(EINVAL);
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-23 08:55:30 +00:00
|
|
|
|
lmask.__bits[0] = frame.sf_sc.sc_mask;
|
|
|
|
|
for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
|
|
|
|
|
lmask.__bits[i+1] = frame.sf_extramask[i];
|
2001-01-24 00:27:28 +00:00
|
|
|
|
PROC_LOCK(p);
|
2003-03-31 22:49:17 +00:00
|
|
|
|
linux_to_bsd_sigset(&lmask, &td->td_sigmask);
|
|
|
|
|
SIG_CANTMASK(td->td_sigmask);
|
|
|
|
|
signotify(td);
|
2001-01-24 00:27:28 +00:00
|
|
|
|
PROC_UNLOCK(p);
|
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
|
|
|
|
/*
|
|
|
|
|
* Restore signal context.
|
|
|
|
|
*/
|
1999-04-28 01:04:33 +00:00
|
|
|
|
/* %gs was restored by the trampoline. */
|
2000-11-23 08:55:30 +00:00
|
|
|
|
regs->tf_fs = frame.sf_sc.sc_fs;
|
|
|
|
|
regs->tf_es = frame.sf_sc.sc_es;
|
|
|
|
|
regs->tf_ds = frame.sf_sc.sc_ds;
|
|
|
|
|
regs->tf_edi = frame.sf_sc.sc_edi;
|
|
|
|
|
regs->tf_esi = frame.sf_sc.sc_esi;
|
|
|
|
|
regs->tf_ebp = frame.sf_sc.sc_ebp;
|
|
|
|
|
regs->tf_ebx = frame.sf_sc.sc_ebx;
|
|
|
|
|
regs->tf_edx = frame.sf_sc.sc_edx;
|
|
|
|
|
regs->tf_ecx = frame.sf_sc.sc_ecx;
|
|
|
|
|
regs->tf_eax = frame.sf_sc.sc_eax;
|
|
|
|
|
regs->tf_eip = frame.sf_sc.sc_eip;
|
|
|
|
|
regs->tf_cs = frame.sf_sc.sc_cs;
|
1997-05-07 20:05:45 +00:00
|
|
|
|
regs->tf_eflags = eflags;
|
2000-11-23 08:55:30 +00:00
|
|
|
|
regs->tf_esp = frame.sf_sc.sc_esp_at_signal;
|
|
|
|
|
regs->tf_ss = frame.sf_sc.sc_ss;
|
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
|
|
|
|
|
|
|
|
|
return (EJUSTRETURN);
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-17 00:00:20 +00:00
|
|
|
|
/*
|
|
|
|
|
* System call to cleanup state after a signal
|
|
|
|
|
* has been taken. Reset signal mask and
|
|
|
|
|
* stack state from context left by rt_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
|
|
|
|
|
* psl to gain improper privileges or to cause
|
|
|
|
|
* a machine fault.
|
|
|
|
|
*/
|
|
|
|
|
int
|
2002-10-19 11:57:38 +00:00
|
|
|
|
linux_rt_sigreturn(struct thread *td, struct linux_rt_sigreturn_args *args)
|
2000-10-17 00:00:20 +00:00
|
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
|
struct proc *p = td->td_proc;
|
2001-09-08 19:07:04 +00:00
|
|
|
|
struct l_ucontext uc;
|
|
|
|
|
struct l_sigcontext *context;
|
|
|
|
|
l_stack_t *lss;
|
2002-09-01 22:30:27 +00:00
|
|
|
|
stack_t ss;
|
2003-03-03 09:17:12 +00:00
|
|
|
|
struct trapframe *regs;
|
2000-10-17 00:00:20 +00:00
|
|
|
|
int eflags;
|
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
|
regs = td->td_frame;
|
2000-10-17 00:00:20 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(rt_sigreturn))
|
|
|
|
|
printf(ARGS(rt_sigreturn, "%p"), (void *)args->ucp);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
#endif
|
|
|
|
|
/*
|
2000-11-23 08:55:30 +00:00
|
|
|
|
* The trampoline code hands us the ucontext.
|
2000-10-17 00:00:20 +00:00
|
|
|
|
* It is unsafe to keep track of it ourselves, in the event that a
|
|
|
|
|
* program jumps out of a signal handler.
|
|
|
|
|
*/
|
2003-03-03 09:14:26 +00:00
|
|
|
|
if (copyin(args->ucp, &uc, sizeof(uc)) != 0)
|
2000-10-17 00:00:20 +00:00
|
|
|
|
return (EFAULT);
|
|
|
|
|
|
|
|
|
|
context = &uc.uc_mcontext;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check for security violations.
|
|
|
|
|
*/
|
|
|
|
|
#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0)
|
|
|
|
|
eflags = context->sc_eflags;
|
|
|
|
|
/*
|
|
|
|
|
* XXX do allow users to change the privileged flag PSL_RF. The
|
|
|
|
|
* cpu sets PSL_RF in tf_eflags for faults. Debuggers should
|
|
|
|
|
* sometimes set it there too. tf_eflags is kept in the signal
|
|
|
|
|
* context during signal handling and there is no other place
|
|
|
|
|
* to remember it, so the PSL_RF bit may be corrupted by the
|
|
|
|
|
* signal handler without us knowing. Corruption of the PSL_RF
|
|
|
|
|
* bit at worst causes one more or one less debugger trap, so
|
|
|
|
|
* allowing it is fairly harmless.
|
|
|
|
|
*/
|
2002-10-19 11:57:38 +00:00
|
|
|
|
if (!EFLAGS_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF))
|
2003-03-03 09:17:12 +00:00
|
|
|
|
return(EINVAL);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Don't allow users to load a valid privileged %cs. Let the
|
|
|
|
|
* hardware check for invalid selectors, excess privilege in
|
|
|
|
|
* other selectors, invalid %eip's and invalid %esp's.
|
|
|
|
|
*/
|
|
|
|
|
#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL)
|
|
|
|
|
if (!CS_SECURE(context->sc_cs)) {
|
2003-03-31 22:02:38 +00:00
|
|
|
|
trapsignal(td, SIGBUS, T_PROTFLT);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
return(EINVAL);
|
|
|
|
|
}
|
|
|
|
|
|
2001-01-24 00:27:28 +00:00
|
|
|
|
PROC_LOCK(p);
|
2003-03-31 22:49:17 +00:00
|
|
|
|
linux_to_bsd_sigset(&uc.uc_sigmask, &td->td_sigmask);
|
|
|
|
|
SIG_CANTMASK(td->td_sigmask);
|
|
|
|
|
signotify(td);
|
2001-01-24 00:27:28 +00:00
|
|
|
|
PROC_UNLOCK(p);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2000-11-23 08:55:30 +00:00
|
|
|
|
* Restore signal context
|
2000-10-17 00:00:20 +00:00
|
|
|
|
*/
|
|
|
|
|
/* %gs was restored by the trampoline. */
|
|
|
|
|
regs->tf_fs = context->sc_fs;
|
|
|
|
|
regs->tf_es = context->sc_es;
|
|
|
|
|
regs->tf_ds = context->sc_ds;
|
|
|
|
|
regs->tf_edi = context->sc_edi;
|
|
|
|
|
regs->tf_esi = context->sc_esi;
|
|
|
|
|
regs->tf_ebp = context->sc_ebp;
|
|
|
|
|
regs->tf_ebx = context->sc_ebx;
|
|
|
|
|
regs->tf_edx = context->sc_edx;
|
|
|
|
|
regs->tf_ecx = context->sc_ecx;
|
|
|
|
|
regs->tf_eax = context->sc_eax;
|
|
|
|
|
regs->tf_eip = context->sc_eip;
|
|
|
|
|
regs->tf_cs = context->sc_cs;
|
|
|
|
|
regs->tf_eflags = eflags;
|
|
|
|
|
regs->tf_esp = context->sc_esp_at_signal;
|
|
|
|
|
regs->tf_ss = context->sc_ss;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* call sigaltstack & ignore results..
|
|
|
|
|
*/
|
|
|
|
|
lss = &uc.uc_stack;
|
2002-09-01 22:30:27 +00:00
|
|
|
|
ss.ss_sp = lss->ss_sp;
|
|
|
|
|
ss.ss_size = lss->ss_size;
|
|
|
|
|
ss.ss_flags = linux_to_bsd_sigaltstack(lss->ss_flags);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-02-16 16:40:43 +00:00
|
|
|
|
if (ldebug(rt_sigreturn))
|
|
|
|
|
printf(LMSG("rt_sigret flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x"),
|
2002-09-01 22:30:27 +00:00
|
|
|
|
ss.ss_flags, ss.ss_sp, ss.ss_size, context->sc_mask);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
#endif
|
2002-09-01 22:30:27 +00:00
|
|
|
|
(void)kern_sigaltstack(td, &ss, NULL);
|
2000-10-17 00:00:20 +00:00
|
|
|
|
|
|
|
|
|
return (EJUSTRETURN);
|
|
|
|
|
}
|
|
|
|
|
|
2001-08-30 18:50:57 +00:00
|
|
|
|
/*
|
|
|
|
|
* MPSAFE
|
|
|
|
|
*/
|
1998-02-09 06:11:36 +00:00
|
|
|
|
static void
|
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
|
|
|
|
linux_prepsyscall(struct trapframe *tf, int *args, u_int *code, caddr_t *params)
|
|
|
|
|
{
|
|
|
|
|
args[0] = tf->tf_ebx;
|
|
|
|
|
args[1] = tf->tf_ecx;
|
|
|
|
|
args[2] = tf->tf_edx;
|
|
|
|
|
args[3] = tf->tf_esi;
|
|
|
|
|
args[4] = tf->tf_edi;
|
2002-09-07 04:59:49 +00:00
|
|
|
|
args[5] = tf->tf_ebp; /* Unconfirmed */
|
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
|
|
|
|
*params = NULL; /* no copyin */
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 20:58:40 +00:00
|
|
|
|
/*
|
2003-03-03 09:17:12 +00:00
|
|
|
|
* If a linux binary is exec'ing something, try this image activator
|
2000-04-26 20:58:40 +00:00
|
|
|
|
* first. We override standard shell script execution in order to
|
|
|
|
|
* be able to modify the interpreter path. We only do this if a linux
|
|
|
|
|
* binary is doing the exec, so we do not create an EXEC module for it.
|
|
|
|
|
*/
|
2002-03-20 07:51:46 +00:00
|
|
|
|
static int exec_linux_imgact_try(struct image_params *iparams);
|
2000-04-26 20:58:40 +00:00
|
|
|
|
|
|
|
|
|
static int
|
2002-10-19 11:57:38 +00:00
|
|
|
|
exec_linux_imgact_try(struct image_params *imgp)
|
2000-04-26 20:58:40 +00:00
|
|
|
|
{
|
|
|
|
|
const char *head = (const char *)imgp->image_header;
|
2005-02-07 18:37:51 +00:00
|
|
|
|
char *rpath;
|
|
|
|
|
int error = -1, len;
|
2000-04-26 20:58:40 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The interpreter for shell scripts run from a linux binary needs
|
|
|
|
|
* to be located in /compat/linux if possible in order to recursively
|
|
|
|
|
* maintain linux path emulation.
|
|
|
|
|
*/
|
|
|
|
|
if (((const short *)head)[0] == SHELLMAGIC) {
|
|
|
|
|
/*
|
|
|
|
|
* Run our normal shell image activator. If it succeeds attempt
|
|
|
|
|
* to use the alternate path for the interpreter. If an alternate
|
|
|
|
|
* path is found, use our stringspace to store it.
|
|
|
|
|
*/
|
|
|
|
|
if ((error = exec_shell_imgact(imgp)) == 0) {
|
2005-02-07 18:37:51 +00:00
|
|
|
|
linux_emul_convpath(FIRST_THREAD_IN_PROC(imgp->proc),
|
|
|
|
|
imgp->interpreter_name, UIO_SYSSPACE, &rpath, 0);
|
|
|
|
|
if (rpath != NULL) {
|
|
|
|
|
len = strlen(rpath) + 1;
|
2000-04-26 20:58:40 +00:00
|
|
|
|
|
|
|
|
|
if (len <= MAXSHELLCMDLEN) {
|
2001-10-27 11:15:19 +00:00
|
|
|
|
memcpy(imgp->interpreter_name, rpath, len);
|
2000-04-26 20:58:40 +00:00
|
|
|
|
}
|
|
|
|
|
free(rpath, M_TEMP);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return(error);
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-11 21:51:11 +00:00
|
|
|
|
/*
|
|
|
|
|
* exec_setregs may initialize some registers differently than Linux
|
|
|
|
|
* does, thus potentially confusing Linux binaries. If necessary, we
|
|
|
|
|
* override the exec_setregs default(s) here.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
exec_linux_setregs(struct thread *td, u_long entry,
|
|
|
|
|
u_long stack, u_long ps_strings)
|
|
|
|
|
{
|
2005-02-06 17:29:20 +00:00
|
|
|
|
static const u_short control = __LINUX_NPXCW__;
|
2003-05-11 21:51:11 +00:00
|
|
|
|
struct pcb *pcb = td->td_pcb;
|
|
|
|
|
|
|
|
|
|
exec_setregs(td, entry, stack, ps_strings);
|
|
|
|
|
|
|
|
|
|
/* Linux sets %gs to 0, we default to _udatasel */
|
|
|
|
|
pcb->pcb_gs = 0; load_gs(0);
|
2005-02-06 17:29:20 +00:00
|
|
|
|
|
|
|
|
|
/* Linux sets the i387 to extended precision. */
|
|
|
|
|
fldcw(&control);
|
2003-05-11 21:51:11 +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
|
|
|
|
struct sysentvec linux_sysvec = {
|
1996-03-10 08:42:54 +00:00
|
|
|
|
LINUX_SYS_MAXSYSCALL,
|
|
|
|
|
linux_sysent,
|
|
|
|
|
0xff,
|
1999-09-29 15:12:18 +00:00
|
|
|
|
LINUX_SIGTBLSZ,
|
1996-03-10 08:42:54 +00:00
|
|
|
|
bsd_to_linux_signal,
|
2003-03-03 09:17:12 +00:00
|
|
|
|
ELAST + 1,
|
1996-03-10 08:42:54 +00:00
|
|
|
|
bsd_to_linux_errno,
|
1998-04-28 18:15:08 +00:00
|
|
|
|
translate_traps,
|
1996-03-10 08:42:54 +00:00
|
|
|
|
linux_fixup,
|
|
|
|
|
linux_sendsig,
|
2003-03-03 09:17:12 +00:00
|
|
|
|
linux_sigcode,
|
1996-03-10 08:42:54 +00:00
|
|
|
|
&linux_szsigcode,
|
|
|
|
|
linux_prepsyscall,
|
1998-09-14 05:36:51 +00:00
|
|
|
|
"Linux a.out",
|
2004-11-27 06:46:45 +00:00
|
|
|
|
NULL,
|
2000-11-09 08:25:48 +00:00
|
|
|
|
exec_linux_imgact_try,
|
2002-09-01 21:41:24 +00:00
|
|
|
|
LINUX_MINSIGSTKSZ,
|
|
|
|
|
PAGE_SIZE,
|
|
|
|
|
VM_MIN_ADDRESS,
|
|
|
|
|
VM_MAXUSER_ADDRESS,
|
|
|
|
|
USRSTACK,
|
|
|
|
|
PS_STRINGS,
|
|
|
|
|
VM_PROT_ALL,
|
|
|
|
|
exec_copyout_strings,
|
2003-09-25 01:10:26 +00:00
|
|
|
|
exec_linux_setregs,
|
|
|
|
|
NULL
|
1996-03-10 08:42:54 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct sysentvec elf_linux_sysvec = {
|
1999-09-29 15:12:18 +00:00
|
|
|
|
LINUX_SYS_MAXSYSCALL,
|
|
|
|
|
linux_sysent,
|
|
|
|
|
0xff,
|
|
|
|
|
LINUX_SIGTBLSZ,
|
|
|
|
|
bsd_to_linux_signal,
|
|
|
|
|
ELAST + 1,
|
|
|
|
|
bsd_to_linux_errno,
|
|
|
|
|
translate_traps,
|
|
|
|
|
elf_linux_fixup,
|
|
|
|
|
linux_sendsig,
|
|
|
|
|
linux_sigcode,
|
|
|
|
|
&linux_szsigcode,
|
|
|
|
|
linux_prepsyscall,
|
1998-09-14 05:36:51 +00:00
|
|
|
|
"Linux ELF",
|
2002-07-20 02:56:12 +00:00
|
|
|
|
elf32_coredump,
|
2000-11-09 08:25:48 +00:00
|
|
|
|
exec_linux_imgact_try,
|
2002-09-01 21:41:24 +00:00
|
|
|
|
LINUX_MINSIGSTKSZ,
|
|
|
|
|
PAGE_SIZE,
|
|
|
|
|
VM_MIN_ADDRESS,
|
|
|
|
|
VM_MAXUSER_ADDRESS,
|
|
|
|
|
USRSTACK,
|
|
|
|
|
PS_STRINGS,
|
|
|
|
|
VM_PROT_ALL,
|
|
|
|
|
exec_copyout_strings,
|
2003-09-25 01:10:26 +00:00
|
|
|
|
exec_linux_setregs,
|
|
|
|
|
NULL
|
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-10 08:42:54 +00:00
|
|
|
|
|
1998-10-11 21:08:02 +00:00
|
|
|
|
static Elf32_Brandinfo linux_brand = {
|
2000-04-18 02:39:26 +00:00
|
|
|
|
ELFOSABI_LINUX,
|
2002-07-20 02:56:12 +00:00
|
|
|
|
EM_386,
|
2001-02-24 22:20:11 +00:00
|
|
|
|
"Linux",
|
1996-10-16 17:51:08 +00:00
|
|
|
|
"/compat/linux",
|
1996-03-10 22:42:16 +00:00
|
|
|
|
"/lib/ld-linux.so.1",
|
2003-12-23 02:42:39 +00:00
|
|
|
|
&elf_linux_sysvec,
|
|
|
|
|
NULL,
|
1996-03-10 22:42:16 +00:00
|
|
|
|
};
|
|
|
|
|
|
1998-10-11 21:08:02 +00:00
|
|
|
|
static Elf32_Brandinfo linux_glibc2brand = {
|
2000-04-18 02:39:26 +00:00
|
|
|
|
ELFOSABI_LINUX,
|
2002-07-20 02:56:12 +00:00
|
|
|
|
EM_386,
|
2001-02-24 22:20:11 +00:00
|
|
|
|
"Linux",
|
1998-09-17 22:08:34 +00:00
|
|
|
|
"/compat/linux",
|
|
|
|
|
"/lib/ld-linux.so.2",
|
2003-12-23 02:42:39 +00:00
|
|
|
|
&elf_linux_sysvec,
|
|
|
|
|
NULL,
|
1998-09-17 22:08:34 +00:00
|
|
|
|
};
|
|
|
|
|
|
1998-10-11 21:08:02 +00:00
|
|
|
|
Elf32_Brandinfo *linux_brandlist[] = {
|
|
|
|
|
&linux_brand,
|
|
|
|
|
&linux_glibc2brand,
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
1998-10-16 03:55:01 +00:00
|
|
|
|
static int
|
1998-11-15 15:33:52 +00:00
|
|
|
|
linux_elf_modevent(module_t mod, int type, void *data)
|
1997-03-29 10:50:27 +00:00
|
|
|
|
{
|
1998-10-11 21:08:02 +00:00
|
|
|
|
Elf32_Brandinfo **brandinfo;
|
|
|
|
|
int error;
|
2001-06-13 10:58:39 +00:00
|
|
|
|
struct linux_ioctl_handler **lihp;
|
1998-10-11 21:08:02 +00:00
|
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
|
|
1998-10-16 03:55:01 +00:00
|
|
|
|
switch(type) {
|
|
|
|
|
case MOD_LOAD:
|
|
|
|
|
for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
|
1999-12-04 11:10:22 +00:00
|
|
|
|
++brandinfo)
|
2002-07-20 02:56:12 +00:00
|
|
|
|
if (elf32_insert_brand_entry(*brandinfo) < 0)
|
1998-10-16 03:55:01 +00:00
|
|
|
|
error = EINVAL;
|
2000-11-23 03:21:58 +00:00
|
|
|
|
if (error == 0) {
|
2001-06-13 10:58:39 +00:00
|
|
|
|
SET_FOREACH(lihp, linux_ioctl_handler_set)
|
|
|
|
|
linux_ioctl_register_handler(*lihp);
|
1999-12-04 11:10:22 +00:00
|
|
|
|
if (bootverbose)
|
2000-11-23 03:21:58 +00:00
|
|
|
|
printf("Linux ELF exec handler installed\n");
|
|
|
|
|
} else
|
|
|
|
|
printf("cannot insert Linux ELF brand handler\n");
|
1998-10-16 03:55:01 +00:00
|
|
|
|
break;
|
|
|
|
|
case MOD_UNLOAD:
|
|
|
|
|
for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
|
1999-12-04 11:10:22 +00:00
|
|
|
|
++brandinfo)
|
2002-07-20 02:56:12 +00:00
|
|
|
|
if (elf32_brand_inuse(*brandinfo))
|
1999-02-04 21:20:13 +00:00
|
|
|
|
error = EBUSY;
|
|
|
|
|
if (error == 0) {
|
|
|
|
|
for (brandinfo = &linux_brandlist[0];
|
1999-12-04 11:10:22 +00:00
|
|
|
|
*brandinfo != NULL; ++brandinfo)
|
2002-07-20 02:56:12 +00:00
|
|
|
|
if (elf32_remove_brand_entry(*brandinfo) < 0)
|
1999-02-04 21:20:13 +00:00
|
|
|
|
error = EINVAL;
|
|
|
|
|
}
|
2000-11-23 03:21:58 +00:00
|
|
|
|
if (error == 0) {
|
2001-06-13 10:58:39 +00:00
|
|
|
|
SET_FOREACH(lihp, linux_ioctl_handler_set)
|
|
|
|
|
linux_ioctl_unregister_handler(*lihp);
|
2000-11-23 03:21:58 +00:00
|
|
|
|
if (bootverbose)
|
|
|
|
|
printf("Linux ELF exec handler removed\n");
|
2003-03-26 18:29:44 +00:00
|
|
|
|
linux_mib_destroy();
|
2000-11-23 03:21:58 +00:00
|
|
|
|
} else
|
1998-10-16 03:55:01 +00:00
|
|
|
|
printf("Could not deinstall ELF interpreter entry\n");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2004-07-15 08:26:07 +00:00
|
|
|
|
return EOPNOTSUPP;
|
1998-10-16 03:55:01 +00:00
|
|
|
|
}
|
|
|
|
|
return error;
|
1997-03-29 10:50:27 +00:00
|
|
|
|
}
|
2000-11-23 03:21:58 +00:00
|
|
|
|
|
1998-10-16 03:55:01 +00:00
|
|
|
|
static moduledata_t linux_elf_mod = {
|
|
|
|
|
"linuxelf",
|
|
|
|
|
linux_elf_modevent,
|
|
|
|
|
0
|
|
|
|
|
};
|
2000-11-23 03:21:58 +00:00
|
|
|
|
|
1998-10-16 03:55:01 +00:00
|
|
|
|
DECLARE_MODULE(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY);
|