342 /*
343 * Perform pre-system-call processing, including stopping for tracing,
344 * auditing, microstate-accounting, etc.
345 *
346 * This routine is called only if the t_pre_sys flag is set. Any condition
347 * requiring pre-syscall handling must set the t_pre_sys flag. If the
348 * condition is persistent, this routine will repost t_pre_sys.
349 */
350 int
351 pre_syscall(int arg0)
352 {
353 unsigned int code;
354 kthread_t *t = curthread;
355 proc_t *p = ttoproc(t);
356 klwp_t *lwp = ttolwp(t);
357 struct regs *rp = lwptoregs(lwp);
358 int repost;
359
360 t->t_pre_sys = repost = 0; /* clear pre-syscall processing flag */
361
362 ASSERT(t->t_schedflag & TS_DONT_SWAP);
363
364 syscall_mstate(LMS_USER, LMS_SYSTEM);
365
366 /*
367 * The syscall arguments in the out registers should be pointed to
368 * by lwp_ap. If the args need to be copied so that the outs can
369 * be changed without losing the ability to get the args for /proc,
370 * they can be saved by save_syscall_args(), and lwp_ap will be
371 * restored by post_syscall().
372 */
373 ASSERT(lwp->lwp_ap == (long *)&rp->r_o0);
374
375 /*
376 * Make sure the thread is holding the latest credentials for the
377 * process. The credentials in the process right now apply to this
378 * thread for the entire system call.
379 */
380 if (t->t_cred != p->p_cred) {
381 cred_t *oldcred = t->t_cred;
382 /*
383 * DTrace accesses t_cred in probe context. t_cred must
|
342 /*
343 * Perform pre-system-call processing, including stopping for tracing,
344 * auditing, microstate-accounting, etc.
345 *
346 * This routine is called only if the t_pre_sys flag is set. Any condition
347 * requiring pre-syscall handling must set the t_pre_sys flag. If the
348 * condition is persistent, this routine will repost t_pre_sys.
349 */
350 int
351 pre_syscall(int arg0)
352 {
353 unsigned int code;
354 kthread_t *t = curthread;
355 proc_t *p = ttoproc(t);
356 klwp_t *lwp = ttolwp(t);
357 struct regs *rp = lwptoregs(lwp);
358 int repost;
359
360 t->t_pre_sys = repost = 0; /* clear pre-syscall processing flag */
361
362 syscall_mstate(LMS_USER, LMS_SYSTEM);
363
364 /*
365 * The syscall arguments in the out registers should be pointed to
366 * by lwp_ap. If the args need to be copied so that the outs can
367 * be changed without losing the ability to get the args for /proc,
368 * they can be saved by save_syscall_args(), and lwp_ap will be
369 * restored by post_syscall().
370 */
371 ASSERT(lwp->lwp_ap == (long *)&rp->r_o0);
372
373 /*
374 * Make sure the thread is holding the latest credentials for the
375 * process. The credentials in the process right now apply to this
376 * thread for the entire system call.
377 */
378 if (t->t_cred != p->p_cred) {
379 cred_t *oldcred = t->t_cred;
380 /*
381 * DTrace accesses t_cred in probe context. t_cred must
|