[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20150902233124.EA9A70E5@viggo.jf.intel.com>
Date: Wed, 02 Sep 2015 16:31:24 -0700
From: Dave Hansen <dave@...1.net>
To: dave@...1.net
Cc: dave.hansen@...ux.intel.com, mingo@...hat.com, x86@...nel.org,
bp@...en8.de, fenghua.yu@...el.com, tim.c.chen@...ux.intel.com,
linux-kernel@...r.kernel.org
Subject: [PATCH 02/15] x86, fpu: move XSAVE-disabling code to a helper
From: Dave Hansen <dave.hansen@...ux.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@...ux.intel.com>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: x86@...nel.org
Cc: Borislav Petkov <bp@...en8.de>
Cc: Fenghua Yu <fenghua.yu@...el.com>
Cc: Tim Chen <tim.c.chen@...ux.intel.com>
Cc: linux-kernel@...r.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:
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists