From patchwork Fri Apr 29 15:34:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12832389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C57E7C433EF for ; Fri, 29 Apr 2022 15:44:18 +0000 (UTC) Received: from localhost ([::1]:47832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkSn4-0000TR-0f for qemu-devel@archiver.kernel.org; Fri, 29 Apr 2022 11:44:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkSe9-00053V-Qj for qemu-devel@nongnu.org; Fri, 29 Apr 2022 11:35:06 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:39742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nkSe8-0007s1-0L for qemu-devel@nongnu.org; Fri, 29 Apr 2022 11:35:05 -0400 Received: by mail-pg1-x530.google.com with SMTP id i62so6806230pgd.6 for ; Fri, 29 Apr 2022 08:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Iph17vM5JKx2zwjUTuCtizhPT+K6iT4BbkNaUeHmZmk=; b=pbVoXyPpz6u2GpHz6nk0NY2yd35Pcl2nKq8I+pW3/lAHkvbDOUo+zeHcqTvdhtvO4F lHqBdc7Dgw11Z5KTSqcMdROARtteC6IrwCrslglxw1zAGBvdi7vGPrEpy+1s/PxNHt8+ /WjqlI6ifmRCvgCvZmqjo4fUpsjDHCoOr/O6hsADs/qlRtatiVeA3arnU4JTREU4kqQ/ nba/hqfHEK5ooI93NNv/ZSLzltk7T4vKUfRwAfldYiHf+beQBxD1fTo6tEv5XxohaQ/H /yePhYtkoIAMcljjAuVhEeN07681uq1FdBs/ZrT9bBR5MgWjTmtLxmJqqpTtsoKzlk+u SJ7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Iph17vM5JKx2zwjUTuCtizhPT+K6iT4BbkNaUeHmZmk=; b=qmyzEIVhp06du82C+Ug1JoAOFFV0WNbc5IlIAN60ygUskhQvLstniVAZA08Tqi/0ZR b40gkSv4yJ/nwqe5pkDdeJZ6Nrkxhj7DFHXMCsx+rvZGC82YWOscRAbU8xZxWAWru/W9 iA/4ncqE6t31OtCnbtOKc55o7n3KBktCOkooEkCJtWTdz32ZOBxrzuL4030PZ8oLm/1a s233u6AmWOpF8xIXHl4r8BiX0lBXTZQfGWnOuwP0tByNDSuIrAiC2ZfUKvhHY5/v/1pq t33tmsdW2ZXiaQYe1gyqrMlhR+MLNkBlNQ+byPSezo+48mwVe4YLNvY92B6RwC3iWUjS DKfg== X-Gm-Message-State: AOAM531X6/cE6ciZVckNhMIxBqxu/0bjmaCfwIBDgF/MGNSf0sRCV6Ax ic0r6ZT5oJ0Q7SkgqyWKXRAMDg== X-Google-Smtp-Source: ABdhPJwhecgxf5jmlYzSo1MdOmEWhZkEOfAzoEbiqR5gVRgboxsLXmBPzsOL0mstx31LTRRbpL2quw== X-Received: by 2002:a63:8c1:0:b0:3c1:7c1b:7084 with SMTP id 184-20020a6308c1000000b003c17c1b7084mr6642934pgi.438.1651246502498; Fri, 29 Apr 2022 08:35:02 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([122.167.97.237]) by smtp.gmail.com with ESMTPSA id t13-20020a65608d000000b003c14af50606sm6439380pgu.30.2022.04.29.08.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 08:35:01 -0700 (PDT) From: Anup Patel To: Peter Maydell , Palmer Dabbelt , Alistair Francis , Sagar Karandikar Subject: [PATCH 1/3] target/riscv: Don't force update priv spec version to latest Date: Fri, 29 Apr 2022 21:04:29 +0530 Message-Id: <20220429153431.308829-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220429153431.308829-1-apatel@ventanamicro.com> References: <20220429153431.308829-1-apatel@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=apatel@ventanamicro.com; helo=mail-pg1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Atish Patra Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The riscv_cpu_realize() sets priv spec verion to v1.12 when it is when "env->priv_ver == 0" (i.e. default v1.10) because the enum value of priv spec v1.10 is zero. Due to above issue, the sifive_u machine will see priv spec v1.12 instead of priv spec v1.10. To fix this issue, we set latest priv spec version (i.e. v1.12) for base rv64/rv32 cpu and riscv_cpu_realize() will override priv spec version only when "cpu->cfg.priv_spec != NULL". Fixes: 7100fe6c2441 ("target/riscv: Enable privileged spec version 1.12") Signed-off-by: Anup Patel Reviewed-by: Frank Chang Reviewed-by: Alistair Francis Reviewed-by: Atish Patra --- target/riscv/cpu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f0a702fee6..02ee7d45d8 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -169,6 +169,8 @@ static void rv64_base_cpu_init(Object *obj) CPURISCVState *env = &RISCV_CPU(obj)->env; /* We set this in the realise function */ set_misa(env, MXL_RV64, 0); + /* Set latest version of privileged specification */ + set_priv_version(env, PRIV_VERSION_1_12_0); } static void rv64_sifive_u_cpu_init(Object *obj) @@ -204,6 +206,8 @@ static void rv32_base_cpu_init(Object *obj) CPURISCVState *env = &RISCV_CPU(obj)->env; /* We set this in the realise function */ set_misa(env, MXL_RV32, 0); + /* Set latest version of privileged specification */ + set_priv_version(env, PRIV_VERSION_1_12_0); } static void rv32_sifive_u_cpu_init(Object *obj) @@ -509,7 +513,7 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) CPURISCVState *env = &cpu->env; RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(dev); CPUClass *cc = CPU_CLASS(mcc); - int priv_version = 0; + int priv_version = -1; Error *local_err = NULL; cpu_exec_realizefn(cs, &local_err); @@ -533,10 +537,8 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) } } - if (priv_version) { + if (priv_version >= PRIV_VERSION_1_10_0) { set_priv_version(env, priv_version); - } else if (!env->priv_ver) { - set_priv_version(env, PRIV_VERSION_1_12_0); } if (cpu->cfg.mmu) { From patchwork Fri Apr 29 15:34:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12832430 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2BDEC433EF for ; Fri, 29 Apr 2022 16:15:11 +0000 (UTC) Received: from localhost ([::1]:36232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkTGv-0000HP-3S for qemu-devel@archiver.kernel.org; Fri, 29 Apr 2022 12:15:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkSeD-0005Dd-Ol for qemu-devel@nongnu.org; Fri, 29 Apr 2022 11:35:10 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:38415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nkSeB-00083J-Ky for qemu-devel@nongnu.org; Fri, 29 Apr 2022 11:35:09 -0400 Received: by mail-pj1-x1031.google.com with SMTP id cx11-20020a17090afd8b00b001d9fe5965b3so8906898pjb.3 for ; Fri, 29 Apr 2022 08:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5WjOMo0TMUU1OTQL/m4WBjGf/+/CuZs36+TMUyQ5xTU=; b=P/QndRt6B7RJTdmM3YkWThIndiBR9zqHTSUO9chlPqQOYrLTL1PO+DaenUaMjUhlVX ziTLFh2wD62hGnyfTCYXxfIdjEk4tt3ZX/UiNoD/pdcW6IG+X386dHfpjTyeuBVoPU1v kf6z1EpDdv3vMRWIgmXytLppTAQik9LJ9ilye1k5MplDhiPfTw+Cj9I3G5RJUunMXPLY mW3s7fHa+y5Bm4DMbFwmNTwnxogSjzVLA+Pf1Ge2ADLR0PoB3GL2/hfzRGyp1VxtLBCC mDlxQiC6fzXo+4nXFqi40EcCLvlxikR1RmiAaT0ToHQgOnULBDlyS++LX5c38bcbwMDF lu2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5WjOMo0TMUU1OTQL/m4WBjGf/+/CuZs36+TMUyQ5xTU=; b=BZZHwYyG223iyA+Nq29CCzp3IPy0TDN5ccueRPpFJfG58WlovBou67bXUIs1JjR7lv EwyXxgvzG71cXz/UrEOQn3KFeVfvNX6E80E4rJ2hHFDmO1TyaE1yj8cyIsdfFVBbv48h ZO3zombwmzNkP//WrBPhsKdJKyFBfk8HgbGEHVNGAOjgrAotEx10RFRQihVv+j4Wjg5U ziQjUuR+any9agTTTxvFX7XPOdjMl2ZoLQnc2rafa3hL52Twc5KjGED0Ws4vw8llD8Fc BxGgA7z/RLVOPZO4PNyLle6L4gkxI1bwqFcg6ja53XsqXK0HHoUbJOV89jiFbZ8GQUcu eX9w== X-Gm-Message-State: AOAM5321HVWJdulo8zMsdEJ+VGd32y/va4i3Rtuwlzy/pCZVvDYF0AM3 /9CelZknb6CfZtjuKJM0a/G3nw== X-Google-Smtp-Source: ABdhPJz7QiDqL9f49LjxROWn+igG/3zXVZDek/3DwtFlWBrpM6669mn/+pxULBAzU5mZONhrrGD84w== X-Received: by 2002:a17:902:e94e:b0:158:91e6:501 with SMTP id b14-20020a170902e94e00b0015891e60501mr39165683pll.29.1651246506346; Fri, 29 Apr 2022 08:35:06 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([122.167.97.237]) by smtp.gmail.com with ESMTPSA id t13-20020a65608d000000b003c14af50606sm6439380pgu.30.2022.04.29.08.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 08:35:05 -0700 (PDT) From: Anup Patel To: Peter Maydell , Palmer Dabbelt , Alistair Francis , Sagar Karandikar Subject: [PATCH 2/3] target/riscv: Add dummy mcountinhibit CSR for priv spec v1.11 or higher Date: Fri, 29 Apr 2022 21:04:30 +0530 Message-Id: <20220429153431.308829-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220429153431.308829-1-apatel@ventanamicro.com> References: <20220429153431.308829-1-apatel@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=apatel@ventanamicro.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Atish Patra Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The mcountinhibit CSR is mandatory for priv spec v1.11 or higher. For implementation that don't want to implement can simply have a dummy mcountinhibit which always zero. Fixes: a4b2fa433125 ("target/riscv: Introduce privilege version field in the CSR ops.") Signed-off-by: Anup Patel Reviewed-by: Frank Chang Reviewed-by: Alistair Francis --- target/riscv/cpu_bits.h | 3 +++ target/riscv/csr.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 4d04b20d06..4a55c6a709 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -159,6 +159,9 @@ #define CSR_MTVEC 0x305 #define CSR_MCOUNTEREN 0x306 +/* Machine Counter Setup */ +#define CSR_MCOUNTINHIBIT 0x320 + /* 32-bit only */ #define CSR_MSTATUSH 0x310 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 2bf0a97196..e144ce7135 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -3391,6 +3391,8 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_MIE] = { "mie", any, NULL, NULL, rmw_mie }, [CSR_MTVEC] = { "mtvec", any, read_mtvec, write_mtvec }, [CSR_MCOUNTEREN] = { "mcounteren", any, read_mcounteren, write_mcounteren }, + [CSR_MCOUNTINHIBIT] = { "mcountinhibit", any, read_zero, write_ignore, + .min_priv_ver = PRIV_VERSION_1_11_0 }, [CSR_MSTATUSH] = { "mstatush", any32, read_mstatush, write_mstatush }, From patchwork Fri Apr 29 15:34:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12832392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6BB22C433F5 for ; Fri, 29 Apr 2022 15:48:03 +0000 (UTC) Received: from localhost ([::1]:56618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nkSqg-0006OD-CY for qemu-devel@archiver.kernel.org; Fri, 29 Apr 2022 11:48:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nkSeK-0005OI-6L for qemu-devel@nongnu.org; Fri, 29 Apr 2022 11:35:16 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:37719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nkSeG-000840-Rg for qemu-devel@nongnu.org; Fri, 29 Apr 2022 11:35:14 -0400 Received: by mail-pg1-x535.google.com with SMTP id 15so6807130pgf.4 for ; Fri, 29 Apr 2022 08:35:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9Hx4b71G5E1NzAMSl39dnt/1YXU7Pnr/C1/Pv/rP0Xg=; b=cojMKx7lyDigbLsFvTrMJ4/Gs+1WihzitlmBHEKX2P1RjzwFio2kCJIG6PaHA4IMzO b1h51/4zAT5GbAU/H2J6AqKz7sbrK81uhTscPeNtmylxlKefdX8I5zxDJ7yadiuyx7rv MfJbrWI0G/nDpYrzGhbHQ8vk9Q8Qrz1K0mLou6AnLOm1ukIdfxLgP9kRwNW9ahGsBJus u9p8/hoOp+PsM0Ic5dX9Okh68mxbLRPYip8nfjhKPBFbJMvnDg6PVMhZqCtBmqsvGLWS 5Js2ux07SCB1Gml9o6gFvhjJzUUhmsB1iSq+NeLeCjtXlu5T5rwTmYnJf9AxwmngTBQc 4qmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9Hx4b71G5E1NzAMSl39dnt/1YXU7Pnr/C1/Pv/rP0Xg=; b=VyDyJFAsC6nP+d8eMARw38YgFRA/8MeLpQYMOWJOpPhI3j1KErSKUPXaFyC61caA0u SHo5G47Q7jcf00HhoR8fThT5/hVXvZnewNc3iBQVbVQwrEW0BWqcvSRAP54jZd+91gFW Sd3BhymE0mTwy6fMRC5RyJdfYFDxtfFEg5H2ZjgqO8fM8zf+6TLXHuafoceYT4Ys5AP2 QSbJAQkGpFO90H8PoqerbykHTW52xFj2K7bwYL7uJb8NsmzUL+sL5td/u5VBMjAbJVz2 SAlGLsgrikBBY2IKUkkClbcVYbPEAnnQwkfalBRx/jrs5Af9iPpUzeE1MVKnKrfBAX5t 6bBg== X-Gm-Message-State: AOAM530r3L92ALaqp3yGHxQj/MspXNOkrGNrB+xDk6yVuvqIqaJKbtNM E4nNWqkbnpfhOefTp9HmP+B23g== X-Google-Smtp-Source: ABdhPJy5gHFDDVsbDg/fOnupLRzHLL+LLkNQKrXSdYqrhl3NIeTYSw10llqcrHr7HUf6+CTmoDZ/jQ== X-Received: by 2002:a63:e802:0:b0:39e:5503:e800 with SMTP id s2-20020a63e802000000b0039e5503e800mr31726787pgh.45.1651246510227; Fri, 29 Apr 2022 08:35:10 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([122.167.97.237]) by smtp.gmail.com with ESMTPSA id t13-20020a65608d000000b003c14af50606sm6439380pgu.30.2022.04.29.08.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 08:35:09 -0700 (PDT) From: Anup Patel To: Peter Maydell , Palmer Dabbelt , Alistair Francis , Sagar Karandikar Subject: [PATCH 3/3] target/riscv: Consider priv spec version when generating ISA string Date: Fri, 29 Apr 2022 21:04:31 +0530 Message-Id: <20220429153431.308829-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220429153431.308829-1-apatel@ventanamicro.com> References: <20220429153431.308829-1-apatel@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=apatel@ventanamicro.com; helo=mail-pg1-x535.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Atish Patra Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Most of the multi-letter extensions (such as Svpbmt, Svnapot, Svinval, etc) are only available after Priv spec v1.12 so ISA string generation should check the minimum required priv spec version for all extensions. Fixes: a775398be2e ("target/riscv: Add isa extenstion strings to the device tree") Signed-off-by: Anup Patel Reviewed-by: Frank Chang --- target/riscv/cpu.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 02ee7d45d8..d8c88b96bc 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -44,6 +44,7 @@ static const char riscv_single_letter_exts[] = "IEMAFDQCPVH"; struct isa_ext_data { const char *name; bool enabled; + uint32_t min_priv_ver; }; const char * const riscv_int_regnames[] = { @@ -974,7 +975,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) device_class_set_props(dc, riscv_cpu_properties); } -#define ISA_EDATA_ENTRY(name, prop) {#name, cpu->cfg.prop} +#define ISA_EDATA_ENTRY(name, prop, priv) {#name, cpu->cfg.prop, priv} static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str, int max_str_len) { @@ -1000,25 +1001,26 @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str, int max_str_len) * extensions by an underscore. */ struct isa_ext_data isa_edata_arr[] = { - ISA_EDATA_ENTRY(zfh, ext_zfh), - ISA_EDATA_ENTRY(zfhmin, ext_zfhmin), - ISA_EDATA_ENTRY(zfinx, ext_zfinx), - ISA_EDATA_ENTRY(zhinx, ext_zhinx), - ISA_EDATA_ENTRY(zhinxmin, ext_zhinxmin), - ISA_EDATA_ENTRY(zdinx, ext_zdinx), - ISA_EDATA_ENTRY(zba, ext_zba), - ISA_EDATA_ENTRY(zbb, ext_zbb), - ISA_EDATA_ENTRY(zbc, ext_zbc), - ISA_EDATA_ENTRY(zbs, ext_zbs), - ISA_EDATA_ENTRY(zve32f, ext_zve32f), - ISA_EDATA_ENTRY(zve64f, ext_zve64f), - ISA_EDATA_ENTRY(svinval, ext_svinval), - ISA_EDATA_ENTRY(svnapot, ext_svnapot), - ISA_EDATA_ENTRY(svpbmt, ext_svpbmt), + ISA_EDATA_ENTRY(zfh, ext_zfh, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(zfhmin, ext_zfhmin, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(zfinx, ext_zfinx, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(zhinx, ext_zhinx, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(zhinxmin, ext_zhinxmin, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(zdinx, ext_zdinx, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(zba, ext_zba, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(zbb, ext_zbb, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(zbc, ext_zbc, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(zbs, ext_zbs, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(zve32f, ext_zve32f, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(zve64f, ext_zve64f, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(svinval, ext_svinval, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(svnapot, ext_svnapot, PRIV_VERSION_1_12_0), + ISA_EDATA_ENTRY(svpbmt, ext_svpbmt, PRIV_VERSION_1_12_0), }; for (i = 0; i < ARRAY_SIZE(isa_edata_arr); i++) { - if (isa_edata_arr[i].enabled) { + if (isa_edata_arr[i].enabled && + cpu->env.priv_ver >= isa_edata_arr[i].min_priv_ver) { new = g_strconcat(old, "_", isa_edata_arr[i].name, NULL); g_free(old); old = new;