]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoumtx: Add bitset conditional wakeup functionality.
Dmitry Chagin [Thu, 29 Jul 2021 09:42:49 +0000 (12:42 +0300)]
umtx: Add bitset conditional wakeup functionality.

The bitset is a Linux emulation layer extension. This 32-bit mask, in which at
least one bit must be set, is used to select which threads should be woken up.

The bitset is stored in the umtx_q structure, which is used to enqueue the waiter
into the umtx waitqueue. Put the bitset into the hole, that appeared on LP64 due
to data alignment, to prevent the growth of the struct umtx_q.

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

(cherry picked from commit 7caa29115b4a2023128ed07942b71074507a44a1)

2 years agoumtx: Expose some of the umtx structures and API to the rest of the kernel.
Dmitry Chagin [Thu, 29 Jul 2021 09:42:17 +0000 (12:42 +0300)]
umtx: Expose some of the umtx structures and API to the rest of the kernel.

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

(cherry picked from commit 1fdcc87cfd6775896d3cb46bb677dc2a15cfd9ac)

2 years agoumtx: Expose struct abs_timeout to the rest of the kernel.
Dmitry Chagin [Thu, 29 Jul 2021 09:41:58 +0000 (12:41 +0300)]
umtx: Expose struct abs_timeout to the rest of the kernel.

Add umtx_ prefix to all abs_timeout facility and add declaration for it.
For consistency with others abs_timeout mark inline abs_timeout_init2.

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

(cherry picked from commit 307a3dd35cd48ae39849192e0d7a7d34ac7e6ac8)

2 years agoumtx: Split umtx.h on two counterparts.
Dmitry Chagin [Thu, 29 Jul 2021 09:41:29 +0000 (12:41 +0300)]
umtx: Split umtx.h on two counterparts.

To prevent umtx.h polluting by future changes split it on two headers:
umtx.h - ABI header for userspace;
umtxvar.h - the kernel staff.

While here fix umtx_key_match style.

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

(cherry picked from commit af29f3995882fac6e1c0360c2276c7a98056957f)

2 years agofreebsd32: Remove the unnecessary spaces.
Dmitry Chagin [Thu, 29 Jul 2021 09:40:36 +0000 (12:40 +0300)]
freebsd32: Remove the unnecessary spaces.

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

(cherry picked from commit 7cf06e075d1c28ad444e6b6beaf783210123c9d7)

2 years agofreebsd32: Remove unused umtx.h include.
Dmitry Chagin [Thu, 29 Jul 2021 09:40:08 +0000 (12:40 +0300)]
freebsd32: Remove unused umtx.h include.

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

(cherry picked from commit 3c886cb6917f1ff89e5756916cc0ff011e22c74d)

2 years agofreebsd32: Eliminate spaces at end of line.
Dmitry Chagin [Thu, 29 Jul 2021 09:39:30 +0000 (12:39 +0300)]
freebsd32: Eliminate spaces at end of line.

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

(cherry picked from commit 32a18e9abd3809cf265e0e2969cd942fa84ae32b)

2 years agolinux(4): Fix gcc buld.
Dmitry Chagin [Thu, 29 Jul 2021 06:52:33 +0000 (09:52 +0300)]
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 f33794014468562100f6f02ab8147b58bd9f82c0)

2 years agolinux(4): Fix amd64 gcc build.
Dmitry Chagin [Mon, 26 Jul 2021 19:28:21 +0000 (22:28 +0300)]
linux(4): Fix amd64 gcc build.

Do not specify memory model and mregparm for amd64, it's only
available on IA-32 architecture.

Reported by: jhb, jrtc27
MFC after: 2 weeks

(cherry picked from commit b0fa09a0a7e30f301cc58750dedb3d88ec39992d)

2 years agolinux(4): Fix i386 gcc build.
Dmitry Chagin [Mon, 26 Jul 2021 18:28:16 +0000 (21:28 +0300)]
linux(4): Fix i386 gcc build.

Do not specify memory model for i386. Seems that clang silencly
ignores -mcmodel unlike gcc.

Reported by: jhb
MFC after: 2 weeks

(cherry picked from commit de273c83a10c5807b52b7479e477854b77baa912)

2 years agolinux(4): Factor out the futex_wait() op into linux_futex_wait().
Dmitry Chagin [Tue, 20 Jul 2021 11:40:24 +0000 (14:40 +0300)]
linux(4): Factor out the futex_wait() op into linux_futex_wait().

MFC after: 2 weeks

(cherry picked from commit 75cb2382b84d2a7c385e98a18da209236701494e)

2 years agolinux(4): Prevent an endless loop.
Dmitry Chagin [Tue, 20 Jul 2021 11:40:08 +0000 (14:40 +0300)]
linux(4): Prevent an endless loop.

In the futex_atomic_op() the encoded_op is a user-supplied parameter.
If the user specifies an incorrect value for this parameter paired with a valid
*uaddr parameter the caller will go into the endless loop. To prevent this check
futex_atomic_op() result and break the loop in case of ENOSYS.

MFC after: 2 weeks

(cherry picked from commit ef4251e271486227f577494b8cc48623772a74ab)

