2 * sigreturn_codes.S - code sinpets for sigreturn syscalls
4 * Created by: Victor Kamensky, 2013-08-13
5 * Copyright: (C) 2013 Linaro Limited
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.
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.
17 #include <asm/assembler.h>
18 #include <asm/asm-offsets.h>
19 #include <asm/unistd.h>
22 * For ARM syscalls, we encode the syscall number into the instruction.
23 * With EABI, the syscall number has to be loaded into r7. As result
24 * ARM syscall sequence snippet will have move and svc in .arm encoding
26 * For Thumb syscalls, we pass the syscall number via r7. We therefore
27 * need two 16-bit instructions in .thumb encoding
29 * Please note sigreturn_codes code are not executed in place. Instead
30 * they just copied by kernel into appropriate places. Code inside of
31 * arch/arm/kernel/signal.c is very sensitive to layout of these code
36 * In CPU_THUMBONLY case kernel arm opcodes are not allowed.
37 * Note in this case codes skips those instructions but it uses .org
38 * directive to keep correct layout of sigreturn_codes array.
40 #ifndef CONFIG_CPU_THUMBONLY
41 #define ARM_OK(code...) code
43 #define ARM_OK(code...)
47 .org sigreturn_codes + 12 * (\n)
52 .org sigreturn_codes + 12 * (\n) + 8
56 .macro arm_fdpic_slot n
57 .org sigreturn_codes + 24 + 20 * (\n)
61 .macro thumb_fdpic_slot n
62 .org sigreturn_codes + 24 + 20 * (\n) + 12
67 #if __LINUX_ARM_ARCH__ <= 4
69 * Note we manually set minimally required arch that supports
70 * required thumb opcodes for early arch versions. It is OK
71 * for this file to be used in combination with other
72 * lower arch variants, since these code snippets are only
79 .global sigreturn_codes
80 .type sigreturn_codes, #object
86 /* ARM sigreturn syscall code snippet */
88 ARM_OK( mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE) )
89 ARM_OK( swi #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
91 /* Thumb sigreturn syscall code snippet */
93 movs r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
96 /* ARM sigreturn_rt syscall code snippet */
98 ARM_OK( mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE) )
99 ARM_OK( swi #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
101 /* Thumb sigreturn_rt syscall code snippet */
103 movs r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
106 /* ARM sigreturn restorer FDPIC bounce code snippet */
108 ARM_OK( ldr r3, [sp, #SIGFRAME_RC3_OFFSET] )
109 ARM_OK( ldmia r3, {r3, r9} )
110 #ifdef CONFIG_ARM_THUMB
116 /* Thumb sigreturn restorer FDPIC bounce code snippet */
118 ldr r3, [sp, #SIGFRAME_RC3_OFFSET]
123 /* ARM sigreturn_rt restorer FDPIC bounce code snippet */
125 ARM_OK( ldr r3, [sp, #RT_SIGFRAME_RC3_OFFSET] )
126 ARM_OK( ldmia r3, {r3, r9} )
127 #ifdef CONFIG_ARM_THUMB
133 /* Thumb sigreturn_rt restorer FDPIC bounce code snippet */
135 ldr r3, [sp, #RT_SIGFRAME_RC3_OFFSET]
141 * Note on additional space: setup_return in signal.c
142 * always copies the same number of words regardless whether
143 * it is thumb case or not, so we need one additional padding
144 * word after the last entry.
148 .size sigreturn_codes, . - sigreturn_codes