History log of /freebsd-current/sys/amd64/linux32/linux.h
Revision Date Author Comments
# 2a1cf1b6 05-Sep-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Deduplicate mmap2

To help porting the Linux emulation layer to a new platforms start using
Linux names for conditional builds instead of architecture-specific ifdefs.

MFC after: 1 week


# 524c9acc 20-Aug-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Replace linux32_copyiniov by freebsd32_copyiniov

MFC after: 1 month


# c987ff4d 20-Aug-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Replace linux32_copyinuio by freebsd32_copyinuio

MFC after: 1 month


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 3d0addcd 18-May-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Make ptrace_pokeusr machine dependent

Differential Revision: https://reviews.freebsd.org/D40096
MFC after: 1 week


# dd2a6cd7 18-May-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Make ptrace_peekusr machine dependend

And partially implement it for x86_64.

Differential Revision: https://reviews.freebsd.org/D40095
MFC after: 1 week


# 80d8a4a0 28-Apr-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Make struct stat64 to match Linux actual one


# 19973638 28-Apr-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Move dev_t type declaration under /compat/linux

As of version 2.6.0 of the Linux kernel, dev_t is a 32-bit unsigned integer
on all platforms. Move it into the MI linux.h under /compat/linux.


# e0bfe0d6 28-Apr-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Make struct newstat to match actual Linux one

In the struct stat the st_dev, st_rdev are unsigned long.


# a408fc09 28-Apr-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Rename obsolete old struct l_stat to struct l_old_stat


# 56c5230a 22-Apr-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Fix LINUX_AT_COUNT comments

Differential Revision: https://reviews.freebsd.org/D39645
MFC after: 1 month


# 7d8c9839 22-Apr-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Deduplicate linux_copyout_auxargs()

Export default MINSIGSTKSZ value for the x86 until we do not preserve AVX
registers in the signal context.

Differential Revision: https://reviews.freebsd.org/D39644
MFC after: 1 month


# cabbfb60 03-Mar-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Reduce code duplication between MD files

Move struct ifnet definitions under compat/linux.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38791


# 575e48f1 01-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Deduplicate MI futex structures.

MFC after: 1 week


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

linux(4): To reuse MD linux.h hide kernel dependencies unde _KERNEL constraint

MFC after: 2 weeks


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

linux(4): Reduce duplication between MD parts of the Linuxulator

Move sigprocmask actions defines under compat/linux,
they are identical across all Linux architectures.

MFC after: 2 weeks


# 0e26e54b 28-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Handle 64-bit SO_TIMESTAMP for 32-bit binaries

To solve y2k38 problem in the recvmsg syscall the new SO_TIMESTAMP
constant were added on v5.1 Linux kernel. So, old 32-bit binaries
that knows only 32-bit time_t uses the old value of the constant,
and binaries that knows 64-bit time_t uses the new constant.

To determine what size of time_t type is expected by the user-space,
store requested value (SO_TIMESTAMP) in the process emuldata structure.

MFC after: 2 weeks


# af557e64 15-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Rework the definition of struct siginfo to match Linux actual one

Rework the defintion of struct siginfo so that the array padding
struct siginfo to SI_MAX_SIZE can be placed in a union along side of the
rest of the struct siginfo members. The result is that we no longer need
the __ARCH_SI_PREAMBLE_SIZE or SI_PAD_SIZE definitions.

Move struct siginfo definition under /compat/linux to reduce MD part.
To avoid headers polution include linux_siginfo.h in the MD linux.h

MFC after: 2 weeks


# 21f24617 15-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Move sigframe definitions to separate headers

The signal trampoine-related definitions are used only in the MD part
of code, wherefore moved from everywhere used linux.h to separate MD
headers.

MFC after: 2 weeks


# ba279bcd 15-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Cleanup signal trampolines

This is the first stage of a signal trampolines refactoring.

From trampolines retired emulation of the 'call' instruction, which is
replaced by direct call of a signal handler. The signal handler address
is in the register.

The previous trampoline implemenatation used semi-Linux-way to call
a signal handler via the 'jmp' instruction. Wherefore the trampoline
emulated a 'call' instruction to into the stack the return address for
signal handler's 'ret' instruction. Wherefore handmade DWARD annotations
was used.

While here rephrased and removed excessive comments.

MFC after: 2 weeks


# d5dc757e 31-Mar-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Add compat.linux32.emulate_i386 knob.