2 years agolinux(4): Eliminate bogus comment.
Dmitry Chagin [Tue, 20 Jul 2021 11:39:56 +0000 (14:39 +0300)]
linux(4): Eliminate bogus comment.

For the caller is no need for access checking here, as the caller must take care
of EFAULT handling. Moreover, this check would be superfluous, since EFAULT is
extremily rare, and we prefer the fast path.

MFC after: 2 weeks

(cherry picked from commit 80b8d6b144c2f22dda252efe0d9fc70a1c8e15b7)

2 years agolinux(4): Allow musl brand to use FUTEX_REQUEUE op.
Dmitry Chagin [Tue, 20 Jul 2021 11:39:20 +0000 (14:39 +0300)]
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 cf8d74e3fe63da7359d6ca7e0b4b57c5684c2845)

2 years agolinux(4): Factor out the FUTEX_WAKE_OP op into linux_futex_wakeop().
Dmitry Chagin [Tue, 20 Jul 2021 11:38:44 +0000 (14:38 +0300)]
linux(4): Factor out the FUTEX_WAKE_OP op into linux_futex_wakeop().

MFC after: 2 weeks

(cherry picked from commit 4c361d7a5acc04f3da304a605855e23774449204)

2 years agolinux(4): Factor out the FUTEX_CMP_REQUEUE op into linux_futex_requeue().
Dmitry Chagin [Tue, 20 Jul 2021 11:38:27 +0000 (14:38 +0300)]
linux(4): Factor out the FUTEX_CMP_REQUEUE op into linux_futex_requeue().

MFC after: 2 weeks

(cherry picked from commit bb62a91944fa7985ebea29063721c633e28d0752)

2 years agolinux(4): Factor out the FUTEX_WAKE op into linux_futex_wake().
Dmitry Chagin [Tue, 20 Jul 2021 11:38:05 +0000 (14:38 +0300)]
linux(4): Factor out the FUTEX_WAKE op into linux_futex_wake().

MFC after: 2 weeks

(cherry picked from commit 19f7e2c2fb443c1964dcfbd19ca01e2ba37a8c50)

2 years agolinux(4): Factor out the FUTEX_WAIT op into linux_futex_wait().
Dmitry Chagin [Tue, 20 Jul 2021 11:37:51 +0000 (14:37 +0300)]
linux(4): Factor out the FUTEX_WAIT op into linux_futex_wait().

MFC after: 2 weeks

(cherry picked from commit f6b0d275eb9eb89b9719ca835b34116257f6a236)

2 years agolinux(4): Refactor the struct linux_futex_args.
Dmitry Chagin [Tue, 20 Jul 2021 11:37:37 +0000 (14:37 +0300)]
linux(4): Refactor the struct linux_futex_args.

Move flags and rtclock to the struct linux_futex_args. This will be used when
I split linux_futex() into separate futex op functions.

MFC after: 2 weeks

(cherry picked from commit 1866eef48435eda506db32c88ed52605a4cb941a)

2 years agolinux: implement sigaltstack(2) on arm64
Edward Tomasz Napierala [Mon, 26 Jul 2021 23:43:09 +0000 (23:43 +0000)]
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 30c6d982190482857883fc96eefafcc6fd769fa0)

2 years agolinux: implement signal delivery on arm64
Edward Tomasz Napierala [Sun, 25 Jul 2021 06:22:47 +0000 (06:22 +0000)]
linux: implement signal delivery on arm64

Note that this still uses FreeBSD-style sigframe;
this will be addressed later.

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

(cherry picked from commit ccc510b46340da563e21549a1a0cb99915d8d623)

2 years agoDrop rdivacky@ "All rights reserved" from linux_event.
Dmitry Chagin [Tue, 20 Jul 2021 07:06:16 +0000 (10:06 +0300)]
Drop rdivacky@ "All rights reserved" from linux_event.

I got explicit permission from Roman.

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

(cherry picked from commit 2b3818633090aed7941b9d484cb7d05f810ca8f5)

2 years agoDrop "All rights reserved" from my copyright statements.
Dmitry Chagin [Tue, 20 Jul 2021 07:05:50 +0000 (10:05 +0300)]
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

(cherry picked from commit 1ca6b15bbdcebd6a0726dae2e9b72f383139d16c)

2 years agolinux(4): Add arch name to the some printfs.
Dmitry Chagin [Tue, 20 Jul 2021 07:05:08 +0000 (10:05 +0300)]
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 ae8330b44868b260267d850fbd003a11d01c9444)

2 years agolinprocfs: Fixup vDSO name in the procmaps after 9931033bbf.
Dmitry Chagin [Tue, 20 Jul 2021 07:04:20 +0000 (10:04 +0300)]
linprocfs: Fixup vDSO name in the procmaps after 9931033bbf.

As the sv_shared_page_base now pointed out to the native sharedpage and
the process VA layout has changed as follows:
VDSOPAGE (2 * PAGE_SIZE)
SHAREDPAGE (PAGE_SIZE)
USRSTACK
fixup the vDSO name by calculating the start of page relative to the
native sharedpage.

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

(cherry picked from commit fe7409530c5420c739aee72b3dfd036c05628a2c)

2 years agolinux(4): Fixup the vDSO initialization order.
Dmitry Chagin [Tue, 20 Jul 2021 07:02:34 +0000 (10:02 +0300)]
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 09cffde975b87b293457c9a228cb980ec729384a)

2 years agolinux(4): Constify vdso install/deinstall.
Dmitry Chagin [Tue, 20 Jul 2021 07:01:47 +0000 (10:01 +0300)]
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 a543556c8128c52fb044250b8f52f9702c81788d)

2 years agolinux(4); Almost complete the vDSO.
Dmitry Chagin [Fri, 17 Jun 2022 19:33:07 +0000 (22:33 +0300)]
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 9931033bbfbe56a037723638cf3712366c6d943f)

2 years agolinux(4): Modify sv_onexec hook to return an error.
Dmitry Chagin [Fri, 17 Jun 2022 19:33:05 +0000 (22:33 +0300)]
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 5fd9cd53d256e08c601548c425bfcb3472f2d09b)

2 years agoCall sv_onexec hook after the process VA is created.
Dmitry Chagin [Fri, 17 Jun 2022 19:33:04 +0000 (22:33 +0300)]
Call sv_onexec hook after the process VA is created.

For future use in the Linux emulation layer call sv_onexec hook right after
the new process address space is created. It's safe, as sv_onexec used only
by Linux abi and linux_on_exec() does not depend on a state of process VA.

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

(cherry picked from commit 62ba4cd340670e901fbaab98766bd5490b4334bd)

2 years agolinux(4): Remove function prototypes from the vDSO.
Dmitry Chagin [Fri, 17 Jun 2022 19:33:03 +0000 (22:33 +0300)]
linux(4): Remove function prototypes from the vDSO.

In preparation for vDSO code revision get rid of incomplete vDSO methods
from locore, but leave .note.Linux section commented out.
.note.Linux section is used by glibc rtld to get the kernel version, that
saves one system call call. I'll try to implement it later, if figure out
how to use it with jails.

MFC after:      2 weeks

(cherry picked from commit 815165be201e49d118e93dec6c257cd63b69d158)

2 years agolinux(4): implement coredumps on arm64
Edward Tomasz Napierala [Sat, 3 Jul 2021 07:05:44 +0000 (08:05 +0100)]
linux(4): implement coredumps on arm64

Previously they only worked on amd64.

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

(cherry picked from commit 45d99014ca3a57fcc6b603cf4494516b4dadda1b)

2 years agolinux(4): revert arm64 part of 447636e43c0
Edward Tomasz Napierala [Thu, 1 Jul 2021 08:28:01 +0000 (08:28 +0000)]
linux(4): revert arm64 part of 447636e43c0

The arm64 part of the patch was incomplete and prevented
linux64.ko from loading due to missing symbol.

Sponsored By: EPSRC

(cherry picked from commit 93c3453f11c9bc99ae482565b3a3f29b39ab8f62)

2 years agolinux(4): implement coredump support
Edward Tomasz Napierala [Wed, 30 Jun 2021 16:45:21 +0000 (17:45 +0100)]
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 447636e43c08d697664512a50f00f93f41c0a79f)

2 years agoLinuxKPI: Rename a short description of the kmalloc type.
Dmitry Chagin [Tue, 29 Jun 2021 17:20:01 +0000 (20:20 +0300)]
LinuxKPI: Rename a short description of the kmalloc type.

To avoid duplication in the vmstat -m output rename the kmalloc type short
description to 'lkpikmalloc' as the Linux emulation layer historically names
its linux malloc type as 'linux'.

Reviewed by: hselasky, kib, emaste
Differential Revision: https://reviews.freebsd.org/D30928
MFC after: 2 weeks

(cherry picked from commit 5ca9d41700078aa0757ee49aafbdd8f52fc96aae)

2 years agoLinuxKPI: Put compat code under appropriate condition.
Dmitry Chagin [Tue, 29 Jun 2021 17:19:17 +0000 (20:19 +0300)]
LinuxKPI: Put compat code under appropriate condition.

Reviewed by: hselasky, emaste, kib
Differential Revision: https://reviews.freebsd.org/D30927
MFC after: 2 weeks

(cherry picked from commit 1fd26da926d55bc0923b1218af65720dfaa4ca28)

2 years agoEliminate p_elf_machine from struct proc.
Dmitry Chagin [Fri, 17 Jun 2022 19:30:27 +0000 (22:30 +0300)]
Eliminate p_elf_machine from struct proc.

Instead of p_elf_machine use machine member of the Elf_Brandinfo which is now
cached in the struct proc at p_elf_brandinfo member.

Note to MFC: D30918, KBI

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

(cherry picked from commit 945accf502db0dd44522489857f461e29ef17d30)

2 years agoLinuxKPI: Use the proper API to determine the ABI of the running process.
Dmitry Chagin [Tue, 29 Jun 2021 17:17:16 +0000 (20:17 +0300)]
LinuxKPI: Use the proper API to determine the ABI of the running process.

Reviewed by: markj, hselasky, kib
Differential Revision: https://reviews.freebsd.org/D30924
MFC after: 2 weeks

(cherry picked from commit 945accf502db0dd44522489857f461e29ef17d30)

2 years agoAdd a link to the Elf_Brandinfo into the struc proc.
Dmitry Chagin [Fri, 17 Jun 2022 19:30:26 +0000 (22:30 +0300)]
Add a link to the Elf_Brandinfo into the struc proc.

To allow the ABI to make a dicision based on the Brandinfo add a link
to the Elf_Brandinfo into the struct proc. Add a note that the high 8 bits
of Elf_Brandinfo flags is private to the ABI.

Note to MFC: it breaks KBI.

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

(cherry picked from commit 615f22b2fb6d999005473abcb771c6bf25118dfe)

2 years agolinux(4): Make vDSO defines private.
Dmitry Chagin [Fri, 25 Jun 2021 15:41:04 +0000 (18:41 +0300)]
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 4aae133469c6bc4ace55bc54eee552971e37e1c4)

2 years agolinux(4): Retire unused declaration.
Dmitry Chagin [Tue, 22 Jun 2021 05:41:33 +0000 (08:41 +0300)]
linux(4): Retire unused declaration.

MFC after: 2 weeks

(cherry picked from commit 79617645c6d3dc7ac2d5af658a99cbf142646e69)

2 years agolinux(4): Retire a now unused include.
Dmitry Chagin [Tue, 22 Jun 2021 05:39:47 +0000 (08:39 +0300)]
linux(4): Retire a now unused include.

MFC after: 2 weeks

(cherry picked from commit 4efdf5820ef573321b008c228b913d7e48841f59)

2 years agolinux(4): Do not specify shared page for aout binaries.
Dmitry Chagin [Tue, 22 Jun 2021 05:38:45 +0000 (08:38 +0300)]
linux(4): Do not specify shared page for aout binaries.

In Linux vDSO is a small shared ELF library, so it is not intended
for aout binaries. This was added on 64-bit Linuxulator import by mistake.

MFC after: 2 weeks

(cherry picked from commit bfe29037983913f27eae9c5a6d31545ed89f4040)

2 years agolinux(4): Retire linux_kplatform.
Dmitry Chagin [Fri, 17 Jun 2022 19:30:23 +0000 (22:30 +0300)]
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 c1da89fec254f9d079fc17a186e2665a32cc718d)

2 years agolinux(4): Get rid of Linuxulator kernel build options.
Dmitry Chagin [Fri, 17 Jun 2022 19:30:22 +0000 (22:30 +0300)]
linux(4): Get rid of Linuxulator kernel build options.

Stop confusing people, retire COMPAT_LINUX and COMPAT_LINUX32 kernel
build options. Since we have 32 and 64 bit Linux emulators, we can't build both
emulators together into the kernel. I don't think it matters, Linux emulation
depends on loadable modules (via rc).

Cut LINPROCFS and LINSYSFS for consistency.

PR:                     215061
Reviewed by:            bcr (manpages), trasz
Differential Revision:  https://reviews.freebsd.org/D30751
MFC after:              2 weeks

(cherry picked from commit e013e36939ac87b53195370fb5e29f29c1a4b5c6)

2 years agolinux: fix sigaltstack on amd64
Edward Tomasz Napierala [Mon, 26 Jul 2021 10:57:47 +0000 (11:57 +0100)]
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

(cherry picked from commit b54838003cd43845576764dbad8f587d8f8b291d)

2 years agolinux: reduce differences between rt_sendsig() and sendsig()
Edward Tomasz Napierala [Mon, 21 Jun 2021 16:13:53 +0000 (17:13 +0100)]
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

(cherry picked from commit 135dd0cab51e89739416d8f924ea984e364a110e)

2 years agolinux(4): Regen for linux_poll system call.
Dmitry Chagin [Tue, 22 Jun 2021 05:09:55 +0000 (08:09 +0300)]
linux(4): Regen for linux_poll system call.

MFC after: 2 weeks

(cherry picked from commit 8fe8bb7cb573bfc62b04f38acfb2ac79ffcbb97e)

2 years agolinux(4): Implement poll system call via linux_common_ppol()
Dmitry Chagin [Tue, 22 Jun 2021 05:07:46 +0000 (08:07 +0300)]
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 2eff670fde51762239fc64139b0cfb5272ce9cdd)

2 years agolinux(4): Rework Linux ppoll system call.
Dmitry Chagin [Tue, 22 Jun 2021 05:06:05 +0000 (08:06 +0300)]
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 26795a0378b58c3e26b68577a4cc446ab527e8b5)

2 years agosg: get rid of unused include.
Dmitry Chagin [Sun, 13 Jun 2021 08:30:49 +0000 (11:30 +0300)]
sg: get rid of unused include.

sg driver does not depends on the Linuxulator any more.

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

(cherry picked from commit 8345c513c552f458e0d3993e2606c5e98bb79c8b)

2 years agolinux: improve reporting for unsupported syscall flags
Edward Tomasz Napierala [Tue, 15 Jun 2021 09:18:04 +0000 (10:18 +0100)]
linux: improve reporting for unsupported syscall flags

Filter out the flags we do support; previously we would print
out the flag value verbatim.

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

(cherry picked from commit 9d167945e8409c739442a02e3fbacb3bcdcc3306)

2 years agolinux(4): Regen for ppoll_time64 system call.
Dmitry Chagin [Thu, 10 Jun 2021 12:19:12 +0000 (15:19 +0300)]
linux(4): Regen for ppoll_time64 system call.

MFC after: 2 weeks

(cherry picked from commit 89f15b79b187a31815b2d65d900e4ba78a9754ef)

2 years agolinux(4): Implement ppoll_time64 system call.
Dmitry Chagin [Thu, 10 Jun 2021 12:18:46 +0000 (15:18 +0300)]
linux(4): Implement ppoll_time64 system call.

MFC after: 2 weeks

(cherry picked from commit ed61e0ce1d293d659b86e382def05a31ac337e03)

2 years agoSplit kern_poll() on two counterparts.
Dmitry Chagin [Thu, 10 Jun 2021 12:11:25 +0000 (15:11 +0300)]
Split kern_poll() on two counterparts.

The kern_poll_kfds() operates on clear kernel data, kfds points to an
array in the kernel, while kern_poll() operates on user supplied pollfd.
Move nfds check to kern_poll_maxfds().

No functional changes, it's for future use in the Linux emulation layer.

Reviewd by: kib
Differential Revision: https://reviews.freebsd.org/D30690
MFC after: 2 weeks

(cherry picked from commit e884512ad143952f0dbacad631487ce28363fd08)

2 years agolinux(4): Regen for pselect6_time64 system call.
Dmitry Chagin [Thu, 10 Jun 2021 12:04:37 +0000 (15:04 +0300)]
linux(4): Regen for pselect6_time64 system call.

MFC after: 2 weeks

(cherry picked from commit 981a60f112e213e7b8de04bf66588cab5c480b34)

2 years agolinux(4): Implement pselect6_time64 system call.
Dmitry Chagin [Thu, 10 Jun 2021 12:03:30 +0000 (15:03 +0300)]
linux(4): Implement pselect6_time64 system call.

MFC after: 2 weeks

(cherry picked from commit f6d075ecd76925cbe56ea528a59bd74e4dd9451e)

2 years agolinux(4): Regen for rt_sigtimedwait_time64 system call.
Dmitry Chagin [Thu, 10 Jun 2021 11:52:43 +0000 (14:52 +0300)]
linux(4): Regen for rt_sigtimedwait_time64 system call.

MFC after: 2 weeks

(cherry picked from commit c0025290006044d2dd7e3b1b52c04d796dddc374)

2 years agolinux(4): Implement rt_sigtimedwait_time64 system call.
Dmitry Chagin [Thu, 10 Jun 2021 11:51:30 +0000 (14:51 +0300)]
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 db4a1f331b73eb821d5d9c3cbb478ad50223f023)

2 years agolinux(4): Regen for futex_time64 system call.
Dmitry Chagin [Thu, 10 Jun 2021 11:28:25 +0000 (14:28 +0300)]
linux(4): Regen for futex_time64 system call.

MFC after: 2 weeks

(cherry picked from commit 985978806e21073c5578198fedfdd414290c3e64)

2 years agolinux(4): Implement futex_time64 system call.
Dmitry Chagin [Thu, 10 Jun 2021 11:27:06 +0000 (14:27 +0300)]
linux(4): Implement futex_time64 system call.

MFC after: 2 weeks

(cherry picked from commit 2e46d0c3d983ccd603b9bcfb318c37404b0dbc7f)

2 years agolinux(4): Regen for futex system call.
Dmitry Chagin [Thu, 10 Jun 2021 11:16:40 +0000 (14:16 +0300)]
linux(4): Regen for futex system call.

MFC after: 2 weeks

(cherry picked from commit ee64d982049544b1e8a77acc01fd230c906fb305)

2 years agolinux(4): Change Linux futex syscall definition to match Linux actual one.
Dmitry Chagin [Thu, 10 Jun 2021 11:00:00 +0000 (14:00 +0300)]
linux(4): Change Linux futex syscall definition to match Linux actual one.

MFC after: 2 weeks

(cherry picked from commit 3c1de151e365f05809264352b1d57125d792f373)

2 years agoFix copyright, remove "all rights reserved".
Dmitry Chagin [Tue, 8 Jun 2021 05:18:00 +0000 (08:18 +0300)]
Fix copyright, remove "all rights reserved".

The eventfd code was written by me, rdivacky@ copyrigth applicable only
to epoll part of the Linuxulator code. Roman is ok to retire his copyright
from sys/kern/sys_eventfd.c and 'All rights reserved.' lines from
sys/compat/linux/linux_event.[c|h] and sys/kern/sys_eventfd.c files.

Reviewed by: kib, emaste
Approved by: rdivacky
Differential Revision: https://reviews.freebsd.org/D30677
MFC after: 2 weeks

(cherry picked from commit f570a6723e145ae585bfb402f3f42260687666d3)

