4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
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) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #include <sys/param.h>
27 #include <sys/vmparam.h>
28 #include <sys/types.h>
29 #include <sys/sysmacros.h>
30 #include <sys/systm.h>
31 #include <sys/cmn_err.h>
32 #include <sys/signal.h>
33 #include <sys/stack.h>
34 #include <sys/cred.h>
35 #include <sys/user.h>
36 #include <sys/debug.h>
37 #include <sys/errno.h>
38 #include <sys/proc.h>
39 #include <sys/var.h>
40 #include <sys/inline.h>
41 #include <sys/syscall.h>
42 #include <sys/ucontext.h>
43 #include <sys/cpuvar.h>
1009 */
1010 /*ARGSUSED*/
1011 int64_t
1012 loadable_syscall(
1013 long a0, long a1, long a2, long a3,
1014 long a4, long a5, long a6, long a7)
1015 {
1016 int64_t rval;
1017 struct sysent *callp;
1018 struct sysent *se = LWP_GETSYSENT(ttolwp(curthread));
1019 krwlock_t *module_lock;
1020 int code;
1021
1022 code = curthread->t_sysnum;
1023 callp = se + code;
1024
1025 /*
1026 * Try to autoload the system call if necessary.
1027 */
1028 module_lock = lock_syscall(se, code);
1029 THREAD_KPRI_RELEASE(); /* drop priority given by rw_enter */
1030
1031 /*
1032 * we've locked either the loaded syscall or nosys
1033 */
1034 if (callp->sy_flags & SE_ARGC) {
1035 int64_t (*sy_call)();
1036
1037 sy_call = (int64_t (*)())callp->sy_call;
1038 rval = (*sy_call)(a0, a1, a2, a3, a4, a5);
1039 } else {
1040 rval = syscall_ap();
1041 }
1042
1043 THREAD_KPRI_REQUEST(); /* regain priority from read lock */
1044 rw_exit(module_lock);
1045 return (rval);
1046 }
1047
1048 /*
1049 * Handle indirect system calls.
1050 * This interface should be deprecated. The library can handle
1051 * this more efficiently, but keep this implementation for old binaries.
1052 *
1053 * XX64 Needs some work.
1054 */
1055 int64_t
1056 indir(int code, long a0, long a1, long a2, long a3, long a4)
1057 {
1058 klwp_t *lwp = ttolwp(curthread);
1059 struct sysent *callp;
1060
1061 if (code <= 0 || code >= NSYSCALL)
1062 return (nosys());
1063
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
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) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2019 Joyent, Inc.
25 */
26
27 #include <sys/param.h>
28 #include <sys/vmparam.h>
29 #include <sys/types.h>
30 #include <sys/sysmacros.h>
31 #include <sys/systm.h>
32 #include <sys/cmn_err.h>
33 #include <sys/signal.h>
34 #include <sys/stack.h>
35 #include <sys/cred.h>
36 #include <sys/user.h>
37 #include <sys/debug.h>
38 #include <sys/errno.h>
39 #include <sys/proc.h>
40 #include <sys/var.h>
41 #include <sys/inline.h>
42 #include <sys/syscall.h>
43 #include <sys/ucontext.h>
44 #include <sys/cpuvar.h>
1010 */
1011 /*ARGSUSED*/
1012 int64_t
1013 loadable_syscall(
1014 long a0, long a1, long a2, long a3,
1015 long a4, long a5, long a6, long a7)
1016 {
1017 int64_t rval;
1018 struct sysent *callp;
1019 struct sysent *se = LWP_GETSYSENT(ttolwp(curthread));
1020 krwlock_t *module_lock;
1021 int code;
1022
1023 code = curthread->t_sysnum;
1024 callp = se + code;
1025
1026 /*
1027 * Try to autoload the system call if necessary.
1028 */
1029 module_lock = lock_syscall(se, code);
1030
1031 /*
1032 * we've locked either the loaded syscall or nosys
1033 */
1034 if (callp->sy_flags & SE_ARGC) {
1035 int64_t (*sy_call)();
1036
1037 sy_call = (int64_t (*)())callp->sy_call;
1038 rval = (*sy_call)(a0, a1, a2, a3, a4, a5);
1039 } else {
1040 rval = syscall_ap();
1041 }
1042
1043 rw_exit(module_lock);
1044 return (rval);
1045 }
1046
1047 /*
1048 * Handle indirect system calls.
1049 * This interface should be deprecated. The library can handle
1050 * this more efficiently, but keep this implementation for old binaries.
1051 *
1052 * XX64 Needs some work.
1053 */
1054 int64_t
1055 indir(int code, long a0, long a1, long a2, long a3, long a4)
1056 {
1057 klwp_t *lwp = ttolwp(curthread);
1058 struct sysent *callp;
1059
1060 if (code <= 0 || code >= NSYSCALL)
1061 return (nosys());
1062
|