1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* SunOS's execv() call only specifies the argv argument, the
3 * environment settings are the same as the calling processes.
19 set compat_sys_execve, %g1
24 set compat_sys_execveat, %g1
31 ba,pt %xcc, sys_sparc_pipe_real
32 add %sp, PTREGS_OFF, %o0
34 ba,pt %xcc, c_sys_nis_syscall
35 add %sp, PTREGS_OFF, %o0
37 ba,pt %xcc, sparc_memory_ordering
38 add %sp, PTREGS_OFF, %o1
41 ba,pt %xcc, do_sys32_sigstack
47 add %sp, PTREGS_OFF, %o0
53 add %sp, PTREGS_OFF, %o0
59 add %sp, PTREGS_OFF, %o0
60 call do_rt_sigreturn32
65 1: ldx [%g6 + TI_FLAGS], %l5
66 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
69 call syscall_trace_leave
70 add %sp, PTREGS_OFF, %o0
74 /* This is how fork() was meant to be done, 8 instruction entry.
76 * I questioned the following code briefly, let me clear things
77 * up so you must not reason on it like I did.
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.
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
94 * In fact we should take advantage of that fact for other things
95 * during system calls...
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
109 ba,pt %xcc, sparc_do_fork
110 add %sp, PTREGS_OFF, %o2
114 /* Clear current_thread_info()->new_child. */
115 stb %g0, [%g6 + TI_NEW_CHILD]
118 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
119 brnz,pt %o0, ret_sys_call
120 ldx [%g6 + TI_FLAGS], %l0
121 ldx [%sp + PTREGS_OFF + PT_V9_G1], %l1
123 ldx [%sp + PTREGS_OFF + PT_V9_G2], %o0
124 ba,pt %xcc, ret_sys_call
127 .globl sparc_exit_group
128 .type sparc_exit_group,#function
130 sethi %hi(sys_exit_group), %g7
132 or %g7, %lo(sys_exit_group), %g7
133 .size sparc_exit_group,.-sparc_exit_group
136 .type sparc_exit,#function
138 sethi %hi(sys_exit), %g7
139 or %g7, %lo(sys_exit), %g7
141 wrpr %g2, PSTATE_IE, %pstate
145 wrpr %g3, 0x0, %cansave
146 wrpr %g0, 0x0, %otherwin
147 wrpr %g2, 0x0, %pstate
149 stb %g0, [%g6 + TI_WSAVED]
150 .size sparc_exit,.-sparc_exit
152 linux_sparc_ni_syscall:
153 sethi %hi(sys_ni_syscall), %l7
155 or %l7, %lo(sys_ni_syscall), %l7
157 linux_syscall_trace32:
158 call syscall_trace_enter
159 add %sp, PTREGS_OFF, %o0
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
180 lduw [%l7 + %l4], %l7
188 call syscall_trace_enter
189 add %sp, PTREGS_OFF, %o0
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
210 lduw [%l7 + %l4], %l7
218 /* Linux 32-bit system calls enter here... */
220 .globl linux_sparc_syscall32
221 linux_sparc_syscall32:
222 /* Direct access to user regs, much faster. */
223 cmp %g1, NR_syscalls ! IEU1 Group
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
232 srl %i3, 0, %o3 ! IEU0
233 srl %i2, 0, %o2 ! IEU0 Group
234 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
235 bne,pn %icc, linux_syscall_trace32 ! CTI
237 5: call %l7 ! CTI Group brk forced
238 srl %i5, 0, %o5 ! IEU1
242 /* Linux native system calls enter here... */
244 .globl linux_sparc_syscall
246 /* Direct access to user regs, much faster. */
247 cmp %g1, NR_syscalls ! IEU1 Group
248 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
250 sll %g1, 2, %l4 ! IEU0 Group
252 lduw [%l7 + %l4], %l7 ! Load
253 4: mov %i2, %o2 ! IEU0 Group
254 ldx [%g6 + TI_FLAGS], %l0 ! Load
257 mov %i4, %o4 ! IEU0 Group
258 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
259 bne,pn %icc, linux_syscall_trace ! CTI Group
261 2: call %l7 ! CTI Group brk forced
265 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
267 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
268 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
271 cmp %o0, -ERESTART_RESTARTBLOCK
273 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
274 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
277 /* System call success, clear Carry condition code. */
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]
285 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
288 /* Check if force_successful_syscall_return()
291 ldub [%g6 + TI_SYS_NOERROR], %l2
293 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
294 /* System call failure, set Carry condition code.
295 * Also, get abs(errno) to return to the process.
298 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
302 linux_syscall_trace2:
303 call syscall_trace_leave
304 add %sp, PTREGS_OFF, %o0
305 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
307 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]