]> git.karo-electronics.de Git - linux-beck.git/commitdiff
x86/fpu: Move XCR0 manipulation to the FPU code proper
authorIngo Molnar <mingo@kernel.org>
Fri, 24 Apr 2015 08:02:32 +0000 (10:02 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 19 May 2015 13:47:33 +0000 (15:47 +0200)
The suspend code accesses FPU state internals, add a helper for
it and isolate it.

Reviewed-by: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@amacapital.net>
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: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/include/asm/fpu/api.h
arch/x86/kernel/fpu/xsave.c
arch/x86/power/cpu.c

index f1eddcccba16e1d52ffbba64e7212be1a93dc0cc..5bdde8ca87bcab4e3ae5b96231053bb8ccd1d656 100644 (file)
@@ -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);
 
index 1d0e27128f18efce38e11bc618482c0acea2eaf6..a485180ebc3288c3d0659a82c2b8de3c0219327d 100644 (file)
@@ -734,6 +734,18 @@ void __init_refok eager_fpu_init(void)
                setup_init_fpu_buf();
 }
 
+/*
+ * 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.
index 62054acbd0d845307cd572640d153a7e56f791d3..ad0ce6b70fac2bdebaad7e0da5a69a98bb8c999e 100644 (file)
 #include <asm/mtrr.h>
 #include <asm/page.h>
 #include <asm/mce.h>
-#include <asm/xcr.h>
 #include <asm/suspend.h>
 #include <asm/debugreg.h>
-#include <asm/fpu/internal.h> /* xfeatures_mask */
 #include <asm/cpu.h>
 
 #ifdef CONFIG_X86_32
@@ -155,6 +153,8 @@ static void fix_processor_context(void)
 #endif
        load_TR_desc();                         /* This does ltr */
        load_LDT(&current->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();