entry32.S 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 <linux/const.h>
  22. #include <asm/assembler.h>
  23. #include <asm/asm-offsets.h>
  24. #include <asm/errno.h>
  25. #include <asm/page.h>
  26. /*
  27. * System call wrappers for the AArch32 compatibility layer.
  28. */
  29. ENTRY(compat_sys_sigreturn_wrapper)
  30. mov x0, sp
  31. mov x27, #0 // prevent syscall restart handling (why)
  32. b compat_sys_sigreturn
  33. ENDPROC(compat_sys_sigreturn_wrapper)
  34. ENTRY(compat_sys_rt_sigreturn_wrapper)
  35. mov x0, sp
  36. mov x27, #0 // prevent syscall restart handling (why)
  37. b compat_sys_rt_sigreturn
  38. ENDPROC(compat_sys_rt_sigreturn_wrapper)
  39. ENTRY(compat_sys_statfs64_wrapper)
  40. mov w3, #84
  41. cmp w1, #88
  42. csel w1, w3, w1, eq
  43. b compat_sys_statfs64
  44. ENDPROC(compat_sys_statfs64_wrapper)
  45. ENTRY(compat_sys_fstatfs64_wrapper)
  46. mov w3, #84
  47. cmp w1, #88
  48. csel w1, w3, w1, eq
  49. b compat_sys_fstatfs64
  50. ENDPROC(compat_sys_fstatfs64_wrapper)
  51. /*
  52. * Note: off_4k (w5) is always in units of 4K. If we can't do the
  53. * requested offset because it is not page-aligned, we return -EINVAL.
  54. */
  55. ENTRY(compat_sys_mmap2_wrapper)
  56. #if PAGE_SHIFT > 12
  57. tst w5, #~PAGE_MASK >> 12
  58. b.ne 1f
  59. lsr w5, w5, #PAGE_SHIFT - 12
  60. #endif
  61. b sys_mmap_pgoff
  62. 1: mov x0, #-EINVAL
  63. ret
  64. ENDPROC(compat_sys_mmap2_wrapper)
  65. /*
  66. * Wrappers for AArch32 syscalls that either take 64-bit parameters
  67. * in registers or that take 32-bit parameters which require sign
  68. * extension.
  69. */
  70. ENTRY(compat_sys_pread64_wrapper)
  71. regs_to_64 x3, x4, x5
  72. b sys_pread64
  73. ENDPROC(compat_sys_pread64_wrapper)
  74. ENTRY(compat_sys_pwrite64_wrapper)
  75. regs_to_64 x3, x4, x5
  76. b sys_pwrite64
  77. ENDPROC(compat_sys_pwrite64_wrapper)
  78. ENTRY(compat_sys_truncate64_wrapper)
  79. regs_to_64 x1, x2, x3
  80. b sys_truncate
  81. ENDPROC(compat_sys_truncate64_wrapper)
  82. ENTRY(compat_sys_ftruncate64_wrapper)
  83. regs_to_64 x1, x2, x3
  84. b sys_ftruncate
  85. ENDPROC(compat_sys_ftruncate64_wrapper)
  86. ENTRY(compat_sys_readahead_wrapper)
  87. regs_to_64 x1, x2, x3
  88. mov w2, w4
  89. b sys_readahead
  90. ENDPROC(compat_sys_readahead_wrapper)
  91. ENTRY(compat_sys_fadvise64_64_wrapper)
  92. mov w6, w1
  93. regs_to_64 x1, x2, x3
  94. regs_to_64 x2, x4, x5
  95. mov w3, w6
  96. b sys_fadvise64_64
  97. ENDPROC(compat_sys_fadvise64_64_wrapper)
  98. ENTRY(compat_sys_sync_file_range2_wrapper)
  99. regs_to_64 x2, x2, x3
  100. regs_to_64 x3, x4, x5
  101. b sys_sync_file_range2
  102. ENDPROC(compat_sys_sync_file_range2_wrapper)
  103. ENTRY(compat_sys_fallocate_wrapper)
  104. regs_to_64 x2, x2, x3
  105. regs_to_64 x3, x4, x5
  106. b sys_fallocate
  107. ENDPROC(compat_sys_fallocate_wrapper)