scall64-64.S 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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, 02 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/asm-offsets.h>
  18. #include <asm/sysmips.h>
  19. #include <asm/thread_info.h>
  20. #include <asm/unistd.h>
  21. #include <asm/war.h>
  22. #ifndef CONFIG_BINFMT_ELF32
  23. /* Neither O32 nor N32, so define handle_sys here */
  24. #define handle_sys64 handle_sys
  25. #endif
  26. .align 5
  27. NESTED(handle_sys64, PT_SIZE, sp)
  28. #if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32)
  29. /*
  30. * When 32-bit compatibility is configured scall_o32.S
  31. * already did this.
  32. */
  33. .set noat
  34. SAVE_SOME
  35. TRACE_IRQS_ON_RELOAD
  36. STI
  37. .set at
  38. #endif
  39. dsubu t0, v0, __NR_64_Linux # check syscall number
  40. sltiu t0, t0, __NR_64_Linux_syscalls + 1
  41. #if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32)
  42. ld t1, PT_EPC(sp) # skip syscall on return
  43. daddiu t1, 4 # skip to next instruction
  44. sd t1, PT_EPC(sp)
  45. #endif
  46. beqz t0, illegal_syscall
  47. dsll t0, v0, 3 # offset into table
  48. ld t2, (sys_call_table - (__NR_64_Linux * 8))(t0)
  49. # syscall routine
  50. sd a3, PT_R26(sp) # save a3 for syscall restarting
  51. li t1, _TIF_WORK_SYSCALL_ENTRY
  52. LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
  53. and t0, t1, t0
  54. bnez t0, syscall_trace_entry
  55. jalr t2 # Do The Real Thing (TM)
  56. li t0, -EMAXERRNO - 1 # error?
  57. sltu t0, t0, v0
  58. sd t0, PT_R7(sp) # set error flag
  59. beqz t0, 1f
  60. ld t1, PT_R2(sp) # syscall number
  61. dnegu v0 # error
  62. sd t1, PT_R0(sp) # save it for syscall restarting
  63. 1: sd v0, PT_R2(sp) # result
  64. n64_syscall_exit:
  65. j syscall_exit_partial
  66. /* ------------------------------------------------------------------------ */
  67. syscall_trace_entry:
  68. SAVE_STATIC
  69. move s0, t2
  70. move a0, sp
  71. daddiu a1, v0, __NR_64_Linux
  72. jal syscall_trace_enter
  73. bltz v0, 2f # seccomp failed? Skip syscall
  74. move t0, s0
  75. RESTORE_STATIC
  76. ld a0, PT_R4(sp) # Restore argument registers
  77. ld a1, PT_R5(sp)
  78. ld a2, PT_R6(sp)
  79. ld a3, PT_R7(sp)
  80. ld a4, PT_R8(sp)
  81. ld a5, PT_R9(sp)
  82. jalr t0
  83. li t0, -EMAXERRNO - 1 # error?
  84. sltu t0, t0, v0
  85. sd t0, PT_R7(sp) # set error flag
  86. beqz t0, 1f
  87. ld t1, PT_R2(sp) # syscall number
  88. dnegu v0 # error
  89. sd t1, PT_R0(sp) # save it for syscall restarting
  90. 1: sd v0, PT_R2(sp) # result
  91. 2: j syscall_exit
  92. illegal_syscall:
  93. /* This also isn't a 64-bit syscall, throw an error. */
  94. li v0, ENOSYS # error
  95. sd v0, PT_R2(sp)
  96. li t0, 1 # set error flag
  97. sd t0, PT_R7(sp)
  98. j n64_syscall_exit
  99. END(handle_sys64)
  100. .align 3
  101. .type sys_call_table, @object
  102. EXPORT(sys_call_table)
  103. PTR sys_read /* 5000 */
  104. PTR sys_write
  105. PTR sys_open
  106. PTR sys_close
  107. PTR sys_newstat
  108. PTR sys_newfstat /* 5005 */
  109. PTR sys_newlstat
  110. PTR sys_poll
  111. PTR sys_lseek
  112. PTR sys_mips_mmap
  113. PTR sys_mprotect /* 5010 */
  114. PTR sys_munmap
  115. PTR sys_brk
  116. PTR sys_rt_sigaction
  117. PTR sys_rt_sigprocmask
  118. PTR sys_ioctl /* 5015 */
  119. PTR sys_pread64
  120. PTR sys_pwrite64
  121. PTR sys_readv
  122. PTR sys_writev
  123. PTR sys_access /* 5020 */
  124. PTR sysm_pipe
  125. PTR sys_select
  126. PTR sys_sched_yield
  127. PTR sys_mremap
  128. PTR sys_msync /* 5025 */
  129. PTR sys_mincore
  130. PTR sys_madvise
  131. PTR sys_shmget
  132. PTR sys_shmat
  133. PTR sys_shmctl /* 5030 */
  134. PTR sys_dup
  135. PTR sys_dup2
  136. PTR sys_pause
  137. PTR sys_nanosleep
  138. PTR sys_getitimer /* 5035 */
  139. PTR sys_setitimer
  140. PTR sys_alarm
  141. PTR sys_getpid
  142. PTR sys_sendfile64
  143. PTR sys_socket /* 5040 */
  144. PTR sys_connect
  145. PTR sys_accept
  146. PTR sys_sendto
  147. PTR sys_recvfrom
  148. PTR sys_sendmsg /* 5045 */
  149. PTR sys_recvmsg
  150. PTR sys_shutdown
  151. PTR sys_bind
  152. PTR sys_listen
  153. PTR sys_getsockname /* 5050 */
  154. PTR sys_getpeername
  155. PTR sys_socketpair
  156. PTR sys_setsockopt
  157. PTR sys_getsockopt
  158. PTR __sys_clone /* 5055 */
  159. PTR __sys_fork
  160. PTR sys_execve
  161. PTR sys_exit
  162. PTR sys_wait4
  163. PTR sys_kill /* 5060 */
  164. PTR sys_newuname
  165. PTR sys_semget
  166. PTR sys_semop
  167. PTR sys_semctl
  168. PTR sys_shmdt /* 5065 */
  169. PTR sys_msgget
  170. PTR sys_msgsnd
  171. PTR sys_msgrcv
  172. PTR sys_msgctl
  173. PTR sys_fcntl /* 5070 */
  174. PTR sys_flock
  175. PTR sys_fsync
  176. PTR sys_fdatasync
  177. PTR sys_truncate
  178. PTR sys_ftruncate /* 5075 */
  179. PTR sys_getdents
  180. PTR sys_getcwd
  181. PTR sys_chdir
  182. PTR sys_fchdir
  183. PTR sys_rename /* 5080 */
  184. PTR sys_mkdir
  185. PTR sys_rmdir
  186. PTR sys_creat
  187. PTR sys_link
  188. PTR sys_unlink /* 5085 */
  189. PTR sys_symlink
  190. PTR sys_readlink
  191. PTR sys_chmod
  192. PTR sys_fchmod
  193. PTR sys_chown /* 5090 */
  194. PTR sys_fchown
  195. PTR sys_lchown
  196. PTR sys_umask
  197. PTR sys_gettimeofday
  198. PTR sys_getrlimit /* 5095 */
  199. PTR sys_getrusage
  200. PTR sys_sysinfo
  201. PTR sys_times
  202. PTR sys_ptrace
  203. PTR sys_getuid /* 5100 */
  204. PTR sys_syslog
  205. PTR sys_getgid
  206. PTR sys_setuid
  207. PTR sys_setgid
  208. PTR sys_geteuid /* 5105 */
  209. PTR sys_getegid
  210. PTR sys_setpgid
  211. PTR sys_getppid
  212. PTR sys_getpgrp
  213. PTR sys_setsid /* 5110 */
  214. PTR sys_setreuid
  215. PTR sys_setregid
  216. PTR sys_getgroups
  217. PTR sys_setgroups
  218. PTR sys_setresuid /* 5115 */
  219. PTR sys_getresuid
  220. PTR sys_setresgid
  221. PTR sys_getresgid
  222. PTR sys_getpgid
  223. PTR sys_setfsuid /* 5120 */
  224. PTR sys_setfsgid
  225. PTR sys_getsid
  226. PTR sys_capget
  227. PTR sys_capset
  228. PTR sys_rt_sigpending /* 5125 */
  229. PTR sys_rt_sigtimedwait
  230. PTR sys_rt_sigqueueinfo
  231. PTR sys_rt_sigsuspend
  232. PTR sys_sigaltstack
  233. PTR sys_utime /* 5130 */
  234. PTR sys_mknod
  235. PTR sys_personality
  236. PTR sys_ustat
  237. PTR sys_statfs
  238. PTR sys_fstatfs /* 5135 */
  239. PTR sys_sysfs
  240. PTR sys_getpriority
  241. PTR sys_setpriority
  242. PTR sys_sched_setparam
  243. PTR sys_sched_getparam /* 5140 */
  244. PTR sys_sched_setscheduler
  245. PTR sys_sched_getscheduler
  246. PTR sys_sched_get_priority_max
  247. PTR sys_sched_get_priority_min
  248. PTR sys_sched_rr_get_interval /* 5145 */
  249. PTR sys_mlock
  250. PTR sys_munlock
  251. PTR sys_mlockall
  252. PTR sys_munlockall
  253. PTR sys_vhangup /* 5150 */
  254. PTR sys_pivot_root
  255. PTR sys_sysctl
  256. PTR sys_prctl
  257. PTR sys_adjtimex
  258. PTR sys_setrlimit /* 5155 */
  259. PTR sys_chroot
  260. PTR sys_sync
  261. PTR sys_acct
  262. PTR sys_settimeofday
  263. PTR sys_mount /* 5160 */
  264. PTR sys_umount
  265. PTR sys_swapon
  266. PTR sys_swapoff
  267. PTR sys_reboot
  268. PTR sys_sethostname /* 5165 */
  269. PTR sys_setdomainname
  270. PTR sys_ni_syscall /* was create_module */
  271. PTR sys_init_module
  272. PTR sys_delete_module
  273. PTR sys_ni_syscall /* 5170, was get_kernel_syms */
  274. PTR sys_ni_syscall /* was query_module */
  275. PTR sys_quotactl
  276. PTR sys_ni_syscall /* was nfsservctl */
  277. PTR sys_ni_syscall /* res. for getpmsg */
  278. PTR sys_ni_syscall /* 5175 for putpmsg */
  279. PTR sys_ni_syscall /* res. for afs_syscall */
  280. PTR sys_ni_syscall /* res. for security */
  281. PTR sys_gettid
  282. PTR sys_readahead
  283. PTR sys_setxattr /* 5180 */
  284. PTR sys_lsetxattr
  285. PTR sys_fsetxattr
  286. PTR sys_getxattr
  287. PTR sys_lgetxattr
  288. PTR sys_fgetxattr /* 5185 */
  289. PTR sys_listxattr
  290. PTR sys_llistxattr
  291. PTR sys_flistxattr
  292. PTR sys_removexattr
  293. PTR sys_lremovexattr /* 5190 */
  294. PTR sys_fremovexattr
  295. PTR sys_tkill
  296. PTR sys_ni_syscall
  297. PTR sys_futex
  298. PTR sys_sched_setaffinity /* 5195 */
  299. PTR sys_sched_getaffinity
  300. PTR sys_cacheflush
  301. PTR sys_cachectl
  302. PTR sys_sysmips
  303. PTR sys_io_setup /* 5200 */
  304. PTR sys_io_destroy
  305. PTR sys_io_getevents
  306. PTR sys_io_submit
  307. PTR sys_io_cancel
  308. PTR sys_exit_group /* 5205 */
  309. PTR sys_lookup_dcookie
  310. PTR sys_epoll_create
  311. PTR sys_epoll_ctl
  312. PTR sys_epoll_wait
  313. PTR sys_remap_file_pages /* 5210 */
  314. PTR sys_rt_sigreturn
  315. PTR sys_set_tid_address
  316. PTR sys_restart_syscall
  317. PTR sys_semtimedop
  318. PTR sys_fadvise64_64 /* 5215 */
  319. PTR sys_timer_create
  320. PTR sys_timer_settime
  321. PTR sys_timer_gettime
  322. PTR sys_timer_getoverrun
  323. PTR sys_timer_delete /* 5220 */
  324. PTR sys_clock_settime
  325. PTR sys_clock_gettime
  326. PTR sys_clock_getres
  327. PTR sys_clock_nanosleep
  328. PTR sys_tgkill /* 5225 */
  329. PTR sys_utimes
  330. PTR sys_mbind
  331. PTR sys_get_mempolicy
  332. PTR sys_set_mempolicy
  333. PTR sys_mq_open /* 5230 */
  334. PTR sys_mq_unlink
  335. PTR sys_mq_timedsend
  336. PTR sys_mq_timedreceive
  337. PTR sys_mq_notify
  338. PTR sys_mq_getsetattr /* 5235 */
  339. PTR sys_ni_syscall /* sys_vserver */
  340. PTR sys_waitid
  341. PTR sys_ni_syscall /* available, was setaltroot */
  342. PTR sys_add_key
  343. PTR sys_request_key /* 5240 */
  344. PTR sys_keyctl
  345. PTR sys_set_thread_area
  346. PTR sys_inotify_init
  347. PTR sys_inotify_add_watch
  348. PTR sys_inotify_rm_watch /* 5245 */
  349. PTR sys_migrate_pages
  350. PTR sys_openat
  351. PTR sys_mkdirat
  352. PTR sys_mknodat
  353. PTR sys_fchownat /* 5250 */
  354. PTR sys_futimesat
  355. PTR sys_newfstatat
  356. PTR sys_unlinkat
  357. PTR sys_renameat
  358. PTR sys_linkat /* 5255 */
  359. PTR sys_symlinkat
  360. PTR sys_readlinkat
  361. PTR sys_fchmodat
  362. PTR sys_faccessat
  363. PTR sys_pselect6 /* 5260 */
  364. PTR sys_ppoll
  365. PTR sys_unshare
  366. PTR sys_splice
  367. PTR sys_sync_file_range
  368. PTR sys_tee /* 5265 */
  369. PTR sys_vmsplice
  370. PTR sys_move_pages
  371. PTR sys_set_robust_list
  372. PTR sys_get_robust_list
  373. PTR sys_kexec_load /* 5270 */
  374. PTR sys_getcpu
  375. PTR sys_epoll_pwait
  376. PTR sys_ioprio_set
  377. PTR sys_ioprio_get
  378. PTR sys_utimensat /* 5275 */
  379. PTR sys_signalfd
  380. PTR sys_ni_syscall /* was timerfd */
  381. PTR sys_eventfd
  382. PTR sys_fallocate
  383. PTR sys_timerfd_create /* 5280 */
  384. PTR sys_timerfd_gettime
  385. PTR sys_timerfd_settime
  386. PTR sys_signalfd4
  387. PTR sys_eventfd2
  388. PTR sys_epoll_create1 /* 5285 */
  389. PTR sys_dup3
  390. PTR sys_pipe2
  391. PTR sys_inotify_init1
  392. PTR sys_preadv
  393. PTR sys_pwritev /* 5290 */
  394. PTR sys_rt_tgsigqueueinfo
  395. PTR sys_perf_event_open
  396. PTR sys_accept4
  397. PTR sys_recvmmsg
  398. PTR sys_fanotify_init /* 5295 */
  399. PTR sys_fanotify_mark
  400. PTR sys_prlimit64
  401. PTR sys_name_to_handle_at
  402. PTR sys_open_by_handle_at
  403. PTR sys_clock_adjtime /* 5300 */
  404. PTR sys_syncfs
  405. PTR sys_sendmmsg
  406. PTR sys_setns
  407. PTR sys_process_vm_readv
  408. PTR sys_process_vm_writev /* 5305 */
  409. PTR sys_kcmp
  410. PTR sys_finit_module
  411. PTR sys_getdents64
  412. PTR sys_sched_setattr
  413. PTR sys_sched_getattr /* 5310 */
  414. PTR sys_renameat2
  415. PTR sys_seccomp
  416. PTR sys_getrandom
  417. PTR sys_memfd_create
  418. PTR sys_bpf /* 5315 */
  419. PTR sys_execveat
  420. .size sys_call_table,.-sys_call_table