x86/fpu: Use 'struct fpu' in restore_fpu_checking()
authorIngo Molnar <mingo@kernel.org>
Thu, 23 Apr 2015 15:30:59 +0000 (17:30 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 19 May 2015 13:47:26 +0000 (15:47 +0200)
Migrate this function to pure 'struct fpu' usage.

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-internal.h
arch/x86/kernel/fpu/core.c

index 3f6d36c..2d7934e 100644 (file)
@@ -294,7 +294,7 @@ static inline int fpu_restore_checking(struct fpu *fpu)
                return frstor_checking(&fpu->state->fsave);
 }
 
-static inline int restore_fpu_checking(struct task_struct *tsk)
+static inline int restore_fpu_checking(struct fpu *fpu)
 {
        /*
         * AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception is
@@ -306,10 +306,10 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
                        "fnclex\n\t"
                        "emms\n\t"
                        "fildl %P[addr]"        /* set F?P to defined value */
-                       : : [addr] "m" (tsk->thread.fpu.has_fpu));
+                       : : [addr] "m" (fpu->has_fpu));
        }
 
-       return fpu_restore_checking(&tsk->thread.fpu);
+       return fpu_restore_checking(fpu);
 }
 
 /* Must be paired with an 'stts' after! */
@@ -456,8 +456,10 @@ static inline fpu_switch_t switch_fpu_prepare(struct task_struct *old, struct ta
  */
 static inline void switch_fpu_finish(struct task_struct *new, fpu_switch_t fpu)
 {
+       struct fpu *new_fpu = &new->thread.fpu;
+
        if (fpu.preload) {
-               if (unlikely(restore_fpu_checking(new)))
+               if (unlikely(restore_fpu_checking(new_fpu)))
                        fpu_reset_state(new);
        }
 }
index 230e937..1ecd250 100644 (file)
@@ -116,7 +116,7 @@ void __kernel_fpu_end(void)
        struct fpu *fpu = &me->thread.fpu;
 
        if (fpu->has_fpu) {
-               if (WARN_ON(restore_fpu_checking(me)))
+               if (WARN_ON(restore_fpu_checking(fpu)))
                        fpu_reset_state(me);
        } else if (!use_eager_fpu()) {
                stts();
@@ -370,7 +370,7 @@ void fpu__restore(void)
        /* Avoid __kernel_fpu_begin() right after __thread_fpu_begin() */
        kernel_fpu_disable();
        __thread_fpu_begin(fpu);
-       if (unlikely(restore_fpu_checking(tsk))) {
+       if (unlikely(restore_fpu_checking(fpu))) {
                fpu_reset_state(tsk);
                force_sig_info(SIGSEGV, SEND_SIG_PRIV, tsk);
        } else {