diff mbox

[v2,1/2] powerpc/math-emu: move the flush FPU state function into do_mathemu

Message ID 1373607402-21738-2-git-send-email-haokexin@gmail.com (mailing list archive)
State Superseded
Headers show

Commit Message

Kevin Hao July 12, 2013, 5:36 a.m. UTC
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>
---
v2: No change.

 arch/powerpc/kernel/traps.c  | 9 ---------
 arch/powerpc/math-emu/math.c | 9 +++++++++
 2 files changed, 9 insertions(+), 9 deletions(-)

Comments

Benjamin Herrenschmidt July 12, 2013, 8:37 a.m. UTC | #1
On Fri, 2013-07-12 at 13:36 +0800, Kevin Hao wrote:
> +       /*
> +        * 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
> +

While at it, care to send a patch that defined an empty
flush_fp_to_thread() in the header instead ?

ie, switch_to.h

#ifdef CONFIG_PPC_FPU
extern void flush_fp_to_thread(struct task-struct *);
#else
static inline void flush_fp_to_thread(struct task-struct *) { };
#endif

And get rid of the ifdef's here (and elsewhere if any) ?

Thanks !

Cheers,
Ben.
Kevin Hao July 14, 2013, 8:29 a.m. UTC | #2
On Fri, Jul 12, 2013 at 06:37:13PM +1000, Benjamin Herrenschmidt wrote:
> On Fri, 2013-07-12 at 13:36 +0800, Kevin Hao wrote:
> > +       /*
> > +        * 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
> > +
> 
> While at it, care to send a patch that defined an empty
> flush_fp_to_thread() in the header instead ?
> 
> ie, switch_to.h
> 
> #ifdef CONFIG_PPC_FPU
> extern void flush_fp_to_thread(struct task-struct *);
> #else
> static inline void flush_fp_to_thread(struct task-struct *) { };
> #endif
> 
> And get rid of the ifdef's here (and elsewhere if any) ?

Sure. Matt also pointed out a typo in the comments of this patch.
So I will respin a v3 for this. But since I also have some similar
clean up patches as the change you just suggested, I will send them
as a separate patch series instead of messing the v3.

Thanks,
Kevin

> 
> Thanks !
> 
> Cheers,
> Ben.
> 
>
diff mbox

Patch

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index bf33c22..58a8065 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1131,15 +1131,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);
diff --git a/arch/powerpc/math-emu/math.c b/arch/powerpc/math-emu/math.c
index 3fe8e35..18ce6a7 100644
--- a/arch/powerpc/math-emu/math.c
+++ b/arch/powerpc/math-emu/math.c
@@ -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
+	 * if 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) {