scall64-n32.S 10 KB

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