Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030585AbbEERwk (ORCPT ); Tue, 5 May 2015 13:52:40 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:36293 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030528AbbEERwd (ORCPT ); Tue, 5 May 2015 13:52:33 -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 094/208] x86/fpu: Remove fpstate_xstate_init_size() boot quirk Date: Tue, 5 May 2015 19:49:46 +0200 Message-Id: <1430848300-27877-16-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: 2380 Lines: 75 fpstate_xstate_init_size() is called in fpu__cpu_init(), which is run on every CPU, every time they are brought online. But we want to call fpstate_xstate_init_size() only once. Move it to fpu__detect(), which only runs once, on the boot CPU. Also clean up the flow of fpstate_xstate_init_size() a bit, by removing a 'return' from the middle of the function. 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 | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c index 0b16f61cb2a4..3e0fee5bc2e7 100644 --- a/arch/x86/kernel/fpu/init.c +++ b/arch/x86/kernel/fpu/init.c @@ -109,13 +109,12 @@ static void fpstate_xstate_init_size(void) setup_clear_cpu_cap(X86_FEATURE_XSAVE); setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT); xstate_size = sizeof(struct i387_soft_struct); - return; + } else { + if (cpu_has_fxsr) + xstate_size = sizeof(struct i387_fxsave_struct); + else + xstate_size = sizeof(struct i387_fsave_struct); } - - if (cpu_has_fxsr) - xstate_size = sizeof(struct i387_fxsave_struct); - else - xstate_size = sizeof(struct i387_fsave_struct); } /* @@ -151,12 +150,6 @@ void fpu__cpu_init(void) cr0 |= X86_CR0_EM; write_cr0(cr0); - /* - * fpstate_xstate_init_size() is only called once, to avoid overriding - * 'xstate_size' during (secondary CPU) bootup or during CPU hotplug. - */ - if (xstate_size == 0) - fpstate_xstate_init_size(); mxcsr_feature_mask_init(); xsave_init(); @@ -194,5 +187,7 @@ void fpu__detect(struct cpuinfo_x86 *c) else clear_cpu_cap(c, X86_FEATURE_FPU); - /* The final cr0 value is set in fpu_init() */ + /* The final cr0 value is set later, in fpu_init() */ + + fpstate_xstate_init_size(); } -- 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/