From nobody Sat May 18 09:01:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676487554; cv=none; d=zohomail.com; s=zohoarc; b=f9O6jbbGTc/wHSvyj9u6IEn7n+rB+udBaUrO366thj8ak94jIrtxDjOJjOSCvaKEY6mS14cJdkmUXepFJUUjRU8SVH6I+V4Z0Nln9R9vieZu2KZTYBexzRCghBQQm8/w8JtKUjdGUMHoUXloaLcKANp4XANTO+BZ7GX9MPKto3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676487554; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=x3Rpse8tpnuic4jsmgudmXGGcOHYXYnwKwheV2Dzwek=; b=HLo1BzOXczaSKsHNzJ32vmavj3s0jo4UJavLCaTr06scdXgihKMdGFwo7BUJnbAeFbNsWf3PwzQMv9IaC7HGQ8I8iRALSykBko0O3QU/xu+9kcKZFF4BumfrrpF/OJar/sLOn1uKs545H5Alxr5C0hss93ruV8PST71n6pJMSlA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676487554750718.8212335596165; Wed, 15 Feb 2023 10:59:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyT-0007tN-RX; Wed, 15 Feb 2023 13:57:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyH-0007bS-RT for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:37 -0500 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyG-0007vU-E6 for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:37 -0500 Received: by mail-oi1-x22a.google.com with SMTP id w11so1979542oiv.5 for ; Wed, 15 Feb 2023 10:57:36 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x3Rpse8tpnuic4jsmgudmXGGcOHYXYnwKwheV2Dzwek=; b=FcoLlVlO2EyTVFlPSJqjZ4uF/aqJZRiq7eIFQ6gK7iKD5x1HT7jRGYguk77LDnNsJ+ QN94ingGm1iDIa9pSC9tCw2unv+oPKUBWkIAx4weF9Q3UU8rIs9uiiR31B/+CllrBotS m+ab4WYTbb9joq7ABM44HNourW2pcASUGv7U9Hl6vUzxpJ1OwA0MOWF7U2t4hg8Pd1t7 dJX8mnqjUgzduAfIx/Hd4kfHq3dzHSb7FvnV7wh1cMcAyZVl6dK4F1eiAOdtfIJh/Rdv ezCGk/z6MgXHJwCTnZUIDeii+h9Mu0ZHUhvILTyi7aUIWoKTwhoLQDgRjFz3gDjQ5u7e +8kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x3Rpse8tpnuic4jsmgudmXGGcOHYXYnwKwheV2Dzwek=; b=XjrrpJyhbnyumA+N07dOJ57AooP2A3l+8Jm8rk2B0luj2H5GptDZZAcdesV4Q+Gwqp 3hgjqSwCuZuMPO4JNt8WygEga/noKugujBTv+wYor/fQLTrz8NUhN44+IkEq/MSg1MX+ 6hwWcP+THMTMiSkVJ2p+iymHdmYyGLnxEq3w5hmm4tW5iIYkqdc8lT+qdxVFpaXw/CSY Fuadq/qLHKE+okye2rPKmfADNcZZxVznrOzoUFizNnB13hNPnXvlCbmyrF3C8g2Ekmr9 u77L1JRl1hJ84/Vp+nq0BdkuWaH7ol6qImmWY2s4KO1T55Cdq8k3T1fEbK4nk6mWL6hv m8Fg== X-Gm-Message-State: AO0yUKW+/RdSLHLetODqBBqi+DR1ETsNBZhoO2fkKa1dHlRKytj2Cix4 7cbhB3ngFxU14LxNI+STGh8ozwgahx+9/kA1 X-Google-Smtp-Source: AK7set/DvhK0t/FJCTsjEpczCv54R/ierhNHtg9X91RNyi9WPCrnabmpaUfLgHbdbCkMhWsUfNMyvA== X-Received: by 2002:a05:6808:147:b0:36f:883:6f76 with SMTP id h7-20020a056808014700b0036f08836f76mr1248238oie.7.1676487455043; Wed, 15 Feb 2023 10:57:35 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 01/10] target/riscv: do not mask unsupported QEMU extensions in write_misa() Date: Wed, 15 Feb 2023 15:57:17 -0300 Message-Id: <20230215185726.691759-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22a.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 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676487555807100004 Content-Type: text/plain; charset="utf-8" The masking done using env->misa_ext_mask already filters any extension that QEMU doesn't support. If the hart supports the extension then QEMU supports it as well. If the masking done by env->misa_ext_mask is somehow letting unsupported QEMU extensions pass by, misa_ext_mask itself needs to be fixed instead. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/csr.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 1b0a0c1693..e149b453da 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1356,9 +1356,6 @@ static RISCVException write_misa(CPURISCVState *env, = int csrno, /* Mask extensions that are not supported by this hart */ val &=3D env->misa_ext_mask; =20 - /* Mask extensions that are not supported by QEMU */ - val &=3D (RVI | RVE | RVM | RVA | RVF | RVD | RVC | RVS | RVU | RVV); - /* 'D' depends on 'F', so clear 'D' if 'F' is not present */ if ((val & RVD) && !(val & RVF)) { val &=3D ~RVD; --=20 2.39.1 From nobody Sat May 18 09:01:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676487491; cv=none; d=zohomail.com; s=zohoarc; b=Zhx7OQXL3FPT26ItSQk8LRESOSoEi7OLYg3RDuOgEryy5eGmT1uzZJZ4QggeUydgxMVIaWxYLwNOVLSigkPPIr6HaggT/YlgE0yY5XKEVOMblkP8Qwbxm9InvLp6vYPYDauxNblteqFYtmu/QIlzv7nKmiL/O2Ba4VA0dADzjIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676487491; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8Ogl+RmsTuQKGbHwWL7YbtcFc2a1h5NOUKob+9lW4sA=; b=k5gL2RdbISWDa7+6sLbF/TkzXVQgxMVqEYqbb/qA5Zuemra/N/B0ku/zRtl32fJ9wTniDky/V20mRcktvNgb3j/gjl12nm8F/6x7PdJI4lamd8I7hER+Q9/YkBg6EqtGbSEtpVaXWmusb4tVnQzDMDfH+32I/3w2wH3nQMcYfQ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676487491029190.59580194647071; Wed, 15 Feb 2023 10:58:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMya-00081r-PI; Wed, 15 Feb 2023 13:57:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyN-0007i5-JA for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:43 -0500 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyI-0007vG-SW for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:41 -0500 Received: by mail-oi1-x236.google.com with SMTP id bd6so16640945oib.6 for ; Wed, 15 Feb 2023 10:57:38 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8Ogl+RmsTuQKGbHwWL7YbtcFc2a1h5NOUKob+9lW4sA=; b=jQ07UfJNwJQi5B+O+HiP6ewYT/fSCOu79nfT3G8yaztn3ZQWBBo72psVIMPZQISBW0 TLewFyR5NiXFi4ACeXfqxGNqRZgj0yQ3ErzqGjNxXezBY2Q6UTku/pSVE6ThqeuSqF4J +zRAHjf85fUQeBijEINdOlD1XqUJrOVQmbfHOHHgMif+TgTHagSlmMRPY3LOXjcLkMzr s6MLWDEb9WKs3EVW8kOmkF6ZWdR7JVrKTYRE6XxtOLK74Za9q3o9rrO7XmhVMDnT8j2L wXA6Bkgl5FvhAiTtEBdon8HdNeKskg5/KWQtLyOMWXb/eMW2yBR5k7AzB2bAAGaApEWf GgOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8Ogl+RmsTuQKGbHwWL7YbtcFc2a1h5NOUKob+9lW4sA=; b=fEdPJbvdC79Bius5Rmc6V+1pzrR8+lPIndqZOR+CjvaMFze0uGc2jyXZMDAuxPC18e nPD+cHCmNAAaF5byrSAJCYaaONceXBCS0PCdqXGfHcZAb2bhCCU6sEgdik4iWhedZeya tnXuNWp3HUlT9k6CfT2oSfPXzWZnawEbpUc3IYI4WKy4qF7M+iBwVBe00QtEyxcUWn5w An/Q1ojdYWKPxPjygt8IxNYRWN4UwKsqu/RfRyI9figbcWAJ8ttI1USizu/NrQ+Rt7ii Q9yZlm1EZ1y7FEWCAYCJiHPmRcLC76QMC44zClLGOWK1BMTWP9h0cHgpEBmdlRQallW4 NDkw== X-Gm-Message-State: AO0yUKWSTC+oYrlFmE/NzjX8TuCtAnSPsmxPKilQErM1yCSoLYutTfTY ymr00IV2urqaeUyJ8Hz+5n12rvahb83r4HPf X-Google-Smtp-Source: AK7set+tLP3B9PXez80z08GAQtqgo6BLcJHzVLBiJh7tHb+2otHPNI2wQuuZH6ufYEDAAsAkDsFMMA== X-Received: by 2002:a05:6808:1185:b0:37a:2bf0:502a with SMTP id j5-20020a056808118500b0037a2bf0502amr2615611oil.24.1676487457908; Wed, 15 Feb 2023 10:57:37 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza Subject: [PATCH v3 02/10] target/riscv: always allow write_misa() to write MISA Date: Wed, 15 Feb 2023 15:57:18 -0300 Message-Id: <20230215185726.691759-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x236.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 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676487493390100001 Content-Type: text/plain; charset="utf-8" At this moment, and apparently since ever, we have no way of enabling RISCV_FEATURE_MISA. This means that all the code from write_misa(), all the nuts and bolts that handles how to properly write this CSR, has always been a no-op as well because write_misa() will always exit earlier. This seems to be benign in the majority of cases. Booting an Ubuntu 'virt' guest and logging all the calls to 'write_misa' shows that no writes to MISA CSR was attempted. Writing MISA, i.e. enabling/disabling RISC-V extensions after the machine is powered on, seems to be a niche use. Regardless, the spec says that MISA is a WARL read-write CSR, and gating the writes in the register doesn't make sense. OS and applications should be wary of the consequences when writing it, but the write itself must always be allowed. Remove the RISCV_FEATURE_MISA verification at the start of write_misa(), removing RISCV_FEATURE_MISA altogether since there will be no more callers of this enum. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Bin Meng --- target/riscv/cpu.h | 1 - target/riscv/csr.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7128438d8e..01803a020d 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -89,7 +89,6 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, RISCV_FEATURE_EPMP, - RISCV_FEATURE_MISA, RISCV_FEATURE_DEBUG }; =20 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index e149b453da..5bd4cdbef5 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1329,11 +1329,6 @@ static RISCVException read_misa(CPURISCVState *env, = int csrno, static RISCVException write_misa(CPURISCVState *env, int csrno, target_ulong val) { - if (!riscv_feature(env, RISCV_FEATURE_MISA)) { - /* drop write to misa */ - return RISCV_EXCP_NONE; - } - /* 'I' or 'E' must be present */ if (!(val & (RVI | RVE))) { /* It is not, drop write to misa */ --=20 2.39.1 From nobody Sat May 18 09:01:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676487534; cv=none; d=zohomail.com; s=zohoarc; b=ksZsFLyt0iAnlIBoYCcQ3MhxNUpBgbx/laTpT5d+cTEBeROlDPfo/w7HmsINm2TzJssmoiyZN7XIc51o+dwguIfsFkjS/tv2YvFALds6eeWwaSDUxkKb78WDSe17e+JWOJ9vsvPlKuHajaOGAlgtva5Q1LQB12CcPFgWURkYq4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676487534; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/ze670EFc4knKxHYmBNv1C1tJqYk4J5P+dEI+i7TEM8=; b=kpAX8mnYoyRYpUIGXlXIaaOIVHjKKGVrDA4W4PKRxKhU6S5U/ZvApwXpDNBAJXoAYcWeNiXvCqLb239a2SozMQmHk5wlCI4l5PvzlgajzxdF95+ssslzR70ZjPS9/VB715VbI+pg93x9juYTzOqSfq2H7tLAkJZVNkGCOL+8dO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676487534708807.7549928363482; Wed, 15 Feb 2023 10:58:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyV-0007vG-HQ; Wed, 15 Feb 2023 13:57:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyP-0007qE-MI for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:46 -0500 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyN-0007vQ-Cn for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:45 -0500 Received: by mail-oi1-x22a.google.com with SMTP id cz14so16639408oib.12 for ; Wed, 15 Feb 2023 10:57:41 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/ze670EFc4knKxHYmBNv1C1tJqYk4J5P+dEI+i7TEM8=; b=a8ZrW13ClEJW9k3sGdoDd/f+UNGHaZrkEemRiReeQDDQnD+qn3rTtfBR8+KQItUhcy 6OMhONJdDJE+CRjYKHGcm2mwKVqXEu+Ex0IkbZlulc0ZBHj+RPZ+cNVaQk1K3rI+l/1J SvQWJk5WoPQvWeJSWmRNFyFN0p6sikJio/z4co/dxlDU0xXG9XDJ6fVXxyHo4+qTrYTN JiKCb28ynJeC4dJqLsVmzhI92GEUww1Umbe2Bn3t6r83RqV3ggQF0pZtw4hDEKUzT5kH Po624CfWPD+B239xrSAY5j+f3ua+PvVn2gXa3qIY2Ncvo7nJ3CXlEFDGdusQizFgPArm 1N5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ze670EFc4knKxHYmBNv1C1tJqYk4J5P+dEI+i7TEM8=; b=fimMn10m2BUQLwBH4zDSqZjTx5PJiyfiXCXnGx+T+CoJVX6egX37DXG059OqEuWQhm +9YgT/Q/WdSMZu23Bj2iqLbU7/bqAoYbvb6fXkcRs+SAUn7nWc7jADtaChaPWmfwDjyI KaFs9BAtSkPACGSELcZV64W+WhExbAjYLlNGjZ+pBuPPKbkoLr8s9z1pzMyiTafUWohr S/78kxaiSxmVWcHaUHoacS0Bq6D0eVTuXXvOKHjV5yLHRYE8J5ZITNdFCvvCuzlVRK62 sWth09ijEX2Y132U775SuIvbDd1BbNAS7pPGoMswaqkIzNZc8ualpNZZfBwfjXW9YZ33 CCNg== X-Gm-Message-State: AO0yUKWW249jLBP8Gl3HoHJ421GsIQ8n2lJXWzlxpNtITK7RgUJe/OuZ rxJbCzcAMKqRkQa5nOF6ZkwE7n6V1O7PNn6U X-Google-Smtp-Source: AK7set9uUatECYM/r7dub4NSKg4e1kFYuWBBnWLAba6RQt5b7r7VozhT9T0eA3wEUMkwWkRwpaYsyA== X-Received: by 2002:a05:6808:9ad:b0:37a:d54f:8c7a with SMTP id e13-20020a05680809ad00b0037ad54f8c7amr1191017oig.59.1676487461024; Wed, 15 Feb 2023 10:57:41 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 03/10] target/riscv: introduce riscv_cpu_cfg() Date: Wed, 15 Feb 2023 15:57:19 -0300 Message-Id: <20230215185726.691759-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22a.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 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676487537624100007 Content-Type: text/plain; charset="utf-8" We're going to do changes that requires accessing the RISCVCPUConfig struct from the RISCVCPU, having access only to a CPURISCVState 'env' pointer. Add a helper to make the code easier to read. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 01803a020d..368a522b5b 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -653,6 +653,11 @@ static inline RISCVMXL riscv_cpu_mxl(CPURISCVState *en= v) #endif #define riscv_cpu_mxl_bits(env) (1UL << (4 + riscv_cpu_mxl(env))) =20 +static inline RISCVCPUConfig riscv_cpu_cfg(CPURISCVState *env) +{ + return env_archcpu(env)->cfg; +} + #if defined(TARGET_RISCV32) #define cpu_recompute_xl(env) ((void)(env), MXL_RV32) #else --=20 2.39.1 From nobody Sat May 18 09:01:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676487544; cv=none; d=zohomail.com; s=zohoarc; b=Ny8q5a7Y16O1HkVVCMq/CufiGTRzU6VooRXoe3KdOmO9ust1EAtx5KmIFssR5DQ0bwEbm/sZ1nkS9AQEsaqaF3LMfCScQPi0L9P/+hQOTTIMFF4wX245LDLsWJs7iBfBCHHgvYgPP4/2nJz8vlpQukMfopwqkBaegm5LJikMqpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676487544; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ztd1b1aEAN7YodigTUG6Ro/lcZCclFr+SzJZ6tToCaI=; b=bWe8b1cgtaSjTn+F1CyC4adp9hdXrKlx0/zkBhjLTclV+90R6tzYx6A77tN5F1+Nc90oNKUDSsT4h2odGMcGnlNCwYYcMfIV6umZzd2o4cJ2+TegJbjvXlonu/oz+ICQivYeCpZUbQgifilEHXHb/MkGbL1fYPfOov6166PnYfQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676487544747397.27055326414256; Wed, 15 Feb 2023 10:59:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyj-0008S8-Hd; Wed, 15 Feb 2023 13:58:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyR-0007sm-F0 for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:49 -0500 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyP-0007wk-BF for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:46 -0500 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-16a7f5b6882so24090790fac.10 for ; Wed, 15 Feb 2023 10:57:44 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ztd1b1aEAN7YodigTUG6Ro/lcZCclFr+SzJZ6tToCaI=; b=Pu55rwRByNtTYPjjpdQkaIgwolVW2n2+TwhxLZwIi30skV0hSLHPaWhBhd/fWCRCnp 6stZ4sv2rLzNLFFjqVDZriFbas+ABj0JiBM383JxAs1GDYc5/72L+KNmSOSw/QiEyJWT 34/UWEGnXY+OuIMhzHbxP0Bc4waNqn889QmeqE79Xsf05EQkHsJ+PgO7XNa0aLtQnz0k 2i9J5TLfoN6qBRVd8noUlTJu32QmHulNHIQ6cDcatICYuRRZ4+TVD4v5mpdMV/EYl/+I dvLia8sOjI/mvTB96/9OjvEXxlnoqDBpMD8ZQznTQ6uEDpH/Z3LTGupRRv5AhN0L7SY4 GRGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ztd1b1aEAN7YodigTUG6Ro/lcZCclFr+SzJZ6tToCaI=; b=LxJRnMB08xJ4ktMWg1/senSXaJQ15ZnWo7fjLssM3XXv6WUB0iKFI5Lp3yz1QGyCec qP5N18M38sDNE+RFc6UU2QvqnvazFiPEPiWWghrtTEOyErfoS4TxDJ3A9Xm1f7zTKkPC zCJNxQlkJVr7CwiIBs8ooyUyQ18dGA1BBisIIkGIEBlZcZVdWKMvj/wiz/eWC1P7mfoc +nGE3RSTQDEem8JgewvBXFkbFk5w4eEI4P6kPMbiGC8ilNVkA0N6bXIi3TB0oy8JD72U J3gsoQ+tCk2nRb7IxNQ+ZarM6/JtNdn1AcGxEJZopJf4f7TGeYrH7RG27Ixllwj2ScO3 2hZA== X-Gm-Message-State: AO0yUKU6SiZW1s3RlU794/TSIa7czOlZgafzJn4HBrv8zq76YLB3NHBc W113r40cWx60ahZeXNiBC6wZwdwYP0yINC68 X-Google-Smtp-Source: AK7set8zVcpyQ9jSKXFsng+Jx/9trVpoLF0GOK2Fc3P6Xd0zhwde4ZgR38SZu1dSs/VtCm0e3+QAWA== X-Received: by 2002:a05:6870:fb8b:b0:16e:c7d:c657 with SMTP id kv11-20020a056870fb8b00b0016e0c7dc657mr1859450oab.49.1676487463817; Wed, 15 Feb 2023 10:57:43 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 04/10] target/riscv: remove RISCV_FEATURE_DEBUG Date: Wed, 15 Feb 2023 15:57:20 -0300 Message-Id: <20230215185726.691759-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::31; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x31.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 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676487545791100005 Content-Type: text/plain; charset="utf-8" RISCV_FEATURE_DEBUG will always follow the value defined by cpu->cfg.debug flag. Read the flag instead. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 6 +----- target/riscv/cpu.h | 1 - target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 2 +- target/riscv/machine.c | 3 +-- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 93b52b826c..e34a5e3f11 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -637,7 +637,7 @@ static void riscv_cpu_reset_hold(Object *obj) set_default_nan_mode(1, &env->fp_status); =20 #ifndef CONFIG_USER_ONLY - if (riscv_feature(env, RISCV_FEATURE_DEBUG)) { + if (cpu->cfg.debug) { riscv_trigger_init(env); } =20 @@ -935,10 +935,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error = **errp) } } =20 - if (cpu->cfg.debug) { - riscv_set_feature(env, RISCV_FEATURE_DEBUG); - } - =20 #ifndef CONFIG_USER_ONLY if (cpu->cfg.ext_sstc) { diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 368a522b5b..7326aaed27 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -89,7 +89,6 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, RISCV_FEATURE_EPMP, - RISCV_FEATURE_DEBUG }; =20 /* Privileged specification version */ diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index ad8d82662c..4cdd247c6c 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -105,7 +105,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ul= ong *pc, flags =3D FIELD_DP32(flags, TB_FLAGS, MSTATUS_HS_VS, get_field(env->mstatus_hs, MSTATUS_VS)); } - if (riscv_feature(env, RISCV_FEATURE_DEBUG) && !icount_enabled()) { + if (cpu->cfg.debug && !icount_enabled()) { flags =3D FIELD_DP32(flags, TB_FLAGS, ITRIGGER, env->itrigger_enab= led); } #endif diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 5bd4cdbef5..287792d6d6 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -437,7 +437,7 @@ static RISCVException epmp(CPURISCVState *env, int csrn= o) =20 static RISCVException debug(CPURISCVState *env, int csrno) { - if (riscv_feature(env, RISCV_FEATURE_DEBUG)) { + if (riscv_cpu_cfg(env).debug) { return RISCV_EXCP_NONE; } =20 diff --git a/target/riscv/machine.c b/target/riscv/machine.c index c6ce318cce..4634968898 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -226,9 +226,8 @@ static const VMStateDescription vmstate_kvmtimer =3D { static bool debug_needed(void *opaque) { RISCVCPU *cpu =3D opaque; - CPURISCVState *env =3D &cpu->env; =20 - return riscv_feature(env, RISCV_FEATURE_DEBUG); + return cpu->cfg.debug; } =20 static int debug_post_load(void *opaque, int version_id) --=20 2.39.1 From nobody Sat May 18 09:01:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676487578; cv=none; d=zohomail.com; s=zohoarc; b=YVvMW51bc+F2hjEc8YXce31PWxvXMcCEvUSgLlQaSqK8bdDJFXb6yMthVrv573DrcrJrqy4Vjy2Vuv58T58hsF6N+GpX1kVGjbzjim9sjsqkrHhaITIZCUGm7S/YubN0vuMZlUn8rE1llvqACTn+72hf9nAkQBYbOUlJ3Gm8hRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676487578; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bzgUQCLPgU6X7MZ2uleR0+KefuKd7NhosDsVObTIs/M=; b=BfC7PG6+qCBRYIu4Xo5BmxikYiuNXvb8SzueSfzzBmdaaMWIZ5sn7WkY7OHLp/QB1uNpyVkRZ4rQqaArSugn5tn8ujp5guABU96qQCy8QLhwJcq+506S7EcXa5U/bYnE0VlfSEM4ZEeYRxsbQMrEU3telcgVBzElvoQK7nMQUyA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676487577849539.1488654092254; Wed, 15 Feb 2023 10:59:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyi-0008NL-Ke; Wed, 15 Feb 2023 13:58:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyT-0007vA-VY for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:51 -0500 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyS-0007xM-7b for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:49 -0500 Received: by mail-oi1-x22b.google.com with SMTP id n132so16650239oih.7 for ; Wed, 15 Feb 2023 10:57:47 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bzgUQCLPgU6X7MZ2uleR0+KefuKd7NhosDsVObTIs/M=; b=LOO3Aw+4O/x4DDMndxOcWWbRp+PaoLPv9slPF7t6+iQ3HYFjC9ad0ipGLJzz9o7DzI NYIq7tBkjRVqRkTD/lZxULrVSot58/sRPIJQaup876poUjwc4K24bI9YYH4ZCCRNVWhE 9iZEw/gBuQTtYlPLvvjVUmQ4VSJjEIp/2c4azh2Cb/SkwP1qTplfYw7Li6BBbZv2AH6H VZ7q0o6MnwY8+xwUO/0J2PeAbAs6B3UbZQQRRUHln2YLQ0QYGVlJqZrS+RLyy4nKFNoh ge03NXCcA2fLqsraQK3Fy960fTrI9bZVB9ObCYp9vLRhD4M6WBMR7mC0SgcWGmWgiMry BsFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bzgUQCLPgU6X7MZ2uleR0+KefuKd7NhosDsVObTIs/M=; b=KCiFEntwWQjDyKeLvIxw3rTq9HIh7v4zd4ythbMLjSwEZ/FzgcIIgknzmPzNVajcx9 JQ/mnpuQ1Bh90BpQqaKINYZdhN8HWs3wXnRRRk4lqQxgITwIpI1psHxT/C1msdT1S/Tx wFwuuKPx3bTGrwZcNj6a6GD9PS1NPN6Dn6iJJKxMrXaB8Kprk94UtJpljecaUV3QarRn l9AAuvMeIHxjl9wyPxXjAgtBuNzGmv2T0umD6E920FlSqi7ZllH/KbWnLqCh6ba/MhIi Sz2U9HLK25x2zfvgDOSj5FVEMc96ZiKmsBydK/Jgf1aQGt55YDZPmuISRmmue9CH7U0+ ME3w== X-Gm-Message-State: AO0yUKXTjlGNBx68SNc1Ydv87Q4IbSAdrLiwETG0itKTYfWqBbEjcYmR EvsTAFUmcfQ5r8BCpA4xnWZR0OtxHRTP7wxs X-Google-Smtp-Source: AK7set8HGPd+7pnj0afCL9oguEdGct0htrfsgxK4oQR4JM1/M/hRjhjBkBcsMGjOsJiqnEo7GZM8gA== X-Received: by 2002:a05:6808:ab1:b0:364:5d1d:5528 with SMTP id r17-20020a0568080ab100b003645d1d5528mr1299692oij.1.1676487466739; Wed, 15 Feb 2023 10:57:46 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 05/10] target/riscv/cpu.c: error out if EPMP is enabled without PMP Date: Wed, 15 Feb 2023 15:57:21 -0300 Message-Id: <20230215185726.691759-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::22b; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22b.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 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676487580032100003 Content-Type: text/plain; charset="utf-8" Instead of silently ignoring the EPMP setting if there is no PMP available, error out informing the user that EPMP depends on PMP support: $ ./qemu-system-riscv64 -cpu rv64,pmp=3Dfalse,x-epmp=3Dtrue qemu-system-riscv64: Invalid configuration: EPMP requires PMP support This will force users to pick saner options in the QEMU command line. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index e34a5e3f11..4585ca74dc 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -925,13 +925,18 @@ static void riscv_cpu_realize(DeviceState *dev, Error= **errp) =20 if (cpu->cfg.pmp) { riscv_set_feature(env, RISCV_FEATURE_PMP); + } + + if (cpu->cfg.epmp) { + riscv_set_feature(env, RISCV_FEATURE_EPMP); =20 /* * Enhanced PMP should only be available * on harts with PMP support */ - if (cpu->cfg.epmp) { - riscv_set_feature(env, RISCV_FEATURE_EPMP); + if (!cpu->cfg.pmp) { + error_setg(errp, "Invalid configuration: EPMP requires PMP sup= port"); + return; } } =20 --=20 2.39.1 From nobody Sat May 18 09:01:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676487517; cv=none; d=zohomail.com; s=zohoarc; b=WIcUMPY02pNAzQgS+BrpxLftsEwtZ2itXTql00EiL94iKYJd6lkPZkpGFDEsP1Qk2X7XEgLcNj8VAdKO1BxqSVMCCCNabZ1kmKpmRkBstpEfcUOven1X7CRDqLkWrWOtn5F6wqVcv/KzjaqUGJIKLIDmxQW9q4H9mk6f2QAr0eE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676487517; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wGItmEUvt/2Qmm35pUKwvQ8V0KNI6gfDmMeF+0diUQs=; b=iH17TYg5IR7kt1GbdTtoxjN05RRfx+JdiXtxN+rfjFJ4TzLUm/sZc5SBV2ZTXoWBH3HEsEh4+fpIzbg92iJQe8WTKUSaW8dALx0JRzL75UIHATZ9kvFYQww9C84s9qTHmRSLPle1i4AGz49c8/F55M5u0NAxqPgvdrJhr8FZQ0A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676487517683552.5677315447637; Wed, 15 Feb 2023 10:58:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyh-0008H5-Ui; Wed, 15 Feb 2023 13:58:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyX-0007xm-CV for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:53 -0500 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyV-0007vQ-DM for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:52 -0500 Received: by mail-oi1-x22a.google.com with SMTP id cz14so16639831oib.12 for ; Wed, 15 Feb 2023 10:57:50 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wGItmEUvt/2Qmm35pUKwvQ8V0KNI6gfDmMeF+0diUQs=; b=KlZo/jwDeRjULS37T2HMqRjKvfdrlQl4pGFV1xCExfil0Bu28HwWUVLpIIUHusZIbm RM4Ehh+Fbqtqv86E6m/nV8aLJeLrfTpX+F05/aw1AyAAEpxKHuuNxylDjuI2W34aRYq+ z1pimwET5ggfMRaFuyBONMWmodBU5ZL1oKvp6pU64y/HsKPuL8sc05lcMdOflt/MH6fi vBTTV7SbwhDDlZ7TAm1tEpWEkW+axCrwccT1kQkslARmxKWjTwpyZUI1etZ6Vjtucyq8 87C1TPa6sA4EWKwLRMKoF0pg4vL63smGT6BLOz7aKP4lnyo8p6xE6ryPcNZ0Y7T95MBt yXXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wGItmEUvt/2Qmm35pUKwvQ8V0KNI6gfDmMeF+0diUQs=; b=ClGjj7mr2uc/ImFV8JyuLMB2kL4yWocTmhd9YU3ZMWXUCVDZHv2v5UAQ6Y8yAbKCcK SZTvSSZrmuhynfM2+kCfz8zhSZU6cIq0YQlV7g7reSBTE1rbtE3jy5S+e7/kCZ+fCou+ CP92UZq52DdBJmuOm3e6f+HUPLttbFIvTTzxcwFqO46Ug+CdL9NuE/a9KXccMsjd1kYW F4GW+pvJRpPzCaztM3/3ryBXTpXiKzbjz7ghqbOm95CFC0pD4VjLXrND3jY4Yi4qKKEF cnzjuzLnn/uo5vWF6IETmOxErv8u1gMbzEzHayNfSwHtDCGOxjj4PELTQn6sBiLqsuvT WAzQ== X-Gm-Message-State: AO0yUKUzdTVxcxDQIQrbE7gg+m254Z36aWja6wfe93iH6Q1ZA33QDKDB BKjihKIje9Bl7jL2KlP71rOBohV6S2GBf6Ln X-Google-Smtp-Source: AK7set9keYh0vKL+sILODfYwjJ4xVkgqPiRqq1L3hKJAZBQYqUmPT4GDzwmelBEoP37hGBqm+qeqAg== X-Received: by 2002:aca:120f:0:b0:378:89a7:2f4f with SMTP id 15-20020aca120f000000b0037889a72f4fmr1258059ois.3.1676487469638; Wed, 15 Feb 2023 10:57:49 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 06/10] target/riscv: remove RISCV_FEATURE_EPMP Date: Wed, 15 Feb 2023 15:57:22 -0300 Message-Id: <20230215185726.691759-7-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22a.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 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676487519582100003 Content-Type: text/plain; charset="utf-8" RISCV_FEATURE_EPMP is always set to the same value as the cpu->cfg.epmp flag. Use the flag directly. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 10 +++------- target/riscv/cpu.h | 1 - target/riscv/csr.c | 2 +- target/riscv/pmp.c | 4 ++-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 4585ca74dc..71b2042d73 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -927,17 +927,13 @@ static void riscv_cpu_realize(DeviceState *dev, Error= **errp) riscv_set_feature(env, RISCV_FEATURE_PMP); } =20 - if (cpu->cfg.epmp) { - riscv_set_feature(env, RISCV_FEATURE_EPMP); - + if (cpu->cfg.epmp && !cpu->cfg.pmp) { /* * Enhanced PMP should only be available * on harts with PMP support */ - if (!cpu->cfg.pmp) { - error_setg(errp, "Invalid configuration: EPMP requires PMP sup= port"); - return; - } + error_setg(errp, "Invalid configuration: EPMP requires PMP support= "); + return; } =20 =20 diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7326aaed27..c87e50e804 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -88,7 +88,6 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, - RISCV_FEATURE_EPMP, }; =20 /* Privileged specification version */ diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 287792d6d6..6fa6b7e7ed 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -428,7 +428,7 @@ static RISCVException pmp(CPURISCVState *env, int csrno) =20 static RISCVException epmp(CPURISCVState *env, int csrno) { - if (env->priv =3D=3D PRV_M && riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (env->priv =3D=3D PRV_M && riscv_cpu_cfg(env).epmp) { return RISCV_EXCP_NONE; } =20 diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 4bc4113531..bb54899635 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -88,7 +88,7 @@ static void pmp_write_cfg(CPURISCVState *env, uint32_t pm= p_index, uint8_t val) if (pmp_index < MAX_RISCV_PMPS) { bool locked =3D true; =20 - if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (riscv_cpu_cfg(env).epmp) { /* mseccfg.RLB is set */ if (MSECCFG_RLB_ISSET(env)) { locked =3D false; @@ -239,7 +239,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *e= nv, target_ulong addr, { bool ret; =20 - if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (riscv_cpu_cfg(env).epmp) { if (MSECCFG_MMWP_ISSET(env)) { /* * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set --=20 2.39.1 From nobody Sat May 18 09:01:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676487554; cv=none; d=zohomail.com; s=zohoarc; b=c1zN/WEKU9QCvJ99ufauP1InUYyHZiLzQEur2eESvG3iNmA0HIvqYTaVx725lpz9188MMyJYxLawQx0sHk6EKBIhZu4Rj4fa+YnXsSeuSQ2r7+BI4jT5tNrvX/35PBJ8whOYlPZrGZp9dJyfzsTJCaAWhA6LeaXPYqX39GzQ4NI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676487554; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J7fLV3zLmjzcQ9pqfO11dTsPpOFgbHe4zd0GhL8+Yyw=; b=FkOr6c/FZ+syJCJsoH3wlevqnKR/B4C3VhjEi830GuHSYezmh8NDc4FHO5DZ00hUl+hD7mW7Znw08jrfYh5gBn+TuQjSZ6cF1Yo0pc+vLfdPtHjsl/hB3OJrFUqjma2bH/6/AkPTvN2qt+4sAimlLvRiJ4VI01JqUNy2XIRdgfs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676487554147622.317146116133; Wed, 15 Feb 2023 10:59:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyl-0000Dm-1y; Wed, 15 Feb 2023 13:58:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyZ-0007zw-0v for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:55 -0500 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyX-0007vI-DY for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:54 -0500 Received: by mail-oi1-x22f.google.com with SMTP id t5so16652635oiw.1 for ; Wed, 15 Feb 2023 10:57:53 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J7fLV3zLmjzcQ9pqfO11dTsPpOFgbHe4zd0GhL8+Yyw=; b=NXAe8mEi/KRTfdNhWnU5LsUFmO128wORqoqiFFwPfwwqMJDeQQxN0UWvjpmtlHRiHD 5uJmuY7Sb2HzfLlw3YjA9Y+zkINu3CIwtUzEMuvFHNMEl+ow217W1JTr0sb/OZegUa83 jLxOsGfH6y/LzGVPfJfgsY47v8WDN/nGzKLiRhJlXrWVXCLXkAZk0TIeYYyZpNMc78LT wqoUM8eKODDM+2ZnCg73hkZzauvawL59TpnbNaqIb1OLOPzGAsgEVVDmu1pdOKQqevsa enhVo2WJ1rJ0RHMetHdKjpKT+JfAklH8s3XPHoEJcDddG5hCocAi9QeisVUuobxxnwKw H61w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J7fLV3zLmjzcQ9pqfO11dTsPpOFgbHe4zd0GhL8+Yyw=; b=x+qk5UzjZgyiI9pYe86BJcSYYUO2Ybv7wQGMRXPvr9rKz3qIAepRKHXVZwErJn6VPC cG1ijn+0FLsPDVO9j8hiL7WTklNnwXjvuW6rSws260MqDDaudjh/q1KsXhcfusBwhJyt dNHQ/WenwRyWCtpFiFU+GYlE1Lue1ImMtTXld5kQYIwkMRzjmPR/CyDCLu++EzkZ/AmP JgNMJckfoGlLNU7s9wWePRIjqjz0L84GEHwPxa7RxdNaygFHxc1zBiWuUFha1NPn/Her 4pFQQ1bey1oNo6bSlKucOWBxg7buEX7IM0ZAjq6s/uK3Mz3fonfKXpfxzOIuTmoom8Hz i5Ew== X-Gm-Message-State: AO0yUKX2PL2bLyZ41u1PDOkm/U0A+cmh47CMVX///NvoORjhXr/D+0a4 CQVkFbb6Xc4S3HQzeKEZ6LZ6IQHPGxxIaQFA X-Google-Smtp-Source: AK7set88RCHBqm14gR590S9sNi3h/KBh5+UtHsKi5jm+VAP4z0JX94TF0Kk2v6tGdWYvbPU3RajlIA== X-Received: by 2002:a05:6808:7c3:b0:378:9c80:7da0 with SMTP id f3-20020a05680807c300b003789c807da0mr1258892oij.19.1676487472434; Wed, 15 Feb 2023 10:57:52 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 07/10] target/riscv: remove RISCV_FEATURE_PMP Date: Wed, 15 Feb 2023 15:57:23 -0300 Message-Id: <20230215185726.691759-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::22f; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22f.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 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676487555798100003 Content-Type: text/plain; charset="utf-8" RISCV_FEATURE_PMP is being set via riscv_set_feature() by mirroring the cpu->cfg.pmp flag. Use the flag instead. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 4 ---- target/riscv/cpu.h | 1 - target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 2 +- target/riscv/machine.c | 3 +-- target/riscv/op_helper.c | 2 +- target/riscv/pmp.c | 2 +- 7 files changed, 5 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 71b2042d73..7b1360d6ba 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -923,10 +923,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error = **errp) riscv_set_feature(env, RISCV_FEATURE_MMU); } =20 - if (cpu->cfg.pmp) { - riscv_set_feature(env, RISCV_FEATURE_PMP); - } - if (cpu->cfg.epmp && !cpu->cfg.pmp) { /* * Enhanced PMP should only be available diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index c87e50e804..bd7ab5fceb 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -87,7 +87,6 @@ so a cpu features bitfield is required, likewise for optional PMP suppo= rt */ enum { RISCV_FEATURE_MMU, - RISCV_FEATURE_PMP, }; =20 /* Privileged specification version */ diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 4cdd247c6c..15d9542691 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -706,7 +706,7 @@ static int get_physical_address_pmp(CPURISCVState *env,= int *prot, pmp_priv_t pmp_priv; int pmp_index =3D -1; =20 - if (!riscv_feature(env, RISCV_FEATURE_PMP)) { + if (!riscv_cpu_cfg(env).pmp) { *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TRANSLATE_SUCCESS; } diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 6fa6b7e7ed..4011b0d6f8 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -419,7 +419,7 @@ static int aia_hmode32(CPURISCVState *env, int csrno) =20 static RISCVException pmp(CPURISCVState *env, int csrno) { - if (riscv_feature(env, RISCV_FEATURE_PMP)) { + if (riscv_cpu_cfg(env).pmp) { return RISCV_EXCP_NONE; } =20 diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 4634968898..67e9e56853 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -27,9 +27,8 @@ static bool pmp_needed(void *opaque) { RISCVCPU *cpu =3D opaque; - CPURISCVState *env =3D &cpu->env; =20 - return riscv_feature(env, RISCV_FEATURE_PMP); + return cpu->cfg.pmp; } =20 static int pmp_post_load(void *opaque, int version_id) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index 48f918b71b..f34701b443 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -195,7 +195,7 @@ target_ulong helper_mret(CPURISCVState *env) uint64_t mstatus =3D env->mstatus; target_ulong prev_priv =3D get_field(mstatus, MSTATUS_MPP); =20 - if (riscv_feature(env, RISCV_FEATURE_PMP) && + if (riscv_cpu_cfg(env).pmp && !pmp_get_num_rules(env) && (prev_priv !=3D PRV_M)) { riscv_raise_exception(env, RISCV_EXCP_INST_ACCESS_FAULT, GETPC()); } diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index bb54899635..1e7903dffa 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -265,7 +265,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *e= nv, target_ulong addr, } } =20 - if ((!riscv_feature(env, RISCV_FEATURE_PMP)) || (mode =3D=3D PRV_M)) { + if (!riscv_cpu_cfg(env).pmp || (mode =3D=3D PRV_M)) { /* * Privileged spec v1.10 states if HW doesn't implement any PMP en= try * or no PMP entry matches an M-Mode access, the access succeeds. --=20 2.39.1 From nobody Sat May 18 09:01:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676487588; cv=none; d=zohomail.com; s=zohoarc; b=MSKg9Nl2NU6IWRgNfr53W257WD22iqzCgptIOTH8d1pk+Nsh3Plj7WS6I/ja9oinhqckXzWrlUPzyl/o1dHqbDgZOgF2I8ieWE54n2SCgCVrKO7bpuDK83tBwjL+z5LzIhRyJq7vF5A50GEngJP9vEdm1n1qMvGtODqfo7F41nk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676487588; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Rhjy4ZuFr2J/YQsYfjypiNp1FTwn/nVolIeKKoKX5g0=; b=fqBg80h8NyD/tgT31MPvDopcEWJwJWZn15SyTF+K3CraCnv9MM+5+mQysBIJHENxmQf2czXm+n5TDqiszem8lW2RVZMq/7ctK1TER7vkSmniBXMyFLFG8w7wPsVWQPHMb+dl0+hGgFboytbziGpgsSlcJZgjiBhe1eWEf/l51Kw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676487588922543.4966957309296; Wed, 15 Feb 2023 10:59:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMym-0000RG-GA; Wed, 15 Feb 2023 13:58:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyc-00086f-39 for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:58 -0500 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMya-000805-LA for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:57:57 -0500 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-16ab8581837so24014961fac.4 for ; Wed, 15 Feb 2023 10:57:56 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Rhjy4ZuFr2J/YQsYfjypiNp1FTwn/nVolIeKKoKX5g0=; b=cQRoPKkkeY6SG7kjMP2mcLCrvmFRchM/Ek8r4BVoUl+XreMhbEz3/aJE9u30OC1oFB Hr+Wilsp0sR/R3+FasRaIg3bFIwwBdyqvCuRUTh4RhlA31BqaS3/nDjGarR0nLRxOuFd YIepH7WC2vcAzS6+T4faaD4DJd2S1hfnfTDCkzJ/akGhXQ5U2FM/QyqWFmppnkWDyIHG XqXZt54h/X0XBH29hHkOwxSPpUXIaAvVJUxxFX6etgC5z7H+ydF/5OV8yPbjO5+9vcIY vCWBkMnNkvB7/ZDZXzZ+iB8G1GCwM2jvlfSWDhYcNuRJ3l++mDxuohQF/4FPDhOgxb77 6S/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rhjy4ZuFr2J/YQsYfjypiNp1FTwn/nVolIeKKoKX5g0=; b=ZN8AMzoQ8mQh0Lbpz47Kwwk3h+y8EmFIdm2fD6DmhUht4VsgqfXbbJoBsHVZNSld4B yTtbB2ZlLc/h4hiIHKUjxRoKsKHLTuM9Oou3qBcf47tl1yMlYlA3ZxlwVljsQVpQ+h03 oNkMCQKY14gCebQMnugapkwsYwxZIVk2OzSuwjz0M4QAQ+3D9nk2o7Ft94yZ5dvPhY6L xU3bWfKmuaPoZ9h3eHnRt4nfLvmDksiYxLUzY3zaAuB89A0uQanoLUdd2maLPJfFeWWJ 43s4jvZJXaEGrk4AbZAOkB6YzPB2+ghPKYTfDci+/uRh+1koWSOIto+nPNYCs8GFDrOI hagw== X-Gm-Message-State: AO0yUKUDdXh1xfL/iZoLYmdRkeCf14dlKyR6MhDePOUBsWQ44RjFbCGg Ev1DPqmWA8Ah1VtlSfTYi0smmbSdZPStdJYy X-Google-Smtp-Source: AK7set99WNSWOw5IYu4hKdqjrkA617YNnvhKygjmCUQzmX+RrlC0M6nLJ0LQWAqdh0x9uyYvyddtBQ== X-Received: by 2002:a05:6870:560c:b0:16a:c90e:def9 with SMTP id m12-20020a056870560c00b0016ac90edef9mr1547552oao.9.1676487475205; Wed, 15 Feb 2023 10:57:55 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 08/10] hw/riscv/virt.c: do not use RISCV_FEATURE_MMU in create_fdt_socket_cpus() Date: Wed, 15 Feb 2023 15:57:24 -0300 Message-Id: <20230215185726.691759-9-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::2d; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x2d.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 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676487589968100001 Content-Type: text/plain; charset="utf-8" Read cpu_ptr->cfg.mmu directly. As a bonus, use cpu_ptr in riscv_isa_string(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- hw/riscv/virt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 86c4adc0c9..49f2c157f7 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -232,20 +232,21 @@ static void create_fdt_socket_cpus(RISCVVirtState *s,= int socket, bool is_32_bit =3D riscv_is_32bit(&s->soc[0]); =20 for (cpu =3D s->soc[socket].num_harts - 1; cpu >=3D 0; cpu--) { + RISCVCPU *cpu_ptr =3D &s->soc[socket].harts[cpu]; + cpu_phandle =3D (*phandle)++; =20 cpu_name =3D g_strdup_printf("/cpus/cpu@%d", s->soc[socket].hartid_base + cpu); qemu_fdt_add_subnode(ms->fdt, cpu_name); - if (riscv_feature(&s->soc[socket].harts[cpu].env, - RISCV_FEATURE_MMU)) { + if (cpu_ptr->cfg.mmu) { qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type", (is_32_bit) ? "riscv,sv32" : "riscv,sv= 48"); } else { qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type", "riscv,none"); } - name =3D riscv_isa_string(&s->soc[socket].harts[cpu]); + name =3D riscv_isa_string(cpu_ptr); qemu_fdt_setprop_string(ms->fdt, cpu_name, "riscv,isa", name); g_free(name); qemu_fdt_setprop_string(ms->fdt, cpu_name, "compatible", "riscv"); --=20 2.39.1 From nobody Sat May 18 09:01:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676487497; cv=none; d=zohomail.com; s=zohoarc; b=Q1sLKGy+vLPZ0b8y6UVX5VcyiBw1PLdcKCNSZaT5/Rw0Nfcnhx6EM9AjaKbvdxzMWIZOG6sNsLRbAiimsSBibLKVpCt6AtS1xLZeBtw8N0ZKUVTUfWjruff4/nDoC8YBxAJhsu8sNHTKFDbd6o2sUgarG5PTxbzoLoeAKzP7VNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676487497; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KqvKnxVMWo5xUwBFYmmbLK4P5nYy97w+H/Se5TENS3M=; b=ej1mHyehnDGGmIFedUa0B7TZaEIflJa1TJlWhf2ap1szaO8UFrLqG0GH77wmijytGRl5T/QwRB0d+U6Y7p/82em+nVAnDG4bGSVka2zWN+A1u/kaHnPHG1lW3qECHgeeIUnkIs2NM4TYsMqrsTeaYsdmNQKS0ty7nOI2Qk+wtJM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676487497892781.4900214640852; Wed, 15 Feb 2023 10:58:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyn-0000Z7-G4; Wed, 15 Feb 2023 13:58:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyf-000892-0Z for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:58:03 -0500 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyd-0007wH-7m for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:58:00 -0500 Received: by mail-oi1-x232.google.com with SMTP id bj22so16653155oib.11 for ; Wed, 15 Feb 2023 10:57:58 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KqvKnxVMWo5xUwBFYmmbLK4P5nYy97w+H/Se5TENS3M=; b=mH0tRWzfKrQPXRRnwFeRGaoVw1QWZCcr6oGcW4kuIKZdPBbSg+txJtyEYANuhF17Nx pLRY96VnbZRHXH8Q1G/9yrTcQymKnBIQEjfYBqpozMhD+aJ9jrxwmIywQbcPOevGUJEo NTURaSBy+QbltJDDyWdOB5TACSJw6pNomvi8Tad48gKX7junHnfjhJovIZiBNCbqHMw6 N2+pxFKT+uRaEspONZ+46wdABzvicDqO4aYNK1yjkdYYqfEifC/EWDh/xpGLgM2XE2TZ h16+/fD3oynuMxIK9/6LbA0Z7I1KUwqrZxWRwZ9OKu2F/Rboafra9bqgGdXTvtTsU+id i1fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KqvKnxVMWo5xUwBFYmmbLK4P5nYy97w+H/Se5TENS3M=; b=FqkjSdSPhJK+Kq2CWWyfsaPKeaSm186rxvW0g84XlnSPkJ1CGhToxnh4dQ02upQ/7e Y6I/7AADsVIFo2IHv3VomcgOGJamWYGrF1GHxfPfWaHmh8M2Zr8QaLtaLnhupIkGBN55 8a40QmogzHxHey7zzp3HxnjP7Y9ziFcL5butx1HNoTL0BGHM7voiEdRwTVL/2PeLDmip zOolZcw3eaCAxZXAzIuSePScVxc5rT7/2IuQ+3Pa3V1yqv3pu7goosxP//pN4QKrTGeN j22cg0qHgSwE502H237TzWNpoYlRxMvdjgZFsMZMQjVT8UVxFvgqPfpSV1jq/5wNm45Z Ibxg== X-Gm-Message-State: AO0yUKUV9cwslS52VSTKvg9+EhsLjdVYUUxUOYH5XyjNXBDt2kCod9Cg rwlegZ8RJrXFWBQ2N9WK9/HgLYzlEsQCZOov X-Google-Smtp-Source: AK7set/w7mev+PWMye3T2b17WKghZXE8R/u1VvPij9TpLusC9l4m+gwm4/MHC02JbMXW01EoCVnwig== X-Received: by 2002:a54:4484:0:b0:378:24b1:65a2 with SMTP id v4-20020a544484000000b0037824b165a2mr1236039oiv.6.1676487478183; Wed, 15 Feb 2023 10:57:58 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 09/10] target/riscv: remove RISCV_FEATURE_MMU Date: Wed, 15 Feb 2023 15:57:25 -0300 Message-Id: <20230215185726.691759-10-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::232; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x232.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 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676487501438100003 Content-Type: text/plain; charset="utf-8" RISCV_FEATURE_MMU is set whether cpu->cfg.mmu is set, so let's just use the flag directly instead. With this change the enum is also removed. It is worth noticing that this enum, and all the RISCV_FEATURES_* that were contained in it, predates the existence of the cpu->cfg object. Today, using cpu->cfg is an easier way to retrieve all the features and extensions enabled in the hart. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 4 ---- target/riscv/cpu.h | 7 ------- target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 4 ++-- target/riscv/monitor.c | 2 +- target/riscv/pmp.c | 2 +- 6 files changed, 5 insertions(+), 16 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 7b1360d6ba..075033006c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -919,10 +919,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error = **errp) } } =20 - if (cpu->cfg.mmu) { - riscv_set_feature(env, RISCV_FEATURE_MMU); - } - if (cpu->cfg.epmp && !cpu->cfg.pmp) { /* * Enhanced PMP should only be available diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index bd7ab5fceb..7ff4d90261 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -81,13 +81,6 @@ #define RVH RV('H') #define RVJ RV('J') =20 -/* S extension denotes that Supervisor mode exists, however it is possible - to have a core that support S mode but does not have an MMU and there - is currently no bit in misa to indicate whether an MMU exists or not - so a cpu features bitfield is required, likewise for optional PMP suppo= rt */ -enum { - RISCV_FEATURE_MMU, -}; =20 /* Privileged specification version */ enum { diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 15d9542691..e76b206191 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -796,7 +796,7 @@ static int get_physical_address(CPURISCVState *env, hwa= ddr *physical, mode =3D PRV_U; } =20 - if (mode =3D=3D PRV_M || !riscv_feature(env, RISCV_FEATURE_MMU)) { + if (mode =3D=3D PRV_M || !riscv_cpu_cfg(env).mmu) { *physical =3D addr; *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TRANSLATE_SUCCESS; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 4011b0d6f8..ec2c4c7c4a 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -2616,7 +2616,7 @@ static RISCVException rmw_siph(CPURISCVState *env, in= t csrno, static RISCVException read_satp(CPURISCVState *env, int csrno, target_ulong *val) { - if (!riscv_feature(env, RISCV_FEATURE_MMU)) { + if (!riscv_cpu_cfg(env).mmu) { *val =3D 0; return RISCV_EXCP_NONE; } @@ -2635,7 +2635,7 @@ static RISCVException write_satp(CPURISCVState *env, = int csrno, { target_ulong vm, mask; =20 - if (!riscv_feature(env, RISCV_FEATURE_MMU)) { + if (!riscv_cpu_cfg(env).mmu) { return RISCV_EXCP_NONE; } =20 diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c index 236f93b9f5..b7b8d0614f 100644 --- a/target/riscv/monitor.c +++ b/target/riscv/monitor.c @@ -218,7 +218,7 @@ void hmp_info_mem(Monitor *mon, const QDict *qdict) return; } =20 - if (!riscv_feature(env, RISCV_FEATURE_MMU)) { + if (!riscv_cpu_cfg(env).mmu) { monitor_printf(mon, "S-mode MMU unavailable\n"); return; } diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 1e7903dffa..c67de36942 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -315,7 +315,7 @@ int pmp_hart_has_privs(CPURISCVState *env, target_ulong= addr, } =20 if (size =3D=3D 0) { - if (riscv_feature(env, RISCV_FEATURE_MMU)) { + if (riscv_cpu_cfg(env).mmu) { /* * If size is unknown (0), assume that all bytes * from addr to the end of the page will be accessed. --=20 2.39.1 From nobody Sat May 18 09:01:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1676487541; cv=none; d=zohomail.com; s=zohoarc; b=ecIqA0u5liHBkPRX6aKWqDloaYrzPxPqw2typuC0j4o+vBCGbxy6ALTTdJW0CcN0n7+DjdIFnpRsa8ZR8UHazgXCFmCCgwNGLd9ijCNd+cVMBSXvtSZH0W43fosOlQhYJrV0PO8I9yM7VKtEnbDxO+tFAuxk8QJg8dI2ECheHjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676487541; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GvaH81B5hBrpGPqem9kaUkSdCiGN0le0jCxW0/4CJJg=; b=Kw3E8kRxVun+fG00yTJyjOtFqD4Z8lkEKau3K03kPAaH5SWtOn7G9ACA4OTy3CIUL5c8bIEbr/2qnjjcwGRxoBLVHkYBhmkyeVOR93Mwy1egZj/EbJ4oX7xJabsiqGvOYVTCXHRCIv/hmPmgfV/gJD98ZxBfzPTfLX/B8B1SV70= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1676487541585864.3612389488135; Wed, 15 Feb 2023 10:59:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSMyo-0000il-IR; Wed, 15 Feb 2023 13:58:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSMyj-0008RC-Ad for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:58:05 -0500 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSMyh-00080p-ID for qemu-devel@nongnu.org; Wed, 15 Feb 2023 13:58:05 -0500 Received: by mail-oi1-x22e.google.com with SMTP id dt8so16700886oib.0 for ; Wed, 15 Feb 2023 10:58:02 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c21-20020a056808139500b0037d8dbe4308sm4145697oiw.48.2023.02.15.10.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 10:58:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GvaH81B5hBrpGPqem9kaUkSdCiGN0le0jCxW0/4CJJg=; b=jkIr/+wjpIgWgAjVzvrmpKtmvPFIPna3dhunaWVZGCDKCask1VqCI6jcmt/33lCh04 f74+ZGaCh2tkCVIQIDXWclV1wkolbdlK5WNE2E1m9SmYSKiJ6ntcP6VcjC9IgRzz4UCd GhNXMkAICI3/3AzERPUKUSAV7Ez8XlcvUZvj82iUzQSwM6XHCEGP377BbUGZbIKXLS+3 ZnmfifVg1TOZ01mS/bHBfI8MgGXJq/RENnxQjEpzpBPXZqTEsE13joy1vxg6zNle6+1e WTZxOfM7OZBe0XI7RZFnfSbc64foD5Sm5kt3I5P+0XTT3PtijawEiyVz6Cm2N2XOIT/g IvPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GvaH81B5hBrpGPqem9kaUkSdCiGN0le0jCxW0/4CJJg=; b=bu24kGdc2t+GdVczSincCOc9i0rTehK2pQ4SzdTjscDrTKOs6D0O4Tm4EpPik5ubuN WzRO6Z1zbIwPIkT10gXPAd90jk/Qh513c3m60IsV50iEJsdwUze4zdruNc41JBbtvycp VHWRCZlA/bVwnaTXRt6LDQSjpMm3nLuxmMzVq1y8tcwV9vVC0po5++r/vREJ1/z8qBpZ K3IskRyem9m3Ju81YneyPRgnFccFWrs7B9rJogKMJ/1bUzHCBujpvOdTwQkSfkMUDNh3 L6DnYm7T3j5MjH7XuKXq4FMpaliCDCOlIYJP5Q2rzsUnmJuzrq2NecXlZ9yN1Vxr9x7B Ryfg== X-Gm-Message-State: AO0yUKVg2ptzs4Yzyvs56WZIOckT8LajGykbzQw+1JS5bm4Sz5fPWQji HNooI4QZsR2QhHRY4C7ycMBi2GJdfur+Zz8F X-Google-Smtp-Source: AK7set9+BX1XPIa2drpEYnGU2E2HncOZOL2DVGS5NOZCl0U7L5WuK8o0ABeHUUX0cFnFnuMsSpSQPA== X-Received: by 2002:a05:6808:3a9:b0:37d:c268:d3d9 with SMTP id n9-20020a05680803a900b0037dc268d3d9mr1504057oie.11.1676487481131; Wed, 15 Feb 2023 10:58:01 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v3 10/10] target/riscv/cpu: remove CPUArchState::features and friends Date: Wed, 15 Feb 2023 15:57:26 -0300 Message-Id: <20230215185726.691759-11-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230215185726.691759-1-dbarboza@ventanamicro.com> References: <20230215185726.691759-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22e.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 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676487543752100001 Content-Type: text/plain; charset="utf-8" The attribute is no longer used since we can retrieve all the enabled features in the hart by using cpu->cfg instead. Remove env->feature, riscv_feature() and riscv_set_feature(). We also need to bump vmstate_riscv_cpu version_id and minimal_version_id since 'features' is no longer being migrated. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.h | 12 ------------ target/riscv/machine.c | 5 ++--- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7ff4d90261..671734420b 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -173,8 +173,6 @@ struct CPUArchState { /* 128-bit helpers upper part return value */ target_ulong retxh; =20 - uint32_t features; - #ifdef CONFIG_USER_ONLY uint32_t elf_flags; #endif @@ -524,16 +522,6 @@ static inline int riscv_has_ext(CPURISCVState *env, ta= rget_ulong ext) return (env->misa_ext & ext) !=3D 0; } =20 -static inline bool riscv_feature(CPURISCVState *env, int feature) -{ - return env->features & (1ULL << feature); -} - -static inline void riscv_set_feature(CPURISCVState *env, int feature) -{ - env->features |=3D (1ULL << feature); -} - #include "cpu_user.h" =20 extern const char * const riscv_int_regnames[]; diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 67e9e56853..9c455931d8 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -331,8 +331,8 @@ static const VMStateDescription vmstate_pmu_ctr_state = =3D { =20 const VMStateDescription vmstate_riscv_cpu =3D { .name =3D "cpu", - .version_id =3D 6, - .minimum_version_id =3D 6, + .version_id =3D 7, + .minimum_version_id =3D 7, .post_load =3D riscv_cpu_post_load, .fields =3D (VMStateField[]) { VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32), @@ -351,7 +351,6 @@ const VMStateDescription vmstate_riscv_cpu =3D { VMSTATE_UINT32(env.misa_ext, RISCVCPU), VMSTATE_UINT32(env.misa_mxl_max, RISCVCPU), VMSTATE_UINT32(env.misa_ext_mask, RISCVCPU), - VMSTATE_UINT32(env.features, RISCVCPU), VMSTATE_UINTTL(env.priv, RISCVCPU), VMSTATE_UINTTL(env.virt, RISCVCPU), VMSTATE_UINT64(env.resetvec, RISCVCPU), --=20 2.39.1