From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXCWo-0004hF-1O for qemu-devel@nongnu.org; Tue, 30 Apr 2013 11:31:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXCWl-0007M4-9r for qemu-devel@nongnu.org; Tue, 30 Apr 2013 11:31:37 -0400 Received: from 78-105-108-218.zone3.bethere.co.uk ([78.105.108.218]:13655 helo=athena.yeung.lan) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXCWl-0007Li-3W for qemu-devel@nongnu.org; Tue, 30 Apr 2013 11:31:35 -0400 From: Kwok Cheung Yeung Date: Tue, 30 Apr 2013 15:57:49 +0100 Message-Id: <1367333869-1718-1-git-send-email-kcy@codesourcery.com> Subject: [Qemu-devel] [PATCH] linux-user: Fix MIPS16/microMIPS signal handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: riku.voipio@iki.fi, Kwok Cheung Yeung Signal handlers written using a compressed MIPS instruction set will segfault when invoked. This patch fixes this. Switch the ISA mode on cores supporting the MIPS16/microMIPS ISAs according to bit 0 of the signal handler address. Clear bit 0 of the address assigned to the PC. Signed-off-by: Kwok Cheung Yeung --- linux-user/signal.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linux-user/signal.c b/linux-user/signal.c index 1055507..abfb382 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -2662,6 +2662,11 @@ static void setup_frame(int sig, struct target_sigaction * ka, * since it returns to userland using eret * we cannot do this here, and we must set PC directly */ regs->active_tc.PC = regs->active_tc.gpr[25] = ka->_sa_handler; + if (regs->insn_flags & (ASE_MIPS16 | ASE_MICROMIPS)) { + regs->hflags &= ~MIPS_HFLAG_M16; + regs->hflags |= (ka->_sa_handler & 1) << MIPS_HFLAG_M16_SHIFT; + regs->active_tc.PC &= ~(target_ulong) 1; + } unlock_user_struct(frame, frame_addr, 1); return; @@ -2771,6 +2776,11 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, * since it returns to userland using eret * we cannot do this here, and we must set PC directly */ env->active_tc.PC = env->active_tc.gpr[25] = ka->_sa_handler; + if (env->insn_flags & (ASE_MIPS16 | ASE_MICROMIPS)) { + env->hflags &= ~MIPS_HFLAG_M16; + env->hflags |= (ka->_sa_handler & 1) << MIPS_HFLAG_M16_SHIFT; + env->active_tc.PC &= ~(target_ulong) 1; + } unlock_user_struct(frame, frame_addr, 1); return; -- 1.8.2.2