[7194] MIPS signal handling fixes.
Revision: 7194
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7194 Author: pbrook Date: 2009-04-21 01:41:10 +0000 (Tue, 21 Apr 2009)
Log Message:
-----------
MIPS signal handling fixes.
Also fixes a register corruption bug in do_sigreturn. When "returning" from sigreturn we are actually restoring the virtual cpu state from the signal frame. This is actually surprisingly hard to observe in practice.
Typically an thread be blocked in a FUTEX_WAIT call when the signal arrives, so the effect is a spurious syscall success and the introduction of a subtle race condition.
On x86/arm a syscall modifies a single word sized register, so do_sigreturn can just return that value. On MIPS a syscall clobbers multiple registers, so we need additional smarts. My solution is to invent a magic errno value that means "don't touch CPU state".
Modified Paths:
--------------
trunk/linux-user/main.c
trunk/linux-user/mips/syscall.h
trunk/linux-user/signal.c
Modified: trunk/linux-user/main.c
===================================================================
linux-user/main.c +5 -0
@@ -1858,6 +1858,11 @@ env->active_tc.gpr[7 ], arg5, arg6/*, arg7, arg8*/); } +if (ret == -TARGET_QEMU_ESIGRETURN ) { +/* Returning from a successful sigreturn syscall. +Avoid clobbering register state. */ +break ; + }if ((unsigned int )ret >= (unsigned int )(-1133 )) { env->active_tc.gpr[7 ] =1 ;/* error flag */ ret = -ret;
Modified: trunk/linux-user/mips/syscall.h
===================================================================
linux-user/mips/syscall.h +3 -0
@@ -221,4 +221,7 @@ +/* Nasty hack: define a fake errno value for use by sigreturn. */ +#define TARGET_QEMU_ESIGRETURN 255 +#define UNAME_MACHINE "mips"
Modified: trunk/linux-user/signal.c
===================================================================
linux-user/signal.c +101 -4
127 lines not on this page · raw message