History log of /freebsd-current/sys/amd64/linux/linux_sysvec.c
Revision Date Author Comments
# be707ee0 09-Feb-2024 Konstantin Belousov <kib@FreeBSD.org>

amd64/linux*: mark brandlists as static

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 199e397e 03-Oct-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Deorbit linux_nosys

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


# 7acc4240 25-Sep-2023 Konstantin Belousov <kib@FreeBSD.org>

linuxolator: fix nosys() to not send SIGSYS

Reviewed by: dchagin, markj
Discussed with: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D41976


# 68df2376 11-Sep-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Cleanup includes under amd64/linux

No functional changes.

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/


# 4281dab8 28-Jul-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Add elf_hwcap2 to x86

On x86 Linux via AT_HWCAP2 the user controlled (by tunables) processor
capabilities are exposed.

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


# cbbac560 08-Jun-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Preserve fpu xsave state across signal delivery on amd64

PR: 270247
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D40444
MFC after: 2 weeks


# 920184ed 08-Jun-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): In preparation for xsave refactor fxsave code on amd64

Due to fxsave area is os independent reimplement fxsave handmade code
using copying of a whole area.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D40443
MFC after: 2 weeks


# 84617f6f 06-Jun-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4) rt_sendsig: Remove the use of caddr_t

Replace caddr_t by more appropriate char *.

MFC after: 2 weeks


# fd745e1d 29-May-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Use pwd_altroot() to tell namei() about ABI root path

PR: 72920
Differential Revision: https://reviews.freebsd.org/D40090
MFC after: 2 month


# 037b60fb 28-May-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Preserve %rcx (return address) like a Linux do

Perhaps, this does not makes much sense as destroyng %rcx declared by
the x86_64 Linux syscall ABI. However,:
a) if we get a signal while we are in the kernel, we should restore
tf_rcx when preparing machine context for signal handlers.
b) the Linux world is strange, someone can depend on %rcx value
after syscall, something like go.

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


# 185bd9fa 28-May-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Simplify %r10 restoring on amd64

Restore %r10 at system call entry to avoid doing this multiply times.

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


# a463dd81 28-May-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Add a comment explaining registers at syscall entry point on amd64

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


# a99b890e 28-May-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Drop a weird comment from linux_set_syscall_retval on amd64

I agree, it would be great to avoid PCB_FULL_IRET, however we should
follow Linux system call ABI.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D40152
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


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

linux(4): Cleanup includes under amd64/linux

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

MFC after: 2 weeks


# ce20c00e 02-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Remove stale comment that no longer applies.

MFC after: 1 week


# 6ad07a4b 02-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Microoptimize rt_sendsig() on amd64.

Drop proc lock earlier, before copying user stuff.

Pointed out by: kib
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38326
MFC after: 1 week


# a95cb95e 02-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Preserve fpu fxsave state across signal delivery on amd64.

PR: 240768
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38302
MFC after: 1 week


# 95b86034 02-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Deduplicate linux_trans_osrel().

MFC after: 1 week


# 6039e966 02-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Deduplicate linux_copyout_strings().

It is still present in the 32-bit Linuxulator on amd64.

MFC after: 1 week


# 9e550625 02-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Deduplicate linux_fixup_elf().

Use native routines to fixup initial process stack. On Arm64 linux_elf_fixup() is
noop, as it do the stack fixup (room for argc) in the linux_copyout_strings().

MFC after: 1 week


# 74465145 02-Feb-2023 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Microoptimize linux_elf.h for future use.

In order to reduce code duplication move coredump support definitions
into the appropriate header and hide private definitions.

MFC after: 1 week


# 1da65dcb 28-Oct-2022 Mitchell Horne <mhorne@FreeBSD.org>

linux: populate sv_syscallnames in each sysentvec

This allows the syscallname() function to give a usable result for Linux
ABIs.

Reported by: jrtc27
Reviewed by: jrtc27, markj, jhb
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37199


# 361971fb 02-Jun-2022 Kornel Dulęba <kd@FreeBSD.org>

Rework how shared page related data is stored

Store the shared page address in struct vmspace.
Also instead of storing absolute addresses of various shared page
segments save their offsets with respect to the shared page address.
This will be more useful when the shared page address is randomized.

Approved by: mw(mentor)
Sponsored by: Stormshield
Obtained from: Semihalf
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D35393


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

linux(4): Properly build argument list for the signal handler

Provide arguments 2 and 3 if signal handler installed with SA_SIGINFO.

MFC after: 2 weeks


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

linux(4): Microoptimize rt_sendsig(), convert signal mask once

On amd64 Linux saves the thread signal mask in both contexts, in the machine
dependent and in the machine independent. Both contexts are user accessible.
Convert the mask once, then copy it.

MFC after: 2 weeks


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

