Commit graph

575 commits

Author SHA1 Message Date
Dmitry Chagin
ff95f72dee linux(4): Regen for timer_gettime64 syscall.
MFC after:      2 weeks

(cherry picked from commit 1cccef6dff)
2022-06-17 22:34:20 +03:00
Dmitry Chagin
f925361540 linux(4): Change timer_gettime64 syscall definition to match Linux actual one.
MFC after:		2 weeks

(cherry picked from commit ccec96033c)
2022-06-17 22:34:16 +03:00
Dmitry Chagin
b2f336bb73 linux(4): Implement sched_rr_get_interval_time64 syscall.
MFC after:		2 weeks

(cherry picked from commit 8c84ca657b)
2022-06-17 22:34:15 +03:00
Dmitry Chagin
5c06b4de43 linux(4): Regen for sched_rr_get_interval_time64 syscall.
MFC after:      2 weeks

(cherry picked from commit cdddbb77c3)
2022-06-17 22:34:15 +03:00
Dmitry Chagin
4b05f04fb1 linux(4): Change sched_rr_get_interval_time64 syscall definition to match Linux actual one.
MFC after:		2 weeks

(cherry picked from commit 7b520c0b3c)
2022-06-17 22:34:11 +03:00
Dmitry Chagin
4b4dac6ce8 linux(4): Regen for epoll_pwait2 syscall.
(cherry picked from commit df377f1fb8)
2022-06-17 22:34:09 +03:00
Dmitry Chagin
7a865d8861 linux(4): Change epoll_pwait2 syscall definition to match Linux actual one.
MFC after:	2 weeks

(cherry picked from commit 81b0b7dc0c)
2022-06-17 22:34:05 +03:00
Dmitry Chagin
b203abf47a linux(4): Regen for rseq syscall.
(cherry picked from commit 75e409495f)
2022-06-17 22:34:03 +03:00
Dmitry Chagin
24c5e6eb7b linux(4): Change rseq syscall definition to match Linux actual one.
MFC after:	2 weeks

(cherry picked from commit f202f35db0)
2022-06-17 22:33:57 +03:00
Dmitry Chagin
82fa7c3b83 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

(cherry picked from commit d5dc757e84)
2022-06-17 22:33:47 +03:00
John Baldwin
6cc60a705f linux_copyout_strings: Use PROC_PS_STRINGS().
Reviewed by:	markj
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D34173

(cherry picked from commit 6bea696af2)
2022-06-17 22:33:42 +03:00
Mateusz Guzik
753605353d linux: remove the always curthread argument from lconvpath
(cherry picked from commit af4051d250)
2022-06-17 22:33:39 +03:00
Edward Tomasz Napierala
bf0ad7c979 linux: Constify bsd_to_linux_regset()
No functional changes.

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

(cherry picked from commit 3417c29851)
2022-06-17 22:33:34 +03:00
Dmitry Chagin
8b54e105d5 linux(4): Regen for clone3 system call.
MFC after:		2 weeks

(cherry picked from commit b356030e67)
2022-06-17 22:33:30 +03:00
Dmitry Chagin
b27e302329 linux(4): Implement clone3 system call.
clone3 system call is used by glibc-2.34.

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

(cherry picked from commit 17913b0b6b)
2022-06-17 22:33:30 +03:00
Dmitry Chagin
8fb3f959dc 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

(cherry picked from commit 0a4b664ae8)
2022-06-17 22:33:30 +03:00
Dmitry Chagin
94ac0dac7f linux(4): Regen for clone syscall.
MFC after:		2 weeks

(cherry picked from commit 0c08f34f4d)
2022-06-17 22:33:29 +03:00
Dmitry Chagin
b2c247a0db linux(4): Change clone syscall definition to match Linux actual one.
Differential revision:	https://reviews.freebsd.org/D31473
MFC after:		2 weeks

(cherry picked from commit f1c450492f)
2022-06-17 22:33:29 +03:00
Dmitry Chagin
5a66ec2748 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

(cherry picked from commit de8374df28)
2022-06-17 22:33:28 +03:00
Dmitry Chagin
282eae4d06 linux(4): Regen for faccessat2 system call.
MFC after:		2 weeks

(cherry picked from commit bee191e46f)
2022-06-17 22:33:26 +03:00
Dmitry Chagin
15e715fe7c linux(4): Implement faccessat2 system call.
It's used by bash on arm64 with glibc-2.32.

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

(cherry picked from commit 13d79be995)
2022-06-17 22:33:26 +03:00
Dmitry Chagin
85b2ff6496 linux(4): Fix gcc buld.
gcc failed as it didn't inlined the builtins and generates calls to
the libgcc, ld can't find libgcc as cross-toolchain libgcc is not installed.
To avoid this add internal vDSO ffs functions without optimized builtins.

Reported by:		jhb
MFC after:		2 weeks

(cherry picked from commit f337940144)
2022-06-17 22:33:14 +03:00
Dmitry Chagin
6698c1a28d 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

(cherry picked from commit cf8d74e3fe)
2022-06-17 22:33:12 +03:00
Edward Tomasz Napierala
97382953f2 linux: implement sigaltstack(2) on arm64
... by making it machine-independent.

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

