From patchwork Tue Nov 13 23:50:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10681663 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 4C35214BA for ; Tue, 13 Nov 2018 23:53:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E14F295A5 for ; Tue, 13 Nov 2018 23:53:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 320D22B5F0; Tue, 13 Nov 2018 23:53:02 +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 BC8BE295A5 for ; Tue, 13 Nov 2018 23:53:01 +0000 (UTC) Received: from localhost ([::1]:56539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMiUK-0004VU-0g for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Nov 2018 18:52:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMiT4-0003az-LA for qemu-devel@nongnu.org; Tue, 13 Nov 2018 18:51:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMiSx-0006e0-Oy for qemu-devel@nongnu.org; Tue, 13 Nov 2018 18:51:36 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:34325) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gMiSv-0006ZL-5n for qemu-devel@nongnu.org; Tue, 13 Nov 2018 18:51:31 -0500 Received: by mail-pg1-x542.google.com with SMTP id 17so6196752pgg.1 for ; Tue, 13 Nov 2018 15:51:23 -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=g/0ZoLa/6hOSVcbxsf6LhvQmJ78j8RGRzY77SQsviG3VLBbDF0Pku4DZnTArlQg3zv 34YKAz5jnytHkObVj3/jRBrsyDNSV72zpGcyBhtvrOr62fUsXGpHKhAxhOnoJHmO5qjH X6LGbvIOtsMJjfuXluocDcG13F7nhGW1fiWI8BsSt1rpQcXFsXYTUBuDosuVQ0erqWB7 aiQJMf8XKutg4F4jzqDwaNd9S5Fm4Okq9eB9ynnM1jnyhRGDJzQlxuGIVBiTUDC2aumR V78BGwoLH9tJzZMMyqtlPYAeGi1wxaAwqEUkHSptv2B/oZ5K/dhjV1/PI4G9MaZ+SE7v bxbg== 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=jPdbS9L+07eCYWjKu2XsC/nC79aQ7KDfjy8QtTl3uyR5TAzVpVUq4Uo0ybD8xqoSVd D0aPMndJSUrWPZ1B7pQw9rvNjZCihqWhhvjFQK1lBRjXb8wwzGXKJXIN+bzqbeLZLpFR 7EDHuLj4Hj3diif/f81xU70vesOvJSxfQ7Q1gCXwwFYGe/1DbQprQJ33zgbrR6ziwris VfWQtUHciLJ8eiAcG9w39BxB30a3OXzZ0Sb75UL2VySgZazMsZI0bfgAxsPmWewcxBwD b4wjm+rjEjjWxP6bXevcP6uQESoqdVbN0mhQSim5KAQuawaUsmgNRekf9E07LWumtrcw A1Hw== X-Gm-Message-State: AGRZ1gI01AGjwiHeBWPdscJpRQXTjYF6DH70pKxAwyd2iWztD+LHehsi yYIZI2KsdPXlaifdUTl+Qi8iJ0fljH4VBQ== X-Google-Smtp-Source: AJdET5c4PqvB2Q/qFxqFjPa+fVPck1GCrvW4QGad3rhTRDtQbe0SXHBWQSB5lCmdNjfKtKDhe3VEXA== X-Received: by 2002:a62:682:: with SMTP id 124-v6mr7240462pfg.161.1542153082487; Tue, 13 Nov 2018 15:51:22 -0800 (PST) Received: from localhost ([64.114.255.114]) by smtp.gmail.com with ESMTPSA id u5-v6sm25512059pgk.46.2018.11.13.15.51.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Nov 2018 15:51:21 -0800 (PST) Date: Tue, 13 Nov 2018 15:50:44 -0800 Message-Id: <20181113235045.14155-4-palmer@sifive.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181113235045.14155-1-palmer@sifive.com> References: <20181113235045.14155-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::542 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-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: