From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sasha Levin <sashal@kernel.org>,
Felipe Rechia <felipe.rechia@datacom.com.br>,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH AUTOSEL 4.19 126/237] powerpc/process: Fix flush_all_to_thread for SPE
Date: Sat, 16 Nov 2019 10:39:21 -0500 [thread overview]
Message-ID: <20191116154113.7417-126-sashal@kernel.org> (raw)
In-Reply-To: <20191116154113.7417-1-sashal@kernel.org>
From: Felipe Rechia <felipe.rechia@datacom.com.br>
[ Upstream commit e901378578c62202594cba0f6c076f3df365ec91 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/powerpc/kernel/process.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 909c9407e392a..02b69a68139cc 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -575,12 +575,11 @@ void flush_all_to_thread(struct task_struct *tsk)
if (tsk->thread.regs) {
preempt_disable();
BUG_ON(tsk != current);
- save_all(tsk);
-
#ifdef CONFIG_SPE
if (tsk->thread.regs->msr & MSR_SPE)
tsk->thread.spefscr = mfspr(SPRN_SPEFSCR);
#endif
+ save_all(tsk);
preempt_enable();
}
--
2.20.1
next prev parent reply other threads:[~2019-11-16 16:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191116154113.7417-1-sashal@kernel.org>
2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 010/237] powerpc: Fix signedness bug in update_flash_db() Sasha Levin
2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 011/237] powerpc/boot: Fix opal console in boot wrapper Sasha Levin
2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 012/237] powerpc/boot: Disable vector instructions Sasha Levin
2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 013/237] powerpc/eeh: Fix null deref for devices removed during EEH Sasha Levin
2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 014/237] powerpc/eeh: Fix use of EEH_PE_KEEP on wrong field Sasha Levin
2019-11-16 15:38 ` [PATCH AUTOSEL 4.19 075/237] macintosh/windfarm_smu_sat: Fix debug output Sasha Levin
2019-11-16 15:38 ` [PATCH AUTOSEL 4.19 091/237] powerpc/pseries: Export raw per-CPU VPA data via debugfs Sasha Levin
2019-11-16 15:38 ` [PATCH AUTOSEL 4.19 092/237] powerpc/mm/radix: Fix off-by-one in split mapping logic Sasha Levin
2019-11-16 15:38 ` [PATCH AUTOSEL 4.19 093/237] powerpc/mm/radix: Fix overuse of small pages in splitting logic Sasha Levin
2019-11-16 15:38 ` [PATCH AUTOSEL 4.19 094/237] powerpc/mm/radix: Fix small page at boundary when splitting Sasha Levin
2019-11-16 15:38 ` [PATCH AUTOSEL 4.19 095/237] powerpc/64s/radix: Fix radix__flush_tlb_collapsed_pmd double flushing pmd Sasha Levin
2019-11-16 15:39 ` Sasha Levin [this message]
2019-11-16 15:39 ` [PATCH AUTOSEL 4.19 143/237] powerpc/xmon: Relax frame size for clang Sasha Levin
2019-11-16 15:39 ` [PATCH AUTOSEL 4.19 144/237] selftests/powerpc/ptrace: Fix out-of-tree build Sasha Levin
2019-11-16 15:39 ` [PATCH AUTOSEL 4.19 145/237] selftests/powerpc/signal: " Sasha Levin
2019-11-16 15:39 ` [PATCH AUTOSEL 4.19 146/237] selftests/powerpc/switch_endian: " Sasha Levin
2019-11-16 15:39 ` [PATCH AUTOSEL 4.19 147/237] selftests/powerpc/cache_shape: " Sasha Levin
2019-11-16 15:39 ` [PATCH AUTOSEL 4.19 163/237] mm/memory_hotplug: make add_memory() take the device_hotplug_lock Sasha Levin
2019-11-16 15:40 ` [PATCH AUTOSEL 4.19 165/237] powerpc/powernv: hold device_hotplug_lock when calling device_online() Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191116154113.7417-126-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=felipe.rechia@datacom.com.br \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).