From nobody Tue Nov 4 06:25:19 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=1677092003; cv=none; d=zohomail.com; s=zohoarc; b=Z0n8liIp10lVWk1pc87Q+MYlNnrVJv2VYBpMsyt/WMoe6gjBNtrgOl9uc0Ll7O7x/nDrr8gvyPpRl5Hvnb3LwSNjLqHiusZ1jJYA13hr9uT+EtqQrsjVp4meiSL7lvQ8nbThorQOJcH3kdREhA5Hz7kp7p3hKA/dQ2dAWKJwhPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677092003; 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=ndggLRvy6CI5VGL9R/ZcYN8P1FsQXEZBqDwWbxWEGs0=; b=SR7fXCls4JQBEOpkA0o2PkUTxWyXSubod3xMlEqz8YMLBTOV6wnHCWF+8fFXtVWuvOoktHLAWXGEWXAyVDpPWU5Vls838QojJZ3xU5FAki3Ij4OoG91bbl9y0VOJZsiShmf0AVVGB0Lc86topRsvSLp0N5DfypDsZk7BA8ABdes= 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 1677092003210951.2973102335499; Wed, 22 Feb 2023 10:53:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuEX-0007Lv-Rd; Wed, 22 Feb 2023 13:52:53 -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 1pUuEV-0007Kz-Pq for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:51 -0500 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUuES-0004Op-9u for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:51 -0500 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-17211366c6aso10625868fac.13 for ; Wed, 22 Feb 2023 10:52:47 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 10:52: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=ndggLRvy6CI5VGL9R/ZcYN8P1FsQXEZBqDwWbxWEGs0=; b=eTxUlYX4hLdCREiQXD0D2w6uYTVzHb2t+2tnSdmnKw3HqpXsbM/DzgyVyTCFjQB9ks xjvX5IKQliWvOHa+XTjZ3xAxA/dJX6/MzjrxE2QWl1IVGUbCaqD861k2RZe9D/k1MnLk gof/xxYho1ZwYPPv/b2tqPN7Bgn3Cyo7UJ7aVkb0H27DtoKG0UtAadFpBVHE1clwSW/b T7FGOgS0urC46BC61x8xo4Fpz/iBWETCtERl806mCCnR/XBsDb3R6e2z1pw2BJcRe4aR oWTmVQQoRLPCrdL/iD2Kcy4BnhESuiQYtHjaOZ+LJEb7rrvkQ25vmkoe2y3UrjQwT+VK 0ctw== 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=ndggLRvy6CI5VGL9R/ZcYN8P1FsQXEZBqDwWbxWEGs0=; b=cH0FyZ13MjJ7q4afddNQgYFCg5SH4MtBxMtJW2uyGRJVoNXQrsUzxpkaJuw8vKxaG6 h3Kewjy3hMzuiL3qCz0i6DB4W5ombmjeNm9T+cUUON0KlwPUAxiM08aMD5NGSpx8xBUD Nqhagg+bJH3xj9qYtAWfwSb6crT28CIMp7DjSIMGcjMnogpFDfxwnE8NRMqboMwFilG5 IQVUXLP9Qs3SLBbQHsYl/FhE/WgeBvWpJw/iszg+4NRgzziht1fOhfjWViAiNxErHbhl KX8qkwEYTzGmwFvmqKRA/wYlV7vpb+46hoBOrBZjq76CHRVppX7osmmQDc+cnJ676YQc OxVw== X-Gm-Message-State: AO0yUKUFgUwHNszanwUAKR7oecevmGCkFf/WAcHIJRslQnfI8i/HbKgJ WcNyoztchZrxS8dYRTw8PkPhA50gNl3UwncH X-Google-Smtp-Source: AK7set/iXI38eCoUqj9k/1O9Bb+RsjpaOgKC/1La5s6UdAcACrOw8NGI1H9PnXWrdqpTaZ0oGP0lIg== X-Received: by 2002:a05:6871:204:b0:15f:c10f:4e4c with SMTP id t4-20020a056871020400b0015fc10f4e4cmr11018168oad.44.1677091967026; Wed, 22 Feb 2023 10:52:47 -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 09/10] target/riscv: remove RISCV_FEATURE_MMU Date: Wed, 22 Feb 2023 15:52:04 -0300 Message-Id: <20230222185205.355361-10-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=2001:4860:4864:20::2f; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x2f.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: 1677092004219100006 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 Reviewed-by: LIU Zhiwei --- 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 d321ad28d2..11da920915 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 3246153db2..fb0f2afe0d 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 292b6b3168..eda2293470 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 cf33494945..75a540bfcb 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -2621,7 +2621,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; } @@ -2640,7 +2640,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..f36ddfa967 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 205bfbe090..a08cd95658 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.2