Commit graph

614 commits

Author SHA1 Message Date
Dmitry Chagin
d37548e010 linux(4): Properly restore the thread signal mask after signal delivery on i386
Replace sigframe sf_extramask by native sigset_t and use it to
store/restore the thread signal mask without conversion to/from
Linux signal mask.

Pointy hat to:		dchagin
MFC after:		2 weeks

(cherry picked from commit 4a6c2d075d)
2022-06-17 22:35:40 +03:00
Dmitry Chagin
601c19df36 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

(cherry picked from commit 2ca34847e7)
2022-06-17 22:35:37 +03:00
Dmitry Chagin
6bee81f9c6 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

(cherry picked from commit 0e26e54bdf)
2022-06-17 22:35:34 +03:00
Dmitry Chagin
464d2fec88 linux(4): Fix execve() on amd64/linux32 after a125ed50
MFC after:		2 weeks

(cherry picked from commit 53726a1f1e)
2022-06-17 22:35:28 +03:00
Dmitry Chagin
06f6414a64 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

(cherry picked from commit 9016ec056a)
2022-06-17 22:35:28 +03:00
Dmitry Chagin
f327f595cb linux(4): Deduplicate translate_traps()
As translate_traps() is common for x86 Linuxulators,
move it under x86/linux.

MFC after:		2 weeks

(cherry picked from commit 2434137f69)
2022-06-17 22:35:28 +03:00
Dmitry Chagin
3cf95e49cb Retire sv_transtrap
Call translate_traps directly from sendsig().

MFC after:		2 weeks

(cherry picked from commit eca368ecb6)
2022-06-17 22:35:27 +03:00
Dmitry Chagin
68384ee5e4 linux(4): Retire handmade DWARF annotations from signal trampolines
The Linux exports __kernel_sigreturn and __kernel_rt_sigreturn from the
vdso. Modern glibc's sigaction sets the sa_restorer field of sigaction
to the corresponding vdso __sigreturn, and sets the SA_RESTORER.
Our signal trampolines uses the FreeBSD-way to call a signal handler,
so does not use the sigaction's sa_restorer.

However, as glibc's runtime linker depends on the existment of the vdso
__sigreturn symbols, for all Linuxulators was added separate trampolines
named __sigcode with DWARF anotations and left separate __sigreturn
methods, which are exported.

MFC after:              2 weeks

(cherry picked from commit 8f9635dc99)
2022-06-17 22:35:21 +03:00
Dmitry Chagin
c2704d3780 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

(cherry picked from commit 6e826d27c3)
2022-06-17 22:35:21 +03:00
Dmitry Chagin
43dbc72cc5 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

(cherry picked from commit af557e649c)
2022-06-17 22:35:20 +03:00
Dmitry Chagin
3f3bfb8266 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

(cherry picked from commit 21f2461741)
2022-06-17 22:35:20 +03:00
Dmitry Chagin
0fae97fd1c 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

(cherry picked from commit ba279bcd6d)
2022-06-17 22:35:19 +03:00
Dmitry Chagin
4be4063cef linux(4): Retire unneeded initialization
Both uc_flags and uc_link are zeroed above. On amd64 and i386 the
uc_link field is not used at all. The UC_FP_XSTATE bit should be set
in the uc_flags if OS xsave knob is turned on (and xsave is implemented).

MFC after:		2 weeks

(cherry picked from commit 0b5d5dc376)
2022-06-17 22:35:19 +03:00
Dmitry Chagin
77158a5b2b linux(4): Regen for prctl fix.
MFC after:              2 weeks

(cherry picked from commit 7b76c79b0b)
2022-06-17 22:35:11 +03:00
Dmitry Chagin
c8a5bcdb11 linux(4): Fix 039e98e6.
The patch was about an year in my local queue and I still screwed up...

MFC after:		2 weeks

(cherry picked from commit bfae7fbaa2)
2022-06-17 22:35:07 +03:00
Dmitry Chagin
d9c17939f0 linux(4): Return native error from futex_atomic_op to avoid conversion by the caller.
MFC after:		2 weeks

(cherry picked from commit 07d108932a)
2022-06-17 22:35:06 +03:00
Dmitry Chagin
9e7d26a0ca linux(4): Regen for prctl syscall.
MFC after:              2 weeks

(cherry picked from commit e768576718)
2022-06-17 22:35:05 +03:00
Dmitry Chagin
b54dadc226 linux(4): Change prctl syscall definition to match Linux actual one.
Otherwise argX conversion leads to an unexpected behaviour.

MFC after:		2 weeks

(cherry picked from commit 039e98e60c)
2022-06-17 22:35:01 +03:00
Dmitry Chagin
e7a07ad1db linux(4): Implement vdso getcpu for x86.
This is modeled after f2395455 (by kib@).

MFC after:		2 weeks

(cherry picked from commit 5a6a4fb284)
2022-06-17 22:35:00 +03:00
Dmitry Chagin
f360bdf68d linux(4): Refactor vdso_gettc_x86 includes.
Factor out includes from common vdso_gettc_x86 file to the corresponding
MD files.

MFC after:		2 weeks

(cherry picked from commit 332eca05b5)
2022-06-17 22:34:59 +03:00
Dmitry Chagin
fe35736d0b linux(4): Regen for ppoll_time64 syscall.
MFC after:              2 weeks

(cherry picked from commit 61f45f6733)
2022-06-17 22:34:58 +03:00
Dmitry Chagin
9d88adb476 linux(4): Fix ppoll_time64 syscall definition.
Fixed my typo in ed61e0ce1d. Here tsp is a pointer to the 64-bit timespec.

MFC after:		2 weeks

(cherry picked from commit 94f5f150ef)
2022-06-17 22:34:54 +03:00
Dmitry Chagin
9fd86dde83 linux(4): Implement semtimedop syscalls.
On i386 are two semtimedop. The old one is called via multiplexor and
uses 32-bit timespec, and new semtimedop_tim64, which is uses 64-bit
timespec.

MFC after:		2 weeks

(cherry picked from commit 3245a2ecea)
2022-06-17 22:34:53 +03:00
Dmitry Chagin
639c685d25 linux(4): Regen for semtimedop syscalls.
MFC after:              2 weeks

(cherry picked from commit 430460d717)
2022-06-17 22:34:53 +03:00
Dmitry Chagin
6fe321e3ac linux(4): Change semtimedop syscall definition to match Linux actual one.
MFC after:		2 weeks

(cherry picked from commit f19c4e2341)
2022-06-17 22:34:47 +03:00
Dmitry Chagin
d5316587f0 linux(4): Retire linux_semop implementation.
In i386 Linux semop called via ipc() multiplexor, so use kern_semop
directly from multiplexor.

MFC after:		2 weeks

(cherry picked from commit f48a68874b)
2022-06-17 22:34:47 +03:00
Dmitry Chagin
3f8eb6f28b linux(4): Implement recvmmsg_time64 syscall.
MFC after:		2 weeks

(cherry picked from commit 1744f14e26)
2022-06-17 22:34:42 +03:00
Dmitry Chagin
3f3b7fb182 linux(4): Regen for recvmmsg_time64 syscall.
MFC after:      2 weeks

(cherry picked from commit 79695e9585)
2022-06-17 22:34:42 +03:00
Dmitry Chagin
2ea4eb7484 linux(4): Change recvmmsg_time64 syscall definition to match Linux actual one.
MFC after:		2 weeks

(cherry picked from commit 17ccda0039)
2022-06-17 22:34:37 +03:00
Dmitry Chagin
d32db5360b linux(4): Implement timerfd_gettime64 syscall.
MFC after:		2 weeks

(cherry picked from commit ce9f8d6ab0)
2022-06-17 22:34:37 +03:00
Dmitry Chagin
fd2a538abf linux(4): Regen for timerfd_gettime64 syscall.
MFC after:      2 weeks

(cherry picked from commit ac80ae9313)
2022-06-17 22:34:36 +03:00
Dmitry Chagin
487ac6631f linux(4): Change timerfd_gettime64 syscall definition to match Linux actual one.
MFC after:		2 weeks

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

(cherry picked from commit b1f0b08d93)
2022-06-17 22:34:31 +03:00
Dmitry Chagin
e24e366054 linux(4): Regen for timerfd_settime64 syscall.
MFC after:      2 weeks

(cherry picked from commit f4228fbb4e)
2022-06-17 22:34:31 +03:00
Dmitry Chagin
82f7b817cd linux(4): Change timerfd_settime64 syscall definition to match Linux actual one.
MFC after:		2 weeks

(cherry picked from commit 8545bcff31)
2022-06-17 22:34:26 +03:00
Dmitry Chagin
ad5e9b9867 linux(4): Implement timer_settime64 syscall.
MFC after:		2 weeks

(cherry picked from commit a1fd2911dd)
2022-06-17 22:34:26 +03:00
Dmitry Chagin
62787d1535 linux(4): Regen for timer_settime64 syscall.
MFC after:      2 weeks

(cherry picked from commit 9038a0b74c)
2022-06-17 22:34:26 +03:00
Dmitry Chagin
27ff202df8 linux(4): Change timer_settime64 syscall definition to match Linux actual one.
MFC after:		2 weeks

(cherry picked from commit 1508b1b6a0)
2022-06-17 22:34:21 +03:00
Dmitry Chagin
da266f693c linux(4): Implement timer_gettime64 syscall.
MFC after:		2 weeks

(cherry picked from commit 783c1bd8cb)
2022-06-17 22:34:21 +03:00
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