diff options
Diffstat (limited to 'arch/powerpc/kernel/vdso64/sigtramp.S')
-rw-r--r-- | arch/powerpc/kernel/vdso64/sigtramp.S | 295 |
1 files changed, 295 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/vdso64/sigtramp.S b/arch/powerpc/kernel/vdso64/sigtramp.S new file mode 100644 index 000000000000..31b604ab56de --- /dev/null +++ b/arch/powerpc/kernel/vdso64/sigtramp.S | |||
@@ -0,0 +1,295 @@ | |||
1 | /* | ||
2 | * Signal trampoline for 64 bits processes in a ppc64 kernel for | ||
3 | * use in the vDSO | ||
4 | * | ||
5 | * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), IBM Corp. | ||
6 | * Copyright (C) 2004 Alan Modra (amodra@au.ibm.com)), IBM Corp. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | */ | ||
13 | #include <linux/config.h> | ||
14 | #include <asm/processor.h> | ||
15 | #include <asm/ppc_asm.h> | ||
16 | #include <asm/unistd.h> | ||
17 | #include <asm/vdso.h> | ||
18 | #include <asm/ptrace.h> /* XXX for __SIGNAL_FRAMESIZE */ | ||
19 | |||
20 | .text | ||
21 | |||
22 | /* The nop here is a hack. The dwarf2 unwind routines subtract 1 from | ||
23 | the return address to get an address in the middle of the presumed | ||
24 | call instruction. Since we don't have a call here, we artifically | ||
25 | extend the range covered by the unwind info by padding before the | ||
26 | real start. */ | ||
27 | nop | ||
28 | .balign 8 | ||
29 | V_FUNCTION_BEGIN(__kernel_sigtramp_rt64) | ||
30 | .Lsigrt_start = . - 4 | ||
31 | addi r1, r1, __SIGNAL_FRAMESIZE | ||
32 | li r0,__NR_rt_sigreturn | ||
33 | sc | ||
34 | .Lsigrt_end: | ||
35 | V_FUNCTION_END(__kernel_sigtramp_rt64) | ||
36 | /* The ".balign 8" above and the following zeros mimic the old stack | ||
37 | trampoline layout. The last magic value is the ucontext pointer, | ||
38 | chosen in such a way that older libgcc unwind code returns a zero | ||
39 | for a sigcontext pointer. */ | ||
40 | .long 0,0,0 | ||
41 | .quad 0,-21*8 | ||
42 | |||
43 | /* Register r1 can be found at offset 8 of a pt_regs structure. | ||
44 | A pointer to the pt_regs is stored in memory at the old sp plus PTREGS. */ | ||
45 | #define cfa_save \ | ||
46 | .byte 0x0f; /* DW_CFA_def_cfa_expression */ \ | ||
47 | .uleb128 9f - 1f; /* length */ \ | ||
48 | 1: \ | ||
49 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
50 | .byte 0x06; /* DW_OP_deref */ \ | ||
51 | .byte 0x23; .uleb128 RSIZE; /* DW_OP_plus_uconst */ \ | ||
52 | .byte 0x06; /* DW_OP_deref */ \ | ||
53 | 9: | ||
54 | |||
55 | /* Register REGNO can be found at offset OFS of a pt_regs structure. | ||
56 | A pointer to the pt_regs is stored in memory at the old sp plus PTREGS. */ | ||
57 | #define rsave(regno, ofs) \ | ||
58 | .byte 0x10; /* DW_CFA_expression */ \ | ||
59 | .uleb128 regno; /* regno */ \ | ||
60 | .uleb128 9f - 1f; /* length */ \ | ||
61 | 1: \ | ||
62 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
63 | .byte 0x06; /* DW_OP_deref */ \ | ||
64 | .ifne ofs; \ | ||
65 | .byte 0x23; .uleb128 ofs; /* DW_OP_plus_uconst */ \ | ||
66 | .endif; \ | ||
67 | 9: | ||
68 | |||
69 | /* If msr bit 1<<25 is set, then VMX register REGNO is at offset REGNO*16 | ||
70 | of the VMX reg struct. A pointer to the VMX reg struct is at VREGS in | ||
71 | the pt_regs struct. This macro is for REGNO == 0, and contains | ||
72 | 'subroutines' that the other macros jump to. */ | ||
73 | #define vsave_msr0(regno) \ | ||
74 | .byte 0x10; /* DW_CFA_expression */ \ | ||
75 | .uleb128 regno + 77; /* regno */ \ | ||
76 | .uleb128 9f - 1f; /* length */ \ | ||
77 | 1: \ | ||
78 | .byte 0x30 + regno; /* DW_OP_lit0 */ \ | ||
79 | 2: \ | ||
80 | .byte 0x40; /* DW_OP_lit16 */ \ | ||
81 | .byte 0x1e; /* DW_OP_mul */ \ | ||
82 | 3: \ | ||
83 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
84 | .byte 0x06; /* DW_OP_deref */ \ | ||
85 | .byte 0x12; /* DW_OP_dup */ \ | ||
86 | .byte 0x23; /* DW_OP_plus_uconst */ \ | ||
87 | .uleb128 33*RSIZE; /* msr offset */ \ | ||
88 | .byte 0x06; /* DW_OP_deref */ \ | ||
89 | .byte 0x0c; .long 1 << 25; /* DW_OP_const4u */ \ | ||
90 | .byte 0x1a; /* DW_OP_and */ \ | ||
91 | .byte 0x12; /* DW_OP_dup, ret 0 if bra taken */ \ | ||
92 | .byte 0x30; /* DW_OP_lit0 */ \ | ||
93 | .byte 0x29; /* DW_OP_eq */ \ | ||
94 | .byte 0x28; .short 0x7fff; /* DW_OP_bra to end */ \ | ||
95 | .byte 0x13; /* DW_OP_drop, pop the 0 */ \ | ||
96 | .byte 0x23; .uleb128 VREGS; /* DW_OP_plus_uconst */ \ | ||
97 | .byte 0x06; /* DW_OP_deref */ \ | ||
98 | .byte 0x22; /* DW_OP_plus */ \ | ||
99 | .byte 0x2f; .short 0x7fff; /* DW_OP_skip to end */ \ | ||
100 | 9: | ||
101 | |||
102 | /* If msr bit 1<<25 is set, then VMX register REGNO is at offset REGNO*16 | ||
103 | of the VMX reg struct. REGNO is 1 thru 31. */ | ||
104 | #define vsave_msr1(regno) \ | ||
105 | .byte 0x10; /* DW_CFA_expression */ \ | ||
106 | .uleb128 regno + 77; /* regno */ \ | ||
107 | .uleb128 9f - 1f; /* length */ \ | ||
108 | 1: \ | ||
109 | .byte 0x30 + regno; /* DW_OP_lit n */ \ | ||
110 | .byte 0x2f; .short 2b - 9f; /* DW_OP_skip */ \ | ||
111 | 9: | ||
112 | |||
113 | /* If msr bit 1<<25 is set, then VMX register REGNO is at offset OFS of | ||
114 | the VMX save block. */ | ||
115 | #define vsave_msr2(regno, ofs) \ | ||
116 | .byte 0x10; /* DW_CFA_expression */ \ | ||
117 | .uleb128 regno + 77; /* regno */ \ | ||
118 | .uleb128 9f - 1f; /* length */ \ | ||
119 | 1: \ | ||
120 | .byte 0x0a; .short ofs; /* DW_OP_const2u */ \ | ||
121 | .byte 0x2f; .short 3b - 9f; /* DW_OP_skip */ \ | ||
122 | 9: | ||
123 | |||
124 | /* VMX register REGNO is at offset OFS of the VMX save area. */ | ||
125 | #define vsave(regno, ofs) \ | ||
126 | .byte 0x10; /* DW_CFA_expression */ \ | ||
127 | .uleb128 regno + 77; /* regno */ \ | ||
128 | .uleb128 9f - 1f; /* length */ \ | ||
129 | 1: \ | ||
130 | .byte 0x71; .sleb128 PTREGS; /* DW_OP_breg1 */ \ | ||
131 | .byte 0x06; /* DW_OP_deref */ \ | ||
132 | .byte 0x23; .uleb128 VREGS; /* DW_OP_plus_uconst */ \ | ||
133 | .byte 0x06; /* DW_OP_deref */ \ | ||
134 | .byte 0x23; .uleb128 ofs; /* DW_OP_plus_uconst */ \ | ||
135 | 9: | ||
136 | |||
137 | /* This is where the pt_regs pointer can be found on the stack. */ | ||
138 | #define PTREGS 128+168+56 | ||
139 | |||
140 | /* Size of regs. */ | ||
141 | #define RSIZE 8 | ||
142 | |||
143 | /* This is the offset of the VMX reg pointer. */ | ||
144 | #define VREGS 48*RSIZE+33*8 | ||
145 | |||
146 | /* Describe where general purpose regs are saved. */ | ||
147 | #define EH_FRAME_GEN \ | ||
148 | cfa_save; \ | ||
149 | rsave ( 0, 0*RSIZE); \ | ||
150 | rsave ( 2, 2*RSIZE); \ | ||
151 | rsave ( 3, 3*RSIZE); \ | ||
152 | rsave ( 4, 4*RSIZE); \ | ||
153 | rsave ( 5, 5*RSIZE); \ | ||
154 | rsave ( 6, 6*RSIZE); \ | ||
155 | rsave ( 7, 7*RSIZE); \ | ||
156 | rsave ( 8, 8*RSIZE); \ | ||
157 | rsave ( 9, 9*RSIZE); \ | ||
158 | rsave (10, 10*RSIZE); \ | ||
159 | rsave (11, 11*RSIZE); \ | ||
160 | rsave (12, 12*RSIZE); \ | ||
161 | rsave (13, 13*RSIZE); \ | ||
162 | rsave (14, 14*RSIZE); \ | ||
163 | rsave (15, 15*RSIZE); \ | ||
164 | rsave (16, 16*RSIZE); \ | ||
165 | rsave (17, 17*RSIZE); \ | ||
166 | rsave (18, 18*RSIZE); \ | ||
167 | rsave (19, 19*RSIZE); \ | ||
168 | rsave (20, 20*RSIZE); \ | ||
169 | rsave (21, 21*RSIZE); \ | ||
170 | rsave (22, 22*RSIZE); \ | ||
171 | rsave (23, 23*RSIZE); \ | ||
172 | rsave (24, 24*RSIZE); \ | ||
173 | rsave (25, 25*RSIZE); \ | ||
174 | rsave (26, 26*RSIZE); \ | ||
175 | rsave (27, 27*RSIZE); \ | ||
176 | rsave (28, 28*RSIZE); \ | ||
177 | rsave (29, 29*RSIZE); \ | ||
178 | rsave (30, 30*RSIZE); \ | ||
179 | rsave (31, 31*RSIZE); \ | ||
180 | rsave (67, 32*RSIZE); /* ap, used as temp for nip */ \ | ||
181 | rsave (65, 36*RSIZE); /* lr */ \ | ||
182 | rsave (70, 38*RSIZE) /* cr */ | ||
183 | |||
184 | /* Describe where the FP regs are saved. */ | ||
185 | #define EH_FRAME_FP \ | ||
186 | rsave (32, 48*RSIZE + 0*8); \ | ||
187 | rsave (33, 48*RSIZE + 1*8); \ | ||
188 | rsave (34, 48*RSIZE + 2*8); \ | ||
189 | rsave (35, 48*RSIZE + 3*8); \ | ||
190 | rsave (36, 48*RSIZE + 4*8); \ | ||
191 | rsave (37, 48*RSIZE + 5*8); \ | ||
192 | rsave (38, 48*RSIZE + 6*8); \ | ||
193 | rsave (39, 48*RSIZE + 7*8); \ | ||
194 | rsave (40, 48*RSIZE + 8*8); \ | ||
195 | rsave (41, 48*RSIZE + 9*8); \ | ||
196 | rsave (42, 48*RSIZE + 10*8); \ | ||
197 | rsave (43, 48*RSIZE + 11*8); \ | ||
198 | rsave (44, 48*RSIZE + 12*8); \ | ||
199 | rsave (45, 48*RSIZE + 13*8); \ | ||
200 | rsave (46, 48*RSIZE + 14*8); \ | ||
201 | rsave (47, 48*RSIZE + 15*8); \ | ||
202 | rsave (48, 48*RSIZE + 16*8); \ | ||
203 | rsave (49, 48*RSIZE + 17*8); \ | ||
204 | rsave (50, 48*RSIZE + 18*8); \ | ||
205 | rsave (51, 48*RSIZE + 19*8); \ | ||
206 | rsave (52, 48*RSIZE + 20*8); \ | ||
207 | rsave (53, 48*RSIZE + 21*8); \ | ||
208 | rsave (54, 48*RSIZE + 22*8); \ | ||
209 | rsave (55, 48*RSIZE + 23*8); \ | ||
210 | rsave (56, 48*RSIZE + 24*8); \ | ||
211 | rsave (57, 48*RSIZE + 25*8); \ | ||
212 | rsave (58, 48*RSIZE + 26*8); \ | ||
213 | rsave (59, 48*RSIZE + 27*8); \ | ||
214 | rsave (60, 48*RSIZE + 28*8); \ | ||
215 | rsave (61, 48*RSIZE + 29*8); \ | ||
216 | rsave (62, 48*RSIZE + 30*8); \ | ||
217 | rsave (63, 48*RSIZE + 31*8) | ||
218 | |||
219 | /* Describe where the VMX regs are saved. */ | ||
220 | #ifdef CONFIG_ALTIVEC | ||
221 | #define EH_FRAME_VMX \ | ||
222 | vsave_msr0 ( 0); \ | ||
223 | vsave_msr1 ( 1); \ | ||
224 | vsave_msr1 ( 2); \ | ||
225 | vsave_msr1 ( 3); \ | ||
226 | vsave_msr1 ( 4); \ | ||
227 | vsave_msr1 ( 5); \ | ||
228 | vsave_msr1 ( 6); \ | ||
229 | vsave_msr1 ( 7); \ | ||
230 | vsave_msr1 ( 8); \ | ||
231 | vsave_msr1 ( 9); \ | ||
232 | vsave_msr1 (10); \ | ||
233 | vsave_msr1 (11); \ | ||
234 | vsave_msr1 (12); \ | ||
235 | vsave_msr1 (13); \ | ||
236 | vsave_msr1 (14); \ | ||
237 | vsave_msr1 (15); \ | ||
238 | vsave_msr1 (16); \ | ||
239 | vsave_msr1 (17); \ | ||
240 | vsave_msr1 (18); \ | ||
241 | vsave_msr1 (19); \ | ||
242 | vsave_msr1 (20); \ | ||
243 | vsave_msr1 (21); \ | ||
244 | vsave_msr1 (22); \ | ||
245 | vsave_msr1 (23); \ | ||
246 | vsave_msr1 (24); \ | ||
247 | vsave_msr1 (25); \ | ||
248 | vsave_msr1 (26); \ | ||
249 | vsave_msr1 (27); \ | ||
250 | vsave_msr1 (28); \ | ||
251 | vsave_msr1 (29); \ | ||
252 | vsave_msr1 (30); \ | ||
253 | vsave_msr1 (31); \ | ||
254 | vsave_msr2 (33, 32*16+12); \ | ||
255 | vsave (32, 33*16) | ||
256 | #else | ||
257 | #define EH_FRAME_VMX | ||
258 | #endif | ||
259 | |||
260 | .section .eh_frame,"a",@progbits | ||
261 | .Lcie: | ||
262 | .long .Lcie_end - .Lcie_start | ||
263 | .Lcie_start: | ||
264 | .long 0 /* CIE ID */ | ||
265 | .byte 1 /* Version number */ | ||
266 | .string "zR" /* NUL-terminated augmentation string */ | ||
267 | .uleb128 4 /* Code alignment factor */ | ||
268 | .sleb128 -8 /* Data alignment factor */ | ||
269 | .byte 67 /* Return address register column, ap */ | ||
270 | .uleb128 1 /* Augmentation value length */ | ||
271 | .byte 0x14 /* DW_EH_PE_pcrel | DW_EH_PE_udata8. */ | ||
272 | .byte 0x0c,1,0 /* DW_CFA_def_cfa: r1 ofs 0 */ | ||
273 | .balign 8 | ||
274 | .Lcie_end: | ||
275 | |||
276 | .long .Lfde0_end - .Lfde0_start | ||
277 | .Lfde0_start: | ||
278 | .long .Lfde0_start - .Lcie /* CIE pointer. */ | ||
279 | .quad .Lsigrt_start - . /* PC start, length */ | ||
280 | .quad .Lsigrt_end - .Lsigrt_start | ||
281 | .uleb128 0 /* Augmentation */ | ||
282 | EH_FRAME_GEN | ||
283 | EH_FRAME_FP | ||
284 | EH_FRAME_VMX | ||
285 | # Do we really need to describe the frame at this point? ie. will | ||
286 | # we ever have some call chain that returns somewhere past the addi? | ||
287 | # I don't think so, since gcc doesn't support async signals. | ||
288 | # .byte 0x41 /* DW_CFA_advance_loc 1*4 */ | ||
289 | #undef PTREGS | ||
290 | #define PTREGS 168+56 | ||
291 | # EH_FRAME_GEN | ||
292 | # EH_FRAME_FP | ||
293 | # EH_FRAME_VMX | ||
294 | .balign 8 | ||
295 | .Lfde0_end: | ||