From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0DRX-0007uV-5b for qemu-devel@nongnu.org; Fri, 19 Jul 2013 12:22:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V0DRP-0005DT-72 for qemu-devel@nongnu.org; Fri, 19 Jul 2013 12:22:07 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:46687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0DRP-0005DJ-0X for qemu-devel@nongnu.org; Fri, 19 Jul 2013 12:21:59 -0400 From: Kwok Cheung Yeung Date: Fri, 19 Jul 2013 09:21:44 -0700 Message-ID: <1374250904-10658-1-git-send-email-kcy@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v3] linux-user: Handle compressed ISA encodings when processing MIPS exceptions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org, qemu-devel@nongnu.org Cc: Kwok Cheung Yeung , riku.voipio@iki.fi, aurelien@aurel32.net Decode trap instructions during the handling of an EXCP_BREAK or EXCP_TRAP according to the current ISA mode. Signed-off-by: Kwok Cheung Yeung --- linux-user/main.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) v2->v3: Handle microMIPS and MIPS16e instructions when processing EXCP_BREAK. diff --git a/linux-user/main.c b/linux-user/main.c index 7f15d3d..b137216 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -2348,7 +2348,31 @@ done_syscall: abi_ulong trap_instr; unsigned int code; - ret = get_user_ual(trap_instr, env->active_tc.PC); + if (env->hflags & MIPS_HFLAG_M16) { + if (env->insn_flags & ASE_MICROMIPS) { + /* microMIPS mode */ + abi_ulong instr[2]; + + ret = get_user_u16(instr[0], env->active_tc.PC) || + get_user_u16(instr[1], env->active_tc.PC + 2); + + trap_instr = (instr[0] << 16) | instr[1]; + } else { + /* MIPS16e mode */ + ret = get_user_u16(trap_instr, env->active_tc.PC); + if (ret != 0) { + goto error; + } + code = (trap_instr >> 6) & 0x3f; + if (do_break(env, &info, code) != 0) { + goto error; + } + break; + } + } else { + ret = get_user_ual(trap_instr, env->active_tc.PC); + } + if (ret != 0) { goto error; } @@ -2372,14 +2396,30 @@ done_syscall: abi_ulong trap_instr; unsigned int code = 0; - ret = get_user_ual(trap_instr, env->active_tc.PC); + if (env->hflags & MIPS_HFLAG_M16) { + /* microMIPS mode */ + abi_ulong instr[2]; + + ret = get_user_u16(instr[0], env->active_tc.PC) || + get_user_u16(instr[1], env->active_tc.PC + 2); + + trap_instr = (instr[0] << 16) | instr[1]; + } else { + ret = get_user_ual(trap_instr, env->active_tc.PC); + } + if (ret != 0) { goto error; } /* The immediate versions don't provide a code. */ if (!(trap_instr & 0xFC000000)) { - code = ((trap_instr >> 6) & ((1 << 10) - 1)); + if (env->hflags & MIPS_HFLAG_M16) { + /* microMIPS mode */ + code = ((trap_instr >> 12) & ((1 << 4) - 1)); + } else { + code = ((trap_instr >> 6) & ((1 << 10) - 1)); + } } if (do_break(env, &info, code) != 0) { -- 1.8.3.3