x86, fpu: Avoid FPU lazy restore after suspend
authorVincent Palatin <vpalatin@chromium.org>
Fri, 30 Nov 2012 20:15:32 +0000 (12:15 -0800)
committerH. Peter Anvin <hpa@linux.intel.com>
Fri, 30 Nov 2012 21:48:05 +0000 (13:48 -0800)
commit644c154186386bb1fa6446bc5e037b9ed098db46
treecffc45d54cd63fa1f255406e0759e7a1d8cc58ac
parent6662c34fa9c60a48aaa5879cb229cd9a84de9c22
x86, fpu: Avoid FPU lazy restore after suspend

When a cpu enters S3 state, the FPU state is lost.
After resuming for S3, if we try to lazy restore the FPU for a process running
on the same CPU, this will result in a corrupted FPU context.

Ensure that "fpu_owner_task" is properly invalided when (re-)initializing a CPU,
so nobody will try to lazy restore a state which doesn't exist in the hardware.

Tested with a 64-bit kernel on a 4-core Ivybridge CPU with eagerfpu=off,
by doing thousands of suspend/resume cycles with 4 processes doing FPU
operations running. Without the patch, a process is killed after a
few hundreds cycles by a SIGFPE.

Cc: Duncan Laurie <dlaurie@chromium.org>
Cc: Olof Johansson <olofj@chromium.org>
Cc: <stable@kernel.org> v3.4+ # for 3.4 need to replace this_cpu_write by percpu_write
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Link: http://lkml.kernel.org/r/1354306532-1014-1-git-send-email-vpalatin@chromium.org
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
arch/x86/include/asm/fpu-internal.h
arch/x86/kernel/smpboot.c