public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Andy Lutomirski <luto@kernel.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	Fenghua Yu <fenghua.yu@intel.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>,
	yu-cheng yu <yu-cheng.yu@intel.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Rik van Riel <riel@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH 1/5] x86/fpu: Fix math emulation in eager fpu mode
Date: Sat, 23 Jan 2016 11:02:54 +0100	[thread overview]
Message-ID: <20160123100253.GA16329@pd.tnic> (raw)
In-Reply-To: <b4b8d112436bd6fab866e1b4011131507e8d7fbe.1453510332.git.luto@kernel.org>

On Fri, Jan 22, 2016 at 04:56:02PM -0800, Andy Lutomirski wrote:
> Systems without an FPU are generally old and therefore use lazy FPU
> switching.  Unsurprisingly, math emulation in eager FPU mode is a
> bit buggy.  Fix it.
> 
> There were two bugs involving kernel code trying to use the FPU
> registers in eager mode even if they didn't exist and one BUG_ON
> that was incorrect.
> 
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
>  arch/x86/include/asm/fpu/internal.h | 3 ++-
>  arch/x86/kernel/fpu/core.c          | 2 +-
>  arch/x86/kernel/traps.c             | 1 -
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
> index 0fd440df63f1..a1f78a9fbf41 100644
> --- a/arch/x86/include/asm/fpu/internal.h
> +++ b/arch/x86/include/asm/fpu/internal.h
> @@ -589,7 +589,8 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu)
>  	 * If the task has used the math, pre-load the FPU on xsave processors
>  	 * or if the past 5 consecutive context-switches used math.
>  	 */
> -	fpu.preload = new_fpu->fpstate_active &&
> +	fpu.preload = static_cpu_has(X86_FEATURE_FPU) &&
> +		      new_fpu->fpstate_active &&
>  		      (use_eager_fpu() || new_fpu->counter > 5);

Should we move that static_cpu_has(X86_FEATURE_FPU) check in
use_eager_fpu()?

I mean, when !X86_FEATURE_FPU, then we most certainly aren't doing eager
FPU anyway.

Looking at the call sites briefly says we should be covered but I might
be missing out some detail.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

  reply	other threads:[~2016-01-23 10:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-23  0:56 [PATCH 0/5] x86/fpu: eagerfpu fixes, speedups, and default enablement Andy Lutomirski
2016-01-23  0:56 ` [PATCH 1/5] x86/fpu: Fix math emulation in eager fpu mode Andy Lutomirski
2016-01-23 10:02   ` Borislav Petkov [this message]
2016-01-23 17:40     ` Andy Lutomirski
2016-01-23 17:51       ` Borislav Petkov
2016-01-23  0:56 ` [PATCH 2/5] x86/fpu: Fix FNSAVE usage in eagerfpu mode Andy Lutomirski
2016-01-23  0:56 ` [PATCH 3/5] x86/fpu: Fold fpu_copy into fpu__copy Andy Lutomirski
2016-01-23  0:56 ` [PATCH 4/5] x86/fpu: Speed up lazy FPU restores slightly Andy Lutomirski
2016-01-23 10:14   ` Borislav Petkov
2016-01-23 22:09     ` Andy Lutomirski
2016-01-23 23:35       ` Borislav Petkov
2016-01-23  0:56 ` [PATCH 5/5] x86/fpu: Default eagerfpu=on on all CPUs Andy Lutomirski
2016-01-23 10:19   ` 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=20160123100253.GA16329@pd.tnic \
    --to=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=sai.praneeth.prakhya@intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    --cc=yu-cheng.yu@intel.com \
    /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