aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_syscalls.c
Commit message (Collapse)AuthorAgeFilesLines
* Move syscall_thread_{enter,exit}() into the slow path. This is onlyEdward Tomasz Napierala2020-11-081-2/+8
| | | | | | | | | | | | needed for syscalls from unloadable modules. Reviewed by: kib MFC after: 2 weeks Sponsored by: EPSRC Differential Revision: https://reviews.freebsd.org/D26988 Notes: svn path=/head/; revision=367488
* add a sanity check to the system call registration codeAndriy Gapon2019-12-111-3/+6
| | | | | | | | | | | | A system call number should be at least reserved. We do not expect an attempt to register a fixed number system call when nothing at all is known about it. MFC after: 3 weeks Sponsored by: Panzura Notes: svn path=/head/; revision=355611
* fix a typo resulting in a wrong variable in kern_syscall_deregisterAndriy Gapon2018-08-021-1/+1
| | | | | | | | The difference is between sysent, a global, and sysents, a function parameter. Notes: svn path=/head/; revision=337123
* Avoid calls to syscall_thread_enter/exit for statically defined syscallsMateusz Guzik2018-05-071-6/+2
| | | | | | | | | | | | | | The entire mechanism is rarely used and is quite not performant due to atomci ops on the syscall table. It also has added overhead for completely unrelated syscalls. Reduce it by avoiding the func calls if possible (which consistutes vast majority of cases). Provides about 3% syscall rate speed up for getuid on Broadwell. Notes: svn path=/head/; revision=333339
* Reduce duplication in dynamic syscall registration code.Brooks Davis2018-02-201-20/+47
| | | | | | | | | | | | | | | | | Remove the unused syscall_(de)register() functions in favor of the better documented and easier to use syscall_helper_(un)register(9) functions. The default and freebsd32 versions differed in which array of struct sysents they used and a few missing updates to the 32-bit code as features were added to the main code. Reviewed by: cem Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14337 Notes: svn path=/head/; revision=329647
* sys/kern: adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326271
* Implement lockless resource limits.Mateusz Guzik2015-06-101-0/+1
| | | | | | | | | | | | | Use the same scheme implemented to manage credentials. Code needing to look at process's credentials (as opposed to thred's) is provided with *_proc variants of relevant functions. Places which possibly had to take the proc lock anyway still use the proc pointer to access limits. Notes: svn path=/head/; revision=284215
* Generalised support for copy-on-write structures shared by threads.Mateusz Guzik2015-06-101-0/+2
| | | | | | | | | | | | Thread credentials are maintained as follows: each thread has a pointer to creds and a reference on them. The pointer is compared with proc's creds on userspace<->kernel boundary and updated if needed. This patch introduces a counter which can be compared instead, so that more structures can use this scheme without adding more comparisons on the boundary. Notes: svn path=/head/; revision=284214
* Fix up module unload for syscall_module_handler consumers.Mateusz Guzik2014-11-011-1/+1
| | | | | | | | | | | After r273707 it was registering syscalls as static. This fixes hwpmc module unload. Reported by: markj Notes: svn path=/head/; revision=273953
* Avoid dynamic syscall overhead for statically compiled modules.Mateusz Guzik2014-10-261-9/+17
| | | | | | | | | | | | | | | | The kernel tracks syscall users so that modules can safely unregister them. But if the module is not unloadable or was compiled into the kernel, there is no need to do this. Achieve this by adding SY_THR_STATIC_KLD macro which expands to SY_THR_STATIC during kernel build and 0 otherwise. Reviewed by: kib (previous version) MFC after: 2 weeks Notes: svn path=/head/; revision=273707
* Call chainevh callback when we are invoked with neither MOD_LOAD norXin LI2010-10-211-1/+3
| | | | | | | | | | | | | | MOD_UNLOAD. This makes it possible to add custom hooks for other module events. Return EOPNOTSUPP when there is no callback available. Pointed out by: jhb Reviewed by: jhb MFC after: 1 month Notes: svn path=/head/; revision=214181
* In syscall_module_handler(): all switch branches return, removeXin LI2010-10-211-4/+1
| | | | | | | | | | | | unreached code as pointed out in a Chinese forum [1]. [1] http://www.freebsdchina.org/forum/viewtopic.php?t=50619 Pointed out by: btw616 <btw s qq com> MFC after: 1 month Notes: svn path=/head/; revision=214125
* Count number of threads that enter and leave dynamically registeredKonstantin Belousov2010-06-281-1/+55
| | | | | | | | | | | | | syscalls. On the dynamic syscall deregistration, wait until all threads leave the syscall code. This somewhat increases the safety of the loadable modules unloading. Reviewed by: jhb Tested by: pho MFC after: 1 month Notes: svn path=/head/; revision=209579
* Introduce SYSCALL_INIT_HELPER and SYSCALL32_INIT_HELPER macros andKonstantin Belousov2010-03-191-0/+30
| | | | | | | | | | | | neccessary support functions to allow registering dynamically loaded syscalls from the MOD_LOAD handlers. Helpers handle registration failures semi-automatically. Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=205321
* Various style fixes. 7 space indent is just odd.John Baldwin2008-09-181-74/+74
| | | | Notes: svn path=/head/; revision=183156
* Make system call modules a bit more robust:John Baldwin2006-08-011-1/+11
| | | | | | | | | | | | | | | | | | - If we fail to register the system call during MOD_LOAD, then note that so that we don't try to deregister it or invoke the chained event handler during the subsequent MOD_UNLOAD event. Doing the deregister when the register failed could result in trashing system call entries. - Add a SI_SUB_SYSCALLS just before starting up init and use that to register syscall modules instead of SI_SUB_DRIVERS. Registering system calls as late as possible increases the chances that any other module event handlers or SYSINITs in a module are executed to initialize the data in a kld before a syscall dependent on that data is able to be invoked. MFC after: 3 days Notes: svn path=/head/; revision=160882
* Do a pass over all modules in the kernel and make them return EOPNOTSUPPPoul-Henning Kamp2004-07-151-0/+3
| | | | | | | | | | | for unknown events. A number of modules return EINVAL in this instance, and I have left those alone for now and instead taught MOD_QUIESCE to accept this as "didn't do anything". Notes: svn path=/head/; revision=132199
* Use __FBSDID().David E. O'Brien2003-06-111-2/+3
| | | | Notes: svn path=/head/; revision=116182
* - Lock down the ``module'' structure by adding an SX lock that is used byAndrew R. Reiter2002-03-181-0/+5
| | | | | | | | | | | | all the global bits of ``module'' data. This commit adds a few generic macros, MOD_SLOCK, MOD_XLOCK, etc., that are meant to be used as ways of accessing the SX lock. It is also the first step in helping to lock down the kernel linker and module systems. Reviewed by: jhb, jake, smp@ Notes: svn path=/head/; revision=92547
* KSE Milestone 2Julian Elischer2001-09-121-4/+4
| | | | | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha Notes: svn path=/head/; revision=83366
* sysvipc loadable.Alfred Perlstein2000-12-011-1/+8
| | | | | | | | | new syscall entry lkmressys - "reserved loadable syscall" Make syscall_register allow overwriting of such entries (lkmressys). Notes: svn path=/head/; revision=69449
* Trim unused options (or #ifdef for undoc options).Peter Wemm1999-10-111-5/+0
| | | | | | | Submitted by: phk Notes: svn path=/head/; revision=52128
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Call the chained module handler before unregistering the syscall so thatDoug Rabson1999-06-271-5/+12
| | | | | | | | | | errors can be detected. Submitted by: "A.Yu.Isupov" <isupov@moonhe.jinr.ru> PR: kern/12239 Notes: svn path=/head/; revision=48269
* Move lkmnosys() from kern_lkm.c to here.Peter Wemm1999-01-171-1/+13
| | | | Notes: svn path=/head/; revision=42756
* Implement a mechanism for a module to report a small amount of moduleDoug Rabson1999-01-091-1/+4
| | | | | | | | specific data back to the user via kldstat(2). Use that mechanism in the syscall handler to report the syscall number used. Notes: svn path=/head/; revision=42435
* Implement support for adding syscalls in KLD modules.Doug Rabson1999-01-091-0/+94
Submitted by: Assar Westerlund <assar@sics.se> Notes: svn path=/head/; revision=42433