27 #include <sys/cdefs.h>
30 #include <sys/param.h>
31 #include <sys/kernel.h>
33 #include <sys/module.h>
35 #include <sys/syscall.h>
36 #include <sys/sysent.h>
37 #include <sys/sysproto.h>
38 #include <sys/systm.h>
39 #include <machine/atomic.h>
51 return (
nosys(td, args));
58 return (
nosys(td, args));
64 u_int32_t cnt, oldcnt;
67 oldcnt = se->sy_thrcnt;
68 KASSERT((oldcnt & SY_THR_STATIC) == 0,
69 (
"drain on static syscall"));
70 cnt = oldcnt | SY_THR_DRAINING;
71 }
while (atomic_cmpset_acq_32(&se->sy_thrcnt, oldcnt, cnt) == 0);
72 while (atomic_cmpset_32(&se->sy_thrcnt, SY_THR_DRAINING,
80 u_int32_t cnt, oldcnt;
83 oldcnt = se->sy_thrcnt;
84 if ((oldcnt & SY_THR_STATIC) != 0)
86 if ((oldcnt & (SY_THR_DRAINING | SY_THR_ABSENT)) != 0)
88 cnt = oldcnt + SY_THR_INCR;
89 }
while (atomic_cmpset_acq_32(&se->sy_thrcnt, oldcnt, cnt) == 0);
96 u_int32_t cnt, oldcnt;
99 oldcnt = se->sy_thrcnt;
100 if ((oldcnt & SY_THR_STATIC) != 0)
102 cnt = oldcnt - SY_THR_INCR;
103 }
while (atomic_cmpset_rel_32(&se->sy_thrcnt, oldcnt, cnt) == 0);
108 struct sysent *old_sysent)
112 if (*offset == NO_SYSCALL) {
113 for (i = 1; i < SYS_MAXSYSCALL; ++i)
116 if (i == SYS_MAXSYSCALL)
119 }
else if (*offset < 0 || *offset >= SYS_MAXSYSCALL)
125 KASSERT(
sysent[*offset].sy_thrcnt == SY_THR_ABSENT,
126 (
"dynamic syscall is not protected"));
127 *old_sysent =
sysent[*offset];
128 new_sysent->sy_thrcnt = SY_THR_ABSENT;
129 sysent[*offset] = *new_sysent;
130 atomic_store_rel_32(&
sysent[*offset].sy_thrcnt, 0);
140 sysent[*offset] = *old_sysent;
148 struct syscall_module_data *data = arg;
161 ms.intval = *data->offset;
166 error = data->chainevh(mod, what, data->chainarg);
174 if (data->offset == NULL)
176 if (data->chainevh) {
177 error = data->chainevh(mod, what, data->chainarg);
185 return (data->chainevh(mod, what, data->chainarg));
195 struct syscall_helper_data *sd1;
198 for (sd1 = sd; sd1->syscall_no != NO_SYSCALL; sd1++) {
213 struct syscall_helper_data *sd1;
215 for (sd1 = sd; sd1->registered != 0; sd1++) {
int syscall_helper_unregister(struct syscall_helper_data *sd)
int syscall_helper_register(struct syscall_helper_data *sd)
static void syscall_thread_drain(struct sysent *se)
int nosys(struct thread *td, struct nosys_args *args)
int syscall_deregister(int *offset, struct sysent *old_sysent)
void module_setspecific(module_t mod, modspecific_t *datap)
int syscall_thread_enter(struct thread *td, struct sysent *se)
int syscall_register(int *offset, struct sysent *new_sysent, struct sysent *old_sysent)
int pause(const char *wmesg, int timo)
int syscall_module_handler(struct module *mod, int what, void *arg)
int lkmnosys(struct thread *td, struct nosys_args *args)
int lkmressys(struct thread *td, struct nosys_args *args)
void syscall_thread_exit(struct thread *td, struct sysent *se)