Received: from eggs.gnu.org ([208.118.235.92]:46148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8bmr-0003dw-D0 for qemu-devel@nongnu.org; Fri, 16 Mar 2012 14:22:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8bmp-00077w-08 for qemu-devel@nongnu.org; Fri, 16 Mar 2012 14:22:00 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:42601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8bmo-00077S-MU for qemu-devel@nongnu.org; Fri, 16 Mar 2012 14:21:58 -0400 From: Peter Maydell Date: Fri, 16 Mar 2012 18:21:46 +0000 Message-Id: <1331922106-11774-4-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1331922106-11774-1-git-send-email-peter.maydell@linaro.org> References: <1331922106-11774-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 3/3] target-arm: Decode SETEND correctly in Thumb List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl , Aurelien Jarno , Paul Brook Cc: qemu-devel@nongnu.org Decode the SETEND instruction correctly in Thumb mode, rather than accidentally treating it like CPS. We don't support BE8 mode, but this change brings the Thumb mode in to line with behaviour in ARM mode: 'SETEND BE' is not supported and will provoke an UNDEF exception, but 'SETEND LE' is correctly handled as a no-op. Signed-off-by: Peter Maydell Reported-by: Daniel Forsgren Reviewed-by: Laurent Desnogues --- target-arm/translate.c | 63 ++++++++++++++++++++++++++++++----------------- 1 files changed, 40 insertions(+), 23 deletions(-) diff --git a/target-arm/translate.c b/target-arm/translate.c index 2709010..81725d1 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -9704,32 +9704,49 @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) store_reg(s, rd, tmp); break; - case 6: /* cps */ - ARCH(6); - if (IS_USER(s)) + case 6: + switch ((insn >> 5) & 7) { + case 2: + /* setend */ + ARCH(6); + if (insn & (1 << 3)) { + /* BE8 mode not implemented. */ + goto illegal_op; + } break; - if (IS_M(env)) { - tmp = tcg_const_i32((insn & (1 << 4)) != 0); - /* FAULTMASK */ - if (insn & 1) { - addr = tcg_const_i32(19); - gen_helper_v7m_msr(cpu_env, addr, tmp); - tcg_temp_free_i32(addr); + case 3: + /* cps */ + ARCH(6); + if (IS_USER(s)) { + break; } - /* PRIMASK */ - if (insn & 2) { - addr = tcg_const_i32(16); - gen_helper_v7m_msr(cpu_env, addr, tmp); - tcg_temp_free_i32(addr); + if (IS_M(env)) { + tmp = tcg_const_i32((insn & (1 << 4)) != 0); + /* FAULTMASK */ + if (insn & 1) { + addr = tcg_const_i32(19); + gen_helper_v7m_msr(cpu_env, addr, tmp); + tcg_temp_free_i32(addr); + } + /* PRIMASK */ + if (insn & 2) { + addr = tcg_const_i32(16); + gen_helper_v7m_msr(cpu_env, addr, tmp); + tcg_temp_free_i32(addr); + } + tcg_temp_free_i32(tmp); + gen_lookup_tb(s); + } else { + if (insn & (1 << 4)) { + shift = CPSR_A | CPSR_I | CPSR_F; + } else { + shift = 0; + } + gen_set_psr_im(s, ((insn & 7) << 6), 0, shift); } - tcg_temp_free_i32(tmp); - gen_lookup_tb(s); - } else { - if (insn & (1 << 4)) - shift = CPSR_A | CPSR_I | CPSR_F; - else - shift = 0; - gen_set_psr_im(s, ((insn & 7) << 6), 0, shift); + break; + default: + goto undef; } break; -- 1.7.1