sigreturn_codes.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * sigreturn_codes.S - code sinpets for sigreturn syscalls
  3. *
  4. * Created by: Victor Kamensky, 2013-08-13
  5. * Copyright: (C) 2013 Linaro Limited
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #include <asm/unistd.h>
  17. /*
  18. * For ARM syscalls, we encode the syscall number into the instruction.
  19. * With EABI, the syscall number has to be loaded into r7. As result
  20. * ARM syscall sequence snippet will have move and svc in .arm encoding
  21. *
  22. * For Thumb syscalls, we pass the syscall number via r7. We therefore
  23. * need two 16-bit instructions in .thumb encoding
  24. *
  25. * Please note sigreturn_codes code are not executed in place. Instead
  26. * they just copied by kernel into appropriate places. Code inside of
  27. * arch/arm/kernel/signal.c is very sensitive to layout of these code
  28. * snippets.
  29. */
  30. /*
  31. * In CPU_THUMBONLY case kernel arm opcodes are not allowed.
  32. * Note in this case codes skips those instructions but it uses .org
  33. * directive to keep correct layout of sigreturn_codes array.
  34. */
  35. #ifndef CONFIG_CPU_THUMBONLY
  36. #define ARM_OK(code...) code
  37. #else
  38. #define ARM_OK(code...)
  39. #endif
  40. .macro arm_slot n
  41. .org sigreturn_codes + 12 * (\n)
  42. ARM_OK( .arm )
  43. .endm
  44. .macro thumb_slot n
  45. .org sigreturn_codes + 12 * (\n) + 8
  46. .thumb
  47. .endm
  48. #if __LINUX_ARM_ARCH__ <= 4
  49. /*
  50. * Note we manually set minimally required arch that supports
  51. * required thumb opcodes for early arch versions. It is OK
  52. * for this file to be used in combination with other
  53. * lower arch variants, since these code snippets are only
  54. * used as input data.
  55. */
  56. .arch armv4t
  57. #endif
  58. .section .rodata
  59. .global sigreturn_codes
  60. .type sigreturn_codes, #object
  61. .align
  62. sigreturn_codes:
  63. /* ARM sigreturn syscall code snippet */
  64. arm_slot 0
  65. ARM_OK( mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE) )
  66. ARM_OK( swi #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
  67. /* Thumb sigreturn syscall code snippet */
  68. thumb_slot 0
  69. movs r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
  70. swi #0
  71. /* ARM sigreturn_rt syscall code snippet */
  72. arm_slot 1
  73. ARM_OK( mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE) )
  74. ARM_OK( swi #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
  75. /* Thumb sigreturn_rt syscall code snippet */
  76. thumb_slot 1
  77. movs r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
  78. swi #0
  79. /*
  80. * Note on addtional space: setup_return in signal.c
  81. * algorithm uses two words copy regardless whether
  82. * it is thumb case or not, so we need additional
  83. * word after real last entry.
  84. */
  85. arm_slot 2
  86. .space 4
  87. .size sigreturn_codes, . - sigreturn_codes