History log of /freebsd-current/sys/compat/linux/linux_signal.c
Revision Date Author Comments
# 227d01c1 18-Sep-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): On Linux SIGKILL can not be reset to default

MFC after: 1 week


# 794328fb 18-Sep-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Staticize lsiginfo_to_siginfo

It's not used outside of linux_signal.c
While here fix the indentation.

MFC after: 1 week


# 3460fab5 18-Aug-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# e185d83f 26-Apr-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Use inlined LINUX_KERNVER for tests to improve readability

MFC after: 1 month


# c8a79231 14-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Rename linux_timer.h to linux_time.h

To avoid confusing people, rename linux_timer.h to linux_time.h,
as linux_timer.c is the implementation of timer syscalls only,
while linux_time.c contains implementation of all stuff declared
in linux_time.h.

MFC after: 2 weeks


# d8e53d94 14-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Cleanup includes under compat/linux

Cleanup unneeded includes, sort the rest according to style(9).
No functional changes.

MFC after: 2 weeks


# 10d16789 12-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Get rid of the opt_compat.h include.

Since e013e369 COMPAT_LINUX, COMPAT_LINUX32 build options are removed,
so include of opt_compat.h is no more needed.

MFC after: 2 weeks


# d3d3b76c 16-Jul-2022 Gordon Bergling <gbe@FreeBSD.org>

linux(4): Fix a typo in a source code comment

- s/alredy/already/

MFC after: 3 days


# 93107373 22-Jun-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Trace Linux l_sigset_t.

MFC after: 2 weeks


# 2722e515 30-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Prefer sizeof(object) vs sizeof(type)

MFC after: 2 weeks


# 55731437 30-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Error is not a bool, use proper comparison

MFC afer: 2 weeks


# 5e872c27 30-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Use the copyin_sigset() in the remaining places

MFC after: 2 weeks


# a6f85b12 19-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Convert the native kernel signal codes into the Linux codes

MFC after: 2 weeks


# 707e567a 08-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Add a helper intended for copying timespec's from the userspace.

There are many places where we copyin Linux timespec from the userspace
and then convert it to the kernel timespec. To avoid code duplication
add a tiny halper for doing this.

MFC after: 2 weeks


# 3923e632 26-Apr-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Add copyin_sigset() helper.

MFC after: 2 weeks


# 6201a50d 25-Apr-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Refactor signal send methods.

Created a couple of helpers to send signals to the specific thread or to
the whole process. Use helpers in the corresponding syscalls.
This fixes the confusion where a signal destined for a whole process
was sent to a specific thread and vice versa.
There is an exclusion for the linux_kill() syscall that takes a pid
argument and should send a signal to the whole process, but I know
at least one example where kill() takes tid.

MFC after: 2 weeks


# c8c93b15 29-Oct-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux: Also translate the signal if the code is CLD_KILLED

This fixes ./waitid.gen.test from the strace(1) test suite.

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32617


# 30c6d982 26-Jul-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux: implement sigaltstack(2) on arm64

... by making it machine-independent.

Reviewed By: dchagin
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D31286


# 72f7ddb5 23-Jul-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux: implement rt_sigsuspend(2) on arm64

... by making it architecture-independent.

Reviewed By: dchagin
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D31259


# 3eaf271d 13-Jul-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux(4): Improve comment about SA_RESTORER

No functional changes.

Sponsored By: EPSRC


# db4a1f33 10-Jun-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Implement rt_sigtimedwait_time64 system call.

It still does not work as intended, awaits D30675.

MFC after: 2 weeks


# f4e80108 06-Jun-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): optimize ksiginfo to siginfo conversion.

Retire ksiginfo_to_lsiginfo function, use siginfo_to_lsiginfo instead.
Convert rt_sigtimedwait siginfo variables to well known names.

MFC after: 2 weeks


# 9c1045ff 06-Jun-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Properly convert linux siginfo to native siginfo
add input validation.

MFC after: 2 weeks


# 0f8dab45 06-Jun-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Fix timeout parameter of rt_sigtimedwait syscall, which is
timespec not a timeval.

MFC after: 2 weeks


# 1a180032 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

compat: clean up empty lines in .c and .h files


# 9bc42c18 30-Jun-2020 Edward Tomasz Napierala <trasz@FreeBSD.org>

Make linux(4) ignore SA_INTERRUPT. The zsh(1) binary from Bionic uses it.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25499


# d5629eb2 27-Jun-2020 Edward Tomasz Napierala <trasz@FreeBSD.org>

Make linux(4) warn about unsupported SA_ flags.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25453


# 34ad5ac2 13-Dec-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Add kern_kill() and use it in Linuxulator. It's just a cleanup,
no functional changes.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22645


# c5156c77 13-May-2019 Dmitry Chagin <dchagin@FreeBSD.org>

Linuxulator depends on a fundamental kernel settings such as SMP. Many
of them listed in opt_global.h which is not generated while building
modules outside of a kernel and such modules never match real cofigured
kernel.

So, we should prevent our users from building obviously defective modules.

Therefore, remove the root cause of the building of modules outside of a
kernel - the possibility of building modules with DEBUG or KTR flags.
And remove all of DEBUG printfs as it is incomplete and in threaded
programms not informative, also a half of system call does not have DEBUG
printf. For debuging Linux programms we have dtrace, ktr and ktrace ability.

PR: 222861
Reviewed by: trasz
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20178


# 340f4a8d 12-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Linuxulator: apply style(9) to return

Sponsored by: Turing Robotic Industries Inc.


# 0ba1b365 16-Feb-2018 Ed Maste <emaste@FreeBSD.org>

Rationalize license text on Linuxolator files

Many licenses on Linuxolator files contained small variations from the
standard FreeBSD license text. To avoid license proliferation switch to
the standard 2-clause FreeBSD license for those files where I have
permission from each of the listed copyright holders. Additional files
waiting on permission from others are listed in review D14210.

Approved by: kan, marcel, sos, rdivacky
MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# 132f90c6 05-Feb-2018 Ed Maste <emaste@FreeBSD.org>

Linuxolator whitespace cleanup

A version of each of the MD files by necessity exists for each CPU
architecture supported by the Linuxolator. Clean these up so that new
architectures do not inherit whitespace issues.

Clean up shared Linuxolator files while here.

Sponsored by: Turing Robotic Industries Inc.


# 7f2d13d6 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/compat: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# 537d0fb1 11-Nov-2017 Mateusz Guzik <mjg@FreeBSD.org>

Use pfind_any in linux_rt_sigqueueinfo and kern_sigqueue


# 486a06bd 19-Feb-2017 Dmitry Chagin <dchagin@FreeBSD.org>

Implement rt_tgsigqueueinfo system call used by glibc for pthread_sigqueue(3).

MFC after: 2 week


# 4ab7403b 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Rework signal code to allow using it by other modules, like linprocfs:

1. Linux sigset always 64 bit on all platforms. In order to move Linux
sigset code to the linux_common module define it as 64 bit int. Move
Linux sigset manipulation routines to the MI path.

2. Move Linux signal number definitions to the MI path. In general, they
are the same on all platforms except for a few signals.

3. Map Linux RT signals to the FreeBSD RT signals and hide signal conversion
tables to avoid conversion errors.

4. Emulate Linux SIGPWR signal via FreeBSD SIGRTMIN signal which is outside
of allowed on Linux signal numbers.

PR: 197216


# a7ac4576 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

According to Linux man sigaltstack(3) shall return EINVAL if the ss
argument is not a null pointer, and the ss_flags member pointed to by ss
contains flags other than SS_DISABLE. However, in fact, Linux also
allows SS_ONSTACK flag which is simply ignored.

For buggy apps (at least mono) ignore other than SS_DISABLE
flags as a Linux do.

While here move MI part of sigaltstack code to the appropriate place.

Reported by: abi at abinet dot ru


# 26c68e1f 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Use the BSD_TO_LINUX_SIGNAL() wherever there is no need
to check the ABI as it is known.

Differential Revision: https://reviews.freebsd.org/D1086


# 4ca75bed 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Fix compilation with -DDEBUG option.

Differential Revision: https://reviews.freebsd.org/D1070
Reviewed by: trasz


# 7f8f1d7f 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Disable i386 call for x86-64 Linux.