linux(4): Avoid direct manipulation of td_sigmask

Use kern_sigprocmask() instead of direct manipulation of td_sigmask
to reschedule newly blocked signals.

MFC after: 2 weeks


# 9016ec05 23-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Deduplicate bsd_to_linux_trapcode()

As bsd_to_linux_trapcode() is common for x86 Linuxulators,
move it under x86/linux.

MFC after: 2 weeks


# 2434137f 23-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Deduplicate translate_traps()

As translate_traps() is common for x86 Linuxulators,
move it under x86/linux.

MFC after: 2 weeks


# eca368ec 20-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

Retire sv_transtrap

Call translate_traps directly from sendsig().

MFC after: 2 weeks


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

linux(4): Better naming for ucontext field of struct rt_sigframe

To reduce sendsig code difference and to avoid confusing me,
rename sf_sc to sf_uc to match the content.

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


# 5a6a4fb2 08-May-2022 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Implement vdso getcpu for x86.

This is modeled after f2395455 (by kib@).

MFC after: 2 weeks


# 706f4a81 17-Jan-2022 Mark Johnston <markj@FreeBSD.org>

exec: Introduce the PROC_PS_STRINGS() macro

Rather than fetching the ps_strings address directly from a process'
sysentvec, use this macro. With stack address randomization the
ps_strings address is no longer fixed.

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


# 3fc21fdd 17-Jan-2022 Mark Johnston <markj@FreeBSD.org>

sysent: Add a sv_psstringssz field to struct sysentvec

The size of the ps_strings structure varies between ABIs, so this is
useful for computing the address of the ps_strings structure relative to
the top of the stack when stack address randomization is enabled.

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


# f7b04c53 04-Jan-2022 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux(4): Reduce diffs between linux_rt_sendsig() and sendsig()

No functional changes (except for the uprintf).

Discussed With: kib
Sponsored By: EPSRC


# f04a0960 30-Dec-2021 Mark Johnston <markj@FreeBSD.org>

exec: Simplify sv_copyout_strings implementations a bit

Simplify control flow around handling of the execpath length and signal
trampoline. Cache the sysentvec pointer in a local variable.

No functional change intended.

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


# 2e79a216 16-Sep-2021 Konstantin Belousov <kib@FreeBSD.org>

amd64: consistently use uprintf() to report weird situations in sigreturn

Reviewed by: jhb
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31954


# a42d362b 14-Sep-2021 Konstantin Belousov <kib@FreeBSD.org>

amd64: centralize definitions of CS_SECURE and EFL_SECURE

Requested by markj
Reviewed by: jhb, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31954


# bed2ac27 12-Aug-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Remove the unnecessary spaces.

MFC after: 2 weeks


# 0a4b664a 12-Aug-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Add struct clone_args for future clone3 system call.

In preparation for clone3 system call add struct clone_args and use it in
clone implementation.
Move all of clone related bits to the newly created linux_fork.h header.

Differential revision: https://reviews.freebsd.org/D31474
MFC after: 2 weeks


# de8374df 12-Aug-2021 Dmitry Chagin <dchagin@FreeBSD.org>

fork: Allow ABI to specify fork return values for child.

At least Linux x86 ABI's does not use carry bit and expects that the dx register
is preserved. For this add a new sv_set_fork_retval hook and call it from cpu_fork().

Add a short comment about touching dx in x86_set_fork_retval(), for more details
see phab comments from kib@ and imp@.

Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D31472
MFC after: 2 weeks


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

linux: fix sigaltstack on amd64

To determine whether to use alternate signal stack or not,
we need to use the native signal number, not the one translated
with bsd_to_linux_signal().

In practical terms, this fixes golang.

Reviewed By: dchagin
Fixes: 135dd0cab51
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D31298


# cf8d74e3 20-Jul-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Allow musl brand to use FUTEX_REQUEUE op.

Initial patch from submitter was adapted by me to prevent unconditional
FUTEX_REQUEUE use.

PR: 255947
Submitted by: Philippe Michaud-Boudreault
Differential Revision: https://reviews.freebsd.org/D30332


# 1ca6b15b 20-Jul-2021 Dmitry Chagin <dchagin@FreeBSD.org>

Drop "All rights reserved" from my copyright statements.

Add email and fixup years while here.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D30912
MFC after: 2 weeks


# ae8330b4 20-Jul-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Add arch name to the some printfs.

Reviewed by: emaste
Differential revision: https://reviews.freebsd.org/D30904
MFC after: 2 weeks


# 09cffde9 20-Jul-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Fixup the vDSO initialization order.

The vDSO initialisation order should be as follows:
- native abi init via exec_sysvec_init();
- vDSO symbols queued to the linux_vdso_syms list;
- linux_vdso_install();
- linux_exec_sysvec_init();

