Commit graph

55 commits

Author SHA1 Message Date
Brooks Davis 1fd880742a libsys: add a libsys.h
This declares an API for libsys which currently consists of
__sys_<foo>() declarations for system call stubs and function pointer
typedefs of the form __sys_<foo>_t.  The vast majority of the
implementation resides in a generated _libsys.h which ensures that all
system call stub declarations match syscalls.master.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44387
2024-04-16 17:48:07 +01:00
Christopher Davidson d3de1bd429 open.2: remove self-reference
Change .Xr reference to .Fn, which quiets a mandoc warning.

Reviewed by:	mhorne
MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1135
2024-04-03 13:55:24 -03:00
Brooks Davis b12090676c lib{c,sys}: correctly expose sched_getcpu
When moving the implementation, I failed to move the symbol entry.

Reviewed by:	kib
Fixes:		84dd0c080b libc: libc/gen/sched_getcpu_gen.c -> libsys/
Differential Revision:	https://reviews.freebsd.org/D44112
2024-03-15 22:52:07 +00:00
Brooks Davis ccf4d5eed2 lib{c,sys}: fix powerpcspe build
libsys/powerpc/Symbol.sys.map was removed due to all symbols moving to
libc.

Fixes:		d7847a8d35 lib{c,sys}: return wrapped syscall APIs to libc
2024-03-13 20:09:41 +00:00
Brooks Davis d7847a8d35 lib{c,sys}: return wrapped syscall APIs to libc
These provide standard APIs, but are implemented using another system
call (e.g., pipe implemented in terms of pipe2) or are interposed by the
threading library to support cancelation.

After discussion with kib (see D44111), I've concluded that it is
better to keep most public interfaces in libc with as little
as possible in libsys.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44241
2024-03-13 18:36:02 +00:00
Brooks Davis ef5fddd344 libsys: make __libsys_interposing static
Access __libsys_interposing with __libc_interposing_slot() in all
cases to support a move of these wrappers back to libc.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44239
2024-03-13 17:31:48 +00:00
Brooks Davis f7dbbbd176 libsys: don't expose sigwait wrapper
Long ago (e129c18a83) __sys_sigwait was wrapped to prevent sigwait()
from returning with EINTR.  Through a series of changes this wrapper
become __libc_sigwait which was internal to libc and used solely in the
interposing table.  To support a move of sigwait back to libc, move this
wrapper into libsys and rename it with an __libsys_ prefix.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44238
2024-03-13 17:04:07 +00:00
Brooks Davis 83392afeeb libsys: don't expose __init_elf_aux_vector
__init_elf_aux_vector is now complied statically so don't try to export
it from the dynamic library.

Fixes:	8271d9b99a libsys: remove usage of pthread_once and _once_stub

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44237
2024-03-07 01:02:25 +00:00
Brooks Davis cc4ffc9786 libsys: don't try to expose yield
The undocumented yield system call has never been implemented via libc
or libsys (except accidentally for <15 minutes in 1998 between commits
abd529ceba and 0db2fac06a).  Avoid trying to export it now to avoid
failures when linking with --no-undefined-version.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44236
2024-03-07 01:01:36 +00:00
Brooks Davis 39a15d7470 syscall(2): make i386 less of an outlier
Unlike other architectures, i386 only defined syscall() and not
_syscall() or __sys_syscall().  The syscall() function then invoked the
desired system call directly rather than invoking syscall(2).  Keep the
latter as it's marginally more efficent, but also create the
conventional _syscall() and __sys_syscall() stubs.

This avoids the need to special case syscall(2) in the symbol list
generation in libsys.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44235
2024-03-07 00:59:07 +00:00
Brooks Davis 7b3836c281 libsys/aarch: Remove pointless MD syscall(2)
This file is functionally identical to the stub generated by
Makefile.sys once the MD version is removed.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44234
2024-03-07 00:59:01 +00:00
Brooks Davis 0ee0ae2373 libsys/arm: Remove pointless MD syscall(2)
This file is functionally identical to the stub generated by
Makefile.sys once the MD version is removed.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44233
2024-03-07 00:58:55 +00:00
Brooks Davis e6ffc7669a libsys/riscv: Remove pointless MD syscall(2)
This file is functionally identical to the stub generated by
Makefile.sys once the MD version is removed.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44232
2024-03-07 00:58:44 +00:00
Brooks Davis 269593dc4a libsys/aarch64: end syscall stubs with newlines
Technically speaking, POSIX text files must end with a newline.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44231
2024-03-07 00:58:29 +00:00
Warner Losh beadbca67b read(2): Add write cross reference
Add a write cross reference in the SEE ALSO section.

Sponsored by:		Netflix
2024-03-01 20:36:39 -07:00
Christopher Davidson 0d161f7b60 read.2: Use .Fn markup instead of .Xr for read/write calls
Udpate both write / read references from .Xr to .Fn to eliminate
self-reference cross reference.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1128
2024-03-01 20:34:10 -07:00
Brooks Davis 304cdac738 lib{c,sys}: expose _getlogin consistently
Historically we exposed _getlogin as a private symbol on a per-arch basis
(except on aarch64 and riscv) for no obvious reason.  We now need to
expose it for libc's use so remove the special case from
makesyscalls.lua and expose it in the generated syscalls.map.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44116
2024-02-29 19:46:33 +00:00
Brooks Davis 6d3f4dcda2 libsys: make PSEUDO take a bare syscall name
Rather than having PSEUDO be a list of object files when all consumers
want syscall names or source files, make it a list of bare syscall
names like INTERPOSED (which is built on PSEUDO).

Improve document of variables developers can set.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44108
2024-02-29 19:19:01 +00:00
Brooks Davis f102db5028 libsys: consolidate PSEUDO definitions
Consolidate in preparation for further cleanup.

Also relocate the sole NOASM entry.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44107
2024-02-29 19:19:01 +00:00
Brooks Davis e52a9177d9 libsys: reduce makefile declaration duplication
Every PSEUDO entry (_foo.o) has a corresponding NOASM entry (foo.o) to
suppress its addition to ASM.  Check PSEUDO instead when adding entries
to ASM.  No functional change.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44106
2024-02-29 19:19:01 +00:00
Brooks Davis 882d9f4507 lib{c,sys}: expose cap_sandboxed from libc/gen
It's a thin wrapper on cap_getmode() implemented in libc, not a system
call so the symbol should have been exposed by libc/gen/Symbol.map
alongside the implementation.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44110
2024-02-28 23:39:55 +00:00
Brooks Davis c5698afcd5 libsys: remove duplicate, commented out code 2024-02-23 22:25:35 +00:00
Konstantin Belousov 7d233b2220 libsys: fix sleep(3)/usleep(3) cancel behavior
Move functions back to libc/gen sources; they are only versioned from
libc and not libsys.
Access libsys interposing slots using __libsys_interposing_slot()
instead of direct __libsys_interposing array dereference, which cannot
work from libc.

Reported by:	glebius
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D44042
2024-02-23 19:39:44 +02:00
Konstantin Belousov baa7d0741b libsys: link symbolic
so that libc/libthr do not preempt libsys symbols, esp. errno-related.

The issue is, if libsys is linked with DT_BIND_NOW flag, and then loaded
as filter, rtld tries to relocate its PLT symbols immediately, not as
filter.  There, during symbol lookup, rtld finds filtering symbols in
libc, and since libc is in loading filters mode, the resolution stops
there.  The end result is that libsys links to libc.

Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D44027
2024-02-23 19:39:42 +02:00
Konstantin Belousov 2f4cbf459d libsys auxv.c: add fences needed to ensure that flag works
Noted by:	jrtc27
Sponsored by:	The FreeBSD Foundation
2024-02-21 16:18:10 +02:00
Konstantin Belousov 3668e1fa0a libsys: disable ssp
Reviewed by:	brooks, imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D43985
2024-02-21 02:26:11 +02:00
Konstantin Belousov fe920a4f2f libsys: move errno to libsys
Before, the 'errno' itself was defined in libc and was referenced by
libsys, causing undesired dependency.

Reviewed by:	brooks, imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D43985
2024-02-21 02:26:11 +02:00
Konstantin Belousov 8271d9b99a libsys: remove usage of pthread_once and _once_stub
that existed in auxv.c, use simple bool gate instead. This leaves a
small window if two threads try to call _elf_aux_info(3) simultaneously.
The situation is safe because auxv parsing is really idempotent. The
parsed data is the same, and we store atomic types (int/long/ptr) so
double-init does not matter.

Reviewed by:	brooks, imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D43985
2024-02-21 02:26:11 +02:00
Konstantin Belousov af9758deff libsys: internalize memcpy, memset, and strlcpy
Reviewed by:	brooks, imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D43985
2024-02-21 02:26:11 +02:00
Brooks Davis 99ea675731 lib{c,sys}: move auxargs more firmly into libsys
Continue to filter the public interface (elf_aux_info()), but entierly
relocate the private interfaces (_elf_aux_info(),
__init_elf_aux_vector(), and __elf_aux_vector) to libsys.

This ensures that rtld updates the correct (only) copy of
__elf_aux_vector.  After 968a18975a
updates were confused and __getosreldate was failing, causing
the system to fall back to compat compat12 syscalls in some cases.

Return to explicitly linking libc to libsys and link libthr with libc
and libsys (in that order).

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43910
2024-02-19 22:44:08 +00:00
Konstantin Belousov a52cb4c480 Document aio_read2/aio_write2
Reviewed by:	jhb
Discussed with:	asomers
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43448
2024-02-11 03:54:16 +02:00
Konstantin Belousov e4b7bbd6ab lio_listio(2): add LIO_FOFFSET flag to ignore aiocb aio_offset
and use the current file offset instead.

Requested by:	Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com>
Reviewed by:	jhb
Discussed with:	asomers
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43448
2024-02-11 03:53:50 +02:00
Konstantin Belousov 3e9515846f read.2: Describe debug.iosize_max_clamp
same as it is done for write.2.

PR:	276937
Reported by:	bugs.freebsd.org@masklinn.net
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-02-10 11:43:29 +02:00
Brooks Davis 1995ea1ea2 libsys: add guards to MD manpages
This avoids duplicate installations which fail packaging tests.

Reported by:	emaste
2024-02-09 17:22:13 +00:00
Brooks Davis d5677b0b8b libsys: actually install manpages
In initial hacking I'd bluntly disabled manpage installation in libsys,
then later disabled them for libc, but forgot to fix the former leading
to no syscall manapages.

PR:		276887
Reported by:	Martin Birgmeier <d8zNeCFG@aon.at>
2024-02-08 19:53:29 +00:00
Brooks Davis cc697d22c4 libsys: move some missed manpages
Fixes:	29d079c964 - libsys: move __libsys_interposer consumers
2024-02-08 19:50:32 +00:00
Brooks Davis 11f9745c5b libsys: fix powerpcspe build
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43771
2024-02-07 00:47:03 +00:00
Brooks Davis f217772244 SYS.h: make _SYSCALL_BODY overridable
Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis ef9871c620 libthr: move _umtx_op_err() to libsys
Declare in sys/umtx.h and implement in libsys.  Explicitly link libthr
with libsys.

When building libthr static include _umtx_op_err so we don't break static
linkage with -lpthread.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis e9d961055a libsys: plumb in to build
libsys provides the FreeBSD kernel interface (auxargs, system calls,
vdso).  It can be linked directly for programs using a non-standard
libc and will later be linked as a filter library to libc providing
the actual system call implementation.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 86deddfacb libsys: generate private symbol map
We now export all _ and __sys_ prefixed syscalls stubs from libc and
libsys so that libsys can replace them.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 10f1b536ad libc: move __getosreldate to libsys
Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis f70c5a0925 libc: move getpagesize(s) to libsys
Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 4c33415e4c libc: elf auxiliary vector handling to libsys
This is part of the interface to the kernel and some syscall wrappers
depend on it so move it there.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 81245a77f0 libc: compile _once in libsys
auxv support requires _once(), but we don't want the libsys version
stomping on the libc version should they diverge in the future.  We
could rename it entierly, but for now just hook it in via Makefile.sys.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 1e2502bfca libc: move MD sys related symbols to libsys
This is a mix genuine MD interfaces and compat symbols like _getlogin.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis cdecda8da3 libc: move rfork_thread(3) to libsys
rfork_thread(3) is assembly that makes syscalls directly and uses
cerror so it belongs in libsys.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 31a46e2cc8 libc: Move per-arch sys/Makefile.inc to libsys
libc/<arch>/sys/Makefile.inc -> libsys/<arch>/Makefile.sys.

Require that libsys/<arch>/Makefile.sys exist.  At least for current
archtiectures, it's not possible for an architecture to not have and MD
syscall bits.

powerpcspe/Makefile.sys's structure means it had to be modified when moved
so rename detection won't work, but it has trivial contents so the
history is unimportant.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Brooks Davis 19149b03b1 libc: remove .PATH refs to libc/<arch>/sys
There are no longer any source files here so remove references.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Brooks Davis 4bc66c0f9f libc: remove remaining x86 sys bits to libsys
Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00