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