Historically 32-bit Linuxulator under amd64 emulated the real i386
behavior. Since 3d8dd983 the old i386 Linux world can't be used under
amd64 Linuxulator as it don't know anything about amd64 machine (which
is returned now by newuname() syscall). So, add a knob to allow to swith
the behavior and use i386 Linux binaries on amd64.
Set knob to the new behavior as I think this is common to the modern
Linux distros.

Reviewed by: Pau Amma (doc), emaste
Differential revision: https://reviews.freebsd.org/D34708
MFC after: 2 weeks


# 3417c298 23-Oct-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux: Constify bsd_to_linux_regset()

No functional changes.

Reviewed By: emaste
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32599


# 4aae1334 25-Jun-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Make vDSO defines private.

Hide the vDSO defines to the linux32_sysvec as they are not intended to
be used outside of it. Fix LINUX32_PS_STRINGS, use the size of
struct linux32_ps_strings instead of a numeric constant.

MFC after: 2 weeks


# 26795a03 21-Jun-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Rework Linux ppoll system call.

For now the Linux emulation layer uses in kernel ppoll(2) without
conversion of user supplied fd 'events', and does not convert the
kernel supplied fd 'revents'.

At least POLLRDHUP is handled by FreeBSD differently than by
Linux. Seems that Linux silencly ignores POLLRDHUP on non socket fd's
unlike FreeBSD, which does more strictly check and fails.

Rework the Linux ppoll, using kern_poll and converting 'events'
and 'revents' values.
While here, move poll events defines to the MI part of code as they
mostly identical on all arches except arm.

Differential Revision: https://reviews.freebsd.org/D30716
MFC after: 2 weeks


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

linux(4): add struct timespec64 definition and conversion routine for
future use.

MFC after: 2 weeks


# 19593f77 31-May-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4); Retire unnecessary __packed attribute from some struct's
definition.

Differential Revision: https://reviews.freebsd.org/D30482
MFC after: 2 weeks


# 95c19e1d 21-May-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux: refactor bsd_to_linux_regset() out of linux_ptrace.c

This will be used for Linux coredump support.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30365


# ca6e1fa3 12-Apr-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux: adjust ordering of Linux auxv and add dummy AT_HWCAP2

This should be a no-op; the purpose of this is to reduce
a spurious difference between Linuxulator and Linux, to make
debugging core dumps slightly easier.

Note that AT_HWCAP2 we pass to Linux binaries is always 0,
instead of being equal to 'cpu_feature2'. This matches what
I've observed under Ubuntu Focal VM.

Reviewed By: chuck, dchagin
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D29609


# 562894f0 14-Apr-2020 Brooks Davis <brooks@FreeBSD.org>

Centralize compatability translation macros.

Copy the CP, PTRIN, etc macros from freebsd32.h into a sys/abi_compat.h
and replace existing definitation with includes where required. This
eliminates duplicate code and allows Linux and FreeBSD compatability
headers to be included in the same files.

Input from: cem, jhb
Obtained from: CheriBSD
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24275


# 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


# d151344d 03-May-2019 Dmitry Chagin <dchagin@FreeBSD.org>

In order to reduce duplication between MD parts of the Linuxulator
move bits that are MI out into the headers in compat/linux.
For that remove bogus _packed attribute from struct l_sockaddr
and use MI types for struct members.

And continue to move into the linux_common module a code that is
intended for both Linuxulator modules (both instruction set - 32 & 64 bit)
or for external modules like linsysfs or linprocfs.

To avoid header pollution introduce new sys/compat/linux_common.h header.

Reviewed by: emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20137


# 931e2a1a 15-Jun-2018 Ed Maste <emaste@FreeBSD.org>

linuxulator: do not include legacy syscalls on arm64

Existing linuxulator platforms (i386, amd64) support legacy syscalls,
such as non-*at ones like open, but arm64 and other new platforms do
not.

Wrap these in #ifdef LINUX_LEGACY_SYSCALLS, #defined in the MD linux.h
files. We may need finer grained control in the future but this is
sufficient for now.

Reviewed by: andrew
Sponsored by: Turing Robotic Industries
Differential Revision: https://reviews.freebsd.org/D15237


# dc858467 19-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Rename linuxulator functions with linux_ prefix

It's preferable to have a consistent prefix. This also reduces
differences between the three linux*_sysvec.c files.

Sponsored by: Turing Robotic Industries Inc.


# 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.


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

sys/amd64: 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.


# 7ece126e 08-Apr-2017 Tai-hwa Liang <avatar@FreeBSD.org>

Trying to be more compatible with Linux if.h definitions:
- renaming l_ifreq::ifru_metric to l_ifreq::ifru_ivalue;
- adding a definition for ifr_ifindex which points to l_ifreq::ifru_ivalue.

A quick search indicates that Linux already got the above changes since 2.1.14.

Reviewed by: kib, marcel, dchagin
MFC after: 1 week


# 85712939 18-Mar-2017 Dmitry Chagin <dchagin@FreeBSD.org>

To reduce code duplication move socket defines to the MI path.

MFC after: 1 week


# ab60bc84 07-Mar-2017 Dmitry Chagin <dchagin@FreeBSD.org>

Reduce code duplication between MD Linux code by moving SYSV IPC 64-bit
related struct definitions out into the MI path.

Invert the native ipc structs to the Linux ipc structs convesion logic.
Since 64-bit variant of ipc structs has more precision convert native ipc
structs to the 64-bit Linux ipc structs and then truncate 64-bit values
into the non 64-bit if needed. Unlike Linux, return EOVERFLOW if the
values do not fit.

Fix SYSV IPC for 64-bit Linuxulator which never sets IPC_64 bit.

MFC after: 1 month


# e801ac78 25-Feb-2017 Edward Tomasz Napierala <trasz@FreeBSD.org>

Fix linux_fstatfs() to return proper value for f_frsize. Without it,
linux df(1) binary from Xenial shows garbage.

Reviewed by: dchagin
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D9692


# bd911530 24-Feb-2017 Mahdi Mokhtari <mmokhi@FreeBSD.org>

Add linux_preadv() and linux_pwritev() syscalls to Linuxulator.

Reviewed by: dchagin
Approved by: dchagin, trasz (src committers)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D9722


# 97d06da6 10-Jul-2016 Dmitry Chagin <dchagin@FreeBSD.org>

Fix a copy/paste bug introduced during X86_64 Linuxulator work.
FreeBSD support NX bit on X86_64 processors out of the box, for i386 emulation
use READ_IMPLIES_EXEC flag, introduced in r302515.

While here move common part of mmap() and mprotect() code to the files in compat/linux
to reduce code dupcliation between Linuxulator's.

Reported by: Johannes Jost Meixner, Shawn Webb

MFC after: 1 week
XMFC with: r302515, r302516


# 7c598200 27-Mar-2016 Dmitry Chagin <dchagin@FreeBSD.org>

Revert r297310 as the SOL_XXX are equal to the IPPROTO_XX except SOL_SOCKET.

Pointed out by: ae@


# c826fcfe 27-Mar-2016 Dmitry Chagin <dchagin@FreeBSD.org>

iConvert Linux SOL_IPV6 level.

MFC after: 1 week


# 6cea44a7 29-Oct-2015 John Baldwin <jhb@FreeBSD.org>

Fix build with DEBUG defined.

Reported by: hselasky


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

Reduce duplication between MD Linux code by moving msg related
struct definitions out into the compat/linux/linux_socket.h


# 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


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

Put the correct value for the abi_nfdbits parameter of kern_select() for
all supported Linuxulators.

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


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

To avoid code duplication move open/fcntl definitions to the MI
header file.

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


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

Add AT_RANDOM and AT_EXECFN auxiliary vector entries which are used by
glibc. At list since glibc version 2.16 using AT_RANDOM is mandatory.

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


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

Introduce a new module linux_common.ko which is intended for the
following primary purposes:

1. Remove the dependency of linsysfs and linprocfs modules from linux.ko,
which will be architecture specific on amd64.

2. Incorporate into linux_common.ko general code for platforms on which
we'll support two Linuxulator modules (for both instruction set - 32 & 64 bit).

3. Move malloc(9) declaration to linux_common.ko, to enable getting memory
usage statistics properly.

Currently linux_common.ko incorporates a code from linux_mib.c and linux_util.c
and linprocfs, linsysfs and linux kernel modules depend on linux_common.ko.

Temporarily remove dtrace garbage from linux_mib.c and linux_util.c

Differential Revision: https://reviews.freebsd.org/D1072
In collaboration with: Vassilis Laganakos.

