From patchwork Wed Feb 28 22:16:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10249977 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 A36C560362 for ; Wed, 28 Feb 2018 22:18:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 885D028A67 for ; Wed, 28 Feb 2018 22:18:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C7A228B5A; Wed, 28 Feb 2018 22:18:14 +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=-5.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, HK_RANDOM_FROM, 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 E294C28A67 for ; Wed, 28 Feb 2018 22:18:13 +0000 (UTC) Received: from localhost ([::1]:47322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erA3B-0004cp-04 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Feb 2018 17:18:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erA1a-0003GP-SJ for qemu-devel@nongnu.org; Wed, 28 Feb 2018 17:16:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erA1W-0003BD-LO for qemu-devel@nongnu.org; Wed, 28 Feb 2018 17:16:34 -0500 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:44316) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1erA1W-00038d-0s for qemu-devel@nongnu.org; Wed, 28 Feb 2018 17:16:30 -0500 Received: by mail-lf0-x243.google.com with SMTP id v9so5848320lfa.11 for ; Wed, 28 Feb 2018 14:16:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5tRFWLdPx/DoJNriMMjiE8t2oXE+IdV2YJOrIeUQM9g=; b=T3YL92ndx1QDAss16Zr1SzZsDloD+SgXTq4hlnWuzb+C8NGP/zB9bu3Pku4eEysYut haqUFcH7XH1vsrxJ/Dw/O1HKqfPDi2yFuOfCIrcS0NYF8h4HR9+x/QvineqvX5sMwp79 n0eaEtXvPxDpxtHslI5YjgHcrvD76CtosqGucKnepmm603lSQJHMiezqYqym3IWCuYic nsy307hdE0FnIoTSztqOvTJkosQ59YeONgQGUso0qfAd6dAkxfiVYAvvKEdp4gh8Cees HtXNkADNRnugwTkFU3V7mW8Utb7fAxEWe+euZ5H0ax8bsAjQYcEMSZWmCGfQrQGixzg+ OQGA== 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=5tRFWLdPx/DoJNriMMjiE8t2oXE+IdV2YJOrIeUQM9g=; b=H2u/ZTQ3WbscNItmraBElDQxQlIOMSS4IOS1iUtHLiVzz4FeWPRWYyiaditw2IicfS MvlnlgVSJqz+SyH0S6d5cK/oH7zd1yopOK62BUQlK2/GdAnapZ1tt1qTDJkS96wXVROk QcN7U7cS0Dlrb8bBjRxTVejZzFhv95FawZcui9lMDlw71/IxF3AH49jLNZCj2klAK3ce o7XsPnD2PMmPhSwfkSkPCVqIqUlYhCPd2Xqbnv73E49CuKZPFjq3wP4rvbpUTRRbflgd 10OGcD5UV9K/EnqpJgw7sjUlT9eFTDIsPewnFeUzDu4Pv0afHp9M2qMtMVSh3oH2eqOh aABw== X-Gm-Message-State: APf1xPCuZYdb/ym/V/N48JFXdk8IRR1GSGk1l0rmTec666GccgV7jibo 5QeXL0iyMLuxAK2TKsVJHCuMMg== X-Google-Smtp-Source: AG47ELsiYixAA8iTUwzGvjzu9Xo/8uaMkD6ffPxzNo6ehn5tPTbte11E/mqVAO5qNxfm5XvpsmCqWQ== X-Received: by 10.46.47.23 with SMTP id v23mr1558894ljv.70.1519856188224; Wed, 28 Feb 2018 14:16:28 -0800 (PST) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id s82sm566984lja.7.2018.02.28.14.16.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 14:16:27 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 14:16:02 -0800 Message-Id: <20180228221609.11265-5-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180228221609.11265-1-jcmvbkbc@gmail.com> References: <20180228221609.11265-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::243 Subject: [Qemu-devel] [PATCH v2 04/11] target/xtensa: support MTTCG 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: Max Filippov , "Emilio G . Cota" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP - emit TCG barriers for MEMW, EXTW, S32RI and L32AI; - do atomic_cmpxchg_i32 for S32C1I. Cc: Emilio G. Cota Signed-off-by: Max Filippov --- configure | 1 + target/xtensa/cpu.h | 3 +++ target/xtensa/translate.c | 46 +++++++++++++++++++++++++++++++--------------- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/configure b/configure index 39f3a4300163..f83bdeb2a550 100755 --- a/configure +++ b/configure @@ -6813,6 +6813,7 @@ case "$target_name" in ;; xtensa|xtensaeb) TARGET_ARCH=xtensa + mttcg="yes" ;; *) error_exit "Unsupported target CPU" diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 255cc9e08ed9..d9d3b33a7052 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -31,6 +31,9 @@ #define ALIGNED_ONLY #define TARGET_LONG_BITS 32 +/* Xtensa processors have a weak memory model */ +#define TCG_GUEST_DEFAULT_MO (0) + #define CPUArchState struct CPUXtensaState #include "qemu-common.h" diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 5969d7c3cd96..c06d30d17960 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -1664,9 +1664,15 @@ static void translate_ldst(DisasContext *dc, const uint32_t arg[], gen_load_store_alignment(dc, par[0] & MO_SIZE, addr, par[1]); } if (par[2]) { + if (par[1]) { + tcg_gen_mb(TCG_BAR_STRL | TCG_MO_ALL); + } tcg_gen_qemu_st_tl(cpu_R[arg[0]], addr, dc->cring, par[0]); } else { tcg_gen_qemu_ld_tl(cpu_R[arg[0]], addr, dc->cring, par[0]); + if (par[1]) { + tcg_gen_mb(TCG_BAR_LDAQ | TCG_MO_ALL); + } } tcg_temp_free(addr); } @@ -1823,6 +1829,12 @@ static void translate_mac16(DisasContext *dc, const uint32_t arg[], } } +static void translate_memw(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) +{ + tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL); +} + static void translate_minmax(DisasContext *dc, const uint32_t arg[], const uint32_t par[]) { @@ -2193,29 +2205,33 @@ static void translate_setb_expstate(DisasContext *dc, const uint32_t arg[], tcg_gen_ori_i32(cpu_UR[EXPSTATE], cpu_UR[EXPSTATE], 1u << arg[0]); } +#ifdef CONFIG_USER_ONLY +static void gen_check_atomctl(DisasContext *dc, TCGv_i32 addr) +{ +} +#else +static void gen_check_atomctl(DisasContext *dc, TCGv_i32 addr) +{ + TCGv_i32 tpc = tcg_const_i32(dc->pc); + + gen_helper_check_atomctl(cpu_env, tpc, addr); + tcg_temp_free(tpc); +} +#endif + static void translate_s32c1i(DisasContext *dc, const uint32_t arg[], const uint32_t par[]) { if (gen_window_check2(dc, arg[0], arg[1])) { - TCGLabel *label = gen_new_label(); TCGv_i32 tmp = tcg_temp_local_new_i32(); TCGv_i32 addr = tcg_temp_local_new_i32(); - TCGv_i32 tpc; tcg_gen_mov_i32(tmp, cpu_R[arg[0]]); tcg_gen_addi_i32(addr, cpu_R[arg[1]], arg[2]); gen_load_store_alignment(dc, 2, addr, true); - - tpc = tcg_const_i32(dc->pc); - gen_helper_check_atomctl(cpu_env, tpc, addr); - tcg_gen_qemu_ld32u(cpu_R[arg[0]], addr, dc->cring); - tcg_gen_brcond_i32(TCG_COND_NE, cpu_R[arg[0]], - cpu_SR[SCOMPARE1], label); - - tcg_gen_qemu_st32(tmp, addr, dc->cring); - - gen_set_label(label); - tcg_temp_free(tpc); + gen_check_atomctl(dc, addr); + tcg_gen_atomic_cmpxchg_i32(cpu_R[arg[0]], addr, cpu_SR[SCOMPARE1], + tmp, dc->cring, MO_32); tcg_temp_free(addr); tcg_temp_free(tmp); } @@ -2828,7 +2844,7 @@ static const XtensaOpcodeOps core_ops[] = { .translate = translate_extui, }, { .name = "extw", - .translate = translate_nop, + .translate = translate_memw, }, { .name = "hwwdtlba", .translate = translate_ill, @@ -2945,7 +2961,7 @@ static const XtensaOpcodeOps core_ops[] = { .par = (const uint32_t[]){TCG_COND_GEU}, }, { .name = "memw", - .translate = translate_nop, + .translate = translate_memw, }, { .name = "min", .translate = translate_minmax,