All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave@sr71.net>
To: dave@sr71.net
Cc: dave.hansen@linux.intel.com, mingo@redhat.com, x86@kernel.org,
	bp@alien8.de, fenghua.yu@intel.com, tim.c.chen@linux.intel.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH 02/15] x86, fpu: move XSAVE-disabling code to a helper
Date: Wed, 02 Sep 2015 16:31:24 -0700	[thread overview]
Message-ID: <20150902233124.EA9A70E5@viggo.jf.intel.com> (raw)
In-Reply-To: <20150902233123.3A7E5FB0@viggo.jf.intel.com>


From: Dave Hansen <dave.hansen@linux.intel.com>

When we want to _completely_ disable XSAVE support as far as
the kernel is concerned, we have a big set of feature flags
to clear.  We currently only do this in cases where the user
asks for it to be disabled, but we are about to expand the
places where we do it to handle errors too.

Move the code in to xstate.c, and put it in the xstate.h
header.  We will use it in the next patch too.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: x86@kernel.org
Cc: Borislav Petkov <bp@alien8.de>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
---

 b/arch/x86/include/asm/fpu/xstate.h |    1 +
 b/arch/x86/kernel/fpu/init.c        |   12 +-----------
 b/arch/x86/kernel/fpu/xstate.c      |   19 +++++++++++++++++++
 3 files changed, 21 insertions(+), 11 deletions(-)

