diff options
author | Kwok Cheung Yeung <kcy@codesourcery.com> | 2013-05-17 14:51:20 -0700 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2013-05-20 18:16:17 +0200 |
commit | ea3164aafccdfdd8a9543787cdfa25fac30a5def (patch) | |
tree | 9f6c648b8eb0e608f4c3b20e69384fad9c73fa34 /linux-user | |
parent | d8992825aedbb83b7a0e98284e0527bc82a6f7df (diff) | |
download | qemu-ea3164aafccdfdd8a9543787cdfa25fac30a5def.zip qemu-ea3164aafccdfdd8a9543787cdfa25fac30a5def.tar.gz qemu-ea3164aafccdfdd8a9543787cdfa25fac30a5def.tar.bz2 |
linux-user: Fix MIPS ISA transitions during signal handling
Processors supporting the MIPS16 or microMIPS ISAs set bit 0 in target
addresses to indicate that the target is written using a compressed ISA.
During signal handling, when jumping to or returning from a signal
handler, bit 0 of the destination PC is inspected and MIPS_HFLAG_M16 in
hflags cleared or set accordingly. Bit 0 of the PC is then cleared.
Signed-off-by: Kwok Cheung Yeung <kcy@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/signal.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/linux-user/signal.c b/linux-user/signal.c index 1055507..dc34ae7 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -2620,6 +2620,15 @@ get_sigframe(struct target_sigaction *ka, CPUMIPSState *regs, size_t frame_size) return (sp - frame_size) & ~7; } +static void mips_set_hflags_isa_mode_from_pc(CPUMIPSState *env) +{ + if (env->insn_flags & (ASE_MIPS16 | ASE_MICROMIPS)) { + env->hflags &= ~MIPS_HFLAG_M16; + env->hflags |= (env->active_tc.PC & 1) << MIPS_HFLAG_M16_SHIFT; + env->active_tc.PC &= ~(target_ulong) 1; + } +} + # if defined(TARGET_ABI_MIPSO32) /* compare linux/arch/mips/kernel/signal.c:setup_frame() */ static void setup_frame(int sig, struct target_sigaction * ka, @@ -2662,6 +2671,7 @@ 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; + mips_set_hflags_isa_mode_from_pc(regs); unlock_user_struct(frame, frame_addr, 1); return; @@ -2709,6 +2719,7 @@ long do_sigreturn(CPUMIPSState *regs) #endif regs->active_tc.PC = regs->CP0_EPC; + mips_set_hflags_isa_mode_from_pc(regs); /* I am not sure this is right, but it seems to work * maybe a problem with nested signals ? */ regs->CP0_EPC = 0; @@ -2771,6 +2782,7 @@ 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; + mips_set_hflags_isa_mode_from_pc(env); unlock_user_struct(frame, frame_addr, 1); return; @@ -2804,6 +2816,7 @@ long do_rt_sigreturn(CPUMIPSState *env) goto badframe; env->active_tc.PC = env->CP0_EPC; + mips_set_hflags_isa_mode_from_pc(env); /* I am not sure this is right, but it seems to work * maybe a problem with nested signals ? */ env->CP0_EPC = 0; |