linux/arch/sparc
David S. Miller 683d1a7fb3 sparc64: Fix userspace FPU register corruptions.
[ Upstream commit 44922150d8 ]

If we have a series of events from userpsace, with %fprs=FPRS_FEF,
like follows:

ETRAP
	ETRAP
		VIS_ENTRY(fprs=0x4)
		VIS_EXIT
		RTRAP (kernel FPU restore with fpu_saved=0x4)
	RTRAP

We will not restore the user registers that were clobbered by the FPU
using kernel code in the inner-most trap.

Traps allocate FPU save slots in the thread struct, and FPU using
sequences save the "dirty" FPU registers only.

This works at the initial trap level because all of the registers
get recorded into the top-level FPU save area, and we'll return
to userspace with the FPU disabled so that any FPU use by the user
will take an FPU disabled trap wherein we'll load the registers
back up properly.

But this is not how trap returns from kernel to kernel operate.

The simplest fix for this bug is to always save all FPU register state
for anything other than the top-most FPU save area.

Getting rid of the optimized inner-slot FPU saving code ends up
making VISEntryHalf degenerate into plain VISEntry.

Longer term we need to do something smarter to reinstate the partial
save optimizations.  Perhaps the fundament error is having trap entry
and exit allocate FPU save slots and restore register state.  Instead,
the VISEntry et al. calls should be doing that work.

This bug is about two decades old.

Reported-by: James Y Knight <jyknight@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-08-16 20:51:38 -07:00
..
boot sparc: Fix piggyback with newer binutils. 2012-12-03 11:24:25 -08:00
configs perf: Remove PERF_COUNTERS config option 2012-04-26 13:52:52 +02:00
crypto crypto: prefix module autoloading with "crypto-" 2015-01-29 17:40:57 -08:00
include sparc64: Fix userspace FPU register corruptions. 2015-08-16 20:51:38 -07:00
kernel sparc: Use GFP_ATOMIC in ldc_alloc_exp_dring() as it can be called in softirq context 2015-07-10 10:40:20 -07:00
lib sparc64: Fix userspace FPU register corruptions. 2015-08-16 20:51:38 -07:00
math-emu arch/sparc/math-emu/math_32.c: drop stray break operator 2014-08-14 09:24:16 +08:00
mm vm: add VM_FAULT_SIGSEGV handling support 2015-04-29 10:34:00 +02:00
net net: filter: fix sparc32 typo 2014-06-26 15:12:38 -04:00
oprofile sparc: using HZ needs an include of linux/param.h 2009-10-05 00:46:08 -07:00
power nosave: consolidate __nosave_{begin,end} in <asm/sections.h> 2015-05-06 21:56:28 +02:00
prom arch: sparc: prom: looping issue, need additional length check in the outside looping 2013-06-19 02:10:29 -07:00
Kbuild sparc64: Add SHA1 driver making use of the 'sha1' instruction. 2012-08-20 15:08:49 -07:00
Kconfig locking/mutex: Disable optimistic spinning on some architectures 2014-07-28 08:00:07 -07:00
Kconfig.debug lib: consolidate DEBUG_STACK_USAGE option 2011-05-25 08:39:54 -07:00
Makefile sparc64: Hibernation support 2013-03-20 11:06:54 -07:00