Differential Revision: https://reviews.freebsd.org/D1067
Reviewed by: trasz


# 7ac9766d 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Implement rt_sigqueueinfo() system call.

Differential Revision: https://reviews.freebsd.org/D1047
Reviewed by: trasz


# fe4ed1e7 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Add a siginfo_t conversion function.

Differential Revision: https://reviews.freebsd.org/D1044
Reviewed by: emaste, trasz


# 81338031 24-May-2015 Dmitry Chagin <dchagin@FreeBSD.org>

Switch linuxulator to use the native 1:1 threads.

The reasons:
1. Get rid of the stubs/quirks with process dethreading,
process reparent when the process group leader exits and close
to this problems on wait(), waitpid(), etc.
2. Reuse our kernel code instead of writing excessive thread
managment routines in Linuxulator.

Implementation details:

1. The thread is created via kern_thr_new() in the clone() call with
the CLONE_THREAD parameter. Thus, everything else is a process.
2. The test that the process has a threads is done via P_HADTHREADS
bit p_flag of struct proc.
3. Per thread emulator state data structure is now located in the
struct thread and freed in the thread_dtor() hook.
Mandatory holdig of the p_mtx required when referencing emuldata
from the other threads.
4. PID mangling has changed. Now Linux pid is the native tid
and Linux tgid is the native pid, with the exception of the first
thread in the process where tid and pid are one and the same.

Ugliness:

In case when the Linux thread is the initial thread in the thread
group thread id is equal to the process id. Glibc depends on this
magic (assert in pthread_getattr_np.c). So for system calls that
take thread id as a parameter we should use the special method
to reference struct thread.

Differential Revision: https://reviews.freebsd.org/D1039


# 9a14aa01 15-Jan-2012 Ulrich Spörlein <uqs@FreeBSD.org>

Convert files to UTF-8


# 8451d0dd 16-Sep-2011 Kip Macy <kmacy@FreeBSD.org>

In order to maximize the re-usability of kernel code in user space this
patch modifies makesyscalls.sh to prefix all of the non-compatibility
calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel
entry points and all places in the code that use them. It also
fixes an additional name space collision between the kernel function
psignal and the libc function of the same name by renaming the kernel
psignal kern_psignal(). By introducing this change now we will ease future
MFCs that change syscalls.

Reviewed by: rwatson
Approved by: re (bz)


# 09d6cb0a 15-Feb-2011 Dmitry Chagin <dchagin@FreeBSD.org>

For realtime signals fill the sigval value.


# f3481dd9 15-Feb-2011 Dmitry Chagin <dchagin@FreeBSD.org>

Make a linux_rt_sigtimedwait() system call is actually working.

1) Translate the native signal number in the appropriate Linux signal.
2) Remove bogus code, which can lead to a panic as it calls
kern_sigtimedwait with same ksiginfo.
3) Return the corresponding signal number.


# 8c50c562 15-Feb-2011 Dmitry Chagin <dchagin@FreeBSD.org>

Style(9) fix. Wrap long lines in linux_rt_sigtimedwait().


# 9a6a64d3 23-Jan-2011 Dmitry Chagin <dchagin@FreeBSD.org>

Style(9) fix.

Approved by: kib(mentor)
MFC after: 1 month


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# ad6eec7b 29-Jun-2010 John Baldwin <jhb@FreeBSD.org>

Tweak the in-kernel API for sending signals to threads:
- Rename tdsignal() to tdsendsignal() and make it private to kern_sig.c.
- Add tdsignal() and tdksignal() routines that mirror psignal() and
pksignal() except that they accept a thread as an argument instead of
a process. They send a signal to a specific thread rather than to an
individual process.

Reviewed by: kib


# b065c165 21-Dec-2009 Konstantin Belousov <kib@FreeBSD.org>

MFC r200667:
Return earlier from linux_do_tkill() when supplied signal number is 0.


# 9ae781df 18-Dec-2009 Konstantin Belousov <kib@FreeBSD.org>

Signal 0 is used to check the permission for current process to signal
target one. Since r184058, linux_do_tkill() calls tdsignal() instead of
kill(), without checking for validity of supplied signal number. Prevent
panic when supplied signal is 0 by finishing work after checks.

Found and tested by: scf
MFC after: 3 days


