Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762159AbbEES1b (ORCPT ); Tue, 5 May 2015 14:27:31 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:35444 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030680AbbEERw7 (ORCPT ); Tue, 5 May 2015 13:52:59 -0400 From: Ingo Molnar To: linux-kernel@vger.kernel.org Cc: Andy Lutomirski , Borislav Petkov , Dave Hansen , Fenghua Yu , "H. Peter Anvin" , Linus Torvalds , Oleg Nesterov , Thomas Gleixner Subject: [PATCH 110/208] x86/fpu: Split fpu__ctx_switch_init() into _cpu() and _system() portions Date: Tue, 5 May 2015 19:50:02 +0200 Message-Id: <1430848300-27877-32-git-send-email-mingo@kernel.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430848300-27877-1-git-send-email-mingo@kernel.org> References: <1430848300-27877-1-git-send-email-mingo@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2805 Lines: 87 So fpu__ctx_switch_init() has two aspects: a once per bootup functionality that sets up a capability flag, and a per CPU functionality that sets CR0::TS. Split the function. Note that at this stage we still have duplicate calls into these methods, as both the _system() and the _cpu() methods are run on all CPUs, with lower level on_boot_cpu flags filtering out the duplicates where needed. So add TS flag clearing as well, to handle the aftermath of early CPU init sequences that might call in without having eager-fpu set - don't assume the TS flag is cleared. Calling each from its respective init level will happen later on. Reviewed-by: Borislav Petkov Cc: Andy Lutomirski Cc: Dave Hansen Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Thomas Gleixner Signed-off-by: Ingo Molnar --- arch/x86/kernel/fpu/init.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c index d6d582080c3b..2752b4bae854 100644 --- a/arch/x86/kernel/fpu/init.c +++ b/arch/x86/kernel/fpu/init.c @@ -118,6 +118,18 @@ static void fpstate_xstate_init_size(void) } /* + * Initialize the TS bit in CR0 according to the style of context-switches + * we are using: + */ +static void fpu__init_cpu_ctx_switch(void) +{ + if (!cpu_has_eager_fpu) + stts(); + else + clts(); +} + +/* * Enable all supported FPU features. Called when a CPU is brought online. */ void fpu__init_cpu(void) @@ -167,7 +179,7 @@ __setup("eagerfpu=", eager_fpu_setup); * setup_init_fpu_buf() is __init and it is OK to call it here because * init_xstate_ctx will be unset only once during boot. */ -static void fpu__ctx_switch_init(void) +static void fpu__init_system_ctx_switch(void) { WARN_ON(current->thread.fpu.fpstate_active); current_thread_info()->status = 0; @@ -190,9 +202,6 @@ static void fpu__ctx_switch_init(void) setup_force_cpu_cap(X86_FEATURE_EAGER_FPU); printk_once(KERN_INFO "x86/fpu: Using '%s' FPU context switches.\n", eagerfpu == ENABLE ? "eager" : "lazy"); - - if (!cpu_has_eager_fpu) - stts(); } /* @@ -212,7 +221,8 @@ void fpu__init_system(void) mxcsr_feature_mask_init(); fpu__init_system_xstate(); - fpu__ctx_switch_init(); + fpu__init_system_ctx_switch(); + fpu__init_cpu_ctx_switch(); } void fpu__cpu_init(void) -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/