2 years agolinux(4): Fix clock_nanosleep return value for unsupported clockid.
Dmitry Chagin [Mon, 7 Jun 2021 03:22:25 +0000 (06:22 +0300)]
linux(4): Fix clock_nanosleep return value for unsupported clockid.

The Linux clock_nanosleep() returns ENOTSUP for CLOCK_THREAD_CPUTIME_ID.
This silence one of the LTP clock_nanosleep tests.

MFC after: 2 weeks

(cherry picked from commit 66e73ce7371b717b8dd0dfd6e3deeacfa95e6f8b)

2 years agolinux(4): optimize ksiginfo to siginfo conversion.
Dmitry Chagin [Mon, 7 Jun 2021 03:06:17 +0000 (06:06 +0300)]
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 f4e801085b055fd33f680dd7cb9f8562d236f39a)

2 years agolinux(4): Properly convert linux siginfo to native siginfo
Dmitry Chagin [Mon, 7 Jun 2021 02:55:34 +0000 (05:55 +0300)]
linux(4): Properly convert linux siginfo to native siginfo
add input validation.

MFC after: 2 weeks

(cherry picked from commit 9c1045ff00935a4bb0592d8c00ca1981d3e6eb8b)

2 years agoRegen for ('0f8dab45404f347752470579feccc6d2739b9570') Linux
Dmitry Chagin [Mon, 7 Jun 2021 02:39:29 +0000 (05:39 +0300)]
Regen for ('0f8dab45404f347752470579feccc6d2739b9570') Linux
rt_sigtimedwait system call.

MFC after: 2 weeks

(cherry picked from commit e29ea22f7012bb94f5f427349aa4580539cf2b7c)

2 years agolinux(4): Fix timeout parameter of rt_sigtimedwait syscall, which is
Dmitry Chagin [Mon, 7 Jun 2021 02:35:35 +0000 (05:35 +0300)]
linux(4): Fix timeout parameter of rt_sigtimedwait syscall, which is
timespec not a timeval.

MFC after: 2 weeks

(cherry picked from commit 0f8dab45404f347752470579feccc6d2739b9570)

2 years agoRegen for ('6501370a7dfb358daf07555136742bc064e68cb7') Linux
Dmitry Chagin [Mon, 7 Jun 2021 02:29:27 +0000 (05:29 +0300)]
Regen for ('6501370a7dfb358daf07555136742bc064e68cb7') Linux
clock_nanosleep_time64 system call.

MFC after: 2 weeks

(cherry picked from commit 56b187005c07562dd85f126ee6d2986df1881cec)

2 years agolinux(4): Implement clock_nanosleep_time64 system call.
Dmitry Chagin [Mon, 7 Jun 2021 02:26:48 +0000 (05:26 +0300)]
linux(4): Implement clock_nanosleep_time64 system call.

MFC after: 2 weeks

(cherry picked from commit 6501370a7dfb358daf07555136742bc064e68cb7)

2 years agoRegen for ('187715a420237e1ed94dd5aef158eada7dcdc559') Linux
Dmitry Chagin [Mon, 7 Jun 2021 02:21:48 +0000 (05:21 +0300)]
Regen for ('187715a420237e1ed94dd5aef158eada7dcdc559') Linux
clock_getres_time64 system call.

MFC after: 2 weeks

(cherry picked from commit 773d9153c37a709d5c12bc8abe9166e1d044c01b)

2 years agolinux(4): Implement clock_getres_time64 system call.
Dmitry Chagin [Mon, 7 Jun 2021 02:21:32 +0000 (05:21 +0300)]
linux(4): Implement clock_getres_time64 system call.

MFC after: 2 weeks

(cherry picked from commit 187715a420237e1ed94dd5aef158eada7dcdc559)

2 years agoRegen for ('19f9a0e4df54f8d1e99234146024422bdcfa09ce') Linux
Dmitry Chagin [Mon, 7 Jun 2021 02:14:04 +0000 (05:14 +0300)]
Regen for ('19f9a0e4df54f8d1e99234146024422bdcfa09ce') Linux
clock_settime64 system call.

MFC after: 2 weeks

(cherry picked from commit 82e38486548c70b9e7fc4323376aab85f5cc026c)

2 years agolinux(4): Implement clock_settime64 system call.
Dmitry Chagin [Mon, 7 Jun 2021 02:11:25 +0000 (05:11 +0300)]
linux(4): Implement clock_settime64 system call.

MFC after: 2 weeks

(cherry picked from commit 19f9a0e4df54f8d1e99234146024422bdcfa09ce)

2 years agoRegen for ('99b6f430698fa00a33184dd61591d8b6518ed9d3') Linux
Dmitry Chagin [Mon, 7 Jun 2021 02:08:11 +0000 (05:08 +0300)]
Regen for ('99b6f430698fa00a33184dd61591d8b6518ed9d3') Linux
clock_gettime64 system call.

MFC after: 2 weeks

(cherry picked from commit 9e07ae7a096742018aafb7e29ddf5c4cac8c1e7e)

2 years agolinux(4): Implement clock_gettime64 system call.
Dmitry Chagin [Mon, 7 Jun 2021 02:04:42 +0000 (05:04 +0300)]
linux(4): Implement clock_gettime64 system call.

MFC after: 2 weeks

(cherry picked from commit 99b6f430698fa00a33184dd61591d8b6518ed9d3)

2 years agoRegen for ('e4bffb80bbc6a2e4b3be89aefcbd5bb2c2fc0ba0') Linux
Dmitry Chagin [Mon, 7 Jun 2021 01:56:58 +0000 (04:56 +0300)]
Regen for ('e4bffb80bbc6a2e4b3be89aefcbd5bb2c2fc0ba0') Linux
utimensat_time64 syscall.

MFC after: 2 weeks

(cherry picked from commit ea7fa5583c407664b278a5f50cb16c7a7c6bcbc0)

2 years agolinux(4): Implement utimensat_time64 system call.
Dmitry Chagin [Mon, 7 Jun 2021 01:54:30 +0000 (04:54 +0300)]
linux(4): Implement utimensat_time64 system call.

MFC after: 2 weeks

(cherry picked from commit e4bffb80bbc6a2e4b3be89aefcbd5bb2c2fc0ba0)

2 years agolinux(4): add struct timespec64 definition and conversion routine for
Dmitry Chagin [Mon, 7 Jun 2021 01:47:12 +0000 (04:47 +0300)]
linux(4): add struct timespec64 definition and conversion routine for
future use.

MFC after: 2 weeks

(cherry picked from commit bfcce1a9f6e3c9defde10bb1f83d4ba9752c23f6)

2 years agolinux(4): Microoptimize futimesat, utimes, utime.
Dmitry Chagin [Mon, 31 May 2021 19:54:18 +0000 (22:54 +0300)]
linux(4): Microoptimize futimesat, utimes, utime.
While here wrap long line.

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

(cherry picked from commit 2a0fa277f66b0dc81a97d0f7fc6dc91ff5a7fd9c)

2 years agolinux(4): Handle AT_EMPTY_PATH in the utimensat syscall.
Dmitry Chagin [Mon, 31 May 2021 19:37:06 +0000 (22:37 +0300)]
linux(4): Handle AT_EMPTY_PATH in the utimensat syscall.

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

(cherry picked from commit b4f9b6eef2bb30059cf1040383c88c94f4d093a5)

2 years agolinux(4): Convert flags before use in utimensat.
Dmitry Chagin [Mon, 31 May 2021 19:30:37 +0000 (22:30 +0300)]
linux(4): Convert flags before use in utimensat.

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

(cherry picked from commit 8505eb5dd8f743f29e9c93b6814a34f1890e6c41)

2 years agolinux(4): Add F_GETPIPE_SZ fcntl operation which returns the capacity
Dmitry Chagin [Mon, 31 May 2021 19:15:02 +0000 (22:15 +0300)]
linux(4): Add F_GETPIPE_SZ fcntl operation which returns the capacity
of the pipe referred by fd.

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

(cherry picked from commit a06c12464bb49750c6b113c971e2770408ce422a)

2 years agolinux(4); Retire unnecessary __packed attribute from some struct's
Dmitry Chagin [Mon, 31 May 2021 18:56:34 +0000 (21:56 +0300)]
linux(4); Retire unnecessary __packed attribute from some struct's
definition.

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

(cherry picked from commit 19593f775c23623571cac4cf638996f5c11e91f4)

2 years agolinux: remove redundant SDT tracepoints
Dmitry Chagin [Fri, 17 Jun 2022 19:22:15 +0000 (22:22 +0300)]
linux: remove redundant SDT tracepoints

Remove all the 'entry' and 'return' probes; they clutter up the source
and are redundant to FBT.

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

(cherry picked from commit 5e8caee259d0cc73301b8fc60c8fb388e7f745af)

2 years agolinux(4): make linkat(2) handle AT_EMPTY_PATH
Edward Tomasz Napierala [Tue, 4 May 2021 12:09:31 +0000 (13:09 +0100)]
linux(4): make linkat(2) handle AT_EMPTY_PATH

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

(cherry picked from commit ee384b229dc62b2b0c9180db8c71fa99f30144cf)

2 years agokern_linkat: modify to accept AT_ flags instead of FOLLOW/NOFOLLOW
Edward Tomasz Napierala [Sun, 25 Apr 2021 13:13:02 +0000 (14:13 +0100)]
kern_linkat: modify to accept AT_ flags instead of FOLLOW/NOFOLLOW

This makes this API match other kern_xxxat() functions.

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

(cherry picked from commit 5d1d844a77622878cd05478d4ab504f70e067248)

2 years agoUpdate tools/regression/poll/sockpoll.c for POLLRDPOLL.
Thomas Munro [Wed, 28 Apr 2021 11:08:27 +0000 (23:08 +1200)]
Update tools/regression/poll/sockpoll.c for POLLRDPOLL.

Add a POLLRDHUP example to this tool, for comparison with other
operating systems.  Also record current output on FreeBSD and Linux.

Reviewed by:    kib
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D29757

(cherry picked from commit 18f21f0355481283ceef0ec10e99554f44c205c2)

