From patchwork Tue Jun 28 00:39:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9201599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4D7B66075F for ; Tue, 28 Jun 2016 00:58:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CAE828414 for ; Tue, 28 Jun 2016 00:58:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 311FF285AD; Tue, 28 Jun 2016 00:58:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4C03828414 for ; Tue, 28 Jun 2016 00:58:03 +0000 (UTC) Received: from localhost ([::1]:33538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHhLm-00022D-G3 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Jun 2016 20:58:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHh4L-0002oo-34 for qemu-devel@nongnu.org; Mon, 27 Jun 2016 20:40:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHh4I-0004R5-6y for qemu-devel@nongnu.org; Mon, 27 Jun 2016 20:40:00 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:33982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHh4I-0004R1-1Z for qemu-devel@nongnu.org; Mon, 27 Jun 2016 20:39:58 -0400 Received: by mail-qt0-x244.google.com with SMTP id m2so90315qtd.1 for ; Mon, 27 Jun 2016 17:39:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=jPRwreqzRFLGxWUA9pOzGZAbpbCOX0gBTQyLGuY82n8=; b=KnSElpOzg4CXMpsqJWqEJbu22BJpa87yp93MycSHM+7KLKgNPMSWYZKC6VWMVdPF2o YyWu57cZSEJMI0M+WW4XIjf7wOvaevpIB/QXaTnKyO0Wt9TAHgsTlMOKPJtSkqoo0luG ijEUsZTImb84YrQhzTybAPx7ni8aJPFuRQYlq33xpFRuq0HzuRZyKghZXJUK95q7xngV ruWFjFB6LdYpnCTSiDnsyzbwib2d6s3fx5W/ZUmO/HjDFIMKDeUF5VqBZYYahYwe5cFQ buHwkZp0yEME1sZOI3Qea3Dye4O3/SP77qlaP/cRRULx23u0ufvCLLukZ4pTQSKIcVSD jC4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=jPRwreqzRFLGxWUA9pOzGZAbpbCOX0gBTQyLGuY82n8=; b=eVE1chJ0CqDIaUi7JKpFsd28WC2eqrRr56FxRNVca0c6Dg3StqbqdIk7Htf+wULQWH 3bgA0Q82NcwrUfAiHXN409K0y/Lwq2gc15/vnpw/rps+FZ7aU0rKaBXy7xDFENweXfVz zafoFXwJ5qIS+Y30WqLRUs0K4vGnmaGkJJGNCE4aCHAJXGIlOjE+S8aipgzfhEEja2Uw ZNALMyeN+CcJqrB0EHrWV7BN5Sa2A0FizBkirMIsTg32Vb+SGCl2c4jbK5GLmMZHSI3r 2kZBefmFaJFpMt0JCB4C+S26o4tmZcsbUXwqIJhUOzYkmwSTEul+BszKyk+B0NGnPg5R ZSbQ== X-Gm-Message-State: ALyK8tIHJt/InJnW+3sO8mKUqSP7bSQ8ImPDksumz/f1bjKheF3LBHsiiCwaEn/JJaXyXA== X-Received: by 10.237.44.165 with SMTP id g34mr228209qtd.17.1467074397570; Mon, 27 Jun 2016 17:39:57 -0700 (PDT) Received: from bigtime.com (71-37-54-227.tukw.qwest.net. [71.37.54.227]) by smtp.gmail.com with ESMTPSA id 128sm190406qke.10.2016.06.27.17.39.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jun 2016 17:39:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 27 Jun 2016 17:39:02 -0700 Message-Id: <1467074353-26130-14-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1467074353-26130-1-git-send-email-rth@twiddle.net> References: <1467074353-26130-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c0d::244 Subject: [Qemu-devel] [PATCH v4 13/24] target-sparc: Use QT0 to return results from ldda 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: mark.cave-ayland@ilande.co.uk Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Also implement a few more twinx asis. Reviewed-By: Artyom Tarasenko Signed-off-by: Richard Henderson --- target-sparc/helper.h | 2 +- target-sparc/ldst_helper.c | 156 ++++++++++++++++++++++++++++++++------------- target-sparc/translate.c | 12 +++- 3 files changed, 120 insertions(+), 50 deletions(-) diff --git a/target-sparc/helper.h b/target-sparc/helper.h index 14712cc..66abf83 100644 --- a/target-sparc/helper.h +++ b/target-sparc/helper.h @@ -17,7 +17,7 @@ DEF_HELPER_1(rdcwp, tl, env) DEF_HELPER_2(wrcwp, void, env, tl) DEF_HELPER_FLAGS_2(array8, TCG_CALL_NO_RWG_SE, tl, tl, tl) DEF_HELPER_FLAGS_1(popc, TCG_CALL_NO_RWG_SE, tl, tl) -DEF_HELPER_4(ldda_asi, void, env, tl, int, int) +DEF_HELPER_FLAGS_3(ldda_asi, TCG_CALL_NO_WG, void, env, tl, int) DEF_HELPER_5(ldf_asi, void, env, tl, int, int, int) DEF_HELPER_FLAGS_5(stf_asi, TCG_CALL_NO_WG, void, env, tl, int, int, int) DEF_HELPER_FLAGS_5(casx_asi, TCG_CALL_NO_WG, tl, env, tl, tl, tl, i32) diff --git a/target-sparc/ldst_helper.c b/target-sparc/ldst_helper.c index a6c4d0c..23840db 100644 --- a/target-sparc/ldst_helper.c +++ b/target-sparc/ldst_helper.c @@ -1329,8 +1329,6 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, int asi, int size, case ASI_S: /* Secondary */ case ASI_PL: /* Primary LE */ case ASI_SL: /* Secondary LE */ - case ASI_BLK_INIT_QUAD_LDD_P: /* UA2007 Primary block init */ - case ASI_BLK_INIT_QUAD_LDD_S: /* UA2007 Secondary block init */ if ((asi & 0x80) && (env->pstate & PS_PRIV)) { if (cpu_hypervisor_mode(env)) { switch (size) { @@ -1443,11 +1441,6 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, int asi, int size, } break; } - case ASI_NUCLEUS_QUAD_LDD: /* Nucleus quad LDD 128 bit atomic */ - case ASI_NUCLEUS_QUAD_LDD_L: /* Nucleus quad LDD 128 bit atomic LE */ - /* Only ldda allowed */ - helper_raise_exception(env, TT_ILL_INSN); - return 0; case ASI_N: /* Nucleus */ case ASI_NL: /* Nucleus Little Endian (LE) */ { @@ -1595,6 +1588,25 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, int asi, int size, cpu_unassigned_access(cs, addr, false, false, 1, size); ret = 0; break; + + case ASI_NUCLEUS_QUAD_LDD: /* Nucleus quad LDD 128 bit atomic */ + case ASI_NUCLEUS_QUAD_LDD_L: /* Nucleus quad LDD 128 bit atomic LE */ + case ASI_TWINX_AIUP: /* As if user primary, twinx */ + case ASI_TWINX_AIUS: /* As if user secondary, twinx */ + case ASI_TWINX_REAL: /* Real address, twinx */ + case ASI_TWINX_AIUP_L: /* As if user primary, twinx, LE */ + case ASI_TWINX_AIUS_L: /* As if user secondary, twinx, LE */ + case ASI_TWINX_REAL_L: /* Real address, twinx, LE */ + case ASI_TWINX_N: /* Nucleus, twinx */ + case ASI_TWINX_NL: /* Nucleus, twinx, LE */ + /* ??? From the UA2011 document; overlaps BLK_INIT_QUAD_LDD_* */ + case ASI_TWINX_P: /* Primary, twinx */ + case ASI_TWINX_PL: /* Primary, twinx, LE */ + case ASI_TWINX_S: /* Secondary, twinx */ + case ASI_TWINX_SL: /* Secondary, twinx, LE */ + /* These are all 128-bit atomic; only ldda (now ldtxa) allowed */ + helper_raise_exception(env, TT_ILL_INSN); + return 0; } /* Convert from little endian */ @@ -1702,8 +1714,6 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, case ASI_S: /* Secondary */ case ASI_PL: /* Primary LE */ case ASI_SL: /* Secondary LE */ - case ASI_BLK_INIT_QUAD_LDD_P: /* UA2007 Primary block init */ - case ASI_BLK_INIT_QUAD_LDD_S: /* UA2007 Secondary block init */ if ((asi & 0x80) && (env->pstate & PS_PRIV)) { if (cpu_hypervisor_mode(env)) { switch (size) { @@ -1816,11 +1826,6 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, } } return; - case ASI_NUCLEUS_QUAD_LDD: /* Nucleus quad LDD 128 bit atomic */ - case ASI_NUCLEUS_QUAD_LDD_L: /* Nucleus quad LDD 128 bit atomic LE */ - /* Only ldda allowed */ - helper_raise_exception(env, TT_ILL_INSN); - return; case ASI_N: /* Nucleus */ case ASI_NL: /* Nucleus Little Endian (LE) */ { @@ -2001,6 +2006,24 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, case ASI_INTR_RECEIVE: /* Interrupt data receive */ env->ivec_status = val & 0x20; return; + case ASI_NUCLEUS_QUAD_LDD: /* Nucleus quad LDD 128 bit atomic */ + case ASI_NUCLEUS_QUAD_LDD_L: /* Nucleus quad LDD 128 bit atomic LE */ + case ASI_TWINX_AIUP: /* As if user primary, twinx */ + case ASI_TWINX_AIUS: /* As if user secondary, twinx */ + case ASI_TWINX_REAL: /* Real address, twinx */ + case ASI_TWINX_AIUP_L: /* As if user primary, twinx, LE */ + case ASI_TWINX_AIUS_L: /* As if user secondary, twinx, LE */ + case ASI_TWINX_REAL_L: /* Real address, twinx, LE */ + case ASI_TWINX_N: /* Nucleus, twinx */ + case ASI_TWINX_NL: /* Nucleus, twinx, LE */ + /* ??? From the UA2011 document; overlaps BLK_INIT_QUAD_LDD_* */ + case ASI_TWINX_P: /* Primary, twinx */ + case ASI_TWINX_PL: /* Primary, twinx, LE */ + case ASI_TWINX_S: /* Secondary, twinx */ + case ASI_TWINX_SL: /* Secondary, twinx, LE */ + /* Only stda allowed */ + helper_raise_exception(env, TT_ILL_INSN); + return; case ASI_DCACHE_DATA: /* D-cache data */ case ASI_DCACHE_TAG: /* D-cache tag access */ case ASI_ESTATE_ERROR_EN: /* E-cache error enable */ @@ -2034,8 +2057,11 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, } #endif /* CONFIG_USER_ONLY */ -void helper_ldda_asi(CPUSPARCState *env, target_ulong addr, int asi, int rd) +/* 128-bit LDDA; result returned in QT0. */ +void helper_ldda_asi(CPUSPARCState *env, target_ulong addr, int asi) { + uint64_t h, l; + if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0) || (cpu_has_hypervisor(env) && asi >= 0x30 && asi < 0x80 @@ -2047,44 +2073,82 @@ void helper_ldda_asi(CPUSPARCState *env, target_ulong addr, int asi, int rd) switch (asi) { #if !defined(CONFIG_USER_ONLY) - case ASI_NUCLEUS_QUAD_LDD: /* Nucleus quad LDD 128 bit atomic */ - case ASI_NUCLEUS_QUAD_LDD_L: /* Nucleus quad LDD 128 bit atomic LE */ + case ASI_TWINX_AIUP: /* As if user primary, twinx */ + case ASI_TWINX_AIUP_L: /* As if user primary, twinx, LE */ helper_check_align(env, addr, 0xf); - if (rd == 0) { - env->gregs[1] = cpu_ldq_nucleus(env, addr + 8); - if (asi == ASI_NUCLEUS_QUAD_LDD_L) { - bswap64s(&env->gregs[1]); - } - } else if (rd < 8) { - env->gregs[rd] = cpu_ldq_nucleus(env, addr); - env->gregs[rd + 1] = cpu_ldq_nucleus(env, addr + 8); - if (asi == ASI_NUCLEUS_QUAD_LDD_L) { - bswap64s(&env->gregs[rd]); - bswap64s(&env->gregs[rd + 1]); - } - } else { - env->regwptr[rd - 8] = cpu_ldq_nucleus(env, addr); - env->regwptr[rd + 1 - 8] = cpu_ldq_nucleus(env, addr + 8); - if (asi == ASI_NUCLEUS_QUAD_LDD_L) { - bswap64s(&env->regwptr[rd - 8]); - bswap64s(&env->regwptr[rd + 1 - 8]); + h = cpu_ldq_user(env, addr); + l = cpu_ldq_user(env, addr + 8); + break; + case ASI_TWINX_AIUS: /* As if user secondary, twinx */ + case ASI_TWINX_AIUS_L: /* As if user secondary, twinx, LE */ + helper_check_align(env, addr, 0xf); + h = cpu_ldq_user_secondary(env, addr); + l = cpu_ldq_user_secondary(env, addr + 8); + break; + case ASI_TWINX_REAL: /* Real address, twinx */ + case ASI_TWINX_REAL_L: /* Real address, twinx, LE */ + helper_check_align(env, addr, 0xf); + { + CPUState *cs = CPU(sparc_env_get_cpu(env)); + h = ldq_phys(cs->as, addr); + l = ldq_phys(cs->as, addr + 8); + } + break; + case ASI_NUCLEUS_QUAD_LDD: + case ASI_NUCLEUS_QUAD_LDD_L: + case ASI_TWINX_N: /* Nucleus, twinx */ + case ASI_TWINX_NL: /* Nucleus, twinx, LE */ + helper_check_align(env, addr, 0xf); + h = cpu_ldq_nucleus(env, addr); + l = cpu_ldq_nucleus(env, addr + 8); + break; + case ASI_TWINX_S: /* Secondary, twinx */ + case ASI_TWINX_SL: /* Secondary, twinx, LE */ + if (!cpu_hypervisor_mode(env)) { + helper_check_align(env, addr, 0xf); + if (env->pstate & PS_PRIV) { + h = cpu_ldq_kernel_secondary(env, addr); + l = cpu_ldq_kernel_secondary(env, addr + 8); + } else { + h = cpu_ldq_user_secondary(env, addr); + l = cpu_ldq_user_secondary(env, addr + 8); } + break; } + /* fallthru */ + case ASI_TWINX_P: /* Primary, twinx */ + case ASI_TWINX_PL: /* Primary, twinx, LE */ + helper_check_align(env, addr, 0xf); + h = cpu_ldq_data(env, addr); + l = cpu_ldq_data(env, addr + 8); break; +#else + case ASI_TWINX_P: /* Primary, twinx */ + case ASI_TWINX_PL: /* Primary, twinx, LE */ + case ASI_TWINX_S: /* Primary, twinx */ + case ASI_TWINX_SL: /* Primary, twinx, LE */ + /* ??? Should be available, but we need to implement + an atomic 128-bit load. */ + helper_raise_exception(env, TT_PRIV_ACT); #endif default: - helper_check_align(env, addr, 0x3); - if (rd == 0) { - env->gregs[1] = helper_ld_asi(env, addr + 4, asi, 4, 0); - } else if (rd < 8) { - env->gregs[rd] = helper_ld_asi(env, addr, asi, 4, 0); - env->gregs[rd + 1] = helper_ld_asi(env, addr + 4, asi, 4, 0); - } else { - env->regwptr[rd - 8] = helper_ld_asi(env, addr, asi, 4, 0); - env->regwptr[rd + 1 - 8] = helper_ld_asi(env, addr + 4, asi, 4, 0); - } - break; + /* Non-twinx asi, so this is the legacy ldda insn, which + performs two word sized operations. */ + /* ??? The UA2011 manual recommends emulating this with + a single 64-bit load. However, LE asis *are* treated + as two 32-bit loads individually byte swapped. */ + helper_check_align(env, addr, 0x7); + QT0.high = (uint32_t)helper_ld_asi(env, addr, asi, 4, 0); + QT0.low = (uint32_t)helper_ld_asi(env, addr + 4, asi, 4, 0); + return; + } + + if (asi & 8) { + h = bswap64(h); + l = bswap64(l); } + QT0.high = h; + QT0.low = l; } void helper_ldf_asi(CPUSPARCState *env, target_ulong addr, int asi, int size, diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 55364ad..885fa58 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -2307,12 +2307,18 @@ static void gen_ldda_asi(DisasContext *dc, TCGv hi, TCGv addr, default: { TCGv_i32 r_asi = tcg_const_i32(da.asi); - TCGv_i32 r_rd = tcg_const_i32(rd); + TCGv_i64 tmp; save_state(dc); - gen_helper_ldda_asi(cpu_env, addr, r_asi, r_rd); - tcg_temp_free_i32(r_rd); + gen_helper_ldda_asi(cpu_env, addr, r_asi); tcg_temp_free_i32(r_asi); + + tmp = gen_dest_gpr(dc, rd); + tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUSPARCState, qt0.high)); + gen_store_gpr(dc, rd, tmp); + tmp = gen_dest_gpr(dc, rd + 1); + tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUSPARCState, qt0.low)); + gen_store_gpr(dc, rd + 1, tmp); } break; }