From nobody Tue Nov 4 06:54:12 2025 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=1677092082; cv=none; d=zohomail.com; s=zohoarc; b=MVmZrw1XbEqc6tRAzV/ho/lgS1sHZdd+tHeex4rE/FYuCarO53PPbVExFhc4t7z5gl3ZcTxQ7g7AltUNAzUr2F3/ABahsW5SMFZmvP813CS3GSkfOpO+2p9tpqS5m01r8mfBMui8jOE2MuxHcOfNlPEeg0YFLUBoYYm0tiBEGKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677092082; 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=k0v5m6NdaT0U0yWKVSkcZRcGKgMJTyOkKnvfSCX5LQI=; b=QfSjuGTNkkxXST/IzxlTIVEsJ2QBQCm551ae8U1szC2CJWZZrw2O2dIkVX3JF3rJS/jsrq7eSE4e2HNp/S3CVHNYULcxBVPiYhYKi4weqvORnq5VDkVOibHyNTiHwMnz/aWWxAE49TIIY7TnwXlMZdkbkwXNOFeLSXLoHFQd7Es= 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 1677092082605848.335201685217; Wed, 22 Feb 2023 10:54:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuEP-0007JT-Fy; Wed, 22 Feb 2023 13:52:45 -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 1pUuEN-0007Hs-Og for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:43 -0500 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUuEM-0004OD-2E for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:43 -0500 Received: by mail-ot1-x333.google.com with SMTP id bh19-20020a056830381300b00690bf2011b2so1654733otb.6 for ; Wed, 22 Feb 2023 10:52:41 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([189.110.112.117]) by smtp.gmail.com with ESMTPSA id z2-20020a9d71c2000000b0068bcadcad5bsm1781111otj.57.2023.02.22.10.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 10:52: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=k0v5m6NdaT0U0yWKVSkcZRcGKgMJTyOkKnvfSCX5LQI=; b=hTY0SpT2Avokxm8yVG11E5TWvmhwiY4pIw0MUHwSyONHnOE0PWTwb+be8BEO7UxY6w YdnYWC5ylGUXS6Gbu+PIoK4UU4qppkh03xtvpJU95CwrFAGXiZEzhmb54CpriZmVmhLs dwZ97zGH1fY1E0Cuwfr36ri1S8nxnNG+g7r6VFwCcoNcT9nGwFTYfvy/t+hjJKML0GIq ygMgzNXeN4mnyo+cmPZnd2DwlG2vwBcuGtWzbA8sn8SRu2wL12sd0p80GAnHlKpg4LxS ZUTZ+ZDlhhnyI1suB1Y4+44obAMeJEYdR6BtXg1MPf8XcxsHhQ9LQnKPwqLqFO4dRZAl pPhQ== 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=k0v5m6NdaT0U0yWKVSkcZRcGKgMJTyOkKnvfSCX5LQI=; b=wbva3rUwheVGRJNs6Qa8ofyZZvOGrRvfQaz/z9bCbtAMJenBmc8PMX50XwPkGvYrHa zL/nduWeUBv4h1OD/GSPaNMRz1kx4ywaEG08kyBvcp+Vy8Ef6GwNBWvDeB6FiBhO2M9j V+JcNijK+/5fspqeb6HAPgt2OGCMn8JJ87U5vG3+zjJNs7VjrloUoUTYUlOwpGpXu5S0 Ns85cEZDSyOvXQ3DZfseHTIctZBqZ7YfnJxqPBgwp2oSDKvgeV+Bn/ioiFCsNYO6fykD P1jcCqXOONncARPesJIWXK40apawpB59JGmn9Et70CeQKPCoREPUb1PDwTkdGibVl2xO Ojyg== X-Gm-Message-State: AO0yUKVNKDp7umqc+6lXDbwREo/SdmDOXJKphjKMisk0oRJD12uNh177 6rwrllJdE4Sdgb8NCDgEDdR9fi0SQZuyu9rT X-Google-Smtp-Source: AK7set8ay4K2hjnWkcwoauZermLACwl1eQBEktnGTjiz/F8Quj7Uv0hI/gBkShnZ86dXdULocDVTBQ== X-Received: by 2002:a9d:7141:0:b0:68d:5ffb:9dae with SMTP id y1-20020a9d7141000000b0068d5ffb9daemr236427otj.15.1677091960485; Wed, 22 Feb 2023 10:52:40 -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, palmer@rivosinc.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v7 07/10] target/riscv: remove RISCV_FEATURE_PMP Date: Wed, 22 Feb 2023 15:52:02 -0300 Message-Id: <20230222185205.355361-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230222185205.355361-1-dbarboza@ventanamicro.com> References: <20230222185205.355361-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::333; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x333.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: 1677092084415100001 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 Reviewed-by: LIU Zhiwei --- 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 807a466f34..d321ad28d2 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 d4da420912..3246153db2 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..292b6b3168 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 951327022d..cf33494945 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..9c0b91c88f 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 aa4d1996e9..205bfbe090 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.2