Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
6eda3a75 DM |
2 | /* SunOS's execv() call only specifies the argv argument, the |
3 | * environment settings are the same as the calling processes. | |
4 | */ | |
eb48ffcf AV |
5 | sys64_execve: |
6 | set sys_execve, %g1 | |
7 | jmpl %g1, %g0 | |
8 | flushw | |
6eda3a75 | 9 | |
38351a32 DD |
10 | sys64_execveat: |
11 | set sys_execveat, %g1 | |
12 | jmpl %g1, %g0 | |
13 | flushw | |
14 | ||
6eda3a75 DM |
15 | #ifdef CONFIG_COMPAT |
16 | sunos_execv: | |
eb48ffcf | 17 | mov %g0, %o2 |
6eda3a75 | 18 | sys32_execve: |
eb48ffcf | 19 | set compat_sys_execve, %g1 |
6eda3a75 | 20 | jmpl %g1, %g0 |
eb48ffcf | 21 | flushw |
38351a32 DD |
22 | |
23 | sys32_execveat: | |
24 | set compat_sys_execveat, %g1 | |
25 | jmpl %g1, %g0 | |
26 | flushw | |
eb48ffcf | 27 | #endif |
6eda3a75 DM |
28 | |
29 | .align 32 | |
1134723e | 30 | sys_sparc_pipe: |
e4265019 | 31 | ba,pt %xcc, sys_sparc_pipe_real |
6eda3a75 DM |
32 | add %sp, PTREGS_OFF, %o0 |
33 | sys_nis_syscall: | |
34 | ba,pt %xcc, c_sys_nis_syscall | |
35 | add %sp, PTREGS_OFF, %o0 | |
36 | sys_memory_ordering: | |
37 | ba,pt %xcc, sparc_memory_ordering | |
38 | add %sp, PTREGS_OFF, %o1 | |
6eda3a75 DM |
39 | #ifdef CONFIG_COMPAT |
40 | sys32_sigstack: | |
41 | ba,pt %xcc, do_sys32_sigstack | |
42 | mov %i6, %o2 | |
6eda3a75 DM |
43 | #endif |
44 | .align 32 | |
45 | #ifdef CONFIG_COMPAT | |
46 | sys32_sigreturn: | |
47 | add %sp, PTREGS_OFF, %o0 | |
48 | call do_sigreturn32 | |
49 | add %o7, 1f-.-4, %o7 | |
50 | nop | |
51 | #endif | |
52 | sys_rt_sigreturn: | |
53 | add %sp, PTREGS_OFF, %o0 | |
54 | call do_rt_sigreturn | |
55 | add %o7, 1f-.-4, %o7 | |
56 | nop | |
57 | #ifdef CONFIG_COMPAT | |
58 | sys32_rt_sigreturn: | |
59 | add %sp, PTREGS_OFF, %o0 | |
60 | call do_rt_sigreturn32 | |
61 | add %o7, 1f-.-4, %o7 | |
62 | nop | |
63 | #endif | |
64 | .align 32 | |
65 | 1: ldx [%g6 + TI_FLAGS], %l5 | |
812cb83a | 66 | andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0 |
6eda3a75 DM |
67 | be,pt %icc, rtrap |
68 | nop | |
fe06ccaa DM |
69 | call syscall_trace_leave |
70 | add %sp, PTREGS_OFF, %o0 | |
6eda3a75 DM |
71 | ba,pt %xcc, rtrap |
72 | nop | |
73 | ||
74 | /* This is how fork() was meant to be done, 8 instruction entry. | |
75 | * | |
76 | * I questioned the following code briefly, let me clear things | |
77 | * up so you must not reason on it like I did. | |
78 | * | |
79 | * Know the fork_kpsr etc. we use in the sparc32 port? We don't | |
80 | * need it here because the only piece of window state we copy to | |
81 | * the child is the CWP register. Even if the parent sleeps, | |
82 | * we are safe because we stuck it into pt_regs of the parent | |
83 | * so it will not change. | |
84 | * | |
85 | * XXX This raises the question, whether we can do the same on | |
86 | * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The | |
87 | * XXX answer is yes. We stick fork_kpsr in UREG_G0 and | |
88 | * XXX fork_kwim in UREG_G1 (global registers are considered | |
89 | * XXX volatile across a system call in the sparc ABI I think | |
90 | * XXX if it isn't we can use regs->y instead, anyone who depends | |
91 | * XXX upon the Y register being preserved across a fork deserves | |
92 | * XXX to lose). | |
93 | * | |
94 | * In fact we should take advantage of that fact for other things | |
95 | * during system calls... | |
96 | */ | |
97 | .align 32 | |
98 | sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */ | |
99 | sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0 | |
100 | or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0 | |
101 | ba,pt %xcc, sys_clone | |
102 | sys_fork: | |
103 | clr %o1 | |
104 | mov SIGCHLD, %o0 | |
105 | sys_clone: | |
106 | flushw | |
107 | movrz %o1, %fp, %o1 | |
108 | mov 0, %o3 | |
109 | ba,pt %xcc, sparc_do_fork | |
110 | add %sp, PTREGS_OFF, %o2 | |
111 | ||
37d6fa34 KT |
112 | .globl ret_from_fork |
113 | ret_from_fork: | |
c7d5a005 | 114 | /* Clear current_thread_info()->new_child. */ |
6eda3a75 | 115 | stb %g0, [%g6 + TI_NEW_CHILD] |
6eda3a75 DM |
116 | call schedule_tail |
117 | mov %g7, %o0 | |
1918c7f5 | 118 | ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0 |
2f12af35 | 119 | brnz,pt %o0, ret_sys_call |
1918c7f5 | 120 | ldx [%g6 + TI_FLAGS], %l0 |
2f12af35 AV |
121 | ldx [%sp + PTREGS_OFF + PT_V9_G1], %l1 |
122 | call %l1 | |
1918c7f5 | 123 | ldx [%sp + PTREGS_OFF + PT_V9_G2], %o0 |
c7d5a005 | 124 | ba,pt %xcc, ret_sys_call |
2f12af35 | 125 | mov 0, %o0 |
6eda3a75 | 126 | |
de7531e8 DM |
127 | .globl sparc_exit_group |
128 | .type sparc_exit_group,#function | |
129 | sparc_exit_group: | |
130 | sethi %hi(sys_exit_group), %g7 | |
131 | ba,pt %xcc, 1f | |
132 | or %g7, %lo(sys_exit_group), %g7 | |
133 | .size sparc_exit_group,.-sparc_exit_group | |
134 | ||
6eda3a75 DM |
135 | .globl sparc_exit |
136 | .type sparc_exit,#function | |
137 | sparc_exit: | |
de7531e8 DM |
138 | sethi %hi(sys_exit), %g7 |
139 | or %g7, %lo(sys_exit), %g7 | |
140 | 1: rdpr %pstate, %g2 | |
6eda3a75 DM |
141 | wrpr %g2, PSTATE_IE, %pstate |
142 | rdpr %otherwin, %g1 | |
143 | rdpr %cansave, %g3 | |
144 | add %g3, %g1, %g3 | |
145 | wrpr %g3, 0x0, %cansave | |
146 | wrpr %g0, 0x0, %otherwin | |
147 | wrpr %g2, 0x0, %pstate | |
de7531e8 | 148 | jmpl %g7, %g0 |
6eda3a75 DM |
149 | stb %g0, [%g6 + TI_WSAVED] |
150 | .size sparc_exit,.-sparc_exit | |
151 | ||
152 | linux_sparc_ni_syscall: | |
153 | sethi %hi(sys_ni_syscall), %l7 | |
154 | ba,pt %xcc, 4f | |
155 | or %l7, %lo(sys_ni_syscall), %l7 | |
156 | ||
157 | linux_syscall_trace32: | |
fe06ccaa DM |
158 | call syscall_trace_enter |
159 | add %sp, PTREGS_OFF, %o0 | |
73ccefab RM |
160 | brnz,pn %o0, 3f |
161 | mov -ENOSYS, %o0 | |
1a40b953 MF |
162 | |
163 | /* Syscall tracing can modify the registers. */ | |
164 | ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1 | |
165 | sethi %hi(sys_call_table32), %l7 | |
166 | ldx [%sp + PTREGS_OFF + PT_V9_I0], %i0 | |
167 | or %l7, %lo(sys_call_table32), %l7 | |
168 | ldx [%sp + PTREGS_OFF + PT_V9_I1], %i1 | |
169 | ldx [%sp + PTREGS_OFF + PT_V9_I2], %i2 | |
170 | ldx [%sp + PTREGS_OFF + PT_V9_I3], %i3 | |
171 | ldx [%sp + PTREGS_OFF + PT_V9_I4], %i4 | |
172 | ldx [%sp + PTREGS_OFF + PT_V9_I5], %i5 | |
173 | ||
174 | cmp %g1, NR_syscalls | |
175 | bgeu,pn %xcc, 3f | |
176 | mov -ENOSYS, %o0 | |
177 | ||
178 | sll %g1, 2, %l4 | |
6eda3a75 | 179 | srl %i0, 0, %o0 |
1a40b953 | 180 | lduw [%l7 + %l4], %l7 |
6eda3a75 DM |
181 | srl %i4, 0, %o4 |
182 | srl %i1, 0, %o1 | |
183 | srl %i2, 0, %o2 | |
ab2abda6 | 184 | ba,pt %xcc, 5f |
6eda3a75 DM |
185 | srl %i3, 0, %o3 |
186 | ||
187 | linux_syscall_trace: | |
fe06ccaa DM |
188 | call syscall_trace_enter |
189 | add %sp, PTREGS_OFF, %o0 | |
73ccefab RM |
190 | brnz,pn %o0, 3f |
191 | mov -ENOSYS, %o0 | |
1a40b953 MF |
192 | |
193 | /* Syscall tracing can modify the registers. */ | |
194 | ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1 | |
195 | sethi %hi(sys_call_table64), %l7 | |
196 | ldx [%sp + PTREGS_OFF + PT_V9_I0], %i0 | |
197 | or %l7, %lo(sys_call_table64), %l7 | |
198 | ldx [%sp + PTREGS_OFF + PT_V9_I1], %i1 | |
199 | ldx [%sp + PTREGS_OFF + PT_V9_I2], %i2 | |
200 | ldx [%sp + PTREGS_OFF + PT_V9_I3], %i3 | |
201 | ldx [%sp + PTREGS_OFF + PT_V9_I4], %i4 | |
202 | ldx [%sp + PTREGS_OFF + PT_V9_I5], %i5 | |
203 | ||
204 | cmp %g1, NR_syscalls | |
205 | bgeu,pn %xcc, 3f | |
206 | mov -ENOSYS, %o0 | |
207 | ||
208 | sll %g1, 2, %l4 | |
6eda3a75 | 209 | mov %i0, %o0 |
1a40b953 | 210 | lduw [%l7 + %l4], %l7 |
6eda3a75 DM |
211 | mov %i1, %o1 |
212 | mov %i2, %o2 | |
213 | mov %i3, %o3 | |
214 | b,pt %xcc, 2f | |
215 | mov %i4, %o4 | |
216 | ||
217 | ||
218 | /* Linux 32-bit system calls enter here... */ | |
219 | .align 32 | |
220 | .globl linux_sparc_syscall32 | |
221 | linux_sparc_syscall32: | |
222 | /* Direct access to user regs, much faster. */ | |
c658ad1b | 223 | cmp %g1, NR_syscalls ! IEU1 Group |
6eda3a75 DM |
224 | bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI |
225 | srl %i0, 0, %o0 ! IEU0 | |
226 | sll %g1, 2, %l4 ! IEU0 Group | |
227 | srl %i4, 0, %o4 ! IEU1 | |
228 | lduw [%l7 + %l4], %l7 ! Load | |
229 | srl %i1, 0, %o1 ! IEU0 Group | |
230 | ldx [%g6 + TI_FLAGS], %l0 ! Load | |
231 | ||
ab2abda6 | 232 | srl %i3, 0, %o3 ! IEU0 |
6eda3a75 | 233 | srl %i2, 0, %o2 ! IEU0 Group |
812cb83a | 234 | andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0 |
6eda3a75 DM |
235 | bne,pn %icc, linux_syscall_trace32 ! CTI |
236 | mov %i0, %l5 ! IEU1 | |
ab2abda6 KT |
237 | 5: call %l7 ! CTI Group brk forced |
238 | srl %i5, 0, %o5 ! IEU1 | |
1535bd8a DK |
239 | ba,pt %xcc, 3f |
240 | sra %o0, 0, %o0 | |
6eda3a75 DM |
241 | |
242 | /* Linux native system calls enter here... */ | |
243 | .align 32 | |
244 | .globl linux_sparc_syscall | |
245 | linux_sparc_syscall: | |
246 | /* Direct access to user regs, much faster. */ | |
c658ad1b | 247 | cmp %g1, NR_syscalls ! IEU1 Group |
6eda3a75 DM |
248 | bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI |
249 | mov %i0, %o0 ! IEU0 | |
250 | sll %g1, 2, %l4 ! IEU0 Group | |
251 | mov %i1, %o1 ! IEU1 | |
252 | lduw [%l7 + %l4], %l7 ! Load | |
253 | 4: mov %i2, %o2 ! IEU0 Group | |
254 | ldx [%g6 + TI_FLAGS], %l0 ! Load | |
255 | ||
256 | mov %i3, %o3 ! IEU1 | |
257 | mov %i4, %o4 ! IEU0 Group | |
812cb83a | 258 | andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0 |
6eda3a75 DM |
259 | bne,pn %icc, linux_syscall_trace ! CTI Group |
260 | mov %i0, %l5 ! IEU0 | |
261 | 2: call %l7 ! CTI Group brk forced | |
262 | mov %i5, %o5 ! IEU0 | |
263 | nop | |
264 | ||
265 | 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0] | |
266 | ret_sys_call: | |
267 | ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3 | |
6eda3a75 DM |
268 | mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2 |
269 | sllx %g2, 32, %g2 | |
270 | ||
6eda3a75 DM |
271 | cmp %o0, -ERESTART_RESTARTBLOCK |
272 | bgeu,pn %xcc, 1f | |
812cb83a | 273 | andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0 |
55c2770e AV |
274 | ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc |
275 | ||
276 | 2: | |
6eda3a75 DM |
277 | /* System call success, clear Carry condition code. */ |
278 | andn %g3, %g2, %g3 | |
55c2770e | 279 | 3: |
6eda3a75 DM |
280 | stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE] |
281 | bne,pn %icc, linux_syscall_trace2 | |
282 | add %l1, 0x4, %l2 ! npc = npc+4 | |
283 | stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] | |
284 | ba,pt %xcc, rtrap | |
285 | stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] | |
286 | ||
287 | 1: | |
55c2770e AV |
288 | /* Check if force_successful_syscall_return() |
289 | * was invoked. | |
290 | */ | |
291 | ldub [%g6 + TI_SYS_NOERROR], %l2 | |
292 | brnz,pn %l2, 2b | |
293 | ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc | |
6eda3a75 DM |
294 | /* System call failure, set Carry condition code. |
295 | * Also, get abs(errno) to return to the process. | |
296 | */ | |
6eda3a75 | 297 | sub %g0, %o0, %o0 |
6eda3a75 | 298 | stx %o0, [%sp + PTREGS_OFF + PT_V9_I0] |
55c2770e AV |
299 | ba,pt %xcc, 3b |
300 | or %g3, %g2, %g3 | |
6eda3a75 | 301 | |
6eda3a75 | 302 | linux_syscall_trace2: |
fe06ccaa DM |
303 | call syscall_trace_leave |
304 | add %sp, PTREGS_OFF, %o0 | |
6eda3a75 DM |
305 | stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] |
306 | ba,pt %xcc, rtrap | |
307 | stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] |