| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: aarch32_syscall.c,v 1.4 2021/05/15 11:38:26 rin Exp $ */ | | 1 | /* $NetBSD: aarch32_syscall.c,v 1.5 2021/05/15 11:39:20 rin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2018 Ryo Shimizu <ryo@nerv.org> | | 4 | * Copyright (c) 2018 Ryo Shimizu <ryo@nerv.org> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | | 19 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | | 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | | 24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.4 2021/05/15 11:38:26 rin Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.5 2021/05/15 11:39:20 rin Exp $"); |
31 | | | 31 | |
32 | #include <sys/param.h> | | 32 | #include <sys/param.h> |
33 | #include <sys/ktrace.h> | | 33 | #include <sys/ktrace.h> |
34 | #include <sys/proc.h> | | 34 | #include <sys/proc.h> |
35 | #include <sys/syscallvar.h> | | 35 | #include <sys/syscallvar.h> |
36 | #include <uvm/uvm_extern.h> | | 36 | #include <uvm/uvm_extern.h> |
37 | | | 37 | |
38 | #include <aarch64/armreg.h> | | 38 | #include <aarch64/armreg.h> |
39 | #include <aarch64/frame.h> | | 39 | #include <aarch64/frame.h> |
40 | #include <aarch64/machdep.h> | | 40 | #include <aarch64/machdep.h> |
41 | #include <aarch64/userret.h> | | 41 | #include <aarch64/userret.h> |
42 | | | 42 | |
43 | #ifndef EMULNAME | | 43 | #ifndef EMULNAME |
| @@ -141,27 +141,28 @@ EMULNAME(syscall)(struct trapframe *tf) | | | @@ -141,27 +141,28 @@ EMULNAME(syscall)(struct trapframe *tf) |
141 | /* | | 141 | /* |
142 | * XXX: trace_enter()/trace_exit() called from sy_invoke() expects | | 142 | * XXX: trace_enter()/trace_exit() called from sy_invoke() expects |
143 | * 64bit args, but sy_invoke doesn't take care of it. | | 143 | * 64bit args, but sy_invoke doesn't take care of it. |
144 | * therefore call trace_enter(), sy_call(), trace_exit() manually. | | 144 | * therefore call trace_enter(), sy_call(), trace_exit() manually. |
145 | */ | | 145 | */ |
146 | #ifdef KDTRACE_HOOKS | | 146 | #ifdef KDTRACE_HOOKS |
147 | #define KDTRACE_ENTRY(a) (a) | | 147 | #define KDTRACE_ENTRY(a) (a) |
148 | #else | | 148 | #else |
149 | #define KDTRACE_ENTRY(a) (0) | | 149 | #define KDTRACE_ENTRY(a) (0) |
150 | #endif | | 150 | #endif |
151 | do_trace = p->p_trace_enabled && | | 151 | do_trace = p->p_trace_enabled && |
152 | ((callp->sy_flags & SYCALL_INDIRECT) == 0); | | 152 | ((callp->sy_flags & SYCALL_INDIRECT) == 0); |
153 | if (__predict_false(do_trace || | | 153 | if (__predict_false(do_trace || |
154 | KDTRACE_ENTRY(callp->sy_entry) || KDTRACE_ENTRY(callp->sy_return))) { | | 154 | KDTRACE_ENTRY(callp->sy_entry) || |
| | | 155 | KDTRACE_ENTRY(callp->sy_return))) { |
155 | /* build 64bit args for trace_enter()/trace_exit() */ | | 156 | /* build 64bit args for trace_enter()/trace_exit() */ |
156 | int nargs = callp->sy_narg; | | 157 | int nargs = callp->sy_narg; |
157 | for (i = 0; i < nargs; i++) | | 158 | for (i = 0; i < nargs; i++) |
158 | args64buf.a64[i] = args32buf.a32[i]; | | 159 | args64buf.a64[i] = args32buf.a32[i]; |
159 | } | | 160 | } |
160 | | | 161 | |
161 | if (__predict_false(do_trace || KDTRACE_ENTRY(callp->sy_entry))) | | 162 | if (__predict_false(do_trace || KDTRACE_ENTRY(callp->sy_entry))) |
162 | error = trace_enter(code, callp, args64buf.a64); | | 163 | error = trace_enter(code, callp, args64buf.a64); |
163 | | | 164 | |
164 | if (error == 0) | | 165 | if (error == 0) |
165 | error = sy_call(callp, l, args32buf.a32, rval); | | 166 | error = sy_call(callp, l, args32buf.a32, rval); |
166 | | | 167 | |
167 | if (__predict_false(do_trace || KDTRACE_ENTRY(callp->sy_return))) | | 168 | if (__predict_false(do_trace || KDTRACE_ENTRY(callp->sy_return))) |