All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: linux-kernel@vger.kernel.org, peterz@infradead.org,
	torvalds@linux-foundation.org, tglx@linutronix.de,
	oleg@redhat.com, ravi.v.shankar@intel.com, yu-cheng.yu@intel.com,
	fenghua.yu@intel.com, mingo@kernel.org,
	dave.hansen@linux.intel.com, quentin.casasnovas@oracle.com,
	bp@suse.de, hpa@zytor.com, luto@amacapital.net,
	sai.praneeth.prakhya@intel.com
Cc: linux-tip-commits@vger.kernel.org
Subject: Re: [tip:x86/asm] x86/fpu: Fix early FPU command-line parsing
Date: Fri, 15 Jan 2016 21:28:58 +0100	[thread overview]
Message-ID: <20160115202858.GK25104@pd.tnic> (raw)
In-Reply-To: <tip-4f81cbafcce2c603db7865e9d0e461f7947d77d4@git.kernel.org>

On Tue, Jan 12, 2016 at 04:00:49AM -0800, tip-bot for yu-cheng yu wrote:
> Commit-ID:  4f81cbafcce2c603db7865e9d0e461f7947d77d4
> Gitweb:     http://git.kernel.org/tip/4f81cbafcce2c603db7865e9d0e461f7947d77d4
> Author:     yu-cheng yu <yu-cheng.yu@intel.com>
> AuthorDate: Wed, 6 Jan 2016 14:24:51 -0800
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Tue, 12 Jan 2016 11:51:20 +0100
> 
> x86/fpu: Fix early FPU command-line parsing
> 
> The function fpu__init_system() is executed before
> parse_early_param(). This causes wrong FPU configuration. This
> patch fixes this issue by parsing boot_command_line in the
> beginning of fpu__init_system().
> 
> With all four patches in this series, each parameter disables
> features as the following:
> 
> eagerfpu=off: eagerfpu, avx, avx2, avx512, mpx
> no387: fpu
> nofxsr: fxsr, fxsropt, xmm
> noxsave: xsave, xsaveopt, xsaves, xsavec, avx, avx2, avx512,
> mpx, xgetbv1 noxsaveopt: xsaveopt
> noxsaves: xsaves
> 
> Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Fenghua Yu <fenghua.yu@intel.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
> Cc: Ravi V. Shankar <ravi.v.shankar@intel.com>
> Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: yu-cheng yu <yu-cheng.yu@intel.com>
> Link: http://lkml.kernel.org/r/1452119094-7252-2-git-send-email-yu-cheng.yu@intel.com
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> ---
>  arch/x86/kernel/fpu/init.c | 109 ++++++++++++++++-----------------------------
> 1 file changed, 38 insertions(+), 71 deletions(-)

...

> + * We parse fpu parameters early because fpu__init_system() is executed
> + * before parse_early_param().
> + */
> +static void __init fpu__init_parse_early_param(void)
> +{
> +	/*
> +	 * No need to check "eagerfpu=auto" again, since it is the
> +	 * initial default.
> +	 */
> +	if (cmdline_find_option_bool(boot_command_line, "eagerfpu=off"))
> +		eagerfpu = DISABLE;
> +	else if (cmdline_find_option_bool(boot_command_line, "eagerfpu=on"))
> +		eagerfpu = ENABLE;
> +
> +	if (cmdline_find_option_bool(boot_command_line, "no387"))
> +		setup_clear_cpu_cap(X86_FEATURE_FPU);
> +
> +	if (cmdline_find_option_bool(boot_command_line, "nofxsr")) {
> +		setup_clear_cpu_cap(X86_FEATURE_FXSR);
> +		setup_clear_cpu_cap(X86_FEATURE_FXSR_OPT);
> +		setup_clear_cpu_cap(X86_FEATURE_XMM);
> +	}
> +
> +	if (cmdline_find_option_bool(boot_command_line, "noxsave"))
> +		fpu__xstate_clear_all_cpu_caps();
> +
> +	if (cmdline_find_option_bool(boot_command_line, "noxsaveopt"))
> +		setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
> +
> +	if (cmdline_find_option_bool(boot_command_line, "noxsaves"))
> +		setup_clear_cpu_cap(X86_FEATURE_XSAVES);

This could certainly be improved: we're iterating over the *whole*
command line each time for each option unconditionally instead of
iterating word by word and comparing it with all strings.

We'd need something like cmdline_for_each_word() or so, though...

-- 
Regards/Gruss,
    Boris.

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

  reply	other threads:[~2016-01-15 20:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-06 22:24 [PATCH 0/4] x86/fpu: FPU init code bugfixes yu-cheng yu
2016-01-06 22:24 ` [PATCH 1/4] x86/fpu: Fix early fpu command-line parsing yu-cheng yu
2016-01-12 12:00   ` [tip:x86/asm] x86/fpu: Fix early FPU " tip-bot for yu-cheng yu
2016-01-15 20:28     ` Borislav Petkov [this message]
2016-01-15 20:50       ` Yu-cheng Yu
2016-01-15 21:01         ` Dave Hansen
2016-01-15 21:09           ` Borislav Petkov
2016-01-06 22:24 ` [PATCH 2/4] x86/fpu: Disable XGETBV1 when no XSAVE yu-cheng yu
2016-01-12 12:01   ` [tip:x86/asm] " tip-bot for yu-cheng yu
2016-01-06 22:24 ` [PATCH 3/4] x86/fpu: Disable MPX when eagerfpu is off yu-cheng yu
2016-01-12 12:01   ` [tip:x86/asm] " tip-bot for yu-cheng yu
2016-01-06 22:24 ` [PATCH 4/4] x86/fpu: Disable AVX " yu-cheng yu
2016-01-12 12:01   ` [tip:x86/asm] " tip-bot for yu-cheng yu

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=20160115202858.GK25104@pd.tnic \
    --to=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=quentin.casasnovas@oracle.com \
    --cc=ravi.v.shankar@intel.com \
    --cc=sai.praneeth.prakhya@intel.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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 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.