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