From: Kwok Cheung Yeung <kcy@codesourcery.com>
To: qemu-devel@nongnu.org
Cc: riku.voipio@iki.fi, Kwok Cheung Yeung <kcy@codesourcery.com>
Subject: [Qemu-devel] [PATCH] linux-user: Fix MIPS16/microMIPS signal handling
Date: Tue, 30 Apr 2013 11:09:32 -0700 [thread overview]
Message-ID: <1367345372-5043-1-git-send-email-kcy@codesourcery.com> (raw)
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 <kcy@codesourcery.com>
---
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
next reply other threads:[~2013-04-30 18:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-30 18:09 Kwok Cheung Yeung [this message]
2013-05-01 10:56 ` [Qemu-devel] [PATCH] linux-user: Fix MIPS16/microMIPS signal handling Peter Maydell
-- strict thread matches above, loose matches on Subject: below --
2013-04-30 14:57 Kwok Cheung Yeung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1367345372-5043-1-git-send-email-kcy@codesourcery.com \
--to=kcy@codesourcery.com \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).