Received: from [140.186.70.92] (port=43714 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PUfq0-0004XX-MW for qemu-devel@nongnu.org; Mon, 20 Dec 2010 08:31:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PUfpy-0007DH-CP for qemu-devel@nongnu.org; Mon, 20 Dec 2010 08:31:39 -0500 Received: from adelie.canonical.com ([91.189.90.139]:57105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PUfpy-0007Cx-2j for qemu-devel@nongnu.org; Mon, 20 Dec 2010 08:31:38 -0500 Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.69 #1 (Debian)) id 1PUfps-0002Y5-Kh for ; Mon, 20 Dec 2010 13:31:32 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id BA7B82E8341 for ; Mon, 20 Dec 2010 13:31:00 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Date: Mon, 20 Dec 2010 13:23:58 -0000 From: Peter Maydell Sender: bounces@canonical.com References: <20101104115532.21991.17107.malonedeb@soybean.canonical.com> Message-Id: <20101220132359.29899.40095.malone@wampee.canonical.com> Errors-To: bounces@canonical.com Subject: [Qemu-devel] [Bug 670883] Re: ARM : ldrexd and strexd implementation flawed Reply-To: Bug 670883 <670883@bugs.launchpad.net> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org The patch has now been merged into qemu's master git repo: http://git.qemu.org/qemu.git/commit/?id=3D2c9adbda721c9996ec6b371cac4a00c11= 64b818e (and so this bug should be fixed in the 0.14 release since that has not yet branched.) ** Changed in: qemu Status: New =3D> Fix Committed -- = You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/670883 Title: ARM : ldrexd and strexd implementation flawed Status in QEMU: Fix Committed Bug description: The ldrexd / strexd instructions have a flawed implementation : it never = works properly. For example, the most simple code something like: ldrexd r0, r1, [r2] strexd r4, r0, r1, [r2] which should usually have r4 as zero (successfully done the exclusive store= ). However, the current implementation always returns one (unsuccessfully = done the exclusive store). The current trunk (function gen_load_exclusive, gen_store_exclusive, both f= rom target-arm/translate.c) looks like an incorrect implementation: static void gen_load_exclusive(DisasContext *s, int rt, int rt2, TCGv addr, int size) { TCGv tmp; switch (size) { case 0: tmp =3D gen_ld8u(addr, IS_USER(s)); break; case 1: tmp =3D gen_ld16u(addr, IS_USER(s)); break; case 2: case 3: tmp =3D gen_ld32(addr, IS_USER(s)); break; default: abort(); } tcg_gen_mov_i32(cpu_exclusive_val, tmp); store_reg(s, rt, tmp); if (size =3D=3D 3) { tcg_gen_addi_i32(addr, addr, 4); tmp =3D gen_ld32(addr, IS_USER(s)); tcg_gen_mov_i32(cpu_exclusive_high, tmp); store_reg(s, rt2, tmp); } tcg_gen_mov_i32(cpu_exclusive_addr, addr); } The problem lies when size is 3 (=3Dldrexd) : normally, cpu_exclusive_addr = should be set as addr, but since the current implementation increments addr= by 4 (when size is 3) before cpu_exclusive_addr is updated, it results in = a wrong value stored on cpu_exclusive_addr. Another error on gen_store_exclusive(): ... if (size =3D=3D 3) { TCGv tmp2 =3D new_tmp(); tcg_gen_addi_i32(tmp2, addr, 4); tmp =3D gen_ld32(addr, IS_USER(s)); dead_tmp(tmp2); tcg_gen_brcond_i32(TCG_COND_NE, tmp, cpu_exclusive_high, fail_label= ); dead_tmp(tmp); } .... the current code assigns tmp2 as addr + 4, but loads from addr on the next = line, not from tmp2(=3Daddr+4).