Fix race condition with FPU thread task flag during context switch.
PATCH v2 1/1 Fix race condition with FPU thread task flag during context switch.
From: "Steven J. Hill" <[email protected]>
--- arch/mips/include/asm/switch_to.h | 6 ++++-- arch/mips/kernel/r4k_switch.S | 12 +++--------- 2 files changed, 7 insertions(+), 11 deletions(-)
arch/mips/include/asm/switch_to.h +4 -2
@@ -22,7 +22,7 @@ struct task_struct;* switch_to(n) should switch tasks to task nr n, first * checking that n isn't the current task, in which case it does nothing. */ -extern asmlinkage void *resume(void *last, void *next, void *next_ti); +extern asmlinkage void *resume(void *last, void *next, void *next_ti, u32 __usedfpu);extern unsigned int ll_bit;extern struct task_struct *ll_task;
@@ -66,11 +66,13 @@ do { \#define switch_to (prev, next, last) \ do { \ + u32 __usedfpu; \ __mips_mt_fpaff_switch_to(prev); \ if (cpu_has_dsp) \ __save_dsp(prev); \ __clear_software_ll_bit(); \ - (last) = resume(prev, next, task_thread_info(next)); \ + __usedfpu = test_and_clear_tsk_thread_flag(prev, TIF_USEDFPU); \ + (last) = resume(prev, next, task_thread_info(next), __usedfpu); \ } while (0)#define finish_arch_switch (prev) \
arch/mips/kernel/r4k_switch.S +3 -9
@@ -41,7 +41,7 @@ /* * task_struct *resume(task_struct *prev, task_struct *next, - * struct thread_info *next_ti) + * struct thread_info *next_ti, u32 __usedfpu) */ .align 5 LEAF(resume)
@@ -53,16 +53,10 @@ /* * check if we need to save FPU registers */ - PTR_L t3, TASK_THREAD_INFO(a0) - LONG_L t0, TI_FLAGS(t3) - li t1, _TIF_USEDFPU - and t2, t0, t1 - beqz t2, 1f - nor t1, zero, t1 - and t0, t0, t1 - LONG_S t0, TI_FLAGS(t3) + beqz a3, 1f + PTR_L t3, TASK_THREAD_INFO(a0) /* * clear saved user stack CU1 bit */
Signature · 1 line
1.7.10
Quoted 4 lines · Steven J. Hill
From: "Steven J. Hill" <[email protected]>
Signed-off-by Leonid Yegoshin <[email protected]>Signed-off-by Steven J. Hill <[email protected]>
Good catch - but r2300_switch.S and octeon_switch.S needed the same modification. Also, who is the author, Leonid or Steven?
Ralf
Leonid is the author of this patch. The r2300_switch.S is easy enough to fix, but octeon_switch.S is nothing like the others, so someone else will have to fix that.
-Steve
Quoted 3 lines · Steven
Leonid is the author of this patch. The
r2300_switch.Sis easy enough to fix, butocteon_switch.Sis nothing like the others, so someone else will have to fix that.
octeon_switch.S thanks to Octeon not featuring an FPU does not require this fix. I've already patched that up here, was just waiting for confirmation of authorship to get the commit right.
Thanks!
Ralf
Hello.
Quoted 1 line · Steven
Leonid is the author of this patch.
Then, for the future, you should put the real author in the From: field of
the patch.
Quoted 1 line
-Steve
WBR, Sergei
How about in the future you stop using reply all?
Hello.
Quoted 1 line · Steven
How about in the future you stop using reply all?
Using reply-to-all on the mailing lists is normal default behavior. I don't
quite understand what's your problem with this.
WBR, Sergei