From nobody Sat May 18 22:54:11 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=1677092003; cv=none; d=zohomail.com; s=zohoarc; b=PAN4nQ2lMmXnjZ0fSyRVf30zeYQUMl0uqj9Ggp1Pnn9EEf/47zUwENvAEMWOEDYxy9kq1H4W8//f6yFj77CF4LlZYH/OhCsz1+tzpL2y65VomtMkfTw8W2PRlmaanSUgz7MTbjKpKXWREONZNM0WSbdj0XKLcdFeBVa7htsJChM= 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=uOJjQ+LYJii84tGGghSEtNkWZ701Sd54P2KPAADn0Ns=; b=Wvb+acHElGauyd4pq6bz1s4hxF5hxqFwWOhrNxxBhNolylM0fxzqlqiEEsD4z2JLG8A3vtPkDKi3nhUgo0LCTkE+sQpWTvC09oGUhshP8yya+y3edwf9SkHqp9jrtt+XMU2SLahpLzA5GD418F0avkImK+PLqWjxf8YvuGrtLKc= 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 1677092003270775.4078523039248; 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 1pUuE7-00079K-FR; Wed, 22 Feb 2023 13:52:28 -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 1pUuE4-00078m-QA for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:25 -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 1pUuE3-0004Kk-9j for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:24 -0500 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-172334d5c8aso7376272fac.8 for ; Wed, 22 Feb 2023 10:52:22 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 10:52:20 -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=uOJjQ+LYJii84tGGghSEtNkWZ701Sd54P2KPAADn0Ns=; b=du73QTC1s8erzOXaFLwbB6tAUZGQ8cBSvjvgDZb/BU3BUgJcw5bsig6oklO4LZulX1 Po/liG+40zjc4ULXG2a/0pzm6JF11DAQpuNros8r79tIpQy3nK7yv8grmK37GKzm0JDR hPiMDeHlS5F9esOkH7/xrw/xSggfubWe6egynDpNu9Y8u3MUfgFgIno8y4qARJkVklxE 3/GwZqbkgc5dZFuRdMpM0vrNXztxoFxzpvBSYvDeydzaIfjsMLC3jMFLntu3zkIv34AC 8jptoo37t0+fs32YGXKmXUiiDMqh9Heq54zI+x4hWBYM+279eCZkK8Y3UbnXECyDBImr l2GQ== 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=uOJjQ+LYJii84tGGghSEtNkWZ701Sd54P2KPAADn0Ns=; b=UYuMvrjB508h4JGnpyM8iVZJbp0kSbDgj02nD/sdx54XGptJUyXdMUcq3Qq2wGSTdL lWJQjNA6tlD5PSAx6g+EU9O+ZeHpXzdTln6eTVA3cn0pK/+P2k/InInyGmmTuC5tJ3UY xxmHpsG38CUw7E8CPMf9kW5tu2vOZi9Z5MNZadYzX5qayo+L9quOUbOFfNExaLSyDJ1z e9Hvx4gL1MhH6qB1bOLnI9YCUuNtYz59XRPmZK3DJT8eV0Hpc+lFcS1Bge/mPVfuvFMY qjQ25JzF5Uv9bYCsOS161tFOh7sRM7NFeKcoLdX5EAvHjEKi3zJEXd/VcIo/+LKBLzrB qajA== X-Gm-Message-State: AO0yUKVfpfdoDlR40/ZAtpAFOoAfXSGyxDusFnJXYRVJnJvEF7Jr6dus TvZw39ELp629A+aNGF2i9iwPljjoZbO2eXpc X-Google-Smtp-Source: AK7set9Os3DLBTYwLsmrpnpCVphGmHT48v3uJFc82cDhn6rpcV8TEyEgUGCmbLLGLjBSkUZOMEzg8Q== X-Received: by 2002:a05:6871:1c5:b0:16e:676:bfea with SMTP id q5-20020a05687101c500b0016e0676bfeamr8930971oad.9.1677091941239; Wed, 22 Feb 2023 10:52:21 -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 , Richard Henderson Subject: [PATCH v7 01/10] target/riscv: introduce riscv_cpu_cfg() Date: Wed, 22 Feb 2023 15:51:56 -0300 Message-Id: <20230222185205.355361-2-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: 1677092004206100004 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: Bin Meng Reviewed-by: LIU Zhiwei Reviewed-by: Weiwei Li Reviewed-by: Richard Henderson --- target/riscv/cpu.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7128438d8e..215423499e 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -654,6 +654,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 const 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.2 From nobody Sat May 18 22:54:11 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=1677092003; cv=none; d=zohomail.com; s=zohoarc; b=oEjpVmTnMb65OISYlW0N1avaKo+/uRn/sr32dKXY8/Gl/nCBSk0QkpTjNcBLOFqTuSnA2sSe4wvFo/rshGdB1QjvsWqFHC2FVXmfvYAKK/6ilk7X8kiY7Z9ACWOxaqfmkwCv4VdrlEXxA0PyF0RL4VnFgG/51UX6+k3W0ZMSwSE= 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=zvvhFufYKaxYrfOxF5GlRHGMfqK+pFBiVwcRuEAhcPI=; b=S7sluAYWgHy6t1sDeNhZodyfKYb/uapumhca5Erjmz9sMiUGftKlSvK42suqcvpJ87F9KvfD9w8sLlNvitUKbhIh9T16F5EFneHGi6EOXakmLFVUGWxznd8wGl49iWWbe5aDgb7YLBaCDsvIPQZ1B6f/AnJJmnU+TcNAQc60ZtE= 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 1677092003347909.850105798848; 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 1pUuED-0007Af-5g; Wed, 22 Feb 2023 13:52:33 -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 1pUuE7-00079o-Oz for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:29 -0500 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUuE6-0004LN-6W for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:27 -0500 Received: by mail-ot1-x32b.google.com with SMTP id l13-20020a0568301d6d00b0068f24f576c5so1675022oti.11 for ; Wed, 22 Feb 2023 10:52:25 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 10:52:24 -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=zvvhFufYKaxYrfOxF5GlRHGMfqK+pFBiVwcRuEAhcPI=; b=lNM4ZWhvCG6bS8HQ54ocfKa490tMQstmpHVIU0E9zijywVlLIiCxAg/FEYXp7t4H0/ ER04PZkpbQwNXEk+/1TJe1iiAbFRi2jAe+gHkrzna9m8u7dc93gKo4JQ23xnrWvZ+/sG rYva6WLVM/3jKqfTDoeJuF2T7XXguGN0MmDCnkGWeRkf6r6q36Qq/BGIzBhHwziAjtHf rqKU9kBZzoTSdzzJ0hCiqmkH7sFR7gCvRovkvjdttp8mUGdMUZqoEHp0EwOTG4ky2fDI 6pL/xNhkx0vErlQlvkXelijrp0MB0uXBcnNlMRWpoDRjZL9t4IRsJo4AYZvevG6N81jp 8Z6w== 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=zvvhFufYKaxYrfOxF5GlRHGMfqK+pFBiVwcRuEAhcPI=; b=TbMHnBOO+slPlmyOtk6TSbwkJe2/NISKmPXrdiaRlaXI9Ljq53x8xc49djeHnVbBlg dwx/Xj2RJs2+3tppcULK7C1oo660MhwE69heiGMZZBq0xOwavlZJ6ppbBxl/fNIOpI+p 4jtbLwWNTxVKxqP1EfFpog5kaDuYQb2lyMzRYs98+TiWXpnBSDAOebBNj/0nsVXpcKQB RmGzXjsX8/Mj2cZAZduZl99jOuZN5mF4K6y/4tlHPEoi821qwAvdWh1nFhjBL14XwnpL QAqV5BNKLpM9jNWdOIFYizVnv/Qso1A2lqgNPlcuaTIYUB8E06SbcVWH5WJIq28OMZSv rq2A== X-Gm-Message-State: AO0yUKVqV0teHH4izdBTiB+JlO6cc3Z8wMxdmTGPntnwwXfwjMzBvLHI b+HBtDCccIJkMsghW9XeBcuNtiLHnPgwR1CU X-Google-Smtp-Source: AK7set8wL5d+kOjymM4LgkwHIvlrSH849ezofvRzyEyEwC46GMc6RZcCwoAGmfROJ3ueH3Mr/uy2CQ== X-Received: by 2002:a05:6830:3101:b0:688:56f8:bacc with SMTP id b1-20020a056830310100b0068856f8baccmr456016ots.0.1677091944567; Wed, 22 Feb 2023 10:52:24 -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 02/10] target/riscv: do not mask unsupported QEMU extensions in write_misa() Date: Wed, 22 Feb 2023 15:51:57 -0300 Message-Id: <20230222185205.355361-3-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::32b; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x32b.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: 1677092004223100007 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.2 From nobody Sat May 18 22:54:11 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=1677092039; cv=none; d=zohomail.com; s=zohoarc; b=JbI9hl8AWw44kNUFnK+Ace1rIVhJ3+SrLdpoycLjP/SBYSWUJiql6AWNlcYGkDWItjzwCRkAp4PZGExrVv3UOCEq9uoEmWTgH8kMJ/ZKO3Gl9WJFHS9rfcGttBe0mzIwje0UxDbQQpmAe9s+D9+4J9HtxiBKkYdARRtbZN9fKRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677092039; 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=AUjfQmZFOjBhh67GMkNvzvN+XgGlao3hTMnflad7XzA=; b=jJPwRkhidl4MhJ7WZz76q73HNXm4ldBQgFyhLfDPlGCAJ+LkrOEQOf6VKLm/fc29iAeLw2d86ys8h6FXDRxIE//lyitpvBu83r82lKmu95aT8O/KG7E9+wueddYMn0TPh0p8QJKaLwXUgqAptEvD33RQ5ZUEvcyr32ZsSLOnO1E= 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 1677092039555296.7652209050385; Wed, 22 Feb 2023 10:53:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuEG-0007C1-Sb; Wed, 22 Feb 2023 13:52:36 -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 1pUuEA-0007A6-FX for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:31 -0500 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUuE8-0004Ls-TV for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:30 -0500 Received: by mail-ot1-x329.google.com with SMTP id c2-20020a9d6842000000b0068bc93e7e34so1663892oto.4 for ; Wed, 22 Feb 2023 10:52:28 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 10:52:27 -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=AUjfQmZFOjBhh67GMkNvzvN+XgGlao3hTMnflad7XzA=; b=hevj//avL/AbNTgu6ovHiCrNomyU8hRpmLcCvjQ4SBji5nMwR7El3V7lXF7qRvnXJj hN8vsEPn51KvNiP8yGxpDL27trG31uR2TdCG1kdYFy4fYTmlwzhGH25dRCjeTBE6+Cxb l8hYhT8EMoyHyu70AIQftFId+969NkqXThnLAooszdEJ/BsFRptINwMXaGHj9RnxWw3a qOwfdVtKTW0LXLvt/4a939VVZc9iLfzZBIUiwuKbsClvZ7OJ6H9G5GkMroiHe3N6+sNG u6ZtlViDjrW9Ydbon2HQjlEbzG3I+c8JqjrWux+LyGYOxhMCydi/LY3gb6XVmYnPkhG7 ZTpQ== 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=AUjfQmZFOjBhh67GMkNvzvN+XgGlao3hTMnflad7XzA=; b=Y/MyJonPWFh8K9QEV2LENmMRI4MsAlzs/bdAbhD7cDskSZLW56PbVe64O95+QVysna c6jgQH4FYWDXACJ47j8D55io+100iiW/KnTZspYpn6ZoKjY3rPfP+2WghIBLp8g31d+7 GXuoNWsj7wj4v0Ppx5wCS+XYyqnf+t4LCmYdjur7otPb391f1jYEfe1M5uicmF6RsblQ oOlLGp+Su/atzbd5rtW+GPbBbgGeiGuoJ1BvayPkHL0NrpSfs9epTzBKFYwTK+WBx7hS tw5fFMwDJ+heHhyjap2UHzWWQMD+4au8WhpMkR8cXd5Gkfhw/LXqVP1snFGYjEdX+dEP qjSQ== X-Gm-Message-State: AO0yUKW8tlveLBkt+bikxeWgXi3j2EfUJrHz+EvBwvifNfCzsgh+SyAw KFloG063zulIEAYLfVPLt9yxU1FdzbjHMRGg X-Google-Smtp-Source: AK7set8Y6y6y5/bZozuoam9xpr5OwCmTKbBDg4tneGc3tJN3cSGAVsF22mLNBzhBph5mHxwFHe8zvg== X-Received: by 2002:a05:6830:6518:b0:693:c6d4:c232 with SMTP id cm24-20020a056830651800b00693c6d4c232mr1741592otb.12.1677091947461; Wed, 22 Feb 2023 10:52:27 -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 Subject: [PATCH v7 03/10] target/riscv: allow MISA writes as experimental Date: Wed, 22 Feb 2023 15:51:58 -0300 Message-Id: <20230222185205.355361-4-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::329; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x329.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: 1677092040102100005 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. After discussions in the mailing list, most notably in [1], we reached the consensus that this code is not suited to be exposed to users because it's not well tested, but at the same time removing it is a bit extreme because we would like to fix it, and it's easier to do so with the code available to use instead of fetching it from git log. The approach taken here is to get rid of RISCV_FEATURE_MISA altogether and use a new experimental flag called x-misa-w. The default value is false, meaning that we're keeping the existing behavior of doing nothing if a write_misa() is attempted. As with any existing experimental flag, x-misa-w is also a temporary flag that we need to remove once we fix write_misa(). [1] https://lists.gnu.org/archive/html/qemu-devel/2023-02/msg05092.html Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Bin Meng Reviewed-by: LIU Zhiwei Reviewed-by: Weiwei Li Reviewed-by: Weiwei Li --- target/riscv/cpu.c | 6 ++++++ target/riscv/cpu.h | 2 +- target/riscv/csr.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 93b52b826c..1d637b1acd 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1210,6 +1210,12 @@ static Property riscv_cpu_properties[] =3D { =20 DEFINE_PROP_BOOL("rvv_ta_all_1s", RISCVCPU, cfg.rvv_ta_all_1s, false), DEFINE_PROP_BOOL("rvv_ma_all_1s", RISCVCPU, cfg.rvv_ma_all_1s, false), + + /* + * write_misa() is marked as experimental for now so mark + * it with -x and default to 'false'. + */ + DEFINE_PROP_BOOL("x-misa-w", RISCVCPU, cfg.misa_w, false), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 215423499e..9d3304bcda 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 @@ -498,6 +497,7 @@ struct RISCVCPUConfig { bool pmp; bool epmp; bool debug; + bool misa_w; =20 bool short_isa_string; }; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index e149b453da..3cb8d2ffad 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1329,7 +1329,7 @@ static RISCVException read_misa(CPURISCVState *env, i= nt csrno, static RISCVException write_misa(CPURISCVState *env, int csrno, target_ulong val) { - if (!riscv_feature(env, RISCV_FEATURE_MISA)) { + if (!riscv_cpu_cfg(env)->misa_w) { /* drop write to misa */ return RISCV_EXCP_NONE; } --=20 2.39.2 From nobody Sat May 18 22:54:11 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=1677092036; cv=none; d=zohomail.com; s=zohoarc; b=GfbBwR3vmZMz13Trv0CY0g4felpx+Qbr8fXRw4KyQZ/xTiZ/cqeXH9zES9I22jYaxRNm90TF06/C9SPYt0h4myTO5tTo0KkjDcwW9osMzAu8aKoPAbh9t08kHo7TV0Qq5QuzSmi8It2UgMXEhZXQXXXNSCKvaOd6+xdaOCldoo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677092036; 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=fSRZDgVynDAj9ItsD5H9AyS0Nai5Zcqgb4y0gtfbud4=; b=SS97nQ4f/lkzU5KUeN10SLxrzvWBKAA/zVl2XXeHXqfkCccjRsi8uCeW3ZLd6IXzyJ9I35C/ocGVpMknF2FKJ+JfKfbcENugRoBgP6oCr75WN3rvWaOU+cadK3G/gvwNmxWcND1xJy3bAYvJAAsZBt8yLp1VO9ZzilUfcflgd9s= 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 167709203620540.859717480790096; Wed, 22 Feb 2023 10:53:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuEI-0007Cp-UC; Wed, 22 Feb 2023 13:52:38 -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 1pUuEE-0007BJ-Qk for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:34 -0500 Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUuED-0004MJ-Bw for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:34 -0500 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-17213c961dfso10454018fac.0 for ; Wed, 22 Feb 2023 10:52:32 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 10:52:30 -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=fSRZDgVynDAj9ItsD5H9AyS0Nai5Zcqgb4y0gtfbud4=; b=o7cBHkgOSXgLIc3MIypDwaLaMKc76LYsAol8ZfWJKaClk1jsrcreMWI//pxDxk8QJk ERJ6ZokXT7Ao1j3cGJivfSQs2zXcP+8W24LlwaRHq4J6ZaH0w0ISzGbK/M16/ez+YwKO YHOiBOAExRhQHRFCk0e8LX6qGSxfaibT0bkRNREKyYtHl7gdOyKj8h+rb6tdb6Odx8M3 yeWdw0jmvi5KdMFzFs5G2PrMoNsdU1VbEYNpWjPWaO3tZjlpkZnAXV9YBsSoy/IQ+Urs ORBE5SnLjsm+40XBx484p17RXUurYaheMwH9JpkpX/nwoGx/5c+we9gJeBr9gDImcZmx q/AA== 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=fSRZDgVynDAj9ItsD5H9AyS0Nai5Zcqgb4y0gtfbud4=; b=OKXmDwl8mADx9yIrb+k24meDwBaNXtO8whUt8Z+y/VGCVm471E4Hx6cSap/cuyESwO LDEIC6KZyQF4adWVSjhCM2cxVUYn5J/qdZA0tXxGa7GvE10Vqt+fRkmyoXAnU0XFeh/q vdISMBKSU+5x2xsXfo2RjIxRu/G/2qXOv629ql51ogDJh8k8oxT8uDIW3hXuaCIegaRD 3L/o+7/Ye7GuiRNgoPN3RZeobZkC+BUR/NEeDbXddLbM2POxxbjZcUxodfJZhPuZTvsQ KMHI0ZHF1qtYaQRNJzdqk+mmJbk3aCscWR/lbf+59U4NHvivNFB0qRIC1cRs3jdO9TVr 7KvA== X-Gm-Message-State: AO0yUKVH4lfzCE882ZFgPKvGTIs7AMiiHdJz7zYniuCIeqdf2dym2txO wcHBYEbAsaMXkkvCJTvATcl+zmIMahtk8dD0 X-Google-Smtp-Source: AK7set/TZxqcsqvlCL0VJUFdtOwULv71dEJ7HnCnSqhZBiHCKMK/ADXY9bPYRPk1/aHWrmbi6Ayj6w== X-Received: by 2002:a05:6870:f14e:b0:172:721b:7edf with SMTP id l14-20020a056870f14e00b00172721b7edfmr246986oac.12.1677091950640; Wed, 22 Feb 2023 10:52:30 -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 04/10] target/riscv: remove RISCV_FEATURE_DEBUG Date: Wed, 22 Feb 2023 15:51:59 -0300 Message-Id: <20230222185205.355361-5-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::35; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x35.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: 1677092038037100001 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 Reviewed-by: LIU Zhiwei --- 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 1d637b1acd..13e55ec5bd 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 9d3304bcda..5295c2d701 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 3cb8d2ffad..e220c4a5fd 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.2 From nobody Sat May 18 22:54:11 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=1677092068; cv=none; d=zohomail.com; s=zohoarc; b=NP7eIa44XKYI5nzWtYJL5YrhdXKXOZV/BexXmwucMnnHD5QMrjtfTsJ/fAm4fAV4DnxF1ztGtOJJ4gipycKuJtkuEWQ3SNjD6SZsbClRtWiAdGERJB4jyiUZVkfkz2WHtvlpMRxe8u3XgiQq0LTcwKKl4lwZNPiC2iw2E+QshhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677092068; 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=VeZ860Xds9GWZiENsK46KSStGBncZvpBh5nY+1jAXZw=; b=WkAltL2Q5a4ZcxjEdRY/QeA5/7pmSt9ZysoJ8ROrXDfNu6C64GnRIOzRYYvDf05RH5gC8RbtZ+KyQSxuOKOkLrpMYmDVNtpn0ECMewIh1e2Qx0LM/1wPbeL25KPrrl3zzbpTpAu/M8X6d/CYDzSWUYlSgsENXglxA8kekvWQ2mw= 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 1677092068455420.4708215877523; Wed, 22 Feb 2023 10:54:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuEK-0007DU-Un; Wed, 22 Feb 2023 13:52:40 -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 1pUuEG-0007Bv-SQ for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:36 -0500 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUuEF-0004Mf-8L for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:36 -0500 Received: by mail-ot1-x32b.google.com with SMTP id f19-20020a9d5f13000000b00693ce5a2f3eso268233oti.8 for ; Wed, 22 Feb 2023 10:52:34 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 10:52:33 -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=VeZ860Xds9GWZiENsK46KSStGBncZvpBh5nY+1jAXZw=; b=PLRVN1wmDmPWZe+9lIe7su5o7R+hZyhGKLvGk8/54lkOLAbDwqW8ikg15sKg6PkJI/ h13jRRAgdymp2Tye6HLLYNawj7RMd830K0aMGWaI6LyJm15xEyE/fG3ROUVcvOW8MpaQ bLqTan8lPxOA7fFiPW9bWhk5egOgm51i0hPHjybPIgtHPVoXXN2FCG9xcGmQ6K1yP3sl dyGOOCGMfShn4vovw1P8+0wVYhSR42Gr8N1C1K5lBvfD0RdxN3lt9wCB65XH8djATMH3 UUotqXZ1H+G82hggO+17flkMaWe/r95hKaxbTmFpQHmNFe1xdeFcJUg7nnHE9OPJyeGk M4BQ== 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=VeZ860Xds9GWZiENsK46KSStGBncZvpBh5nY+1jAXZw=; b=cE/BXkRGBhlkssk79iEkhKtUFwL7EdSnRD9W+0ga8hE/ki08d0Tgyyv5sOyREt2QmE BKa75bY8KAemXBZKsdepjnFzCoDRbcOEXFc/hH2j9qXekc7xuWTnfnNcgT0rzQ0GQVBd blswr4QrfSpKYEgu2dR9WyiH7Bg0269m0/PQeAej4Ry6ekHhBZRCDcPBzsW36S7kLbub Caj2b+hD3SgD6n+/FspXg3/lYu3CtZwRNiCSInqzXaNTNJoFmgS9tvA14xRfpGpa+/id fWm/yj8lXiV6sbjegoBwkf54rQ+Nui80MO+Jxpik7xiZCjQgF3eWFgaZoUug1BknjfXH kwRA== X-Gm-Message-State: AO0yUKXMqKId+8mRisDGxyVnyr9Xv5cgqrfh+MxoEui21JMfg3+FVhGC quiBaeXmSAuPFxkbiZzUGehRh+KKx0+tNzhP X-Google-Smtp-Source: AK7set847VD/JmGIoDwfCzWl+DanA+sLZPafspgjaTChtjaNj1l/oAjTzZ1w8Nv1XsOSnnEWMfSv/w== X-Received: by 2002:a05:6830:4387:b0:68d:5a31:af3b with SMTP id s7-20020a056830438700b0068d5a31af3bmr5109342otv.14.1677091953838; Wed, 22 Feb 2023 10:52:33 -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 05/10] target/riscv/cpu.c: error out if EPMP is enabled without PMP Date: Wed, 22 Feb 2023 15:52:00 -0300 Message-Id: <20230222185205.355361-6-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::32b; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x32b.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: 1677092070319100001 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 Reviewed-by: LIU Zhiwei --- 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 13e55ec5bd..aec7830c44 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.2 From nobody Sat May 18 22:54:11 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=1677092015; cv=none; d=zohomail.com; s=zohoarc; b=LO+glRD4jZbEJ7KG9MlagSr7qeQZ9Im3XrKoJYbnDbSa3+ptHRGMJC2T/L8vS1nEWMf8eJ+VYuyAyoH1Q1Lcu/A/yE6s5U62w2DGdXwCxzRV+vFLJkCDEbnAukxCsvUSDJMhaBOhLTUjPIAebCR/3pbarsCMeYSldOv0/O1+Vvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677092015; 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=yDeC9W26Tqq62T+IG4dI73GqG8Ah45b+7FjvvmJyEXM=; b=Fzt/7gyft3I0DDFuQbgTimGjB7QBAQ7SV/KlOV8sxz2L5XDmZb97LWA/Qh6l6OWocfJ+Em3dr1R5dcxaw78VfBt1VQF6O0oXXdfrPtXefQ8g5RguUpZqPxzqSQG4mzsTaUjkUy9Gx0g32971nYHgn6hOJE9HePH9UTLmMU1LY68= 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 167709201527243.186406644628846; Wed, 22 Feb 2023 10:53:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuEL-0007E4-Vl; Wed, 22 Feb 2023 13:52:41 -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 1pUuEK-0007DG-NM for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:40 -0500 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUuEI-0004Nm-U4 for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:40 -0500 Received: by mail-ot1-x331.google.com with SMTP id a14-20020a056830100e00b00690ed91749aso1799411otp.7 for ; Wed, 22 Feb 2023 10:52:38 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 10:52:36 -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=yDeC9W26Tqq62T+IG4dI73GqG8Ah45b+7FjvvmJyEXM=; b=bRKq3z0wtjJsNBnxemXRLAXT/IOGNDDIAS5sFHejMQW13E0UXgk6X8ZB3yxQb+P+cM weIpHdC3+IynSXODGnqMq+0glWvBxzY72ccJsch3Ef2h5snzCjBsnBtzZbdbkgLlTXbQ rOYv9KJpWJPE29OqIUG8lJxcn6QrGrp7pf9IUMANOmhUAqC2IauN8DKwS8X0lCjZLz8K MwhMO2igNPC76Gts4xJ6+Jlu+W08nOgxHUuTPgcx5qMD9fcTOg8Rn+eATVuwkPY9MrVM IcSePMJcMyXOcfgsE059kH6kToo9wCS20TDTBOq3wz1axFR9oh5J3V17sr1t6by7hvUi x14A== 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=yDeC9W26Tqq62T+IG4dI73GqG8Ah45b+7FjvvmJyEXM=; b=Xh2fOfIo4w4qgvSQvrNhnp/vjpAiDx25Ckd8tz3plg+UebNs5av1RBMsdf27jiBI5k JPR5EiYRL+h0oPvZ1zelORppZdHrVcpFKz3x1Gk9/+rutKFrknD5YtRVpeE0n9PaKT7d f0yxFEokhgULUoDxUry05iucA8NPX9b2YQGeLGSNB7aAzajaI0lKMiHp2b2g39zTZ2e6 f399qYqdOCfsAYRiTrlWZHsvpZPpE3wd4hdvTpTVdbU2/gkhCu6TfICj65DCYI6dJ9Qn yE3Jwc3mrx/gH/l1UNQrQOC3GlIiykQ0VTqg1yV21/19BRYlSCf74Vfh+jzBUQYypjVx M1cA== X-Gm-Message-State: AO0yUKVBrm3PzEqmGwvFHDXUlz/4IuznAXTbmsAVmGNn3Wwsbt6FmaPr IXa4oM1rme8asmeDziXtvrd5mHuDI5knWB/j X-Google-Smtp-Source: AK7set+SjW5IJqKTCNNUc6TudQZOrebSD3Q+HUGRw5/toGZtPbviNR5AFnfGenbEr+IxuhuELwjRCA== X-Received: by 2002:a05:6830:44a1:b0:684:ac9d:1a17 with SMTP id r33-20020a05683044a100b00684ac9d1a17mr5670465otv.3.1677091957394; Wed, 22 Feb 2023 10:52: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, palmer@rivosinc.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v7 06/10] target/riscv: remove RISCV_FEATURE_EPMP Date: Wed, 22 Feb 2023 15:52:01 -0300 Message-Id: <20230222185205.355361-7-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::331; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x331.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: 1677092016326100002 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 Reviewed-by: LIU Zhiwei --- 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 aec7830c44..807a466f34 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 5295c2d701..d4da420912 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 e220c4a5fd..951327022d 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..aa4d1996e9 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.2 From nobody Sat May 18 22:54:11 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=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 From nobody Sat May 18 22:54:11 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=1677092008; cv=none; d=zohomail.com; s=zohoarc; b=L5i+F4QgnrU8uJABoH5ShVLpcD8AT35t0JyOTfOMn3MpjnLmN2Z3ug0Y7h0Pe2rkx7v81PW5/aDas4TBNWFzGqLThBRYi7sHn/tP+SlwYuGcv0QWBpUhHHFakxEO4901UFlzMvS2414xy3ygqEo4LaG1hAxdM2usHN43M/fNrYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677092008; 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=TEaF74M6WvRmSzL9d+AXXQnqIGKGvCuao150I2D5AIs=; b=n7gRMD9gsseuYiGdg+Z0uzvaJiGummvB8JgsbLNDD2l452IEEMTHb075WvTexsBgoinuBeBbhWtjj8P1qu4PPFlYf9Opqsfn+ivzo4jZN+DbIStYQv6u/1TB+J4Qg9NuS016L+oVOhiR19A00Esf8iMKljqLAIfn89mbWSgcY4g= 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 1677092008911312.5603232415408; Wed, 22 Feb 2023 10:53:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuES-0007KJ-1s; Wed, 22 Feb 2023 13:52:48 -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 1pUuER-0007Jw-3U for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:47 -0500 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUuEP-0004OX-LZ for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:46 -0500 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-1724d65d002so4291980fac.4 for ; Wed, 22 Feb 2023 10:52:45 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 10:52: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=TEaF74M6WvRmSzL9d+AXXQnqIGKGvCuao150I2D5AIs=; b=ZDMKsiAAvihgzqCIvfpEUHWilzLu+NXOtDeutimPOOuoQNAJbpyudz0GWjR5291RxY Uqt3GPWoyayhWxuVx+nq8TNkhrcYzkt+A8rj1WD68sJvWjmcMjSB/EhqVV1OpczDXVNk 0wdMQGgPOl8x4Ag2jQQKpEU7C9LlSmrEDgLwVa/MTmjwT6fTIZqimDlb3bEDeSn5ityh waA0ZQvNRNsqpfqZCloTeHYozIafiWvF2kUy3Y2N6DT0caBI+n7zen5q8bkWwUO2FA1U wU0eK7o3OJlmQVhnr8GZCcj0AIxvr7ITIMoQnxz5xLDsIhKPzRB1CrnuRmeuAD2GMOQO MJ2w== 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=TEaF74M6WvRmSzL9d+AXXQnqIGKGvCuao150I2D5AIs=; b=ObKKeDe0HTk7kbewMb1CdbwoOLsyFNEkbdloqqS5fDjEVr7abFjlPk1Z7YDGMt0frP FsXWueOmSfgHxcfn7nYA+KLZLxaL5yMfW79tvuD6lJX5i7/qA6tSWbsv5Kc4JlVG6E/B GBJMZO6syLEumLed0GoOuOoCqKeEpy7KAjKqHR0WbGyIYUDizfFdvstZ13+RgmuPv/p7 fU+ILK68o+vfQ8xwHA6mmghvV+b88DV++GHfycUfI+H78KLd9N1pAcq3XVeHvJnvbCkW t9HbcuAxATTCfbhxZG6uCwOJ/L8anAPDipS7PEtwgSBG53RU57Kwt4bYsUQ/rRyxDUZ0 8G0Q== X-Gm-Message-State: AO0yUKU1fUBIrkomVTyzQB7LUAWiwZNkupweuM7btgsN02aCGf21oM+g J78onP6hRvfkCHWar/vNkZZDD9fNGwbawt0f X-Google-Smtp-Source: AK7set+YlVpaxPtNZa9kFVj0Yz408D87QlJ9t6+vc3atYoQFSQMX4QOP8MwwdVH8ALJ/u3jZJpt5qw== X-Received: by 2002:a05:6870:1494:b0:163:2804:596d with SMTP id k20-20020a056870149400b001632804596dmr10030801oab.19.1677091963876; Wed, 22 Feb 2023 10:52: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, palmer@rivosinc.com, Daniel Henrique Barboza , Andrew Jones Subject: [PATCH v7 08/10] hw/riscv/virt.c: do not use RISCV_FEATURE_MMU in create_fdt_socket_cpus() Date: Wed, 22 Feb 2023 15:52:03 -0300 Message-Id: <20230222185205.355361-9-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::2a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x2a.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: 1677092010448100001 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 Reviewed-by: LIU Zhiwei --- 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.2 From nobody Sat May 18 22:54:11 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=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 From nobody Sat May 18 22:54:11 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=1677092047; cv=none; d=zohomail.com; s=zohoarc; b=JF5T0Gbwpnz4/RGel+aAA517OoNdhDRS/Nna6wnTy6ku0LS+MuxmDTQCPNVpesl32QXtUmt95XkhvUbRZEceMYYHQkUshskQ0IdcJ+e28eXxikOB+mBDBirRk2VAUjGOdrRbdxOoyRNoYtaJJ/bjH5ucquRQGk+RfP2XcdtMQ4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677092047; 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=JUJ8HI8MiTVtaRGy3i1ybf9oQwSyF1Q4b3hn/5uDxO0=; b=C72vi+CME187gg05p5gXxd+/vCm3irqJKnfhVEOMnYMRWP0zecQ3wIpukGg10paf4n8djCqZGcqwAKupzoylSaNBBSWnPesysUhNIv2hpRoOBqJWUZq3sinHwHVaARGvsPwXCfsTkfUrzjy+TGjicmjAPbNPkZTkhVTP3m5biJ0= 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 16770920470021013.3497068055999; Wed, 22 Feb 2023 10:54:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuEa-0007Mc-8S; Wed, 22 Feb 2023 13:52:56 -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 1pUuEY-0007M5-Oz for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:54 -0500 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUuEX-0004R7-5K for qemu-devel@nongnu.org; Wed, 22 Feb 2023 13:52:54 -0500 Received: by mail-oi1-x22c.google.com with SMTP id bq17so9065614oib.8 for ; Wed, 22 Feb 2023 10:52:52 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 10:52: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=JUJ8HI8MiTVtaRGy3i1ybf9oQwSyF1Q4b3hn/5uDxO0=; b=jsRoRNL0Uxrd+KCAQNTkSIkF6Gm++uJ4mLyW091d8t3zDAt08PVZXnYgkhYKqZ13bf 0YrS3r+kZ8SwSMWmcKpxGl//J4l84s/c+g+t/CahvoLLTsDm9gDep620MQTDVKnmii27 Smqr704fSBVev4VmDFQF5SXQom3zI5EcCeFgqEmqdE1WXhboucDL8mvLMus4vPXBQNXG qdzAR6tfot9pqjpRD6O20Mgg6PZJ8lFdMMmVAmWkZ0FGoX3J6UKcygYsaKV/JsX9rPRh 5mGYBBdJe5Ozfwmmpv2DR2ujIVhVTNY6yCFi+QKqNeMkISBxhWcfk39JojQUcEpmxzM3 sDIQ== 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=JUJ8HI8MiTVtaRGy3i1ybf9oQwSyF1Q4b3hn/5uDxO0=; b=ApbTmRA6WV4V2NYZ7S3JLOQjYKZDbFy8k0zdpE1TP20bYr1UE5EdoYY2yVISDZ5i1s Vzr28/4u0xgHa8wLRa0BPF8lt+aRw3xxNvOaDep2VnTIaulBJgOwNaCjRZU/R7CI0St/ YNDWECm6OB72qDtEYdgJwu0T6Bt9hLvCZBfYXAol8lBq9Zd0w2d78jTTrzynYX9JcXgT XabBoLQ2oPbe0jLqFE4azlBxGgCOZEYpHDNpsdNCkJoSXpvEMw8geKabYcJEQjo9a4kz xxwcD8xdDt6Jje2O5ijBJFyAKMMuw6BtPCPZQbh2X3g+F8pIhx13WfHz1Y/uk1fG63h5 ZZtg== X-Gm-Message-State: AO0yUKVdMsJqa3y4/6RNA/KgNmlCfh8Mkn9XMh/UrcImgS71xg6OoeqL pt3T7uZ64kAuU0bZu3TzPCd+fC5Jf2bRJt7J X-Google-Smtp-Source: AK7set9HOwER9V5uYQrjOrk9VjjJjPd4fvGn0qZOBICKPgBUevwKmuNQYV9ZIeb4FhH6yjTALUJu4A== X-Received: by 2002:a05:6808:189f:b0:37f:b133:91d9 with SMTP id bi31-20020a056808189f00b0037fb13391d9mr4120560oib.26.1677091970133; Wed, 22 Feb 2023 10:52:50 -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 10/10] target/riscv/cpu: remove CPUArchState::features and friends Date: Wed, 22 Feb 2023 15:52:05 -0300 Message-Id: <20230222185205.355361-11-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::22c; envelope-from=dbarboza@ventanamicro.com; helo=mail-oi1-x22c.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: 1677092048128100001 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 Reviewed-by: LIU Zhiwei --- 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 fb0f2afe0d..29a12acac1 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 @@ -525,16 +523,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.2