From patchwork Fri Jul 1 13:59:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 2401 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 710B923F52 for ; Fri, 1 Jul 2011 13:59:15 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 1FFE0A180EE for ; Fri, 1 Jul 2011 13:59:15 +0000 (UTC) Received: by qwb8 with SMTP id 8so2294904qwb.11 for ; Fri, 01 Jul 2011 06:59:14 -0700 (PDT) Received: by 10.229.62.194 with SMTP id y2mr2636473qch.4.1309528754601; Fri, 01 Jul 2011 06:59:14 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.48.135 with SMTP id r7cs105236qcf; Fri, 1 Jul 2011 06:59:13 -0700 (PDT) Received: by 10.143.66.19 with SMTP id t19mr1466135wfk.262.1309528752793; Fri, 01 Jul 2011 06:59:12 -0700 (PDT) Received: from mail-pv0-f178.google.com (mail-pv0-f178.google.com [74.125.83.178]) by mx.google.com with ESMTPS id c2si17253138wff.53.2011.07.01.06.59.12 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 01 Jul 2011 06:59:12 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.178 is neither permitted nor denied by best guess record for domain of david.gilbert@linaro.org) client-ip=74.125.83.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.83.178 is neither permitted nor denied by best guess record for domain of david.gilbert@linaro.org) smtp.mail=david.gilbert@linaro.org Received: by pvg7 with SMTP id 7so3314538pvg.37 for ; Fri, 01 Jul 2011 06:59:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.152.12 with SMTP id z12mr1346784wfd.337.1309528751036; Fri, 01 Jul 2011 06:59:11 -0700 (PDT) Received: by 10.142.44.9 with HTTP; Fri, 1 Jul 2011 06:59:11 -0700 (PDT) Date: Fri, 1 Jul 2011 14:59:11 +0100 Message-ID: Subject: Valgrind: ldrexd/strexd in thumb mode From: David Gilbert To: Patch Tracking https://bugs.kde.org/attachment.cgi?id=61530 for bug https://bugs.kde.org/show_bug.cgi?id=266035 --- guest_arm_toIR.c (revision 2163) +++ guest_arm_toIR.c (working copy) @@ -17706,6 +17769,76 @@ } } + /* ----------------- (T1) LDREXD ---------------- */ + if (INSN0(15,4) == 0xe8d) { + /* ldrexb, ldrexh, ldrexd (also TBB and tbh but they're done elsewhere */ + if (INSN1(7,0) == 0x7f) { + /* ldrexd */ + UInt rN = INSN0(3,0); + UInt rT = INSN1(15,12); + UInt rT2 = INSN1(11,8); + + if (isBadRegT(rT) || isBadRegT(rT2) || rT == rT2 || rN == 15) { + /* undecodable; fall through */ + } else { + IRTemp res; + + // go uncond + mk_skip_over_T32_if_cond_is_false( condT ); + + /* Ok, now we're unconditional. Do the load. */ + res = newTemp(Ity_I64); + stmt( IRStmt_LLSC(Iend_LE, res, getIRegT(rN), + NULL/*this is a load*/) ); + putIRegT(rT, unop(Iop_64HIto32, mkexpr(res)), IRTemp_INVALID); + putIRegT(rT2, unop(Iop_64to32, mkexpr(res)), IRTemp_INVALID); + + DIP("ldrexd r%u, r%u, [r%u]\n", rT, rT2, rN); + goto decode_success; + } + } + } + /* ----------------- (T1) STREXD ---------------- */ + if (INSN0(15,4) == 0xe8c) { + /* strexb, strexh, strexd */ + if (INSN1(7,4) == 0x7) { + /* strexd */ + UInt rN = INSN0(3,0); + UInt rT = INSN1(15,12); + UInt rT2 = INSN1(11,8); + UInt rD = INSN1(3,0); + + if (rD == 15 || rN == 15 + || isBadRegT(rD) || isBadRegT(rT) || isBadRegT(rT2) + || rD == rN || rD == rT || rD == rT2) { + /* undecodable; fall through */ + } else { + IRTemp data; + IRTemp resSC1, resSC32; + + // go uncond + mk_skip_over_T32_if_cond_is_false( condT ); + + data = newTemp(Ity_I64); + assign( data, binop(Iop_32HLto64, getIRegT(rT), getIRegT(rT2)) ); + resSC1 = newTemp(Ity_I1); + stmt( IRStmt_LLSC(Iend_LE, resSC1, getIRegT(rN), mkexpr(data)) ); + + /* Set rD to 1 on failure, 0 on success. Currently we have + resSC1 == 0 on failure, 1 on success. */ + resSC32 = newTemp(Ity_I32); + assign(resSC32, + unop(Iop_1Uto32, unop(Iop_Not1, mkexpr(resSC1)))); + + putIRegT(rD, mkexpr(resSC32), + IRTemp_INVALID); + DIP("strexd r%u, r%u, r%u, [r%u]\n", rD, rT, rT2, rN); + goto decode_success; + } + /* fall through */ + } + } + /* ----------------- (T1) STREX ----------------- */ if (INSN0(15,4) == 0xE84) { UInt rN = INSN0(3,0);