From patchwork Sat Feb 2 09:43:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10794245 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 491BF746 for ; Sat, 2 Feb 2019 09:57:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A9903154F for ; Sat, 2 Feb 2019 09:57:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F283315C6; Sat, 2 Feb 2019 09:57:59 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C84483154F for ; Sat, 2 Feb 2019 09:57:58 +0000 (UTC) Received: from localhost ([127.0.0.1]:40099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gps3i-0002T4-4J for patchwork-qemu-devel@patchwork.kernel.org; Sat, 02 Feb 2019 04:57:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gprzI-0006z8-Hq for qemu-devel@nongnu.org; Sat, 02 Feb 2019 04:53:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gprq8-0005hF-05 for qemu-devel@nongnu.org; Sat, 02 Feb 2019 04:43:57 -0500 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]:36371) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gprq5-0005WZ-Uh for qemu-devel@nongnu.org; Sat, 02 Feb 2019 04:43:55 -0500 Received: by mail-ed1-x541.google.com with SMTP id f23so7492720edb.3 for ; Sat, 02 Feb 2019 01:43:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=subject:date:message-id:in-reply-to:references:cc:from:to; bh=VsEG5EqtY/F+uxugfJZjY5iDDB0h1Q1FwFLq+ViPw8A=; b=EGmT8jIL7TUd74YGaj3Jsr3YfNXRK3ptPXzUbXooqKQSCvVVmHwQcdAWLnxEVuFS0W nkGjJWt8bf3DNHHrjZ0a136IpB83vcBeVv7wuZOy8XsfUOLTWFJlIT3w2mBQf1XgShxI CH8R48yUAZ3t6ggsFGOsQus4o1nDmC471CA9yrmrreODwKUCiwu9e0tUjbSQQyRFIL0x PT6m/28vthCAV09T6k3RFttHMKqPy8R7MYzu9+uuAKCzYNA6Y10Uhorrq0T3svtda6kx v11e3UuVLC5vXAT9ZGYqT0mlprI8J7XBb99BBxMni2FLGQ2nNWxt0cHxLJ91uBlK4vzH Hrrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :cc:from:to; bh=VsEG5EqtY/F+uxugfJZjY5iDDB0h1Q1FwFLq+ViPw8A=; b=mKmE5ly7X1BRKCWtEHi8u7XReax5RhoVMUvWFeSz0mIPvFnK9jdeFCOGECQ38BC/1F B5/oxQ4AMmFIfL8jZS94fo0g71pCWGoUC0rr62ujFzcSHeHq1kXJ7oRV2nliHm0E4NCu BAx/4rBhJMko60FT5W2HE3amtaMgw1Ea9KO31vCUAlctMx2tTznsA0eHdH3iH6FbfJUc wHhotHLom5dc0EM7dZXTvLNSx10H1oBw1fVjognzH8fI0fCy6G35eFTBOGcTH99otodU s1xGPYt4DzBKvZS7p3B8tt8nYfKH13ijiTSC4coY9mtewhjIWjsupyNd0SFppPj0zysT FQcw== X-Gm-Message-State: AJcUukfiB5h2u35zdGNDfIjA7aPQQNysB4gjjPkH5kqJKwPLat8ucD1/ DRvxGDd5t5F9CfDn4obuJxFnkg== X-Google-Smtp-Source: ALg8bN5iM9GIyqLWUDJUfeALUsMmV4TvEJdNga3GJYEXmtkL7NuKbO3XiQoej4M+ec83UUgeUAVucg== X-Received: by 2002:a50:a622:: with SMTP id d31mr44346771edc.228.1549100625259; Sat, 02 Feb 2019 01:43:45 -0800 (PST) Received: from localhost ([2001:67c:1810:f051:fd32:55e2:f60b:183b]) by smtp.gmail.com with ESMTPSA id g21sm2665204edc.63.2019.02.02.01.43.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Feb 2019 01:43:44 -0800 (PST) Date: Sat, 2 Feb 2019 01:43:24 -0800 Message-Id: <20190202094329.22874-6-palmer@sifive.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190202094329.22874-1-palmer@sifive.com> References: <20190202094329.22874-1-palmer@sifive.com> From: Palmer Dabbelt To: Peter Maydell X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::541 Subject: [Qemu-devel] [PULL 05/10] RISC-V: Add priv_ver to DisasContext 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: Alistair Francis , Palmer Dabbelt , qemu-riscv@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Alistair Francis The gen methods should access state from DisasContext. Add priv_ver field to the DisasContext struct. Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Signed-off-by: Palmer Dabbelt --- target/riscv/translate.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 0581b3c1f7d7..35eb6bdfe099 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -43,6 +43,7 @@ typedef struct DisasContext { DisasContextBase base; /* pc_succ_insn points to the instruction following base.pc_next */ target_ulong pc_succ_insn; + target_ulong priv_ver; uint32_t opcode; uint32_t mstatus_fs; uint32_t mem_idx; @@ -1330,7 +1331,7 @@ static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc, #ifndef CONFIG_USER_ONLY /* Extract funct7 value and check whether it matches SFENCE.VMA */ if ((opc == OPC_RISC_ECALL) && ((csr >> 5) == 9)) { - if (env->priv_ver == PRIV_VERSION_1_10_0) { + if (ctx->priv_ver == PRIV_VERSION_1_10_0) { /* sfence.vma */ /* TODO: handle ASID specific fences */ gen_helper_tlb_flush(cpu_env); @@ -1384,7 +1385,7 @@ static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc, gen_helper_wfi(cpu_env); break; case 0x104: /* SFENCE.VM */ - if (env->priv_ver <= PRIV_VERSION_1_09_1) { + if (ctx->priv_ver <= PRIV_VERSION_1_09_1) { gen_helper_tlb_flush(cpu_env); } else { gen_exception_illegal(ctx); @@ -1854,10 +1855,12 @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx) static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) { DisasContext *ctx = container_of(dcbase, DisasContext, base); + CPURISCVState *env = cs->env_ptr; ctx->pc_succ_insn = ctx->base.pc_first; ctx->mem_idx = ctx->base.tb->flags & TB_FLAGS_MMU_MASK; ctx->mstatus_fs = ctx->base.tb->flags & TB_FLAGS_MSTATUS_FS; + ctx->priv_ver = env->priv_ver; ctx->frm = -1; /* unknown rounding mode */ }