blob: 2ef41e67f0bef3e4ffce7e5bd7d4f6426ebeb765 [file] [log] [blame]
David S. Miller6eda3a72008-04-28 00:47:20 -07001 /* SunOS's execv() call only specifies the argv argument, the
2 * environment settings are the same as the calling processes.
3 */
Al Viroeb48ffc2012-09-26 19:44:26 -04004sys64_execve:
5 set sys_execve, %g1
6 jmpl %g1, %g0
7 flushw
David S. Miller6eda3a72008-04-28 00:47:20 -07008
9#ifdef CONFIG_COMPAT
10sunos_execv:
Al Viroeb48ffc2012-09-26 19:44:26 -040011 mov %g0, %o2
David S. Miller6eda3a72008-04-28 00:47:20 -070012sys32_execve:
Al Viroeb48ffc2012-09-26 19:44:26 -040013 set compat_sys_execve, %g1
David S. Miller6eda3a72008-04-28 00:47:20 -070014 jmpl %g1, %g0
Al Viroeb48ffc2012-09-26 19:44:26 -040015 flushw
16#endif
David S. Miller6eda3a72008-04-28 00:47:20 -070017
18 .align 32
Heiko Carstens11347232009-01-14 14:13:56 +010019sys_sparc_pipe:
David S. Millere4265012009-01-19 21:11:27 -080020 ba,pt %xcc, sys_sparc_pipe_real
David S. Miller6eda3a72008-04-28 00:47:20 -070021 add %sp, PTREGS_OFF, %o0
22sys_nis_syscall:
23 ba,pt %xcc, c_sys_nis_syscall
24 add %sp, PTREGS_OFF, %o0
25sys_memory_ordering:
26 ba,pt %xcc, sparc_memory_ordering
27 add %sp, PTREGS_OFF, %o1
28sys_sigaltstack:
29 ba,pt %xcc, do_sigaltstack
30 add %i6, STACK_BIAS, %o2
31#ifdef CONFIG_COMPAT
32sys32_sigstack:
33 ba,pt %xcc, do_sys32_sigstack
34 mov %i6, %o2
35sys32_sigaltstack:
36 ba,pt %xcc, do_sys32_sigaltstack
37 mov %i6, %o2
38#endif
39 .align 32
40#ifdef CONFIG_COMPAT
41sys32_sigreturn:
42 add %sp, PTREGS_OFF, %o0
43 call do_sigreturn32
44 add %o7, 1f-.-4, %o7
45 nop
46#endif
47sys_rt_sigreturn:
48 add %sp, PTREGS_OFF, %o0
49 call do_rt_sigreturn
50 add %o7, 1f-.-4, %o7
51 nop
52#ifdef CONFIG_COMPAT
53sys32_rt_sigreturn:
54 add %sp, PTREGS_OFF, %o0
55 call do_rt_sigreturn32
56 add %o7, 1f-.-4, %o7
57 nop
58#endif
59 .align 32
601: ldx [%g6 + TI_FLAGS], %l5
David S. Millerc658ad12009-12-11 00:44:47 -080061 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
David S. Miller6eda3a72008-04-28 00:47:20 -070062 be,pt %icc, rtrap
63 nop
David S. Millerfe06cca2008-08-24 20:10:23 -070064 call syscall_trace_leave
65 add %sp, PTREGS_OFF, %o0
David S. Miller6eda3a72008-04-28 00:47:20 -070066 ba,pt %xcc, rtrap
67 nop
68
69 /* This is how fork() was meant to be done, 8 instruction entry.
70 *
71 * I questioned the following code briefly, let me clear things
72 * up so you must not reason on it like I did.
73 *
74 * Know the fork_kpsr etc. we use in the sparc32 port? We don't
75 * need it here because the only piece of window state we copy to
76 * the child is the CWP register. Even if the parent sleeps,
77 * we are safe because we stuck it into pt_regs of the parent
78 * so it will not change.
79 *
80 * XXX This raises the question, whether we can do the same on
81 * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
82 * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
83 * XXX fork_kwim in UREG_G1 (global registers are considered
84 * XXX volatile across a system call in the sparc ABI I think
85 * XXX if it isn't we can use regs->y instead, anyone who depends
86 * XXX upon the Y register being preserved across a fork deserves
87 * XXX to lose).
88 *
89 * In fact we should take advantage of that fact for other things
90 * during system calls...
91 */
92 .align 32
93sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
94 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
95 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
96 ba,pt %xcc, sys_clone
97sys_fork:
98 clr %o1
99 mov SIGCHLD, %o0
100sys_clone:
101 flushw
102 movrz %o1, %fp, %o1
103 mov 0, %o3
104 ba,pt %xcc, sparc_do_fork
105 add %sp, PTREGS_OFF, %o2
106
107 .globl ret_from_syscall
108ret_from_syscall:
David S. Millerc7d5a002010-03-03 08:08:49 -0800109 /* Clear current_thread_info()->new_child. */
David S. Miller6eda3a72008-04-28 00:47:20 -0700110 stb %g0, [%g6 + TI_NEW_CHILD]
David S. Miller6eda3a72008-04-28 00:47:20 -0700111 call schedule_tail
112 mov %g7, %o0
Al Viro1918c7f2012-10-05 22:37:01 -0400113 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
Al Viro2f12af32012-09-26 19:28:00 -0400114 brnz,pt %o0, ret_sys_call
Al Viro1918c7f2012-10-05 22:37:01 -0400115 ldx [%g6 + TI_FLAGS], %l0
Al Viro2f12af32012-09-26 19:28:00 -0400116 ldx [%sp + PTREGS_OFF + PT_V9_G1], %l1
117 call %l1
Al Viro1918c7f2012-10-05 22:37:01 -0400118 ldx [%sp + PTREGS_OFF + PT_V9_G2], %o0
Al Viro2f12af32012-09-26 19:28:00 -0400119 ba,pt %xcc, ret_sys_call
120 mov 0, %o0
David S. Miller6eda3a72008-04-28 00:47:20 -0700121
122 .globl sparc_exit
123 .type sparc_exit,#function
124sparc_exit:
125 rdpr %pstate, %g2
126 wrpr %g2, PSTATE_IE, %pstate
127 rdpr %otherwin, %g1
128 rdpr %cansave, %g3
129 add %g3, %g1, %g3
130 wrpr %g3, 0x0, %cansave
131 wrpr %g0, 0x0, %otherwin
132 wrpr %g2, 0x0, %pstate
133 ba,pt %xcc, sys_exit
134 stb %g0, [%g6 + TI_WSAVED]
135 .size sparc_exit,.-sparc_exit
136
137linux_sparc_ni_syscall:
138 sethi %hi(sys_ni_syscall), %l7
139 ba,pt %xcc, 4f
140 or %l7, %lo(sys_ni_syscall), %l7
141
142linux_syscall_trace32:
David S. Millerfe06cca2008-08-24 20:10:23 -0700143 call syscall_trace_enter
144 add %sp, PTREGS_OFF, %o0
Roland McGrath73ccefa2008-07-27 00:30:50 -0700145 brnz,pn %o0, 3f
146 mov -ENOSYS, %o0
David S. Miller6eda3a72008-04-28 00:47:20 -0700147 srl %i0, 0, %o0
148 srl %i4, 0, %o4
149 srl %i1, 0, %o1
150 srl %i2, 0, %o2
151 ba,pt %xcc, 2f
152 srl %i3, 0, %o3
153
154linux_syscall_trace:
David S. Millerfe06cca2008-08-24 20:10:23 -0700155 call syscall_trace_enter
156 add %sp, PTREGS_OFF, %o0
Roland McGrath73ccefa2008-07-27 00:30:50 -0700157 brnz,pn %o0, 3f
158 mov -ENOSYS, %o0
David S. Miller6eda3a72008-04-28 00:47:20 -0700159 mov %i0, %o0
160 mov %i1, %o1
161 mov %i2, %o2
162 mov %i3, %o3
163 b,pt %xcc, 2f
164 mov %i4, %o4
165
166
167 /* Linux 32-bit system calls enter here... */
168 .align 32
169 .globl linux_sparc_syscall32
170linux_sparc_syscall32:
171 /* Direct access to user regs, much faster. */
David S. Millerc658ad12009-12-11 00:44:47 -0800172 cmp %g1, NR_syscalls ! IEU1 Group
David S. Miller6eda3a72008-04-28 00:47:20 -0700173 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
174 srl %i0, 0, %o0 ! IEU0
175 sll %g1, 2, %l4 ! IEU0 Group
176 srl %i4, 0, %o4 ! IEU1
177 lduw [%l7 + %l4], %l7 ! Load
178 srl %i1, 0, %o1 ! IEU0 Group
179 ldx [%g6 + TI_FLAGS], %l0 ! Load
180
181 srl %i5, 0, %o5 ! IEU1
182 srl %i2, 0, %o2 ! IEU0 Group
David S. Millerc658ad12009-12-11 00:44:47 -0800183 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
David S. Miller6eda3a72008-04-28 00:47:20 -0700184 bne,pn %icc, linux_syscall_trace32 ! CTI
185 mov %i0, %l5 ! IEU1
186 call %l7 ! CTI Group brk forced
187 srl %i3, 0, %o3 ! IEU0
188 ba,a,pt %xcc, 3f
189
190 /* Linux native system calls enter here... */
191 .align 32
192 .globl linux_sparc_syscall
193linux_sparc_syscall:
194 /* Direct access to user regs, much faster. */
David S. Millerc658ad12009-12-11 00:44:47 -0800195 cmp %g1, NR_syscalls ! IEU1 Group
David S. Miller6eda3a72008-04-28 00:47:20 -0700196 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
197 mov %i0, %o0 ! IEU0
198 sll %g1, 2, %l4 ! IEU0 Group
199 mov %i1, %o1 ! IEU1
200 lduw [%l7 + %l4], %l7 ! Load
2014: mov %i2, %o2 ! IEU0 Group
202 ldx [%g6 + TI_FLAGS], %l0 ! Load
203
204 mov %i3, %o3 ! IEU1
205 mov %i4, %o4 ! IEU0 Group
David S. Millerc658ad12009-12-11 00:44:47 -0800206 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
David S. Miller6eda3a72008-04-28 00:47:20 -0700207 bne,pn %icc, linux_syscall_trace ! CTI Group
208 mov %i0, %l5 ! IEU0
2092: call %l7 ! CTI Group brk forced
210 mov %i5, %o5 ! IEU0
211 nop
212
2133: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
214ret_sys_call:
215 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
David S. Miller6eda3a72008-04-28 00:47:20 -0700216 sra %o0, 0, %o0
217 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
218 sllx %g2, 32, %g2
219
David S. Miller6eda3a72008-04-28 00:47:20 -0700220 cmp %o0, -ERESTART_RESTARTBLOCK
221 bgeu,pn %xcc, 1f
Al Viro55c27702012-10-10 17:25:00 -0700222 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
223 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
224
2252:
David S. Miller6eda3a72008-04-28 00:47:20 -0700226 /* System call success, clear Carry condition code. */
227 andn %g3, %g2, %g3
Al Viro55c27702012-10-10 17:25:00 -07002283:
David S. Miller6eda3a72008-04-28 00:47:20 -0700229 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
230 bne,pn %icc, linux_syscall_trace2
231 add %l1, 0x4, %l2 ! npc = npc+4
232 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
233 ba,pt %xcc, rtrap
234 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
235
2361:
Al Viro55c27702012-10-10 17:25:00 -0700237 /* Check if force_successful_syscall_return()
238 * was invoked.
239 */
240 ldub [%g6 + TI_SYS_NOERROR], %l2
241 brnz,pn %l2, 2b
242 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
David S. Miller6eda3a72008-04-28 00:47:20 -0700243 /* System call failure, set Carry condition code.
244 * Also, get abs(errno) to return to the process.
245 */
David S. Miller6eda3a72008-04-28 00:47:20 -0700246 sub %g0, %o0, %o0
David S. Miller6eda3a72008-04-28 00:47:20 -0700247 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
Al Viro55c27702012-10-10 17:25:00 -0700248 ba,pt %xcc, 3b
249 or %g3, %g2, %g3
David S. Miller6eda3a72008-04-28 00:47:20 -0700250
David S. Miller6eda3a72008-04-28 00:47:20 -0700251linux_syscall_trace2:
David S. Millerfe06cca2008-08-24 20:10:23 -0700252 call syscall_trace_leave
253 add %sp, PTREGS_OFF, %o0
David S. Miller6eda3a72008-04-28 00:47:20 -0700254 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
255 ba,pt %xcc, rtrap
256 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]