As the exec_sysvec_init() called with SI_ORDER_ANY (last) at SI_SUB_EXEC
order, move linux_vdso_install() and linux_exec_sysvec_init() to the
SI_SUB_EXEC+1 order.

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


# a543556c 20-Jul-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Constify vdso install/deinstall.

In order to reduce diff between arches constify vdso install/deinstall
functions like arm64.

Reviewed by: emaste
Differential revision: https://reviews.freebsd.org/D30901
MFC after: 2 weeks


# 9931033b 20-Jul-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4); Almost complete the vDSO.

The vDSO (virtual dynamic shared object) is a small shared library that the
kernel maps R/O into the address space of all Linux processes on image
activation. The vDSO is a fully formed ELF image, shared by all processes
with the same ABI, has no process private data.

The primary purpose of the vDSO:
- non-executable stack, signal trampolines not copied to the stack;
- signal trampolines unwind, mandatory for the NPTL;
- to avoid contex-switch overhead frequently used system calls can be
implemented in the vDSO: for now gettimeofday, clock_gettime.

The first two have been implemented, so add the implementation of system
calls.

System calls implemenation based on a native timekeeping code with some
limitations:
- ifunc can't be used, as vDSO r/o mapped to the process VA and rtld
can't relocate symbols;
- reading HPET memory is not implemented for now (TODO).

In case on any error vDSO system calls fallback to the kernel system
calls. For unimplemented vDSO system calls added prototypes which call
corresponding kernel system call.

Tested by: trasz (arm64)
Differential revision: https://reviews.freebsd.org/D30900
MFC after: 2 weeks


# 5fd9cd53 20-Jul-2021 Dmitry Chagin <dchagin@FreeBSD.org>

linux(4): Modify sv_onexec hook to return an error.

Temporary add stubs to the Linux emulation layer which calls the existing hook.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D30911
MFC after: 2 weeks


# cf98bc28 10-Jul-2021 David Chisnall <theraven@FreeBSD.org>

Pass the syscall number to capsicum permission-denied signals

The syscall number is stored in the same register as the syscall return
on amd64 (and possibly other architectures) and so it is impossible to
recover in the signal handler after the call has returned. This small
tweak delivers it in the `si_value` field of the signal, which is
sufficient to catch capability violations and emulate them with a call
to a more-privileged process in the signal handler.

This reapplies 3a522ba1bc852c3d4660a4fa32e4a94999d09a47 with a fix for
the static assertion failure on i386.

Approved by: markj (mentor)

Reviewed by: kib, bcr (manpages)

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


# d2b55828 10-Jul-2021 David Chisnall <theraven@FreeBSD.org>

Revert "Pass the syscall number to capsicum permission-denied signals"

This broke the i386 build.

This reverts commit 3a522ba1bc852c3d4660a4fa32e4a94999d09a47.


# 3a522ba1 10-Jul-2021 David Chisnall <theraven@FreeBSD.org>

Pass the syscall number to capsicum permission-denied signals

The syscall number is stored in the same register as the syscall return
on amd64 (and possibly other architectures) and so it is impossible to
recover in the signal handler after the call has returned. This small
tweak delivers it in the `si_value` field of the signal, which is
sufficient to catch capability violations and emulate them with a call
to a more-privileged process in the signal handler.

Approved by: markj (mentor)

Reviewed by: kib, bcr (manpages)

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


# 447636e4 30-Jun-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux(4): implement coredump support

Implement dumping core for Linux binaries on amd64, for both
32- and 64-bit executables. Some bits are still missing.

This is based on a prototype by chuck@.

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


# 435754a5 29-Jun-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

Add infrastructure required for Linux coredump support

This adds `sv_elf_core_osabi`, `sv_elf_core_abi_vendor`,
and `sv_elf_core_prepare_notes` fields to `struct sysentvec`,
and modifies imgact_elf.c to make use of them instead
of hardcoding FreeBSD-specific values. It also updates all
of the ABI definitions to preserve current behaviour.

This makes it possible to implement non-native ELF coredump
support without unnecessary code duplication. It will be used
for Linux coredumps.

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


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

linux(4): Retire linux_kplatform.

Assuming we can't run on i486, i586 class cpu, retire linux_kplatform var
and use hardcoded 'machine' value in linux_newuname().

I have added linux_kplatform for consistency with linux_platform which is
placed in to vdso to avoid excess copyout it on stack for AT_PLATFORM at
exec time.

This is the first stage of Linuxulator's vdso revision.

Reviewed by: trasz, imp
Differential Revision: https://reviews.freebsd.org/D30774
MFC after: 2 weeks


# 135dd0ca 21-Jun-2021 Edward Tomasz Napierala <trasz@FreeBSD.org>

linux: reduce differences between rt_sendsig() and sendsig()

This makes it easier to compare the two. This involves moving
the mutex slightly lower down, but there should be no functional
changes.

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


