This moves us to save the Target Address Register (TAR) a earlier in __switch_to. It introduces a new function save_tar() to do this. We need to save the TAR earlier as we will overwrite it in the transactional memory reclaim/recheckpoint path. We are going to do this in a subsequent patch which will fix saving the TAR register when it's modified inside a transaction.
Unified · Split
| @@ -15,6 +15,15 @@ extern struct task_struct *__switch_to(struct task_struct *, · 14 unmodified lines | ||
| 15 | 15 | struct thread_struct; |
| 16 | 16 | extern struct task_struct *_switch(struct thread_struct *prev, |
| 17 | 17 | struct thread_struct *next); |
| 18 | +#ifdef CONFIG_PPC_BOOK3S_64 | |
| 19 | +static inline void save_tar(struct thread_struct *prev) | |
| 20 | +{ | |
| 21 | + if (cpu_has_feature(CPU_FTR_ARCH_207S)) | |
| 22 | + prev->tar = mfspr(SPRN_TAR); | |
| 23 | +} | |
| 24 | +#else | |
| 25 | +static inline void save_tar(struct thread_struct *prev) {} | |
| 26 | +#endif | |
| 18 | 27 | |
| 19 | 28 | extern void giveup_fpu(struct task_struct *); |
| 20 | 29 | extern void load_up_fpu(void); |
| @@ -449,15 +449,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_DSCR) · 448 unmodified lines | ||
| 449 | 449 | |
| 450 | 450 | #ifdef CONFIG_PPC_BOOK3S_64 |
| 451 | 451 | BEGIN_FTR_SECTION |
| 452 | − /* | |
| 453 | − * Back up the TAR across context switches. Note that the TAR is not | |
| 454 | − * available for use in the kernel. (To provide this, the TAR should | |
| 455 | − * be backed up/restored on exception entry/exit instead, and be in | |
| 456 | − * pt_regs. FIXME, this should be in pt_regs anyway (for debug).) | |
| 457 | − */ | |
| 458 | − mfspr r0,SPRN_TAR | |
| 459 | − std r0,THREAD_TAR(r3) | |
| 460 | − | |
| 461 | 452 | /* Event based branch registers */ |
| 462 | 453 | mfspr r0, SPRN_BESCR |
| 463 | 454 | std r0, THREAD_BESCR(r3) |
| @@ -600,6 +600,16 @@ struct task_struct *__switch_to(struct task_struct *prev, · 599 unmodified lines | ||
| 600 | 600 | struct ppc64_tlb_batch *batch; |
| 601 | 601 | #endif |
| 602 | 602 | |
| 603 | + /* Back up the TAR across context switches. | |
| 604 | + * Note that the TAR is not available for use in the kernel. (To | |
| 605 | + * provide this, the TAR should be backed up/restored on exception | |
| 606 | + * entry/exit instead, and be in pt_regs. FIXME, this should be in | |
| 607 | + * pt_regs anyway (for debug).) | |
| 608 | + * Save the TAR here before we do treclaim/trecheckpoint as these | |
| 609 | + * will change the TAR. | |
| 610 | + */ | |
| 611 | + save_tar(&prev->thread); | |
| 612 | + | |
| 603 | 613 | __switch_to_tm(prev); |
| 604 | 614 | |
| 605 | 615 | #ifdef CONFIG_SMP |