From patchwork Fri Nov 16 21:30:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10687049 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 65FF014D6 for ; Fri, 16 Nov 2018 21:35:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 573322D1DF for ; Fri, 16 Nov 2018 21:35:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A6272D54A; Fri, 16 Nov 2018 21:35:08 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 DF7FF2D1DF for ; Fri, 16 Nov 2018 21:35:07 +0000 (UTC) Received: from localhost ([::1]:47075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNllb-0003TJ-98 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 16 Nov 2018 16:35:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNlhm-0000Ma-RT for qemu-devel@nongnu.org; Fri, 16 Nov 2018 16:31:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNlhi-0001iu-Py for qemu-devel@nongnu.org; Fri, 16 Nov 2018 16:31:10 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:46945) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gNlhh-0001gr-Fl for qemu-devel@nongnu.org; Fri, 16 Nov 2018 16:31:05 -0500 Received: by mail-pl1-x644.google.com with SMTP id t13so8750650ply.13 for ; Fri, 16 Nov 2018 13:31:02 -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=v8thlYChsOVWo1muMkMOtoqaVRzSIwN5qBNyohP/GZI=; b=bSzCpLkREpjYw/FAjuDeWoFmreejGhaZ/YKDWWiy6RwmMpR84RsvOWlV6z9hy2bnrW wte6lkFs2adkQ8JskipXZscdpBqG2CQMDp9/KkIZBFL/RtzGo/rYovw9wod3VSXHpxgX mv044FO3D3hYKMeC1qdcaNFMisecgj8/Wn3mw5g9GCThHxUNNdqkrPwWnN3ha1a0qm7E HkcZpqJcjaztxeRT5dV1dnRSkiE6PEGCZ/FZD6YctuFtsniF9Vy9JizOSJhUzMhxwPus Udc2lJ83Aq9fFUZtmDsUP/souqEOgLjrvDlqK/Xo6/2IMlrSGVrgXLwfhrNyQ7oMMsVd Pzdw== 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=v8thlYChsOVWo1muMkMOtoqaVRzSIwN5qBNyohP/GZI=; b=rwIY3CqieSxwHenXqyta4/mzLtpf5bihaWLm8BBE+75H0nn4Qq+STOEMl9Xasi2Ucb HSJNEG/JuXMJQh0IEi/+QIyGGPDEFgyW+sKXmaakO5jbZEolZKg0enOlf0/HD1UYt0QB 32r2Bf2ohI+BsmS7Hgqt9cIzmNh2eQ97U0zzVnsSxIGiqLeYwxxDE58v1BWalOYZBn9U aIGAnGEkM4Dqou4sCceGi17ddN0aQq6LI0jgDpQFgMmilxEpgxhsM2/0TDHGKuHp8ik/ SUHghC3pN+j69+MZhdq1ilnvXmS3KENttPFna82xteY6jNufmecGORomXLCJaP2bAVtv bAnA== X-Gm-Message-State: AGRZ1gJeSG6QO2qfBkrSPmAbfE11+6nQHV+Zhd+142G7f0zs2SO2hJto wEr8llTaMPVThgHOPWY91OIrb46PiEc7cw== X-Google-Smtp-Source: AJdET5ejevUScU5COtn7bZt3r0z/mB+/gl++NJenrtjKkTiKIHZkpn6yY7k0Cl+TJCoZBT27I6zt4Q== X-Received: by 2002:a17:902:9881:: with SMTP id s1-v6mr6298192plp.328.1542403860766; Fri, 16 Nov 2018 13:31:00 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id b202sm15729094pfb.88.2018.11.16.13.30.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Nov 2018 13:30:59 -0800 (PST) Date: Fri, 16 Nov 2018 13:30:43 -0800 Message-Id: <20181116213045.19825-4-palmer@sifive.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181116213045.19825-1-palmer@sifive.com> References: <20181116213045.19825-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::644 Subject: [Qemu-devel] [PULL 3/4] target/riscv: Fix sfence.vm/a both available in any priv version 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: Bastian Koppelmann , 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: Bastian Koppelmann sfence.vm has been replaced in priv v1.10 spec by sfence.vma. Reported-by: Richard Henderson Signed-off-by: Bastian Koppelmann Reviewed-by: Richard Henderson Signed-off-by: Palmer Dabbelt --- target/riscv/translate.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 5359088e24bc..f44eb9c41b48 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1292,10 +1292,14 @@ 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)) { - /* sfence.vma */ - /* TODO: handle ASID specific fences */ - gen_helper_tlb_flush(cpu_env); - return; + if (env->priv_ver == PRIV_VERSION_1_10_0) { + /* sfence.vma */ + /* TODO: handle ASID specific fences */ + gen_helper_tlb_flush(cpu_env); + return; + } else { + gen_exception_illegal(ctx); + } } #endif @@ -1342,7 +1346,11 @@ static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc, gen_helper_wfi(cpu_env); break; case 0x104: /* SFENCE.VM */ - gen_helper_tlb_flush(cpu_env); + if (env->priv_ver <= PRIV_VERSION_1_09_1) { + gen_helper_tlb_flush(cpu_env); + } else { + gen_exception_illegal(ctx); + } break; #endif default: