PageRenderTime 60ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/arch/mips/kernel/scall64-o32.S

https://bitbucket.org/cresqo/cm7-p500-kernel
Assembly | 542 lines | 516 code | 26 blank | 0 comment | 7 complexity | 4fcc25f671fc4d6d230aa2442e94ca6f MD5 | raw file
Possible License(s): LGPL-2.0, AGPL-1.0, GPL-2.0
  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 - 2000, 2001 by Ralf Baechle
  7. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  8. * Copyright (C) 2001 MIPS Technologies, Inc.
  9. * Copyright (C) 2004 Thiemo Seufer
  10. *
  11. * Hairy, the userspace application uses a different argument passing
  12. * convention than the kernel, so we have to translate things from o32
  13. * to ABI64 calling convention. 64-bit syscalls are also processed
  14. * here for now.
  15. */
  16. #include <linux/errno.h>
  17. #include <asm/asm.h>
  18. #include <asm/asmmacro.h>
  19. #include <asm/irqflags.h>
  20. #include <asm/mipsregs.h>
  21. #include <asm/regdef.h>
  22. #include <asm/stackframe.h>
  23. #include <asm/thread_info.h>
  24. #include <asm/unistd.h>
  25. #include <asm/sysmips.h>
  26. .align 5
  27. NESTED(handle_sys, PT_SIZE, sp)
  28. .set noat
  29. SAVE_SOME
  30. TRACE_IRQS_ON_RELOAD
  31. STI
  32. .set at
  33. ld t1, PT_EPC(sp) # skip syscall on return
  34. dsubu t0, v0, __NR_O32_Linux # check syscall number
  35. sltiu t0, t0, __NR_O32_Linux_syscalls + 1
  36. daddiu t1, 4 # skip to next instruction
  37. sd t1, PT_EPC(sp)
  38. beqz t0, not_o32_scall
  39. #if 0
  40. SAVE_ALL
  41. move a1, v0
  42. PRINT("Scall %ld\n")
  43. RESTORE_ALL
  44. #endif
  45. /* We don't want to stumble over broken sign extensions from
  46. userland. O32 does never use the upper half. */
  47. sll a0, a0, 0
  48. sll a1, a1, 0
  49. sll a2, a2, 0
  50. sll a3, a3, 0
  51. dsll t0, v0, 3 # offset into table
  52. ld t2, (sys_call_table - (__NR_O32_Linux * 8))(t0)
  53. sd a3, PT_R26(sp) # save a3 for syscall restarting
  54. /*
  55. * More than four arguments. Try to deal with it by copying the
  56. * stack arguments from the user stack to the kernel stack.
  57. * This Sucks (TM).
  58. *
  59. * We intentionally keep the kernel stack a little below the top of
  60. * userspace so we don't have to do a slower byte accurate check here.
  61. */
  62. ld t0, PT_R29(sp) # get old user stack pointer
  63. daddu t1, t0, 32
  64. bltz t1, bad_stack
  65. 1: lw a4, 16(t0) # argument #5 from usp
  66. 2: lw a5, 20(t0) # argument #6 from usp
  67. 3: lw a6, 24(t0) # argument #7 from usp
  68. 4: lw a7, 28(t0) # argument #8 from usp (for indirect syscalls)
  69. .section __ex_table,"a"
  70. PTR 1b, bad_stack
  71. PTR 2b, bad_stack
  72. PTR 3b, bad_stack
  73. PTR 4b, bad_stack
  74. .previous
  75. li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
  76. LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
  77. and t0, t1, t0
  78. bnez t0, trace_a_syscall
  79. jalr t2 # Do The Real Thing (TM)
  80. li t0, -EMAXERRNO - 1 # error?
  81. sltu t0, t0, v0
  82. sd t0, PT_R7(sp) # set error flag
  83. beqz t0, 1f
  84. dnegu v0 # error
  85. sd v0, PT_R0(sp) # flag for syscall restarting
  86. 1: sd v0, PT_R2(sp) # result
  87. o32_syscall_exit:
  88. local_irq_disable # make need_resched and
  89. # signals dont change between
  90. # sampling and return
  91. LONG_L a2, TI_FLAGS($28)
  92. li t0, _TIF_ALLWORK_MASK
  93. and t0, a2, t0
  94. bnez t0, o32_syscall_exit_work
  95. j restore_partial
  96. o32_syscall_exit_work:
  97. j syscall_exit_work_partial
  98. /* ------------------------------------------------------------------------ */
  99. trace_a_syscall:
  100. SAVE_STATIC
  101. sd a4, PT_R8(sp) # Save argument registers
  102. sd a5, PT_R9(sp)
  103. sd a6, PT_R10(sp)
  104. sd a7, PT_R11(sp) # For indirect syscalls
  105. move s0, t2 # Save syscall pointer
  106. move a0, sp
  107. li a1, 0
  108. jal do_syscall_trace
  109. move t0, s0
  110. RESTORE_STATIC
  111. ld a0, PT_R4(sp) # Restore argument registers
  112. ld a1, PT_R5(sp)
  113. ld a2, PT_R6(sp)
  114. ld a3, PT_R7(sp)
  115. ld a4, PT_R8(sp)
  116. ld a5, PT_R9(sp)
  117. ld a6, PT_R10(sp)
  118. ld a7, PT_R11(sp) # For indirect syscalls
  119. jalr t0
  120. li t0, -EMAXERRNO - 1 # error?
  121. sltu t0, t0, v0
  122. sd t0, PT_R7(sp) # set error flag
  123. beqz t0, 1f
  124. dnegu v0 # error
  125. sd v0, PT_R0(sp) # set flag for syscall restarting
  126. 1: sd v0, PT_R2(sp) # result
  127. j syscall_exit
  128. /* ------------------------------------------------------------------------ */
  129. /*
  130. * The stackpointer for a call with more than 4 arguments is bad.
  131. */
  132. bad_stack:
  133. dnegu v0 # error
  134. sd v0, PT_R0(sp)
  135. sd v0, PT_R2(sp)
  136. li t0, 1 # set error flag
  137. sd t0, PT_R7(sp)
  138. j o32_syscall_exit
  139. not_o32_scall:
  140. /*
  141. * This is not an o32 compatibility syscall, pass it on
  142. * to the 64-bit syscall handlers.
  143. */
  144. #ifdef CONFIG_MIPS32_N32
  145. j handle_sysn32
  146. #else
  147. j handle_sys64
  148. #endif
  149. END(handle_sys)
  150. LEAF(sys32_syscall)
  151. subu t0, a0, __NR_O32_Linux # check syscall number
  152. sltiu v0, t0, __NR_O32_Linux_syscalls + 1
  153. beqz t0, einval # do not recurse
  154. dsll t1, t0, 3
  155. beqz v0, einval
  156. ld t2, sys_call_table(t1) # syscall routine
  157. move a0, a1 # shift argument registers
  158. move a1, a2
  159. move a2, a3
  160. move a3, a4
  161. move a4, a5
  162. move a5, a6
  163. move a6, a7
  164. sd a0, PT_R4(sp) # ... and push back a0 - a3, some
  165. sd a1, PT_R5(sp) # syscalls expect them there
  166. sd a2, PT_R6(sp)
  167. sd a3, PT_R7(sp)
  168. sd a3, PT_R26(sp) # update a3 for syscall restarting
  169. jr t2
  170. /* Unreached */
  171. einval: li v0, -ENOSYS
  172. jr ra
  173. END(sys32_syscall)
  174. .align 3
  175. .type sys_call_table,@object
  176. sys_call_table:
  177. PTR sys32_syscall /* 4000 */
  178. PTR sys_exit
  179. PTR sys_fork
  180. PTR sys_read
  181. PTR sys_write
  182. PTR compat_sys_open /* 4005 */
  183. PTR sys_close
  184. PTR sys_waitpid
  185. PTR sys_creat
  186. PTR sys_link
  187. PTR sys_unlink /* 4010 */
  188. PTR sys32_execve
  189. PTR sys_chdir
  190. PTR compat_sys_time
  191. PTR sys_mknod
  192. PTR sys_chmod /* 4015 */
  193. PTR sys_lchown
  194. PTR sys_ni_syscall
  195. PTR sys_ni_syscall /* was sys_stat */
  196. PTR sys_lseek
  197. PTR sys_getpid /* 4020 */
  198. PTR compat_sys_mount
  199. PTR sys_oldumount
  200. PTR sys_setuid
  201. PTR sys_getuid
  202. PTR compat_sys_stime /* 4025 */
  203. PTR compat_sys_ptrace
  204. PTR sys_alarm
  205. PTR sys_ni_syscall /* was sys_fstat */
  206. PTR sys_pause
  207. PTR compat_sys_utime /* 4030 */
  208. PTR sys_ni_syscall
  209. PTR sys_ni_syscall
  210. PTR sys_access
  211. PTR sys_nice
  212. PTR sys_ni_syscall /* 4035 */
  213. PTR sys_sync
  214. PTR sys_kill
  215. PTR sys_rename
  216. PTR sys_mkdir
  217. PTR sys_rmdir /* 4040 */
  218. PTR sys_dup
  219. PTR sysm_pipe
  220. PTR compat_sys_times
  221. PTR sys_ni_syscall
  222. PTR sys_brk /* 4045 */
  223. PTR sys_setgid
  224. PTR sys_getgid
  225. PTR sys_ni_syscall /* was signal 2 */
  226. PTR sys_geteuid
  227. PTR sys_getegid /* 4050 */
  228. PTR sys_acct
  229. PTR sys_umount
  230. PTR sys_ni_syscall
  231. PTR compat_sys_ioctl
  232. PTR compat_sys_fcntl /* 4055 */
  233. PTR sys_ni_syscall
  234. PTR sys_setpgid
  235. PTR sys_ni_syscall
  236. PTR sys_olduname
  237. PTR sys_umask /* 4060 */
  238. PTR sys_chroot
  239. PTR compat_sys_ustat
  240. PTR sys_dup2
  241. PTR sys_getppid
  242. PTR sys_getpgrp /* 4065 */
  243. PTR sys_setsid
  244. PTR sys_32_sigaction
  245. PTR sys_sgetmask
  246. PTR sys_ssetmask
  247. PTR sys_setreuid /* 4070 */
  248. PTR sys_setregid
  249. PTR sys32_sigsuspend
  250. PTR compat_sys_sigpending
  251. PTR sys_sethostname
  252. PTR compat_sys_setrlimit /* 4075 */
  253. PTR compat_sys_getrlimit
  254. PTR compat_sys_getrusage
  255. PTR compat_sys_gettimeofday
  256. PTR compat_sys_settimeofday
  257. PTR sys_getgroups /* 4080 */
  258. PTR sys_setgroups
  259. PTR sys_ni_syscall /* old_select */
  260. PTR sys_symlink
  261. PTR sys_ni_syscall /* was sys_lstat */
  262. PTR sys_readlink /* 4085 */
  263. PTR sys_uselib
  264. PTR sys_swapon
  265. PTR sys_reboot
  266. PTR compat_sys_old_readdir
  267. PTR sys_mips_mmap /* 4090 */
  268. PTR sys_munmap
  269. PTR sys_truncate
  270. PTR sys_ftruncate
  271. PTR sys_fchmod
  272. PTR sys_fchown /* 4095 */
  273. PTR sys_getpriority
  274. PTR sys_setpriority
  275. PTR sys_ni_syscall
  276. PTR compat_sys_statfs
  277. PTR compat_sys_fstatfs /* 4100 */
  278. PTR sys_ni_syscall /* sys_ioperm */
  279. PTR compat_sys_socketcall
  280. PTR sys_syslog
  281. PTR compat_sys_setitimer
  282. PTR compat_sys_getitimer /* 4105 */
  283. PTR compat_sys_newstat
  284. PTR compat_sys_newlstat
  285. PTR compat_sys_newfstat
  286. PTR sys_uname
  287. PTR sys_ni_syscall /* sys_ioperm *//* 4110 */
  288. PTR sys_vhangup
  289. PTR sys_ni_syscall /* was sys_idle */
  290. PTR sys_ni_syscall /* sys_vm86 */
  291. PTR compat_sys_wait4
  292. PTR sys_swapoff /* 4115 */
  293. PTR compat_sys_sysinfo
  294. PTR sys_32_ipc
  295. PTR sys_fsync
  296. PTR sys32_sigreturn
  297. PTR sys32_clone /* 4120 */
  298. PTR sys_setdomainname
  299. PTR sys_newuname
  300. PTR sys_ni_syscall /* sys_modify_ldt */
  301. PTR compat_sys_adjtimex
  302. PTR sys_mprotect /* 4125 */
  303. PTR compat_sys_sigprocmask
  304. PTR sys_ni_syscall /* was creat_module */
  305. PTR sys_init_module
  306. PTR sys_delete_module
  307. PTR sys_ni_syscall /* 4130, get_kernel_syms */
  308. PTR sys_quotactl
  309. PTR sys_getpgid
  310. PTR sys_fchdir
  311. PTR sys_bdflush
  312. PTR sys_sysfs /* 4135 */
  313. PTR sys_32_personality
  314. PTR sys_ni_syscall /* for afs_syscall */
  315. PTR sys_setfsuid
  316. PTR sys_setfsgid
  317. PTR sys_32_llseek /* 4140 */
  318. PTR compat_sys_getdents
  319. PTR compat_sys_select
  320. PTR sys_flock
  321. PTR sys_msync
  322. PTR compat_sys_readv /* 4145 */
  323. PTR compat_sys_writev
  324. PTR sys_cacheflush
  325. PTR sys_cachectl
  326. PTR sys_sysmips
  327. PTR sys_ni_syscall /* 4150 */
  328. PTR sys_getsid
  329. PTR sys_fdatasync
  330. PTR compat_sys_sysctl
  331. PTR sys_mlock
  332. PTR sys_munlock /* 4155 */
  333. PTR sys_mlockall
  334. PTR sys_munlockall
  335. PTR sys_sched_setparam
  336. PTR sys_sched_getparam
  337. PTR sys_sched_setscheduler /* 4160 */
  338. PTR sys_sched_getscheduler
  339. PTR sys_sched_yield
  340. PTR sys_sched_get_priority_max
  341. PTR sys_sched_get_priority_min
  342. PTR sys_32_sched_rr_get_interval /* 4165 */
  343. PTR compat_sys_nanosleep
  344. PTR sys_mremap
  345. PTR sys_accept
  346. PTR sys_bind
  347. PTR sys_connect /* 4170 */
  348. PTR sys_getpeername
  349. PTR sys_getsockname
  350. PTR sys_getsockopt
  351. PTR sys_listen
  352. PTR compat_sys_recv /* 4175 */
  353. PTR compat_sys_recvfrom
  354. PTR compat_sys_recvmsg
  355. PTR sys_send
  356. PTR compat_sys_sendmsg
  357. PTR sys_sendto /* 4180 */
  358. PTR compat_sys_setsockopt
  359. PTR sys_shutdown
  360. PTR sys_socket
  361. PTR sys_socketpair
  362. PTR sys_setresuid /* 4185 */
  363. PTR sys_getresuid
  364. PTR sys_ni_syscall /* was query_module */
  365. PTR sys_poll
  366. PTR compat_sys_nfsservctl
  367. PTR sys_setresgid /* 4190 */
  368. PTR sys_getresgid
  369. PTR sys_prctl
  370. PTR sys32_rt_sigreturn
  371. PTR sys_32_rt_sigaction
  372. PTR sys_32_rt_sigprocmask /* 4195 */
  373. PTR sys_32_rt_sigpending
  374. PTR compat_sys_rt_sigtimedwait
  375. PTR sys_32_rt_sigqueueinfo
  376. PTR sys32_rt_sigsuspend
  377. PTR sys_32_pread /* 4200 */
  378. PTR sys_32_pwrite
  379. PTR sys_chown
  380. PTR sys_getcwd
  381. PTR sys_capget
  382. PTR sys_capset /* 4205 */
  383. PTR sys32_sigaltstack
  384. PTR sys_32_sendfile
  385. PTR sys_ni_syscall
  386. PTR sys_ni_syscall
  387. PTR sys_mips_mmap2 /* 4210 */
  388. PTR sys_32_truncate64
  389. PTR sys_32_ftruncate64
  390. PTR sys_newstat
  391. PTR sys_newlstat
  392. PTR sys_newfstat /* 4215 */
  393. PTR sys_pivot_root
  394. PTR sys_mincore
  395. PTR sys_madvise
  396. PTR sys_getdents64
  397. PTR compat_sys_fcntl64 /* 4220 */
  398. PTR sys_ni_syscall
  399. PTR sys_gettid
  400. PTR sys32_readahead
  401. PTR sys_setxattr
  402. PTR sys_lsetxattr /* 4225 */
  403. PTR sys_fsetxattr
  404. PTR sys_getxattr
  405. PTR sys_lgetxattr
  406. PTR sys_fgetxattr
  407. PTR sys_listxattr /* 4230 */
  408. PTR sys_llistxattr
  409. PTR sys_flistxattr
  410. PTR sys_removexattr
  411. PTR sys_lremovexattr
  412. PTR sys_fremovexattr /* 4235 */
  413. PTR sys_tkill
  414. PTR sys_sendfile64
  415. PTR compat_sys_futex
  416. PTR compat_sys_sched_setaffinity
  417. PTR compat_sys_sched_getaffinity /* 4240 */
  418. PTR sys_io_setup
  419. PTR sys_io_destroy
  420. PTR sys_io_getevents
  421. PTR sys_io_submit
  422. PTR sys_io_cancel /* 4245 */
  423. PTR sys_exit_group
  424. PTR sys32_lookup_dcookie
  425. PTR sys_epoll_create
  426. PTR sys_epoll_ctl
  427. PTR sys_epoll_wait /* 4250 */
  428. PTR sys_remap_file_pages
  429. PTR sys_set_tid_address
  430. PTR sys_restart_syscall
  431. PTR sys32_fadvise64_64
  432. PTR compat_sys_statfs64 /* 4255 */
  433. PTR compat_sys_fstatfs64
  434. PTR compat_sys_timer_create
  435. PTR compat_sys_timer_settime
  436. PTR compat_sys_timer_gettime
  437. PTR sys_timer_getoverrun /* 4260 */
  438. PTR sys_timer_delete
  439. PTR compat_sys_clock_settime
  440. PTR compat_sys_clock_gettime
  441. PTR compat_sys_clock_getres
  442. PTR compat_sys_clock_nanosleep /* 4265 */
  443. PTR sys_tgkill
  444. PTR compat_sys_utimes
  445. PTR sys_ni_syscall /* sys_mbind */
  446. PTR sys_ni_syscall /* sys_get_mempolicy */
  447. PTR sys_ni_syscall /* 4270 sys_set_mempolicy */
  448. PTR compat_sys_mq_open
  449. PTR sys_mq_unlink
  450. PTR compat_sys_mq_timedsend
  451. PTR compat_sys_mq_timedreceive
  452. PTR compat_sys_mq_notify /* 4275 */
  453. PTR compat_sys_mq_getsetattr
  454. PTR sys_ni_syscall /* sys_vserver */
  455. PTR sys_32_waitid
  456. PTR sys_ni_syscall /* available, was setaltroot */
  457. PTR sys_add_key /* 4280 */
  458. PTR sys_request_key
  459. PTR sys_keyctl
  460. PTR sys_set_thread_area
  461. PTR sys_inotify_init
  462. PTR sys_inotify_add_watch /* 4285 */
  463. PTR sys_inotify_rm_watch
  464. PTR sys_migrate_pages
  465. PTR compat_sys_openat
  466. PTR sys_mkdirat
  467. PTR sys_mknodat /* 4290 */
  468. PTR sys_fchownat
  469. PTR compat_sys_futimesat
  470. PTR sys_newfstatat
  471. PTR sys_unlinkat
  472. PTR sys_renameat /* 4295 */
  473. PTR sys_linkat
  474. PTR sys_symlinkat
  475. PTR sys_readlinkat
  476. PTR sys_fchmodat
  477. PTR sys_faccessat /* 4300 */
  478. PTR compat_sys_pselect6
  479. PTR compat_sys_ppoll
  480. PTR sys_unshare
  481. PTR sys_splice
  482. PTR sys32_sync_file_range /* 4305 */
  483. PTR sys_tee
  484. PTR compat_sys_vmsplice
  485. PTR compat_sys_move_pages
  486. PTR compat_sys_set_robust_list
  487. PTR compat_sys_get_robust_list /* 4310 */
  488. PTR compat_sys_kexec_load
  489. PTR sys_getcpu
  490. PTR compat_sys_epoll_pwait
  491. PTR sys_ioprio_set
  492. PTR sys_ioprio_get /* 4315 */
  493. PTR compat_sys_utimensat
  494. PTR compat_sys_signalfd
  495. PTR sys_ni_syscall
  496. PTR sys_eventfd
  497. PTR sys32_fallocate /* 4320 */
  498. PTR sys_timerfd_create
  499. PTR compat_sys_timerfd_gettime
  500. PTR compat_sys_timerfd_settime
  501. PTR compat_sys_signalfd4
  502. PTR sys_eventfd2 /* 4325 */
  503. PTR sys_epoll_create1
  504. PTR sys_dup3
  505. PTR sys_pipe2
  506. PTR sys_inotify_init1
  507. PTR compat_sys_preadv /* 4330 */
  508. PTR compat_sys_pwritev
  509. PTR compat_sys_rt_tgsigqueueinfo
  510. PTR sys_perf_event_open
  511. PTR sys_accept4
  512. PTR compat_sys_recvmmsg
  513. .size sys_call_table,.-sys_call_table