132 */
133 static struct sysent sysent_err = {
134 0, SE_32RVAL1, NULL, NULL, (llfcn_t)syscall_err
135 };
136
137 /*
138 * Called from syscall() when a non-trivial 32-bit system call occurs.
139 * Sets up the args and returns a pointer to the handler.
140 */
141 struct sysent *
142 syscall_entry(kthread_t *t, long *argp)
143 {
144 klwp_t *lwp = ttolwp(t);
145 struct regs *rp = lwptoregs(lwp);
146 unsigned int code;
147 struct sysent *callp;
148 struct sysent *se = LWP_GETSYSENT(lwp);
149 int error = 0;
150 uint_t nargs;
151
152 ASSERT(t == curthread && curthread->t_schedflag & TS_DONT_SWAP);
153
154 lwp->lwp_ru.sysc++;
155 lwp->lwp_eosys = NORMALRETURN; /* assume this will be normal */
156
157 /*
158 * Set lwp_ap to point to the args, even if none are needed for this
159 * system call. This is for the loadable-syscall case where the
160 * number of args won't be known until the system call is loaded, and
161 * also maintains a non-NULL lwp_ap setup for get_syscall_args(). Note
162 * that lwp_ap MUST be set to a non-NULL value _BEFORE_ t_sysnum is
163 * set to non-zero; otherwise get_syscall_args(), seeing a non-zero
164 * t_sysnum for this thread, will charge ahead and dereference lwp_ap.
165 */
166 lwp->lwp_ap = argp; /* for get_syscall_args */
167
168 code = rp->r_r0;
169 t->t_sysnum = (short)code;
170 callp = code >= NSYSCALL ? &nosys_ent : se + code;
171
172 if ((t->t_pre_sys | syscalltrace) != 0) {
225 }
226
227 /*
228 * Perform pre-system-call processing, including stopping for tracing,
229 * auditing, etc.
230 *
231 * This routine is called only if the t_pre_sys flag is set. Any condition
232 * requiring pre-syscall handling must set the t_pre_sys flag. If the
233 * condition is persistent, this routine will repost t_pre_sys.
234 */
235 int
236 pre_syscall()
237 {
238 kthread_t *t = curthread;
239 unsigned code = t->t_sysnum;
240 klwp_t *lwp = ttolwp(t);
241 proc_t *p = ttoproc(t);
242 int repost;
243
244 t->t_pre_sys = repost = 0; /* clear pre-syscall processing flag */
245
246 ASSERT(t->t_schedflag & TS_DONT_SWAP);
247
248 #if defined(DEBUG)
249 /*
250 * On the i386 kernel, lwp_ap points at the piece of the thread
251 * stack that we copy the users arguments into.
252 *
253 * On the amd64 kernel, the syscall arguments in the rdi..r9
254 * registers should be pointed at by lwp_ap. If the args need to
255 * be copied so that those registers can be changed without losing
256 * the ability to get the args for /proc, they can be saved by
257 * save_syscall_args(), and lwp_ap will be restored by post_syscall().
258 */
259 if (lwp_getdatamodel(lwp) == DATAMODEL_NATIVE) {
260 #if defined(_LP64)
261 ASSERT(lwp->lwp_ap == (long *)&lwptoregs(lwp)->r_rdi);
262 } else {
263 #endif
264 ASSERT((caddr_t)lwp->lwp_ap > t->t_stkbase &&
265 (caddr_t)lwp->lwp_ap < t->t_stk);
266 }
|
132 */
133 static struct sysent sysent_err = {
134 0, SE_32RVAL1, NULL, NULL, (llfcn_t)syscall_err
135 };
136
137 /*
138 * Called from syscall() when a non-trivial 32-bit system call occurs.
139 * Sets up the args and returns a pointer to the handler.
140 */
141 struct sysent *
142 syscall_entry(kthread_t *t, long *argp)
143 {
144 klwp_t *lwp = ttolwp(t);
145 struct regs *rp = lwptoregs(lwp);
146 unsigned int code;
147 struct sysent *callp;
148 struct sysent *se = LWP_GETSYSENT(lwp);
149 int error = 0;
150 uint_t nargs;
151
152 ASSERT(t == curthread);
153
154 lwp->lwp_ru.sysc++;
155 lwp->lwp_eosys = NORMALRETURN; /* assume this will be normal */
156
157 /*
158 * Set lwp_ap to point to the args, even if none are needed for this
159 * system call. This is for the loadable-syscall case where the
160 * number of args won't be known until the system call is loaded, and
161 * also maintains a non-NULL lwp_ap setup for get_syscall_args(). Note
162 * that lwp_ap MUST be set to a non-NULL value _BEFORE_ t_sysnum is
163 * set to non-zero; otherwise get_syscall_args(), seeing a non-zero
164 * t_sysnum for this thread, will charge ahead and dereference lwp_ap.
165 */
166 lwp->lwp_ap = argp; /* for get_syscall_args */
167
168 code = rp->r_r0;
169 t->t_sysnum = (short)code;
170 callp = code >= NSYSCALL ? &nosys_ent : se + code;
171
172 if ((t->t_pre_sys | syscalltrace) != 0) {
225 }
226
227 /*
228 * Perform pre-system-call processing, including stopping for tracing,
229 * auditing, etc.
230 *
231 * This routine is called only if the t_pre_sys flag is set. Any condition
232 * requiring pre-syscall handling must set the t_pre_sys flag. If the
233 * condition is persistent, this routine will repost t_pre_sys.
234 */
235 int
236 pre_syscall()
237 {
238 kthread_t *t = curthread;
239 unsigned code = t->t_sysnum;
240 klwp_t *lwp = ttolwp(t);
241 proc_t *p = ttoproc(t);
242 int repost;
243
244 t->t_pre_sys = repost = 0; /* clear pre-syscall processing flag */
245
246 #if defined(DEBUG)
247 /*
248 * On the i386 kernel, lwp_ap points at the piece of the thread
249 * stack that we copy the users arguments into.
250 *
251 * On the amd64 kernel, the syscall arguments in the rdi..r9
252 * registers should be pointed at by lwp_ap. If the args need to
253 * be copied so that those registers can be changed without losing
254 * the ability to get the args for /proc, they can be saved by
255 * save_syscall_args(), and lwp_ap will be restored by post_syscall().
256 */
257 if (lwp_getdatamodel(lwp) == DATAMODEL_NATIVE) {
258 #if defined(_LP64)
259 ASSERT(lwp->lwp_ap == (long *)&lwptoregs(lwp)->r_rdi);
260 } else {
261 #endif
262 ASSERT((caddr_t)lwp->lwp_ap > t->t_stkbase &&
263 (caddr_t)lwp->lwp_ap < t->t_stk);
264 }
|