Merge branch 'x86-build-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / arch / sparc / kernel / syscalls.S
1 /* SunOS's execv() call only specifies the argv argument, the
2 * environment settings are the same as the calling processes.
3 */
4 sys64_execve:
5 set sys_execve, %g1
6 jmpl %g1, %g0
7 flushw
8
9 #ifdef CONFIG_COMPAT
10 sunos_execv:
11 mov %g0, %o2
12 sys32_execve:
13 set compat_sys_execve, %g1
14 jmpl %g1, %g0
15 flushw
16 #endif
17
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
28 sys_sigaltstack:
29 ba,pt %xcc, do_sigaltstack
30 add %i6, STACK_BIAS, %o2
31 #ifdef CONFIG_COMPAT
32 sys32_sigstack:
33 ba,pt %xcc, do_sys32_sigstack
34 mov %i6, %o2
35 sys32_sigaltstack:
36 ba,pt %xcc, do_sys32_sigaltstack
37 mov %i6, %o2
38 #endif
39 .align 32
40 #ifdef CONFIG_COMPAT
41 sys32_sigreturn:
42 add %sp, PTREGS_OFF, %o0
43 call do_sigreturn32
44 add %o7, 1f-.-4, %o7
45 nop
46 #endif
47 sys_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
53 sys32_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
60 1: ldx [%g6 + TI_FLAGS], %l5
61 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
62 be,pt %icc, rtrap
63 nop
64 call syscall_trace_leave
65 add %sp, PTREGS_OFF, %o0
66 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
93 sys_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
97 sys_fork:
98 clr %o1
99 mov SIGCHLD, %o0
100 sys_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
108 ret_from_syscall:
109 /* Clear current_thread_info()->new_child. */
110 stb %g0, [%g6 + TI_NEW_CHILD]
111 call schedule_tail
112 mov %g7, %o0
113 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
114 brnz,pt %o0, ret_sys_call
115 ldx [%g6 + TI_FLAGS], %l0
116 ldx [%sp + PTREGS_OFF + PT_V9_G1], %l1
117 call %l1
118 ldx [%sp + PTREGS_OFF + PT_V9_G2], %o0
119 ba,pt %xcc, ret_sys_call
120 mov 0, %o0
121
122 .globl sparc_exit_group
123 .type sparc_exit_group,#function
124 sparc_exit_group:
125 sethi %hi(sys_exit_group), %g7
126 ba,pt %xcc, 1f
127 or %g7, %lo(sys_exit_group), %g7
128 .size sparc_exit_group,.-sparc_exit_group
129
130 .globl sparc_exit
131 .type sparc_exit,#function
132 sparc_exit:
133 sethi %hi(sys_exit), %g7
134 or %g7, %lo(sys_exit), %g7
135 1: rdpr %pstate, %g2
136 wrpr %g2, PSTATE_IE, %pstate
137 rdpr %otherwin, %g1
138 rdpr %cansave, %g3
139 add %g3, %g1, %g3
140 wrpr %g3, 0x0, %cansave
141 wrpr %g0, 0x0, %otherwin
142 wrpr %g2, 0x0, %pstate
143 jmpl %g7, %g0
144 stb %g0, [%g6 + TI_WSAVED]
145 .size sparc_exit,.-sparc_exit
146
147 linux_sparc_ni_syscall:
148 sethi %hi(sys_ni_syscall), %l7
149 ba,pt %xcc, 4f
150 or %l7, %lo(sys_ni_syscall), %l7
151
152 linux_syscall_trace32:
153 call syscall_trace_enter
154 add %sp, PTREGS_OFF, %o0
155 brnz,pn %o0, 3f
156 mov -ENOSYS, %o0
157 srl %i0, 0, %o0
158 srl %i4, 0, %o4
159 srl %i1, 0, %o1
160 srl %i2, 0, %o2
161 ba,pt %xcc, 2f
162 srl %i3, 0, %o3
163
164 linux_syscall_trace:
165 call syscall_trace_enter
166 add %sp, PTREGS_OFF, %o0
167 brnz,pn %o0, 3f
168 mov -ENOSYS, %o0
169 mov %i0, %o0
170 mov %i1, %o1
171 mov %i2, %o2
172 mov %i3, %o3
173 b,pt %xcc, 2f
174 mov %i4, %o4
175
176
177 /* Linux 32-bit system calls enter here... */
178 .align 32
179 .globl linux_sparc_syscall32
180 linux_sparc_syscall32:
181 /* Direct access to user regs, much faster. */
182 cmp %g1, NR_syscalls ! IEU1 Group
183 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
184 srl %i0, 0, %o0 ! IEU0
185 sll %g1, 2, %l4 ! IEU0 Group
186 srl %i4, 0, %o4 ! IEU1
187 lduw [%l7 + %l4], %l7 ! Load
188 srl %i1, 0, %o1 ! IEU0 Group
189 ldx [%g6 + TI_FLAGS], %l0 ! Load
190
191 srl %i5, 0, %o5 ! IEU1
192 srl %i2, 0, %o2 ! IEU0 Group
193 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
194 bne,pn %icc, linux_syscall_trace32 ! CTI
195 mov %i0, %l5 ! IEU1
196 call %l7 ! CTI Group brk forced
197 srl %i3, 0, %o3 ! IEU0
198 ba,a,pt %xcc, 3f
199
200 /* Linux native system calls enter here... */
201 .align 32
202 .globl linux_sparc_syscall
203 linux_sparc_syscall:
204 /* Direct access to user regs, much faster. */
205 cmp %g1, NR_syscalls ! IEU1 Group
206 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
207 mov %i0, %o0 ! IEU0
208 sll %g1, 2, %l4 ! IEU0 Group
209 mov %i1, %o1 ! IEU1
210 lduw [%l7 + %l4], %l7 ! Load
211 4: mov %i2, %o2 ! IEU0 Group
212 ldx [%g6 + TI_FLAGS], %l0 ! Load
213
214 mov %i3, %o3 ! IEU1
215 mov %i4, %o4 ! IEU0 Group
216 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
217 bne,pn %icc, linux_syscall_trace ! CTI Group
218 mov %i0, %l5 ! IEU0
219 2: call %l7 ! CTI Group brk forced
220 mov %i5, %o5 ! IEU0
221 nop
222
223 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
224 ret_sys_call:
225 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
226 sra %o0, 0, %o0
227 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
228 sllx %g2, 32, %g2
229
230 cmp %o0, -ERESTART_RESTARTBLOCK
231 bgeu,pn %xcc, 1f
232 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
233 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
234
235 2:
236 /* System call success, clear Carry condition code. */
237 andn %g3, %g2, %g3
238 3:
239 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
240 bne,pn %icc, linux_syscall_trace2
241 add %l1, 0x4, %l2 ! npc = npc+4
242 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
243 ba,pt %xcc, rtrap
244 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
245
246 1:
247 /* Check if force_successful_syscall_return()
248 * was invoked.
249 */
250 ldub [%g6 + TI_SYS_NOERROR], %l2
251 brnz,pn %l2, 2b
252 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
253 /* System call failure, set Carry condition code.
254 * Also, get abs(errno) to return to the process.
255 */
256 sub %g0, %o0, %o0
257 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
258 ba,pt %xcc, 3b
259 or %g3, %g2, %g3
260
261 linux_syscall_trace2:
262 call syscall_trace_leave
263 add %sp, PTREGS_OFF, %o0
264 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
265 ba,pt %xcc, rtrap
266 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
This page took 0.036854 seconds and 6 git commands to generate.