From patchwork Tue Jul 23 15:49:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 261123 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B685E2C00CA for ; Wed, 24 Jul 2013 01:59:39 +1000 (EST) Received: from localhost ([::1]:48230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1ezx-0004MZ-0J for incoming@patchwork.ozlabs.org; Tue, 23 Jul 2013 11:59:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1eqL-0005Ol-2s for qemu-devel@nongnu.org; Tue, 23 Jul 2013 11:50:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1eq0-0001ba-1t for qemu-devel@nongnu.org; Tue, 23 Jul 2013 11:49:40 -0400 Received: from afflict.kos.to ([92.243.29.197]:45204) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1epz-0001b8-OI for qemu-devel@nongnu.org; Tue, 23 Jul 2013 11:49:19 -0400 Received: from kos.to (a91-156-63-85.elisa-laajakaista.fi [91.156.63.85]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id E5FE326561 for ; Tue, 23 Jul 2013 17:49:17 +0200 (CEST) Received: from voipio (uid 1000) (envelope-from voipio@kos.to) id 5e07ee by kos.to (DragonFly Mail Agent); Tue, 23 Jul 2013 18:49:14 +0300 From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 23 Jul 2013 18:49:11 +0300 Message-Id: X-Mailer: git-send-email 1.8.1.2 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Kwok Cheung Yeung Subject: [Qemu-devel] [PULL 21/21] linux-user: Handle compressed ISA encodings when processing MIPS exceptions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Kwok Cheung Yeung 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 Signed-off-by: Riku Voipio --- linux-user/main.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 547884c..441e31d 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -2310,7 +2310,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; } @@ -2334,14 +2358,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) {