From patchwork Tue Jul 3 05:57:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 140903 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp777116ljj; Mon, 2 Jul 2018 23:16:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdm2oiG8qICn02JaxvarJdgR5puq16KKepyQGf8tXKphvyfu4z8qA9zyhDuqu0PBgsD9lPs X-Received: by 2002:ac8:376a:: with SMTP id p39-v6mr15852423qtb.257.1530598583044; Mon, 02 Jul 2018 23:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530598583; cv=none; d=google.com; s=arc-20160816; b=bf/8G9Ch+ASq+ubNYM4LVQseSk9giRoWmBI3t4/3x62UO4gwrMdWllcFD2ZJFM9fJ/ ZnGTJyhoShhediIKzmSQV5qZZYcC/sfCGvXml2tCHxrNIUf12Qlw97hus4pHVf4nO3OJ tc3G+Rp6RD2DCaJGP/YQYe4CXh4gSjezRHsNJW8tLrH3zkxcCclqlu66vSxEGN3nlj8H ty/4VTuqe+jwRezQoZIKHvl84t2IFtFbVIxM4plMF6yIS8H+bchNIU/lpbwmgUx/ka0z QJBMA0y8N60/3tTZ0AcQ8AVj7FeP31Lakjs7T4MEasfLUijWsP5WPZy54R+QB5H33PgV luIg== 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:arc-authentication-results; bh=kaN5u7JFQ8U1Rs0Q0Ierd50YNUnMK/z2u0PGbLB3og4=; b=tINvccaOb7SUZCwGrLngrLnEn3Kx6uvuK0XDtovDwFu2+mTeC+mx6QYzy2FTqSqC2m pNCEGlGgliX37+hkS2QEerTasDWZpcL1qHR2KlnYNKz9llg+FacTY8JGWk3PK83PYnmI 8iFUvE4eIPX5h9g0ShBlwGuVISpiWUy+jatZd6Tf09aBQuiH045eEXEEifn3Pwcjjkli lnX11nDNPMmdRcB2p2c6/JEaK5xLTqDSnxXfb9gpAj5RJfWdtHjheysFhs6Uh0FAgHdW i7TkS6c1Jo9mSjxVUp5O18iwwxSCMe8RhRsBmOTWyPKU7QDFPiWTETvNPDR4ClRikn5q +V8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b=miNqF7eR; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a25-v6si375038qtp.285.2018.07.02.23.16.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 23:16:23 -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=@gibson.dropbear.id.au header.s=201602 header.b=miNqF7eR; 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" Received: from localhost ([::1]:38024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEbu-0008PG-Dq for patch@linaro.org; Tue, 03 Jul 2018 02:16:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKT-0002pU-Mb for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKR-0006wZ-L4 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:21 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:46609) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKQ-0006tQ-Pz; Tue, 03 Jul 2018 01:58:19 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM820J3z9s5c; Tue, 3 Jul 2018 15:58:11 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597492; bh=+op4qHd5DWt9QN8eRmYhE6PDypEs4nGq0DdaqcdC1sE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=miNqF7eRHl5VoUaTsto9Sz4MTyboshlVvw1uO2yTyQZCCz9Y+s1ELJsotqCcwSJvy +kapJBwIcbeLZbEzPWVakQq3OQRrNcxajLB5WJ6VmFnaOEUvLEyYPV1+85WXxPAdIe LGF3c2YeGvDXpCN/jOd4FTHQBgOX/89jSCaI2oVI= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:42 +1000 Message-Id: <20180703055804.13449-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 13/35] target/ppc: Use atomic store for STQ 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: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Section 1.4 of the Power ISA v3.0B states that this insn is single-copy atomic. As we cannot (yet) issue 128-bit stores within TCG, use the generic helpers provided. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/helper.h | 4 ++++ target/ppc/mem_helper.c | 14 ++++++++++++++ target/ppc/translate.c | 35 +++++++++++++++++++++++++++-------- 3 files changed, 45 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 3f451a5d7e..cbc1228570 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -803,4 +803,8 @@ DEF_HELPER_FLAGS_1(fixup_thrm, TCG_CALL_NO_RWG, void, env) #if defined(TARGET_PPC64) && defined(CONFIG_ATOMIC128) DEF_HELPER_FLAGS_3(lq_le_parallel, TCG_CALL_NO_WG, i64, env, tl, i32) DEF_HELPER_FLAGS_3(lq_be_parallel, TCG_CALL_NO_WG, i64, env, tl, i32) +DEF_HELPER_FLAGS_5(stq_le_parallel, TCG_CALL_NO_WG, + void, env, tl, i64, i64, i32) +DEF_HELPER_FLAGS_5(stq_be_parallel, TCG_CALL_NO_WG, + void, env, tl, i64, i64, i32) #endif diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index 44a8f3445a..57e301edc3 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -231,6 +231,20 @@ uint64_t helper_lq_be_parallel(CPUPPCState *env, target_ulong addr, env->retxh = int128_gethi(ret); return int128_getlo(ret); } + +void helper_stq_le_parallel(CPUPPCState *env, target_ulong addr, + uint64_t lo, uint64_t hi, uint32_t opidx) +{ + Int128 val = int128_make128(lo, hi); + helper_atomic_sto_le_mmu(env, addr, val, opidx, GETPC()); +} + +void helper_stq_be_parallel(CPUPPCState *env, target_ulong addr, + uint64_t lo, uint64_t hi, uint32_t opidx) +{ + Int128 val = int128_make128(lo, hi); + helper_atomic_sto_be_mmu(env, addr, val, opidx, GETPC()); +} #endif /*****************************************************************************/ diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 0923cc24e3..3d63a62269 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -2760,6 +2760,7 @@ static void gen_std(DisasContext *ctx) if ((ctx->opcode & 0x3) == 0x2) { /* stq */ bool legal_in_user_mode = (ctx->insns_flags2 & PPC2_LSQ_ISA207) != 0; bool le_is_supported = (ctx->insns_flags2 & PPC2_LSQ_ISA207) != 0; + TCGv hi, lo; if (!(ctx->insns_flags & PPC_64BX)) { gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); @@ -2783,20 +2784,38 @@ static void gen_std(DisasContext *ctx) EA = tcg_temp_new(); gen_addr_imm_index(ctx, EA, 0x03); - /* We only need to swap high and low halves. gen_qemu_st64_i64 does - necessary 64-bit byteswap already. */ - if (unlikely(ctx->le_mode)) { - gen_qemu_st64_i64(ctx, cpu_gpr[rs + 1], EA); + /* Note that the low part is always in RS+1, even in LE mode. */ + lo = cpu_gpr[rs + 1]; + hi = cpu_gpr[rs]; + + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { +#ifdef CONFIG_ATOMIC128 + TCGv_i32 oi = tcg_temp_new_i32(); + if (ctx->le_mode) { + tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx)); + gen_helper_stq_le_parallel(cpu_env, EA, lo, hi, oi); + } else { + tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx)); + gen_helper_stq_be_parallel(cpu_env, EA, lo, hi, oi); + } + tcg_temp_free_i32(oi); +#else + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp = DISAS_NORETURN; +#endif + } else if (ctx->le_mode) { + tcg_gen_qemu_st_i64(lo, EA, ctx->mem_idx, MO_LEQ); gen_addr_add(ctx, EA, EA, 8); - gen_qemu_st64_i64(ctx, cpu_gpr[rs], EA); + tcg_gen_qemu_st_i64(hi, EA, ctx->mem_idx, MO_LEQ); } else { - gen_qemu_st64_i64(ctx, cpu_gpr[rs], EA); + tcg_gen_qemu_st_i64(hi, EA, ctx->mem_idx, MO_BEQ); gen_addr_add(ctx, EA, EA, 8); - gen_qemu_st64_i64(ctx, cpu_gpr[rs + 1], EA); + tcg_gen_qemu_st_i64(lo, EA, ctx->mem_idx, MO_BEQ); } tcg_temp_free(EA); } else { - /* std / stdu*/ + /* std / stdu */ if (Rc(ctx->opcode)) { if (unlikely(rA(ctx->opcode) == 0)) { gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);