Browse files

i387: ptrace breaks the lazy-fpu-restore logic

Starting from 7e16838 "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()

Reported-by: Jan Kratochvil <>
Suggested-by: Linus Torvalds <>
Signed-off-by: Oleg Nesterov <>
Cc: <> v3.3
Signed-off-by: H. Peter Anvin <>
  • Loading branch information...
1 parent 6889463 commit 089f9fba56faf33cc6dd2a6442b7ac92c58b8209 @utrace utrace committed with H. Peter Anvin Apr 16, 2012
Showing with 1 addition and 0 deletions.
  1. +1 −0 arch/x86/kernel/i387.c
1 arch/x86/kernel/i387.c
@@ -235,6 +235,7 @@ int init_fpu(struct task_struct *tsk)
if (tsk_used_math(tsk)) {
if (HAVE_HWFP && tsk == current)
+ tsk->thread.fpu.last_cpu = ~0;
return 0;

0 comments on commit 089f9fb

Please sign in to comment.