From: tip-bot for Christoph Hellwig <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: bigeasy@linutronix.de, hch@lst.de, jannh@google.com, bp@suse.de,
mingo@redhat.com, aubrey.li@intel.com, dave.hansen@intel.com,
linux-kernel@vger.kernel.org, hpa@zytor.com, x86@kernel.org,
tglx@linutronix.de, riel@surriel.com, mingo@kernel.org,
nstange@suse.de, peterz@infradead.org
Subject: [tip:x86/urgent] x86/fpu: Don't use current->mm to check for a kthread
Date: Thu, 13 Jun 2019 12:07:13 -0700 [thread overview]
Message-ID: <tip-8d3289f2fa1e0c7e2f72c7352f1efb75d2ad7c76@git.kernel.org> (raw)
In-Reply-To: <20190604175411.GA27477@lst.de>
Commit-ID: 8d3289f2fa1e0c7e2f72c7352f1efb75d2ad7c76
Gitweb: https://git.kernel.org/tip/8d3289f2fa1e0c7e2f72c7352f1efb75d2ad7c76
Author: Christoph Hellwig <hch@lst.de>
AuthorDate: Tue, 4 Jun 2019 19:54:12 +0200
Committer: Borislav Petkov <bp@suse.de>
CommitDate: Thu, 13 Jun 2019 20:57:49 +0200
x86/fpu: Don't use current->mm to check for a kthread
current->mm can be non-NULL if a kthread calls use_mm(). Check for
PF_KTHREAD instead to decide when to store user mode FP state.
Fixes: 2722146eb784 ("x86/fpu: Remove fpu->initialized")
Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Aubrey Li <aubrey.li@intel.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jann Horn <jannh@google.com>
Cc: Nicolai Stange <nstange@suse.de>
Cc: Rik van Riel <riel@surriel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20190604175411.GA27477@lst.de
---
arch/x86/include/asm/fpu/internal.h | 6 +++---
arch/x86/kernel/fpu/core.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
index 9e27fa05a7ae..4c95c365058a 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -536,7 +536,7 @@ static inline void __fpregs_load_activate(void)
struct fpu *fpu = ¤t->thread.fpu;
int cpu = smp_processor_id();
- if (WARN_ON_ONCE(current->mm == NULL))
+ if (WARN_ON_ONCE(current->flags & PF_KTHREAD))
return;
if (!fpregs_state_valid(fpu, cpu)) {
@@ -567,11 +567,11 @@ static inline void __fpregs_load_activate(void)
* otherwise.
*
* The FPU context is only stored/restored for a user task and
- * ->mm is used to distinguish between kernel and user threads.
+ * PF_KTHREAD is used to distinguish between kernel and user threads.
*/
static inline void switch_fpu_prepare(struct fpu *old_fpu, int cpu)
{
- if (static_cpu_has(X86_FEATURE_FPU) && current->mm) {
+ if (static_cpu_has(X86_FEATURE_FPU) && !(current->flags & PF_KTHREAD)) {
if (!copy_fpregs_to_fpstate(old_fpu))
old_fpu->last_cpu = -1;
else
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 466fca686fb9..649fbc3fcf9f 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -102,7 +102,7 @@ static void __kernel_fpu_begin(void)
kernel_fpu_disable();
- if (current->mm) {
+ if (!(current->flags & PF_KTHREAD)) {
if (!test_thread_flag(TIF_NEED_FPU_LOAD)) {
set_thread_flag(TIF_NEED_FPU_LOAD);
/*
prev parent reply other threads:[~2019-06-13 19:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-04 7:15 x86 fpu cleanups Christoph Hellwig
2019-06-04 7:15 ` [PATCH 1/3] x86/fpu: Simplify kernel_fpu_end Christoph Hellwig
2019-06-17 10:31 ` [tip:x86/fpu] x86/fpu: Simplify kernel_fpu_end() tip-bot for Christoph Hellwig
2019-06-04 7:15 ` [PATCH 2/3] x86/fpu: Simplify kernel_fpu_begin Christoph Hellwig
2019-06-04 11:47 ` Peter Zijlstra
2019-06-04 13:11 ` Christoph Hellwig
2019-06-04 13:34 ` Peter Zijlstra
2019-06-04 14:34 ` Christoph Hellwig
2019-06-17 10:31 ` [tip:x86/fpu] x86/fpu: Simplify kernel_fpu_begin() tip-bot for Christoph Hellwig
2019-06-04 7:15 ` [PATCH 3/3] x86/fpu: remove the fpu__save export Christoph Hellwig
2019-06-17 10:32 ` [tip:x86/fpu] x86/fpu: Remove the fpu__save() export tip-bot for Christoph Hellwig
2019-06-04 17:54 ` [PATCH 4/3] x86/fpu: don't use current->mm to check for a kthread Christoph Hellwig
2019-06-11 7:52 ` Sebastian Andrzej Siewior
2019-06-13 19:03 ` Borislav Petkov
2019-06-13 19:07 ` tip-bot for Christoph Hellwig [this message]
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=tip-8d3289f2fa1e0c7e2f72c7352f1efb75d2ad7c76@git.kernel.org \
--to=tipbot@zytor.com \
--cc=aubrey.li@intel.com \
--cc=bigeasy@linutronix.de \
--cc=bp@suse.de \
--cc=dave.hansen@intel.com \
--cc=hch@lst.de \
--cc=hpa@zytor.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=nstange@suse.de \
--cc=peterz@infradead.org \
--cc=riel@surriel.com \
--cc=tglx@linutronix.de \
--cc=x86@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
Powered by JetHome