powerpc: Disable VSX or current process in giveup_fpu/altivec
authorMichael Neuling <mikey@neuling.org>
Wed, 1 Apr 2009 18:02:42 +0000 (18:02 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 18 Jan 2010 18:34:01 +0000 (10:34 -0800)
commit816972c12bfc3a1a92a64bf0fba633501004e4c6
tree16964dbe9204b19c4631fd1f961f3107aea8e658
parent6f5195525e548d474a77ce00baa927e5c7ed6976
powerpc: Disable VSX or current process in giveup_fpu/altivec

commit 7e875e9dc8af70d126fa632446e967327ac3fdda upstream.

When we call giveup_fpu, we need to need to turn off VSX for the
current process.  If we don't, on return to userspace it may execute a
VSX instruction before the next FP instruction, and not have its
register state refreshed correctly from the thread_struct.  Ditto for
altivec.

This caused a bug where an unaligned lfs or stfs results in
fix_alignment calling giveup_fpu so it can use the FPRs (in order to
do a single <-> double conversion), and then returning to userspace
with FP off but VSX on.  Then if a VSX instruction is executed, before
another FP instruction, it will proceed without another exception and
hence have the incorrect register state for VSX registers 0-31.

   lfs unaligned   <- alignment exception turns FP off but leaves VSX on

   VSX instruction <- no exception since VSX on, hence we get the
                      wrong VSX register values for VSX registers 0-31,
                      which overlap the FPRs.

Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/powerpc/kernel/fpu.S
arch/powerpc/kernel/misc_64.S