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
32 ba,pt %xcc, do_sys32_sigstack
38 add %sp, PTREGS_OFF, %o0
44 add %sp, PTREGS_OFF, %o0
50 add %sp, PTREGS_OFF, %o0
51 call do_rt_sigreturn32
56 1: ldx [%g6 + TI_FLAGS], %l5
57 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
60 call syscall_trace_leave
61 add %sp, PTREGS_OFF, %o0
65 /* This is how fork() was meant to be done, 8 instruction entry.
67 * I questioned the following code briefly, let me clear things
68 * up so you must not reason on it like I did.
70 * Know the fork_kpsr etc. we use in the sparc32 port? We don't
71 * need it here because the only piece of window state we copy to
72 * the child is the CWP register. Even if the parent sleeps,
73 * we are safe because we stuck it into pt_regs of the parent
74 * so it will not change.
76 * XXX This raises the question, whether we can do the same on
77 * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
78 * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
79 * XXX fork_kwim in UREG_G1 (global registers are considered
80 * XXX volatile across a system call in the sparc ABI I think
81 * XXX if it isn't we can use regs->y instead, anyone who depends
82 * XXX upon the Y register being preserved across a fork deserves
85 * In fact we should take advantage of that fact for other things
86 * during system calls...
91 ba,pt %xcc, sparc_vfork
92 add %sp, PTREGS_OFF, %o0
97 ba,pt %xcc, sparc_fork
98 add %sp, PTREGS_OFF, %o0
103 ba,pt %xcc, sparc_clone
104 add %sp, PTREGS_OFF, %o0
108 /* Clear current_thread_info()->new_child. */
109 stb %g0, [%g6 + TI_NEW_CHILD]
112 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
113 brnz,pt %o0, ret_sys_call
114 ldx [%g6 + TI_FLAGS], %l0
115 ldx [%sp + PTREGS_OFF + PT_V9_G1], %l1
117 ldx [%sp + PTREGS_OFF + PT_V9_G2], %o0
118 ba,pt %xcc, ret_sys_call
121 .globl sparc_exit_group
122 .type sparc_exit_group,#function
124 sethi %hi(sys_exit_group), %g7
126 or %g7, %lo(sys_exit_group), %g7
127 .size sparc_exit_group,.-sparc_exit_group
130 .type sparc_exit,#function
132 sethi %hi(sys_exit), %g7
133 or %g7, %lo(sys_exit), %g7
135 wrpr %g2, PSTATE_IE, %pstate
139 wrpr %g3, 0x0, %cansave
140 wrpr %g0, 0x0, %otherwin
141 wrpr %g2, 0x0, %pstate
143 stb %g0, [%g6 + TI_WSAVED]
144 .size sparc_exit,.-sparc_exit
146 linux_sparc_ni_syscall:
147 sethi %hi(sys_ni_syscall), %l7
149 or %l7, %lo(sys_ni_syscall), %l7
151 linux_syscall_trace32:
152 call syscall_trace_enter
153 add %sp, PTREGS_OFF, %o0
157 /* Syscall tracing can modify the registers. */
158 ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1
159 sethi %hi(sys_call_table32), %l7
160 ldx [%sp + PTREGS_OFF + PT_V9_I0], %i0
161 or %l7, %lo(sys_call_table32), %l7
162 ldx [%sp + PTREGS_OFF + PT_V9_I1], %i1
163 ldx [%sp + PTREGS_OFF + PT_V9_I2], %i2
164 ldx [%sp + PTREGS_OFF + PT_V9_I3], %i3
165 ldx [%sp + PTREGS_OFF + PT_V9_I4], %i4
166 ldx [%sp + PTREGS_OFF + PT_V9_I5], %i5
174 lduw [%l7 + %l4], %l7
182 call syscall_trace_enter
183 add %sp, PTREGS_OFF, %o0
187 /* Syscall tracing can modify the registers. */
188 ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1
189 sethi %hi(sys_call_table64), %l7
190 ldx [%sp + PTREGS_OFF + PT_V9_I0], %i0
191 or %l7, %lo(sys_call_table64), %l7
192 ldx [%sp + PTREGS_OFF + PT_V9_I1], %i1
193 ldx [%sp + PTREGS_OFF + PT_V9_I2], %i2
194 ldx [%sp + PTREGS_OFF + PT_V9_I3], %i3
195 ldx [%sp + PTREGS_OFF + PT_V9_I4], %i4
196 ldx [%sp + PTREGS_OFF + PT_V9_I5], %i5
204 lduw [%l7 + %l4], %l7
212 /* Linux 32-bit system calls enter here... */
214 .globl linux_sparc_syscall32
215 linux_sparc_syscall32:
216 /* Direct access to user regs, much faster. */
217 cmp %g1, NR_syscalls ! IEU1 Group
218 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
219 srl %i0, 0, %o0 ! IEU0
220 sll %g1, 2, %l4 ! IEU0 Group
221 srl %i4, 0, %o4 ! IEU1
222 lduw [%l7 + %l4], %l7 ! Load
223 srl %i1, 0, %o1 ! IEU0 Group
224 ldx [%g6 + TI_FLAGS], %l0 ! Load
226 srl %i3, 0, %o3 ! IEU0
227 srl %i2, 0, %o2 ! IEU0 Group
228 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
229 bne,pn %icc, linux_syscall_trace32 ! CTI
231 5: call %l7 ! CTI Group brk forced
232 srl %i5, 0, %o5 ! IEU1
236 /* Linux native system calls enter here... */
238 .globl linux_sparc_syscall
240 /* Direct access to user regs, much faster. */
241 cmp %g1, NR_syscalls ! IEU1 Group
242 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
244 sll %g1, 2, %l4 ! IEU0 Group
246 lduw [%l7 + %l4], %l7 ! Load
247 4: mov %i2, %o2 ! IEU0 Group
248 ldx [%g6 + TI_FLAGS], %l0 ! Load
251 mov %i4, %o4 ! IEU0 Group
252 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
253 bne,pn %icc, linux_syscall_trace ! CTI Group
255 2: call %l7 ! CTI Group brk forced
259 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
261 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
262 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
265 cmp %o0, -ERESTART_RESTARTBLOCK
267 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0
268 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
271 /* System call success, clear Carry condition code. */
274 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
275 bne,pn %icc, linux_syscall_trace2
276 add %l1, 0x4, %l2 ! npc = npc+4
277 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
279 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
282 /* Check if force_successful_syscall_return()
285 ldub [%g6 + TI_SYS_NOERROR], %l2
287 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
288 /* System call failure, set Carry condition code.
289 * Also, get abs(errno) to return to the process.
292 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
296 linux_syscall_trace2:
297 call syscall_trace_leave
298 add %sp, PTREGS_OFF, %o0
299 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
301 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]