From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boy4y-0002oR-NP for qemu-devel@nongnu.org; Tue, 27 Sep 2016 15:30:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boy4s-0003Av-PU for qemu-devel@nongnu.org; Tue, 27 Sep 2016 15:30:11 -0400 Received: from mail-yw0-x241.google.com ([2607:f8b0:4002:c05::241]:33479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boy4s-0003AC-Ls for qemu-devel@nongnu.org; Tue, 27 Sep 2016 15:30:06 -0400 Received: by mail-yw0-x241.google.com with SMTP id g192so938579ywh.0 for ; Tue, 27 Sep 2016 12:30:06 -0700 (PDT) Sender: Richard Henderson References: <5612d43547465b4fbb2e2e8be0857413b575cb0d.1474886798.git.sagark@eecs.berkeley.edu> From: Richard Henderson Message-ID: Date: Tue, 27 Sep 2016 12:30:03 -0700 MIME-Version: 1.0 In-Reply-To: <5612d43547465b4fbb2e2e8be0857413b575cb0d.1474886798.git.sagark@eecs.berkeley.edu> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 08/18] target-riscv: Add Atomic Instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sagar Karandikar , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, kbastian@mail.uni-paderborn.de On 09/26/2016 03:56 AM, Sagar Karandikar wrote: > +static inline void gen_atomic(DisasContext *ctx, uint32_t opc, > + int rd, int rs1, int rs2) > +{ > + /* TODO: handle aq, rl bits? - for now just get rid of them: */ > + opc = MASK_OP_ATOMIC_NO_AQ_RL(opc); We have already added tcg_gen_mb to insert memory barriers; hopefully the branch containing atomic operations will be merged soon. See git://github.com/rth7680/qemu.git atomic-4 > + case OPC_RISC_SC_W: > + tcg_gen_brcond_tl(TCG_COND_NE, load_res, source1, j); > + tcg_gen_qemu_st_tl(source2, source1, ctx->mem_idx, MO_TEUL | MO_ALIGN); > + tcg_gen_movi_tl(dat, 0); /*success */ > + tcg_gen_br(done); > + gen_set_label(j); > + tcg_gen_movi_tl(dat, 1); /*fail */ > + gen_set_label(done); > + break; I will note that generally SC needs to compare against the value loaded by LR as well as the address used by LR. Please have a look at the AArch64 implementation. r~