# 870e197d 05-Jun-2021 Konstantin Belousov <kib@FreeBSD.org>

Add quirks for Linux ABI signals handling

Require queueing of the signals with default action, and disable
dequeueing SIGCHLD on wait for live process.

Reported and tested by: dchagin
Reviewed by: dchagin, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30675


# 598f6fb4 14-Jan-2021 Konstantin Belousov <kib@FreeBSD.org>

linuxolator: Add compat.linux.setid_allowed knob

PR: 21463
Reported by: kris
Reviewed by: dchagin
Tested by: trasz
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28154


# 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


# 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


# 2f158847 09-Apr-2021 Konstantin Belousov <kib@FreeBSD.org>

amd64 linux64: use x86_clear_dbregs()

instead of manually inlining it

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D29687


# 0fc8a796 16-Feb-2021 Mark Johnston <markj@FreeBSD.org>

linux: Unmap the VDSO page when unloading

linux_shared_page_init() creates an object and grabs and maps a single
page to back the VDSO. When destroying the VDSO object, we failed to
destroy the mapping and free KVA. Fix this.

Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28696


# 4815f175 23-Nov-2020 Konstantin Belousov <kib@FreeBSD.org>

Linuxolator: Replace use of eventhandlers by sysent hooks.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27309


# 866b1f51 26-Oct-2020 Edward Tomasz Napierala <trasz@FreeBSD.org>

Fix misnomer - linux_to_bsd_errno() does the exact opposite.

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


# 6221ec60 18-Oct-2020 Edward Tomasz Napierala <trasz@FreeBSD.org>

Stop calling set_syscall_retval() from linux_set_syscall_retval().
The former clobbers some registers that shouldn't be touched.

Reviewed by: kib (earlier version)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26406


# 1e2521ff 27-Sep-2020 Edward Tomasz Napierala <trasz@FreeBSD.org>

Get rid of sa->narg. It serves no purpose; use sa->callp->sy_narg instead.

Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D26458


# 70890254 17-Sep-2020 Edward Tomasz Napierala <trasz@FreeBSD.org>

Get rid of sv_errtbl and SV_ABI_ERRNO().

Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D26388


# c26391f4 15-Sep-2020 Edward Tomasz Napierala <trasz@FreeBSD.org>

Move SV_ABI_ERRNO translation into linux-specific code, to simplify
the syscall path and declutter it a bit. No functional changes intended.

Reviewed by: kib (earlier version)
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D26378


# 9ce875d9 23-Aug-2020 Konstantin Belousov <kib@FreeBSD.org>

amd64 pmap: LA57 AKA 5-level paging

Since LA57 was moved to the main SDM document with revision 072, it
seems that we should have a support for it, and silicons are coming.

This patch makes pmap support both LA48 and LA57 hardware. The
selection of page table level is done at startup, kernel always
receives control from loader with 4-level paging. It is not clear how
UEFI spec would adapt LA57, for instance it could hand out control in
LA57 mode sometimes.

To switch from LA48 to LA57 requires turning off long mode, requesting
LA57 in CR4, then re-entering long mode. This is somewhat delicate
and done in pmap_bootstrap_la57(). AP startup in LA57 mode is much
easier, we only need to toggle a bit in CR4 and load right value in CR3.

I decided to not change kernel map for now. Single PML5 entry is
created that points to the existing kernel_pml4 (KML4Phys) page, and a
pml5 entry to create our recursive mapping for vtopte()/vtopde().
This decision is motivated by the fact that we cannot overcommit for
KVA, so large space there is unusable until machines start providing
wider physical memory addressing. Another reason is that I do not
want to break our fragile autotuning, so the KVA expansion is not
included into this first step. Nice side effect is that minidumps are
compatible.

On the other hand, (very) large address space is definitely
immediately useful for some userspace applications.

For userspace, numbering of pte entries (or page table pages) is
always done for 5-level structures even if we operate in 4-level mode.
The pmap_is_la57() function is added to report the mode of the
specified pmap, this is done not to allow simultaneous 4-/5-levels
(which is not allowed by hw), but to accomodate for EPT which has
separate level control and in principle might not allow 5-leve EPT
despite x86 paging supports it. Anyway, it does not seems critical to
have 5-level EPT support now.

Tested by: pho (LA48 hardware)
Reviewed by: alc
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D25273


# 0cfac4d5 31-May-2020 Mark Johnston <markj@FreeBSD.org>

Handle getcpu() calls in vsyscall emulation on amd64.

linux_getcpu() has been implemented since r356241.

PR: 246339
Submitted by: John Hay <john@sanren.ac.za>
MFC after: 1 week


# b24e6ac8 16-Apr-2020 Brooks Davis <brooks@FreeBSD.org>

