diff options
author | Felipe Rechia <felipe.rechia@datacom.com.br> | 2018-10-24 09:57:22 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-10-26 06:58:58 -0400 |
commit | e901378578c62202594cba0f6c076f3df365ec91 (patch) | |
tree | 1b16ca7e9f1075a5cc6104c3650e93e87d844c83 | |
parent | 8dce6b2215eaa91dbf04463e11098a48748da5ab (diff) |
powerpc/process: Fix flush_all_to_thread for SPE
Fix a bug introduced by the creation of flush_all_to_thread() for
processors that have SPE (Signal Processing Engine) and use it to
compute floating-point operations.
>From userspace perspective, the problem was seen in attempts of
computing floating-point operations which should generate exceptions.
For example:
fork();
float x = 0.0 / 0.0;
isnan(x); // forked process returns False (should be True)
The operation above also should always cause the SPEFSCR FINV bit to
be set. However, the SPE floating-point exceptions were turned off
after a fork().
Kernel versions prior to the bug used flush_spe_to_thread(), which
first saves SPEFSCR register values in tsk->thread and then calls
giveup_spe(tsk).
After commit 579e633e764e, the save_all() function was called first
to giveup_spe(), and then the SPEFSCR register values were saved in
tsk->thread. This would save the SPEFSCR register values after
disabling SPE for that thread, causing the bug described above.
Fixes 579e633e764e ("powerpc: create flush_all_to_thread()")
Signed-off-by: Felipe Rechia <felipe.rechia@datacom.com.br>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | arch/powerpc/kernel/process.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 7ad304a3cc7d..bcb36229d4fd 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c | |||
@@ -590,12 +590,11 @@ void flush_all_to_thread(struct task_struct *tsk) | |||
590 | if (tsk->thread.regs) { | 590 | if (tsk->thread.regs) { |
591 | preempt_disable(); | 591 | preempt_disable(); |
592 | BUG_ON(tsk != current); | 592 | BUG_ON(tsk != current); |
593 | save_all(tsk); | ||
594 | |||
595 | #ifdef CONFIG_SPE | 593 | #ifdef CONFIG_SPE |
596 | if (tsk->thread.regs->msr & MSR_SPE) | 594 | if (tsk->thread.regs->msr & MSR_SPE) |
597 | tsk->thread.spefscr = mfspr(SPRN_SPEFSCR); | 595 | tsk->thread.spefscr = mfspr(SPRN_SPEFSCR); |
598 | #endif | 596 | #endif |
597 | save_all(tsk); | ||
599 | 598 | ||
600 | preempt_enable(); | 599 | preempt_enable(); |
601 | } | 600 | } |