i387: ptrace breaks the lazy-fpu-restore logic
authorOleg Nesterov <[email protected]>
Mon, 16 Apr 2012 20:48:15 +0000 (22:48 +0200)
committerH. Peter Anvin <[email protected]>
Mon, 16 Apr 2012 23:23:59 +0000 (16:23 -0700)
Starting from 7e16838d "i387: support lazy restore of FPU state"
we assume that fpu_owner_task doesn't need restore_fpu_checking()
on the context switch, its FPU state should match what we already
have in the FPU on this CPU.

However, debugger can change the tracee's FPU state, in this case
we should reset fpu.last_cpu to ensure fpu_lazy_restore() can't
return true.

Change init_fpu() to do this, it is called by user_regset->set()
methods.

Reported-by: Jan Kratochvil <[email protected]>
Suggested-by: Linus Torvalds <[email protected]>
Signed-off-by: Oleg Nesterov <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Cc: <[email protected]> v3.3
Signed-off-by: H. Peter Anvin <[email protected]>
arch/x86/kernel/i387.c

index 7734bcbb5a3a3b21e11374f82747972d678e8999..2d6e6498c176cda24349b01d5d89cd57b2cfb5ac 100644 (file)
@@ -235,6 +235,7 @@ int init_fpu(struct task_struct *tsk)
        if (tsk_used_math(tsk)) {
                if (HAVE_HWFP && tsk == current)
                        unlazy_fpu(tsk);
+               tsk->thread.fpu.last_cpu = ~0;
                return 0;
        }