# 14961ba7 27-Jun-2009 Robert Watson <rwatson@FreeBSD.org>

Replace AUDIT_ARG() with variable argument macros with a set more more
specific macros for each audit argument type. This makes it easier to
follow call-graphs, especially for automated analysis tools (such as
fxr).

In MFC, we should leave the existing AUDIT_ARG() macros as they may be
used by third-party kernel modules.

Suggested by: brooks
Approved by: re (kib)
Obtained from: TrustedBSD Project
MFC after: 1 week


# aa8b2011 19-Oct-2008 Konstantin Belousov <kib@FreeBSD.org>

Correctly fill siginfo for the signals delivered by linux tkill/tgkill.
It is required for async cancellation to work.

Fix PROC_LOCK leak in linux_tgkill when signal delivery attempt is made
to not linux process.

Do not call em_find(p, ...) with p unlocked.

Move common code for linux_tkill() and linux_tgkill() into
linux_do_tkill().

Change linux siginfo_t definition to match actual linux one. Extend
uid fields to 4 bytes from 2. The extension does not change structure
layout and is binary compatible with previous definition, because i386
is little endian, and each uid field has 2 byte padding after it.

Reported by: Nicolas Joly <njoly pasteur fr>
Submitted by: dchangin
MFC after: 1 month


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 0ed6f09c 07-Jan-2007 Alexander Leidinger <netchild@FreeBSD.org>

MFp4 (112534):
Dont lock em in a case of just using em->shared->group_pid because
the group_pid never changes.

Submitted by: rdivacky
Reviewed by: kib
Glanced at by: jhb


# 1c65504c 07-Jan-2007 Alexander Leidinger <netchild@FreeBSD.org>

MFp4 (112498):
Rename the locking flags to EMUL_DOLOCK and EMUL_DONTLOCK to prevent confusion.

Submitted by: rdivacky


# 59038483 01-Jan-2007 Xin LI <delphij@FreeBSD.org>

Fix amd64 build.

Submitted by: Divacky Roman <xdivac02 stud fit vutbr cz>


# c9447c75 31-Dec-2006 Alexander Leidinger <netchild@FreeBSD.org>

MFp4 (111746, 108671, 108945, 112352):
- add linux utimes syscall [1]
- add linux rt_sigtimedwait syscall [2]

Submitted by: "Scot Hetzel" <swhetzel@gmail.com> [1]
Submitted by: Bruce Becker <hostmaster@whois.gts.net> [2]
PR: 93199 [2]


# 64742216 15-Oct-2006 Alexander Leidinger <netchild@FreeBSD.org>

Fix compile (use the right variable name).


# 687c23be 14-Oct-2006 Alexander Leidinger <netchild@FreeBSD.org>

MFP4 (107868 - 107870):
Use a macro to test for a valid signal instead of doing it my hand everywhere.

Submitted by: rdivacky


# 29ddc19b 19-Aug-2006 Alexander Leidinger <netchild@FreeBSD.org>

Get rid of some nested includes.

Sponsored by: Google SoC 2006
Submitted by: rdivacky
Noticed by: jhb


# 94cb2ecf 17-Aug-2006 Alexander Leidinger <netchild@FreeBSD.org>

Move some stuff into headers where they belong.

Sponsored by: Google SoC 2006
Submitted by: rdivacky
Noticed by: jhb, ssouhlal


# 9b44bfc5 14-Aug-2006 Alexander Leidinger <netchild@FreeBSD.org>

Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)

Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked

On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.

To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2

Don't switch while running a linux program, strange things may or may not
happen.

Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild


# 01e0ffba 10-May-2006 Alexander Leidinger <netchild@FreeBSD.org>

Now that we don't have a linuxolator on alpha anymore:
- unifdef __alpha__
- revert rev. 1.66 of linux_socket.c


# 17138b61 10-May-2006 Alexander Leidinger <netchild@FreeBSD.org>

Implement rt_sigpending in the linuxolator.

PR: 92671
Submitted by: Markus Niemist"o <markus.niemisto@gmx.net>


# aefce619 19-Mar-2006 Ruslan Ermilov <ru@FreeBSD.org>

Unbreak COMPAT_LINUX32 option support on amd64.

Broken by: netchild


# d4a3f5dd 18-Mar-2006 Alexander Leidinger <netchild@FreeBSD.org>

Fixup some problems in my previous commit (COMPAT_43).

Pointyhat to: netchild


# f4e98881 03-Dec-2005 Ruslan Ermilov <ru@FreeBSD.org>

Fix -Wundef.


# 1e8d246e 13-Feb-2005 Nate Lawson <njl@FreeBSD.org>

Unbreak the kernel build. Pointy hat to: sobomax.


# 1a88a252 13-Feb-2005 Maxim Sobolev <sobomax@FreeBSD.org>

Backout previous change (disabling of security checks for signals delivered
in emulation layers), since it appears to be too broad.

Requested by: rwatson


# d8ff44b7 13-Feb-2005 Maxim Sobolev <sobomax@FreeBSD.org>

Split out kill(2) syscall service routine into user-level and kernel part, the
former is callable from user space and the latter from the kernel one. Make
kernel version take additional argument which tells if the respective call
should check for additional restrictions for sending signals to suid/sugid
applications or not.

Make all emulation layers using non-checked version, since signal numbers in
emulation layers can have different meaning that in native mode and such
protection can cause misbehaviour.

As a result remove LIBTHR from the signals allowed to be delivered to a
suid/sugid application.

Requested (sorta) by: rwatson
MFC after: 2 weeks


# 1997c537 13-Jan-2005 David E. O'Brien <obrien@FreeBSD.org>

Match the LINUX32's style with existing style
Submitted by: Jung-uk Kim <jkim@niksun.com>

Use positive, not negative logic.


# b61c60d4 15-Aug-2004 David E. O'Brien <obrien@FreeBSD.org>

Fix the 'DEBUG' argument code to unbreak the amd64 LINT build.


# 4af27623 16-Aug-2004 Tim J. Robbins <tjr@FreeBSD.org>

Changes to MI Linux emulation code necessary to run 32-bit Linux binaries
on AMD64, and the general case where the emulated platform has different
size pointers than we use natively:
- declare certain structure members as l_uintptr_t and use the new PTRIN
and PTROUT macros to convert to and from native pointers.
- declare some structures __packed on amd64 when the layout would differ
from that used on i386.
- include <machine/../linux32/linux.h> instead of <machine/../linux/linux.h>
if compiling with COMPAT_LINUX32. This will need to be revisited before
32-bit and 64-bit Linux emulation support can coexist in the same kernel.
- other small scattered changes.

This should be a no-op on i386 and Alpha.


# 16dbc7f2 10-Jun-2003 David E. O'Brien <obrien@FreeBSD.org>

Use __FBSDID().


# 2f7ed219 28-Apr-2003 John Baldwin <jhb@FreeBSD.org>

Argh! We want to return the old signal set when the error return is zero
(i.e. success), not non-zero (failure).

Submitted by: tegge
Pointy hat to: jhb


# 19dde5cd 25-Apr-2003 John Baldwin <jhb@FreeBSD.org>

Use a switch to convert the Linux sigprocmask flags to the equivalent
FreeBSD flags instead of just adding one to the Linux flags. This should
be identical to the previous version except that I have at least one report
of this patch fixing problems people were having with Linux apps after my
last commit to this file. It is safer to use the switch then to make
assumptions about the flag values anyways, esp. since we currently use
MD defines for the values of the flags and this is MI code.

Tested by: Michael Class <michael_class@gmx.net>


# fe8cdcae 22-Apr-2003 John Baldwin <jhb@FreeBSD.org>

- Replace inline implementations of sigprocmask() with calls to
kern_sigprocmask() in the various binary compatibility emulators.
- Replace calls to sigsuspend(), sigaltstack(), sigaction(), and
sigprocmask() that used the stackgap with calls to the corresponding
kern_sig*() functions instead without using the stackgap.


# 9d8643ec 17-Apr-2003 John Baldwin <jhb@FreeBSD.org>

Don't hold the proc lock while performing sigset conversions on local
variables.


# 4093529d 31-Mar-2003 Jeff Roberson <jeff@FreeBSD.org>

