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