Received: from eggs.gnu.org ([2001:4830:134:3::10]:55331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCApL-00007b-Tc for qemu-devel@nongnu.org; Mon, 06 Jul 2015 14:09:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCApH-0005vg-OT for qemu-devel@nongnu.org; Mon, 06 Jul 2015 14:09:11 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:58528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCApH-0005uY-J9 for qemu-devel@nongnu.org; Mon, 06 Jul 2015 14:09:07 -0400 From: Date: Mon, 6 Jul 2015 11:09:01 -0700 Message-ID: <1436206141-13361-1-git-send-email-meadori@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH] arm: Ensure LSB of BLX is set List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Meador Inge From: Meador Inge This small patch adds a sanity check when disassembling the BLX instruction. The use case came to light when doing toolchain development and a similar check was upstreamed for Binutils: * https://sourceware.org/ml/binutils/2011-01/msg00077.html Patch by Nathan Sidwell. Signed-off-by: Meador Inge --- target-arm/translate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target-arm/translate.c b/target-arm/translate.c index 69ac18c..fedc8f3 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -9912,6 +9912,12 @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw gen_jmp(s, offset); } else { /* blx */ + /* The instruction must have bit zero unset, even + though it is part of the offset. Real hardware + will abort, so we do too. */ + if (insn & 1) { + goto illegal_op; + } offset &= ~(uint32_t)2; /* thumb2 bx, no need to check */ gen_bx_im(s, offset); -- 1.8.1.1