blob: b2c7624995b8068e3d8ae21b7faa56c016225ec9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/errno.h>
11#include <asm/asm.h>
12#include <asm/asmmacro.h>
Ralf Baechle192ef362006-07-07 14:07:18 +010013#include <asm/irqflags.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#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/* This duplicates the definition from <linux/sched.h> */
21#define PT_TRACESYS 0x00000002 /* tracing system calls */
22
23/* This duplicates the definition from <asm/signal.h> */
24#define SIGILL 4 /* Illegal instruction (ANSI). */
25
26#ifndef CONFIG_MIPS32_O32
27/* No O32, so define handle_sys here */
28#define handle_sysn32 handle_sys
29#endif
30
31 .align 5
32NESTED(handle_sysn32, PT_SIZE, sp)
33#ifndef CONFIG_MIPS32_O32
34 .set noat
35 SAVE_SOME
Atsushi Nemotoeae6c0d2006-09-26 23:43:40 +090036 TRACE_IRQS_ON_RELOAD
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 STI
38 .set at
39#endif
40
41 dsubu t0, v0, __NR_N32_Linux # check syscall number
42 sltiu t0, t0, __NR_N32_Linux_syscalls + 1
43
44#ifndef CONFIG_MIPS32_O32
45 ld t1, PT_EPC(sp) # skip syscall on return
46 daddiu t1, 4 # skip to next instruction
47 sd t1, PT_EPC(sp)
48#endif
49 beqz t0, not_n32_scall
50
51 dsll t0, v0, 3 # offset into table
52 ld t2, (sysn32_call_table - (__NR_N32_Linux * 8))(t0)
53
54 sd a3, PT_R26(sp) # save a3 for syscall restarting
55
56 li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
57 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
58 and t0, t1, t0
59 bnez t0, n32_syscall_trace_entry
60
61 jalr t2 # Do The Real Thing (TM)
62
63 li t0, -EMAXERRNO - 1 # error?
64 sltu t0, t0, v0
65 sd t0, PT_R7(sp) # set error flag
66 beqz t0, 1f
67
Al Viro8f5a00eb2010-09-28 18:50:37 +010068 ld t1, PT_R2(sp) # syscall number
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 dnegu v0 # error
Al Viro8f5a00eb2010-09-28 18:50:37 +010070 sd t1, PT_R0(sp) # save it for syscall restarting
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711: sd v0, PT_R2(sp) # result
72
73 local_irq_disable # make sure need_resched and
74 # signals dont change between
75 # sampling and return
76 LONG_L a2, TI_FLAGS($28) # current->work
77 li t0, _TIF_ALLWORK_MASK
78 and t0, a2, t0
79 bnez t0, n32_syscall_exit_work
80
81 j restore_partial
82
83n32_syscall_exit_work:
84 j syscall_exit_work_partial
85
86/* ------------------------------------------------------------------------ */
87
88n32_syscall_trace_entry:
89 SAVE_STATIC
90 move s0, t2
91 move a0, sp
92 li a1, 0
93 jal do_syscall_trace
94
Ralf Baechle04a70522005-11-30 16:24:57 +000095 move t0, s0
96 RESTORE_STATIC
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 ld a0, PT_R4(sp) # Restore argument registers
98 ld a1, PT_R5(sp)
99 ld a2, PT_R6(sp)
100 ld a3, PT_R7(sp)
101 ld a4, PT_R8(sp)
102 ld a5, PT_R9(sp)
Ralf Baechle04a70522005-11-30 16:24:57 +0000103 jalr t0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
105 li t0, -EMAXERRNO - 1 # error?
106 sltu t0, t0, v0
107 sd t0, PT_R7(sp) # set error flag
108 beqz t0, 1f
109
Al Viro8f5a00eb2010-09-28 18:50:37 +0100110 ld t1, PT_R2(sp) # syscall number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 dnegu v0 # error
Al Viro8f5a00eb2010-09-28 18:50:37 +0100112 sd t1, PT_R0(sp) # save it for syscall restarting
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131: sd v0, PT_R2(sp) # result
114
115 j syscall_exit
116
117not_n32_scall:
118 /* This is not an n32 compatibility syscall, pass it on to
119 the n64 syscall handlers. */
120 j handle_sys64
121
122 END(handle_sysn32)
123
124EXPORT(sysn32_call_table)
125 PTR sys_read /* 6000 */
126 PTR sys_write
127 PTR sys_open
128 PTR sys_close
129 PTR sys_newstat
130 PTR sys_newfstat /* 6005 */
131 PTR sys_newlstat
132 PTR sys_poll
133 PTR sys_lseek
Ralf Baechledbda6ac2009-02-08 16:00:26 +0000134 PTR sys_mips_mmap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 PTR sys_mprotect /* 6010 */
136 PTR sys_munmap
137 PTR sys_brk
Ralf Baechledbda6ac2009-02-08 16:00:26 +0000138 PTR sys_32_rt_sigaction
139 PTR sys_32_rt_sigprocmask
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 PTR compat_sys_ioctl /* 6015 */
141 PTR sys_pread64
142 PTR sys_pwrite64
143 PTR compat_sys_readv
144 PTR compat_sys_writev
145 PTR sys_access /* 6020 */
Ralf Baechle8213bbf2008-07-20 13:16:46 +0100146 PTR sysm_pipe
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 PTR compat_sys_select
148 PTR sys_sched_yield
149 PTR sys_mremap
150 PTR sys_msync /* 6025 */
151 PTR sys_mincore
152 PTR sys_madvise
153 PTR sys_shmget
Atsushi Nemoto05e43962006-11-07 18:02:44 +0900154 PTR sys_shmat
155 PTR compat_sys_shmctl /* 6030 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 PTR sys_dup
157 PTR sys_dup2
158 PTR sys_pause
159 PTR compat_sys_nanosleep
160 PTR compat_sys_getitimer /* 6035 */
161 PTR compat_sys_setitimer
162 PTR sys_alarm
163 PTR sys_getpid
Ralf Baechledbda6ac2009-02-08 16:00:26 +0000164 PTR sys_32_sendfile
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 PTR sys_socket /* 6040 */
166 PTR sys_connect
167 PTR sys_accept
168 PTR sys_sendto
Johannes Berg1dacc762009-07-01 11:26:02 +0000169 PTR compat_sys_recvfrom
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 PTR compat_sys_sendmsg /* 6045 */
171 PTR compat_sys_recvmsg
172 PTR sys_shutdown
173 PTR sys_bind
174 PTR sys_listen
175 PTR sys_getsockname /* 6050 */
176 PTR sys_getpeername
177 PTR sys_socketpair
178 PTR compat_sys_setsockopt
179 PTR sys_getsockopt
180 PTR sys_clone /* 6055 */
181 PTR sys_fork
182 PTR sys32_execve
183 PTR sys_exit
Ralf Baechleb6e203d2005-02-16 21:18:52 +0000184 PTR compat_sys_wait4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 PTR sys_kill /* 6060 */
Christoph Hellwige28cbf22010-03-10 15:21:19 -0800186 PTR sys_newuname
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 PTR sys_semget
188 PTR sys_semop
Ralf Baechledbda6ac2009-02-08 16:00:26 +0000189 PTR sys_n32_semctl
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 PTR sys_shmdt /* 6065 */
191 PTR sys_msgget
Ralf Baechledbda6ac2009-02-08 16:00:26 +0000192 PTR sys_n32_msgsnd
193 PTR sys_n32_msgrcv
Atsushi Nemoto05e43962006-11-07 18:02:44 +0900194 PTR compat_sys_msgctl
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 PTR compat_sys_fcntl /* 6070 */
196 PTR sys_flock
197 PTR sys_fsync
198 PTR sys_fdatasync
199 PTR sys_truncate
200 PTR sys_ftruncate /* 6075 */
Atsushi Nemoto2fd628f2006-02-21 15:59:00 +0900201 PTR compat_sys_getdents
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 PTR sys_getcwd
203 PTR sys_chdir
204 PTR sys_fchdir
205 PTR sys_rename /* 6080 */
206 PTR sys_mkdir
207 PTR sys_rmdir
208 PTR sys_creat
209 PTR sys_link
210 PTR sys_unlink /* 6085 */
211 PTR sys_symlink
212 PTR sys_readlink
213 PTR sys_chmod
214 PTR sys_fchmod
215 PTR sys_chown /* 6090 */
216 PTR sys_fchown
217 PTR sys_lchown
218 PTR sys_umask
Christoph Hellwigb418da12008-10-15 22:02:06 -0700219 PTR compat_sys_gettimeofday
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 PTR compat_sys_getrlimit /* 6095 */
221 PTR compat_sys_getrusage
Kyle McMartind4d23ad2007-02-10 01:46:00 -0800222 PTR compat_sys_sysinfo
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 PTR compat_sys_times
Thomas Bogendoerfer5d9a76c2008-08-17 16:49:25 +0200224 PTR compat_sys_ptrace
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 PTR sys_getuid /* 6100 */
226 PTR sys_syslog
227 PTR sys_getgid
228 PTR sys_setuid
229 PTR sys_setgid
230 PTR sys_geteuid /* 6105 */
231 PTR sys_getegid
232 PTR sys_setpgid
233 PTR sys_getppid
234 PTR sys_getpgrp
235 PTR sys_setsid /* 6110 */
236 PTR sys_setreuid
237 PTR sys_setregid
238 PTR sys_getgroups
239 PTR sys_setgroups
240 PTR sys_setresuid /* 6115 */
241 PTR sys_getresuid
242 PTR sys_setresgid
243 PTR sys_getresgid
244 PTR sys_getpgid
245 PTR sys_setfsuid /* 6120 */
246 PTR sys_setfsgid
247 PTR sys_getsid
248 PTR sys_capget
249 PTR sys_capset
Ralf Baechledbda6ac2009-02-08 16:00:26 +0000250 PTR sys_32_rt_sigpending /* 6125 */
Ralf Baechle82ad93f2006-02-18 22:47:26 +0000251 PTR compat_sys_rt_sigtimedwait
Ralf Baechledbda6ac2009-02-08 16:00:26 +0000252 PTR sys_32_rt_sigqueueinfo
Ralf Baechle82ad93f2006-02-18 22:47:26 +0000253 PTR sysn32_rt_sigsuspend
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 PTR sys32_sigaltstack
255 PTR compat_sys_utime /* 6130 */
256 PTR sys_mknod
Ralf Baechledbda6ac2009-02-08 16:00:26 +0000257 PTR sys_32_personality
Christoph Hellwig2b1c6bd2008-11-28 10:09:09 +0100258 PTR compat_sys_ustat
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 PTR compat_sys_statfs
260 PTR compat_sys_fstatfs /* 6135 */
261 PTR sys_sysfs
262 PTR sys_getpriority
263 PTR sys_setpriority
264 PTR sys_sched_setparam
265 PTR sys_sched_getparam /* 6140 */
266 PTR sys_sched_setscheduler
267 PTR sys_sched_getscheduler
268 PTR sys_sched_get_priority_max
269 PTR sys_sched_get_priority_min
Ralf Baechledbda6ac2009-02-08 16:00:26 +0000270 PTR sys_32_sched_rr_get_interval /* 6145 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 PTR sys_mlock
272 PTR sys_munlock
273 PTR sys_mlockall
274 PTR sys_munlockall
275 PTR sys_vhangup /* 6150 */
276 PTR sys_pivot_root
Eric W. Biedermanaff639c2009-04-03 00:46:47 -0700277 PTR compat_sys_sysctl
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 PTR sys_prctl
Stephen Rothwell3158e942006-03-26 01:37:29 -0800279 PTR compat_sys_adjtimex
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 PTR compat_sys_setrlimit /* 6155 */
281 PTR sys_chroot
282 PTR sys_sync
283 PTR sys_acct
Christoph Hellwigb418da12008-10-15 22:02:06 -0700284 PTR compat_sys_settimeofday
Ralf Baechle089c7e72006-10-16 16:49:37 +0100285 PTR compat_sys_mount /* 6160 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 PTR sys_umount
287 PTR sys_swapon
288 PTR sys_swapoff
289 PTR sys_reboot
290 PTR sys_sethostname /* 6165 */
291 PTR sys_setdomainname
292 PTR sys_ni_syscall /* was create_module */
293 PTR sys_init_module
294 PTR sys_delete_module
295 PTR sys_ni_syscall /* 6170, was get_kernel_syms */
296 PTR sys_ni_syscall /* was query_module */
297 PTR sys_quotactl
Ralf Baechle72e51062007-11-15 22:20:33 +0000298 PTR compat_sys_nfsservctl
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 PTR sys_ni_syscall /* res. for getpmsg */
300 PTR sys_ni_syscall /* 6175 for putpmsg */
301 PTR sys_ni_syscall /* res. for afs_syscall */
302 PTR sys_ni_syscall /* res. for security */
303 PTR sys_gettid
Atsushi Nemoto8676d2e2007-05-18 00:46:13 +0900304 PTR sys_readahead
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 PTR sys_setxattr /* 6180 */
306 PTR sys_lsetxattr
307 PTR sys_fsetxattr
308 PTR sys_getxattr
309 PTR sys_lgetxattr
310 PTR sys_fgetxattr /* 6185 */
311 PTR sys_listxattr
312 PTR sys_llistxattr
313 PTR sys_flistxattr
314 PTR sys_removexattr
315 PTR sys_lremovexattr /* 6190 */
316 PTR sys_fremovexattr
317 PTR sys_tkill
318 PTR sys_ni_syscall
319 PTR compat_sys_futex
320 PTR compat_sys_sched_setaffinity /* 6195 */
321 PTR compat_sys_sched_getaffinity
322 PTR sys_cacheflush
323 PTR sys_cachectl
324 PTR sys_sysmips
Michel Thebeaue2cc5022010-09-28 14:15:37 -0400325 PTR compat_sys_io_setup /* 6200 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 PTR sys_io_destroy
Michel Thebeaue2cc5022010-09-28 14:15:37 -0400327 PTR compat_sys_io_getevents
328 PTR compat_sys_io_submit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 PTR sys_io_cancel
330 PTR sys_exit_group /* 6205 */
331 PTR sys_lookup_dcookie
332 PTR sys_epoll_create
333 PTR sys_epoll_ctl
334 PTR sys_epoll_wait
335 PTR sys_remap_file_pages /* 6210 */
336 PTR sysn32_rt_sigreturn
Thiemo Seufer589391a2005-04-13 09:11:22 +0000337 PTR compat_sys_fcntl64
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 PTR sys_set_tid_address
339 PTR sys_restart_syscall
Atsushi Nemoto05e43962006-11-07 18:02:44 +0900340 PTR compat_sys_semtimedop /* 6215 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 PTR sys_fadvise64_64
342 PTR compat_sys_statfs64
343 PTR compat_sys_fstatfs64
344 PTR sys_sendfile64
Ralf Baechle821d3132007-02-27 01:21:17 +0000345 PTR compat_sys_timer_create /* 6220 */
Ralf Baechled1abb6a2005-02-16 21:25:03 +0000346 PTR compat_sys_timer_settime
347 PTR compat_sys_timer_gettime
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 PTR sys_timer_getoverrun
349 PTR sys_timer_delete
Ralf Baechled1abb6a2005-02-16 21:25:03 +0000350 PTR compat_sys_clock_settime /* 6225 */
351 PTR compat_sys_clock_gettime
352 PTR compat_sys_clock_getres
353 PTR compat_sys_clock_nanosleep
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 PTR sys_tgkill
355 PTR compat_sys_utimes /* 6230 */
356 PTR sys_ni_syscall /* sys_mbind */
357 PTR sys_ni_syscall /* sys_get_mempolicy */
358 PTR sys_ni_syscall /* sys_set_mempolicy */
359 PTR compat_sys_mq_open
360 PTR sys_mq_unlink /* 6235 */
361 PTR compat_sys_mq_timedsend
362 PTR compat_sys_mq_timedreceive
363 PTR compat_sys_mq_notify
364 PTR compat_sys_mq_getsetattr
365 PTR sys_ni_syscall /* 6240, sys_vserver */
Ralf Baechle440537ef2007-02-27 00:56:37 +0000366 PTR compat_sys_waitid
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 PTR sys_ni_syscall /* available, was setaltroot */
368 PTR sys_add_key
369 PTR sys_request_key
370 PTR sys_keyctl /* 6245 */
Ralf Baechle3c370262005-04-13 17:43:59 +0000371 PTR sys_set_thread_area
Ralf Baechle8d9c6262005-08-05 10:31:47 +0000372 PTR sys_inotify_init
373 PTR sys_inotify_add_watch
374 PTR sys_inotify_rm_watch
Ralf Baechle72bf8912006-02-08 13:38:50 +0000375 PTR sys_migrate_pages /* 6250 */
376 PTR sys_openat
377 PTR sys_mkdirat
378 PTR sys_mknodat
379 PTR sys_fchownat
Johannes Dickgreber82411392007-09-12 18:22:04 +0200380 PTR compat_sys_futimesat /* 6255 */
Ralf Baechle72bf8912006-02-08 13:38:50 +0000381 PTR sys_newfstatat
382 PTR sys_unlinkat
383 PTR sys_renameat
384 PTR sys_linkat
385 PTR sys_symlinkat /* 6260 */
386 PTR sys_readlinkat
387 PTR sys_fchmodat
388 PTR sys_faccessat
Joseph S. Myers99d233f2007-01-10 12:30:50 +0000389 PTR compat_sys_pselect6
Chandrakala Chavva46afb822010-05-10 17:11:54 -0700390 PTR compat_sys_ppoll /* 6265 */
Ralf Baechle72bf8912006-02-08 13:38:50 +0000391 PTR sys_unshare
Ralf Baechlef115da92006-03-31 09:27:20 +0100392 PTR sys_splice
Ralf Baechlea8d587a2006-04-01 07:49:21 +0100393 PTR sys_sync_file_range
Ralf Baechle136d47d2006-04-15 11:16:19 +0200394 PTR sys_tee
Ralf Baechle8d13cb22008-12-03 17:03:27 +0000395 PTR compat_sys_vmsplice /* 6270 */
Ralf Baechle722cfd92006-07-02 16:31:14 +0100396 PTR sys_move_pages
Atsushi Nemoto7fdeb042006-09-06 22:42:02 +0900397 PTR compat_sys_set_robust_list
398 PTR compat_sys_get_robust_list
Nicolas Schichan583bb862006-10-18 15:14:55 +0200399 PTR compat_sys_kexec_load
Ralf Baechle08253b32007-03-06 17:04:49 +0000400 PTR sys_getcpu /* 6275 */
Ralf Baechle431dc802007-02-13 00:05:11 +0000401 PTR compat_sys_epoll_pwait
Ralf Baechle08253b32007-03-06 17:04:49 +0000402 PTR sys_ioprio_set
403 PTR sys_ioprio_get
Atsushi Nemoto7a6d4f32007-05-29 23:29:40 +0900404 PTR compat_sys_utimensat
David Daneye10c53a2010-07-29 13:43:04 -0700405 PTR compat_sys_signalfd /* 6280 */
Davide Libenzi4d672e72008-02-04 22:27:26 -0800406 PTR sys_ni_syscall
Atsushi Nemoto7a6d4f32007-05-29 23:29:40 +0900407 PTR sys_eventfd
Ralf Baechle4dc46772007-07-26 03:38:24 +0100408 PTR sys_fallocate
Dmitri Vorobiev6783fe62008-02-19 00:02:37 +0300409 PTR sys_timerfd_create
David Daneye10c53a2010-07-29 13:43:04 -0700410 PTR compat_sys_timerfd_gettime /* 6285 */
David Daneyc7d16732009-04-16 09:20:17 -0700411 PTR compat_sys_timerfd_settime
Ralf Baechle3885b712008-07-31 11:16:43 +0100412 PTR sys_signalfd4
413 PTR sys_eventfd2
414 PTR sys_epoll_create1
David Daneye10c53a2010-07-29 13:43:04 -0700415 PTR sys_dup3 /* 6290 */
Ralf Baechle3885b712008-07-31 11:16:43 +0100416 PTR sys_pipe2
417 PTR sys_inotify_init1
Ralf Baechleddd9e912009-04-02 16:59:24 -0700418 PTR sys_preadv
419 PTR sys_pwritev
David Daneye10c53a2010-07-29 13:43:04 -0700420 PTR compat_sys_rt_tgsigqueueinfo /* 6295 */
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200421 PTR sys_perf_event_open
Ralf Baechle54822de2009-08-03 17:27:19 +0100422 PTR sys_accept4
Arnaldo Carvalho de Meloa2e27252009-10-12 23:40:10 -0700423 PTR compat_sys_recvmmsg
Bernhard Wallee9fb4d82010-09-03 10:15:34 +0200424 PTR sys_getdents64
David Daney5e844b32010-08-23 14:10:37 -0700425 PTR sys_fanotify_init /* 6300 */
426 PTR sys_fanotify_mark
427 PTR sys_prlimit64
David Daney84ed9432011-03-18 10:37:23 -0700428 PTR sys_name_to_handle_at
429 PTR sys_open_by_handle_at
430 PTR compat_sys_clock_adjtime /* 6305 */
Ralf Baechle1bbf2872011-03-25 18:45:20 +0100431 PTR sys_syncfs
Ralf Baechle08253b32007-03-06 17:04:49 +0000432 .size sysn32_call_table,.-sysn32_call_table