From patchwork Fri Oct 19 06:06:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149235 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2914075lji; Thu, 18 Oct 2018 23:21:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV63l53VcLvoXKh/K8ycoLvukPpMH6H/DLsfitccF1dRCspLjLWvjHLjhwEGWh+yRfzGQvaqN X-Received: by 2002:ac8:6616:: with SMTP id c22-v6mr30779271qtp.199.1539930076296; Thu, 18 Oct 2018 23:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539930076; cv=none; d=google.com; s=arc-20160816; b=jz3f0UnBC2bZV6FTRvIqRGesbHleQxAY8+BDQO4GvODQ3it3KQvjs8tgf/Q/vrD9xv 6HBnTf4zhzqgJOw9Z07vUPlcF0g0fu6IT8tQKpSAEyOESWLmvnjxiAXjUzNtI1N0/5AO 0r81CbnPe/qgyfuYFNxebs8Mz/EhyomDwEkY0MRiXCqZ2jvaqkS3RHiyc6B1h8uSuAH/ 0iRokkT4Wp69eRUGWQNXvFWQRQsPI9qLtMN9LxNojSIidnh9QbKNbHY3vH6xWqFDQ4Rb y3sy5uFM0UBHhT0mTgDf00o3qRAfzJrmtN+BM/7rOZeQFl0lNPf4IWcwYZrGDcQNjX9q J0Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=xbiOv5TcJ4wgSOcnZ3lHtDhz8sB5I99xM4Z83wc2zVg=; b=tBH2zkU1uaSgxeENCTuWodBTL8WQQmWsiUxHZ7rIKTDETzUzTcjLY7ARItbNFUJN1u fHXIXXUmey1w+mb/i8/hAOZgtD0H7fNQ7MdlIoi3ZtpzazzVvulvgy4ietBPIoE/mJ+4 dSapjLGu8qoUGF6UoFLyS64nyrVEuimWzScO46anR5XgaVOfuVZ2LCtgsnHJv9uToxSP V4G00QrFAjp17wZZLK/hJCQeksFUU4i6JxESDoykviSvGUem0LMpFq9zZIIWjPjv0iP0 1GjxT8hBDzZlBmrVe+Xo4fSt1f9zZLTRpbf0NULeOvKivgOXVPdfl5uKmTkGUhp6jmOl PxaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ErxLqeww; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k27si4024358qvf.30.2018.10.18.23.21.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 18 Oct 2018 23:21:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ErxLqeww; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDO9r-0007zK-Pg for patch@linaro.org; Fri, 19 Oct 2018 02:21:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDNwh-0004RQ-6Z for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDNwf-0002lW-Dj for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:38 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:32963) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gDNwe-0002Mm-Oa for qemu-devel@nongnu.org; Fri, 19 Oct 2018 02:07:37 -0400 Received: by mail-pg1-x536.google.com with SMTP id y18-v6so15320162pge.0 for ; Thu, 18 Oct 2018 23:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xbiOv5TcJ4wgSOcnZ3lHtDhz8sB5I99xM4Z83wc2zVg=; b=ErxLqeww6aXFNH4/HGr6Gdse2OBNyV46Bei7anqxeD+yDfThSFKsAk6hC+0h3FxCId Ye0ezDZpl1nkdYdohzMlAcqX+UlDPkSBeLh3mHMs1/iXanbjyHK8hCXdGUoLvxEe/o51 +uSzmz+WijdQf5UGv2bBkcyiW9c7U2s8jbT2g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xbiOv5TcJ4wgSOcnZ3lHtDhz8sB5I99xM4Z83wc2zVg=; b=GufINeEw6rQfubo+JLEOqndDdgfidRlxbcFJWAhIXuuB4xFUuYtmVoLwf86q5dw+Uu o5I4gu45pii4zNFhednxULvgstVMVPW98D+6HyRQvErmtO556B6FE+A26Z+y9SK3Hx79 /P6Ye3bWaAte7s/HOQ60GijJLahx/nhnZVBRoKIHmbc7RosmOREvwwtG5RP5DFu4q287 nJ6hXR+c1v1Z/IHlgRuSWvOuZbVOipCHI73MT1rbF1UUIk0bvf9u5Hp4eqCWb2mAGOIk eb8AHN1FELG+xIiME5KCMoK+Zvcd5lxLcANEimU5fzfdFVvwOU8j/E270n5bTNVLJeNp 6idg== X-Gm-Message-State: ABuFfohd3Erm4ARpHsZ9LpEjmlK9sxFA3mO08OKzSUy7isBljvJqBKMg R84Hs+stTPr3u1IRL19jn6nzRzke8aM= X-Received: by 2002:a62:2bc2:: with SMTP id r185-v6mr33393418pfr.21.1539929246392; Thu, 18 Oct 2018 23:07:26 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-133.tukw.qwest.net. [174.21.9.133]) by smtp.gmail.com with ESMTPSA id q24-v6sm25609327pff.83.2018.10.18.23.07.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 23:07:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 23:06:55 -0700 Message-Id: <20181019060656.7968-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181019060656.7968-1-richard.henderson@linaro.org> References: <20181019060656.7968-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::536 Subject: [Qemu-devel] [PULL v2 20/21] target/s390x: Check HAVE_ATOMIC128 and HAVE_CMPXCHG128 at translate X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- target/s390x/mem_helper.c | 40 +++++++++++++++++++-------------------- target/s390x/translate.c | 25 +++++++++++++++++------- 2 files changed, 38 insertions(+), 27 deletions(-) -- 2.17.2 diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index b5858d2fa2..490c43e6e6 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1420,9 +1420,7 @@ void HELPER(cdsg_parallel)(CPUS390XState *env, uint64_t addr, Int128 oldv; bool fail; - if (!HAVE_CMPXCHG128) { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_CMPXCHG128); mem_idx = cpu_mmu_index(env, false); oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); @@ -2115,16 +2113,17 @@ uint64_t HELPER(lpq_parallel)(CPUS390XState *env, uint64_t addr) { uintptr_t ra = GETPC(); uint64_t hi, lo; + int mem_idx; + TCGMemOpIdx oi; + Int128 v; - if (HAVE_ATOMIC128) { - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - Int128 v = helper_atomic_ldo_be_mmu(env, addr, oi, ra); - hi = int128_gethi(v); - lo = int128_getlo(v); - } else { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_ATOMIC128); + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + v = helper_atomic_ldo_be_mmu(env, addr, oi, ra); + hi = int128_gethi(v); + lo = int128_getlo(v); env->retxl = lo; return hi; @@ -2145,15 +2144,16 @@ void HELPER(stpq_parallel)(CPUS390XState *env, uint64_t addr, uint64_t low, uint64_t high) { uintptr_t ra = GETPC(); + int mem_idx; + TCGMemOpIdx oi; + Int128 v; - if (HAVE_ATOMIC128) { - int mem_idx = cpu_mmu_index(env, false); - TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); - Int128 v = int128_make128(low, high); - helper_atomic_sto_be_mmu(env, addr, v, oi, ra); - } else { - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } + assert(HAVE_ATOMIC128); + + mem_idx = cpu_mmu_index(env, false); + oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); + v = int128_make128(low, high); + helper_atomic_sto_be_mmu(env, addr, v, oi, ra); } /* Execute instruction. This instruction executes an insn modified with diff --git a/target/s390x/translate.c b/target/s390x/translate.c index a7bd689337..b5bd56b7ee 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -44,6 +44,7 @@ #include "trace-tcg.h" #include "exec/translator.h" #include "exec/log.h" +#include "qemu/atomic128.h" /* Information that (most) every instruction needs to manipulate. */ @@ -2040,6 +2041,7 @@ static DisasJumpType op_cdsg(DisasContext *s, DisasOps *o) int r3 = get_field(s->fields, r3); int d2 = get_field(s->fields, d2); int b2 = get_field(s->fields, b2); + DisasJumpType ret = DISAS_NEXT; TCGv_i64 addr; TCGv_i32 t_r1, t_r3; @@ -2047,17 +2049,20 @@ static DisasJumpType op_cdsg(DisasContext *s, DisasOps *o) addr = get_address(s, 0, b2, d2); t_r1 = tcg_const_i32(r1); t_r3 = tcg_const_i32(r3); - if (tb_cflags(s->base.tb) & CF_PARALLEL) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { + gen_helper_cdsg(cpu_env, addr, t_r1, t_r3); + } else if (HAVE_CMPXCHG128) { gen_helper_cdsg_parallel(cpu_env, addr, t_r1, t_r3); } else { - gen_helper_cdsg(cpu_env, addr, t_r1, t_r3); + gen_helper_exit_atomic(cpu_env); + ret = DISAS_NORETURN; } tcg_temp_free_i64(addr); tcg_temp_free_i32(t_r1); tcg_temp_free_i32(t_r3); set_cc_static(s); - return DISAS_NEXT; + return ret; } static DisasJumpType op_csst(DisasContext *s, DisasOps *o) @@ -3034,10 +3039,13 @@ static DisasJumpType op_lpd(DisasContext *s, DisasOps *o) static DisasJumpType op_lpq(DisasContext *s, DisasOps *o) { - if (tb_cflags(s->base.tb) & CF_PARALLEL) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { + gen_helper_lpq(o->out, cpu_env, o->in2); + } else if (HAVE_ATOMIC128) { gen_helper_lpq_parallel(o->out, cpu_env, o->in2); } else { - gen_helper_lpq(o->out, cpu_env, o->in2); + gen_helper_exit_atomic(cpu_env); + return DISAS_NORETURN; } return_low128(o->out2); return DISAS_NEXT; @@ -4414,10 +4422,13 @@ static DisasJumpType op_stmh(DisasContext *s, DisasOps *o) static DisasJumpType op_stpq(DisasContext *s, DisasOps *o) { - if (tb_cflags(s->base.tb) & CF_PARALLEL) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { + gen_helper_stpq(cpu_env, o->in2, o->out2, o->out); + } else if (HAVE_ATOMIC128) { gen_helper_stpq_parallel(cpu_env, o->in2, o->out2, o->out); } else { - gen_helper_stpq(cpu_env, o->in2, o->out2, o->out); + gen_helper_exit_atomic(cpu_env); + return DISAS_NORETURN; } return DISAS_NEXT; }