aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Hansen <dave.hansen@linux.intel.com>2015-09-02 19:31:24 -0400
committerIngo Molnar <mingo@kernel.org>2015-09-14 06:07:56 -0400
commit0a265375028b241a9173b7c569dd2368ba97fcd4 (patch)
tree08afe6d425ae34361d545d8eb0d00bb4ff425950
parentb0815359590f496f80e355a74319b6dc77010951 (diff)
x86/fpu: Move XSAVE-disabling code to a helper
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: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tim Chen <tim.c.chen@linux.intel.com> Cc: dave@sr71.net Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/20150902233124.EA9A70E5@viggo.jf.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/include/asm/fpu/xstate.h1
-rw-r--r--arch/x86/kernel/fpu/init.c12
-rw-r--r--arch/x86/kernel/fpu/xstate.c19
3 files changed, 21 insertions, 11 deletions
diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h
index 4656b25bb9a7..d5a9b736553c 100644
--- a/arch/x86/include/asm/fpu/xstate.h
+++ b/arch/x86/include/asm/fpu/xstate.h
@@ -40,6 +40,7 @@ extern u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
40 40
41extern void update_regset_xstate_info(unsigned int size, u64 xstate_mask); 41extern void update_regset_xstate_info(unsigned int size, u64 xstate_mask);
42 42
43void fpu__xstate_clear_all_cpu_caps(void);
43void *get_xsave_addr(struct xregs_state *xsave, int xstate); 44void *get_xsave_addr(struct xregs_state *xsave, int xstate);
44const void *get_xsave_field_ptr(int xstate_field); 45const void *get_xsave_field_ptr(int xstate_field);
45 46
diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index d14e9ac3235a..0a250afc6cdf 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -354,17 +354,7 @@ static int __init x86_noxsave_setup(char *s)
354 if (strlen(s)) 354 if (strlen(s))
355 return 0; 355 return 0;
356 356
357 setup_clear_cpu_cap(X86_FEATURE_XSAVE); 357 fpu__xstate_clear_all_cpu_caps();
358 setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
359 setup_clear_cpu_cap(X86_FEATURE_XSAVEC);
360 setup_clear_cpu_cap(X86_FEATURE_XSAVES);
361 setup_clear_cpu_cap(X86_FEATURE_AVX);
362 setup_clear_cpu_cap(X86_FEATURE_AVX2);
363 setup_clear_cpu_cap(X86_FEATURE_AVX512F);
364 setup_clear_cpu_cap(X86_FEATURE_AVX512PF);
365 setup_clear_cpu_cap(X86_FEATURE_AVX512ER);
366 setup_clear_cpu_cap(X86_FEATURE_AVX512CD);
367 setup_clear_cpu_cap(X86_FEATURE_MPX);
368 358
369 return 1; 359 return 1;
370} 360}
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index b790dcbd3d2a..2ada11c0f8d7 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -39,6 +39,25 @@ static unsigned int xstate_comp_offsets[sizeof(xfeatures_mask)*8];
39static unsigned int xfeatures_nr; 39static unsigned int xfeatures_nr;
40 40
41/* 41/*
42 * Clear all of the X86_FEATURE_* bits that are unavailable
43 * when the CPU has no XSAVE support.
44 */
45void fpu__xstate_clear_all_cpu_caps(void)
46{
47 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
48 setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
49 setup_clear_cpu_cap(X86_FEATURE_XSAVEC);
50 setup_clear_cpu_cap(X86_FEATURE_XSAVES);
51 setup_clear_cpu_cap(X86_FEATURE_AVX);
52 setup_clear_cpu_cap(X86_FEATURE_AVX2);
53 setup_clear_cpu_cap(X86_FEATURE_AVX512F);
54 setup_clear_cpu_cap(X86_FEATURE_AVX512PF);
55 setup_clear_cpu_cap(X86_FEATURE_AVX512ER);
56 setup_clear_cpu_cap(X86_FEATURE_AVX512CD);
57 setup_clear_cpu_cap(X86_FEATURE_MPX);
58}
59
60/*
42 * Return whether the system supports a given xfeature. 61 * Return whether the system supports a given xfeature.
43 * 62 *
44 * Also return the name of the (most advanced) feature that the caller requested: 63 * Also return the name of the (most advanced) feature that the caller requested: