1
2
3
4
5
6
7
8
9 #include <asm/asm-offsets.h>
10 #include <asm/ppc_asm.h>
11 #include <asm/ppc-opcode.h>
12 #include <asm/ptrace.h>
13 #include <asm/reg.h>
14 #include <asm/bug.h>
15 #include <asm/export.h>
16 #include <asm/feature-fixups.h>
17
18 #ifdef CONFIG_VSX
19
20 #define __SAVE_32FPRS_VSRS(n,c,base) \
21 BEGIN_FTR_SECTION \
22 b 2f; \
23 END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
24 SAVE_32FPRS(n,base); \
25 b 3f; \
26 2: SAVE_32VSRS(n,c,base); \
27 3:
28 #define __REST_32FPRS_VSRS(n,c,base) \
29 BEGIN_FTR_SECTION \
30 b 2f; \
31 END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
32 REST_32FPRS(n,base); \
33 b 3f; \
34 2: REST_32VSRS(n,c,base); \
35 3:
36 #else
37 #define __SAVE_32FPRS_VSRS(n,c,base) SAVE_32FPRS(n, base)
38 #define __REST_32FPRS_VSRS(n,c,base) REST_32FPRS(n, base)
39 #endif
40 #define SAVE_32FPRS_VSRS(n,c,base) \
41 __SAVE_32FPRS_VSRS(n,__REG_##c,__REG_##base)
42 #define REST_32FPRS_VSRS(n,c,base) \
43 __REST_32FPRS_VSRS(n,__REG_##c,__REG_##base)
44
45
46 #define TM_FRAME_L0 TM_FRAME_SIZE-16
47 #define TM_FRAME_L1 TM_FRAME_SIZE-8
48
49
50
51 _GLOBAL(tm_enable)
52 mfmsr r4
53 li r3, MSR_TM >> 32
54 sldi r3, r3, 32
55 and. r0, r4, r3
56 bne 1f
57 or r4, r4, r3
58 mtmsrd r4
59 1: blr
60 EXPORT_SYMBOL_GPL(tm_enable);
61
62 _GLOBAL(tm_disable)
63 mfmsr r4
64 li r3, MSR_TM >> 32
65 sldi r3, r3, 32
66 andc r4, r4, r3
67 mtmsrd r4
68 blr
69 EXPORT_SYMBOL_GPL(tm_disable);
70
71 _GLOBAL(tm_save_sprs)
72 mfspr r0, SPRN_TFHAR
73 std r0, THREAD_TM_TFHAR(r3)
74 mfspr r0, SPRN_TEXASR
75 std r0, THREAD_TM_TEXASR(r3)
76 mfspr r0, SPRN_TFIAR
77 std r0, THREAD_TM_TFIAR(r3)
78 blr
79
80 _GLOBAL(tm_restore_sprs)
81 ld r0, THREAD_TM_TFHAR(r3)
82 mtspr SPRN_TFHAR, r0
83 ld r0, THREAD_TM_TEXASR(r3)
84 mtspr SPRN_TEXASR, r0
85 ld r0, THREAD_TM_TFIAR(r3)
86 mtspr SPRN_TFIAR, r0
87 blr
88
89
90 _GLOBAL(tm_abort)
91 TABORT(R3)
92 blr
93 EXPORT_SYMBOL_GPL(tm_abort);
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112 _GLOBAL(tm_reclaim)
113 mfcr r5
114 mflr r0
115 stw r5, 8(r1)
116 std r0, 16(r1)
117 std r2, STK_GOT(r1)
118 stdu r1, -TM_FRAME_SIZE(r1)
119
120
121
122 std r3, STK_PARAM(R3)(r1)
123 SAVE_NVGPRS(r1)
124
125
126 mfmsr r14
127 mr r15, r14
128 ori r15, r15, MSR_FP
129 li r16, 0
130 ori r16, r16, MSR_EE
131 andc r15, r15, r16
132 oris r15, r15, MSR_VEC@h
133 #ifdef CONFIG_VSX
134 BEGIN_FTR_SECTION
135 oris r15,r15, MSR_VSX@h
136 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
137 #endif
138 mtmsrd r15
139 std r14, TM_FRAME_L0(r1)
140
141
142 li r7, (MSR_TS_S)@higher
143 srdi r6, r14, 32
144 and r6, r6, r7
145 1: tdeqi r6, 0
146 EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,0
147
148
149 std r1, PACAR1(r13)
150
151
152 li r5, 0
153 mtmsrd r5, 1
154
155
156
157
158
159
160
161
162
163
164
165 TRECLAIM(R4)
166
167
168
169
170
171 SET_SCRATCH0(r13)
172 GET_PACA(r13)
173
174
175
176
177
178 std r1, PACATMSCRATCH(r13)
179 ld r1, PACAR1(r13)
180
181 std r11, GPR11(r1)
182
183
184
185
186
187 ld r11, PACATMSCRATCH(r13)
188 std r11, GPR1(r1)
189
190
191
192
193
194 GET_SCRATCH0(r11)
195 std r11, GPR13(r1)
196
197
198 li r11, MSR_RI
199 mtmsrd r11, 1
200
201
202 mfspr r11, SPRN_PPR
203 HMT_MEDIUM
204
205
206 std r7, GPR7(r1)
207 std r12, GPR12(r1)
208 ld r12, STK_PARAM(R3)(r1)
209
210 std r11, THREAD_TM_PPR(r12)
211
212 addi r7, r12, PT_CKPT_REGS
213
214
215
216
217
218 subi r7, r7, STACK_FRAME_OVERHEAD
219
220
221 SAVE_GPR(0, r7)
222 SAVE_GPR(2, r7)
223 SAVE_4GPRS(3, r7)
224 SAVE_GPR(8, r7)
225 SAVE_GPR(9, r7)
226 SAVE_GPR(10, r7)
227 ld r3, GPR1(r1)
228 ld r4, GPR7(r1)
229 ld r5, GPR11(r1)
230 ld r6, GPR12(r1)
231 ld r8, GPR13(r1)
232 std r3, GPR1(r7)
233 std r4, GPR7(r7)
234 std r5, GPR11(r7)
235 std r6, GPR12(r7)
236 std r8, GPR13(r7)
237
238 SAVE_NVGPRS(r7)
239
240
241 mfspr r3, SPRN_TFHAR
242 std r3, _NIP(r7)
243
244
245
246
247
248
249 mfctr r3
250 mflr r4
251 mfcr r5
252 mfxer r6
253
254 std r3, _CTR(r7)
255 std r4, _LINK(r7)
256 std r5, _CCR(r7)
257 std r6, _XER(r7)
258
259
260
261 mfspr r3, SPRN_TAR
262 mfspr r4, SPRN_DSCR
263
264 std r3, THREAD_TM_TAR(r12)
265 std r4, THREAD_TM_DSCR(r12)
266
267
268
269
270
271
272
273
274
275
276
277
278
279 mr r3, r12
280
281
282 addi r7, r3, THREAD_CKVRSTATE
283 SAVE_32VRS(0, r6, r7)
284 mfvscr v0
285 li r6, VRSTATE_VSCR
286 stvx v0, r7, r6
287
288
289 mfspr r0, SPRN_VRSAVE
290 std r0, THREAD_CKVRSAVE(r3)
291
292
293 addi r7, r3, THREAD_CKFPSTATE
294 SAVE_32FPRS_VSRS(0, R6, R7)
295 mffs fr0
296 stfd fr0,FPSTATE_FPSCR(r7)
297
298
299
300
301
302
303
304 mfspr r0, SPRN_TEXASR
305 mfspr r3, SPRN_TFHAR
306 mfspr r4, SPRN_TFIAR
307 std r0, THREAD_TM_TEXASR(r12)
308 std r3, THREAD_TM_TFHAR(r12)
309 std r4, THREAD_TM_TFIAR(r12)
310
311
312
313
314 ld r14, TM_FRAME_L0(r1)
315
316 li r15, 0
317 rldimi r14, r15, MSR_TS_LG, (63-MSR_TS_LG)-1
318 mtmsrd r14
319
320 REST_NVGPRS(r1)
321
322 addi r1, r1, TM_FRAME_SIZE
323 lwz r4, 8(r1)
324 ld r0, 16(r1)
325 mtcr r4
326 mtlr r0
327 ld r2, STK_GOT(r1)
328
329
330 ld r0, PACA_DSCR_DEFAULT(r13)
331 mtspr SPRN_DSCR, r0
332
333 blr
334
335
336
337
338
339
340
341
342
343
344 _GLOBAL(__tm_recheckpoint)
345 mfcr r5
346 mflr r0
347 stw r5, 8(r1)
348 std r0, 16(r1)
349 std r2, STK_GOT(r1)
350 stdu r1, -TM_FRAME_SIZE(r1)
351
352
353
354
355
356 SAVE_NVGPRS(r1)
357
358
359
360 addi r7, r3, PT_CKPT_REGS
361
362
363
364
365
366 subi r7, r7, STACK_FRAME_OVERHEAD
367
368
369 mfmsr r6
370 mr r5, r6
371 ori r5, r5, MSR_FP
372 #ifdef CONFIG_ALTIVEC
373 oris r5, r5, MSR_VEC@h
374 #endif
375 #ifdef CONFIG_VSX
376 BEGIN_FTR_SECTION
377 oris r5,r5, MSR_VSX@h
378 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
379 #endif
380 mtmsrd r5
381
382 #ifdef CONFIG_ALTIVEC
383
384
385
386
387
388
389 addi r8, r3, THREAD_CKVRSTATE
390 li r5, VRSTATE_VSCR
391 lvx v0, r8, r5
392 mtvscr v0
393 REST_32VRS(0, r5, r8)
394 ld r5, THREAD_CKVRSAVE(r3)
395 mtspr SPRN_VRSAVE, r5
396 #endif
397
398 addi r8, r3, THREAD_CKFPSTATE
399 lfd fr0, FPSTATE_FPSCR(r8)
400 MTFSF_L(fr0)
401 REST_32FPRS_VSRS(0, R4, R8)
402
403 mtmsr r6
404
405 restore_gprs:
406
407
408 ld r4, _CTR(r7)
409 ld r5, _LINK(r7)
410 ld r8, _XER(r7)
411
412 mtctr r4
413 mtlr r5
414 mtxer r8
415
416
417 ld r4, THREAD_TM_TAR(r3)
418 mtspr SPRN_TAR, r4
419
420
421 ld r5, THREAD_TM_DSCR(r3)
422 ld r6, THREAD_TM_PPR(r3)
423
424 REST_GPR(0, r7)
425 REST_2GPRS(2, r7)
426 REST_GPR(4, r7)
427 REST_4GPRS(8, r7)
428 REST_2GPRS(12, r7)
429
430 REST_NVGPRS(r7)
431
432
433 mtspr SPRN_DSCR, r5
434 mtspr SPRN_PPR, r6
435
436
437
438
439
440
441 mfspr r5, SPRN_TEXASR
442 srdi r5, r5, 16
443 li r6, (TEXASR_FS)@h
444 and r6, r6, r5
445 1: tdeqi r6, 0
446 EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,0
447
448
449
450
451
452 mfmsr r6
453 li r5, (MSR_TS_MASK)@higher
454 srdi r6, r6, 32
455 and r6, r6, r5
456 1: tdnei r6, 0
457 EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,0
458
459
460 ld r6, _CCR(r7)
461 mtcr r6
462
463 REST_GPR(6, r7)
464
465
466
467
468
469
470 REST_GPR(5, r7)
471 std r5, -8(r1)
472 ld r5, GPR1(r7)
473 std r5, -16(r1)
474
475 REST_GPR(7, r7)
476
477
478 li r5, 0
479 mtmsrd r5, 1
480
481
482
483
484
485
486
487
488 SET_SCRATCH0(r1)
489 ld r5, -8(r1)
490 ld r1, -16(r1)
491
492
493 TRECHKPT
494
495 HMT_MEDIUM
496
497
498
499
500
501
502
503
504
505 GET_PACA(r13)
506 GET_SCRATCH0(r1)
507
508
509 li r4, MSR_RI
510 mtmsrd r4, 1
511
512 REST_NVGPRS(r1)
513
514 addi r1, r1, TM_FRAME_SIZE
515 lwz r4, 8(r1)
516 ld r0, 16(r1)
517 mtcr r4
518 mtlr r0
519 ld r2, STK_GOT(r1)
520
521
522 ld r0, PACA_DSCR_DEFAULT(r13)
523 mtspr SPRN_DSCR, r0
524
525 blr
526
527