From patchwork Wed Jan 30 17:35:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10789089 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 38D3713BF for ; Wed, 30 Jan 2019 17:38:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27C6C2F8D2 for ; Wed, 30 Jan 2019 17:38:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19C9B2F9BA; Wed, 30 Jan 2019 17:38:34 +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 A1A432F8D2 for ; Wed, 30 Jan 2019 17:38:33 +0000 (UTC) Received: from localhost ([127.0.0.1]:41807 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goton-0005wj-08 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 30 Jan 2019 12:38:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gotn5-0004gU-7S for qemu-devel@nongnu.org; Wed, 30 Jan 2019 12:36:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gotn3-00006y-Vz for qemu-devel@nongnu.org; Wed, 30 Jan 2019 12:36:47 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:44938) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gotn3-0008S7-QZ for qemu-devel@nongnu.org; Wed, 30 Jan 2019 12:36:45 -0500 Received: by mail-pg1-x536.google.com with SMTP id t13so107536pgr.11 for ; Wed, 30 Jan 2019 09:36:26 -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=Ox39KvqwawXqwttSHEir8j8oTXIJeu4VCyeHYz8rIShNfmMZ2+W8MOr+5rv3dZSJ76 +rm9AYpvq9gT2GvzY7Zb+WG8eEifI4NLPFuiybaSk6KZJhkjzTXcZcy3MH81YH3322NH upePV8B1dAEc5rl7k5+4dac72ODBibZE+Xxn5NhOWeEnRz8W4GSIRn0A+GxWkhATr5Y/ KF6i4hm7K+TwgCMa/4FAoeJvvStnae32ZAFKKwmgKxuiZDZ3eVvLa2Q9YNDePTL/SfZ9 a7B1A0IcZ18M4DlekXvgZr8RtpXjdzLg6QYH0N09EnJGKuZttLMt0q9X0OBeIDDR+FYr DHww== 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=SRAxJ4m/vlPPWc1Iiux85Uc1PBjqcyOF4gwQzUmL6MHSBbDiNTWavCFbSMRz9L4RmU 2m4ioKMKEmAkNOzfOVFZ90skSWDLE1E0vk1vgQ0Iwx7bE4HcOHyib+j7Oj4ZtAKZ67F8 HSVlQeKnQ4sqkYvInGnXVoXRN05j/qzWOG2Q6UYRa8Ld8L4F2Lb/kE9B1spfZLJLkZKh +rLlaAJ5wCUB3iT/1aue3ypwzqbmwgnqTXDEL27ZuD81bZQlS2EXBbODo7F2Q2Z9EokI tUKK9sOSufAezbD3GJBtx63Q74ZTpmHzPyR9R2lhKeaVvDXJczZjheFtFAwMcPaHgLUz 8owQ== X-Gm-Message-State: AJcUukcnOwJtzkY8UnvidnjNA0gcPzRIAPBm2mLFjeIlueA4gCitZqjy 5WxSSpWKoIYpRjP6bOzpJ720zXtZaU0= X-Google-Smtp-Source: ALg8bN7peMaf0GYFTdUNXfWD64dzFYrvAEw1GZF3X7+9w5xl4RLEInvO/RDi2QLpTaFbklt5U6P1cg== X-Received: by 2002:a63:f1f:: with SMTP id e31mr28079825pgl.274.1548869785312; Wed, 30 Jan 2019 09:36:25 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id m67sm7018486pfb.25.2019.01.30.09.36.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 09:36:24 -0800 (PST) Date: Wed, 30 Jan 2019 09:35:56 -0800 Message-Id: <20190130173601.3268-6-palmer@sifive.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190130173601.3268-1-palmer@sifive.com> References: <20190130173601.3268-1-palmer@sifive.com> From: Palmer Dabbelt To: qemu-riscv@nongnu.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 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: Palmer Dabbelt , Alistair Francis , 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 */ }