- Move p->p_sigmask to td->td_sigmask. Signal masks will be per thread with
a follow on commit to kern_sig.c
- signotify() now operates on a thread since unmasked pending signals are
stored in the thread.
- PS_NEEDSIGCHK moves to TDF_NEEDSIGCHK.


# 5d58e285 15-Feb-2003 Tim J. Robbins <tjr@FreeBSD.org>

Add MPSAFE comment to linux_sigpending().


# 1d9c5696 01-Oct-2002 Juli Mallett <jmallett@FreeBSD.org>

Back our kernel support for reliable signal queues.

Requested by: rwatson, phk, and many others


# 1226f694 30-Sep-2002 Juli Mallett <jmallett@FreeBSD.org>

First half of implementation of ksiginfo, signal queues, and such. This
gets signals operating based on a TailQ, and is good enough to run X11,
GNOME, and do job control. There are some intricate parts which could be
more refined to match the sigset_t versions, but those require further
evaluation of directions in which our signal system can expand and contract
to fit our needs.

After this has been in the tree for a while, I will make in kernel API
changes, most notably to trapsignal(9) and sendsig(9), to use ksiginfo
more robustly, such that we can actually pass information with our
(queued) signals to the userland. That will also result in using a
struct ksiginfo pointer, rather than a signal number, in a lot of
kern_sig.c, to refer to an individual pending signal queue member, but
right now there is no defined behaviour for such.

CODAFS is unfinished in this regard because the logic is unclear in
some places.

Sponsored by: New Gold Technology
Reviewed by: bde, tjr, jake [an older version, logic similar]


# 206a5d3a 01-Sep-2002 Ian Dowse <iedowse@FreeBSD.org>

Use the new kern_* functions to avoid the need to store arguments
in the stack gap. This converts most VFS and signal related system
calls, as well as select().

Discussed on: -arch
Approved by: marcel


# 21dc7d4f 02-Jun-2002 Jens Schweikhardt <schweikh@FreeBSD.org>

Fix typo in the BSD copyright: s/withough/without/

Spotted and suggested by: des
MFC after: 3 weeks


# 79065dba 04-Apr-2002 Bruce Evans <bde@FreeBSD.org>

Moved signal handling and rescheduling from userret() to ast() so that
they aren't in the usual path of execution for syscalls and traps.
The main complication for this is that we have to set flags to control
ast() everywhere that changes the signal mask.

Avoid locking in userret() in most of the remaining cases.

Submitted by: luoqi (first part only, long ago, reorganized by me)
Reminded by: dillon


# b40ce416 12-Sep-2001 Julian Elischer <julian@FreeBSD.org>

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


# 5002a60f 08-Sep-2001 Marcel Moolenaar <marcel@FreeBSD.org>

Round of cleanups and enhancements. These include (in random order):

o Introduce private types for use in linux syscalls for two reasons:
1. establish type independence for ease in porting and,
2. provide a visual queue as to which syscalls have proper
prototypes to further cleanup the i386/alpha split.
Linuxulator types are prefixed by 'l_'. void and char have not
been "virtualized".

o Provide dummy functions for all syscalls and remove dummy functions
or implementations of truely obsolete syscalls.

o Sanitize the shm*, sem* and msg* syscalls.

o Make a first attempt to implement the linux_sysctl syscall. At this
time it only returns one MIB (KERN_VERSION), but most importantly,
it tells us when we need to add additional sysctls :-)

o Bump the kenel version up to 2.4.2 (this is not the same as the
KERN_VERSION MIB, BTW).

o Implement new syscalls, of which most are specific to i386. Our
syscall table is now up to date with Linux 2.4.2. Some highlights:
- Implement the 32-bit uid_t and gid_t bases syscalls.
- Implement a couple of 64-bit file size/offset bases syscalls.

o Fix or improve numerous syscalls and prototypes.

o Reduce style(9) violations while I'm here. Especially indentation
inconsistencies within the same file are addressed. Re-indenting
did not obfuscate actual changes to the extend that it could not
be combined.

NOTE: I spend some time testing these changes and found that if there
were regressions, they were not caused by these changes AFAICT.
It was observed that installing a RH 7.1 runtime environment
did make matters worse. Hangs and/or reboots have been observed
with and without these changes, so when it failed to make life
better in cases it doesn't look like it made it worse.


