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