Reviewed by: trasz


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

x86_64 Linux do not use multiplexing on ipc system calls.
Move struct ipc_perm definition to the MD path as it differs for 64 and
32 bit platform.

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


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

Eliminate a now unused global declaration of elf_linux_sysvec.

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


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

Implement vdso - virtual dynamic shared object. Through vdso Linux
exposes functions from kernel with proper DWARF CFI information so that
it becomes easier to unwind through them.
Using vdso is a mandatory for a thread cancelation && cleanup
on a modern glibc.

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


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

To reduce code duplication introduce linux_copyout_rusage() method.
Use it in linux_wait4() system call and move linux_wait4() to the MI path.
While here add a prototype for the static bsd_to_linux_rusage().

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


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

In preparation for switching linuxulator to the use the native 1:1
threads print the thread id in addition to the pid in debug messages.


# 0a041f3b 18-Sep-2014 Bjoern A. Zeeb <bz@FreeBSD.org>

Implement most of timer_{create,settime,gettime,getoverrun,delete}
for amd64/linux32. Fix the entirely bogus (untested) version from
r161310 for i386/linux using the same shared code in compat/linux.

It is unclear to me if we could support more clock mappings but
the current set allows me to successfully run commercial
32bit linux software under linuxolator on amd64.

Reviewed by: jhb
Differential Revision: D784
MFC after: 3 days
Sponsored by: DARPA, AFRL


# d825ce0a 29-Jan-2013 John Baldwin <jhb@FreeBSD.org>

Reduce duplication between i386/linux/linux.h and amd64/linux32/linux.h
by moving bits that are MI out into headers in compat/linux.

Reviewed by: Chagin Dmitry dmitry | gmail
MFC after: 2 weeks


# fb709557 23-Jan-2013 John Baldwin <jhb@FreeBSD.org>

Don't assume that all Linux TCP-level socket options are identical to
FreeBSD TCP-level socket options (only the first two are). Instead,
using a mapping function and fail unsupported options as we do for other
socket option levels.

MFC after: 2 weeks


# 19e252ba 05-May-2012 Alexander Leidinger <netchild@FreeBSD.org>

- >500 static DTrace probes for the linuxulator
- DTrace scripts to check for errors, performance, ...
they serve mostly as examples of what you can do with the static probe;s
with moderate load the scripts may be overwhelmed, excessive lock-tracing
may influence program behavior (see the last design decission)

Design decissions:
- use "linuxulator" as the provider for the native bitsize; add the
bitsize for the non-native emulation (e.g. "linuxuator32" on amd64)
- Add probes only for locks which are acquired in one function and released
in another function. Locks which are aquired and released in the same
function should be easy to pair in the code, inter-function
locking is more easy to verify in DTrace.
- Probes for locks should be fired after locking and before releasing to
prevent races (to provide data/function stability in DTrace, see the
man-page of "dtrace -v ..." and the corresponding DTrace docs).


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

Convert files to UTF-8


# dd01579c 29-Dec-2011 John Baldwin <jhb@FreeBSD.org>

Implement linux_fadvise64() and linux_fadvise64_64() using
kern_posix_fadvise().

Reviewed by: silence on emulation@
MFC after: 2 weeks


# a930718a 31-Mar-2011 Andriy Gapon <avg@FreeBSD.org>

Revert r220032:linux compat: add SO_PASSCRED option with basic handling

I have not properly thought through the commit. After r220031 (linux
compat: improve and fix sendmsg/recvmsg compatibility) the basic
handling for SO_PASSCRED is not sufficient as it breaks recvmsg
functionality for SCM_CREDS messages because now we would need to handle
sockcred data in addition to cmsgcred. And that is not implemented yet.

Pointyhat to: avg


# 01a9e1a1 26-Mar-2011 Andriy Gapon <avg@FreeBSD.org>

linux compat: add SO_PASSCRED option with basic handling

This seems to have been a part of a bigger patch by dchagin that either
haven't been committed or committed partially.

Submitted by: dchagin, nox
MFC after: 2 weeks


# 8f1e49a6 13-Mar-2011 Dmitry Chagin <dchagin@FreeBSD.org>

Enable shared page use for amd64/linux32 and i386/linux binaries.
Move signal trampoline code from the top of the stack to the shared page.

MFC after: 2 Weeks


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

For realtime signals fill the sigval value.