# fb919e4d 01-May-2001 Mark Murray <markm@FreeBSD.org>

Undo part of the tangle of having sys/lock.h and sys/mutex.h included in
other "system" header files.

Also help the deprecation of lockmgr.h by making it a sub-include of
sys/lock.h and removing sys/lockmgr.h form kernel .c files.

Sort sys/*.h includes where possible in affected files.

OK'ed by: bde (with reservations)


# 24593369 16-Feb-2001 Jonathan Lemon <jlemon@FreeBSD.org>

Allow debugging output to be controlled on a per-syscall granularity.
Also clean up debugging output in a slightly more uniform fashion.

The default behavior remains the same (all debugging output is turned on)


# 216af822 15-Dec-2000 John Baldwin <jhb@FreeBSD.org>

Lock access to proc members.

Glanced over by: marcel


# b4c6727a 02-Dec-2000 Marcel Moolenaar <marcel@FreeBSD.org>

Don't auto-generate the syscalls.


# ebea8660 10-Nov-2000 Marcel Moolenaar <marcel@FreeBSD.org>

Revert auto-generation. The Alpha port is broken.
Syncing with it is wrong.


# 2da829a0 09-Nov-2000 Marcel Moolenaar <marcel@FreeBSD.org>

Sync with Alpha:
Do not use sysent.c, proto.h and syscall.h in source tree;
use auto-generated versions.


# 5231fb20 01-Nov-2000 David E. O'Brien <obrien@FreeBSD.org>

The MI/MD split wasn't perfect and the MI files need hacks for the
AlphaLinux compat bits. This will be better cleaned up soon.

Agreed to what ever was necessary by: marcel


# 79363394 16-Oct-2000 Andrew Gallatin <gallatin@FreeBSD.org>

A start at an implemention of linux_rt_sendsig & linux_rt_sigreturn
and associated user-level signal trampoline glue.

Without this patch, an SA_SIGINFO style handler can be installed by a linux
app, but if the handler accesses its sip argument, it will get a garbage
pointer and likely segfault.

We currently supply a valid pointer, but its contents are mainly
garbage. Filling this in properly is future work.

This is the second of 3 commits that will get IBM's JDK 1.3 working with
FreeBSD ...


# ba9ef45b 21-Aug-2000 Marcel Moolenaar <marcel@FreeBSD.org>

Update include directives.

Make linux_to_bsd_sigset and linux_do_sigaction non-static.

Move linux_sigaction. linux_sigsuspend, linux_rt_sigsuspend,
linux_pause and linux_sigaltstack to MD code.


# 7ec7564a 05-Dec-1999 Archie Cobbs <archie@FreeBSD.org>

Fix LINT breakage.


# ec99e322 30-Nov-1999 Marcel Moolenaar <marcel@FreeBSD.org>

Implement linux_sigaltstack.


# 956d3333 29-Sep-1999 Marcel Moolenaar <marcel@FreeBSD.org>

sigset_t change (part 4 of 5)
-----------------------------

The compatibility code and/or emulators have been updated:

iBCS2 now mostly uses the older syscalls. SVR4 now properly
handles all signals. This has been achieved by using the
new sigset_t throughout the emulator. The Linuxulator has
been severely updated. Internally the new Linux sigset_t is
made the default. These are then mapped to and from the
new FreeBSD sigset_t.

Also, rt_sigsuspend has been implemented in the Linuxulator.
Implementing this syscall basicly caused all this sigset_t
changing in the first place and the syscall has been used
throughout the change as a means for testing. It basicly is
too much work to undo the implementation so that it can
later be added again.

A special note on the use of sv_sigtbl and sv_sigsize in
struct sysentvec:
Every signal larger than sv_sigsize is not translated and is
passed on to the signal handler unmodified. Signals in the
range 1 upto and including sv_sigsize are translated.
The rationale is that only the system defined signals need to
be translated.

The emulators also have been updated so that the translation
tables are only indexed for valid (system defined) signals.
This change also fixes the translation bug already in the
SVR4 emulator.


# c3aac50f 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 06ebbe77 14-Aug-1999 Marcel Moolenaar <marcel@FreeBSD.org>

Implementation of linux_rt_sigaction and linux_rt_sigprocmask syscalls. Both
functions use the new sigset_t and sigaction_t which allows support for more
than 32 signals. Only the lower 32 signals are supported for now.

linux_rt_sigaction, linux_sigaction and linux_signal use linux_do_sigaction
to do the actual work. That way unnecessary redundancy is avoided. The same
has been done for linux_rt_sigprocmask and linux_sigprocmask. They call
linux_do_sigprocmask to do the actual work.


# 8f437f44 06-Jul-1999 Martin Cracauer <cracauer@FreeBSD.org>

Rename struct members sa_siginfo. POSIX reserves identifiers starting
with sa_ when <signal.h> is included. They would conflict with the
upcoming SA_SIGINFO implementation.

Reviewed by: BDE


# d5558c00 06-May-1999 Peter Wemm <peter@FreeBSD.org>

Fix up a few easy 'assignment used as truth value' and 'suggest parens
around && within ||' type warnings. I'm pretty sure I have not masked
any problems here, I've committed real problem fixes seperately.


# c26abb75 21-Dec-1998 Søren Schmidt <sos@FreeBSD.org>

Kill(pid, 0) normally returns 0 on both FreeBSD and Redhat after having
performed all sorts of sanity checks. The FreeBSD linux emulator returns
EINVAL in such a case.
Allowing signal 0 to be passed to kill will result in compatible behaviour.

PR: 9082
Submitted by: Marcel Moolenaar <marcel@scc.nl>


# 2116e6ab 10-Oct-1998 John Polstra <jdp@FreeBSD.org>

Fix a couple of out-of-bounds array references in mapping between
Linux and FreeBSD signal numbers. Also, check signal numbers passed
in from application programs for validity. Without these checks,
it is trivial to panic the system from a Linux program.


# 24382fa4 15-Aug-1998 Bruce Evans <bde@FreeBSD.org>

Oops, the previous fix confused Linux's sigset_t with a pointer type.
It can be integral or a struct in POSIX, so it is difficult to print,
but it is actually declared as unsigned long. Assume that it is
unsigned integral.


# e4e6ae13 29-Jul-1998 Bruce Evans <bde@FreeBSD.org>

Fixed print format errors.


# cb226aaa 06-Nov-1997 Poul-Henning Kamp <phk@FreeBSD.org>

Move the "retval" (3rd) parameter from all syscall functions and put
it in struct proc instead.

This fixes a boatload of compiler warning, and removes a lot of cruft
from the sources.

I have not removed the /*ARGSUSED*/, they will require some looking at.