(cherry picked from commit 30c6d98219)
2022-06-17 22:33:10 +03:00
Dmitry Chagin
896a4b7c79 linux(4): Add arch name to the some printfs.
Reviewed by:		emaste
Differential revision:	https://reviews.freebsd.org/D30904
MFC after:		2 weeks

(cherry picked from commit ae8330b448)
2022-06-17 22:33:08 +03:00
Dmitry Chagin
4e34c0445c 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

(cherry picked from commit 09cffde975)
2022-06-17 22:33:07 +03:00
Dmitry Chagin
b960dd4815 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

(cherry picked from commit a543556c81)
2022-06-17 22:33:07 +03:00
Dmitry Chagin
a340b5b4bd 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.

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

(cherry picked from commit 9931033bbf)
2022-06-17 22:33:07 +03:00
Dmitry Chagin
54689a282a 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

(cherry picked from commit 5fd9cd53d2)
2022-06-17 22:33:05 +03:00
Edward Tomasz Napierala
1b196c07b8 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

(cherry picked from commit 447636e43c)
2022-06-17 22:33:02 +03:00
Dmitry Chagin
a13f21b252 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

(cherry picked from commit 4aae133469)
2022-06-17 22:30:24 +03:00
Dmitry Chagin
0cd177a3d3 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

(cherry picked from commit c1da89fec2)
2022-06-17 22:30:23 +03:00
Dmitry Chagin
b5bfa2af4b linux(4): Regen for linux_poll system call.
MFC after:	2 weeks

(cherry picked from commit 8fe8bb7cb5)
2022-06-17 22:30:20 +03:00
Dmitry Chagin
b7289a2e08 linux(4): Implement poll system call via linux_common_ppol()
for the sake of converting events to/from native.

MFC after:	2 weeks

(cherry picked from commit 2eff670fde)
2022-06-17 22:30:19 +03:00
Dmitry Chagin
b2deba043c 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

(cherry picked from commit 26795a0378)
2022-06-17 22:30:19 +03:00
Dmitry Chagin
7e3a56d742 linux(4): Regen for ppoll_time64 system call.
MFC after:	2 weeks

(cherry picked from commit 89f15b79b1)
2022-06-17 22:30:18 +03:00
Dmitry Chagin
ad561d55e4 linux(4): Implement ppoll_time64 system call.
MFC after:	2 weeks

(cherry picked from commit ed61e0ce1d)
2022-06-17 22:30:17 +03:00
Dmitry Chagin
9616bcffa1 linux(4): Regen for pselect6_time64 system call.
MFC after:	2 weeks

(cherry picked from commit 981a60f112)
2022-06-17 22:30:17 +03:00
Dmitry Chagin
4250154ede linux(4): Implement pselect6_time64 system call.
MFC after:	2 weeks

(cherry picked from commit f6d075ecd7)
2022-06-17 22:30:16 +03:00
Dmitry Chagin
efb9538e1f linux(4): Regen for rt_sigtimedwait_time64 system call.
MFC after:	2 weeks

(cherry picked from commit c002529000)
2022-06-17 22:30:16 +03:00
Dmitry Chagin
2eae70753e linux(4): Implement rt_sigtimedwait_time64 system call.
It still does not work as intended, awaits D30675.

MFC after:	2 weeks

(cherry picked from commit db4a1f331b)
2022-06-17 22:30:15 +03:00
Dmitry Chagin
f83465c2e7 linux(4): Regen for futex_time64 system call.
MFC after:	2 weeks

(cherry picked from commit 985978806e)
2022-06-17 22:30:15 +03:00
Dmitry Chagin
75ed1704e3 linux(4): Implement futex_time64 system call.
MFC after:	2 weeks

(cherry picked from commit 2e46d0c3d9)
2022-06-17 22:30:15 +03:00
Dmitry Chagin
92b1cf8572 linux(4): Regen for futex system call.
MFC after:	2 weeks

(cherry picked from commit ee64d98204)
2022-06-17 22:30:14 +03:00
Dmitry Chagin
f348d6732b linux(4): Change Linux futex syscall definition to match Linux actual one.
MFC after:	2 weeks

(cherry picked from commit 3c1de151e3)
2022-06-17 22:30:14 +03:00
Dmitry Chagin
27c31bdac5 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

(cherry picked from commit f4e801085b)
2022-06-17 22:28:00 +03:00
Dmitry Chagin
e58a9a565f Regen for ('0f8dab45404f347752470579feccc6d2739b9570') Linux
rt_sigtimedwait system call.

MFC after:	2 weeks

(cherry picked from commit e29ea22f70)
2022-06-17 22:27:59 +03:00
Dmitry Chagin
77935ceb59 linux(4): Fix timeout parameter of rt_sigtimedwait syscall, which is
timespec not a timeval.

MFC after:	2 weeks

(cherry picked from commit 0f8dab4540)
2022-06-17 22:27:59 +03:00
Dmitry Chagin
e13423cc78 Regen for ('6501370a7dfb358daf07555136742bc064e68cb7') Linux
clock_nanosleep_time64 system call.

MFC after:	2 weeks

(cherry picked from commit 56b187005c)
2022-06-17 22:27:59 +03:00
Dmitry Chagin
677bd84068 linux(4): Implement clock_nanosleep_time64 system call.
MFC after:	2 weeks

(cherry picked from commit 6501370a7d)
2022-06-17 22:27:58 +03:00