# 222198ab 12-Feb-2011 Dmitry Chagin <dchagin@FreeBSD.org>

Move linux_clone(), linux_fork(), linux_vfork() to a MI path.


# c8d6845e 12-Feb-2011 Dmitry Chagin <dchagin@FreeBSD.org>

In preparation for moving linux_clone() to a MI path
introduce linux_set_upcall_kse().


# 77185f47 27-Jan-2011 Konstantin Belousov <kib@FreeBSD.org>

linux_sigreturn() loads the struct trapframe from l_sigcontext
members, thus making a signed extension of 32 bit register
context. If the register is not touched in usermode between
return from signal and next syscall entry, the sign-extension
part of 64bit register is not cleared, causing
linux32_fetch_syscall_args() to read wrong values.

Use unsigned type for the registers in the linux sigcontext.

Reported by: Jacob Frelinger <jacob.frelinger duke edu>, arundel
In collaboration with: dchagin
MFC after: 1 week


# 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.


# 510ea843 28-Mar-2010 Ed Schouten <ed@FreeBSD.org>

Rename st_*timespec fields to st_*tim for POSIX 2008 compliance.

A nice thing about POSIX 2008 is that it finally standardizes a way to
obtain file access/modification/change times in sub-second precision,
namely using struct timespec, which we already have for a very long
time. Unfortunately POSIX uses different names.

This commit adds compatibility macros, so existing code should still
build properly. Also change all source code in the kernel to work
without any of the compatibility macros. This makes it all a less
ambiguous.

I am also renaming st_birthtime to st_birthtim, even though it was a
local extension anyway. It seems Cygwin also has a st_birthtim.


# f8cd0af2 01-Jun-2009 Dmitry Chagin <dchagin@FreeBSD.org>

Implement accept4 syscall.

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


# 3933bde2 16-May-2009 Dmitry Chagin <dchagin@FreeBSD.org>

Somewhere between 2.6.23 and 2.6.27, Linux added SOCK_CLOEXEC and
SOCK_NONBLOCK flags, that allow to save fcntl() calls.

Implement a variation of the socket() syscall which takes a flags
in addition to the type argument.

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


# 03cc95d2 11-May-2009 Dmitry Chagin <dchagin@FreeBSD.org>

Translate l_timeval arg to native struct timeval in
linux_setsockopt()/linux_getsockopt() for SO_RCVTIMEO,
SO_SNDTIMEO opts as l_timeval has MD members.

Remove bogus __packed attribute from l_timeval struct on __amd64__.

PR: kern/134276
Submitted by: Thomas Mueller <tmueller sysgo com>
Approved by: kib (mentor)
MFC after: 2 weeks


# 13f20d7e 07-May-2009 Dmitry Chagin <dchagin@FreeBSD.org>

To avoid excessive code duplication move MI definitions to the MI
header file. As it is defined in Linux.

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


# 0af71035 27-Mar-2009 Doug Ambrisko <ambrisko@FreeBSD.org>

Revert 190445 change to this file restoring:
typedef l_long l_off_t;
Change l_mmap_argv's to l_ulong for pgoff. This restores prior behaviour
to consumers of l_off_t but allows mmap to mmap a 32bit position which a
Linux application requires to access SMBIOS data via /dev/mem.

Reviewed by: dchagin
Prompted by: rdivacky


# d2b2128a 26-Mar-2009 Doug Ambrisko <ambrisko@FreeBSD.org>

Add stuff to support upcoming BMC/IPMI flashing of newer Dell machine
via the Linux tool.
- Add Linux shim to ipmi(4)
- Create a partitions file to linprocfs to make Linux fdisk see
disks. This file is dynamic so we can see disks come and go.
- Convert msdosfs to vfat in mtab since Linux uses that for
msdosfs.
- In the Linux mount path convert vfat passed in to msdosfs
so Linux mount works on FreeBSD. Note that tasting works
so that if da0 is a msdos file system
/compat/linux/bin/mount /dev/da0 /mnt
works.
- fix a 64it bug for l_off_t.
Grabing sh, mount, fdisk, df from Linux, creating a symlink of mtab to
/compat/linux/etc/mtab and then some careful unpacking of the Linux bmc
update tool and hacking makes it work on newer Dell boxes. Note, probably
if you can't figure out how to do this, then you probably shouldn't be
doing it :-)


