18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * System call trap handler.
28 */
29 #include <sys/asm_linkage.h>
30 #include <sys/machpcb.h>
31 #include <sys/machthread.h>
32 #include <sys/syscall.h>
33 #include <sys/trap.h>
34 #include <sys/machtrap.h>
35 #include <sys/pcb.h>
36 #include <sys/machparam.h>
37
38 #if !defined(lint) && !defined(__lint)
39 #include "assym.h"
40 #endif
41
42 #ifdef TRAPTRACE
43 #include <sys/traptrace.h>
44 #endif /* TRAPTRACE */
45
46 #if defined(lint) || defined(__lint)
47
48 /*ARGSUSED*/
49 void
50 syscall_trap(struct regs *rp) /* for tags only; not called from C */
51 {}
52
53 #else /* lint */
54
55 #if (1 << SYSENT_SHIFT) != SYSENT_SIZE
56 #error "SYSENT_SHIFT does not correspond to size of sysent structure"
57 #endif
58
59 /*
60 * Native System call trap handler.
61 *
62 * We branch here from sys_trap when a 64-bit system call occurs.
63 *
64 * Entry:
65 * %o0 = regs
66 *
67 * Usage:
68 * %l0 = saved return address
69 * %l1 = saved regs
70 * %l2 = lwp
71 */
72 ENTRY_NP(syscall_trap)
73 ldn [THREAD_REG + T_CPU], %g1 ! get cpu pointer
74 mov %o7, %l0 ! save return addr
273 andn %l3, FP_TRAPPED, %l3
274 st %l3, [%sp + STACK_BIAS + MPCB_FLAGS] ! clear FP_TRAPPED
275 jmp %l0 + 8 ! return to user_rtt
276 clrh [THREAD_REG + T_SYSNUM] ! clear syscall code
277
278 !
279 ! illegal system call - syscall number out of range
280 !
281 _syscall_ill:
282 call nosys
283 nop
284 !
285 ! Post-syscall with special processing needed.
286 !
287 _syscall_post:
288 call post_syscall ! post_syscall(rvals)
289 nop
290 jmp %l0 + 8 ! return to user_rtt
291 nop
292 SET_SIZE(syscall_trap)
293 #endif /* lint */
294
295 #if defined(lint) || defined(__lint)
296
297 void
298 syscall_trap32(void) /* for tags only - trap handler - not called from C */
299 {}
300
301 #else /* lint */
302
303 /*
304 * System call trap handler for ILP32 processes.
305 *
306 * We branch here from sys_trap when a system call occurs.
307 *
308 * Entry:
309 * %o0 = regs
310 *
311 * Usage:
312 * %l0 = saved return address
313 * %l1 = saved regs
314 * %l2 = lwp
315 */
316 ENTRY_NP(syscall_trap32)
317 ldx [THREAD_REG + T_CPU], %g1 ! get cpu pointer
318 mov %o7, %l0 ! save return addr
319
320 !
321 ! If the trapping thread has the address mask bit clear, then it's
322 ! a 64-bit process, and has no business calling 32-bit syscalls.
533 st %l3, [%sp + STACK_BIAS + MPCB_FLAGS] ! clear FP_TRAPPED
534 jmp %l0 + 8 ! return to user_rtt
535 clrh [THREAD_REG + T_SYSNUM] ! clear syscall code
536
537 !
538 ! illegal system call - syscall number out of range
539 !
540 _syscall_ill32:
541 call nosys
542 nop
543 !
544 ! Post-syscall with special processing needed.
545 !
546 _syscall_post32:
547 call post_syscall ! post_syscall(rvals)
548 nop
549 jmp %l0 + 8 ! return to user_rtt
550 nop
551 SET_SIZE(syscall_trap32)
552
553 #endif /* lint */
554
555
556 /*
557 * lwp_rtt - start execution in newly created LWP.
558 * Here with t_post_sys set by lwp_create, and lwp_eosys == JUSTRETURN,
559 * so that post_syscall() will run and the registers will
560 * simply be restored.
561 * This must go out through sys_rtt instead of syscall_rtt.
562 */
563 #if defined(lint) || defined(__lint)
564
565 void
566 lwp_rtt_initial(void)
567 {}
568
569 void
570 lwp_rtt(void)
571 {}
572
573 #else /* lint */
574 ENTRY_NP(lwp_rtt_initial)
575 ldn [THREAD_REG + T_STACK], %l7
576 call __dtrace_probe___proc_start
577 sub %l7, STACK_BIAS, %sp
578 ba,a,pt %xcc, 0f
579
580 ENTRY_NP(lwp_rtt)
581 ldn [THREAD_REG + T_STACK], %l7
582 sub %l7, STACK_BIAS, %sp
583 0:
584 call __dtrace_probe___proc_lwp__start
585 nop
586 call dtrace_systrace_rtt
587 add %sp, REGOFF + STACK_BIAS, %l7
588 ldx [%l7 + O0_OFF], %o0
589 call post_syscall
590 ldx [%l7 + O1_OFF], %o1
591 ba,a,pt %xcc, user_rtt
592 SET_SIZE(lwp_rtt)
593 SET_SIZE(lwp_rtt_initial)
594
595 #endif /* lint */
|
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * System call trap handler.
28 */
29 #include <sys/asm_linkage.h>
30 #include <sys/machpcb.h>
31 #include <sys/machthread.h>
32 #include <sys/syscall.h>
33 #include <sys/trap.h>
34 #include <sys/machtrap.h>
35 #include <sys/pcb.h>
36 #include <sys/machparam.h>
37
38 #include "assym.h"
39
40 #ifdef TRAPTRACE
41 #include <sys/traptrace.h>
42 #endif /* TRAPTRACE */
43
44 #if (1 << SYSENT_SHIFT) != SYSENT_SIZE
45 #error "SYSENT_SHIFT does not correspond to size of sysent structure"
46 #endif
47
48 /*
49 * Native System call trap handler.
50 *
51 * We branch here from sys_trap when a 64-bit system call occurs.
52 *
53 * Entry:
54 * %o0 = regs
55 *
56 * Usage:
57 * %l0 = saved return address
58 * %l1 = saved regs
59 * %l2 = lwp
60 */
61 ENTRY_NP(syscall_trap)
62 ldn [THREAD_REG + T_CPU], %g1 ! get cpu pointer
63 mov %o7, %l0 ! save return addr
262 andn %l3, FP_TRAPPED, %l3
263 st %l3, [%sp + STACK_BIAS + MPCB_FLAGS] ! clear FP_TRAPPED
264 jmp %l0 + 8 ! return to user_rtt
265 clrh [THREAD_REG + T_SYSNUM] ! clear syscall code
266
267 !
268 ! illegal system call - syscall number out of range
269 !
270 _syscall_ill:
271 call nosys
272 nop
273 !
274 ! Post-syscall with special processing needed.
275 !
276 _syscall_post:
277 call post_syscall ! post_syscall(rvals)
278 nop
279 jmp %l0 + 8 ! return to user_rtt
280 nop
281 SET_SIZE(syscall_trap)
282
283 /*
284 * System call trap handler for ILP32 processes.
285 *
286 * We branch here from sys_trap when a system call occurs.
287 *
288 * Entry:
289 * %o0 = regs
290 *
291 * Usage:
292 * %l0 = saved return address
293 * %l1 = saved regs
294 * %l2 = lwp
295 */
296 ENTRY_NP(syscall_trap32)
297 ldx [THREAD_REG + T_CPU], %g1 ! get cpu pointer
298 mov %o7, %l0 ! save return addr
299
300 !
301 ! If the trapping thread has the address mask bit clear, then it's
302 ! a 64-bit process, and has no business calling 32-bit syscalls.
513 st %l3, [%sp + STACK_BIAS + MPCB_FLAGS] ! clear FP_TRAPPED
514 jmp %l0 + 8 ! return to user_rtt
515 clrh [THREAD_REG + T_SYSNUM] ! clear syscall code
516
517 !
518 ! illegal system call - syscall number out of range
519 !
520 _syscall_ill32:
521 call nosys
522 nop
523 !
524 ! Post-syscall with special processing needed.
525 !
526 _syscall_post32:
527 call post_syscall ! post_syscall(rvals)
528 nop
529 jmp %l0 + 8 ! return to user_rtt
530 nop
531 SET_SIZE(syscall_trap32)
532
533
534 /*
535 * lwp_rtt - start execution in newly created LWP.
536 * Here with t_post_sys set by lwp_create, and lwp_eosys == JUSTRETURN,
537 * so that post_syscall() will run and the registers will
538 * simply be restored.
539 * This must go out through sys_rtt instead of syscall_rtt.
540 */
541 ENTRY_NP(lwp_rtt_initial)
542 ldn [THREAD_REG + T_STACK], %l7
543 call __dtrace_probe___proc_start
544 sub %l7, STACK_BIAS, %sp
545 ba,a,pt %xcc, 0f
546
547 ENTRY_NP(lwp_rtt)
548 ldn [THREAD_REG + T_STACK], %l7
549 sub %l7, STACK_BIAS, %sp
550 0:
551 call __dtrace_probe___proc_lwp__start
552 nop
553 call dtrace_systrace_rtt
554 add %sp, REGOFF + STACK_BIAS, %l7
555 ldx [%l7 + O0_OFF], %o0
556 call post_syscall
557 ldx [%l7 + O1_OFF], %o1
558 ba,a,pt %xcc, user_rtt
559 SET_SIZE(lwp_rtt)
560 SET_SIZE(lwp_rtt_initial)
561
|