libkvm, ps and other userland struct proc frobbing programs will need
recompiled.


# 293a9e51 20-Jul-1997 Bruce Evans <bde@FreeBSD.org>

Removed unused #includes.


# 6875d254 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# dbc09a63 04-Mar-1996 Peter Wemm <peter@FreeBSD.org>

update linux_times() and linux_utime() emulation,
fix sigsuspend() (actually back out my recent change there)
and regen the syscall tables..


# a1ebcbfb 02-Mar-1996 Peter Wemm <peter@FreeBSD.org>

Minor touch-up... make two functions static, and add missing $Id$


# d66a5066 02-Mar-1996 Peter Wemm <peter@FreeBSD.org>

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.


# ef04503d 14-Dec-1995 Peter Wemm <peter@FreeBSD.org>

Clean up some warnings by using the generated structures in <sys/sysproto.h>
for passing to the bsd system calls, rather than inveninting our own
equivalent structures.


# 1f3dad5a 22-Nov-1995 Bruce Evans <bde@FreeBSD.org>

Completed function declarations and added prototypes.

Removed some unnecessary #includes.

Fixed warnings about nested externs.


# c21dee17 25-Jun-1995 Søren Schmidt <sos@FreeBSD.org>

First incarnation of our Linux emulator or rather compatibility code.
This first shot only incorporaties so much functionality that DOOM
can run (the X version), signal handling is VERY weak, so is many
other things. But it meets my milestone number one (you guessed it
- running DOOM).

Uses /compat/linux as prefix for loading shared libs, so it won't
conflict with our own libs.

Kernel must be compiled with "options COMPAT_LINUX" for this to work.