Convert canary, execpathp, and pagesizes to pointers.

Use AUXARGS_ENTRY_PTR to export these pointers. This is a followup to
r359987 and r359988.

Reviewed by: jhb
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24446


# b5f20658 16-Dec-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Add compat.linux.emul_path, so it can be set to something other
than "/compat/linux". Useful when you have several compat directories
with different Linux versions and you don't want to clash with files
installed by linux-c7 packages.

Reviewed by: bcr (manpages)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22574


# d8010b11 09-Dec-2019 John Baldwin <jhb@FreeBSD.org>

Copy out aux args after the argument and environment vectors.

Partially revert r354741 and r354754 and go back to allocating a
fixed-size chunk of stack space for the auxiliary vector. Keep
sv_copyout_auxargs but change it to accept the address at the end of
the environment vector as an input stack address and no longer
allocate room on the stack. It is now called at the end of
copyout_strings after the argv and environment vectors have been
copied out.

This should fix a regression in r354754 that broke the stack alignment
for newer Linux amd64 binaries (and probably broke Linux arm64 as
well).

Reviewed by: kib
Tested on: amd64 (native, linux64 (only linux-base-c7), and i386)
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22695


# 31174518 03-Dec-2019 John Baldwin <jhb@FreeBSD.org>

Use uintptr_t instead of register_t * for the stack base.

- Use ustringp for the location of the argv and environment strings
and allow destp to travel further down the stack for the stackgap
and auxv regions.
- Update the Linux copyout_strings variants to move destp down the
stack as was done for the native ABIs in r263349.
- Stop allocating a space for a stack gap in the Linux ABIs. This
used to hold translated system call arguments, but hasn't been used
since r159992.

Reviewed by: kib
Tested on: md64 (amd64, i386, linux64), i386 (i386, linux)
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22501


# 03b0d68c 18-Nov-2019 John Baldwin <jhb@FreeBSD.org>

Check for errors from copyout() and suword*() in sv_copyout_args/strings.

Reviewed by: brooks, kib
Tested on: amd64 (amd64, i386, linux64), i386 (i386, linux)
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22401


# 5caa67fa 15-Nov-2019 John Baldwin <jhb@FreeBSD.org>

Use a sv_copyout_auxargs hook in the Linux ELF ABIs.

Reviewed by: emaste
Tested on: amd64 (linux64 only), i386
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22356


# a161fba9 17-Oct-2019 Yuri Pankov <yuripv@FreeBSD.org>

linux: futex_mtx should follow futex_list

Move futex_mtx to linux_common.ko for amd64 and aarch64 along
with respective list/mutex init/destroy.

PR: 240989
Reported by: Alex S <iwtcex@gmail.com>


# ee6da5ce 03-Sep-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Unbreak Linux binaries linked against new glibc, such as the ones
from recent Ubuntu versions. Without it they segfault on startup.

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


# 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


# 1699546d 01-Mar-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Remove sv_pagesize, originally introduced with r100384.

In all of the architectures we have today, we always use PAGE_SIZE.
While in theory one could define different things, none of the
current architectures do, even the ones that have transitioned from
32-bit to 64-bit like i386 and arm. Some ancient mips binaries on
other systems used 8k instead of 4k, but we don't support running
those and likely never will due to their age and obscurity.

Reviewed by: imp (who also contributed the commit message)
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19280


# 628888f0 19-Dec-2018 Mateusz Guzik <mjg@FreeBSD.org>

Remove iBCS2, part2: general kernel

Reviewed by: kib (previous version)
Sponsored by: The FreeBSD Foundation


# 35755049 21-Jun-2018 Chuck Tuffli <chuck@FreeBSD.org>

Fix the Linux kernel version number calculation

The Linux compatibility code was converting the version number (e.g.
2.6.32) in two different ways and then comparing the results.

The linux_map_osrel() function converted MAJOR.MINOR.PATCH similar to
what FreeBSD does natively. I.e. where major=v0, minor=v1, and patch=v2
v = v0 * 1000000 + v1 * 1000 + v2;

The LINUX_KERNVER() macro, on the other hand, converted the value with
bit shifts. I.e. where major=a, minor=b, and patch=c
v = (((a) << 16) + ((b) << 8) + (c))

The Linux kernel uses the later format via the KERNEL_VERSION() macro in
include/generated/uapi/linux/version.h

Fix is to use the LINUX_KERNVER() macro in linux_map_osrel() as well as
in the .trans_osrel functions.

PR: 229209
Reviewed by: emaste, cem, imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15952


# 459ccd3c 13-Jun-2018 Konstantin Belousov <kib@FreeBSD.org>

linuxolator/amd64: Don't mangle %r10 on return from syscall for EJUSTRETURN.

This fixes the %r10 content for rt_sigreturn.

Submitted by: Yanko Yankulov <yanko.yankulov@gmail.com>
MFC after: 1 week


# cbf7e0cb 29-May-2018 Brooks Davis <brooks@FreeBSD.org>

Correct pointer subtraction in KASSERT().

The assertion would never fire without truly spectacular future
programming errors.

Reported by: Coverity
CID: 1391370
Sponsored by: DARPA, AFRL


# 5f77b8a8 24-May-2018 Brooks Davis <brooks@FreeBSD.org>

Avoid two suword() calls per auxarg entry.

Instead, construct an auxargs array and copy it out all at once.

Use an array of Elf_Auxinfo rather than pairs of Elf_Addr * to represent
the array. This is the correct type where pairs of words just happend
to work. To reduce the size of the diff, AUXARGS_ENTRY is altered to act
on this array rather than introducing a new macro.

Return errors on copyout() and suword() failures and handle them in the
caller.

Incidentally fixes AT_RANDOM and AT_EXECFN in 32-bit linux on amd64
which incorrectly used AUXARG_ENTRY instead of AUXARGS_ENTRY_32
(now removed due to the use of proper types).

Reviewed by: kib
Comments from: emaste, jhb
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D15485


# 73c8686e 19-Apr-2018 John Baldwin <jhb@FreeBSD.org>

Simplify the code to allocate stack for auxv, argv[], and environment vectors.

Remove auxarg_size as it was only used once right after a confusing
assignment in each of the variants of exec_copyout_strings().

Reviewed by: emaste
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D15123


# 7c5d1690 12-Apr-2018 Konstantin Belousov <kib@FreeBSD.org>

Fix PSL_T inheritance on exec for x86.

The miscellaneous x86 sysent->sv_setregs() implementations tried to
migrate PSL_T from the previous program to the new executed one, but
they evaluated regs->tf_eflags after the whole regs structure was
bzeroed. Make this functional by saving PSL_T value before zeroing.

Note that if the debugger is not attached, executing the first
instruction in the new program with PSL_T set results in SIGTRAP, and
since all intercepted signals are reset to default dispostion on
exec(2), this means that non-debugged process gets killed immediately
if PSL_T is inherited. In particular, since suid images drop
P_TRACED, attempt to set PSL_T for execution of such program would
kill the process.

Another issue with userspace PSL_T handling is that it is reset by
trap(). It is reasonable to clear PSL_T when entering SIGTRAP
handler, to allow the signal to be handled without recursion or
delivery of blocked fault. But it is not reasonable to return back to
the normal flow with PSL_T cleared. This is too late to change, I
think.

Discussed with: bde, Ali Mashtizadeh
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
Differential revision: https://reviews.freebsd.org/D14995


# b267239d 09-Apr-2018 Ed Maste <emaste@FreeBSD.org>

linuxulator: deduplicate linux_exec_imgact_try

Previously linuxulator had three identical copies of
linux_exec_imgact_try. Deduplicate before adding another arch to
linuxulator.

Sponsored by: Turing Robotic Industries Inc
Differential Revision: https://reviews.freebsd.org/D14856


# 6469bdcd 06-Apr-2018 Brooks Davis <brooks@FreeBSD.org>

Move most of the contents of opt_compat.h to opt_global.h.

opt_compat.h is mentioned in nearly 180 files. In-progress network
driver compabibility improvements may add over 100 more so this is
closer to "just about everywhere" than "only some files" per the
guidance in sys/conf/options.

Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h
is created on all architectures.

Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
set of compiled files.

Reviewed by: kib, cem, jhb, jtl
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14941


# d41e41f9 27-Mar-2018 John Baldwin <jhb@FreeBSD.org>

Remove very old and unused signal information codes.

These have been supplanted by the MI signal information codes in
<sys/signal.h> since 7.0. The FPE_*_TRAP ones were deprecated even
earlier in 1999.

PR: 226579 (exp-run)
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D14637


# f8268d4d 23-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Remove redundant cast from Linuxulator SYSINITs


# ad448975 23-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Fixup return style(9) in amd64 linux*_sysvec.c

Sponsored by: Turing Robotic Industries Inc.


# c0aa0e2c 23-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Sort headers in MD Linuxulator files

Bring #includes closer to style(9) and reduce differences between the
(three) MD versions of linux_machdep.c and linux_sysvec.c.

Sponsored by: Turing Robotic Industries Inc.


# 1ac2776b 21-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Share Linux errno table with libsysdecode

Requested by: jhb
Reviewed by: jhb
Sponsored by: Turing Robotic Industries Inc.


# b7d779b3 20-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Make linuxulator fn declaration match definition

I accidentally swapped 'linux_fixup_elf' to 'linux_elf_fixup' in amd64's
declaration (only), while bringing this change over from git and
encountering a conflict.


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


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

linux*_sysvec.c: rationalize whitespace and comments

