aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu-cheng Yu <yu-cheng.yu@intel.com>2017-01-24 13:25:46 -0500
committerIngo Molnar <mingo@kernel.org>2017-01-25 02:25:12 -0500
commita5828ed3d03d38399159dc17a98cefde3109a66b (patch)
tree07dc07c7f98988890801687c30964f7cdcace20a
parentdffba9a31c7769be3231c420d4b364c92ba3f1ac (diff)
x86/fpu/xstate: Move XSAVES state init to a function
Make XSTATE init similar to existing code; move it to a separate function. There is no functionality change. Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.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: Ravi V. Shankar <ravi.v.shankar@intel.com> Cc: Rik van Riel <riel@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1485282346-15437-1-git-send-email-yu-cheng.yu@intel.com [ Minor cleanliness edits. ] Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/include/asm/fpu/internal.h10
-rw-r--r--arch/x86/kernel/fpu/core.c9
2 files changed, 11 insertions, 8 deletions
diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
index d4a684997497..255645f60ca2 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -87,6 +87,16 @@ extern void fpstate_init_soft(struct swregs_state *soft);
87#else 87#else
88static inline void fpstate_init_soft(struct swregs_state *soft) {} 88static inline void fpstate_init_soft(struct swregs_state *soft) {}
89#endif 89#endif
90
91static inline void fpstate_init_xstate(struct xregs_state *xsave)
92{
93 /*
94 * XRSTORS requires these bits set in xcomp_bv, or it will
95 * trigger #GP:
96 */
97 xsave->header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT | xfeatures_mask;
98}
99
90static inline void fpstate_init_fxstate(struct fxregs_state *fx) 100static inline void fpstate_init_fxstate(struct fxregs_state *fx)
91{ 101{
92 fx->cwd = 0x37f; 102 fx->cwd = 0x37f;
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index de7234401275..e1114f070c2d 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -9,7 +9,6 @@
9#include <asm/fpu/regset.h> 9#include <asm/fpu/regset.h>
10#include <asm/fpu/signal.h> 10#include <asm/fpu/signal.h>
11#include <asm/fpu/types.h> 11#include <asm/fpu/types.h>
12#include <asm/fpu/xstate.h>
13#include <asm/traps.h> 12#include <asm/traps.h>
14 13
15#include <linux/hardirq.h> 14#include <linux/hardirq.h>
@@ -179,14 +178,8 @@ void fpstate_init(union fpregs_state *state)
179 178
180 memset(state, 0, fpu_kernel_xstate_size); 179 memset(state, 0, fpu_kernel_xstate_size);
181 180
182 /*
183 * XRSTORS requires that this bit is set in xcomp_bv, or
184 * it will #GP. Make sure it is replaced after the memset().
185 */
186 if (static_cpu_has(X86_FEATURE_XSAVES)) 181 if (static_cpu_has(X86_FEATURE_XSAVES))
187 state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT | 182 fpstate_init_xstate(&state->xsave);
188 xfeatures_mask;
189
190 if (static_cpu_has(X86_FEATURE_FXSR)) 183 if (static_cpu_has(X86_FEATURE_FXSR))
191 fpstate_init_fxstate(&state->fxsave); 184 fpstate_init_fxstate(&state->fxsave);
192 else 185 else