If there are per-platform differences in which syscalls are supported,
we should only try to export implemented ones in libc. Fortunately,
syscall maps are run though cpp. This is arguably incomplete as
syscall.mk isn't (and can't practically be) supported.
Reviewed by: kevans
Sponsored by: DARPA, AFRL
Pull Request: https://github.com/freebsd/freebsd-src/pull/1575
Warn that C preprocessor directives in the config file are deprecated.
They are unsound and support has a number of potential pitfalls. They
should be replaced by compile-time generation of files plus an overlay
framework to allow things like per-arch variation.
Reviewed by: kevans
Sponsored by: DARPA, AFRL
Pull Request: https://github.com/freebsd/freebsd-src/pull/1575
Allow patterns like this in syscalls.master:
#if 0
91 AUE_NULL RESERVED
#else
91 AUE_NULL STD|CAPENABLED {
int newsyscall(void);
}
#endif
makesyscalls.lua and it's predecessor makesyscalls.sh (really an awk
script with a tiny shell prolog) used a single pass parsing model where
lines beginning with `#` were emitted into most generated files as they
were read. I belive this was initially there to allow includes to be
listed in syscalls.master, but Hyrum's Law[0] applies and people are using
it for things like architecture-specific syscall definitions.
This use of CPP macro is unsound and there are a number of sharp edges
in both the new and old implementations. The macros are unsound because
not all the files were generate are run through CPP (or if they are not
in the same context) and this will increasingly be true as we generate
more things. Sharp edges include the fact that anything before the
first syscall would be printed at a different scope (e.g., before an
array is declared).
In this patch I collect each non-#include CPP directive and attach them
to the syscall table or individual entries. All entries before the
first syscall and after the last are attached to the prolog and epilog
members. Within the syscall table all entries are attached to the next
system calls's prolog member. In generators, each prolog entry is
printed regardless of the system call's visibiilty which replicates the
naive single pass model's behavior (including lots of empty blocks
of #if/#else/#endif in the output). Unlike makesyscalls.lua, I discard
none #define entries at the top of the file and print a warning as their
usefulness appears limited.
[0] https://www.hyrumslaw.com
Reported by: kevans
Reviewed by: kevans
Sponsored by: DARPA, AFRL
Pull Request: https://github.com/freebsd/freebsd-src/pull/1575
The two outer blocks had identical contents and the two inner blocks
differed in a single location.
Reviewed by: kevans
Sponsored by: DARPA, AFRL
Pull Request: https://github.com/freebsd/freebsd-src/pull/1575
The yield system call has long existed, but never had a stub. Replace
the hardcoded checks for it in libsys_h.lua and syscalls_map.lua and
stop inserting it into MIASM (requiring libsys/Makefile.sys to disable
the stub).
(This seems like overkill, but I've got another case in CheriBSD so this
reduces my diff appreciably.)
Reviewed by: emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1503
We haven't used this since commit be67ea40c5 in 2021 so stop carrying
it forward.
Also remove support for setting the list in syscalls.conf via the
capenabled variable. This was last used by cloudabi (removed in 2021
by commit cf0ee8738e).
* main.lua replicates the functionality of makesyscalls.lua
* Individual files are generated by their associated module
* Modules can be called as standalone scripts to generate a specific
file
* Data and procedures are performed by objects instead of procedual code
* Bitmasks are replaced by declarative types
* Temporary files are no longer produced, writing is stored in memory
* Comments provide explanation to functions and semantics
Google Summer of Code 2024 Final Work Product
Co-authored-by: Warner Losh <imp@freebsd.org>
Co-authored-by: Kyle Evans <kevans@freebsd.org>
Co-authored-by: Brooks Davis <brooks@freebsd.org>
Sponsored by: Google (GSoC 24)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1362
Signed-off-by: agge3 <sterspark@gmail.com>
An upcoming refactor appends do-not-merge comments to all headers
centrally to do the same to reduce the final diff. Headers also start
with a comment line (for /*) and end with a blank line.
Comment aligning was inconsistent and required a ton of book-keeping.
Replaced comment aligning with a simple, single tab out.
Pull Request: https://github.com/freebsd/freebsd-src/pull/1441
Signed-off-by: agge3 <sterspark@gmail.com>
Some of the defined names are not the direct 1:1 mapping with vendor
and device names used by Linux device drivers.
Introduce a p(roduct)alias so we can map the one device entry I came
across without much extra hassle and generate a name device drivers
know about:
palias BROADCOM_CYPRESS_43439 CYPRESS_43439
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D46455
Generate defined names which match the ones in the Linux drivers (a lot more);
given we are likely to have drivers only based on those one way or another
there is absolutely no reason to fight over differently generated names
for device and vendor IDs.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D46300
The input file used to have a $FreeBSD$ tag on the first line and we
recorded that in the generated files to know which versions they were
based on. With the removal of $FreeBSD$ the logic was not quite
correct anymore; fix that to generate proper header files again.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D46300
The latest ota is the first one in FreeBSD that treats 0 + "0xf" as
being '0' instead of '15'. Don't use this old trick anymore to convert
from hexidecimal to a number. Write a function to do that instead. This
fixes kernel.bin building on arm*. awk on 14 doesn't need this, but to
build FreeBSD stable/14's kernel.bin on 15 we'll need it, so fast MFC.
MFC After: 3 days
Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D44801
Create a header covering most of the "stable" libsys interfaces.
Specifically __sys_<foo> syscall stubs and __sys_<foo>_t typedefs for
those interfaces.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D44386
In sysproto.h, stop including sys/acl.h as syscall defintions now use
__acl* types from sys/_types.h. Add sys/types.h to provide types
previously provided by sys/param.h (via sys/acl.h).
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D44467
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
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
For libsys we need to expose all the private symbols (_ and __sys_
prefixes) so libsys can replace the libc versions. Rather than trying
to maintain a table, teach makesyscalls to generate it.
There are a small number of "_" prefixed symbols that are exposed as
public interfaces rather than in the private symbol space. Since the
list is short, just hardcode it for now.
If doesn't appear that we need to export freebsd#_foo symbols for compat
system calls explicitly. If it turns out we do, there are probably few
enough of them to handle seperately.
Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.
Sponsored by: Netflix
We only want to produce syscall.mk for the main syscall table so default
to not producing it (send it to /dev/null) and add a syscalls.conf to
sys/kern to trigger the creation of sys/sys/syscall.mk. This eliminates
the need for entries in other syscalls.conf files and is a cleaner
pattern going forward.
Reviewed by: kevans, imp
Differential Revision: https://reviews.freebsd.org/D42663
Just ignore the first line of the usbdevs file. And stop recording what
the usbdevs* files were generated from. It's said '$FreeBSD$' for years
now...
Sponsored by: Netflix
Currently for the MFS, firmware and VDSO template assembly files we pass
the path to include with .incbin unquoted and use __XSTRING within the
assembly file to stringify it. However, __XSTRING doesn't just perform a
single level of expansion, it performs the normal full expansion of the
macro, and so if the path itself happens to tokenise to something that
includes a defined macro in it that will itself be substituted. For
example, with #define MACRO 1, a path like /path/containing/MACRO/in/it
will expand to /path/containing/1/in/it and then, when stringified, end
up as "/path/containing/1/in/it", not the intended string. Normally,
macros have names that start or end witih underscores and are unlikely
to appear in a tokenised path (even if technically they could), but now
that we've switched to GNU C as of commit ec41a96daa ("sys: Switch the
kernel's C standard from C99 to GNU99.") there are a few new macros
defined which don't start or end with underscores: unix, which is always
defined to 1, and i386, which is defined to 1 on i386. The former
probably doesn't appear in user paths in practice, but the latter has
been seen to and is likely quite common in the wild.
Fix this by defining the macro pre-quoted instead of using __XSTRING.
Note that technically we don't need to do this for vdso_wrap.S today as
all the paths passed to it are safe file names with no user-controlled
prefix but we should do it anyway for consistency and robustness against
future changes.
This allows make tinderbox to pass when built with source and object
directories inside ~/path-with-unix, which would otherwise expand to
~/path-with-1 and break.
PR: 272744
Fixes: ec41a96daa ("sys: Switch the kernel's C standard from C99 to GNU99.")
With 14 coming, we no longer need to generate the $FreeBSD$. We can
likely MFC that to 13 as well.
MFC After: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D39879
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.
Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.
Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix
luacheck pointed out two minor issues: line isn't declared as a global,
so declare it local. Also remove an unused parameter.
Suggested by: kevans
Sponsored by: Netflix
x["y"] can be written as x.y, which looks better and is a more typical
lua idiom.
Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D39709
Include the phase and argument field to make it easier to determine
at a glance where the failure originated.
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D38091
Make the dtb/dtbo files with less noise. Remove echo statements, but add
back the call for the non-meta builds to replace the removed noise.
Suggetions by: jrtc27
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37073
These are used in a few places. Pass them to the generated .c and .h
files to allow us to build the parts of the interface the kernel config
supports.
Reviewed by: imp, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36882
When specifying a custom band-pass filter for the sound(4) equalizer,
use the same format as used by the resulting C-code define to avoid
confusion.
PR: 195760
Sponsored by: NVIDIA Networking
'@' is not a valid character in symbol names and can sometimes appear
in path names.
Reviewed by: imp, markj
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D35480