arch/tile: fix up some issues in calling do_work_pending()
authorChris Metcalf <cmetcalf@tilera.com>
Sat, 28 Apr 2012 22:51:43 +0000 (18:51 -0400)
committerChris Metcalf <cmetcalf@tilera.com>
Wed, 16 May 2012 20:01:16 +0000 (16:01 -0400)
commitfc327e268fbef08e129ad51aa3a7113ee9bc6ba5
treeba75f2ac9509090c6896a4fbc6be7c3aaba1aaf6
parent36be50515fe2aef61533b516fa2576a2c7fe7664
arch/tile: fix up some issues in calling do_work_pending()

First, we were at risk of handling thread-info flags, in particular
do_signal(), when returning from kernel space.  This could happen
after a failed kernel_execve(), or when forking a kernel thread.
The fix is to test in do_work_pending() for user_mode() and return
immediately if so; we already had this test for one of the flags,
so I just hoisted it to the top of the function.

Second, if a ptraced process updated the callee-saved registers
in the ptregs struct and then processed another thread-info flag, we
would overwrite the modifications with the original callee-saved
registers.  To fix this, we add a register to note if we've already
saved the registers once, and skip doing it on additional passes
through the loop.  To avoid a performance hit from the couple of
extra instructions involved, I modified the GET_THREAD_INFO() macro
to be guaranteed to be one instruction, then bundled it with adjacent
instructions, yielding an overall net savings.

Reported-By: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
arch/tile/include/asm/thread_info.h
arch/tile/kernel/intvec_32.S
arch/tile/kernel/intvec_64.S
arch/tile/kernel/process.c