1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * sigreturn_codes.S - code sinpets for sigreturn syscalls
5 * Created by: Victor Kamensky, 2013-08-13
6 * Copyright: (C) 2013 Linaro Limited
9 #include <asm/assembler.h>
10 #include <asm/asm-offsets.h>
11 #include <asm/unistd.h>
14 * For ARM syscalls, we encode the syscall number into the instruction.
15 * With EABI, the syscall number has to be loaded into r7. As result
16 * ARM syscall sequence snippet will have move and svc in .arm encoding
18 * For Thumb syscalls, we pass the syscall number via r7. We therefore
19 * need two 16-bit instructions in .thumb encoding
21 * Please note sigreturn_codes code are not executed in place. Instead
22 * they just copied by kernel into appropriate places. Code inside of
23 * arch/arm/kernel/signal.c is very sensitive to layout of these code
28 * In CPU_THUMBONLY case kernel arm opcodes are not allowed.
29 * Note in this case codes skips those instructions but it uses .org
30 * directive to keep correct layout of sigreturn_codes array.
32 #ifndef CONFIG_CPU_THUMBONLY
33 #define ARM_OK(code...) code
35 #define ARM_OK(code...)
39 .org sigreturn_codes + 12 * (\n)
44 .org sigreturn_codes + 12 * (\n) + 8
48 .macro arm_fdpic_slot n
49 .org sigreturn_codes + 24 + 20 * (\n)
53 .macro thumb_fdpic_slot n
54 .org sigreturn_codes + 24 + 20 * (\n) + 12
59 #if __LINUX_ARM_ARCH__ <= 4
61 * Note we manually set minimally required arch that supports
62 * required thumb opcodes for early arch versions. It is OK
63 * for this file to be used in combination with other
64 * lower arch variants, since these code snippets are only
71 .global sigreturn_codes
72 .type sigreturn_codes, #object
78 /* ARM sigreturn syscall code snippet */
80 ARM_OK( mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE) )
81 ARM_OK( swi #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
83 /* Thumb sigreturn syscall code snippet */
85 movs r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
88 /* ARM sigreturn_rt syscall code snippet */
90 ARM_OK( mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE) )
91 ARM_OK( swi #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
93 /* Thumb sigreturn_rt syscall code snippet */
95 movs r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
98 /* ARM sigreturn restorer FDPIC bounce code snippet */
100 ARM_OK( ldr r3, [sp, #SIGFRAME_RC3_OFFSET] )
101 ARM_OK( ldmia r3, {r3, r9} )
102 #ifdef CONFIG_ARM_THUMB
108 /* Thumb sigreturn restorer FDPIC bounce code snippet */
110 ldr r3, [sp, #SIGFRAME_RC3_OFFSET]
115 /* ARM sigreturn_rt restorer FDPIC bounce code snippet */
117 ARM_OK( ldr r3, [sp, #RT_SIGFRAME_RC3_OFFSET] )
118 ARM_OK( ldmia r3, {r3, r9} )
119 #ifdef CONFIG_ARM_THUMB
125 /* Thumb sigreturn_rt restorer FDPIC bounce code snippet */
127 ldr r3, [sp, #RT_SIGFRAME_RC3_OFFSET]
133 * Note on additional space: setup_return in signal.c
134 * always copies the same number of words regardless whether
135 * it is thumb case or not, so we need one additional padding
136 * word after the last entry.
140 .size sigreturn_codes, . - sigreturn_codes