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