1
0
Fork 0
alistair23-linux/arch/x86
Suresh Siddha 870568b390 x86, fpu: fix CONFIG_PREEMPT=y corruption of application's FPU stack
Jürgen Mell reported an FPU state corruption bug under CONFIG_PREEMPT,
and bisected it to commit v2.6.19-1363-gacc2076, "i386: add sleazy FPU
optimization".

Add tsk_used_math() checks to prevent calling math_state_restore()
which can sleep in the case of !tsk_used_math(). This prevents
making a blocking call in __switch_to().

Apparently "fpu_counter > 5" check is not enough, as in some signal handling
and fork/exec scenarios, fpu_counter > 5 and !tsk_used_math() is possible.

It's a side effect though. This is the failing scenario:

process 'A' in save_i387_ia32() just after clear_used_math()

Got an interrupt and pre-empted out.

At the next context switch to process 'A' again, kernel tries to restore
the math state proactively and sees a fpu_counter > 0 and !tsk_used_math()

This results in init_fpu() during the __switch_to()'s math_state_restore()

And resulting in fpu corruption which will be saved/restored
(save_i387_fxsave and restore_i387_fxsave) during the remaining
part of the signal handling after the context switch.

Bisected-by: Jürgen Mell <j.mell@t-online.de>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Tested-by: Jürgen Mell <j.mell@t-online.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@kernel.org
2008-06-04 16:21:24 +02:00
..
boot x86: fix integer as NULL pointer warning 2008-05-23 08:11:06 -07:00
configs x86: add optimized inlining 2008-04-26 17:44:55 +02:00
crypto [CRYPTO] aes-x86-32: Remove unused return code 2008-04-21 10:19:21 +08:00
ia32 signals: x86 TS_RESTORE_SIGMASK 2008-04-30 08:29:37 -07:00
kernel x86, fpu: fix CONFIG_PREEMPT=y corruption of application's FPU stack 2008-06-04 16:21:24 +02:00
kvm namespacecheck: automated fixes 2008-05-23 14:08:06 +02:00
lguest lguest: fix ugly <NULL> in /proc/interrupts 2008-05-30 15:09:43 +10:00
lib x86: enable preemption in delay 2008-06-04 13:11:46 +02:00
mach-default spelling fixes: arch/i386/ 2007-10-20 01:13:56 +02:00
mach-es7000 i386: es7000 minor cleanups 2007-10-17 20:16:15 +02:00
mach-generic x86: coding style fixes to arch/x86/mach-generic/bigsmp.c 2008-04-17 17:40:48 +02:00
mach-rdc321x x86, rdc321x: remove watchdog file 2008-04-17 17:40:50 +02:00
mach-visws x86: fix compilation error in VisWS 2008-04-24 23:15:44 +02:00
mach-voyager x86, voyager: fix ioremap_nocache() 2008-04-30 23:15:34 +02:00
math-emu x86: fix broken math-emu with lazy allocation of fpu area 2008-06-04 13:11:46 +02:00
mm x86: section mismatch fix 2008-06-04 13:11:47 +02:00
oprofile x86: oprofile: remove NR_CPUS arrays in arch/x86/oprofile/nmi_int.c 2008-04-19 19:44:58 +02:00
pci PCI: Correct last two HP entries in the bfsort whitelist 2008-05-19 12:21:36 -07:00
power x86: coding style fixes to arch/x86/power/cpu_32.c 2008-04-17 17:40:50 +02:00
vdso x86: use explicit copy in vdso_gettimeofday() 2008-05-23 14:08:06 +02:00
video x86: video/fbdev.c: add MODULE_LICENSE 2008-05-04 20:04:46 +02:00
xen x86/xen: fix arbitrary_virt_to_machine() 2008-05-23 14:08:06 +02:00
Kconfig Kconfig: introduce ARCH_DEFCONFIG to DEFCONFIG_LIST 2008-05-25 23:03:18 +02:00
Kconfig.cpu x86: CONFIG_X86_ELAN fix 2008-04-30 23:15:35 +02:00
Kconfig.debug x86: Mark OPTIMIZE_INLINING broken 2008-04-30 20:07:22 -07:00
Makefile x86: add subarch support (for headers) to x86_64 2008-04-17 17:41:01 +02:00
Makefile_32.cpu x86: move i386 and x86_64 Makefiles to arch/x86 2007-10-25 22:27:34 +02:00