2 years agopoll(2): Add POLLRDHUP.
Thomas Munro [Wed, 28 Apr 2021 09:31:38 +0000 (21:31 +1200)]
poll(2): Add POLLRDHUP.

Teach poll(2) to support Linux-style POLLRDHUP events for sockets, if
requested.  Triggered when the remote peer shuts down writing or closes
its end.

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29757

(cherry picked from commit 3aaaa2efde896e19d229ee2cf09fe7e6ab0fbf6e)

2 years agolinux: drop unneeded casts
Edward Tomasz Napierala [Mon, 15 Feb 2021 12:34:10 +0000 (12:34 +0000)]
linux: drop unneeded casts

No functional changes.

Sponsored By: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28533

(cherry picked from commit cc743b050acf59862b268296d50923d6e5f0e86f)

2 years agoLoader: support booting OS from memory disk (MD)
Yongbo Yao [Wed, 7 Apr 2021 18:33:22 +0000 (13:33 -0500)]
Loader: support booting OS from memory disk (MD)

Until now, the boot image can be embedded into the loader with
/sys/tools/embed_mfs.sh, and memory disk (MD) is already supported
in loader source. But due to memory disk (MD) driver isn't registered
to the loader yet, the boot image can't be boot from embedded memory
disk.

Reviewed by: dab, tsoome
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D29512

(cherry picked from commit 5984246f9626fbc3d356ee2d3b3cd159f6d0a7c2)

2 years agobsdinstall/scripts/docsinstall: Add Indonesian Documentation
Marc Fonvieille [Mon, 6 Jun 2022 11:40:56 +0000 (13:40 +0200)]
bsdinstall/scripts/docsinstall: Add Indonesian Documentation

Add Indonesian Documentation to docinstall menu.

Approved by: doceng (implicit) re (gjb, implicit)
MFC after: 1 week

(cherry picked from commit 45ef6b4b5db14eaadb1c8c2eda48353c112fd2ae)

2 years agosshd_config: clarify password authentication options
Ed Maste [Wed, 25 May 2022 13:32:57 +0000 (09:32 -0400)]
sshd_config: clarify password authentication options

Passwords may be accepted by both the PasswordAuthentication and
KbdInteractiveAuthentication authentication schemes.  Add a reference to
the latter in the description/comment for PasswordAuthentication, as it
otherwise may seem that "PasswordAuthentication no" implies passwords
will be disallowed.

This situation should be clarified with more extensive documentation on
the authentication schemes and configuration options, but that should be
done in coordination with upstream OpenSSH.  This is a minimal change
that will hopefully clarify the situation without requiring an extensive
local patch set.

PR: 263045
Reviewed by: manu (earlier version)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35272

(cherry picked from commit 9f009e066f088e2c31442db31d2a85001040abfe)

2 years agogetpagesize(3): add .Xr to sysconf(3)
Ed Maste [Mon, 30 May 2022 19:34:34 +0000 (15:34 -0400)]
getpagesize(3): add .Xr to sysconf(3)

POSIX deprecated getpagesize(3).  The portable way to obtain the page
size is `sysconf(_SC_PAGESIZE)`.

Reviewed by: cperciva (earlier), imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35352

(cherry picked from commit 49c937e7040c44afdcfccede57dcecaf9ff08ed6)

2 years agosyscons: note incompatibility with UEFI
Ed Maste [Thu, 26 May 2022 00:19:24 +0000 (20:19 -0400)]
syscons: note incompatibility with UEFI

PR: 264226
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 20b2b464ebb6748756e262d8a421509a2937c74b)

2 years agomakefs: sort cd9660 sysid entries in man page
Ed Maste [Wed, 18 May 2022 19:38:54 +0000 (15:38 -0400)]
makefs: sort cd9660 sysid entries in man page

"efi" was added at the end of the sysid list rather than in alpha
order.  Move it as a diff reduction against NetBSD.

(cherry picked from commit ec3c01ae7233088057395aa50be2439d1abde828)

2 years agoloader.efi: add cross-reference to loader(8)
Ed Maste [Wed, 18 May 2022 14:33:20 +0000 (10:33 -0400)]
loader.efi: add cross-reference to loader(8)

The loader.efi man page describes UEFI-specific loader details, but not
general loader information.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f70de61e567df59bceb2d18c8bc1b54943a7466b)

2 years agourtw(4): Adjust all pause calls to use milliseconds instead of ticks.
Hans Petter Selasky [Thu, 9 Jun 2022 13:11:29 +0000 (15:11 +0200)]
urtw(4): Adjust all pause calls to use milliseconds instead of ticks.

Sponsored by: NVIDIA Networking

(cherry picked from commit c6c22ebb38e7371191e2f8c411b81011ecbe096a)

2 years agoupgt(4): Adjust all pause calls to use milliseconds instead of ticks.
Hans Petter Selasky [Thu, 9 Jun 2022 13:14:17 +0000 (15:14 +0200)]
upgt(4): Adjust all pause calls to use milliseconds instead of ticks.

Sponsored by: NVIDIA Networking

(cherry picked from commit bc2e447338b7ade8d800d1f24913bb3873c65f99)