Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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/config.h> |
| 11 | #include <linux/errno.h> |
| 12 | #include <asm/asm.h> |
| 13 | #include <asm/asmmacro.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 | /* 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 |
| 32 | NESTED(handle_sysn32, PT_SIZE, sp) |
| 33 | #ifndef CONFIG_MIPS32_O32 |
| 34 | .set noat |
| 35 | SAVE_SOME |
| 36 | STI |
| 37 | .set at |
| 38 | #endif |
| 39 | |
| 40 | dsubu t0, v0, __NR_N32_Linux # check syscall number |
| 41 | sltiu t0, t0, __NR_N32_Linux_syscalls + 1 |
| 42 | |
| 43 | #ifndef CONFIG_MIPS32_O32 |
| 44 | ld t1, PT_EPC(sp) # skip syscall on return |
| 45 | daddiu t1, 4 # skip to next instruction |
| 46 | sd t1, PT_EPC(sp) |
| 47 | #endif |
| 48 | beqz t0, not_n32_scall |
| 49 | |
| 50 | dsll t0, v0, 3 # offset into table |
| 51 | ld t2, (sysn32_call_table - (__NR_N32_Linux * 8))(t0) |
| 52 | |
| 53 | sd a3, PT_R26(sp) # save a3 for syscall restarting |
| 54 | |
| 55 | li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT |
| 56 | LONG_L t0, TI_FLAGS($28) # syscall tracing enabled? |
| 57 | and t0, t1, t0 |
| 58 | bnez t0, n32_syscall_trace_entry |
| 59 | |
| 60 | jalr t2 # Do The Real Thing (TM) |
| 61 | |
| 62 | li t0, -EMAXERRNO - 1 # error? |
| 63 | sltu t0, t0, v0 |
| 64 | sd t0, PT_R7(sp) # set error flag |
| 65 | beqz t0, 1f |
| 66 | |
| 67 | dnegu v0 # error |
| 68 | sd v0, PT_R0(sp) # set flag for syscall restarting |
| 69 | 1: sd v0, PT_R2(sp) # result |
| 70 | |
| 71 | local_irq_disable # make sure need_resched and |
| 72 | # signals dont change between |
| 73 | # sampling and return |
| 74 | LONG_L a2, TI_FLAGS($28) # current->work |
| 75 | li t0, _TIF_ALLWORK_MASK |
| 76 | and t0, a2, t0 |
| 77 | bnez t0, n32_syscall_exit_work |
| 78 | |
| 79 | j restore_partial |
| 80 | |
| 81 | n32_syscall_exit_work: |
| 82 | j syscall_exit_work_partial |
| 83 | |
| 84 | /* ------------------------------------------------------------------------ */ |
| 85 | |
| 86 | n32_syscall_trace_entry: |
| 87 | SAVE_STATIC |
| 88 | move s0, t2 |
| 89 | move a0, sp |
| 90 | li a1, 0 |
| 91 | jal do_syscall_trace |
| 92 | |
Ralf Baechle | 04a7052 | 2005-11-30 16:24:57 +0000 | [diff] [blame] | 93 | move t0, s0 |
| 94 | RESTORE_STATIC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | ld a0, PT_R4(sp) # Restore argument registers |
| 96 | ld a1, PT_R5(sp) |
| 97 | ld a2, PT_R6(sp) |
| 98 | ld a3, PT_R7(sp) |
| 99 | ld a4, PT_R8(sp) |
| 100 | ld a5, PT_R9(sp) |
Ralf Baechle | 04a7052 | 2005-11-30 16:24:57 +0000 | [diff] [blame] | 101 | jalr t0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
| 103 | li t0, -EMAXERRNO - 1 # error? |
| 104 | sltu t0, t0, v0 |
| 105 | sd t0, PT_R7(sp) # set error flag |
| 106 | beqz t0, 1f |
| 107 | |
| 108 | dnegu v0 # error |
| 109 | sd v0, PT_R0(sp) # set flag for syscall restarting |
| 110 | 1: sd v0, PT_R2(sp) # result |
| 111 | |
| 112 | j syscall_exit |
| 113 | |
| 114 | not_n32_scall: |
| 115 | /* This is not an n32 compatibility syscall, pass it on to |
| 116 | the n64 syscall handlers. */ |
| 117 | j handle_sys64 |
| 118 | |
| 119 | END(handle_sysn32) |
| 120 | |
| 121 | EXPORT(sysn32_call_table) |
| 122 | PTR sys_read /* 6000 */ |
| 123 | PTR sys_write |
| 124 | PTR sys_open |
| 125 | PTR sys_close |
| 126 | PTR sys_newstat |
| 127 | PTR sys_newfstat /* 6005 */ |
| 128 | PTR sys_newlstat |
| 129 | PTR sys_poll |
| 130 | PTR sys_lseek |
| 131 | PTR old_mmap |
| 132 | PTR sys_mprotect /* 6010 */ |
| 133 | PTR sys_munmap |
| 134 | PTR sys_brk |
| 135 | PTR sys32_rt_sigaction |
| 136 | PTR sys32_rt_sigprocmask |
| 137 | PTR compat_sys_ioctl /* 6015 */ |
| 138 | PTR sys_pread64 |
| 139 | PTR sys_pwrite64 |
| 140 | PTR compat_sys_readv |
| 141 | PTR compat_sys_writev |
| 142 | PTR sys_access /* 6020 */ |
| 143 | PTR sys_pipe |
| 144 | PTR compat_sys_select |
| 145 | PTR sys_sched_yield |
| 146 | PTR sys_mremap |
| 147 | PTR sys_msync /* 6025 */ |
| 148 | PTR sys_mincore |
| 149 | PTR sys_madvise |
| 150 | PTR sys_shmget |
| 151 | PTR sys32_shmat |
| 152 | PTR sys_shmctl /* 6030 */ |
| 153 | PTR sys_dup |
| 154 | PTR sys_dup2 |
| 155 | PTR sys_pause |
| 156 | PTR compat_sys_nanosleep |
| 157 | PTR compat_sys_getitimer /* 6035 */ |
| 158 | PTR compat_sys_setitimer |
| 159 | PTR sys_alarm |
| 160 | PTR sys_getpid |
| 161 | PTR sys32_sendfile |
| 162 | PTR sys_socket /* 6040 */ |
| 163 | PTR sys_connect |
| 164 | PTR sys_accept |
| 165 | PTR sys_sendto |
| 166 | PTR sys_recvfrom |
| 167 | PTR compat_sys_sendmsg /* 6045 */ |
| 168 | PTR compat_sys_recvmsg |
| 169 | PTR sys_shutdown |
| 170 | PTR sys_bind |
| 171 | PTR sys_listen |
| 172 | PTR sys_getsockname /* 6050 */ |
| 173 | PTR sys_getpeername |
| 174 | PTR sys_socketpair |
| 175 | PTR compat_sys_setsockopt |
| 176 | PTR sys_getsockopt |
| 177 | PTR sys_clone /* 6055 */ |
| 178 | PTR sys_fork |
| 179 | PTR sys32_execve |
| 180 | PTR sys_exit |
Ralf Baechle | b6e203d | 2005-02-16 21:18:52 +0000 | [diff] [blame] | 181 | PTR compat_sys_wait4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | PTR sys_kill /* 6060 */ |
| 183 | PTR sys32_newuname |
| 184 | PTR sys_semget |
| 185 | PTR sys_semop |
| 186 | PTR sys_semctl |
| 187 | PTR sys_shmdt /* 6065 */ |
| 188 | PTR sys_msgget |
| 189 | PTR sys_msgsnd |
| 190 | PTR sys_msgrcv |
| 191 | PTR sys_msgctl |
| 192 | PTR compat_sys_fcntl /* 6070 */ |
| 193 | PTR sys_flock |
| 194 | PTR sys_fsync |
| 195 | PTR sys_fdatasync |
| 196 | PTR sys_truncate |
| 197 | PTR sys_ftruncate /* 6075 */ |
Atsushi Nemoto | 2fd628f | 2006-02-21 15:59:00 +0900 | [diff] [blame] | 198 | PTR compat_sys_getdents |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | PTR sys_getcwd |
| 200 | PTR sys_chdir |
| 201 | PTR sys_fchdir |
| 202 | PTR sys_rename /* 6080 */ |
| 203 | PTR sys_mkdir |
| 204 | PTR sys_rmdir |
| 205 | PTR sys_creat |
| 206 | PTR sys_link |
| 207 | PTR sys_unlink /* 6085 */ |
| 208 | PTR sys_symlink |
| 209 | PTR sys_readlink |
| 210 | PTR sys_chmod |
| 211 | PTR sys_fchmod |
| 212 | PTR sys_chown /* 6090 */ |
| 213 | PTR sys_fchown |
| 214 | PTR sys_lchown |
| 215 | PTR sys_umask |
| 216 | PTR sys32_gettimeofday |
| 217 | PTR compat_sys_getrlimit /* 6095 */ |
| 218 | PTR compat_sys_getrusage |
| 219 | PTR sys32_sysinfo |
| 220 | PTR compat_sys_times |
Daniel Jacobowitz | ea3d710 | 2005-09-28 18:11:15 -0400 | [diff] [blame] | 221 | PTR sys32_ptrace |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | PTR sys_getuid /* 6100 */ |
| 223 | PTR sys_syslog |
| 224 | PTR sys_getgid |
| 225 | PTR sys_setuid |
| 226 | PTR sys_setgid |
| 227 | PTR sys_geteuid /* 6105 */ |
| 228 | PTR sys_getegid |
| 229 | PTR sys_setpgid |
| 230 | PTR sys_getppid |
| 231 | PTR sys_getpgrp |
| 232 | PTR sys_setsid /* 6110 */ |
| 233 | PTR sys_setreuid |
| 234 | PTR sys_setregid |
| 235 | PTR sys_getgroups |
| 236 | PTR sys_setgroups |
| 237 | PTR sys_setresuid /* 6115 */ |
| 238 | PTR sys_getresuid |
| 239 | PTR sys_setresgid |
| 240 | PTR sys_getresgid |
| 241 | PTR sys_getpgid |
| 242 | PTR sys_setfsuid /* 6120 */ |
| 243 | PTR sys_setfsgid |
| 244 | PTR sys_getsid |
| 245 | PTR sys_capget |
| 246 | PTR sys_capset |
| 247 | PTR sys32_rt_sigpending /* 6125 */ |
Ralf Baechle | 82ad93f | 2006-02-18 22:47:26 +0000 | [diff] [blame] | 248 | PTR compat_sys_rt_sigtimedwait |
Ralf Baechle | d1abb6a | 2005-02-16 21:25:03 +0000 | [diff] [blame] | 249 | PTR sys_rt_sigqueueinfo |
Ralf Baechle | 82ad93f | 2006-02-18 22:47:26 +0000 | [diff] [blame] | 250 | PTR sysn32_rt_sigsuspend |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | PTR sys32_sigaltstack |
| 252 | PTR compat_sys_utime /* 6130 */ |
| 253 | PTR sys_mknod |
| 254 | PTR sys32_personality |
Thiemo Seufer | cce812c | 2005-04-17 00:04:21 +0000 | [diff] [blame] | 255 | PTR sys32_ustat |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | PTR compat_sys_statfs |
| 257 | PTR compat_sys_fstatfs /* 6135 */ |
| 258 | PTR sys_sysfs |
| 259 | PTR sys_getpriority |
| 260 | PTR sys_setpriority |
| 261 | PTR sys_sched_setparam |
| 262 | PTR sys_sched_getparam /* 6140 */ |
| 263 | PTR sys_sched_setscheduler |
| 264 | PTR sys_sched_getscheduler |
| 265 | PTR sys_sched_get_priority_max |
| 266 | PTR sys_sched_get_priority_min |
| 267 | PTR sys32_sched_rr_get_interval /* 6145 */ |
| 268 | PTR sys_mlock |
| 269 | PTR sys_munlock |
| 270 | PTR sys_mlockall |
| 271 | PTR sys_munlockall |
| 272 | PTR sys_vhangup /* 6150 */ |
| 273 | PTR sys_pivot_root |
| 274 | PTR sys32_sysctl |
| 275 | PTR sys_prctl |
Stephen Rothwell | 3158e94 | 2006-03-26 01:37:29 -0800 | [diff] [blame^] | 276 | PTR compat_sys_adjtimex |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | PTR compat_sys_setrlimit /* 6155 */ |
| 278 | PTR sys_chroot |
| 279 | PTR sys_sync |
| 280 | PTR sys_acct |
| 281 | PTR sys32_settimeofday |
| 282 | PTR sys_mount /* 6160 */ |
| 283 | PTR sys_umount |
| 284 | PTR sys_swapon |
| 285 | PTR sys_swapoff |
| 286 | PTR sys_reboot |
| 287 | PTR sys_sethostname /* 6165 */ |
| 288 | PTR sys_setdomainname |
| 289 | PTR sys_ni_syscall /* was create_module */ |
| 290 | PTR sys_init_module |
| 291 | PTR sys_delete_module |
| 292 | PTR sys_ni_syscall /* 6170, was get_kernel_syms */ |
| 293 | PTR sys_ni_syscall /* was query_module */ |
| 294 | PTR sys_quotactl |
| 295 | PTR sys_nfsservctl |
| 296 | PTR sys_ni_syscall /* res. for getpmsg */ |
| 297 | PTR sys_ni_syscall /* 6175 for putpmsg */ |
| 298 | PTR sys_ni_syscall /* res. for afs_syscall */ |
| 299 | PTR sys_ni_syscall /* res. for security */ |
| 300 | PTR sys_gettid |
| 301 | PTR sys32_readahead |
| 302 | PTR sys_setxattr /* 6180 */ |
| 303 | PTR sys_lsetxattr |
| 304 | PTR sys_fsetxattr |
| 305 | PTR sys_getxattr |
| 306 | PTR sys_lgetxattr |
| 307 | PTR sys_fgetxattr /* 6185 */ |
| 308 | PTR sys_listxattr |
| 309 | PTR sys_llistxattr |
| 310 | PTR sys_flistxattr |
| 311 | PTR sys_removexattr |
| 312 | PTR sys_lremovexattr /* 6190 */ |
| 313 | PTR sys_fremovexattr |
| 314 | PTR sys_tkill |
| 315 | PTR sys_ni_syscall |
| 316 | PTR compat_sys_futex |
| 317 | PTR compat_sys_sched_setaffinity /* 6195 */ |
| 318 | PTR compat_sys_sched_getaffinity |
| 319 | PTR sys_cacheflush |
| 320 | PTR sys_cachectl |
| 321 | PTR sys_sysmips |
| 322 | PTR sys_io_setup /* 6200 */ |
| 323 | PTR sys_io_destroy |
| 324 | PTR sys_io_getevents |
| 325 | PTR sys_io_submit |
| 326 | PTR sys_io_cancel |
| 327 | PTR sys_exit_group /* 6205 */ |
| 328 | PTR sys_lookup_dcookie |
| 329 | PTR sys_epoll_create |
| 330 | PTR sys_epoll_ctl |
| 331 | PTR sys_epoll_wait |
| 332 | PTR sys_remap_file_pages /* 6210 */ |
| 333 | PTR sysn32_rt_sigreturn |
Thiemo Seufer | 589391a | 2005-04-13 09:11:22 +0000 | [diff] [blame] | 334 | PTR compat_sys_fcntl64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | PTR sys_set_tid_address |
| 336 | PTR sys_restart_syscall |
| 337 | PTR sys_semtimedop /* 6215 */ |
| 338 | PTR sys_fadvise64_64 |
| 339 | PTR compat_sys_statfs64 |
| 340 | PTR compat_sys_fstatfs64 |
| 341 | PTR sys_sendfile64 |
Ralf Baechle | d1abb6a | 2005-02-16 21:25:03 +0000 | [diff] [blame] | 342 | PTR sys32_timer_create /* 6220 */ |
| 343 | PTR compat_sys_timer_settime |
| 344 | PTR compat_sys_timer_gettime |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | PTR sys_timer_getoverrun |
| 346 | PTR sys_timer_delete |
Ralf Baechle | d1abb6a | 2005-02-16 21:25:03 +0000 | [diff] [blame] | 347 | PTR compat_sys_clock_settime /* 6225 */ |
| 348 | PTR compat_sys_clock_gettime |
| 349 | PTR compat_sys_clock_getres |
| 350 | PTR compat_sys_clock_nanosleep |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | PTR sys_tgkill |
| 352 | PTR compat_sys_utimes /* 6230 */ |
| 353 | PTR sys_ni_syscall /* sys_mbind */ |
| 354 | PTR sys_ni_syscall /* sys_get_mempolicy */ |
| 355 | PTR sys_ni_syscall /* sys_set_mempolicy */ |
| 356 | PTR compat_sys_mq_open |
| 357 | PTR sys_mq_unlink /* 6235 */ |
| 358 | PTR compat_sys_mq_timedsend |
| 359 | PTR compat_sys_mq_timedreceive |
| 360 | PTR compat_sys_mq_notify |
| 361 | PTR compat_sys_mq_getsetattr |
| 362 | PTR sys_ni_syscall /* 6240, sys_vserver */ |
Ralf Baechle | 54f2da7 | 2005-02-16 21:21:29 +0000 | [diff] [blame] | 363 | PTR sysn32_waitid |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | PTR sys_ni_syscall /* available, was setaltroot */ |
| 365 | PTR sys_add_key |
| 366 | PTR sys_request_key |
| 367 | PTR sys_keyctl /* 6245 */ |
Ralf Baechle | 3c37026 | 2005-04-13 17:43:59 +0000 | [diff] [blame] | 368 | PTR sys_set_thread_area |
Ralf Baechle | 8d9c626 | 2005-08-05 10:31:47 +0000 | [diff] [blame] | 369 | PTR sys_inotify_init |
| 370 | PTR sys_inotify_add_watch |
| 371 | PTR sys_inotify_rm_watch |
Ralf Baechle | 72bf891 | 2006-02-08 13:38:50 +0000 | [diff] [blame] | 372 | PTR sys_migrate_pages /* 6250 */ |
| 373 | PTR sys_openat |
| 374 | PTR sys_mkdirat |
| 375 | PTR sys_mknodat |
| 376 | PTR sys_fchownat |
| 377 | PTR sys_futimesat /* 6255 */ |
| 378 | PTR sys_newfstatat |
| 379 | PTR sys_unlinkat |
| 380 | PTR sys_renameat |
| 381 | PTR sys_linkat |
| 382 | PTR sys_symlinkat /* 6260 */ |
| 383 | PTR sys_readlinkat |
| 384 | PTR sys_fchmodat |
| 385 | PTR sys_faccessat |
| 386 | PTR sys_pselect6 |
| 387 | PTR sys_ppoll /* 6265 */ |
| 388 | PTR sys_unshare |