Merge tag 'phy-for-4.6-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon...
[deliverable/linux.git] / arch / arm / kernel / sigreturn_codes.S
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
17 #include <asm/unistd.h>
18
19 /*
20 * For ARM syscalls, we encode the syscall number into the instruction.
21 * With EABI, the syscall number has to be loaded into r7. As result
22 * ARM syscall sequence snippet will have move and svc in .arm encoding
23 *
24 * For Thumb syscalls, we pass the syscall number via r7. We therefore
25 * need two 16-bit instructions in .thumb encoding
26 *
27 * Please note sigreturn_codes code are not executed in place. Instead
28 * they just copied by kernel into appropriate places. Code inside of
29 * arch/arm/kernel/signal.c is very sensitive to layout of these code
30 * snippets.
31 */
32
33 /*
34 * In CPU_THUMBONLY case kernel arm opcodes are not allowed.
35 * Note in this case codes skips those instructions but it uses .org
36 * directive to keep correct layout of sigreturn_codes array.
37 */
38 #ifndef CONFIG_CPU_THUMBONLY
39 #define ARM_OK(code...) code
40 #else
41 #define ARM_OK(code...)
42 #endif
43
44 .macro arm_slot n
45 .org sigreturn_codes + 12 * (\n)
46 ARM_OK( .arm )
47 .endm
48
49 .macro thumb_slot n
50 .org sigreturn_codes + 12 * (\n) + 8
51 .thumb
52 .endm
53
54 #if __LINUX_ARM_ARCH__ <= 4
55 /*
56 * Note we manually set minimally required arch that supports
57 * required thumb opcodes for early arch versions. It is OK
58 * for this file to be used in combination with other
59 * lower arch variants, since these code snippets are only
60 * used as input data.
61 */
62 .arch armv4t
63 #endif
64
65 .section .rodata
66 .global sigreturn_codes
67 .type sigreturn_codes, #object
68
69 .align
70
71 sigreturn_codes:
72
73 /* ARM sigreturn syscall code snippet */
74 arm_slot 0
75 ARM_OK( mov r7, #(__NR_sigreturn - __NR_SYSCALL_BASE) )
76 ARM_OK( swi #(__NR_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
77
78 /* Thumb sigreturn syscall code snippet */
79 thumb_slot 0
80 movs r7, #(__NR_sigreturn - __NR_SYSCALL_BASE)
81 swi #0
82
83 /* ARM sigreturn_rt syscall code snippet */
84 arm_slot 1
85 ARM_OK( mov r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE) )
86 ARM_OK( swi #(__NR_rt_sigreturn)|(__NR_OABI_SYSCALL_BASE) )
87
88 /* Thumb sigreturn_rt syscall code snippet */
89 thumb_slot 1
90 movs r7, #(__NR_rt_sigreturn - __NR_SYSCALL_BASE)
91 swi #0
92
93 /*
94 * Note on addtional space: setup_return in signal.c
95 * algorithm uses two words copy regardless whether
96 * it is thumb case or not, so we need additional
97 * word after real last entry.
98 */
99 arm_slot 2
100 .space 4
101
102 .size sigreturn_codes, . - sigreturn_codes
This page took 0.058555 seconds and 5 git commands to generate.