6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2012 Milan Jurik. All rights reserved.
25 * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
26 * Copyright (c) 2015, Joyent, Inc.
27 */
28
29 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
30 /* All Rights Reserved */
31
32 #include <sys/param.h>
33 #include <sys/types.h>
34 #include <sys/systm.h>
35 #include <sys/systrace.h>
36 #include <sys/procfs.h>
37 #include <sys/mman.h>
38 #include <sys/int_types.h>
39 #include <c2/audit.h>
40 #include <sys/stat.h>
41 #include <sys/times.h>
42 #include <sys/statfs.h>
43 #include <sys/stropts.h>
44 #include <sys/statvfs.h>
45 #include <sys/utsname.h>
46 #include <sys/timex.h>
47 #include <sys/socket.h>
48 #include <sys/sendfile.h>
49
50 struct hrtsysa;
51 struct mmaplf32a;
52
53 /*
54 * This table is the switch used to transfer to the appropriate
55 * routine for processing a system call. Each row contains the
56 * number of arguments expected, a switch that tells systrap()
57 * in trap.c whether a setjmp() is not necessary, and a pointer
58 * to the routine.
59 */
60
61 int access(char *, int);
62 int alarm(int);
63 int auditsys(struct auditcalls *, rval_t *);
64 int64_t brandsys(int, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t,
65 uintptr_t);
66 int brk(caddr_t);
67 int chdir(char *);
68 int chmod(char *, int);
69 int chown(char *, uid_t, gid_t);
70 int chroot(char *);
71 int cladm(int, int, void *);
72 int close(int);
73 int exece(const char *, const char **, const char **);
74 int faccessat(int, char *, int, int);
75 int fchmodat(int, char *, int, int);
76 int fchownat(int, char *, uid_t, gid_t, int);
77 int fcntl(int, int, intptr_t);
78 int64_t vfork();
79 int64_t forksys(int, int);
80 int fstat(int, struct stat *);
81 int fdsync(int, int);
82 int64_t getgid();
83 int ucredsys(int, int, void *);
84 int64_t getpid();
85 int64_t getuid();
629 /* 165 */ SYSENT_2CI("lwp_sigmask", lwp_sigmask, 5),
630 /* 166 */ IF_x86(
631 SYSENT_CI("lwp_private", syslwp_private, 3),
632 SYSENT_NOSYS()),
633 /* 167 */ SYSENT_CI("lwp_wait", lwp_wait, 2),
634 /* 168 */ SYSENT_CI("lwp_mutex_wakeup", lwp_mutex_wakeup, 2),
635 /* 169 */ SYSENT_LOADABLE(), /* (was lwp_mutex_lock) */
636 /* 170 */ SYSENT_CI("lwp_cond_wait", lwp_cond_wait, 4),
637 /* 171 */ SYSENT_CI("lwp_cond_signal", lwp_cond_signal, 1),
638 /* 172 */ SYSENT_CI("lwp_cond_broadcast", lwp_cond_broadcast, 1),
639 /* 173 */ SYSENT_CL("pread", pread, 4),
640 /* 174 */ SYSENT_CL("pwrite ", pwrite, 4),
641 /*
642 * The 64-bit C library maps llseek() to lseek(), so this
643 * is needed as a native syscall only on the 32-bit kernel.
644 */
645 /* 175 */ IF_LP64(
646 SYSENT_NOSYS(),
647 SYSENT_C("llseek", llseek32, 4)),
648 /* 176 */ SYSENT_LOADABLE(), /* inst_sync */
649 /* 177 */ SYSENT_CI("brandsys", brandsys, 6),
650 /* 178 */ SYSENT_LOADABLE(), /* kaio */
651 /* 179 */ SYSENT_LOADABLE(), /* cpc */
652 /* 180 */ SYSENT_CI("lgrpsys", lgrpsys, 3),
653 /* 181 */ SYSENT_CI("rusagesys", rusagesys, 5),
654 /* 182 */ SYSENT_LOADABLE(), /* portfs */
655 /* 183 */ SYSENT_CI("pollsys", pollsys, 4),
656 /* 184 */ SYSENT_CI("labelsys", labelsys, 5),
657 /* 185 */ SYSENT_CI("acl", acl, 4),
658 /* 186 */ SYSENT_AP("auditsys", auditsys, 6),
659 /* 187 */ SYSENT_CI("processor_bind", processor_bind, 4),
660 /* 188 */ SYSENT_CI("processor_info", processor_info, 2),
661 /* 189 */ SYSENT_CI("p_online", p_online, 2),
662 /* 190 */ SYSENT_CI("sigqueue", sigqueue, 5),
663 /* 191 */ SYSENT_CI("clock_gettime", clock_gettime, 2),
664 /* 192 */ SYSENT_CI("clock_settime", clock_settime, 2),
665 /* 193 */ SYSENT_CI("clock_getres", clock_getres, 2),
666 /* 194 */ SYSENT_CI("timer_create", timer_create, 3),
667 /* 195 */ SYSENT_CI("timer_delete", timer_delete, 1),
668 /* 196 */ SYSENT_CI("timer_settime", timer_settime, 4),
669 /* 197 */ SYSENT_CI("timer_gettime", timer_gettime, 2),
984 /* 159 */ SYSENT_CI("lwp_create", syslwp_create, 3),
985 /* 160 */ SYSENT_CI("lwp_exit", (int (*)())syslwp_exit, 0),
986 /* 161 */ SYSENT_CI("lwp_suspend", syslwp_suspend, 1),
987 /* 162 */ SYSENT_CI("lwp_continue", syslwp_continue, 1),
988 /* 163 */ SYSENT_CI("lwp_kill", lwp_kill, 2),
989 /* 164 */ SYSENT_CI("lwp_self", lwp_self, 0),
990 /* 165 */ SYSENT_2CI("lwp_sigmask", lwp_sigmask, 5),
991 /* 166 */ IF_x86(
992 SYSENT_CI("lwp_private", syslwp_private, 3),
993 SYSENT_NOSYS()),
994 /* 167 */ SYSENT_CI("lwp_wait", lwp_wait, 2),
995 /* 168 */ SYSENT_CI("lwp_mutex_wakeup", lwp_mutex_wakeup, 2),
996 /* 169 */ SYSENT_LOADABLE32(), /* (was lwp_mutex_lock) */
997 /* 170 */ SYSENT_CI("lwp_cond_wait", lwp_cond_wait, 4),
998 /* 171 */ SYSENT_CI("lwp_cond_signal", lwp_cond_signal, 1),
999 /* 172 */ SYSENT_CI("lwp_cond_broadcast", lwp_cond_broadcast, 1),
1000 /* 173 */ SYSENT_CI("pread", pread32, 4),
1001 /* 174 */ SYSENT_CI("pwrite", pwrite32, 4),
1002 /* 175 */ SYSENT_C("llseek", llseek32, 4),
1003 /* 176 */ SYSENT_LOADABLE32(), /* inst_sync */
1004 /* 177 */ SYSENT_CI("brandsys", brandsys, 6),
1005 /* 178 */ SYSENT_LOADABLE32(), /* kaio */
1006 /* 179 */ SYSENT_LOADABLE32(), /* cpc */
1007 /* 180 */ SYSENT_CI("lgrpsys", lgrpsys, 3),
1008 /* 181 */ SYSENT_CI("rusagesys", rusagesys, 5),
1009 /* 182 */ SYSENT_LOADABLE32(), /* portfs */
1010 /* 183 */ SYSENT_CI("pollsys", pollsys, 4),
1011 /* 184 */ SYSENT_CI("labelsys", labelsys, 5),
1012 /* 185 */ SYSENT_CI("acl", acl, 4),
1013 /* 186 */ SYSENT_AP("auditsys", auditsys, 6),
1014 /* 187 */ SYSENT_CI("processor_bind", processor_bind, 4),
1015 /* 188 */ SYSENT_CI("processor_info", processor_info, 2),
1016 /* 189 */ SYSENT_CI("p_online", p_online, 2),
1017 /* 190 */ SYSENT_CI("sigqueue", sigqueue32, 5),
1018 /* 191 */ SYSENT_CI("clock_gettime", clock_gettime, 2),
1019 /* 192 */ SYSENT_CI("clock_settime", clock_settime, 2),
1020 /* 193 */ SYSENT_CI("clock_getres", clock_getres, 2),
1021 /* 194 */ SYSENT_CI("timer_create", timer_create, 3),
1022 /* 195 */ SYSENT_CI("timer_delete", timer_delete, 1),
1023 /* 196 */ SYSENT_CI("timer_settime", timer_settime, 4),
1024 /* 197 */ SYSENT_CI("timer_gettime", timer_gettime, 2),
1076 /* 246 */ SYSENT_CI("setsockopt", setsockopt, 6),
1077 /* 247 */ SYSENT_CI("sockconfig", sockconfig, 5),
1078 /* 248 */ SYSENT_CI("ntp_gettime", ntp_gettime, 1),
1079 /* 249 */ SYSENT_CI("ntp_adjtime", ntp_adjtime, 1),
1080 /* 250 */ SYSENT_CI("lwp_mutex_unlock", lwp_mutex_unlock, 1),
1081 /* 251 */ SYSENT_CI("lwp_mutex_trylock", lwp_mutex_trylock, 2),
1082 /* 252 */ SYSENT_CI("lwp_mutex_register", lwp_mutex_register, 2),
1083 /* 253 */ SYSENT_CI("cladm", cladm, 3),
1084 /* 254 */ SYSENT_CI("uucopy", uucopy, 3),
1085 /* 255 */ SYSENT_CI("umount2", umount2, 2)
1086 };
1087 #endif /* _SYSCALL32_IMPL */
1088
1089 /*
1090 * Space allocated and initialized in init_syscallnames().
1091 */
1092 char **syscallnames;
1093
1094 systrace_sysent_t *systrace_sysent;
1095 void (*systrace_probe)(dtrace_id_t, uintptr_t, uintptr_t,
1096 uintptr_t, uintptr_t, uintptr_t, uintptr_t);
1097
1098 /*ARGSUSED*/
1099 void
1100 systrace_stub(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
1101 uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
1102 {}
1103
1104 /*ARGSUSED*/
1105 int64_t
1106 dtrace_systrace_syscall(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
1107 uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
1108 {
1109 systrace_sysent_t *sy = &systrace_sysent[curthread->t_sysnum];
1110 dtrace_id_t id;
1111 int64_t rval;
1112 proc_t *p;
1113
1114 if ((id = sy->stsy_entry) != DTRACE_IDNONE)
1115 (*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4, arg5);
1116
1117 /*
1118 * We want to explicitly allow DTrace consumers to stop a process
1119 * before it actually executes the meat of the syscall.
1120 */
1121 p = ttoproc(curthread);
1122 mutex_enter(&p->p_lock);
1123 if (curthread->t_dtrace_stop && !curthread->t_lwp->lwp_nostop) {
1124 curthread->t_dtrace_stop = 0;
1125 stop(PR_REQUESTED, 0);
1126 }
1127 mutex_exit(&p->p_lock);
1128
1129 rval = (*sy->stsy_underlying)(arg0, arg1, arg2, arg3, arg4, arg5);
1130
1131 if (ttolwp(curthread)->lwp_errno != 0)
1132 rval = -1;
1133
1134 if ((id = sy->stsy_return) != DTRACE_IDNONE)
1135 (*systrace_probe)(id, (uintptr_t)rval, (uintptr_t)rval,
1136 (uintptr_t)((int64_t)rval >> 32), 0, 0, 0);
1137
1138 return (rval);
1139 }
1140
1141 #ifdef _SYSCALL32_IMPL
1142
1143 systrace_sysent_t *systrace_sysent32;
1144
1145 /*ARGSUSED*/
1146 int64_t
1147 dtrace_systrace_syscall32(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
1148 uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
1149 {
1150 systrace_sysent_t *sy = &systrace_sysent32[curthread->t_sysnum];
1151 dtrace_id_t id;
1152 int64_t rval;
1153 proc_t *p;
1154
1155 if ((id = sy->stsy_entry) != DTRACE_IDNONE)
1156 (*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4, arg5);
1157
1158 /*
1159 * We want to explicitly allow DTrace consumers to stop a process
1160 * before it actually executes the meat of the syscall.
1161 */
1162 p = ttoproc(curthread);
1163 mutex_enter(&p->p_lock);
1164 if (curthread->t_dtrace_stop && !curthread->t_lwp->lwp_nostop) {
1165 curthread->t_dtrace_stop = 0;
1166 stop(PR_REQUESTED, 0);
1167 }
1168 mutex_exit(&p->p_lock);
1169
1170 rval = (*sy->stsy_underlying)(arg0, arg1, arg2, arg3, arg4, arg5);
1171
1172 if (ttolwp(curthread)->lwp_errno != 0)
1173 rval = -1;
1174
1175 if ((id = sy->stsy_return) != DTRACE_IDNONE)
1176 (*systrace_probe)(id, (uintptr_t)rval, (uintptr_t)rval,
1177 (uintptr_t)((uint64_t)rval >> 32), 0, 0, 0);
1178
1179 return (rval);
1180 }
1181
1182 #endif
1183
1184 void
1185 dtrace_systrace_rtt(void)
1186 {
1187 systrace_sysent_t *sy;
1188 dtrace_id_t id;
1189
1190 if (get_udatamodel() == DATAMODEL_NATIVE) {
1191 if (systrace_sysent == NULL)
1192 return;
1193
1194 sy = &systrace_sysent[curthread->t_sysnum];
1195 #ifdef _SYSCALL32_IMPL
1196 } else {
1197 if (systrace_sysent32 == NULL)
1198 return;
1199
1200 sy = &systrace_sysent32[curthread->t_sysnum];
1201 #endif
1202 }
1203
1204 if ((id = sy->stsy_return) != DTRACE_IDNONE)
1205 (*systrace_probe)(id, 0, 0, 0, 0, 0, 0);
1206 }
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2012 Milan Jurik. All rights reserved.
25 * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
26 * Copyright 2016 Joyent, Inc.
27 */
28
29 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
30 /* All Rights Reserved */
31
32 #include <sys/param.h>
33 #include <sys/types.h>
34 #include <sys/systm.h>
35 #include <sys/systrace.h>
36 #include <sys/procfs.h>
37 #include <sys/mman.h>
38 #include <sys/int_types.h>
39 #include <c2/audit.h>
40 #include <sys/stat.h>
41 #include <sys/times.h>
42 #include <sys/statfs.h>
43 #include <sys/stropts.h>
44 #include <sys/statvfs.h>
45 #include <sys/utsname.h>
46 #include <sys/timex.h>
47 #include <sys/socket.h>
48 #include <sys/sendfile.h>
49
50 struct hrtsysa;
51 struct mmaplf32a;
52
53 /*
54 * This table is the switch used to transfer to the appropriate
55 * routine for processing a system call. Each row contains the
56 * number of arguments expected, a switch that tells systrap()
57 * in trap.c whether a setjmp() is not necessary, and a pointer
58 * to the routine.
59 */
60
61 int access(char *, int);
62 int alarm(int);
63 int auditsys(struct auditcalls *, rval_t *);
64 int64_t brandsys(int, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
65 int brk(caddr_t);
66 int chdir(char *);
67 int chmod(char *, int);
68 int chown(char *, uid_t, gid_t);
69 int chroot(char *);
70 int cladm(int, int, void *);
71 int close(int);
72 int exece(const char *, const char **, const char **);
73 int faccessat(int, char *, int, int);
74 int fchmodat(int, char *, int, int);
75 int fchownat(int, char *, uid_t, gid_t, int);
76 int fcntl(int, int, intptr_t);
77 int64_t vfork();
78 int64_t forksys(int, int);
79 int fstat(int, struct stat *);
80 int fdsync(int, int);
81 int64_t getgid();
82 int ucredsys(int, int, void *);
83 int64_t getpid();
84 int64_t getuid();
628 /* 165 */ SYSENT_2CI("lwp_sigmask", lwp_sigmask, 5),
629 /* 166 */ IF_x86(
630 SYSENT_CI("lwp_private", syslwp_private, 3),
631 SYSENT_NOSYS()),
632 /* 167 */ SYSENT_CI("lwp_wait", lwp_wait, 2),
633 /* 168 */ SYSENT_CI("lwp_mutex_wakeup", lwp_mutex_wakeup, 2),
634 /* 169 */ SYSENT_LOADABLE(), /* (was lwp_mutex_lock) */
635 /* 170 */ SYSENT_CI("lwp_cond_wait", lwp_cond_wait, 4),
636 /* 171 */ SYSENT_CI("lwp_cond_signal", lwp_cond_signal, 1),
637 /* 172 */ SYSENT_CI("lwp_cond_broadcast", lwp_cond_broadcast, 1),
638 /* 173 */ SYSENT_CL("pread", pread, 4),
639 /* 174 */ SYSENT_CL("pwrite ", pwrite, 4),
640 /*
641 * The 64-bit C library maps llseek() to lseek(), so this
642 * is needed as a native syscall only on the 32-bit kernel.
643 */
644 /* 175 */ IF_LP64(
645 SYSENT_NOSYS(),
646 SYSENT_C("llseek", llseek32, 4)),
647 /* 176 */ SYSENT_LOADABLE(), /* inst_sync */
648 /* 177 */ SYSENT_CI("brandsys", brandsys, 5),
649 /* 178 */ SYSENT_LOADABLE(), /* kaio */
650 /* 179 */ SYSENT_LOADABLE(), /* cpc */
651 /* 180 */ SYSENT_CI("lgrpsys", lgrpsys, 3),
652 /* 181 */ SYSENT_CI("rusagesys", rusagesys, 5),
653 /* 182 */ SYSENT_LOADABLE(), /* portfs */
654 /* 183 */ SYSENT_CI("pollsys", pollsys, 4),
655 /* 184 */ SYSENT_CI("labelsys", labelsys, 5),
656 /* 185 */ SYSENT_CI("acl", acl, 4),
657 /* 186 */ SYSENT_AP("auditsys", auditsys, 6),
658 /* 187 */ SYSENT_CI("processor_bind", processor_bind, 4),
659 /* 188 */ SYSENT_CI("processor_info", processor_info, 2),
660 /* 189 */ SYSENT_CI("p_online", p_online, 2),
661 /* 190 */ SYSENT_CI("sigqueue", sigqueue, 5),
662 /* 191 */ SYSENT_CI("clock_gettime", clock_gettime, 2),
663 /* 192 */ SYSENT_CI("clock_settime", clock_settime, 2),
664 /* 193 */ SYSENT_CI("clock_getres", clock_getres, 2),
665 /* 194 */ SYSENT_CI("timer_create", timer_create, 3),
666 /* 195 */ SYSENT_CI("timer_delete", timer_delete, 1),
667 /* 196 */ SYSENT_CI("timer_settime", timer_settime, 4),
668 /* 197 */ SYSENT_CI("timer_gettime", timer_gettime, 2),
983 /* 159 */ SYSENT_CI("lwp_create", syslwp_create, 3),
984 /* 160 */ SYSENT_CI("lwp_exit", (int (*)())syslwp_exit, 0),
985 /* 161 */ SYSENT_CI("lwp_suspend", syslwp_suspend, 1),
986 /* 162 */ SYSENT_CI("lwp_continue", syslwp_continue, 1),
987 /* 163 */ SYSENT_CI("lwp_kill", lwp_kill, 2),
988 /* 164 */ SYSENT_CI("lwp_self", lwp_self, 0),
989 /* 165 */ SYSENT_2CI("lwp_sigmask", lwp_sigmask, 5),
990 /* 166 */ IF_x86(
991 SYSENT_CI("lwp_private", syslwp_private, 3),
992 SYSENT_NOSYS()),
993 /* 167 */ SYSENT_CI("lwp_wait", lwp_wait, 2),
994 /* 168 */ SYSENT_CI("lwp_mutex_wakeup", lwp_mutex_wakeup, 2),
995 /* 169 */ SYSENT_LOADABLE32(), /* (was lwp_mutex_lock) */
996 /* 170 */ SYSENT_CI("lwp_cond_wait", lwp_cond_wait, 4),
997 /* 171 */ SYSENT_CI("lwp_cond_signal", lwp_cond_signal, 1),
998 /* 172 */ SYSENT_CI("lwp_cond_broadcast", lwp_cond_broadcast, 1),
999 /* 173 */ SYSENT_CI("pread", pread32, 4),
1000 /* 174 */ SYSENT_CI("pwrite", pwrite32, 4),
1001 /* 175 */ SYSENT_C("llseek", llseek32, 4),
1002 /* 176 */ SYSENT_LOADABLE32(), /* inst_sync */
1003 /* 177 */ SYSENT_CI("brandsys", brandsys, 5),
1004 /* 178 */ SYSENT_LOADABLE32(), /* kaio */
1005 /* 179 */ SYSENT_LOADABLE32(), /* cpc */
1006 /* 180 */ SYSENT_CI("lgrpsys", lgrpsys, 3),
1007 /* 181 */ SYSENT_CI("rusagesys", rusagesys, 5),
1008 /* 182 */ SYSENT_LOADABLE32(), /* portfs */
1009 /* 183 */ SYSENT_CI("pollsys", pollsys, 4),
1010 /* 184 */ SYSENT_CI("labelsys", labelsys, 5),
1011 /* 185 */ SYSENT_CI("acl", acl, 4),
1012 /* 186 */ SYSENT_AP("auditsys", auditsys, 6),
1013 /* 187 */ SYSENT_CI("processor_bind", processor_bind, 4),
1014 /* 188 */ SYSENT_CI("processor_info", processor_info, 2),
1015 /* 189 */ SYSENT_CI("p_online", p_online, 2),
1016 /* 190 */ SYSENT_CI("sigqueue", sigqueue32, 5),
1017 /* 191 */ SYSENT_CI("clock_gettime", clock_gettime, 2),
1018 /* 192 */ SYSENT_CI("clock_settime", clock_settime, 2),
1019 /* 193 */ SYSENT_CI("clock_getres", clock_getres, 2),
1020 /* 194 */ SYSENT_CI("timer_create", timer_create, 3),
1021 /* 195 */ SYSENT_CI("timer_delete", timer_delete, 1),
1022 /* 196 */ SYSENT_CI("timer_settime", timer_settime, 4),
1023 /* 197 */ SYSENT_CI("timer_gettime", timer_gettime, 2),
1075 /* 246 */ SYSENT_CI("setsockopt", setsockopt, 6),
1076 /* 247 */ SYSENT_CI("sockconfig", sockconfig, 5),
1077 /* 248 */ SYSENT_CI("ntp_gettime", ntp_gettime, 1),
1078 /* 249 */ SYSENT_CI("ntp_adjtime", ntp_adjtime, 1),
1079 /* 250 */ SYSENT_CI("lwp_mutex_unlock", lwp_mutex_unlock, 1),
1080 /* 251 */ SYSENT_CI("lwp_mutex_trylock", lwp_mutex_trylock, 2),
1081 /* 252 */ SYSENT_CI("lwp_mutex_register", lwp_mutex_register, 2),
1082 /* 253 */ SYSENT_CI("cladm", cladm, 3),
1083 /* 254 */ SYSENT_CI("uucopy", uucopy, 3),
1084 /* 255 */ SYSENT_CI("umount2", umount2, 2)
1085 };
1086 #endif /* _SYSCALL32_IMPL */
1087
1088 /*
1089 * Space allocated and initialized in init_syscallnames().
1090 */
1091 char **syscallnames;
1092
1093 systrace_sysent_t *systrace_sysent;
1094 void (*systrace_probe)(dtrace_id_t, uintptr_t, uintptr_t,
1095 uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
1096
1097 /*ARGSUSED*/
1098 void
1099 systrace_stub(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
1100 uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5,
1101 uintptr_t arg6, uintptr_t arg7)
1102 {}
1103
1104 /*ARGSUSED*/
1105 int64_t
1106 dtrace_systrace_syscall(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
1107 uintptr_t arg3, uintptr_t arg4, uintptr_t arg5, uintptr_t arg6,
1108 uintptr_t arg7)
1109 {
1110 systrace_sysent_t *sy = &systrace_sysent[curthread->t_sysnum];
1111 dtrace_id_t id;
1112 int64_t rval;
1113 proc_t *p;
1114
1115 if ((id = sy->stsy_entry) != DTRACE_IDNONE)
1116 (*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4, arg5,
1117 arg6, arg7);
1118
1119 /*
1120 * We want to explicitly allow DTrace consumers to stop a process
1121 * before it actually executes the meat of the syscall.
1122 */
1123 p = ttoproc(curthread);
1124 mutex_enter(&p->p_lock);
1125 if (curthread->t_dtrace_stop && !curthread->t_lwp->lwp_nostop) {
1126 curthread->t_dtrace_stop = 0;
1127 stop(PR_REQUESTED, 0);
1128 }
1129 mutex_exit(&p->p_lock);
1130
1131 rval = (*sy->stsy_underlying)(arg0, arg1, arg2, arg3, arg4, arg5,
1132 arg6, arg7);
1133
1134 if (ttolwp(curthread)->lwp_errno != 0)
1135 rval = -1;
1136
1137 if ((id = sy->stsy_return) != DTRACE_IDNONE)
1138 (*systrace_probe)(id, (uintptr_t)rval, (uintptr_t)rval,
1139 (uintptr_t)((int64_t)rval >> 32), 0, 0, 0, 0, 0);
1140
1141 return (rval);
1142 }
1143
1144 #ifdef _SYSCALL32_IMPL
1145
1146 systrace_sysent_t *systrace_sysent32;
1147
1148 /*ARGSUSED*/
1149 int64_t
1150 dtrace_systrace_syscall32(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
1151 uintptr_t arg3, uintptr_t arg4, uintptr_t arg5, uintptr_t arg6,
1152 uintptr_t arg7)
1153 {
1154 systrace_sysent_t *sy = &systrace_sysent32[curthread->t_sysnum];
1155 dtrace_id_t id;
1156 int64_t rval;
1157 proc_t *p;
1158
1159 if ((id = sy->stsy_entry) != DTRACE_IDNONE)
1160 (*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4, arg5, arg6,
1161 arg7);
1162
1163 /*
1164 * We want to explicitly allow DTrace consumers to stop a process
1165 * before it actually executes the meat of the syscall.
1166 */
1167 p = ttoproc(curthread);
1168 mutex_enter(&p->p_lock);
1169 if (curthread->t_dtrace_stop && !curthread->t_lwp->lwp_nostop) {
1170 curthread->t_dtrace_stop = 0;
1171 stop(PR_REQUESTED, 0);
1172 }
1173 mutex_exit(&p->p_lock);
1174
1175 rval = (*sy->stsy_underlying)(arg0, arg1, arg2, arg3, arg4, arg5, arg6,
1176 arg7);
1177
1178 if (ttolwp(curthread)->lwp_errno != 0)
1179 rval = -1;
1180
1181 if ((id = sy->stsy_return) != DTRACE_IDNONE)
1182 (*systrace_probe)(id, (uintptr_t)rval, (uintptr_t)rval,
1183 (uintptr_t)((uint64_t)rval >> 32), 0, 0, 0, 0, 0);
1184
1185 return (rval);
1186 }
1187
1188 #endif
1189
1190 void
1191 dtrace_systrace_rtt(void)
1192 {
1193 systrace_sysent_t *sy;
1194 dtrace_id_t id;
1195
1196 if (get_udatamodel() == DATAMODEL_NATIVE) {
1197 if (systrace_sysent == NULL)
1198 return;
1199
1200 sy = &systrace_sysent[curthread->t_sysnum];
1201 #ifdef _SYSCALL32_IMPL
1202 } else {
1203 if (systrace_sysent32 == NULL)
1204 return;
1205
1206 sy = &systrace_sysent32[curthread->t_sysnum];
1207 #endif
1208 }
1209
1210 if ((id = sy->stsy_return) != DTRACE_IDNONE)
1211 (*systrace_probe)(id, 0, 0, 0, 0, 0, 0, 0, 0);
1212 }
|