xref: /linux/arch/mips/kernel/scall64-n32.S (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License.  See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 96, 97, 98, 99, 2000, 01 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc.
9 */
10#include <linux/errno.h>
11#include <asm/asm.h>
12#include <asm/asmmacro.h>
13#include <asm/irqflags.h>
14#include <asm/mipsregs.h>
15#include <asm/regdef.h>
16#include <asm/stackframe.h>
17#include <asm/thread_info.h>
18#include <asm/unistd.h>
19
20#ifndef CONFIG_MIPS32_O32
21/* No O32, so define handle_sys here */
22#define handle_sysn32 handle_sys
23#endif
24
25	.align	5
26NESTED(handle_sysn32, PT_SIZE, sp)
27#ifndef CONFIG_MIPS32_O32
28	.set	noat
29	SAVE_SOME
30	TRACE_IRQS_ON_RELOAD
31	STI
32	.set	at
33#endif
34
35	dsubu	t0, v0, __NR_N32_Linux	# check syscall number
36	sltiu	t0, t0, __NR_N32_Linux_syscalls + 1
37
38#ifndef CONFIG_MIPS32_O32
39	ld	t1, PT_EPC(sp)		# skip syscall on return
40	daddiu	t1, 4			# skip to next instruction
41	sd	t1, PT_EPC(sp)
42#endif
43	beqz	t0, not_n32_scall
44
45	dsll	t0, v0, 3		# offset into table
46	ld	t2, (sysn32_call_table - (__NR_N32_Linux * 8))(t0)
47
48	sd	a3, PT_R26(sp)		# save a3 for syscall restarting
49
50	li	t1, _TIF_WORK_SYSCALL_ENTRY
51	LONG_L	t0, TI_FLAGS($28)	# syscall tracing enabled?
52	and	t0, t1, t0
53	bnez	t0, n32_syscall_trace_entry
54
55syscall_common:
56	jalr	t2			# Do The Real Thing (TM)
57
58	li	t0, -EMAXERRNO - 1	# error?
59	sltu	t0, t0, v0
60	sd	t0, PT_R7(sp)		# set error flag
61	beqz	t0, 1f
62
63	ld	t1, PT_R2(sp)		# syscall number
64	dnegu	v0			# error
65	sd	t1, PT_R0(sp)		# save it for syscall restarting
661:	sd	v0, PT_R2(sp)		# result
67
68	j	syscall_exit_partial
69
70/* ------------------------------------------------------------------------ */
71
72n32_syscall_trace_entry:
73	SAVE_STATIC
74	move	s0, t2
75	move	a0, sp
76	move	a1, v0
77	jal	syscall_trace_enter
78
79	bltz	v0, 1f			# seccomp failed? Skip syscall
80
81	move	t2, s0
82	RESTORE_STATIC
83	ld	a0, PT_R4(sp)		# Restore argument registers
84	ld	a1, PT_R5(sp)
85	ld	a2, PT_R6(sp)
86	ld	a3, PT_R7(sp)
87	ld	a4, PT_R8(sp)
88	ld	a5, PT_R9(sp)
89	j	syscall_common
90
911:	j	syscall_exit
92
93not_n32_scall:
94	/* This is not an n32 compatibility syscall, pass it on to
95	   the n64 syscall handlers.  */
96	j	handle_sys64
97
98	END(handle_sysn32)
99
100	.type	sysn32_call_table, @object
101EXPORT(sysn32_call_table)
102	PTR	sys_read			/* 6000 */
103	PTR	sys_write
104	PTR	sys_open
105	PTR	sys_close
106	PTR	sys_newstat
107	PTR	sys_newfstat			/* 6005 */
108	PTR	sys_newlstat
109	PTR	sys_poll
110	PTR	sys_lseek
111	PTR	sys_mips_mmap
112	PTR	sys_mprotect			/* 6010 */
113	PTR	sys_munmap
114	PTR	sys_brk
115	PTR	compat_sys_rt_sigaction
116	PTR	compat_sys_rt_sigprocmask
117	PTR	compat_sys_ioctl		/* 6015 */
118	PTR	sys_pread64
119	PTR	sys_pwrite64
120	PTR	compat_sys_readv
121	PTR	compat_sys_writev
122	PTR	sys_access			/* 6020 */
123	PTR	sysm_pipe
124	PTR	compat_sys_select
125	PTR	sys_sched_yield
126	PTR	sys_mremap
127	PTR	sys_msync			/* 6025 */
128	PTR	sys_mincore
129	PTR	sys_madvise
130	PTR	sys_shmget
131	PTR	sys_shmat
132	PTR	compat_sys_shmctl			/* 6030 */
133	PTR	sys_dup
134	PTR	sys_dup2
135	PTR	sys_pause
136	PTR	compat_sys_nanosleep
137	PTR	compat_sys_getitimer		/* 6035 */
138	PTR	compat_sys_setitimer
139	PTR	sys_alarm
140	PTR	sys_getpid
141	PTR	compat_sys_sendfile
142	PTR	sys_socket			/* 6040 */
143	PTR	sys_connect
144	PTR	sys_accept
145	PTR	sys_sendto
146	PTR	compat_sys_recvfrom
147	PTR	compat_sys_sendmsg		/* 6045 */
148	PTR	compat_sys_recvmsg
149	PTR	sys_shutdown
150	PTR	sys_bind
151	PTR	sys_listen
152	PTR	sys_getsockname			/* 6050 */
153	PTR	sys_getpeername
154	PTR	sys_socketpair
155	PTR	compat_sys_setsockopt
156	PTR	compat_sys_getsockopt
157	PTR	__sys_clone			/* 6055 */
158	PTR	__sys_fork
159	PTR	compat_sys_execve
160	PTR	sys_exit
161	PTR	compat_sys_wait4
162	PTR	sys_kill			/* 6060 */
163	PTR	sys_newuname
164	PTR	sys_semget
165	PTR	sys_semop
166	PTR	compat_sys_semctl
167	PTR	sys_shmdt			/* 6065 */
168	PTR	sys_msgget
169	PTR	compat_sys_msgsnd
170	PTR	compat_sys_msgrcv
171	PTR	compat_sys_msgctl
172	PTR	compat_sys_fcntl		/* 6070 */
173	PTR	sys_flock
174	PTR	sys_fsync
175	PTR	sys_fdatasync
176	PTR	sys_truncate
177	PTR	sys_ftruncate			/* 6075 */
178	PTR	compat_sys_getdents
179	PTR	sys_getcwd
180	PTR	sys_chdir
181	PTR	sys_fchdir
182	PTR	sys_rename			/* 6080 */
183	PTR	sys_mkdir
184	PTR	sys_rmdir
185	PTR	sys_creat
186	PTR	sys_link
187	PTR	sys_unlink			/* 6085 */
188	PTR	sys_symlink
189	PTR	sys_readlink
190	PTR	sys_chmod
191	PTR	sys_fchmod
192	PTR	sys_chown			/* 6090 */
193	PTR	sys_fchown
194	PTR	sys_lchown
195	PTR	sys_umask
196	PTR	compat_sys_gettimeofday
197	PTR	compat_sys_getrlimit		/* 6095 */
198	PTR	compat_sys_getrusage
199	PTR	compat_sys_sysinfo
200	PTR	compat_sys_times
201	PTR	compat_sys_ptrace
202	PTR	sys_getuid			/* 6100 */
203	PTR	sys_syslog
204	PTR	sys_getgid
205	PTR	sys_setuid
206	PTR	sys_setgid
207	PTR	sys_geteuid			/* 6105 */
208	PTR	sys_getegid
209	PTR	sys_setpgid
210	PTR	sys_getppid
211	PTR	sys_getpgrp
212	PTR	sys_setsid			/* 6110 */
213	PTR	sys_setreuid
214	PTR	sys_setregid
215	PTR	sys_getgroups
216	PTR	sys_setgroups
217	PTR	sys_setresuid			/* 6115 */
218	PTR	sys_getresuid
219	PTR	sys_setresgid
220	PTR	sys_getresgid
221	PTR	sys_getpgid
222	PTR	sys_setfsuid			/* 6120 */
223	PTR	sys_setfsgid
224	PTR	sys_getsid
225	PTR	sys_capget
226	PTR	sys_capset
227	PTR	compat_sys_rt_sigpending	/* 6125 */
228	PTR	compat_sys_rt_sigtimedwait
229	PTR	compat_sys_rt_sigqueueinfo
230	PTR	compat_sys_rt_sigsuspend
231	PTR	compat_sys_sigaltstack
232	PTR	compat_sys_utime		/* 6130 */
233	PTR	sys_mknod
234	PTR	sys_32_personality
235	PTR	compat_sys_ustat
236	PTR	compat_sys_statfs
237	PTR	compat_sys_fstatfs		/* 6135 */
238	PTR	sys_sysfs
239	PTR	sys_getpriority
240	PTR	sys_setpriority
241	PTR	sys_sched_setparam
242	PTR	sys_sched_getparam		/* 6140 */
243	PTR	sys_sched_setscheduler
244	PTR	sys_sched_getscheduler
245	PTR	sys_sched_get_priority_max
246	PTR	sys_sched_get_priority_min
247	PTR	compat_sys_sched_rr_get_interval	/* 6145 */
248	PTR	sys_mlock
249	PTR	sys_munlock
250	PTR	sys_mlockall
251	PTR	sys_munlockall
252	PTR	sys_vhangup			/* 6150 */
253	PTR	sys_pivot_root
254	PTR	compat_sys_sysctl
255	PTR	sys_prctl
256	PTR	compat_sys_adjtimex
257	PTR	compat_sys_setrlimit		/* 6155 */
258	PTR	sys_chroot
259	PTR	sys_sync
260	PTR	sys_acct
261	PTR	compat_sys_settimeofday
262	PTR	compat_sys_mount		/* 6160 */
263	PTR	sys_umount
264	PTR	sys_swapon
265	PTR	sys_swapoff
266	PTR	sys_reboot
267	PTR	sys_sethostname			/* 6165 */
268	PTR	sys_setdomainname
269	PTR	sys_ni_syscall			/* was create_module */
270	PTR	sys_init_module
271	PTR	sys_delete_module
272	PTR	sys_ni_syscall			/* 6170, was get_kernel_syms */
273	PTR	sys_ni_syscall			/* was query_module */
274	PTR	sys_quotactl
275	PTR	sys_ni_syscall			/* was nfsservctl */
276	PTR	sys_ni_syscall			/* res. for getpmsg */
277	PTR	sys_ni_syscall			/* 6175	 for putpmsg */
278	PTR	sys_ni_syscall			/* res. for afs_syscall */
279	PTR	sys_ni_syscall			/* res. for security */
280	PTR	sys_gettid
281	PTR	sys_readahead
282	PTR	sys_setxattr			/* 6180 */
283	PTR	sys_lsetxattr
284	PTR	sys_fsetxattr
285	PTR	sys_getxattr
286	PTR	sys_lgetxattr
287	PTR	sys_fgetxattr			/* 6185 */
288	PTR	sys_listxattr
289	PTR	sys_llistxattr
290	PTR	sys_flistxattr
291	PTR	sys_removexattr
292	PTR	sys_lremovexattr		/* 6190 */
293	PTR	sys_fremovexattr
294	PTR	sys_tkill
295	PTR	sys_ni_syscall
296	PTR	compat_sys_futex
297	PTR	compat_sys_sched_setaffinity	/* 6195 */
298	PTR	compat_sys_sched_getaffinity
299	PTR	sys_cacheflush
300	PTR	sys_cachectl
301	PTR	sys_sysmips
302	PTR	compat_sys_io_setup			/* 6200 */
303	PTR	sys_io_destroy
304	PTR	compat_sys_io_getevents
305	PTR	compat_sys_io_submit
306	PTR	sys_io_cancel
307	PTR	sys_exit_group			/* 6205 */
308	PTR	sys_lookup_dcookie
309	PTR	sys_epoll_create
310	PTR	sys_epoll_ctl
311	PTR	sys_epoll_wait
312	PTR	sys_remap_file_pages		/* 6210 */
313	PTR	sysn32_rt_sigreturn
314	PTR	compat_sys_fcntl64
315	PTR	sys_set_tid_address
316	PTR	sys_restart_syscall
317	PTR	compat_sys_semtimedop			/* 6215 */
318	PTR	sys_fadvise64_64
319	PTR	compat_sys_statfs64
320	PTR	compat_sys_fstatfs64
321	PTR	sys_sendfile64
322	PTR	compat_sys_timer_create		/* 6220 */
323	PTR	compat_sys_timer_settime
324	PTR	compat_sys_timer_gettime
325	PTR	sys_timer_getoverrun
326	PTR	sys_timer_delete
327	PTR	compat_sys_clock_settime		/* 6225 */
328	PTR	compat_sys_clock_gettime
329	PTR	compat_sys_clock_getres
330	PTR	compat_sys_clock_nanosleep
331	PTR	sys_tgkill
332	PTR	compat_sys_utimes		/* 6230 */
333	PTR	compat_sys_mbind
334	PTR	compat_sys_get_mempolicy
335	PTR	compat_sys_set_mempolicy
336	PTR	compat_sys_mq_open
337	PTR	sys_mq_unlink			/* 6235 */
338	PTR	compat_sys_mq_timedsend
339	PTR	compat_sys_mq_timedreceive
340	PTR	compat_sys_mq_notify
341	PTR	compat_sys_mq_getsetattr
342	PTR	sys_ni_syscall			/* 6240, sys_vserver */
343	PTR	compat_sys_waitid
344	PTR	sys_ni_syscall			/* available, was setaltroot */
345	PTR	sys_add_key
346	PTR	sys_request_key
347	PTR	sys_keyctl			/* 6245 */
348	PTR	sys_set_thread_area
349	PTR	sys_inotify_init
350	PTR	sys_inotify_add_watch
351	PTR	sys_inotify_rm_watch
352	PTR	compat_sys_migrate_pages	/* 6250 */
353	PTR	sys_openat
354	PTR	sys_mkdirat
355	PTR	sys_mknodat
356	PTR	sys_fchownat
357	PTR	compat_sys_futimesat		/* 6255 */
358	PTR	sys_newfstatat
359	PTR	sys_unlinkat
360	PTR	sys_renameat
361	PTR	sys_linkat
362	PTR	sys_symlinkat			/* 6260 */
363	PTR	sys_readlinkat
364	PTR	sys_fchmodat
365	PTR	sys_faccessat
366	PTR	compat_sys_pselect6
367	PTR	compat_sys_ppoll		/* 6265 */
368	PTR	sys_unshare
369	PTR	sys_splice
370	PTR	sys_sync_file_range
371	PTR	sys_tee
372	PTR	compat_sys_vmsplice		/* 6270 */
373	PTR	compat_sys_move_pages
374	PTR	compat_sys_set_robust_list
375	PTR	compat_sys_get_robust_list
376	PTR	compat_sys_kexec_load
377	PTR	sys_getcpu			/* 6275 */
378	PTR	compat_sys_epoll_pwait
379	PTR	sys_ioprio_set
380	PTR	sys_ioprio_get
381	PTR	compat_sys_utimensat
382	PTR	compat_sys_signalfd		/* 6280 */
383	PTR	sys_ni_syscall			/* was timerfd */
384	PTR	sys_eventfd
385	PTR	sys_fallocate
386	PTR	sys_timerfd_create
387	PTR	compat_sys_timerfd_gettime	/* 6285 */
388	PTR	compat_sys_timerfd_settime
389	PTR	compat_sys_signalfd4
390	PTR	sys_eventfd2
391	PTR	sys_epoll_create1
392	PTR	sys_dup3			/* 6290 */
393	PTR	sys_pipe2
394	PTR	sys_inotify_init1
395	PTR	compat_sys_preadv
396	PTR	compat_sys_pwritev
397	PTR	compat_sys_rt_tgsigqueueinfo	/* 6295 */
398	PTR	sys_perf_event_open
399	PTR	sys_accept4
400	PTR	compat_sys_recvmmsg
401	PTR	sys_getdents64
402	PTR	sys_fanotify_init		/* 6300 */
403	PTR	sys_fanotify_mark
404	PTR	sys_prlimit64
405	PTR	sys_name_to_handle_at
406	PTR	sys_open_by_handle_at
407	PTR	compat_sys_clock_adjtime	/* 6305 */
408	PTR	sys_syncfs
409	PTR	compat_sys_sendmmsg
410	PTR	sys_setns
411	PTR	compat_sys_process_vm_readv
412	PTR	compat_sys_process_vm_writev	/* 6310 */
413	PTR	sys_kcmp
414	PTR	sys_finit_module
415	PTR	sys_sched_setattr
416	PTR	sys_sched_getattr
417	PTR	sys_renameat2			/* 6315 */
418	PTR	sys_seccomp
419	PTR	sys_getrandom
420	PTR	sys_memfd_create
421	PTR	sys_bpf
422	PTR	compat_sys_execveat		/* 6320 */
423	PTR	sys_userfaultfd
424	PTR	sys_membarrier
425	.size	sysn32_call_table,.-sysn32_call_table
426