aboutsummaryrefslogtreecommitdiff
path: root/sys/tools
Commit message (Collapse)AuthorAgeFilesLines
* make_dtb.sh: add include pathOskar Holmlund2025-12-111-1/+2
| | | | | | | | | | | | | The device tree include file for TI TPS65* is in a relative path to the source for example: device-tree/src/arm/ti/omap/am335x-bone-common.dtsi#n305 device-tree/src/arm/rockchip/rk3066a-marsboard.dts#n183 This patch gets the dts path and adds that as an include path for the device tree compiler. Approved by: manu (mentor) Differential revision: https://reviews.freebsd.org/D53887
* gdb: Fix some PEP 8 violationsMark Johnston2025-11-194-1/+10
| | | | | | Silence some warnings in my editor. No functional change intended. MFC after: 1 week
* gdb: Make development a bit easierMark Johnston2025-10-272-4/+37
| | | | | | Provide a command which can be used to reload gdb modules. MFC after: 1 week
* gdb: Improve doc stringsMark Johnston2025-10-273-6/+4
| | | | | | | | These are printed by gdb when requesting help for the corresponding function or command, so phrase them such that they make sense in that context. MFC after: 1 week
* libexec/kgdb: Add new modules and install them together with debug infoMark Johnston2025-10-038-0/+390
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change simplifies integration of gdb python scripts with our kernel debugging infrastructure. Rather than putting debugging scripts in /usr/libexec/kgdb, move them to <path-to-kernel-debug-symbols>/gdb, and add a kernel-gdb.py which automatically loads modules from that directory. kernel-gdb.py will be automatically executed by kgdb when loading kernel debug symbols (assuming a default configuration), so one no longer needs to do anything to use these modules. The change also adds a couple of new modules, vnet.py and pcpu.py, for conveniently accessing VNET symbols and PCPU/DPCPU fields, respectively. Note that these require a change to the kernel linker when accessing symbols from a loadable kernel module. sys/tools/gdb/README.txt describes the scheme in more detail and provides some rudiementary documentation for the commands and functions added by these modules. It should be updated when adding new features. sys/tools/gdb/selftest.py can be used to do some primitive testing of the modules. All it does is execute a number of gdb commands making use of commands and functions added by these modules. The developer is expected to verify that the commands complete without errors and that the output looks sane. Discussed with: kp, avg, jhb, glebius MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D50825
* vfs: stop using SDT_PROBES_ENABLED in inlined opsMateusz Guzik2025-09-271-4/+9
| | | | No point after hot patching was introduced.
* makeobjops.awk: Style nits in generated filesZhenlei Huang2025-09-081-2/+2
| | | | | MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D52407
* vdso: Build without debug infoMark Johnston2025-08-222-2/+2
| | | | | | | | | | | | | The debug info is not very useful and embeds build paths because elf-vdso.so.o is built without CFLAGS, breaking reproducibility of elf-vdso.so.o and thus the kernel. Just stop passing debug flags to amd64_vdso.sh. Reviewed by: kib MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52129
* sysent: add a new NORETURN type flagBrooks Davis2025-08-082-2/+7
| | | | | | | | System calls of type NORETURN don't return and their stubs are declare not to. Reviewed by: kevans, kib Differential Revision: https://reviews.freebsd.org/D51673
* syscalls: normalize _exit(2) declerationsBrooks Davis2025-08-083-1/+6
| | | | | | | | | | | | | | | | | | | exit(3) is implemented by the runtime and performs a number of shutdown actions before ultimately calling _exit(2) to terminate the program. We historically named the syscall table entry `exit` rather than `_exit`, but this requires special handling in libc/libsys to cause the `_exit` symbol to exist while implementing `exit` in libc. Declare the syscall as `_exit` and flow that through the system. Because syscall(SYS_exit, code) is fairly widely used, allow a configured extra line in syscall.h to define SYS_exit to SYS__exit. I've found no external uses of __sys_exit() so I've not bothered to create a compatability version of this private symbol. Reviewed by: imp, kib, emaste Differential Revision: https://reviews.freebsd.org/D51672
* arm: Generate the kernel.bin file in zImage format.Michal Meloun2025-08-071-0/+32
| | | | | | | | | This allows you to run the kernel using the bootz command, which can be useful on a board where the manufacturer's u-boot does not support EFI. The original behavior has not been changed, the zImage binary can still be run by jumping to the beginning of the binary file. MFC after: 2 weeks
* vfs: Move DEBUG_VFS_LOCKS checks to INVARIANTSMark Johnston2025-08-031-3/+3
| | | | | | | | | | | | | | | | | | | It is easy to forget to configure DEBUG_VFS_LOCKS, and when one does, no vnode lock assertions are checked when INVARIANTS is configured, so bugs can arise. This has happened to me more than once, and the overhead over DEBUG_VFS_LOCKS does not appear to be high enough to prohibit folding it into INVARIANTS, so let's do that. The change makes vnode lock assertions useful in plain INVARIANTS kernels, and guards VOP debug routines on INVARIANTS rather than DEBUG_VFS_LOCKS. Further, invariants are now checked by plain assertions rather than having various sysctls to finely control what happens the checks fail. The extra complexity didn't seem particularly useful and is at odds with how we handle debugging most everywhere else. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D51402
* vfs: Initial revision of inotifyMark Johnston2025-07-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an implementation of inotify_init(), inotify_add_watch(), inotify_rm_watch(), source-compatible with Linux. This provides functionality similar to kevent(2)'s EVFILT_VNODE, i.e., it lets applications monitor filesystem files for accesses. Compared to inotify, however, EVFILT_VNODE has the limitation of requiring the application to open the file to be monitored. This means that activity on a newly created file cannot be monitored reliably, and that a file descriptor per file in the hierarchy is required. inotify on the other hand allows a directory and its entries to be monitored at once. It introduces a new file descriptor type to which "watches" can be attached; a watch is a pseudo-file descriptor associated with a file or directory and a set of events to watch for. When a watched vnode is accessed, a description of the event is queued to the inotify descriptor, readable with read(2). Events for files in a watched directory include the file name. A watched vnode has its usecount bumped, so name cache entries originating from a watched directory are not evicted. Name cache entries are used to populate inotify events for files with a link in a watched directory. In particular, if a file is accessed with, say, read(2), an IN_ACCESS event will be generated for any watched hard link of the file. The inotify_add_watch_at() variant is included so that this functionality is available in capability mode; plain inotify_add_watch() is disallowed in capability mode. When a file in a nullfs mount is watched, the watch is attached to the lower vnode, such that accesses via either layer generate inotify events. Many thanks to Gleb Popov for testing this patch and finding lots of bugs. PR: 258010, 215011 Reviewed by: kib Tested by: arrowd MFC after: 3 months Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D50315
* vnode_if: Remove some branching around SDT probes in VOP wrappersMark Johnston2025-05-221-7/+3
| | | | | | | | | | Now that SDT is implemented using hot-patching, SDT_PROBE* no longer introduces a branch instruction, so the SDT_PROBES_ENABLED() check in each VOP_*_APV() is not really worth preserving. Reviewed by: olce, kib Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D50423
* makesyscalls: emit cpp in syscalls.mapBrooks Davis2025-02-183-1/+22
| | | | | | | | | | | 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
* makesyscalls: deprecate cpp other than includesBrooks Davis2025-02-181-0/+6
| | | | | | | | | | | 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
* makesyscalls: Restore support for cpp in inputBrooks Davis2025-02-186-5/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* makesyscalls: reduce redundency in syscall.mk codeBrooks Davis2025-02-181-14/+4
| | | | | | | | | 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
* sys: syscalls: add a test syscall definition fileKyle Evans2025-02-188-0/+248
| | | | | | | This exercises some subset of the preprocessor that would be nice to still support. Pull Request: https://github.com/freebsd/freebsd-src/pull/1575
* vnode: Make the vop_vector reference a pointer to constMark Johnston2024-11-261-2/+2
| | | | | | No functional change intended. MFC after: 1 week
* sysent: add a NOLIB modifer to prevent stub generationBrooks Davis2024-11-014-4/+5
| | | | | | | | | | | | | 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
* sysent: sort modifier flagsBrooks Davis2024-11-011-1/+3
| | | | | | | | These flags are a mix of excusive types and modifer flags. Comment the modifer flags and sort them. Reviewed by: emaste Pull Request: https://github.com/freebsd/freebsd-src/pull/1503
* sysent: GC sys/tools/makesyscalls.luaBrooks Davis2024-10-301-1710/+0
| | | | System call entry generation now lives in sys/tools/syscalls/*
* Update mentions of makesyscalls.luaBrooks Davis2024-10-301-1/+1
| | | | It is obsolete and will be removed in a followup commit.
* sys/tools/syscalls: desupport capabilities.confBrooks Davis2024-10-3011-67/+4
| | | | | | | | | We haven't used this since commit be67ea40c5a0 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 cf0ee8738e31).
* Refactor makesyscalls.lua into a libraryagge32024-10-3017-0/+2768
| | | | | | | | | | | | | | | | | | | | * 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>
* makesyscalls.lua: converstion -> conversionBrooks Davis2024-10-221-1/+1
| | | | Reported by: agge3 <sterspark@gmail.com>
* amd64: do not pass -z rodynamic to ld.bfd when building vdsoKonstantin Belousov2024-10-182-3/+13
| | | | | | | | | | | Apparently newer versions of binutils complain instead of silently ignoring the unknown -z option. Reported by: bz Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D47176
* sysent: fix a couple more do-no-edit commentsBrooks Davis2024-10-031-0/+2
| | | | | | | Add blank like after comment to align with upcoming refactor for makesysent.lua. Fixes: 0d490c6a445a sysent: make header comments more consistent
* sysent: make header comments more consistentBrooks Davis2024-10-011-4/+11
| | | | | | 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.
* sysent: Remove comment aligningagge32024-10-011-24/+4
| | | | | | | | 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>
* tools/sdiodevs2h.awk: introduce paliasBjoern A. Zeeb2024-08-311-0/+16
| | | | | | | | | | | | | | 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
* tools/sdiodevs2h.awk: adjust defined named for vendor and device IDsBjoern A. Zeeb2024-08-271-4/+4
| | | | | | | | | | | | 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
* tools/sdiodevs2h.awk: fix after removal of $FreeBSD$Bjoern A. Zeeb2024-08-271-6/+0
| | | | | | | | | | | | 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
* arm_kernel_bothdr.awk: Update to latest otaWarner Losh2024-04-171-4/+10
| | | | | | | | | | | | | 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
* makesyscalls: generate core libsys headerBrooks Davis2024-04-161-0/+91
| | | | | | | | | 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
* sysproto.h: sys/acl.h -> sys/types.hBrooks Davis2024-04-151-1/+1
| | | | | | | | | 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
* libsys: don't try to expose yieldBrooks Davis2024-03-071-0/+4
| | | | | | | | | | The undocumented yield system call has never been implemented via libc or libsys (except accidentally for <15 minutes in 1998 between commits abd529cebab9 and 0db2fac06ab7). 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
* lib{c,sys}: expose _getlogin consistentlyBrooks Davis2024-02-291-1/+1
| | | | | | | | | | 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
* makesyscalls: generate private syscall symbolsBrooks Davis2024-02-051-0/+16
| | | | | | | | | | | | | | | | | 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
* makesyscalls: add COMPAT14 supportBrooks Davis2023-12-011-0/+1
| | | | | | Reviewed by: kevans, imp Fixes: 84d12f887c91f Add a COMPAT_FREEBSD14 kernel option Differential Revision: https://reviews.freebsd.org/D42861
* sys: Remove ancient SCCS tags.Warner Losh2023-11-272-7/+0
| | | | | | | | 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
* makesyscall: Simplify a bit emitting syscall declarationsOlivier Certner2023-11-211-8/+5
| | | | | | | Reviewed by: kevans, imp MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42168
* makesyscalls: don't make syscall.mk by defaultBrooks Davis2023-11-181-1/+1
| | | | | | | | | | | 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
* pccarddevs2h.awk: RemoveWarner Losh2023-08-251-173/+0
| | | | | | | | pccard support was removed in 31b35400cf77on Dec 14, 2021, but this wasn't. Belatedly remove it. MFC After: 1 week Sponsored by: Netflix
* sys: Remove $FreeBSD$: two-line lua tagWarner Losh2023-08-161-2/+0
| | | | Remove /^--\n--\s*\$FreeBSD\$.*$\n/
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-1619-19/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* vnode_if: Don't add $FreeBSD$ to the outputWarner Losh2023-08-161-2/+0
| | | | Sponsored by: Netflix
* fw_stub: Don't add $FreeBSD$ to generated fileWarner Losh2023-08-161-2/+1
| | | | Sponsored by: Netflix
* miidevs2h: Ignore the first lineWarner Losh2023-08-161-7/+0
| | | | | | | The first line hasn't contained version information in years. Ignore it entirely. Sponsored by: Netflix