Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030596AbbEESfl (ORCPT ); Tue, 5 May 2015 14:35:41 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:36723 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030396AbbEERwD (ORCPT ); Tue, 5 May 2015 13:52:03 -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 081/208] x86/fpu: Move XCR0 manipulation to the FPU code proper Date: Tue, 5 May 2015 19:49:33 +0200 Message-Id: <1430848300-27877-3-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: 2901 Lines: 98 The suspend code accesses FPU state internals, add a helper for it and isolate it. 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/include/asm/fpu/api.h | 1 + arch/x86/kernel/fpu/xsave.c | 12 ++++++++++++ arch/x86/power/cpu.c | 10 ++-------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h index f1eddcccba16..5bdde8ca87bc 100644 --- a/arch/x86/include/asm/fpu/api.h +++ b/arch/x86/include/asm/fpu/api.h @@ -23,6 +23,7 @@ extern void fpu__clear(struct task_struct *tsk); extern int dump_fpu(struct pt_regs *, struct user_i387_struct *); extern void fpu__restore(void); extern void fpu__init_check_bugs(void); +extern void fpu__resume_cpu(void); extern bool irq_fpu_usable(void); diff --git a/arch/x86/kernel/fpu/xsave.c b/arch/x86/kernel/fpu/xsave.c index 1d0e27128f18..a485180ebc32 100644 --- a/arch/x86/kernel/fpu/xsave.c +++ b/arch/x86/kernel/fpu/xsave.c @@ -735,6 +735,18 @@ void __init_refok eager_fpu_init(void) } /* + * Restore minimal FPU state after suspend: + */ +void fpu__resume_cpu(void) +{ + /* + * Restore XCR0 on xsave capable CPUs: + */ + if (cpu_has_xsave) + xsetbv(XCR_XFEATURE_ENABLED_MASK, xfeatures_mask); +} + +/* * Given the xsave area and a state inside, this function returns the * address of the state. * diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c index 62054acbd0d8..ad0ce6b70fac 100644 --- a/arch/x86/power/cpu.c +++ b/arch/x86/power/cpu.c @@ -18,10 +18,8 @@ #include #include #include -#include #include #include -#include /* xfeatures_mask */ #include #ifdef CONFIG_X86_32 @@ -155,6 +153,8 @@ static void fix_processor_context(void) #endif load_TR_desc(); /* This does ltr */ load_LDT(¤t->active_mm->context); /* This does lldt */ + + fpu__resume_cpu(); } /** @@ -221,12 +221,6 @@ static void notrace __restore_processor_state(struct saved_context *ctxt) wrmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base); #endif - /* - * restore XCR0 for xsave capable cpu's. - */ - if (cpu_has_xsave) - xsetbv(XCR_XFEATURE_ENABLED_MASK, xfeatures_mask); - fix_processor_context(); do_fpu_end(); -- 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/