.. | .. |
---|
92 | 92 | blr |
---|
93 | 93 | EXPORT_SYMBOL_GPL(tm_abort); |
---|
94 | 94 | |
---|
95 | | -/* void tm_reclaim(struct thread_struct *thread, |
---|
| 95 | +/* |
---|
| 96 | + * void tm_reclaim(struct thread_struct *thread, |
---|
96 | 97 | * uint8_t cause) |
---|
97 | 98 | * |
---|
98 | 99 | * - Performs a full reclaim. This destroys outstanding |
---|
99 | | - * transactions and updates thread->regs.tm_ckpt_* with the |
---|
100 | | - * original checkpointed state. Note that thread->regs is |
---|
101 | | - * unchanged. |
---|
| 100 | + * transactions and updates thread.ckpt_regs, thread.ckfp_state and |
---|
| 101 | + * thread.ckvr_state with the original checkpointed state. Note that |
---|
| 102 | + * thread->regs is unchanged. |
---|
102 | 103 | * |
---|
103 | 104 | * Purpose is to both abort transactions of, and preserve the state of, |
---|
104 | 105 | * a transactions at a context switch. We preserve/restore both sets of process |
---|
.. | .. |
---|
120 | 121 | |
---|
121 | 122 | std r3, STK_PARAM(R3)(r1) |
---|
122 | 123 | SAVE_NVGPRS(r1) |
---|
| 124 | + |
---|
| 125 | + /* |
---|
| 126 | + * Save kernel live AMR since it will be clobbered by treclaim |
---|
| 127 | + * but can be used elsewhere later in kernel space. |
---|
| 128 | + */ |
---|
| 129 | + mfspr r3, SPRN_AMR |
---|
| 130 | + std r3, TM_FRAME_L1(r1) |
---|
123 | 131 | |
---|
124 | 132 | /* We need to setup MSR for VSX register save instructions. */ |
---|
125 | 133 | mfmsr r14 |
---|
.. | .. |
---|
147 | 155 | /* Stash the stack pointer away for use after reclaim */ |
---|
148 | 156 | std r1, PACAR1(r13) |
---|
149 | 157 | |
---|
150 | | - /* Clear MSR RI since we are about to change r1, EE is already off. */ |
---|
| 158 | + /* Clear MSR RI since we are about to use SCRATCH0, EE is already off */ |
---|
151 | 159 | li r5, 0 |
---|
152 | 160 | mtmsrd r5, 1 |
---|
153 | 161 | |
---|
.. | .. |
---|
163 | 171 | */ |
---|
164 | 172 | TRECLAIM(R4) /* Cause in r4 */ |
---|
165 | 173 | |
---|
166 | | - /* ******************** GPRs ******************** */ |
---|
167 | | - /* Stash the checkpointed r13 away in the scratch SPR and get the real |
---|
168 | | - * paca |
---|
| 174 | + /* |
---|
| 175 | + * ******************** GPRs ******************** |
---|
| 176 | + * Stash the checkpointed r13 in the scratch SPR and get the real paca. |
---|
169 | 177 | */ |
---|
170 | 178 | SET_SCRATCH0(r13) |
---|
171 | 179 | GET_PACA(r13) |
---|
172 | 180 | |
---|
173 | | - /* Stash the checkpointed r1 away in paca tm_scratch and get the real |
---|
174 | | - * stack pointer back |
---|
| 181 | + /* |
---|
| 182 | + * Stash the checkpointed r1 away in paca->tm_scratch and get the real |
---|
| 183 | + * stack pointer back into r1. |
---|
175 | 184 | */ |
---|
176 | 185 | std r1, PACATMSCRATCH(r13) |
---|
177 | 186 | ld r1, PACAR1(r13) |
---|
.. | .. |
---|
209 | 218 | |
---|
210 | 219 | addi r7, r12, PT_CKPT_REGS /* Thread's ckpt_regs */ |
---|
211 | 220 | |
---|
212 | | - /* Make r7 look like an exception frame so that we |
---|
213 | | - * can use the neat GPRx(n) macros. r7 is NOT a pt_regs ptr! |
---|
| 221 | + /* |
---|
| 222 | + * Make r7 look like an exception frame so that we can use the neat |
---|
| 223 | + * GPRx(n) macros. r7 is NOT a pt_regs ptr! |
---|
214 | 224 | */ |
---|
215 | 225 | subi r7, r7, STACK_FRAME_OVERHEAD |
---|
216 | 226 | |
---|
217 | 227 | /* Sync the userland GPRs 2-12, 14-31 to thread->regs: */ |
---|
218 | 228 | SAVE_GPR(0, r7) /* user r0 */ |
---|
219 | | - SAVE_GPR(2, r7) /* user r2 */ |
---|
| 229 | + SAVE_GPR(2, r7) /* user r2 */ |
---|
220 | 230 | SAVE_4GPRS(3, r7) /* user r3-r6 */ |
---|
221 | 231 | SAVE_GPR(8, r7) /* user r8 */ |
---|
222 | 232 | SAVE_GPR(9, r7) /* user r9 */ |
---|
.. | .. |
---|
237 | 247 | /* ******************** NIP ******************** */ |
---|
238 | 248 | mfspr r3, SPRN_TFHAR |
---|
239 | 249 | std r3, _NIP(r7) /* Returns to failhandler */ |
---|
240 | | - /* The checkpointed NIP is ignored when rescheduling/rechkpting, |
---|
| 250 | + /* |
---|
| 251 | + * The checkpointed NIP is ignored when rescheduling/rechkpting, |
---|
241 | 252 | * but is used in signal return to 'wind back' to the abort handler. |
---|
242 | 253 | */ |
---|
243 | 254 | |
---|
244 | | - /* ******************** CR,LR,CCR,MSR ********** */ |
---|
| 255 | + /* ***************** CTR, LR, CR, XER ********** */ |
---|
245 | 256 | mfctr r3 |
---|
246 | 257 | mflr r4 |
---|
247 | 258 | mfcr r5 |
---|
.. | .. |
---|
252 | 263 | std r5, _CCR(r7) |
---|
253 | 264 | std r6, _XER(r7) |
---|
254 | 265 | |
---|
255 | | - |
---|
256 | 266 | /* ******************** TAR, DSCR ********** */ |
---|
257 | 267 | mfspr r3, SPRN_TAR |
---|
258 | 268 | mfspr r4, SPRN_DSCR |
---|
.. | .. |
---|
260 | 270 | std r3, THREAD_TM_TAR(r12) |
---|
261 | 271 | std r4, THREAD_TM_DSCR(r12) |
---|
262 | 272 | |
---|
263 | | - /* MSR and flags: We don't change CRs, and we don't need to alter |
---|
264 | | - * MSR. |
---|
| 273 | + /* ******************** AMR **************** */ |
---|
| 274 | + mfspr r3, SPRN_AMR |
---|
| 275 | + std r3, THREAD_TM_AMR(r12) |
---|
| 276 | + |
---|
| 277 | + /* |
---|
| 278 | + * MSR and flags: We don't change CRs, and we don't need to alter MSR. |
---|
265 | 279 | */ |
---|
266 | 280 | |
---|
267 | 281 | |
---|
268 | | - /* ******************** FPR/VR/VSRs ************ |
---|
| 282 | + /* |
---|
| 283 | + * ******************** FPR/VR/VSRs ************ |
---|
269 | 284 | * After reclaiming, capture the checkpointed FPRs/VRs. |
---|
270 | 285 | * |
---|
271 | 286 | * We enabled VEC/FP/VSX in the msr above, so we can execute these |
---|
.. | .. |
---|
275 | 290 | |
---|
276 | 291 | /* Altivec (VEC/VMX/VR)*/ |
---|
277 | 292 | addi r7, r3, THREAD_CKVRSTATE |
---|
278 | | - SAVE_32VRS(0, r6, r7) /* r6 scratch, r7 transact vr state */ |
---|
| 293 | + SAVE_32VRS(0, r6, r7) /* r6 scratch, r7 ckvr_state */ |
---|
279 | 294 | mfvscr v0 |
---|
280 | 295 | li r6, VRSTATE_VSCR |
---|
281 | 296 | stvx v0, r7, r6 |
---|
.. | .. |
---|
286 | 301 | |
---|
287 | 302 | /* Floating Point (FP) */ |
---|
288 | 303 | addi r7, r3, THREAD_CKFPSTATE |
---|
289 | | - SAVE_32FPRS_VSRS(0, R6, R7) /* r6 scratch, r7 transact fp state */ |
---|
| 304 | + SAVE_32FPRS_VSRS(0, R6, R7) /* r6 scratch, r7 ckfp_state */ |
---|
290 | 305 | mffs fr0 |
---|
291 | 306 | stfd fr0,FPSTATE_FPSCR(r7) |
---|
292 | 307 | |
---|
293 | 308 | |
---|
294 | | - /* TM regs, incl TEXASR -- these live in thread_struct. Note they've |
---|
| 309 | + /* |
---|
| 310 | + * TM regs, incl TEXASR -- these live in thread_struct. Note they've |
---|
295 | 311 | * been updated by the treclaim, to explain to userland the failure |
---|
296 | 312 | * cause (aborted). |
---|
297 | 313 | */ |
---|
.. | .. |
---|
302 | 318 | std r3, THREAD_TM_TFHAR(r12) |
---|
303 | 319 | std r4, THREAD_TM_TFIAR(r12) |
---|
304 | 320 | |
---|
305 | | - /* AMR is checkpointed too, but is unsupported by Linux. */ |
---|
| 321 | + /* Restore kernel live AMR */ |
---|
| 322 | + ld r8, TM_FRAME_L1(r1) |
---|
| 323 | + mtspr SPRN_AMR, r8 |
---|
306 | 324 | |
---|
307 | 325 | /* Restore original MSR/IRQ state & clear TM mode */ |
---|
308 | 326 | ld r14, TM_FRAME_L0(r1) /* Orig MSR */ |
---|
.. | .. |
---|
327 | 345 | blr |
---|
328 | 346 | |
---|
329 | 347 | |
---|
330 | | - /* |
---|
| 348 | + /* |
---|
331 | 349 | * void __tm_recheckpoint(struct thread_struct *thread) |
---|
332 | 350 | * - Restore the checkpointed register state saved by tm_reclaim |
---|
333 | 351 | * when we switch_to a process. |
---|
.. | .. |
---|
343 | 361 | std r2, STK_GOT(r1) |
---|
344 | 362 | stdu r1, -TM_FRAME_SIZE(r1) |
---|
345 | 363 | |
---|
346 | | - /* We've a struct pt_regs at [r1+STACK_FRAME_OVERHEAD]. |
---|
| 364 | + /* |
---|
| 365 | + * We've a struct pt_regs at [r1+STACK_FRAME_OVERHEAD]. |
---|
347 | 366 | * This is used for backing up the NVGPRs: |
---|
348 | 367 | */ |
---|
349 | 368 | SAVE_NVGPRS(r1) |
---|
| 369 | + |
---|
| 370 | + /* |
---|
| 371 | + * Save kernel live AMR since it will be clobbered for trechkpt |
---|
| 372 | + * but can be used elsewhere later in kernel space. |
---|
| 373 | + */ |
---|
| 374 | + mfspr r8, SPRN_AMR |
---|
| 375 | + std r8, TM_FRAME_L0(r1) |
---|
350 | 376 | |
---|
351 | 377 | /* Load complete register state from ts_ckpt* registers */ |
---|
352 | 378 | |
---|
353 | 379 | addi r7, r3, PT_CKPT_REGS /* Thread's ckpt_regs */ |
---|
354 | 380 | |
---|
355 | | - /* Make r7 look like an exception frame so that we |
---|
356 | | - * can use the neat GPRx(n) macros. r7 is now NOT a pt_regs ptr! |
---|
| 381 | + /* |
---|
| 382 | + * Make r7 look like an exception frame so that we can use the neat |
---|
| 383 | + * GPRx(n) macros. r7 is now NOT a pt_regs ptr! |
---|
357 | 384 | */ |
---|
358 | 385 | subi r7, r7, STACK_FRAME_OVERHEAD |
---|
359 | 386 | |
---|
.. | .. |
---|
396 | 423 | |
---|
397 | 424 | restore_gprs: |
---|
398 | 425 | |
---|
399 | | - /* ******************** CR,LR,CCR,MSR ********** */ |
---|
| 426 | + /* ****************** CTR, LR, XER ************* */ |
---|
400 | 427 | ld r4, _CTR(r7) |
---|
401 | 428 | ld r5, _LINK(r7) |
---|
402 | 429 | ld r8, _XER(r7) |
---|
.. | .. |
---|
408 | 435 | /* ******************** TAR ******************** */ |
---|
409 | 436 | ld r4, THREAD_TM_TAR(r3) |
---|
410 | 437 | mtspr SPRN_TAR, r4 |
---|
| 438 | + |
---|
| 439 | + /* ******************** AMR ******************** */ |
---|
| 440 | + ld r4, THREAD_TM_AMR(r3) |
---|
| 441 | + mtspr SPRN_AMR, r4 |
---|
411 | 442 | |
---|
412 | 443 | /* Load up the PPR and DSCR in GPRs only at this stage */ |
---|
413 | 444 | ld r5, THREAD_TM_DSCR(r3) |
---|
.. | .. |
---|
421 | 452 | |
---|
422 | 453 | REST_NVGPRS(r7) /* GPR14-31 */ |
---|
423 | 454 | |
---|
424 | | - /* Load up PPR and DSCR here so we don't run with user values for long |
---|
425 | | - */ |
---|
| 455 | + /* Load up PPR and DSCR here so we don't run with user values for long */ |
---|
426 | 456 | mtspr SPRN_DSCR, r5 |
---|
427 | 457 | mtspr SPRN_PPR, r6 |
---|
428 | 458 | |
---|
429 | | - /* Do final sanity check on TEXASR to make sure FS is set. Do this |
---|
| 459 | + /* |
---|
| 460 | + * Do final sanity check on TEXASR to make sure FS is set. Do this |
---|
430 | 461 | * here before we load up the userspace r1 so any bugs we hit will get |
---|
431 | | - * a call chain */ |
---|
| 462 | + * a call chain. |
---|
| 463 | + */ |
---|
432 | 464 | mfspr r5, SPRN_TEXASR |
---|
433 | 465 | srdi r5, r5, 16 |
---|
434 | 466 | li r6, (TEXASR_FS)@h |
---|
.. | .. |
---|
436 | 468 | 1: tdeqi r6, 0 |
---|
437 | 469 | EMIT_BUG_ENTRY 1b,__FILE__,__LINE__,0 |
---|
438 | 470 | |
---|
439 | | - /* Do final sanity check on MSR to make sure we are not transactional |
---|
440 | | - * or suspended |
---|
| 471 | + /* |
---|
| 472 | + * Do final sanity check on MSR to make sure we are not transactional |
---|
| 473 | + * or suspended. |
---|
441 | 474 | */ |
---|
442 | 475 | mfmsr r6 |
---|
443 | 476 | li r5, (MSR_TS_MASK)@higher |
---|
.. | .. |
---|
453 | 486 | REST_GPR(6, r7) |
---|
454 | 487 | |
---|
455 | 488 | /* |
---|
456 | | - * Store r1 and r5 on the stack so that we can access them |
---|
457 | | - * after we clear MSR RI. |
---|
| 489 | + * Store r1 and r5 on the stack so that we can access them after we |
---|
| 490 | + * clear MSR RI. |
---|
458 | 491 | */ |
---|
459 | 492 | |
---|
460 | 493 | REST_GPR(5, r7) |
---|
.. | .. |
---|
464 | 497 | |
---|
465 | 498 | REST_GPR(7, r7) |
---|
466 | 499 | |
---|
467 | | - /* Clear MSR RI since we are about to change r1. EE is already off */ |
---|
| 500 | + /* Clear MSR RI since we are about to use SCRATCH0. EE is already off */ |
---|
468 | 501 | li r5, 0 |
---|
469 | 502 | mtmsrd r5, 1 |
---|
470 | 503 | |
---|
.. | .. |
---|
484 | 517 | |
---|
485 | 518 | HMT_MEDIUM |
---|
486 | 519 | |
---|
487 | | - /* Our transactional state has now changed. |
---|
| 520 | + /* |
---|
| 521 | + * Our transactional state has now changed. |
---|
488 | 522 | * |
---|
489 | 523 | * Now just get out of here. Transactional (current) state will be |
---|
490 | 524 | * updated once restore is called on the return path in the _switch-ed |
---|
.. | .. |
---|
498 | 532 | li r4, MSR_RI |
---|
499 | 533 | mtmsrd r4, 1 |
---|
500 | 534 | |
---|
| 535 | + /* Restore kernel live AMR */ |
---|
| 536 | + ld r8, TM_FRAME_L0(r1) |
---|
| 537 | + mtspr SPRN_AMR, r8 |
---|
| 538 | + |
---|
501 | 539 | REST_NVGPRS(r1) |
---|
502 | 540 | |
---|
503 | 541 | addi r1, r1, TM_FRAME_SIZE |
---|