From patchwork Wed Feb 13 15:44:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10810189 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 C866C1399 for ; Wed, 13 Feb 2019 15:47:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5D222D958 for ; Wed, 13 Feb 2019 15:47:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A99A42D986; Wed, 13 Feb 2019 15:47:00 +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 4BD182D959 for ; Wed, 13 Feb 2019 15:47:00 +0000 (UTC) Received: from localhost ([127.0.0.1]:58824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtwkV-0002Ap-HG for patchwork-qemu-devel@patchwork.kernel.org; Wed, 13 Feb 2019 10:46:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtwiw-00026z-MR for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:45:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtwiq-0006hg-G9 for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:45:20 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:45289) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtwio-0006at-Qq for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:45:14 -0500 Received: by mail-pl1-x62e.google.com with SMTP id r14so1318201pls.12 for ; Wed, 13 Feb 2019 07:45:11 -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=e4/Z1dmMBry1NJ3ubcYYRerIcMd2PxVzfpMI1AVbeef6+jWxx1mX0oXiHFeOZLKpwC kcrpNkneJcoGAOSAXqt8pADwirF9q06ypQQdgNAySYCop27Ct+WiHf7XuzTxHvGlEZSF ykGZfnfm9iwDakZx1zMSUfIQDsyK5TL/VvmzuHbI34YTD1acbvJwXD+Y4OGg+y6Kuc1/ 1MpTo7qUpj5mf2iRAXKdLvT301tkTt6TpTm/o1otbaz5G0dIIJjnGSTIpzfPJE+Haj7R N47JCXXS0AF94fV1Ln44UE7ok7NNR0FpsQiPVIN9dy6nTTFJbRnmYALYvujzdey2oEQ6 uMkw== 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=c9CZkEFZxuZN7G+Ho2SnJxC2MMkpZn3qHFlnO69Wssohd/J7V+A1DfkkpcTDXvq0DD S/lQowyuq+qjNdZtxXIsrAmb/AdWMF93KAgYzyVc39RnUYU029tzl3SQ8zzF31mNQCt8 y5xvxRXtjnU2IXursalxFHju0wyuWDjtUv2uBULdOcCtmbnHPLLuArCKXY8ohTnMoSh4 aYLBlJt+tuL2DuQtdwVRzdY/0Om/Wz1mPDlkIth/Q3jn7OAm5jBP6Sa64I05Z92JurZV 9mMQfTdwTVvwkVDgnw+WwqtV45sP/rsQaSkWG5stPowgd4KgA30983T5pIiOCclEggXs hWaQ== X-Gm-Message-State: AHQUAubOc+hG2fW3BlLI7uLFpu/bySMCQLxMzvRJSnzgwyQPkd7mXIHz +AkNuny5DDL24OE9SHsl3ymzqEvllow= X-Google-Smtp-Source: AHgI3Ia3F1XI6Y0NJBEU6jbRqFIsSE9ulrC51JnFGh9DnuYSudXeUJn60F8nqMBDQCGvRmsQCUd8EA== X-Received: by 2002:a17:902:4225:: with SMTP id g34mr1192793pld.152.1550072710529; Wed, 13 Feb 2019 07:45:10 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id k17sm4098110pfj.92.2019.02.13.07.45.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 07:45:09 -0800 (PST) Date: Wed, 13 Feb 2019 07:44:44 -0800 Message-Id: <20190213154450.14749-6-palmer@sifive.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190213154450.14749-1-palmer@sifive.com> References: <20190213154450.14749-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: 2607:f8b0:4864:20::62e Subject: [Qemu-devel] [PULL 05/11] 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 */ }