powerpc: Save the TAR register earlier

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.

Signed-off-by: Michael Neuling <mikey@neuling.org>
Cc: <stable@vger.kernel.org> [v3.10]
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by Michael Neuling and committed by Benjamin Herrenschmidt c2d52644 2517617e

Changed files
+19 -9
arch
powerpc
include
kernel
+9
arch/powerpc/include/asm/switch_to.h
··· 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);
-9
arch/powerpc/kernel/entry_64.S
··· 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)
+10
arch/powerpc/kernel/process.c
··· 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