powerpc/math-emu: Move the flush FPU state function into do_mathemu
authorKevin Hao <haokexin@gmail.com>
Sun, 14 Jul 2013 08:40:06 +0000 (16:40 +0800)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 14 Aug 2013 04:59:06 +0000 (14:59 +1000)
By doing this we can make sure that the FPU state is only flushed to
the thread struct when it is really needed.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/kernel/traps.c
arch/powerpc/math-emu/math.c

index f58eaf23e8f1462e6a5cbbf9bb050511ac30d5de..82df498069bc47495f5d46651437aea405b2833d 100644 (file)
@@ -1134,15 +1134,6 @@ void __kprobes program_check_exception(struct pt_regs *regs)
         * instruction or only on FP instructions, whether there is a
         * pattern to occurrences etc. -dgibson 31/Mar/2003
         */
-
-       /*
-        * If we support a HW FPU, we need to ensure the FP state
-        * if flushed into the thread_struct before attempting
-        * emulation
-        */
-#ifdef CONFIG_PPC_FPU
-       flush_fp_to_thread(current);
-#endif
        switch (do_mathemu(regs)) {
        case 0:
                emulate_single_step(regs);
index 3fe8e35287a18ba3eb2ca6f6a09f766d7cf715b2..f9ef34746f16a1a8598c7b2ca75d3b40d804d308 100644 (file)
@@ -420,6 +420,15 @@ do_mathemu(struct pt_regs *regs)
                goto illegal;
        }
 
+       /*
+        * If we support a HW FPU, we need to ensure the FP state
+        * is flushed into the thread_struct before attempting
+        * emulation
+        */
+#ifdef CONFIG_PPC_FPU
+       flush_fp_to_thread(current);
+#endif
+
        eflag = func(op0, op1, op2, op3);
 
        if (insn & 1) {