There's a fair amount of duplication between MD linuxulator files.
Make indentation and comments consistent between the three versions of
linux_sysvec.c to reduce diffs when comparing them.

Sponsored by: Turing Robotic Industries Inc.


# 6e481f83 16-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Share a single bsd-linux errno table across MD consumers

Three copies of the linuxulator linux_sysvec.c contained identical
BSD to Linux errno translation tables, and future work to support other
architectures will also use the same table. Move the table to a common
file to be used by all. Make it 'const int' to place it in .rodata.

(Some existing Linux architectures use MD errno values, but x86 and Arm
share the generic set.)

This change should introduce no functional change; a followup will add
missing errno values.

MFC after: 3 weeks
Sponsored by: Turing Robotic Industries Inc.
Differential Revision: https://reviews.freebsd.org/D14665


# 7b194b3d 14-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Remove stray ; at end of linux_vdso_deinstall()


# a95659f7 13-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Use C99 boolean type for translate_osrel

Migrate to modern types before creating MD Linuxolator bits for new
architectures.

Reviewed by: cem
Sponsored by: Turing Robotic Industries Inc.
Differential Revision: https://reviews.freebsd.org/D14676


# 4ba25759 12-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Apply some style(9) to Linuxulator linux_sysvec.c comments


# eae594f7 21-Feb-2018 Ed Maste <emaste@FreeBSD.org>

Correct proper nouns in the Linuxulator

- Capitalize Linux
- Spell FreeBSD out in full
- Address some style(9) on changed lines

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.


# cd76ee1e 27-Nov-2017 Fedor Uporov <fsu@FreeBSD.org>

Remap ENOATTR to ENODATA in the linuxulator.
In the linux ENOADATA is frequently #defined as ENOATTR.
The change is required for an xattrs support implementation.

MFC after: 1 week
Discussed with: netchild
Approved by: pfg

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


# d95498d4 19-Oct-2017 Mateusz Guzik <mjg@FreeBSD.org>

amd64: avoid acquiring dt lock if possible (which is the common case)

Discussed with: kib
MFC after: 1 week


# cd155b56 01-Aug-2017 Don Lewis <truckman@FreeBSD.org>

Lower the amd64 shared page, which contains the signal trampoline,
from the top of user memory to one page lower on machines with the
Ryzen (AMD Family 17h) CPU. This pushes ps_strings and the stack
down by one page as well. On Ryzen there is some sort of interaction
between code running at the top of user memory address space and
interrupts that can cause FreeBSD to either hang or silently reset.
This sounds similar to the problem found with DragonFly BSD that
was fixed with this commit:
https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/b48dd28447fc8ef62fbc963accd301557fd9ac20
but our signal trampoline location was already lower than the address
that DragonFly moved their signal trampoline to. It also does not
appear to be related to SMT as described here:
https://www.phoronix.com/forums/forum/hardware/processors-memory/955368-some-ryzen-linux-users-are-facing-issues-with-heavy-compilation-loads?p=955498#post955498

"Hi, Matt Dillon here. Yes, I did find what I believe to be a
hardware issue with Ryzen related to concurrent operations. In a
nutshell, for any given hyperthread pair, if one hyperthread is
in a cpu-bound loop of any kind (can be in user mode), and the
other hyperthread is returning from an interrupt via IRETQ, the
hyperthread issuing the IRETQ can stall indefinitely until the
other hyperthread with the cpu-bound loop pauses (aka HLT until
next interrupt). After this situation occurs, the system appears
to destabilize. The situation does not occur if the cpu-bound
loop is on a different core than the core doing the IRETQ. The
%rip the IRETQ returns to (e.g. userland %rip address) matters a
*LOT*. The problem occurs more often with high %rip addresses
such as near the top of the user stack, which is where DragonFly's
signal trampoline traditionally resides. So a user program taking
a signal on one thread while another thread is cpu-bound can cause
this behavior. Changing the location of the signal trampoline
makes it more difficult to reproduce the problem. I have not
been because the able to completely mitigate it. When a cpu-thread
stalls in this manner it appears to stall INSIDE the microcode
for IRETQ. It doesn't make it to the return pc, and the cpu thread
cannot take any IPIs or other hardware interrupts while in this
state."
since the system instability has been observed on FreeBSD with SMT
disabled. Interrupts to appear to play a factor since running a
signal-intensive process on the first CPU core, which handles most
of the interrupts on my machine, is far more likely to trigger the
problem than running such a process on any other core.

Also lower sv_maxuser to prevent a malicious user from using mmap()
to load and execute code in the top page of user memory that was made
available when the shared page was moved down.

Make the same changes to the 64-bit Linux emulator.

PR: 219399
Reported by: nbe@renzel.net
Reviewed by: kib
Reviewed by: dchagin (previous version)
Tested by: nbe@renzel.net (earlier version)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D11780


# c151945c 30-Jul-2017 Dmitry Chagin <dchagin@FreeBSD.org>

Avoid using [LINUX_]SHAREDPAGE constant directly in the vdso code.
This is needed for https://reviews.freebsd.org/D11780.

Reported by: kib@


# a0c59c7a 03-Jul-2017 Dmitry Chagin <dchagin@FreeBSD.org>

Add support for musl consumers to the Linuxulator.

PR: 213809
Submitted by: Yonas Yanfa
Reported by: Yonas Yanfa
MFC after: 1 week
Relnotes: yes


# 2d88da2f 12-Jun-2017 Konstantin Belousov <kib@FreeBSD.org>

Move struct syscall_args syscall arguments parameters container into
struct thread.

For all architectures, the syscall trap handlers have to allocate the
structure on the stack. The structure takes 88 bytes on 64bit arches
which is not negligible. Also, it cannot be easily found by other
code, which e.g. caused duplication of some members of the structure
to struct thread already. The change removes td_dbg_sc_code and
td_dbg_sc_nargs which were directly copied from syscall_args.

The structure is put into the copied on fork part of the struct thread
to make the syscall arguments information correct in the child after
fork.

This move will also allow several more uses shortly.

Reviewed by: jhb (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
X-Differential revision: https://reviews.freebsd.org/D11080


# 86e01d5a 24-Jan-2017 Tijl Coosemans <tijl@FreeBSD.org>

Apply r210555 to 64 bit linux support:

The interpreter name should no longer be treated as a buffer that can be
overwritten.

PR: 216346
MFC after: 3 days


# b66bb393 22-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

Cleanup redundant parenthesis from existing howmany()/roundup() macro uses.


# ea24b056 19-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

X86: use our nitems() macro when it is avaliable through param.h.

No functional change, only trivial cases are done in this sweep,

Discussed in: freebsd-current


# b6348be7 05-Apr-2016 Baptiste Daroussin <bapt@FreeBSD.org>

Add kern.features flags for linux and linux64 modules

kern.features.linux: 1 meaning linux 32 bits binaries are supported
kern.features.linux64: 1 meaning linux 64 bits binaries are supported

The goal here is to help 3rd party applications (including ports) to determine
if the host do support linux emulation

Reviewed by: dchagin
MFC after: 1 week
Relnotes: yes
Differential Revision: D5830


# aa949be5 27-Jan-2016 John Baldwin <jhb@FreeBSD.org>

Convert ss_sp in stack_t and sigstack to void *.

POSIX requires these members to be of type void * rather than the
char * inherited from 4BSD. NetBSD and OpenBSD both changed their
fields to void * back in 1998. No new build failures were reported
via an exp-run.

PR: 206503 (exp-run)
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D5092


# 669414e4 27-Jan-2016 Xin LI <delphij@FreeBSD.org>

Implement AT_SECURE properly.

AT_SECURE auxv entry has been added to the Linux 2.5 kernel to pass a
boolean flag indicating whether secure mode should be enabled. 1 means
that the program has changes its credentials during the execution.
Being exported AT_SECURE used by glibc issetugid() call.

Submitted by: imp, dchagin
Security: FreeBSD-SA-16:10.linux
Security: CVE-2016-1883


# 038c7205 09-Jan-2016 Dmitry Chagin <dchagin@FreeBSD.org>

Implement vsyscall hack. Prior to 2.13 glibc uses vsyscall
instead of vdso. An upcoming linux_base-c6 needs it.

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

Reviewed by: kib, trasz
MFC after: 1 week


# 724f4b62 28-Nov-2015 Konstantin Belousov <kib@FreeBSD.org>

Remove sv_prepsyscall, sv_sigsize and sv_sigtbl members of the struct
sysent.

sv_prepsyscall is unused.

sv_sigsize and sv_sigtbl translate signal number from the FreeBSD
namespace into the ABI domain. It is only utilized on i386 for iBCS2
binaries. The issue with this approach is that signals for iBCS2 were
delivered with the FreeBSD signal frame layout, which does not follow
iBCS2. The same note is true for any other potential user if
sv_sigtbl. In other words, if ABI needs signal number translation, it
really needs custom sv_sendsig method instead.

Sponsored by: The FreeBSD Foundation


# 3e15a670 08-Oct-2015 Mateusz Guzik <mjg@FreeBSD.org>

linux: fix handling of out-of-bounds syscall attempts

Due to an off by one the code would read an entry past the table, as
opposed to the last entry which contains the nosys handler.

Reported by: Pawel Biernacki <pawel.biernacki gmail.com>


# 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


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

Call nosys in case when the incorrect syscall number is specified.

Reported by: trinity


# 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


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

Add preliminary support for x86-64 Linux binaries.

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