1 /* $NetBSD: kern_stub.c,v 1.20 2009/10/06 21:07:06 elad Exp $ */
4 * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
30 * Copyright (c) 1982, 1986, 1991, 1993
31 * The Regents of the University of California. All rights reserved.
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
36 * 1. Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer in the
40 * documentation and/or other materials provided with the distribution.
41 * 3. Neither the name of the University nor the names of its contributors
42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission.
45 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * @(#)subr_xxx.c 8.3 (Berkeley) 3/29/95
61 * Stubs for system calls and facilities not included in the system.
64 #include <sys/cdefs.h>
65 __KERNEL_RCSID(0, "$NetBSD: kern_stub.c,v 1.20 2009/10/06 21:07:06 elad Exp $");
67 #include "opt_ptrace.h"
68 #include "opt_ktrace.h"
69 #include "opt_modular.h"
75 /* XXX To get syscall prototypes. */
80 #include <sys/param.h>
81 #include <sys/kernel.h>
83 #include <sys/fstypes.h>
84 #include <sys/signalvar.h>
85 #include <sys/syscall.h>
86 #include <sys/syscallargs.h>
87 #include <sys/syscallvar.h>
88 #include <sys/ktrace.h>
91 #include <sys/module.h>
94 * Nonexistent system call-- signal process (may want to handle it). Flag
95 * error in case process won't see signal immediately (blocked or ignored).
98 __weak_alias(sys_ptrace
,sys_nosys
);
102 * ktrace stubs. ktruser() goes to enosys as we want to fail the syscall,
103 * but not kill the process: utrace() is a debugging feature.
106 __weak_alias(ktr_csw
,nullop
); /* Probes */
107 __weak_alias(ktr_emul
,nullop
);
108 __weak_alias(ktr_geniov
,nullop
);
109 __weak_alias(ktr_genio
,nullop
);
110 __weak_alias(ktr_mibio
,nullop
);
111 __weak_alias(ktr_namei
,nullop
);
112 __weak_alias(ktr_namei2
,nullop
);
113 __weak_alias(ktr_psig
,nullop
);
114 __weak_alias(ktr_saupcall
,nullop
);
115 __weak_alias(ktr_syscall
,nullop
);
116 __weak_alias(ktr_sysret
,nullop
);
117 __weak_alias(ktr_kuser
,nullop
);
118 __weak_alias(ktr_mmsg
,nullop
);
119 __weak_alias(ktr_mib
,nullop
);
120 __weak_alias(ktr_mool
,nullop
);
121 __weak_alias(ktr_execarg
,nullop
);
122 __weak_alias(ktr_execenv
,nullop
);
124 __weak_alias(sys_fktrace
,sys_nosys
); /* Syscalls */
125 __weak_alias(sys_ktrace
,sys_nosys
);
126 __weak_alias(sys_utrace
,sys_nosys
);
128 int ktrace_on
; /* Misc */
129 __weak_alias(ktruser
,enosys
);
130 __weak_alias(ktr_point
,nullop
);
133 __weak_alias(spldebug_start
, voidop
);
134 __weak_alias(spldebug_stop
, voidop
);
135 __weak_alias(machdep_init
,nullop
);
137 #if !defined(KERN_SA)
139 * Scheduler activations system calls. These need to remain, even when
140 * KERN_SA isn't defined, until libc's major version is bumped.
142 __strong_alias(sys_sa_register
,sys_nosys
);
143 __strong_alias(sys_sa_stacks
,sys_nosys
);
144 __strong_alias(sys_sa_enable
,sys_nosys
);
145 __strong_alias(sys_sa_setconcurrency
,sys_nosys
);
146 __strong_alias(sys_sa_yield
,sys_nosys
);
147 __strong_alias(sys_sa_preempt
,sys_nosys
);
148 __strong_alias(sys_sa_unblockyield
,sys_nosys
);
151 * Stubs for compat_netbsd32.
153 __strong_alias(dosa_register
,sys_nosys
);
154 __strong_alias(sa_stacks1
,sys_nosys
);
158 * Stubs for architectures that do not support kernel preemption.
160 #ifndef __HAVE_PREEMPTION
162 cpu_kpreempt_enter(uintptr_t where
, int s
)
169 cpu_kpreempt_exit(uintptr_t where
)
175 cpu_kpreempt_disabled(void)
181 # ifndef MULTIPROCESSOR
182 # error __HAVE_PREEMPTION requires MULTIPROCESSOR
184 #endif /* !__HAVE_PREEMPTION */
187 sys_nosys(struct lwp
*l
, const void *v
, register_t
*retval
)
190 mutex_enter(proc_lock
);
191 psignal(l
->l_proc
, SIGSYS
);
192 mutex_exit(proc_lock
);
197 sys_nomodule(struct lwp
*l
, const void *v
, register_t
*retval
)
202 const char *al_module
;
203 } const autoload
[] = {
204 { SYS_aio_cancel
, "aio" },
205 { SYS_aio_error
, "aio" },
206 { SYS_aio_fsync
, "aio" },
207 { SYS_aio_read
, "aio" },
208 { SYS_aio_return
, "aio" },
209 { SYS___aio_suspend50
, "aio" },
210 { SYS_aio_write
, "aio" },
211 { SYS_lio_listio
, "aio" },
212 { SYS_mq_open
, "mqueue" },
213 { SYS_mq_close
, "mqueue" },
214 { SYS_mq_unlink
, "mqueue" },
215 { SYS_mq_getattr
, "mqueue" },
216 { SYS_mq_setattr
, "mqueue" },
217 { SYS_mq_notify
, "mqueue" },
218 { SYS_mq_send
, "mqueue" },
219 { SYS_mq_receive
, "mqueue" },
220 { SYS___mq_timedsend50
, "mqueue" },
221 { SYS___mq_timedreceive50
, "mqueue" },
222 { SYS_compat_43_fstat43
, "compat" },
223 { SYS_compat_43_lstat43
, "compat" },
224 { SYS_compat_43_oaccept
, "compat" },
225 { SYS_compat_43_ocreat
, "compat" },
226 { SYS_compat_43_oftruncate
, "compat" },
227 { SYS_compat_43_ogetdirentries
, "compat" },
228 { SYS_compat_43_ogetdtablesize
, "compat" },
229 { SYS_compat_43_ogethostid
, "compat" },
230 { SYS_compat_43_ogethostname
, "compat" },
231 { SYS_compat_43_ogetkerninfo
, "compat" },
232 { SYS_compat_43_ogetpagesize
, "compat" },
233 { SYS_compat_43_ogetpeername
, "compat" },
234 { SYS_compat_43_ogetrlimit
, "compat" },
235 { SYS_compat_43_ogetsockname
, "compat" },
236 { SYS_compat_43_okillpg
, "compat" },
237 { SYS_compat_43_olseek
, "compat" },
238 { SYS_compat_43_ommap
, "compat" },
239 { SYS_compat_43_oquota
, "compat" },
240 { SYS_compat_43_orecv
, "compat" },
241 { SYS_compat_43_orecvfrom
, "compat" },
242 { SYS_compat_43_orecvmsg
, "compat" },
243 { SYS_compat_43_osend
, "compat" },
244 { SYS_compat_43_osendmsg
, "compat" },
245 { SYS_compat_43_osethostid
, "compat" },
246 { SYS_compat_43_osethostname
, "compat" },
247 { SYS_compat_43_osetrlimit
, "compat" },
248 { SYS_compat_43_osigblock
, "compat" },
249 { SYS_compat_43_osigsetmask
, "compat" },
250 { SYS_compat_43_osigstack
, "compat" },
251 { SYS_compat_43_osigvec
, "compat" },
252 { SYS_compat_43_otruncate
, "compat" },
253 { SYS_compat_43_owait
, "compat" },
254 { SYS_compat_43_stat43
, "compat" },
255 { SYS_compat_09_ogetdomainname
, "compat" },
256 { SYS_compat_09_osetdomainname
, "compat" },
257 { SYS_compat_09_ouname
, "compat" },
259 { SYS_compat_10_omsgsys
, "compat" },
260 { SYS_compat_10_osemsys
, "compat" },
261 { SYS_compat_10_oshmsys
, "compat" },
263 { SYS_compat_12_fstat12
, "compat" },
264 { SYS_compat_12_getdirentries
, "compat" },
265 { SYS_compat_12_lstat12
, "compat" },
266 { SYS_compat_12_msync
, "compat" },
267 { SYS_compat_12_oreboot
, "compat" },
268 { SYS_compat_12_oswapon
, "compat" },
269 { SYS_compat_12_stat12
, "compat" },
270 { SYS_compat_13_sigaction13
, "compat" },
271 { SYS_compat_13_sigaltstack13
, "compat" },
272 { SYS_compat_13_sigpending13
, "compat" },
273 { SYS_compat_13_sigprocmask13
, "compat" },
274 { SYS_compat_13_sigreturn13
, "compat" },
275 { SYS_compat_13_sigsuspend13
, "compat" },
276 { SYS_compat_14___semctl
, "compat" },
277 { SYS_compat_14_msgctl
, "compat" },
278 { SYS_compat_14_shmctl
, "compat" },
279 { SYS_compat_16___sigaction14
, "compat" },
280 { SYS_compat_16___sigreturn14
, "compat" },
281 { SYS_compat_20_fhstatfs
, "compat" },
282 { SYS_compat_20_fstatfs
, "compat" },
283 { SYS_compat_20_getfsstat
, "compat" },
284 { SYS_compat_20_statfs
, "compat" },
285 { SYS_compat_30___fhstat30
, "compat" },
286 { SYS_compat_30___fstat13
, "compat" },
287 { SYS_compat_30___lstat13
, "compat" },
288 { SYS_compat_30___stat13
, "compat" },
289 { SYS_compat_30_fhopen
, "compat" },
290 { SYS_compat_30_fhstat
, "compat" },
291 { SYS_compat_30_fhstatvfs1
, "compat" },
292 { SYS_compat_30_getdents
, "compat" },
293 { SYS_compat_30_getfh
, "compat" },
294 { SYS_compat_30_socket
, "compat" },
295 { SYS_compat_40_mount
, "compat" },
296 { SYS_compat_50_wait4
, "compat" },
297 { SYS_compat_50_mknod
, "compat" },
298 { SYS_compat_50_setitimer
, "compat" },
299 { SYS_compat_50_getitimer
, "compat" },
300 { SYS_compat_50_select
, "compat" },
301 { SYS_compat_50_gettimeofday
, "compat" },
302 { SYS_compat_50_getrusage
, "compat" },
303 { SYS_compat_50_settimeofday
, "compat" },
304 { SYS_compat_50_utimes
, "compat" },
305 { SYS_compat_50_adjtime
, "compat" },
307 { SYS_compat_50_lfs_segwait
, "compat" },
309 { SYS_compat_50_futimes
, "compat" },
310 { SYS_compat_50_clock_gettime
, "compat" },
311 { SYS_compat_50_clock_settime
, "compat" },
312 { SYS_compat_50_clock_getres
, "compat" },
313 { SYS_compat_50_timer_settime
, "compat" },
314 { SYS_compat_50_timer_gettime
, "compat" },
315 { SYS_compat_50_nanosleep
, "compat" },
316 { SYS_compat_50___sigtimedwait
, "compat" },
317 { SYS_compat_50_mq_timedsend
, "compat" },
318 { SYS_compat_50_mq_timedreceive
, "compat" },
319 { SYS_compat_50_lutimes
, "compat" },
320 { SYS_compat_50_____semctl13
, "compat" },
321 { SYS_compat_50___msgctl13
, "compat" },
322 { SYS_compat_50___shmctl13
, "compat" },
323 { SYS_compat_50__lwp_park
, "compat" },
324 { SYS_compat_50_kevent
, "compat" },
325 { SYS_compat_50_pselect
, "compat" },
326 { SYS_compat_50_pollts
, "compat" },
327 { SYS_compat_50___stat30
, "compat" },
328 { SYS_compat_50___fstat30
, "compat" },
329 { SYS_compat_50___lstat30
, "compat" },
330 { SYS_compat_50___ntp_gettime30
, "compat" },
331 { SYS_compat_50___fhstat40
, "compat" },
332 { SYS_compat_50_aio_suspend
, "compat" },
333 { SYS__ksem_init
, "ksem" },
334 { SYS__ksem_open
, "ksem" },
335 { SYS__ksem_unlink
, "ksem" },
336 { SYS__ksem_close
, "ksem" },
337 { SYS__ksem_post
, "ksem" },
338 { SYS__ksem_wait
, "ksem" },
339 { SYS__ksem_trywait
, "ksem" },
340 { SYS__ksem_getvalue
, "ksem" },
341 { SYS__ksem_destroy
, "ksem" },
342 { SYS_nfssvc
, "nfsserver" },
344 const struct sysent
*sy
;
345 const struct emul
*em
;
349 * Restart the syscall if we interrupted a module unload that
350 * failed. Acquiring module_lock delays us until any unload
351 * has been completed or rolled back.
353 mutex_enter(&module_lock
);
355 if (sy
->sy_call
!= sys_nomodule
) {
356 mutex_exit(&module_lock
);
360 * Try to autoload a module to satisfy the request. If it
361 * works, retry the request.
363 em
= l
->l_proc
->p_emul
;
364 if (em
== &emul_netbsd
) {
365 code
= sy
- em
->e_sysent
;
366 for (i
= 0; i
< __arraycount(autoload
); i
++) {
367 if (autoload
[i
].al_code
!= code
) {
370 if (module_autoload(autoload
[i
].al_module
,
371 MODULE_CLASS_ANY
) != 0 ||
372 sy
->sy_call
== sys_nomodule
) {
375 mutex_exit(&module_lock
);
379 mutex_exit(&module_lock
);
382 return sys_nosys(l
, v
, retval
);
386 * Unsupported device function (e.g. writing to read-only device).
396 * Unconfigured device function; driver not configured.
406 * Unsupported ioctl function.
416 * Unsupported system function.
417 * This is used for an otherwise-reasonable operation
418 * that is not supported by the current system binary.
428 * Return error for operation not supported
429 * on a specific object or file type.
439 * Generic null operation, void return value.
447 * Generic null operation, always returns success.