# 4d7c2e8a 03-Mar-2009 Dmitry Chagin <dchagin@FreeBSD.org>

Add AT_PLATFORM, AT_HWCAP and AT_CLKTCK auxiliary vector entries which
are used by glibc. This silents the message "2.4+ kernel w/o ELF notes?"
from some programs at start, among them are top and pkill.

Do the assignment of the vector entries in elf_linux_fixup()
as it is done in glibc.

Fix some minor style issues.

Submitted by: Marcin Cieslak <saper at SYSTEM PL>
Approved by: kib (mentor)
MFC after: 1 week


# 74f5d680 29-Nov-2008 Konstantin Belousov <kib@FreeBSD.org>

Make linux_sendmsg() and linux_recvmsg() work on linux32/amd64.
Change types used in the linux' struct msghdr and struct cmsghdr
definitions to the properly-sized architecture-specific types.
Move ancillary data handler from linux_sendit() to linux_sendmsg().

Submitted by: dchagin


# 41f53a36 29-Nov-2008 Konstantin Belousov <kib@FreeBSD.org>

Fix iovec32 for linux32/amd64.

Add a custom version of copyiniov() to deal with the 32-bit iovec
pointers from userland (to be used later).

Adjust prototypes for linux_readv() and linux_writev() to use new
l_iovec32 definition and to match actual linux code. In particular,
use ulong for fd (why ?).

Submitted by: dchagin


# 62162dfc 16-Nov-2008 Konstantin Belousov <kib@FreeBSD.org>

In the robust futexes list head, futex_offset shall be signed,
and glibc actually supplies negative offsets. Change l_ulong to l_long.

Submitted by: dchagin


# 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.


# 175c6c31 14-Oct-2008 Konstantin Belousov <kib@FreeBSD.org>

Make robust futexes work on linux32/amd64. Use PTRIN to read
user-mode pointers. Change types used in the structures definitions to
properly-sized architecture-specific types.

Submitted by: dchagin
MFC after: 1 week


# 48b05c3f 08-Apr-2008 Konstantin Belousov <kib@FreeBSD.org>

Implement the linux syscalls
openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat,
renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat.

Submitted by: rdivacky
Sponsored by: Google Summer of Code 2007
Tested by: pho


# 3ab85269 18-Sep-2007 David Malone <dwmalone@FreeBSD.org>

The kernel version of Linux statfs64 is actually supposed to take
3 arguments, but we had forgotten the second argument. Also make the
Linux statfs64 struct depend on the architecture because it has an
extra 4 bytes padding on amd64 compared to i386.

The three argument fix is from David Taylor, the struct statfs64
stuff is my fault. With this patch I can install i386 Linux matlab
on an amd64 machine.

Submitted by: David Taylor <davidt_at_yadt.co.uk>
Approved by: re (kensmith)


# 6734f35e 28-Mar-2007 Julian Elischer <julian@FreeBSD.org>

Implement the openat() linux syscall
Submitted by: Roman Divacky (rdivacky@)
MFC after: 2 weeks


# a4e3bad7 01-Mar-2007 Jung-uk Kim <jkim@FreeBSD.org>

MFP4: 115220, 115222

- Fix style(9) and reduce diff between amd64 and i386.
- Prefix Linuxulator macros with LINUX_ to prevent future collision.


# 802e08a3 24-Feb-2007 Alexander Leidinger <netchild@FreeBSD.org>

Partial MFp4 of 114977:
Whitespace commit: Fix grammar, spelling and punctuation.

Submitted by: "Scot Hetzel" <swhetzel@gmail.com>


# 10931a46 14-Feb-2007 Jung-uk Kim <jkim@FreeBSD.org>

MFP4: 113025, 113146, 113177, 113203, 113500, 113546, 113570

- PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC.
Linux/ia64's i386 emulation layer does this and it complies with Linux
header files. This fixes mmap05 LTP test case on amd64.
- Do not adjust stack size when failure has occurred.
- Synchronize i386 mmap/mprotect with amd64.


# d0b2365e 01-Feb-2007 Konstantin Belousov <kib@FreeBSD.org>

Introduce some more SO_ option equivalents from Linux to FreeBSD.

The msg variable in linux_recvmsg() was not initialized.
Copy it from userspace.

Submitted by: rdivacky


# 77424f41 20-Dec-2006 Jung-uk Kim <jkim@FreeBSD.org>

MFP4: 109655

- Move linux_nanosleep() from src/sys/amd64/linux32/linux32_machdep.c to
src/sys/compat/linux/linux_time.c.
- Validate timespec ranges before use as Linux kernel does.
- Fix l_timespec structure.
- Clean up style(9) nits.


# 6ddd7e6a 07-Nov-2006 John Baldwin <jhb@FreeBSD.org>

Add a new 'union l_sigval' to use in place of 'union sigval' in the
linux siginfo structure. l_sigval uses a l_uintptr_t for sival_ptr so
that sival_ptr is the right size for linux32 on amd64. Since no code
currently uses 'lsi_ptr' this is just a cosmetic nit rather than a bug
fix.


# 3680a419 29-Oct-2006 Alexander Leidinger <netchild@FreeBSD.org>

Backout the linux aio stuff. Several problems where identified and the
dynamic nature (if no native aio code is available, the linux part
returns ENOSYS because of missing requisites) should be solved differently
than it is.

All this will be done in P4.

Not included in this commit is a backout of the changes to the native aio
code (removing static in some places). Those changes (and some more) will
also be needed when the reworked linux aio stuff will reenter the tree.

Requested by: rwatson
Discussed with: rwatson


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

MFP4 (with some minor changes):

Implement the linux_io_* syscalls (AIO). They are only enabled if the native
AIO code is available (either compiled in to the kernel or as a module) at
the time the functions are used. If the AIO stuff is not available there
will be a ENOSYS.

From the submitter:
---snip---
DESIGN NOTES:

1. Linux permits a process to own multiple AIO queues (distinguished by
"context"), but FreeBSD creates only one single AIO queue per process.
My code maintains a request queue (STAILQ of queue(3)) per "context",
and throws all AIO requests of all contexts owned by a process into
the single FreeBSD per-process AIO queue.

When the process calls io_destroy(2), io_getevents(2), io_submit(2) and
io_cancel(2), my code can pick out requests owned by the specified context
from the single FreeBSD per-process AIO queue according to the per-context
request queues maintained by my code.

2. The request queue maintained by my code stores contrast information between
Linux IO control blocks (struct linux_iocb) and FreeBSD IO control blocks
(struct aiocb). FreeBSD IO control block actually exists in userland memory
space, required by FreeBSD native aio_XXXXXX(2).

3. It is quite troubling that the function io_getevents() of libaio-0.3.105
needs to use Linux-specific "struct aio_ring", which is a partial mirror
of context in user space. I would rather take the address of context in
kernel as the context ID, but the io_getevents() of libaio forces me to
take the address of the "ring" in user space as the context ID.

To my surprise, one comment line in the file "io_getevents.c" of
libaio-0.3.105 reads:

Ben will hate me for this

REFERENCE:

1. Linux kernel source code: http://www.kernel.org/pub/linux/kernel/v2.6/
(include/linux/aio_abi.h, fs/aio.c)

2. Linux manual pages: http://www.kernel.org/pub/linux/docs/manpages/
(io_setup(2), io_destroy(2), io_getevents(2), io_submit(2), io_cancel(2))

3. Linux Scalability Effort: http://lse.sourceforge.net/io/aio.html
The design notes: http://lse.sourceforge.net/io/aionotes.txt

4. The package libaio, both source and binary:
http://rpmfind.net/linux/rpm2html/search.php?query=libaio
Simple transparent interface to Linux AIO system calls.

5. Libaio-oracle: http://oss.oracle.com/projects/libaio-oracle/
POSIX AIO implementation based on Linux AIO system calls (depending on
libaio).
---snip---

Submitted by: Li, Xiao <intron@intron.ac>


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

MFP4 (106538 + 106541):
Implement CLONE_VFORK. This fixes the clone05 LTP test.

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


# 0eef2f8a 16-Aug-2006 Alexander Leidinger <netchild@FreeBSD.org>

Style fixes to comments.

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


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

regen after COMPAT_43 removal


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

Add preliminary support for running 32-bit Linux binaries on amd64, enabled
with the COMPAT_LINUX32 option. This is largely based on the i386 MD Linux
emulations bits, but also builds on the 32-bit FreeBSD and generic IA-32
binary emulation work.

Some of this is still a little rough around the edges, and will need to be
revisited before 32-bit and 64-bit Linux emulation support can coexist in
the same kernel.