| 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. |
| 4 |
*/ |
| 5 |
sys64_execve: |
| 6 |
set sys_execve, %g1 |
| 7 |
jmpl %g1, %g0 |
| 8 |
flushw |
| 9 |
|
| 10 |
sys64_execveat: |
| 11 |
set sys_execveat, %g1 |
| 12 |
jmpl %g1, %g0 |
| 13 |
flushw |
| 14 |
|
| 15 |
#ifdef CONFIG_COMPAT |
| 16 |
sunos_execv: |
| 17 |
mov %g0, %o2 |
| 18 |
sys32_execve: |
| 19 |
set compat_sys_execve, %g1 |
| 20 |
jmpl %g1, %g0 |
| 21 |
flushw |
| 22 |
|
| 23 |
sys32_execveat: |
| 24 |
set compat_sys_execveat, %g1 |
| 25 |
jmpl %g1, %g0 |
| 26 |
flushw |
| 27 |
#endif |
| 28 |
|
| 29 |
.align 32 |
| 30 |
#ifdef CONFIG_COMPAT |
| 31 |
sys32_sigstack: |
| 32 |
ba,pt %xcc, do_sys32_sigstack |
| 33 |
mov %i6, %o2 |
| 34 |
#endif |
| 35 |
.align 32 |
| 36 |
#ifdef CONFIG_COMPAT |
| 37 |
sys32_sigreturn: |
| 38 |
add %sp, PTREGS_OFF, %o0 |
| 39 |
call do_sigreturn32 |
| 40 |
add %o7, 1f-.-4, %o7 |
| 41 |
nop |
| 42 |
#endif |
| 43 |
sys_rt_sigreturn: |
| 44 |
add %sp, PTREGS_OFF, %o0 |
| 45 |
call do_rt_sigreturn |
| 46 |
add %o7, 1f-.-4, %o7 |
| 47 |
nop |
| 48 |
#ifdef CONFIG_COMPAT |
| 49 |
sys32_rt_sigreturn: |
| 50 |
add %sp, PTREGS_OFF, %o0 |
| 51 |
call do_rt_sigreturn32 |
| 52 |
add %o7, 1f-.-4, %o7 |
| 53 |
nop |
| 54 |
#endif |
| 55 |
.align 32 |
| 56 |
1: ldx [%g6 + TI_FLAGS], %l5 |
| 57 |
andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0 |
| 58 |
be,pt %icc, rtrap |
| 59 |
nop |
| 60 |
call syscall_trace_leave |
| 61 |
add %sp, PTREGS_OFF, %o0 |
| 62 |
ba,pt %xcc, rtrap |
| 63 |
nop |
| 64 |
|
| 65 |
/* This is how fork() was meant to be done, 8 instruction entry. |
| 66 |
* |
| 67 |
* I questioned the following code briefly, let me clear things |
| 68 |
* up so you must not reason on it like I did. |
| 69 |
* |
| 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. |
| 75 |
* |
| 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 |
| 83 |
* XXX to lose). |
| 84 |
* |
| 85 |
* In fact we should take advantage of that fact for other things |
| 86 |
* during system calls... |
| 87 |
*/ |
| 88 |
.align 32 |
| 89 |
sys_vfork: |
| 90 |
flushw |
| 91 |
ba,pt %xcc, sparc_vfork |
| 92 |
add %sp, PTREGS_OFF, %o0 |
| 93 |
|
| 94 |
.align 32 |
| 95 |
sys_fork: |
| 96 |
flushw |
| 97 |
ba,pt %xcc, sparc_fork |
| 98 |
add %sp, PTREGS_OFF, %o0 |
| 99 |
|
| 100 |
.align 32 |
| 101 |
sys_clone: |
| 102 |
flushw |
| 103 |
ba,pt %xcc, sparc_clone |
| 104 |
add %sp, PTREGS_OFF, %o0 |
| 105 |
|
| 106 |
.align 32 |
| 107 |
__sys_clone3: |
| 108 |
flushw |
| 109 |
ba,pt %xcc, sparc_clone3 |
| 110 |
add %sp, PTREGS_OFF, %o0 |
| 111 |
|
| 112 |
.globl ret_from_fork |
| 113 |
ret_from_fork: |
| 114 |
/* Clear current_thread_info()->new_child. */ |
| 115 |
stb %g0, [%g6 + TI_NEW_CHILD] |
| 116 |
call schedule_tail |
| 117 |
mov %g7, %o0 |
| 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 |
| 122 |
brz,pt %l1, ret_sys_call |
| 123 |
nop |
| 124 |
call %l1 |
| 125 |
ldx [%sp + PTREGS_OFF + PT_V9_G2], %o0 |
| 126 |
ba,pt %xcc, ret_sys_call |
| 127 |
mov 0, %o0 |
| 128 |
|
| 129 |
.globl sparc_exit_group |
| 130 |
.type sparc_exit_group,#function |
| 131 |
sparc_exit_group: |
| 132 |
sethi %hi(sys_exit_group), %g7 |
| 133 |
ba,pt %xcc, 1f |
| 134 |
or %g7, %lo(sys_exit_group), %g7 |
| 135 |
.size sparc_exit_group,.-sparc_exit_group |
| 136 |
|
| 137 |
.globl sparc_exit |
| 138 |
.type sparc_exit,#function |
| 139 |
sparc_exit: |
| 140 |
sethi %hi(sys_exit), %g7 |
| 141 |
or %g7, %lo(sys_exit), %g7 |
| 142 |
1: rdpr %pstate, %g2 |
| 143 |
wrpr %g2, PSTATE_IE, %pstate |
| 144 |
rdpr %otherwin, %g1 |
| 145 |
rdpr %cansave, %g3 |
| 146 |
add %g3, %g1, %g3 |
| 147 |
wrpr %g3, 0x0, %cansave |
| 148 |
wrpr %g0, 0x0, %otherwin |
| 149 |
wrpr %g2, 0x0, %pstate |
| 150 |
jmpl %g7, %g0 |
| 151 |
stb %g0, [%g6 + TI_WSAVED] |
| 152 |
.size sparc_exit,.-sparc_exit |
| 153 |
|
| 154 |
linux_sparc_ni_syscall: |
| 155 |
sethi %hi(sys_ni_syscall), %l7 |
| 156 |
ba,pt %xcc, 4f |
| 157 |
or %l7, %lo(sys_ni_syscall), %l7 |
| 158 |
|
| 159 |
linux_syscall_trace32: |
| 160 |
call syscall_trace_enter |
| 161 |
add %sp, PTREGS_OFF, %o0 |
| 162 |
brnz,pn %o0, 3f |
| 163 |
mov -ENOSYS, %o0 |
| 164 |
|
| 165 |
/* Syscall tracing can modify the registers. */ |
| 166 |
ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1 |
| 167 |
sethi %hi(sys_call_table32), %l7 |
| 168 |
ldx [%sp + PTREGS_OFF + PT_V9_I0], %i0 |
| 169 |
or %l7, %lo(sys_call_table32), %l7 |
| 170 |
ldx [%sp + PTREGS_OFF + PT_V9_I1], %i1 |
| 171 |
ldx [%sp + PTREGS_OFF + PT_V9_I2], %i2 |
| 172 |
ldx [%sp + PTREGS_OFF + PT_V9_I3], %i3 |
| 173 |
ldx [%sp + PTREGS_OFF + PT_V9_I4], %i4 |
| 174 |
ldx [%sp + PTREGS_OFF + PT_V9_I5], %i5 |
| 175 |
|
| 176 |
cmp %g1, NR_syscalls |
| 177 |
bgeu,pn %xcc, 3f |
| 178 |
mov -ENOSYS, %o0 |
| 179 |
|
| 180 |
sll %g1, 2, %l4 |
| 181 |
srl %i0, 0, %o0 |
| 182 |
lduw [%l7 + %l4], %l7 |
| 183 |
srl %i4, 0, %o4 |
| 184 |
srl %i1, 0, %o1 |
| 185 |
srl %i2, 0, %o2 |
| 186 |
ba,pt %xcc, 5f |
| 187 |
srl %i3, 0, %o3 |
| 188 |
|
| 189 |
linux_syscall_trace: |
| 190 |
call syscall_trace_enter |
| 191 |
add %sp, PTREGS_OFF, %o0 |
| 192 |
brnz,pn %o0, 3f |
| 193 |
mov -ENOSYS, %o0 |
| 194 |
|
| 195 |
/* Syscall tracing can modify the registers. */ |
| 196 |
ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1 |
| 197 |
sethi %hi(sys_call_table64), %l7 |
| 198 |
ldx [%sp + PTREGS_OFF + PT_V9_I0], %i0 |
| 199 |
or %l7, %lo(sys_call_table64), %l7 |
| 200 |
ldx [%sp + PTREGS_OFF + PT_V9_I1], %i1 |
| 201 |
ldx [%sp + PTREGS_OFF + PT_V9_I2], %i2 |
| 202 |
ldx [%sp + PTREGS_OFF + PT_V9_I3], %i3 |
| 203 |
ldx [%sp + PTREGS_OFF + PT_V9_I4], %i4 |
| 204 |
ldx [%sp + PTREGS_OFF + PT_V9_I5], %i5 |
| 205 |
|
| 206 |
cmp %g1, NR_syscalls |
| 207 |
bgeu,pn %xcc, 3f |
| 208 |
mov -ENOSYS, %o0 |
| 209 |
|
| 210 |
sll %g1, 2, %l4 |
| 211 |
mov %i0, %o0 |
| 212 |
lduw [%l7 + %l4], %l7 |
| 213 |
mov %i1, %o1 |
| 214 |
mov %i2, %o2 |
| 215 |
mov %i3, %o3 |
| 216 |
b,pt %xcc, 2f |
| 217 |
mov %i4, %o4 |
| 218 |
|
| 219 |
|
| 220 |
/* Linux 32-bit system calls enter here... */ |
| 221 |
.align 32 |
| 222 |
.globl linux_sparc_syscall32 |
| 223 |
linux_sparc_syscall32: |
| 224 |
/* Direct access to user regs, much faster. */ |
| 225 |
cmp %g1, NR_syscalls ! IEU1 Group |
| 226 |
bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI |
| 227 |
srl %i0, 0, %o0 ! IEU0 |
| 228 |
sll %g1, 2, %l4 ! IEU0 Group |
| 229 |
srl %i4, 0, %o4 ! IEU1 |
| 230 |
lduw [%l7 + %l4], %l7 ! Load |
| 231 |
srl %i1, 0, %o1 ! IEU0 Group |
| 232 |
ldx [%g6 + TI_FLAGS], %l0 ! Load |
| 233 |
|
| 234 |
srl %i3, 0, %o3 ! IEU0 |
| 235 |
srl %i2, 0, %o2 ! IEU0 Group |
| 236 |
andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0 |
| 237 |
bne,pn %icc, linux_syscall_trace32 ! CTI |
| 238 |
mov %i0, %l5 ! IEU1 |
| 239 |
5: call %l7 ! CTI Group brk forced |
| 240 |
srl %i5, 0, %o5 ! IEU1 |
| 241 |
ba,pt %xcc, 3f |
| 242 |
sra %o0, 0, %o0 |
| 243 |
|
| 244 |
/* Linux native system calls enter here... */ |
| 245 |
.align 32 |
| 246 |
.globl linux_sparc_syscall |
| 247 |
linux_sparc_syscall: |
| 248 |
/* Direct access to user regs, much faster. */ |
| 249 |
cmp %g1, NR_syscalls ! IEU1 Group |
| 250 |
bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI |
| 251 |
mov %i0, %o0 ! IEU0 |
| 252 |
sll %g1, 2, %l4 ! IEU0 Group |
| 253 |
mov %i1, %o1 ! IEU1 |
| 254 |
lduw [%l7 + %l4], %l7 ! Load |
| 255 |
4: mov %i2, %o2 ! IEU0 Group |
| 256 |
ldx [%g6 + TI_FLAGS], %l0 ! Load |
| 257 |
|
| 258 |
mov %i3, %o3 ! IEU1 |
| 259 |
mov %i4, %o4 ! IEU0 Group |
| 260 |
andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0 |
| 261 |
bne,pn %icc, linux_syscall_trace ! CTI Group |
| 262 |
mov %i0, %l5 ! IEU0 |
| 263 |
2: call %l7 ! CTI Group brk forced |
| 264 |
mov %i5, %o5 ! IEU0 |
| 265 |
nop |
| 266 |
|
| 267 |
3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0] |
| 268 |
ret_sys_call: |
| 269 |
ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3 |
| 270 |
mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2 |
| 271 |
sllx %g2, 32, %g2 |
| 272 |
|
| 273 |
cmp %o0, -ERESTART_RESTARTBLOCK |
| 274 |
bgeu,pn %xcc, 1f |
| 275 |
andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0 |
| 276 |
ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc |
| 277 |
|
| 278 |
2: |
| 279 |
/* System call success, clear Carry condition code. */ |
| 280 |
andn %g3, %g2, %g3 |
| 281 |
3: |
| 282 |
stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE] |
| 283 |
bne,pn %icc, linux_syscall_trace2 |
| 284 |
add %l1, 0x4, %l2 ! npc = npc+4 |
| 285 |
stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] |
| 286 |
ba,pt %xcc, rtrap |
| 287 |
stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] |
| 288 |
|
| 289 |
1: |
| 290 |
/* Check if force_successful_syscall_return() |
| 291 |
* was invoked. |
| 292 |
*/ |
| 293 |
ldub [%g6 + TI_SYS_NOERROR], %l2 |
| 294 |
brnz,pn %l2, 2b |
| 295 |
ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc |
| 296 |
/* System call failure, set Carry condition code. |
| 297 |
* Also, get abs(errno) to return to the process. |
| 298 |
*/ |
| 299 |
sub %g0, %o0, %o0 |
| 300 |
stx %o0, [%sp + PTREGS_OFF + PT_V9_I0] |
| 301 |
ba,pt %xcc, 3b |
| 302 |
or %g3, %g2, %g3 |
| 303 |
|
| 304 |
linux_syscall_trace2: |
| 305 |
call syscall_trace_leave |
| 306 |
add %sp, PTREGS_OFF, %o0 |
| 307 |
stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] |
| 308 |
ba,pt %xcc, rtrap |
| 309 |
stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] |