xref: /openbmc/linux/arch/sparc/kernel/sys32.S (revision 4800cd83)
1/*
2 * sys32.S: I-cache tricks for 32-bit compatibility layer simple
3 *          conversions.
4 *
5 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1998 Jakub Jelinek   (jj@ultra.linux.cz)
7 */
8
9#include <asm/errno.h>
10
11/* NOTE: call as jump breaks return stack, we have to avoid that */
12
13	.text
14
15#define SIGN1(STUB,SYSCALL,REG1) \
16	.align	32; \
17	.globl	STUB; \
18STUB:	sethi	%hi(SYSCALL), %g1; \
19	jmpl	%g1 + %lo(SYSCALL), %g0; \
20	sra	REG1, 0, REG1
21
22#define SIGN2(STUB,SYSCALL,REG1,REG2) \
23	.align	32; \
24	.globl	STUB; \
25STUB:	sethi	%hi(SYSCALL), %g1; \
26	sra	REG1, 0, REG1; \
27	jmpl	%g1 + %lo(SYSCALL), %g0; \
28	sra	REG2, 0, REG2
29
30#define SIGN3(STUB,SYSCALL,REG1,REG2,REG3) \
31	.align	32; \
32	.globl	STUB; \
33STUB:	sra	REG1, 0, REG1; \
34	sethi	%hi(SYSCALL), %g1; \
35	sra	REG2, 0, REG2; \
36	jmpl	%g1 + %lo(SYSCALL), %g0; \
37	sra	REG3, 0, REG3
38
39#define SIGN4(STUB,SYSCALL,REG1,REG2,REG3,REG4) \
40	.align	32; \
41	.globl	STUB; \
42STUB:	sra	REG1, 0, REG1; \
43	sethi	%hi(SYSCALL), %g1; \
44	sra	REG2, 0, REG2; \
45	sra	REG3, 0, REG3; \
46	jmpl	%g1 + %lo(SYSCALL), %g0; \
47	sra	REG4, 0, REG4
48
49SIGN1(sys32_exit, sparc_exit, %o0)
50SIGN1(sys32_exit_group, sys_exit_group, %o0)
51SIGN1(sys32_wait4, compat_sys_wait4, %o2)
52SIGN1(sys32_creat, sys_creat, %o1)
53SIGN1(sys32_mknod, sys_mknod, %o1)
54SIGN1(sys32_umount, sys_umount, %o1)
55SIGN1(sys32_signal, sys_signal, %o0)
56SIGN1(sys32_access, sys_access, %o1)
57SIGN1(sys32_msync, sys_msync, %o2)
58SIGN2(sys32_reboot, sys_reboot, %o0, %o1)
59SIGN1(sys32_setitimer, compat_sys_setitimer, %o0)
60SIGN1(sys32_getitimer, compat_sys_getitimer, %o0)
61SIGN1(sys32_sethostname, sys_sethostname, %o1)
62SIGN1(sys32_swapon, sys_swapon, %o1)
63SIGN1(sys32_sigaction, compat_sys_sigaction, %o0)
64SIGN1(sys32_rt_sigaction, compat_sys_rt_sigaction, %o0)
65SIGN1(sys32_sigprocmask, compat_sys_sigprocmask, %o0)
66SIGN1(sys32_rt_sigprocmask, compat_sys_rt_sigprocmask, %o0)
67SIGN2(sys32_rt_sigqueueinfo, compat_sys_rt_sigqueueinfo, %o0, %o1)
68SIGN1(sys32_getrusage, compat_sys_getrusage, %o0)
69SIGN1(sys32_setxattr, sys_setxattr, %o4)
70SIGN1(sys32_lsetxattr, sys_lsetxattr, %o4)
71SIGN1(sys32_fsetxattr, sys_fsetxattr, %o4)
72SIGN1(sys32_fgetxattr, sys_fgetxattr, %o0)
73SIGN1(sys32_flistxattr, sys_flistxattr, %o0)
74SIGN1(sys32_fremovexattr, sys_fremovexattr, %o0)
75SIGN2(sys32_tkill, sys_tkill, %o0, %o1)
76SIGN1(sys32_epoll_create, sys_epoll_create, %o0)
77SIGN3(sys32_epoll_ctl, sys_epoll_ctl, %o0, %o1, %o2)
78SIGN3(sys32_epoll_wait, sys_epoll_wait, %o0, %o2, %o3)
79SIGN1(sys32_readahead, compat_sys_readahead, %o0)
80SIGN2(sys32_fadvise64, compat_sys_fadvise64, %o0, %o4)
81SIGN2(sys32_fadvise64_64, compat_sys_fadvise64_64, %o0, %o5)
82SIGN2(sys32_bdflush, sys_bdflush, %o0, %o1)
83SIGN1(sys32_mlockall, sys_mlockall, %o0)
84SIGN1(sys32_nfsservctl, compat_sys_nfsservctl, %o0)
85SIGN1(sys32_clock_nanosleep, compat_sys_clock_nanosleep, %o1)
86SIGN1(sys32_timer_settime, compat_sys_timer_settime, %o1)
87SIGN1(sys32_io_submit, compat_sys_io_submit, %o1)
88SIGN1(sys32_mq_open, compat_sys_mq_open, %o1)
89SIGN1(sys32_select, compat_sys_select, %o0)
90SIGN1(sys32_mkdir, sys_mkdir, %o1)
91SIGN3(sys32_futex, compat_sys_futex, %o1, %o2, %o5)
92SIGN1(sys32_sysfs, compat_sys_sysfs, %o0)
93SIGN2(sys32_sendfile, compat_sys_sendfile, %o0, %o1)
94SIGN2(sys32_sendfile64, compat_sys_sendfile64, %o0, %o1)
95SIGN1(sys32_prctl, sys_prctl, %o0)
96SIGN1(sys32_sched_rr_get_interval, compat_sys_sched_rr_get_interval, %o0)
97SIGN2(sys32_waitpid, sys_waitpid, %o0, %o2)
98SIGN1(sys32_getgroups, sys_getgroups, %o0)
99SIGN1(sys32_getpgid, sys_getpgid, %o0)
100SIGN2(sys32_getpriority, sys_getpriority, %o0, %o1)
101SIGN1(sys32_getsid, sys_getsid, %o0)
102SIGN2(sys32_kill, sys_kill, %o0, %o1)
103SIGN1(sys32_nice, sys_nice, %o0)
104SIGN1(sys32_lseek, sys_lseek, %o1)
105SIGN2(sys32_open, sparc32_open, %o1, %o2)
106SIGN1(sys32_readlink, sys_readlink, %o2)
107SIGN1(sys32_sched_get_priority_max, sys_sched_get_priority_max, %o0)
108SIGN1(sys32_sched_get_priority_min, sys_sched_get_priority_min, %o0)
109SIGN1(sys32_sched_getparam, sys_sched_getparam, %o0)
110SIGN1(sys32_sched_getscheduler, sys_sched_getscheduler, %o0)
111SIGN1(sys32_sched_setparam, sys_sched_setparam, %o0)
112SIGN2(sys32_sched_setscheduler, sys_sched_setscheduler, %o0, %o1)
113SIGN1(sys32_getdomainname, sys_getdomainname, %o1)
114SIGN1(sys32_setdomainname, sys_setdomainname, %o1)
115SIGN1(sys32_setgroups, sys_setgroups, %o0)
116SIGN2(sys32_setpgid, sys_setpgid, %o0, %o1)
117SIGN3(sys32_setpriority, sys_setpriority, %o0, %o1, %o2)
118SIGN1(sys32_ssetmask, sys_ssetmask, %o0)
119SIGN2(sys32_syslog, sys_syslog, %o0, %o2)
120SIGN1(sys32_umask, sys_umask, %o0)
121SIGN3(sys32_tgkill, sys_tgkill, %o0, %o1, %o2)
122SIGN1(sys32_sendto, sys_sendto, %o0)
123SIGN1(sys32_recvfrom, compat_sys_recvfrom, %o0)
124SIGN3(sys32_socket, sys_socket, %o0, %o1, %o2)
125SIGN2(sys32_connect, sys_connect, %o0, %o2)
126SIGN2(sys32_bind, sys_bind, %o0, %o2)
127SIGN2(sys32_listen, sys_listen, %o0, %o1)
128SIGN1(sys32_recvmsg, compat_sys_recvmsg, %o0)
129SIGN1(sys32_sendmsg, compat_sys_sendmsg, %o0)
130SIGN2(sys32_shutdown, sys_shutdown, %o0, %o1)
131SIGN3(sys32_socketpair, sys_socketpair, %o0, %o1, %o2)
132SIGN1(sys32_getpeername, sys_getpeername, %o0)
133SIGN1(sys32_getsockname, sys_getsockname, %o0)
134SIGN2(sys32_ioprio_get, sys_ioprio_get, %o0, %o1)
135SIGN3(sys32_ioprio_set, sys_ioprio_set, %o0, %o1, %o2)
136SIGN2(sys32_splice, sys_splice, %o0, %o2)
137SIGN2(sys32_sync_file_range, compat_sync_file_range, %o0, %o5)
138SIGN2(sys32_tee, sys_tee, %o0, %o1)
139SIGN1(sys32_vmsplice, compat_sys_vmsplice, %o0)
140SIGN1(sys32_truncate, sys_truncate, %o1)
141SIGN1(sys32_ftruncate, sys_ftruncate, %o1)
142
143	.globl		sys32_mmap2
144sys32_mmap2:
145	sethi		%hi(sys_mmap), %g1
146	jmpl		%g1 + %lo(sys_mmap), %g0
147	 sllx		%o5, 12, %o5
148
149	.align		32
150	.globl		sys32_socketcall
151sys32_socketcall:	/* %o0=call, %o1=args */
152	cmp		%o0, 1
153	bl,pn		%xcc, do_einval
154	 cmp		%o0, 18
155	bg,pn		%xcc, do_einval
156	 sub		%o0, 1, %o0
157	sllx		%o0, 5, %o0
158	sethi		%hi(__socketcall_table_begin), %g2
159	or		%g2, %lo(__socketcall_table_begin), %g2
160	jmpl		%g2 + %o0, %g0
161	 nop
162do_einval:
163	retl
164	 mov		-EINVAL, %o0
165
166	.align		32
167__socketcall_table_begin:
168
169	/* Each entry is exactly 32 bytes. */
170do_sys_socket: /* sys_socket(int, int, int) */
1711:	ldswa		[%o1 + 0x0] %asi, %o0
172	sethi		%hi(sys_socket), %g1
1732:	ldswa		[%o1 + 0x8] %asi, %o2
174	jmpl		%g1 + %lo(sys_socket), %g0
1753:	 ldswa		[%o1 + 0x4] %asi, %o1
176	nop
177	nop
178	nop
179do_sys_bind: /* sys_bind(int fd, struct sockaddr *, int) */
1804:	ldswa		[%o1 + 0x0] %asi, %o0
181	sethi		%hi(sys_bind), %g1
1825:	ldswa		[%o1 + 0x8] %asi, %o2
183	jmpl		%g1 + %lo(sys_bind), %g0
1846:	 lduwa		[%o1 + 0x4] %asi, %o1
185	nop
186	nop
187	nop
188do_sys_connect: /* sys_connect(int, struct sockaddr *, int) */
1897:	ldswa		[%o1 + 0x0] %asi, %o0
190	sethi		%hi(sys_connect), %g1
1918:	ldswa		[%o1 + 0x8] %asi, %o2
192	jmpl		%g1 + %lo(sys_connect), %g0
1939:	 lduwa		[%o1 + 0x4] %asi, %o1
194	nop
195	nop
196	nop
197do_sys_listen: /* sys_listen(int, int) */
19810:	ldswa		[%o1 + 0x0] %asi, %o0
199	sethi		%hi(sys_listen), %g1
200	jmpl		%g1 + %lo(sys_listen), %g0
20111:	 ldswa		[%o1 + 0x4] %asi, %o1
202	nop
203	nop
204	nop
205	nop
206do_sys_accept: /* sys_accept(int, struct sockaddr *, int *) */
20712:	ldswa		[%o1 + 0x0] %asi, %o0
208	sethi		%hi(sys_accept), %g1
20913:	lduwa		[%o1 + 0x8] %asi, %o2
210	jmpl		%g1 + %lo(sys_accept), %g0
21114:	 lduwa		[%o1 + 0x4] %asi, %o1
212	nop
213	nop
214	nop
215do_sys_getsockname: /* sys_getsockname(int, struct sockaddr *, int *) */
21615:	ldswa		[%o1 + 0x0] %asi, %o0
217	sethi		%hi(sys_getsockname), %g1
21816:	lduwa		[%o1 + 0x8] %asi, %o2
219	jmpl		%g1 + %lo(sys_getsockname), %g0
22017:	 lduwa		[%o1 + 0x4] %asi, %o1
221	nop
222	nop
223	nop
224do_sys_getpeername: /* sys_getpeername(int, struct sockaddr *, int *) */
22518:	ldswa		[%o1 + 0x0] %asi, %o0
226	sethi		%hi(sys_getpeername), %g1
22719:	lduwa		[%o1 + 0x8] %asi, %o2
228	jmpl		%g1 + %lo(sys_getpeername), %g0
22920:	 lduwa		[%o1 + 0x4] %asi, %o1
230	nop
231	nop
232	nop
233do_sys_socketpair: /* sys_socketpair(int, int, int, int *) */
23421:	ldswa		[%o1 + 0x0] %asi, %o0
235	sethi		%hi(sys_socketpair), %g1
23622:	ldswa		[%o1 + 0x8] %asi, %o2
23723:	lduwa		[%o1 + 0xc] %asi, %o3
238	jmpl		%g1 + %lo(sys_socketpair), %g0
23924:	 ldswa		[%o1 + 0x4] %asi, %o1
240	nop
241	nop
242do_sys_send: /* sys_send(int, void *, size_t, unsigned int) */
24325:	ldswa		[%o1 + 0x0] %asi, %o0
244	sethi		%hi(sys_send), %g1
24526:	lduwa		[%o1 + 0x8] %asi, %o2
24627:	lduwa		[%o1 + 0xc] %asi, %o3
247	jmpl		%g1 + %lo(sys_send), %g0
24828:	 lduwa		[%o1 + 0x4] %asi, %o1
249	nop
250	nop
251do_sys_recv: /* sys_recv(int, void *, size_t, unsigned int) */
25229:	ldswa		[%o1 + 0x0] %asi, %o0
253	sethi		%hi(sys_recv), %g1
25430:	lduwa		[%o1 + 0x8] %asi, %o2
25531:	lduwa		[%o1 + 0xc] %asi, %o3
256	jmpl		%g1 + %lo(sys_recv), %g0
25732:	 lduwa		[%o1 + 0x4] %asi, %o1
258	nop
259	nop
260do_sys_sendto: /* sys_sendto(int, u32, compat_size_t, unsigned int, u32, int) */
26133:	ldswa		[%o1 + 0x0] %asi, %o0
262	sethi		%hi(sys_sendto), %g1
26334:	lduwa		[%o1 + 0x8] %asi, %o2
26435:	lduwa		[%o1 + 0xc] %asi, %o3
26536:	lduwa		[%o1 + 0x10] %asi, %o4
26637:	ldswa		[%o1 + 0x14] %asi, %o5
267	jmpl		%g1 + %lo(sys_sendto), %g0
26838:	 lduwa		[%o1 + 0x4] %asi, %o1
269do_sys_recvfrom: /* sys_recvfrom(int, u32, compat_size_t, unsigned int, u32, u32) */
27039:	ldswa		[%o1 + 0x0] %asi, %o0
271	sethi		%hi(sys_recvfrom), %g1
27240:	lduwa		[%o1 + 0x8] %asi, %o2
27341:	lduwa		[%o1 + 0xc] %asi, %o3
27442:	lduwa		[%o1 + 0x10] %asi, %o4
27543:	lduwa		[%o1 + 0x14] %asi, %o5
276	jmpl		%g1 + %lo(sys_recvfrom), %g0
27744:	 lduwa		[%o1 + 0x4] %asi, %o1
278do_sys_shutdown: /* sys_shutdown(int, int) */
27945:	ldswa		[%o1 + 0x0] %asi, %o0
280	sethi		%hi(sys_shutdown), %g1
281	jmpl		%g1 + %lo(sys_shutdown), %g0
28246:	 ldswa		[%o1 + 0x4] %asi, %o1
283	nop
284	nop
285	nop
286	nop
287do_sys_setsockopt: /* compat_sys_setsockopt(int, int, int, char *, int) */
28847:	ldswa		[%o1 + 0x0] %asi, %o0
289	sethi		%hi(compat_sys_setsockopt), %g1
29048:	ldswa		[%o1 + 0x8] %asi, %o2
29149:	lduwa		[%o1 + 0xc] %asi, %o3
29250:	ldswa		[%o1 + 0x10] %asi, %o4
293	jmpl		%g1 + %lo(compat_sys_setsockopt), %g0
29451:	 ldswa		[%o1 + 0x4] %asi, %o1
295	nop
296do_sys_getsockopt: /* compat_sys_getsockopt(int, int, int, u32, u32) */
29752:	ldswa		[%o1 + 0x0] %asi, %o0
298	sethi		%hi(compat_sys_getsockopt), %g1
29953:	ldswa		[%o1 + 0x8] %asi, %o2
30054:	lduwa		[%o1 + 0xc] %asi, %o3
30155:	lduwa		[%o1 + 0x10] %asi, %o4
302	jmpl		%g1 + %lo(compat_sys_getsockopt), %g0
30356:	 ldswa		[%o1 + 0x4] %asi, %o1
304	nop
305do_sys_sendmsg: /* compat_sys_sendmsg(int, struct compat_msghdr *, unsigned int) */
30657:	ldswa		[%o1 + 0x0] %asi, %o0
307	sethi		%hi(compat_sys_sendmsg), %g1
30858:	lduwa		[%o1 + 0x8] %asi, %o2
309	jmpl		%g1 + %lo(compat_sys_sendmsg), %g0
31059:	 lduwa		[%o1 + 0x4] %asi, %o1
311	nop
312	nop
313	nop
314do_sys_recvmsg: /* compat_sys_recvmsg(int, struct compat_msghdr *, unsigned int) */
31560:	ldswa		[%o1 + 0x0] %asi, %o0
316	sethi		%hi(compat_sys_recvmsg), %g1
31761:	lduwa		[%o1 + 0x8] %asi, %o2
318	jmpl		%g1 + %lo(compat_sys_recvmsg), %g0
31962:	 lduwa		[%o1 + 0x4] %asi, %o1
320	nop
321	nop
322	nop
323do_sys_accept4: /* sys_accept4(int, struct sockaddr *, int *, int) */
32463:	ldswa		[%o1 + 0x0] %asi, %o0
325	sethi		%hi(sys_accept4), %g1
32664:	lduwa		[%o1 + 0x8] %asi, %o2
32765:	ldswa		[%o1 + 0xc] %asi, %o3
328	jmpl		%g1 + %lo(sys_accept4), %g0
32966:	 lduwa		[%o1 + 0x4] %asi, %o1
330	nop
331	nop
332
333	.globl		sys32_fanotify_mark
334sys32_fanotify_mark:
335	sethi		%hi(sys_fanotify_mark), %g1
336	sllx		%o2, 32, %o2
337	or		%o2, %o3, %o2
338	mov		%o4, %o3
339	jmpl		%g1 + %lo(sys_fanotify_mark), %g0
340	 mov		%o5, %o4
341
342	.section	__ex_table,"a"
343	.align		4
344	.word		1b, __retl_efault, 2b, __retl_efault
345	.word		3b, __retl_efault, 4b, __retl_efault
346	.word		5b, __retl_efault, 6b, __retl_efault
347	.word		7b, __retl_efault, 8b, __retl_efault
348	.word		9b, __retl_efault, 10b, __retl_efault
349	.word		11b, __retl_efault, 12b, __retl_efault
350	.word		13b, __retl_efault, 14b, __retl_efault
351	.word		15b, __retl_efault, 16b, __retl_efault
352	.word		17b, __retl_efault, 18b, __retl_efault
353	.word		19b, __retl_efault, 20b, __retl_efault
354	.word		21b, __retl_efault, 22b, __retl_efault
355	.word		23b, __retl_efault, 24b, __retl_efault
356	.word		25b, __retl_efault, 26b, __retl_efault
357	.word		27b, __retl_efault, 28b, __retl_efault
358	.word		29b, __retl_efault, 30b, __retl_efault
359	.word		31b, __retl_efault, 32b, __retl_efault
360	.word		33b, __retl_efault, 34b, __retl_efault
361	.word		35b, __retl_efault, 36b, __retl_efault
362	.word		37b, __retl_efault, 38b, __retl_efault
363	.word		39b, __retl_efault, 40b, __retl_efault
364	.word		41b, __retl_efault, 42b, __retl_efault
365	.word		43b, __retl_efault, 44b, __retl_efault
366	.word		45b, __retl_efault, 46b, __retl_efault
367	.word		47b, __retl_efault, 48b, __retl_efault
368	.word		49b, __retl_efault, 50b, __retl_efault
369	.word		51b, __retl_efault, 52b, __retl_efault
370	.word		53b, __retl_efault, 54b, __retl_efault
371	.word		55b, __retl_efault, 56b, __retl_efault
372	.word		57b, __retl_efault, 58b, __retl_efault
373	.word		59b, __retl_efault, 60b, __retl_efault
374	.word		61b, __retl_efault, 62b, __retl_efault
375	.word		63b, __retl_efault, 64b, __retl_efault
376	.word		65b, __retl_efault, 66b, __retl_efault
377	.previous
378