diff -puN arch/x86/include/asm/fpu/xstate.h~clear-all-xsave-cpu-caps arch/x86/include/asm/fpu/xstate.h
--- a/arch/x86/include/asm/fpu/xstate.h~clear-all-xsave-cpu-caps	2015-09-02 15:52:47.582783889 -0700
+++ b/arch/x86/include/asm/fpu/xstate.h	2015-09-02 16:26:19.739216233 -0700
@@ -40,6 +40,7 @@ extern u64 xstate_fx_sw_bytes[USER_XSTAT
 
 extern void update_regset_xstate_info(unsigned int size, u64 xstate_mask);
 
+void fpu__xstate_clear_all_cpu_caps(void);
 void *get_xsave_addr(struct xregs_state *xsave, int xstate);
 const void *get_xsave_field_ptr(int xstate_field);
 
diff -puN arch/x86/kernel/fpu/init.c~clear-all-xsave-cpu-caps arch/x86/kernel/fpu/init.c
--- a/arch/x86/kernel/fpu/init.c~clear-all-xsave-cpu-caps	2015-09-02 15:52:47.583783934 -0700
+++ b/arch/x86/kernel/fpu/init.c	2015-09-02 16:26:19.739216233 -0700
@@ -354,17 +354,7 @@ static int __init x86_noxsave_setup(char
 	if (strlen(s))
 		return 0;
 
-	setup_clear_cpu_cap(X86_FEATURE_XSAVE);
-	setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
-	setup_clear_cpu_cap(X86_FEATURE_XSAVEC);
-	setup_clear_cpu_cap(X86_FEATURE_XSAVES);
-	setup_clear_cpu_cap(X86_FEATURE_AVX);
-	setup_clear_cpu_cap(X86_FEATURE_AVX2);
-	setup_clear_cpu_cap(X86_FEATURE_AVX512F);
-	setup_clear_cpu_cap(X86_FEATURE_AVX512PF);
-	setup_clear_cpu_cap(X86_FEATURE_AVX512ER);
-	setup_clear_cpu_cap(X86_FEATURE_AVX512CD);
-	setup_clear_cpu_cap(X86_FEATURE_MPX);
+	fpu__xstate_clear_all_cpu_caps();
 
 	return 1;
 }
diff -puN arch/x86/kernel/fpu/xstate.c~clear-all-xsave-cpu-caps arch/x86/kernel/fpu/xstate.c
--- a/arch/x86/kernel/fpu/xstate.c~clear-all-xsave-cpu-caps	2015-09-02 15:52:47.585784026 -0700
+++ b/arch/x86/kernel/fpu/xstate.c	2015-09-02 16:26:25.775490411 -0700
@@ -39,6 +39,25 @@ static unsigned int xstate_comp_offsets[
 static unsigned int xfeatures_nr;
 
 /*
+ * Clear all of the X86_FEATURE_* bits that are unavailable
+ * when the CPU has no XSAVE support.
+ */
+void fpu__xstate_clear_all_cpu_caps(void)
+{
+	setup_clear_cpu_cap(X86_FEATURE_XSAVE);
+	setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
+	setup_clear_cpu_cap(X86_FEATURE_XSAVEC);
+	setup_clear_cpu_cap(X86_FEATURE_XSAVES);
+	setup_clear_cpu_cap(X86_FEATURE_AVX);
+	setup_clear_cpu_cap(X86_FEATURE_AVX2);
+	setup_clear_cpu_cap(X86_FEATURE_AVX512F);
+	setup_clear_cpu_cap(X86_FEATURE_AVX512PF);
+	setup_clear_cpu_cap(X86_FEATURE_AVX512ER);
+	setup_clear_cpu_cap(X86_FEATURE_AVX512CD);
+	setup_clear_cpu_cap(X86_FEATURE_MPX);
+}
+
+/*
  * Return whether the system supports a given xfeature.
  *
  * Also return the name of the (most advanced) feature that the caller requested:
_

  reply	other threads:[~2015-09-02 23:31 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02 23:31 [PATCH 00/15] [v4] x86, fpu: XSAVE cleanups and sanity checks Dave Hansen
2015-09-02 23:31 ` Dave Hansen [this message]
2015-09-14 12:19   ` [tip:x86/fpu] x86/fpu: Move XSAVE-disabling code to a helper tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 01/15] x86, fpu: print xfeature buffer size in decimal Dave Hansen
2015-09-14 12:19   ` [tip:x86/fpu] x86/fpu: Print " tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 03/15] x86, fpu: remove XSTATE_RESERVE Dave Hansen
2015-09-14 12:20   ` [tip:x86/fpu] x86/fpu: Remove XSTATE_RESERVE tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 04/15] x86, fpu: kill LWP support Dave Hansen
2015-09-14 12:20   ` [tip:x86/fpu] x86/fpu: Remove partial LWP support definitions tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 05/15] x86, fpu: XSAVE macro renames Dave Hansen
2015-09-14 12:21   ` [tip:x86/fpu] x86/fpu: Rename XSAVE macros tip-bot for Dave Hansen
2015-09-23 10:49     ` Borislav Petkov
2015-09-24  7:24       ` [tip:x86/fpu] x86/fpu: Fixup uninitialized feature_name warning tip-bot for Borislav Petkov
2015-09-02 23:31 ` [PATCH 06/15] x86, fpu: rename XFEATURES_NR_MAX Dave Hansen
2015-09-14 12:21   ` [tip:x86/fpu] x86/fpu: Rename XFEATURES_NR_MAX tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 07/15] x86, fpu: rework XSTATE_* macros to remove magic '2' Dave Hansen
2015-09-14 12:21   ` [tip:x86/fpu] x86/fpu: Rework " tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 08/15] x86, fpu: remove xfeature_nr Dave Hansen
2015-09-14 12:22   ` [tip:x86/fpu] x86/fpu: Remove 'xfeature_nr' tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 11/15] x86, fpu: rework YMM definition Dave Hansen
2015-09-14 12:23   ` [tip:x86/fpu] x86/fpu: Rework " tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 12/15] x86, fpu: add C structures for AVX-512 state components Dave Hansen
2015-09-14 12:23   ` [tip:x86/fpu] x86/fpu: Add " tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 10/15] x86, fpu: rework MPX 'xstate' types Dave Hansen
2015-09-14 12:22   ` [tip:x86/fpu] x86/fpu/mpx: Rework " tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 09/15] x86, fpu: add helper xfeature_enabled() instead of test_bit() Dave Hansen
2015-09-14 12:22   ` [tip:x86/fpu] x86/fpu: Add xfeature_enabled() helper " tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 14/15] x86, fpu: check to ensure increasing-offset xstate offsets Dave Hansen
2015-09-14 12:24   ` [tip:x86/fpu] x86/fpu: Check " tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 13/15] x86, fpu: correct and check XSAVE xstate size calculations Dave Hansen
2015-09-14 12:23   ` [tip:x86/fpu] x86/fpu: Correct " tip-bot for Dave Hansen
2015-09-02 23:31 ` [PATCH 15/15] x86, fpu: check CPU-provided sizes against struct declarations Dave Hansen
2015-09-14 12:24   ` [tip:x86/fpu] x86/fpu: Check " tip-bot for Dave Hansen
2015-09-14 10:07 ` [PATCH 00/15] [v4] x86, fpu: XSAVE cleanups and sanity checks Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2015-08-31 22:20 [PATCH 00/15] [v3] " Dave Hansen
2015-08-31 22:20 ` [PATCH 02/15] x86, fpu: move XSAVE-disabling code to a helper Dave Hansen

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=20150902233124.EA9A70E5@viggo.jf.intel.com \
    --to=dave@sr71.net \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tim.c.chen@linux.intel.com \
    --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 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.