aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include/asm/switch_to.h
diff options
context:
space:
mode:
authorSam bobroff <sam.bobroff@au1.ibm.com>2014-06-05 02:19:22 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-06-11 03:02:56 -0400
commit96d016108640bc2b7fb0ee800737f80923847294 (patch)
treefb14f3cf31e266ff70d4585c9d2aa91b5df5dc45 /arch/powerpc/include/asm/switch_to.h
parentfb5a515704d7e84c139140a83c5eff515adfc000 (diff)
powerpc: Correct DSCR during TM context switch
Correct the DSCR SPR becoming temporarily corrupted if a task is context switched during a transaction. The problem occurs while suspending the task and is caused by saving the DSCR to thread.dscr after it has already been set to the CPU's default value: __switch_to() calls __switch_to_tm() which calls tm_reclaim_task() which calls tm_reclaim_thread() which calls tm_reclaim() where the DSCR is set to the CPU's default __switch_to() calls _switch() where thread.dscr is set to the DSCR When the task is resumed, it's transaction will be doomed (as usual) and the DSCR SPR will be corrupted, although the checkpointed value will be correct. Therefore the DSCR will be immediately corrected by the transaction aborting, unless it has been suspended. In that case the incorrect value can be seen by the task until it resumes the transaction. The fix is to treat the DSCR similarly to the TAR and save it early in __switch_to(). A program exposing the problem is added to the kernel self tests as: tools/testing/selftests/powerpc/tm/tm-resched-dscr. Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com> CC: <stable@vger.kernel.org> [v3.10+] Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/include/asm/switch_to.h')
-rw-r--r--arch/powerpc/include/asm/switch_to.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h
index 0e83e7d8c73f..d2468eb12639 100644
--- a/arch/powerpc/include/asm/switch_to.h
+++ b/arch/powerpc/include/asm/switch_to.h
@@ -16,13 +16,15 @@ struct thread_struct;
16extern struct task_struct *_switch(struct thread_struct *prev, 16extern struct task_struct *_switch(struct thread_struct *prev,
17 struct thread_struct *next); 17 struct thread_struct *next);
18#ifdef CONFIG_PPC_BOOK3S_64 18#ifdef CONFIG_PPC_BOOK3S_64
19static inline void save_tar(struct thread_struct *prev) 19static inline void save_early_sprs(struct thread_struct *prev)
20{ 20{
21 if (cpu_has_feature(CPU_FTR_ARCH_207S)) 21 if (cpu_has_feature(CPU_FTR_ARCH_207S))
22 prev->tar = mfspr(SPRN_TAR); 22 prev->tar = mfspr(SPRN_TAR);
23 if (cpu_has_feature(CPU_FTR_DSCR))
24 prev->dscr = mfspr(SPRN_DSCR);
23} 25}
24#else 26#else
25static inline void save_tar(struct thread_struct *prev) {} 27static inline void save_early_sprs(struct thread_struct *prev) {}
26#endif 28#endif
27 29
28extern void enable_kernel_fp(void); 30extern void enable_kernel_fp(void);