sys32.S 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /*
  2. * Compat system call wrappers
  3. *
  4. * Copyright (C) 2012 ARM Ltd.
  5. * Authors: Will Deacon <will.deacon@arm.com>
  6. * Catalin Marinas <catalin.marinas@arm.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <linux/linkage.h>
  21. #include <asm/assembler.h>
  22. #include <asm/asm-offsets.h>
  23. /*
  24. * System call wrappers for the AArch32 compatibility layer.
  25. */
  26. compat_sys_fork_wrapper:
  27. mov x0, sp
  28. b compat_sys_fork
  29. ENDPROC(compat_sys_fork_wrapper)
  30. compat_sys_vfork_wrapper:
  31. mov x0, sp
  32. b compat_sys_vfork
  33. ENDPROC(compat_sys_vfork_wrapper)
  34. compat_sys_execve_wrapper:
  35. mov x3, sp
  36. b compat_sys_execve
  37. ENDPROC(compat_sys_execve_wrapper)
  38. compat_sys_clone_wrapper:
  39. mov x5, sp
  40. b compat_sys_clone
  41. ENDPROC(compat_sys_clone_wrapper)
  42. compat_sys_sigreturn_wrapper:
  43. mov x0, sp
  44. mov x27, #0 // prevent syscall restart handling (why)
  45. b compat_sys_sigreturn
  46. ENDPROC(compat_sys_sigreturn_wrapper)
  47. compat_sys_rt_sigreturn_wrapper:
  48. mov x0, sp
  49. mov x27, #0 // prevent syscall restart handling (why)
  50. b compat_sys_rt_sigreturn
  51. ENDPROC(compat_sys_rt_sigreturn_wrapper)
  52. compat_sys_sigaltstack_wrapper:
  53. ldr x2, [sp, #S_COMPAT_SP]
  54. b compat_do_sigaltstack
  55. ENDPROC(compat_sys_sigaltstack_wrapper)
  56. compat_sys_statfs64_wrapper:
  57. mov w3, #84
  58. cmp w1, #88
  59. csel w1, w3, w1, eq
  60. b compat_sys_statfs64
  61. ENDPROC(compat_sys_statfs64_wrapper)
  62. compat_sys_fstatfs64_wrapper:
  63. mov w3, #84
  64. cmp w1, #88
  65. csel w1, w3, w1, eq
  66. b compat_sys_fstatfs64
  67. ENDPROC(compat_sys_fstatfs64_wrapper)
  68. /*
  69. * Wrappers for AArch32 syscalls that either take 64-bit parameters
  70. * in registers or that take 32-bit parameters which require sign
  71. * extension.
  72. */
  73. compat_sys_lseek_wrapper:
  74. sxtw x1, w1
  75. b sys_lseek
  76. ENDPROC(compat_sys_lseek_wrapper)
  77. compat_sys_pread64_wrapper:
  78. orr x3, x4, x5, lsl #32
  79. b sys_pread64
  80. ENDPROC(compat_sys_pread64_wrapper)
  81. compat_sys_pwrite64_wrapper:
  82. orr x3, x4, x5, lsl #32
  83. b sys_pwrite64
  84. ENDPROC(compat_sys_pwrite64_wrapper)
  85. compat_sys_truncate64_wrapper:
  86. orr x1, x2, x3, lsl #32
  87. b sys_truncate
  88. ENDPROC(compat_sys_truncate64_wrapper)
  89. compat_sys_ftruncate64_wrapper:
  90. orr x1, x2, x3, lsl #32
  91. b sys_ftruncate
  92. ENDPROC(compat_sys_ftruncate64_wrapper)
  93. compat_sys_readahead_wrapper:
  94. orr x1, x2, x3, lsl #32
  95. mov w2, w4
  96. b sys_readahead
  97. ENDPROC(compat_sys_readahead_wrapper)
  98. compat_sys_lookup_dcookie:
  99. orr x0, x0, x1, lsl #32
  100. mov w1, w2
  101. mov w2, w3
  102. b sys_lookup_dcookie
  103. ENDPROC(compat_sys_lookup_dcookie)
  104. compat_sys_fadvise64_64_wrapper:
  105. mov w6, w1
  106. orr x1, x2, x3, lsl #32
  107. orr x2, x4, x5, lsl #32
  108. mov w3, w6
  109. b sys_fadvise64_64
  110. ENDPROC(compat_sys_fadvise64_64_wrapper)
  111. compat_sys_sync_file_range2_wrapper:
  112. orr x2, x2, x3, lsl #32
  113. orr x3, x4, x5, lsl #32
  114. b sys_sync_file_range2
  115. ENDPROC(compat_sys_sync_file_range2_wrapper)
  116. compat_sys_fallocate_wrapper:
  117. orr x2, x2, x3, lsl #32
  118. orr x3, x4, x5, lsl #32
  119. b sys_fallocate
  120. ENDPROC(compat_sys_fallocate_wrapper)
  121. compat_sys_fanotify_mark_wrapper:
  122. orr x2, x2, x3, lsl #32
  123. mov w3, w4
  124. mov w4, w5
  125. b sys_fanotify_mark
  126. ENDPROC(compat_sys_fanotify_mark_wrapper)
  127. /*
  128. * Use the compat system call wrappers.
  129. */
  130. #define sys_fork compat_sys_fork_wrapper
  131. #define sys_open compat_sys_open
  132. #define sys_execve compat_sys_execve_wrapper
  133. #define sys_lseek compat_sys_lseek_wrapper
  134. #define sys_mount compat_sys_mount
  135. #define sys_ptrace compat_sys_ptrace
  136. #define sys_times compat_sys_times
  137. #define sys_ioctl compat_sys_ioctl
  138. #define sys_fcntl compat_sys_fcntl
  139. #define sys_ustat compat_sys_ustat
  140. #define sys_sigaction compat_sys_sigaction
  141. #define sys_sigsuspend compat_sys_sigsuspend
  142. #define sys_sigpending compat_sys_sigpending
  143. #define sys_setrlimit compat_sys_setrlimit
  144. #define sys_getrusage compat_sys_getrusage
  145. #define sys_gettimeofday compat_sys_gettimeofday
  146. #define sys_settimeofday compat_sys_settimeofday
  147. #define sys_statfs compat_sys_statfs
  148. #define sys_fstatfs compat_sys_fstatfs
  149. #define sys_setitimer compat_sys_setitimer
  150. #define sys_getitimer compat_sys_getitimer
  151. #define sys_newstat compat_sys_newstat
  152. #define sys_newlstat compat_sys_newlstat
  153. #define sys_newfstat compat_sys_newfstat
  154. #define sys_wait4 compat_sys_wait4
  155. #define sys_sysinfo compat_sys_sysinfo
  156. #define sys_sigreturn compat_sys_sigreturn_wrapper
  157. #define sys_clone compat_sys_clone_wrapper
  158. #define sys_adjtimex compat_sys_adjtimex
  159. #define sys_sigprocmask compat_sys_sigprocmask
  160. #define sys_getdents compat_sys_getdents
  161. #define sys_select compat_sys_select
  162. #define sys_readv compat_sys_readv
  163. #define sys_writev compat_sys_writev
  164. #define sys_sysctl compat_sys_sysctl
  165. #define sys_sched_rr_get_interval compat_sys_sched_rr_get_interval
  166. #define sys_nanosleep compat_sys_nanosleep
  167. #define sys_rt_sigreturn compat_sys_rt_sigreturn_wrapper
  168. #define sys_rt_sigaction compat_sys_rt_sigaction
  169. #define sys_rt_sigprocmask compat_sys_rt_sigprocmask
  170. #define sys_rt_sigpending compat_sys_rt_sigpending
  171. #define sys_rt_sigtimedwait compat_sys_rt_sigtimedwait
  172. #define sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo
  173. #define sys_rt_sigsuspend compat_sys_rt_sigsuspend
  174. #define sys_pread64 compat_sys_pread64_wrapper
  175. #define sys_pwrite64 compat_sys_pwrite64_wrapper
  176. #define sys_sigaltstack compat_sys_sigaltstack_wrapper
  177. #define sys_sendfile compat_sys_sendfile
  178. #define sys_vfork compat_sys_vfork_wrapper
  179. #define sys_getrlimit compat_sys_getrlimit
  180. #define sys_mmap2 sys_mmap_pgoff
  181. #define sys_truncate64 compat_sys_truncate64_wrapper
  182. #define sys_ftruncate64 compat_sys_ftruncate64_wrapper
  183. #define sys_getdents64 compat_sys_getdents64
  184. #define sys_fcntl64 compat_sys_fcntl64
  185. #define sys_readahead compat_sys_readahead_wrapper
  186. #define sys_futex compat_sys_futex
  187. #define sys_sched_setaffinity compat_sys_sched_setaffinity
  188. #define sys_sched_getaffinity compat_sys_sched_getaffinity
  189. #define sys_io_setup compat_sys_io_setup
  190. #define sys_io_getevents compat_sys_io_getevents
  191. #define sys_io_submit compat_sys_io_submit
  192. #define sys_lookup_dcookie compat_sys_lookup_dcookie
  193. #define sys_timer_create compat_sys_timer_create
  194. #define sys_timer_settime compat_sys_timer_settime
  195. #define sys_timer_gettime compat_sys_timer_gettime
  196. #define sys_clock_settime compat_sys_clock_settime
  197. #define sys_clock_gettime compat_sys_clock_gettime
  198. #define sys_clock_getres compat_sys_clock_getres
  199. #define sys_clock_nanosleep compat_sys_clock_nanosleep
  200. #define sys_statfs64 compat_sys_statfs64_wrapper
  201. #define sys_fstatfs64 compat_sys_fstatfs64_wrapper
  202. #define sys_utimes compat_sys_utimes
  203. #define sys_fadvise64_64 compat_sys_fadvise64_64_wrapper
  204. #define sys_mq_open compat_sys_mq_open
  205. #define sys_mq_timedsend compat_sys_mq_timedsend
  206. #define sys_mq_timedreceive compat_sys_mq_timedreceive
  207. #define sys_mq_notify compat_sys_mq_notify
  208. #define sys_mq_getsetattr compat_sys_mq_getsetattr
  209. #define sys_waitid compat_sys_waitid
  210. #define sys_recv compat_sys_recv
  211. #define sys_recvfrom compat_sys_recvfrom
  212. #define sys_setsockopt compat_sys_setsockopt
  213. #define sys_getsockopt compat_sys_getsockopt
  214. #define sys_sendmsg compat_sys_sendmsg
  215. #define sys_recvmsg compat_sys_recvmsg
  216. #define sys_semctl compat_sys_semctl
  217. #define sys_msgsnd compat_sys_msgsnd
  218. #define sys_msgrcv compat_sys_msgrcv
  219. #define sys_msgctl compat_sys_msgctl
  220. #define sys_shmat compat_sys_shmat
  221. #define sys_shmctl compat_sys_shmctl
  222. #define sys_keyctl compat_sys_keyctl
  223. #define sys_semtimedop compat_sys_semtimedop
  224. #define sys_mbind compat_sys_mbind
  225. #define sys_get_mempolicy compat_sys_get_mempolicy
  226. #define sys_set_mempolicy compat_sys_set_mempolicy
  227. #define sys_openat compat_sys_openat
  228. #define sys_futimesat compat_sys_futimesat
  229. #define sys_pselect6 compat_sys_pselect6
  230. #define sys_ppoll compat_sys_ppoll
  231. #define sys_set_robust_list compat_sys_set_robust_list
  232. #define sys_get_robust_list compat_sys_get_robust_list
  233. #define sys_sync_file_range2 compat_sys_sync_file_range2_wrapper
  234. #define sys_vmsplice compat_sys_vmsplice
  235. #define sys_move_pages compat_sys_move_pages
  236. #define sys_epoll_pwait compat_sys_epoll_pwait
  237. #define sys_kexec_load compat_sys_kexec_load
  238. #define sys_utimensat compat_sys_utimensat
  239. #define sys_signalfd compat_sys_signalfd
  240. #define sys_fallocate compat_sys_fallocate_wrapper
  241. #define sys_timerfd_settime compat_sys_timerfd_settime
  242. #define sys_timerfd_gettime compat_sys_timerfd_gettime
  243. #define sys_signalfd4 compat_sys_signalfd4
  244. #define sys_preadv compat_sys_preadv
  245. #define sys_pwritev compat_sys_pwritev
  246. #define sys_rt_tgsigqueueinfo compat_sys_rt_tgsigqueueinfo
  247. #define sys_recvmmsg compat_sys_recvmmsg
  248. #define sys_fanotify_mark compat_sys_fanotify_mark_wrapper
  249. #undef __SYSCALL
  250. #define __SYSCALL(x, y) .quad y // x
  251. #define __SYSCALL_COMPAT
  252. /*
  253. * The system calls table must be 4KB aligned.
  254. */
  255. .align 12
  256. ENTRY(compat_sys_call_table)
  257. #include <asm/unistd.h>