All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Oleg Nesterov <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: oleg@redhat.com, hpa@zytor.com, tglx@linutronix.de, bp@suse.de,
	torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
	riel@redhat.com, mingo@kernel.org
Subject: [tip:x86/fpu] x86/fpu: Change math_error() to use unlazy_fpu(), kill (now) unused save_init_fpu()
Date: Thu, 19 Feb 2015 03:32:58 -0800	[thread overview]
Message-ID: <tip-08a744c6bfded3d5fa66f94263f81773226113d1@git.kernel.org> (raw)
In-Reply-To: <1423252925-14451-4-git-send-email-riel@redhat.com>

Commit-ID:  08a744c6bfded3d5fa66f94263f81773226113d1
Gitweb:     http://git.kernel.org/tip/08a744c6bfded3d5fa66f94263f81773226113d1
Author:     Oleg Nesterov <oleg@redhat.com>
AuthorDate: Fri, 6 Feb 2015 15:02:00 -0500
Committer:  Borislav Petkov <bp@suse.de>
CommitDate: Thu, 19 Feb 2015 11:15:03 +0100

x86/fpu: Change math_error() to use unlazy_fpu(), kill (now) unused save_init_fpu()

math_error() calls save_init_fpu() after conditional_sti(), this means
that the caller can be preempted. If !use_eager_fpu() we can hit the
WARN_ON_ONCE(!__thread_has_fpu(tsk)) and/or save the wrong FPU state.

Change math_error() to use unlazy_fpu() and kill save_init_fpu().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Rik van Riel <riel@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/1423252925-14451-4-git-send-email-riel@redhat.com
Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/include/asm/fpu-internal.h | 18 ------------------
 arch/x86/kernel/traps.c             |  2 +-
 2 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
index e97622f..02f2e08 100644
--- a/arch/x86/include/asm/fpu-internal.h
+++ b/arch/x86/include/asm/fpu-internal.h
@@ -518,24 +518,6 @@ static inline void __save_fpu(struct task_struct *tsk)
 }
 
 /*
- * These disable preemption on their own and are safe
- */
-static inline void save_init_fpu(struct task_struct *tsk)
-{
-	WARN_ON_ONCE(!__thread_has_fpu(tsk));
-
-	if (use_eager_fpu()) {
-		__save_fpu(tsk);
-		return;
-	}
-
-	preempt_disable();
-	__save_init_fpu(tsk);
-	__thread_fpu_end(tsk);
-	preempt_enable();
-}
-
-/*
  * i387 state interaction
  */
 static inline unsigned short get_fpu_cwd(struct task_struct *tsk)
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 88900e2..9d889f7 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -663,7 +663,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)
 	/*
 	 * Save the info for the exception handler and clear the error.
 	 */
-	save_init_fpu(task);
+	unlazy_fpu(task);
 	task->thread.trap_nr = trapnr;
 	task->thread.error_code = error_code;
 	info.si_signo = SIGFPE;

  parent reply	other threads:[~2015-02-19 11:33 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-06 20:01 [PATCH 0/8] x86,fpu: various small FPU cleanups and optimizations riel
2015-02-06 20:01 ` [PATCH 1/8] x86, fpu: unlazy_fpu: don't reset thread.fpu_counter riel
2015-02-16 17:04   ` Borislav Petkov
2015-02-16 17:58     ` Rik van Riel
2015-02-16 18:14       ` Oleg Nesterov
2015-02-16 18:16         ` Borislav Petkov
2015-02-19 11:32   ` [tip:x86/fpu] x86/fpu: Don't " tip-bot for Oleg Nesterov
2015-02-06 20:01 ` [PATCH 2/8] x86, fpu: unlazy_fpu: don't do __thread_fpu_end() if use_eager_fpu() riel
2015-02-16 20:25   ` Borislav Petkov
2015-02-17 10:47     ` Oleg Nesterov
2015-02-17 12:09       ` Borislav Petkov
2015-02-19 11:32   ` [tip:x86/fpu] x86/fpu: Don't " tip-bot for Oleg Nesterov
2015-02-06 20:02 ` [PATCH 3/8] x86, fpu: kill save_init_fpu(), change math_error() to use unlazy_fpu() riel
2015-02-16 21:09   ` Borislav Petkov
2015-02-16 21:30     ` Rik van Riel
2015-02-17 10:58       ` Oleg Nesterov
2015-02-19 11:32   ` tip-bot for Oleg Nesterov [this message]
2015-02-06 20:02 ` [PATCH 4/8] x86,fpu: move lazy restore functions up a few lines riel
2015-02-19 11:33   ` [tip:x86/fpu] x86/fpu: Move " tip-bot for Rik van Riel
2015-02-06 20:02 ` [PATCH 5/8] x86,fpu: introduce task_disable_lazy_fpu_restore helper riel
2015-02-19 11:33   ` [tip:x86/fpu] x86/fpu: Introduce task_disable_lazy_fpu_restore() helper tip-bot for Rik van Riel
2015-02-06 20:02 ` [PATCH 6/8] x86,fpu: use an explicit if/else in switch_fpu_prepare riel
2015-02-17  8:44   ` Borislav Petkov
2015-02-19 11:33   ` [tip:x86/fpu] x86/fpu: Use an explicit if/ else in switch_fpu_prepare() tip-bot for Rik van Riel
2015-02-06 20:02 ` [PATCH 7/8] x86,fpu: use disable_task_lazy_fpu_restore helper riel
2015-02-17  9:00   ` Borislav Petkov
2015-02-17 11:04     ` Oleg Nesterov
2015-02-17 12:11       ` Borislav Petkov
2015-02-19 11:34   ` [tip:x86/fpu] x86/fpu: Use task_disable_lazy_fpu_restore() helper tip-bot for Rik van Riel
2015-02-06 20:02 ` [PATCH 8/8] x86,fpu: also check fpu_lazy_restore when use_eager_fpu riel
2015-02-19 11:34   ` [tip:x86/fpu] x86/fpu: Also check fpu_lazy_restore() when use_eager_fpu() tip-bot for Rik van Riel
2015-02-16 15:26 ` [PATCH 0/8] x86,fpu: various small FPU cleanups and optimizations Rik van Riel
2015-02-16 16:00   ` Borislav Petkov

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-08a744c6bfded3d5fa66f94263f81773226113d1@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.