From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750783AbdAXS37 (ORCPT ); Tue, 24 Jan 2017 13:29:59 -0500 Received: from mga02.intel.com ([134.134.136.20]:3078 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750755AbdAXS36 (ORCPT ); Tue, 24 Jan 2017 13:29:58 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,279,1477983600"; d="scan'208";a="926160781" From: Yu-cheng Yu To: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, Dave Hansen , Fenghua Yu , "Ravi V. Shankar" Cc: Yu-cheng Yu Subject: [PATCH] x86/fpu/xstate: Move XSAVES state init to a function Date: Tue, 24 Jan 2017 10:25:46 -0800 Message-Id: <1485282346-15437-1-git-send-email-yu-cheng.yu@intel.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make XSTATE init similar to existing code; move it to a separate function. There is no functionality change. Signed-off-by: Yu-cheng Yu --- arch/x86/include/asm/fpu/internal.h | 11 +++++++++++ arch/x86/kernel/fpu/core.c | 8 +------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h index d4a6849..7fed690 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -87,6 +87,17 @@ static __always_inline __pure bool use_fxsr(void) #else static inline void fpstate_init_soft(struct swregs_state *soft) {} #endif + +static inline void fpstate_init_xstate(struct xregs_state *xsave) +{ + /* + * XRSTORS requires that these bits set in xcomp_bv, or it will + * trigger #GP. Make sure they are replaced after memset(). + */ + xsave->header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT | + xfeatures_mask; +} + static inline void fpstate_init_fxstate(struct fxregs_state *fx) { fx->cwd = 0x37f; diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index de72344..5763b27 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -179,14 +179,8 @@ void fpstate_init(union fpregs_state *state) memset(state, 0, fpu_kernel_xstate_size); - /* - * XRSTORS requires that this bit is set in xcomp_bv, or - * it will #GP. Make sure it is replaced after the memset(). - */ if (static_cpu_has(X86_FEATURE_XSAVES)) - state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT | - xfeatures_mask; - + fpstate_init_xstate(&state->xsave); if (static_cpu_has(X86_FEATURE_FXSR)) fpstate_init_fxstate(&state->fxsave); else -- 1.9.1