Messages in this thread Patch in this message | | | Subject | [PATCH] microblaze: restore r4 in sys_rt_sigreturn to fix corruption after signal | From | Richard Theil <> | Date | Mon, 7 Apr 2014 19:58:51 +0200 |
| |
From: Richard Theil <linux@rdtheil.de>
As already identified in http://marc.info/?l=microblaze-uclinux&m=126203029729306 , the Microblaze signal handling code will corrupt r4 on a signal return. This was never fixed upstream. ret_from_trap in entry.S expects both r3 and r4, but sys_rt_sigreturn will only provide r3 by means of a 32-bit return value. The patch explicitly loads r4 instead of returning a 64 bit compound to avoid surprises from the compiler. Applicable at least from 3.6 on to today's git master.
Signed-off-by: Richard Theil <linux@rdtheil.de> --- --- linux-3.13.5/arch/microblaze/kernel/signal.c.orig 2014-02-22 22:35:30.000000000 +0100 +++ linux-3.13.5/arch/microblaze/kernel/signal.c 2014-04-07 19:20:54.282023372 +0200 @@ -105,6 +105,10 @@ asmlinkage long sys_rt_sigreturn(struct if (restore_altstack(&frame->uc.uc_stack)) goto badframe; + /* after signal, ret_from_trap needs r3 _and_ r4 from context */ + __asm__ __volatile__("lwi r4,%0,%1":: + "r"(regs),"i"(offsetof(struct pt_regs,r4))); + return rval; badframe:
| |