From nobody Sat May 18 21:00:23 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=1676552743; cv=none; d=zohomail.com; s=zohoarc; b=Nd2tKn+kFsPSBrSEwk472iRHQPmnEG++HbxQgamXdFKoCkv+OnkcENkvRxZaKmL7adUlq/KOwtTeOAx/lmKGwWgg0yqMbpJrBSWeD1cP1k/04F25Bg/xzWnXgwq8seQVsbBlkdMjOOrrYe+faFTO2xf8T2RKv0fejpJzUto8kE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676552743; 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=f88+yOPuLx3v7ygVDnzy/XRokhgMXFEeFf99sPFr+yo=; b=jTmg07mNHudXYcbQ/c8tdRhx5Qb0B08r5k1YXnisBlsUMh/J8h7ZbFPO3k6cpKnL4zoWe7kKR1ebROlqz6D6BNrfDMUem2I2KD9e46tZfscizHIj1D80PkdzWVn2+ETOC6WXWwOOO7nUdMjsqYoE91UZ3YadvPt0PxcDEVRkjkA= 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 1676552743097457.88918757600663; Thu, 16 Feb 2023 05:05:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdwe-0004I7-TE; Thu, 16 Feb 2023 08:05:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSdwb-0004HV-4a for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:01 -0500 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSdwZ-0001xS-F3 for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:00 -0500 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-16e55be7c76so2433278fac.6 for ; Thu, 16 Feb 2023 05:04:58 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c74-20020a4a4f4d000000b0051f97e8a1d5sm594315oob.35.2023.02.16.05.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 05:04:56 -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=f88+yOPuLx3v7ygVDnzy/XRokhgMXFEeFf99sPFr+yo=; b=J/LdNf+5Z5K1XpLbjAaVtfKYV2SY2D2rI6plWpS5Cb8nIKYTJ6iLRTX4QSLVLdv+Zl 0dgesIyp8mnyF+yXeqzHU8TalnHSviLo7ZmABC/5/i7ul7H87Ix1jyr5x9ZouiAhe9b+ bC75uZRPZ4j8bk0UCIbuKpxSJF/+FSISptAatsQ44lMzBtpPhX+KSnZKEvdf3LH9x3za pQv052E1sPskph02DKNqW3qh6MhvHy+G0+i1lDs3VQLVW3Urei3v0GEJLVnrbRTp1Aaj 1s/UCwJsARkbG2WO1Bnb5ybU7e7sfrm4ArM1eatUFc8q/WWSrCh0K0ruzs5e3p7P/qwq wt2Q== 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=f88+yOPuLx3v7ygVDnzy/XRokhgMXFEeFf99sPFr+yo=; b=KvEQ7MRxcjuTQskxMyBUrKHtq+FIDxbOsKLeciUXuJsKcHSJKNcodJ1qWejdyIHlTO weCUYg9puavhoxQaZrrhudsU3/CcfnO94B8CfBBdSSZLqCaQZe16iugbUIky9+i32ZdE PpFYzO3xbOpFUQKAS9UHjUFhMfYoz+n9pUBgGjze2zQ7EaAFIvdIjlooGYJdK6ECIbIs 8+9gyNrnvDeq4SntvMo3s98YbnW4jwb56jyz9MbIfQbOGB+BgMW5EgPKgjKD4p5ESyxU 1IMKI5XMOCtwDyi7aJR93C2adeoE3GGcMuGbZ8m5XhlpioWoE2zSITxzAIJ5AaQ/Pzzj s0pA== X-Gm-Message-State: AO0yUKX/O0oXdFVxcNah8rbuqjhG+EWF4A3AOQjgd0RISPdywZmDaOuE 0C5dzxtV0BZVgfcCtcsa6yYH37B9AXQbaB0O X-Google-Smtp-Source: AK7set+V+kqXbqRSM7uWSoWTAEV3x7kflSObmnzw5Ylyq7G2H1ECbkdYYBiC1JFzxWHtG/k/lpWd1g== X-Received: by 2002:a05:6870:e747:b0:16d:ee42:67d with SMTP id t7-20020a056870e74700b0016dee42067dmr2986060oak.40.1676552697205; Thu, 16 Feb 2023 05:04:57 -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, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v4 01/10] target/riscv: turn write_misa() into an official no-op Date: Thu, 16 Feb 2023 10:04:35 -0300 Message-Id: <20230216130444.795997-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216130444.795997-1-dbarboza@ventanamicro.com> References: <20230216130444.795997-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::36; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x36.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676552745335100003 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 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. It is important to mention that the spec says that MISA is a WARL (Write Any Read Legal) CSR, and having the write operations as a no-op is a valid spec implementation. Allowing the dormant code to write MISA can cause tricky bugs to solve later on. Given that we don't have a particularly interesting case of writing MISA to support today, the risks outweights the benefits. Let's make it official and erase all the body of write_misa(), making it an official no-op. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Bin Meng --- target/riscv/csr.c | 55 ---------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 1b0a0c1693..f7862ff4a4 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1329,61 +1329,6 @@ static RISCVException read_misa(CPURISCVState *env, = int csrno, static RISCVException write_misa(CPURISCVState *env, int csrno, target_ulong val) { - if (!riscv_feature(env, RISCV_FEATURE_MISA)) { - /* drop write to misa */ - return RISCV_EXCP_NONE; - } - - /* 'I' or 'E' must be present */ - if (!(val & (RVI | RVE))) { - /* It is not, drop write to misa */ - return RISCV_EXCP_NONE; - } - - /* 'E' excludes all other extensions */ - if (val & RVE) { - /* when we support 'E' we can do "val =3D RVE;" however - * for now we just drop writes if 'E' is present. - */ - return RISCV_EXCP_NONE; - } - - /* - * misa.MXL writes are not supported by QEMU. - * Drop writes to those bits. - */ - - /* Mask extensions that are not supported by this hart */ - val &=3D env->misa_ext_mask; - - /* 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; - } - - /* Suppress 'C' if next instruction is not aligned - * TODO: this should check next_pc - */ - if ((val & RVC) && (GETPC() & ~3) !=3D 0) { - val &=3D ~RVC; - } - - /* If nothing changed, do nothing. */ - if (val =3D=3D env->misa_ext) { - return RISCV_EXCP_NONE; - } - - if (!(val & RVF)) { - env->mstatus &=3D ~MSTATUS_FS; - } - - /* flush translation cache */ - tb_flush(env_cpu(env)); - env->misa_ext =3D val; - env->xl =3D riscv_cpu_mxl(env); return RISCV_EXCP_NONE; } =20 --=20 2.39.1 From nobody Sat May 18 21:00:23 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=1676552836; cv=none; d=zohomail.com; s=zohoarc; b=H8d3xi3u2uMINnKmKVzvimsJR6cefa2okRWEIbmtOChLN5DRElAkts6qUOTF9085HaAvDQVES8K819sfr5MJhVW5quVMmgDUQgFvsKJgzCOT4rzBpDbEPDLlPPqYwjth7mEbbzeZF+RbMiipXmWg2726OD1fsUNn4b7pv+QbQ6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676552836; 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=hK7hUX9DpCweRWw5pi7iDFzv4O4v8vKk9BPAoNwGEr4=; b=BN0+FnwHm53l8Vdv0QO9jnwEt5s57sk2EgN6h1n2ZhqqhxdWkIrN/ka64zGgkCZaNCm86ZGc3hc13zMP28xw5ug5Sl5TjWRY2Pf4bOyVMRTONCMld2nXSHtzmsP5O4JthQ3pkwg/3a2aWDfJbcK6JNn17e8h4Waxp3Te8IWZNGk= 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 1676552836743782.9203153059211; Thu, 16 Feb 2023 05:07:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdww-0004PD-4H; Thu, 16 Feb 2023 08:05:22 -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 1pSdwg-0004Ip-6C for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:08 -0500 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSdwc-00020d-Jk for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:05 -0500 Received: by mail-oo1-xc2a.google.com with SMTP id y17-20020a4ade11000000b0051762fdf955so204341oot.3 for ; Thu, 16 Feb 2023 05:05:02 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c74-20020a4a4f4d000000b0051f97e8a1d5sm594315oob.35.2023.02.16.05.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 05:05:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hK7hUX9DpCweRWw5pi7iDFzv4O4v8vKk9BPAoNwGEr4=; b=PwEP8PoUSUUhlc/r1rPXY07CJCpr2oV1HIRW+Zv0IYBNCrlpOPhrR3m3SrlKJOmoXm YJLFN1CWOloIVnL5jeGe3LZDPBsYoUkfK5lRJLcxpu7qa+a6peexpuVq7lppsPrTrBbA gqr6eNqJvuWZ9Krim9vE/EgRZPBFmzqLR/4ihNhsjGIIcPw2ryGAKl5h7SbTXR0ms3kP Op4p15V6aLj8LRuKdQkQELziv4ssYGrY71HtO9ByEcquAFhrqWIhij/7V8zk2ozeaZoE T4JBGTnvSVZZWMyxr/psgSGXCdCE0Z1IMv6l9ApgEtc779MX8Xm2bULPQ6eYZa8XNuE9 hb9w== 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=hK7hUX9DpCweRWw5pi7iDFzv4O4v8vKk9BPAoNwGEr4=; b=zanVL0U8bs/aJG8yb59Ba+lYcN5pZKBbi3jqP+NtzfZ04jH0fNKKlIEihTmNLxvm7W FrUKK8+bqLoDgNJP0uy08GVX+JUBDaefqGwmCDbC1B9662Rqj6/mUjZ36wRlmofY5PvF 3DPCZZrTjMFUuhj0W7bN20LZLOKrRWXexr53FZfQXNBYydNID5EcqtzR0NvZIkHWP1cd NqJTOaVQj/54negQHRKuyeMjQT6cmegVvJZqyL4l1XqIMewbsXUFYJtqUgQm54PGGmlH yKxUOsED7wF/UgCVM5l3WOZqCiI7db2wdJ/j3FnUJbuk6RAfZDGsGD4Kz7GT1C9kt16l 7N4w== X-Gm-Message-State: AO0yUKWkqwN6tlUGNUOaqg8qs4ngF56RN4Lpv2jDjf8YNBd7MG60ycHz fISvXWVrH/Zxg9XC6MsMLDfB+UNTs6ZQ+EBl X-Google-Smtp-Source: AK7set9BVhHVYEONygd6Qeq6Rf6V9idsQvUH69FFQp2/m+M0/CCjfiyDSc5twoBrKFx7YJk2Yh76ag== X-Received: by 2002:a4a:9871:0:b0:51a:9c6f:a7a9 with SMTP id z46-20020a4a9871000000b0051a9c6fa7a9mr2635761ooi.1.1676552700627; Thu, 16 Feb 2023 05:05:00 -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, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v4 02/10] target/riscv: remove RISCV_FEATURE_MISA Date: Thu, 16 Feb 2023 10:04:36 -0300 Message-Id: <20230216130444.795997-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216130444.795997-1-dbarboza@ventanamicro.com> References: <20230216130444.795997-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::c2a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2a.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: 1676552837814100001 Content-Type: text/plain; charset="utf-8" It's unused after write_misa() became a regular no-op. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Bin Meng --- target/riscv/cpu.h | 1 - 1 file changed, 1 deletion(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7128438d8e..01803a020d 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -89,7 +89,6 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, RISCV_FEATURE_EPMP, - RISCV_FEATURE_MISA, RISCV_FEATURE_DEBUG }; =20 --=20 2.39.1 From nobody Sat May 18 21:00:23 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=1676552792; cv=none; d=zohomail.com; s=zohoarc; b=k2KdglT745cPrhNZr8dW+2ddbvCUXdv7JC8R96UWnfUYIrv4MU3VUlr6oBlhpK39kfN0oVlBiJC6mKm5hWA92HmKFHBalRYU8DzgJCuIwyQeSRgPj6a6GT42qxIyP4/B9iMsNWiP+vcDrgaTYV01bTdO40EQ4c+R4qhXEsx2r7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676552792; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/ze670EFc4knKxHYmBNv1C1tJqYk4J5P+dEI+i7TEM8=; b=m/P2bpqXol4Rm4ScNnK2KRHiWyCqRD5F1u6xnkFxj7b0YB24PTrJYp8XYE6S4tiBquRrkb0yziCs1P7oMaxRiZkuyXeDAmz6L67T3/JhjuWeoq42nLGmLrOHeifJy+dz2rr7lmPS3K8GR++fTU5ad32nWbZdLxe+4UJ+cUX/cTE= 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 1676552792224201.1876511450099; Thu, 16 Feb 2023 05:06:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdww-0004Pv-BA; Thu, 16 Feb 2023 08:05:22 -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 1pSdwg-0004Iu-F7 for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:09 -0500 Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSdwe-0001zy-O5 for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:06 -0500 Received: by mail-oo1-xc31.google.com with SMTP id g13-20020a4ac4cd000000b0051f842ba672so204003ooq.4 for ; Thu, 16 Feb 2023 05:05:04 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c74-20020a4a4f4d000000b0051f97e8a1d5sm594315oob.35.2023.02.16.05.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 05:05:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/ze670EFc4knKxHYmBNv1C1tJqYk4J5P+dEI+i7TEM8=; b=Q6ZfqstKdSMCBt+AQrpSDkK+1RW2xGatL5kKb8IVMWR4o+sAbjgHtPQ4tcFJGVzowJ 98iC0QlG+SqQLkNJbK4R5YuNfr8aiC6hTY13M17TFXaZOKQGbX5svOPiyvjirM13iW6G IUA1J0OdKcyOmzRXkM7KaSrXeB2aigEy1qS8Ugg3aG87H3N3aFmT4Ud83z9qE06qzE+d O/XS7ZA2O+i4P1bdK70ISRYs3oOQWI9KDCO4c/crcwZzq4ShnLaiNgavJhkL8zPnWvx4 6663ruu6A1ZVF4KvzIxQqyVbb5FSdsAdaMHpJA6Q6Jq8i6cO00gHaQwg+7/1J9x+SUTm blEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ze670EFc4knKxHYmBNv1C1tJqYk4J5P+dEI+i7TEM8=; b=IepHSslKYsWKPJV+OJ1GsGevhoze1bBxtUBhuSv84V4Q2rizS9Y823e9g/Qiz4bDg1 5Vq33INhabYBATNhVTnTnRTUADEbIyhk8uEE/txxVw+9NDLP7h2Ft0jiFDxhopRppICR SNDUor3YnMr0sEjkT9Mx3jdTMtra4cJUPjNvQdOpNZaxV3Bz8sBbInJ6+DHO0VzkiP7U jb/8UT7IhsY5J0f8aS/Wh/mDoekRUvMSFL89f9Et59RUARqe8OjiSmC0GMZgVLF27XKm pXuEfTskRudH8b+8lgv4MvKVka78EEmoYULVoIC2r/A0KrzQ/ikdOqid+oAdLw37m/l1 vgHw== X-Gm-Message-State: AO0yUKVp554rPQPeiIpBeNVzbNSaooLoL5rZ4S+2D6xcUw0O5SKhxYn+ vzYv7bF8UQa67SiRkO5Dt8QY0LG8exzhc17o X-Google-Smtp-Source: AK7set8IpNStI+mC3jSdckhet/H/zyyD2NbrRka8JWail9/qNO4360WH8NBBVTBxC1u8M2YCjzsbZg== X-Received: by 2002:a4a:94c4:0:b0:51a:35de:d4c1 with SMTP id l4-20020a4a94c4000000b0051a35ded4c1mr2615202ooi.5.1676552703594; Thu, 16 Feb 2023 05:05:03 -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, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v4 03/10] target/riscv: introduce riscv_cpu_cfg() Date: Thu, 16 Feb 2023 10:04:37 -0300 Message-Id: <20230216130444.795997-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216130444.795997-1-dbarboza@ventanamicro.com> References: <20230216130444.795997-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::c31; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc31.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676552793539100009 Content-Type: text/plain; charset="utf-8" We're going to do changes that requires accessing the RISCVCPUConfig struct from the RISCVCPU, having access only to a CPURISCVState 'env' pointer. Add a helper to make the code easier to read. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 01803a020d..368a522b5b 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -653,6 +653,11 @@ static inline RISCVMXL riscv_cpu_mxl(CPURISCVState *en= v) #endif #define riscv_cpu_mxl_bits(env) (1UL << (4 + riscv_cpu_mxl(env))) =20 +static inline RISCVCPUConfig riscv_cpu_cfg(CPURISCVState *env) +{ + return env_archcpu(env)->cfg; +} + #if defined(TARGET_RISCV32) #define cpu_recompute_xl(env) ((void)(env), MXL_RV32) #else --=20 2.39.1 From nobody Sat May 18 21:00:23 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=1676552790; cv=none; d=zohomail.com; s=zohoarc; b=jYeILwdriKrXHucIOmAMLJGaOtl5wKHJoKGy7XfJhAinuB/fiwwBHSaItXsrBsOA6aJ3fpAZyyUcf8a7uyYEzlQn3h0ce9vKxiiu4Fc2AqfWx7iHNZ7WfMsX+h+pjK+inats4STzD4jfFT+qvGu+gG8km08rylgmyaz7ZCIR3Jk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676552790; 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=zeLc19rvg9BNm7u7QZh1b1577pYy8eBeQfNkS++7q68=; b=I6s88SySY6TNQWjIxfWzpHjochxwIwwuN9KkFPBAaAQzKY2ZxGHsvY8x7rxrygp0+9OhcC1itg/sEJrnn9cooRgyHlx7s18QhXJAHW/+KkU+w8mmFaGWeP8lTSJJaQR1/f6o2VeASbNtrmh+hZER01AZISyhhQrG0M6zbtzKY1Q= 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 1676552790152797.4556909083009; Thu, 16 Feb 2023 05:06:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdwo-0004Lz-Hg; Thu, 16 Feb 2023 08:05:15 -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 1pSdwm-0004KC-2s for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:12 -0500 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSdwk-0002CZ-At for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:11 -0500 Received: by mail-oo1-xc2f.google.com with SMTP id r192-20020a4a37c9000000b00517677496d0so199828oor.13 for ; Thu, 16 Feb 2023 05:05:08 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c74-20020a4a4f4d000000b0051f97e8a1d5sm594315oob.35.2023.02.16.05.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 05:05:06 -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=zeLc19rvg9BNm7u7QZh1b1577pYy8eBeQfNkS++7q68=; b=Q43FJsdCTcuMUuVaJCtZrsTu/ThCKaXN3hVBdSB93P4ccqN2jcXt75HAMRYhYqKQ1t txhh6lTHVubdoHOtnEZAYsxRXKYzKIrEjSj60kAdd+GgmEq3aC8rIS4DYwuH6wQ1ZggQ d7+H+0fRGVgqqx19eYLaejCCwtscuU8LJ+P7XHSZU1gtkDYUYfVz1zOvUxyt2kzuR5Hv 2wkw5TJ1WImYVTYP3eiEPorbAsQ/GFZ1RjM/3/52acCFC2oixu2gPansS9wTi81VemyC yc+sl5a6c/pnJmqn6LR2Wfew8kV7rFw8d2JnRMw0HPLKfbD6op0eaUyKJoKVcxaz2cAa eNDg== 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=zeLc19rvg9BNm7u7QZh1b1577pYy8eBeQfNkS++7q68=; b=f5q3cKhybAa3/YcmgJSaw/THe6fsUOtRymfZM23Qq3hPSfRHdmh8HjIDA1s2y7T8OE BcP4uLfw0xxSrGCy6mzN5VvKr0atgB+2aUiI5NvsgOcnFfRoe0XxpX+3mTW4r88jx/D1 TgbiFFXZNWZvZCddOcfrjcpI1IeDlG46z4OdC/jCBDLlGkfBf/CUCB6utkq9/fQSxjx8 RlaVmPQC2xJM8DKt0w1PvtfTAbnEabPhGO7e0urxjnI6Mh0zZb/U9GOm29mX74VJr/HI D5bwHM+IyNEDGpDjQh/Hhewf6cF9ZkSYADn7u3dl+3JebuWhlqTG3sTvJiTLb51fW7EF xVjw== X-Gm-Message-State: AO0yUKVF7OVLYpqMdPNgGy3Dw+k0CD3fc6FjJBd+lJCKDJKPGQTku6V5 sH4fMtibcVcZmVz9H7/8Uyli2MMSoqqpE3tH X-Google-Smtp-Source: AK7set9+Nu0mNXuZizOU2I8fAQFO83E9OjuhJjFB33Sz1rc74IQZKbxzGhq9iRzTmJG9TjJ5DGnqCQ== X-Received: by 2002:a4a:9669:0:b0:516:f374:443f with SMTP id r38-20020a4a9669000000b00516f374443fmr2272182ooi.8.1676552706797; Thu, 16 Feb 2023 05:05:06 -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, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v4 04/10] target/riscv: remove RISCV_FEATURE_DEBUG Date: Thu, 16 Feb 2023 10:04:38 -0300 Message-Id: <20230216130444.795997-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216130444.795997-1-dbarboza@ventanamicro.com> References: <20230216130444.795997-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::c2f; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2f.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: 1676552791534100005 Content-Type: text/plain; charset="utf-8" RISCV_FEATURE_DEBUG will always follow the value defined by cpu->cfg.debug flag. Read the flag instead. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 6 +----- target/riscv/cpu.h | 1 - target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 2 +- target/riscv/machine.c | 3 +-- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 93b52b826c..e34a5e3f11 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -637,7 +637,7 @@ static void riscv_cpu_reset_hold(Object *obj) set_default_nan_mode(1, &env->fp_status); =20 #ifndef CONFIG_USER_ONLY - if (riscv_feature(env, RISCV_FEATURE_DEBUG)) { + if (cpu->cfg.debug) { riscv_trigger_init(env); } =20 @@ -935,10 +935,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error = **errp) } } =20 - if (cpu->cfg.debug) { - riscv_set_feature(env, RISCV_FEATURE_DEBUG); - } - =20 #ifndef CONFIG_USER_ONLY if (cpu->cfg.ext_sstc) { diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 368a522b5b..7326aaed27 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -89,7 +89,6 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, RISCV_FEATURE_EPMP, - RISCV_FEATURE_DEBUG }; =20 /* Privileged specification version */ diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index ad8d82662c..4cdd247c6c 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -105,7 +105,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ul= ong *pc, flags =3D FIELD_DP32(flags, TB_FLAGS, MSTATUS_HS_VS, get_field(env->mstatus_hs, MSTATUS_VS)); } - if (riscv_feature(env, RISCV_FEATURE_DEBUG) && !icount_enabled()) { + if (cpu->cfg.debug && !icount_enabled()) { flags =3D FIELD_DP32(flags, TB_FLAGS, ITRIGGER, env->itrigger_enab= led); } #endif diff --git a/target/riscv/csr.c b/target/riscv/csr.c index f7862ff4a4..90dc28e22e 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -437,7 +437,7 @@ static RISCVException epmp(CPURISCVState *env, int csrn= o) =20 static RISCVException debug(CPURISCVState *env, int csrno) { - if (riscv_feature(env, RISCV_FEATURE_DEBUG)) { + if (riscv_cpu_cfg(env).debug) { return RISCV_EXCP_NONE; } =20 diff --git a/target/riscv/machine.c b/target/riscv/machine.c index c6ce318cce..4634968898 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -226,9 +226,8 @@ static const VMStateDescription vmstate_kvmtimer =3D { static bool debug_needed(void *opaque) { RISCVCPU *cpu =3D opaque; - CPURISCVState *env =3D &cpu->env; =20 - return riscv_feature(env, RISCV_FEATURE_DEBUG); + return cpu->cfg.debug; } =20 static int debug_post_load(void *opaque, int version_id) --=20 2.39.1 From nobody Sat May 18 21:00:23 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=1676552794; cv=none; d=zohomail.com; s=zohoarc; b=HaLKmbH6RQiiXX8oUYGz2X4uy3Ioqx0wkaxh8SoWlm/OaxdODVlW62YOSXvTN4Omrma3vuCo4CZV7sQTPwbaL5BVwKrotJr3VSZAIBggxFqWQ+xVwYQXj5ojcm6ZllrhWm5ywdd0XAp8b0SHm0FxiXFppTNTUHaFsL9rdDfwoeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676552794; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bzgUQCLPgU6X7MZ2uleR0+KefuKd7NhosDsVObTIs/M=; b=KO+2YK9sKOkJnmTSMbKmIEAOAxiSDj2v4noRBwYfSl8WLzpxfDlwZTDqZG9tMw6grtorFKwWJsmjznUvNuCLmtSB7q09nO5qShQsUHYUsYMvEMspsqarED8jOKsY1mEHlihCTlkqeL2CdHAHmXauyUxrItkUSxw85UUBk11RDpY= 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 1676552794962824.9087005938378; Thu, 16 Feb 2023 05:06:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdwy-0004R7-Jj; Thu, 16 Feb 2023 08:05:24 -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 1pSdwn-0004Kt-5L for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:13 -0500 Received: from mail-oo1-xc33.google.com ([2607:f8b0:4864:20::c33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSdwl-0002CK-3X for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:12 -0500 Received: by mail-oo1-xc33.google.com with SMTP id z25-20020a4ad1b9000000b00517affa07c0so201815oor.7 for ; Thu, 16 Feb 2023 05:05:10 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c74-20020a4a4f4d000000b0051f97e8a1d5sm594315oob.35.2023.02.16.05.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 05:05:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bzgUQCLPgU6X7MZ2uleR0+KefuKd7NhosDsVObTIs/M=; b=PKgnkpGsaShJmPV4MGbZVSEl0sntGgP7dqF4BjeK6h4MGQ1AxqhMaC8Jj7w6GwdNmU f1gLVjV7GAOV0e57SvlviBJja4ExO3KcFDK3HJjWkOvktUcmPzRqAhxRc78hPDQ4HFV+ I5k/YwvtsmBNI9UIuQJJ/17x3C0wypPKh76i0Bgl6Tr5HK1F81EOQW3z0L7SBvCQ6nGB ZgcHJZCBzC3yTbTWA5GBBpPYKnEmlba52x8MSEP81amrr6Nzcmdi0KxkMyCwb/o5KjEj Tv+0hV7A3IEEYcS07hKP3el1hn7xs4UTGA81W7AlMlvSj6s3UpdAqx2GJlJbl/M1AFPu AV1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bzgUQCLPgU6X7MZ2uleR0+KefuKd7NhosDsVObTIs/M=; b=TGgPosPozclZqgA5mU/kexpqrc6hvK8guS0nvuVdSxjHzI11PODZ+Ojx/DcaoMuhA2 RzX1QUmfHsnHvGmm8IGKRozlXUIkLAoKroaBY7UTZ7YL+OyzvHUqL5m5mpRJwqH8CSBr aReB/rSAHid/IibkUH5S7g974vAjVK7OyhirfkdO+soBsVVffAfsynZKnJ4oXyTEbHl/ 5msFRwgH/H+Jcnnt5pVcUDuffuJDh2nD4GtTUzM9wKedxZ4in22ANPBfM15m6CL/HUIN 4KRZsQ2FcZWe3qao/io/uyOYBThsojzOGyC3csQZWII3zDAe6GfXvYIfdJnhpuQaBOET xrxQ== X-Gm-Message-State: AO0yUKVjS7z4EItfR07OPqADdVA6NJPKnsK48oPfKQJ/pu18YB0r4qxe Gt0K1VScMzwKJKDD94ZYXf+dG0vQY2u3bUsa X-Google-Smtp-Source: AK7set9AwnQaOt03vuyttS9V2szt4NQqrvgz9uKePE3L5LJ4Z5uKR6Exjtj2xA61PTm1M5jzJdmhsA== X-Received: by 2002:a4a:d792:0:b0:51a:32b0:9601 with SMTP id c18-20020a4ad792000000b0051a32b09601mr2632528oou.4.1676552710066; Thu, 16 Feb 2023 05:05:10 -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, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v4 05/10] target/riscv/cpu.c: error out if EPMP is enabled without PMP Date: Thu, 16 Feb 2023 10:04:39 -0300 Message-Id: <20230216130444.795997-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216130444.795997-1-dbarboza@ventanamicro.com> References: <20230216130444.795997-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::c33; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc33.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676552795516100013 Content-Type: text/plain; charset="utf-8" Instead of silently ignoring the EPMP setting if there is no PMP available, error out informing the user that EPMP depends on PMP support: $ ./qemu-system-riscv64 -cpu rv64,pmp=3Dfalse,x-epmp=3Dtrue qemu-system-riscv64: Invalid configuration: EPMP requires PMP support This will force users to pick saner options in the QEMU command line. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index e34a5e3f11..4585ca74dc 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -925,13 +925,18 @@ static void riscv_cpu_realize(DeviceState *dev, Error= **errp) =20 if (cpu->cfg.pmp) { riscv_set_feature(env, RISCV_FEATURE_PMP); + } + + if (cpu->cfg.epmp) { + riscv_set_feature(env, RISCV_FEATURE_EPMP); =20 /* * Enhanced PMP should only be available * on harts with PMP support */ - if (cpu->cfg.epmp) { - riscv_set_feature(env, RISCV_FEATURE_EPMP); + if (!cpu->cfg.pmp) { + error_setg(errp, "Invalid configuration: EPMP requires PMP sup= port"); + return; } } =20 --=20 2.39.1 From nobody Sat May 18 21:00:23 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=1676552839; cv=none; d=zohomail.com; s=zohoarc; b=e266KYoaHitMffhLeGQvnZg2ShJ2Cla5XtEEf+lpaeOfS1iw3gc2krcYiHopIU8zhRmh/Yrs9a/CPxKibIVCG/FRBBPo8/yae5nhRGtseUly0s4EJ9I8Ps8BkC2mgYwuSEu0j1Mcl01nVxBBKqv3rIGDYjhE2B4B0QEqkWBUaIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676552839; 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=Wh23YR+MTb3Z95gd9Zx/XoNgfzFVu0diZGWAULwkKw8=; b=dNfifwfPBcssRAITJ3/C7xFfxespQCaXYdaLqFxGyGByUPpZvbOyuMVWASi2+Wq8JAucwcDAg0hBexluLm7C+mtoQwGTPxOX/Goo4s5e5vgTIo61gbLXBr+BnJN4+vmqU/oHUdWFk92QP2780c16iT9CbqvlDKBa+uKTdmEgfdA= 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 1676552839116517.6457576322434; Thu, 16 Feb 2023 05:07:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdwz-0004Rm-Bw; Thu, 16 Feb 2023 08:05:25 -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 1pSdwr-0004Mm-R8 for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:19 -0500 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSdwp-0002EC-Kg for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:17 -0500 Received: by mail-oo1-xc36.google.com with SMTP id j22-20020a4ad6d6000000b0051fcc9bff19so199940oot.12 for ; Thu, 16 Feb 2023 05:05:14 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c74-20020a4a4f4d000000b0051f97e8a1d5sm594315oob.35.2023.02.16.05.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 05:05:12 -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=Wh23YR+MTb3Z95gd9Zx/XoNgfzFVu0diZGWAULwkKw8=; b=N8EwJnMI0B321r/4ruvmro5IaPtImwHneIKRD2MG5hZRE/WBHtZF/sXL6VUOvuIZlB VSRtvgrQWM9FnexXXfti5r6wSNCoxZBB43aZDQ2zlpmuOXlKh0+4H6zSO2zKYcu1sUXT y6gP1EgO9FWbNq65mrkLhe5lDihzuM83P1d//9UBPAReVFEDz3ASAM2heGduDVbX5CzT BAc2ujTopSfToQyU5+iu21I9d6+rR+iaC513bnvIALa+juzFXbTJH90pc3mlOUQRUoGz tLyz7NBOvADQ6v38XNY5v9aco2nqbtBzTxtdiqt3h67wjd5dvIrmJeHyVDovaaYTd+O5 DxBw== 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=Wh23YR+MTb3Z95gd9Zx/XoNgfzFVu0diZGWAULwkKw8=; b=mBRDh1T261DI6lNk3af8rAc+RNNfc3hQfYiaUNqoeggj3FTufDwqjx8+2alM2gWpXY 98eu7EUJ8CqCOtDx/BrevoYRp4qyFey8nvcVWzyorxcFuqdYSAvRR38kwkBsqJCgIKhL khShkFq06tRntatahZ3CoaKXsH79uO6FlWKt/1b4Q7Nnn+2d2OIZdKTld2A2oGHVBlq+ GvZpWkpbeja0Nd1VxM9x8Fsh2Ymn0oGWewmJtQuXYYmwhPIypw/vsi+tqFifSnL4mG7p du4OUKvMiemSeAAipeimtOoF1icKpWFmbhegoYHLvRwKU7Zi76J3EU6Mh1yE48Askw5d xI4g== X-Gm-Message-State: AO0yUKVjR3aMxgBCaB0bguNhmITPbpsVJ3I6jT/fDkIuUHqIxYiBIZIr 2ht8lnk+zwoEJZtsEV2H103+oW6b+uf4BRD/ X-Google-Smtp-Source: AK7set87CFOxrAZL7IGU8J6DotizKL5svnJWCEjY+3EqKaB1Rnz4XHdGmTymsdaxCvP5AN4MCLznww== X-Received: by 2002:a4a:9871:0:b0:51a:9c6f:a7a9 with SMTP id z46-20020a4a9871000000b0051a9c6fa7a9mr2636105ooi.1.1676552713230; Thu, 16 Feb 2023 05:05:13 -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, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v4 06/10] target/riscv: remove RISCV_FEATURE_EPMP Date: Thu, 16 Feb 2023 10:04:40 -0300 Message-Id: <20230216130444.795997-7-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216130444.795997-1-dbarboza@ventanamicro.com> References: <20230216130444.795997-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::c36; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc36.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1676552839748100005 Content-Type: text/plain; charset="utf-8" RISCV_FEATURE_EPMP is always set to the same value as the cpu->cfg.epmp flag. Use the flag directly. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 10 +++------- target/riscv/cpu.h | 1 - target/riscv/csr.c | 2 +- target/riscv/pmp.c | 4 ++-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 4585ca74dc..71b2042d73 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -927,17 +927,13 @@ static void riscv_cpu_realize(DeviceState *dev, Error= **errp) riscv_set_feature(env, RISCV_FEATURE_PMP); } =20 - if (cpu->cfg.epmp) { - riscv_set_feature(env, RISCV_FEATURE_EPMP); - + if (cpu->cfg.epmp && !cpu->cfg.pmp) { /* * Enhanced PMP should only be available * on harts with PMP support */ - if (!cpu->cfg.pmp) { - error_setg(errp, "Invalid configuration: EPMP requires PMP sup= port"); - return; - } + error_setg(errp, "Invalid configuration: EPMP requires PMP support= "); + return; } =20 =20 diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7326aaed27..c87e50e804 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -88,7 +88,6 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, - RISCV_FEATURE_EPMP, }; =20 /* Privileged specification version */ diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 90dc28e22e..3a2e85918a 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -428,7 +428,7 @@ static RISCVException pmp(CPURISCVState *env, int csrno) =20 static RISCVException epmp(CPURISCVState *env, int csrno) { - if (env->priv =3D=3D PRV_M && riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (env->priv =3D=3D PRV_M && riscv_cpu_cfg(env).epmp) { return RISCV_EXCP_NONE; } =20 diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 4bc4113531..bb54899635 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -88,7 +88,7 @@ static void pmp_write_cfg(CPURISCVState *env, uint32_t pm= p_index, uint8_t val) if (pmp_index < MAX_RISCV_PMPS) { bool locked =3D true; =20 - if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (riscv_cpu_cfg(env).epmp) { /* mseccfg.RLB is set */ if (MSECCFG_RLB_ISSET(env)) { locked =3D false; @@ -239,7 +239,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *e= nv, target_ulong addr, { bool ret; =20 - if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (riscv_cpu_cfg(env).epmp) { if (MSECCFG_MMWP_ISSET(env)) { /* * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set --=20 2.39.1 From nobody Sat May 18 21:00:23 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=1676552867; cv=none; d=zohomail.com; s=zohoarc; b=V8BnLUw1/YTrk/hp8CwZe9hRchgG9geC5SqAH3rdcrgFkGeZPyqkua9oHe9FQN/6PT6VehwwkuXV2524oO65YDaLA2f2redAbPNlPUO3/6cMpsbj6Cz6fAqmaN82CG04V6c52a8zVPSBe0bc46WBYINnaqcQ+IKdtPIF3xdw1Ow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676552867; 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=KEoLHmo0Wwd1VEBIJTRfk11UDfKznhZCWuv+sKrLWfU=; b=A31pCeRIKH1jHzLZOqYHdhMh6UkfGPenjYjiOt5P5Pp1BJtZpyord7upy8u4P3rn4pR/8a5me+A0Qa67fFgkdBHc5KSSWDF3WS7bZTqe4lf8Jd31gwGyRXINFFMQp4rifTpDP91IMzn4eC8zX0A6hwIsnxFc8HvX+Kx2JP2YTzY= 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 1676552867928636.6500311868602; Thu, 16 Feb 2023 05:07:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdx1-0004Sg-45; Thu, 16 Feb 2023 08:05:27 -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 1pSdwt-0004PO-PH for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:22 -0500 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSdwr-0002Eb-Rs for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:19 -0500 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-16cc1e43244so2381963fac.12 for ; Thu, 16 Feb 2023 05:05:17 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c74-20020a4a4f4d000000b0051f97e8a1d5sm594315oob.35.2023.02.16.05.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 05:05:15 -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=KEoLHmo0Wwd1VEBIJTRfk11UDfKznhZCWuv+sKrLWfU=; b=ZtwfDRudZ7HYleIYYH/Jms14FvduGSmcAyfoP10m898CDOCiLQkfqRFNO8+vC+0buM yefW2NC8TSvihrRUDhTMibXxsQidRZ7yxyEorZ5Em/xLdt+ewhjp9I9U4xJOsk11mYol 5Cak5ww8Upt3qakyy/K5x2mdmZqvPTLBtDa0XZZptm5Dcmf9cdhXYnDEWxBjbcjZh0/w yTfakWLJcF/fcv5gdFx2RmfMUqPOksPVwE+kH5j5tJbpftxlJFpsDEb3qHeBbaSgjQTk 9Pd7NYWHey5JzdFGOzXz3j2sudbSXXvfh0T+fsgpEetaV5sbfRGTCdlgEf3xtQqdBtYE 7yLg== 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=KEoLHmo0Wwd1VEBIJTRfk11UDfKznhZCWuv+sKrLWfU=; b=qaFdXhzcZKJpD0Pcp0xj408Fmkh21ikLAJC9+onzaZil6eGpqz6HNBUi5P1JCiuDso 7Iz2MAJYjZkPv/jcuxWKhah/wN4KUgg533kNDe9NUK9YWhQt3TwqlK+WzI/jfZKVj4B/ wfx4su5G6nUYCmzREP6L+Q2zkehWgxl8XW8dee+cir8OMEq2mO5pvvdJf+Z7FQdQs0dO 1uLL5BeORZilgkPzEKgsMVoI5+Is01lr+1CD80gf52NgvVB9buB/7PnDExur2hHYqZiy RPCc/nb5pE9v4tISUXNFe3QvyqQ8bM7qNZp+wfMEyBTbP2ErjJwdDzpb/Xmw9QoZXGzd 5VFw== X-Gm-Message-State: AO0yUKUK1iKsw+0c7sMq8Vn5RiTfH9ewR5tTxwKnfS66iqTnjucS1rDM +xcjHRwAEm6Cll5xDIkS9dx+7DAEh5/80l2Z X-Google-Smtp-Source: AK7set8ZsC50GtJh2KKHUefwEaJzv+x+NX3GpGJPEAE919S192xrXLozQsel29ibOo9P3NR0Jja5bw== X-Received: by 2002:a05:6870:7027:b0:163:4e13:cd90 with SMTP id u39-20020a056870702700b001634e13cd90mr3568563oae.26.1676552716104; Thu, 16 Feb 2023 05:05:16 -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, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v4 07/10] target/riscv: remove RISCV_FEATURE_PMP Date: Thu, 16 Feb 2023 10:04:41 -0300 Message-Id: <20230216130444.795997-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216130444.795997-1-dbarboza@ventanamicro.com> References: <20230216130444.795997-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::2b; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x2b.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: 1676552869928100003 Content-Type: text/plain; charset="utf-8" RISCV_FEATURE_PMP is being set via riscv_set_feature() by mirroring the cpu->cfg.pmp flag. Use the flag instead. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 4 ---- target/riscv/cpu.h | 1 - target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 2 +- target/riscv/machine.c | 3 +-- target/riscv/op_helper.c | 2 +- target/riscv/pmp.c | 2 +- 7 files changed, 5 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 71b2042d73..7b1360d6ba 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -923,10 +923,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error = **errp) riscv_set_feature(env, RISCV_FEATURE_MMU); } =20 - if (cpu->cfg.pmp) { - riscv_set_feature(env, RISCV_FEATURE_PMP); - } - if (cpu->cfg.epmp && !cpu->cfg.pmp) { /* * Enhanced PMP should only be available diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index c87e50e804..bd7ab5fceb 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -87,7 +87,6 @@ so a cpu features bitfield is required, likewise for optional PMP suppo= rt */ enum { RISCV_FEATURE_MMU, - RISCV_FEATURE_PMP, }; =20 /* Privileged specification version */ diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 4cdd247c6c..15d9542691 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -706,7 +706,7 @@ static int get_physical_address_pmp(CPURISCVState *env,= int *prot, pmp_priv_t pmp_priv; int pmp_index =3D -1; =20 - if (!riscv_feature(env, RISCV_FEATURE_PMP)) { + if (!riscv_cpu_cfg(env).pmp) { *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TRANSLATE_SUCCESS; } diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 3a2e85918a..a8a7d0aa34 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -419,7 +419,7 @@ static int aia_hmode32(CPURISCVState *env, int csrno) =20 static RISCVException pmp(CPURISCVState *env, int csrno) { - if (riscv_feature(env, RISCV_FEATURE_PMP)) { + if (riscv_cpu_cfg(env).pmp) { return RISCV_EXCP_NONE; } =20 diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 4634968898..67e9e56853 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -27,9 +27,8 @@ static bool pmp_needed(void *opaque) { RISCVCPU *cpu =3D opaque; - CPURISCVState *env =3D &cpu->env; =20 - return riscv_feature(env, RISCV_FEATURE_PMP); + return cpu->cfg.pmp; } =20 static int pmp_post_load(void *opaque, int version_id) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index 48f918b71b..f34701b443 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -195,7 +195,7 @@ target_ulong helper_mret(CPURISCVState *env) uint64_t mstatus =3D env->mstatus; target_ulong prev_priv =3D get_field(mstatus, MSTATUS_MPP); =20 - if (riscv_feature(env, RISCV_FEATURE_PMP) && + if (riscv_cpu_cfg(env).pmp && !pmp_get_num_rules(env) && (prev_priv !=3D PRV_M)) { riscv_raise_exception(env, RISCV_EXCP_INST_ACCESS_FAULT, GETPC()); } diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index bb54899635..1e7903dffa 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -265,7 +265,7 @@ static bool pmp_hart_has_privs_default(CPURISCVState *e= nv, target_ulong addr, } } =20 - if ((!riscv_feature(env, RISCV_FEATURE_PMP)) || (mode =3D=3D PRV_M)) { + if (!riscv_cpu_cfg(env).pmp || (mode =3D=3D PRV_M)) { /* * Privileged spec v1.10 states if HW doesn't implement any PMP en= try * or no PMP entry matches an M-Mode access, the access succeeds. --=20 2.39.1 From nobody Sat May 18 21:00:23 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=1676552828; cv=none; d=zohomail.com; s=zohoarc; b=IlwtooFhIhtar7aNlxRzpWSL9LnL7TeZkm4Zd+fbwS4S0Hb3DWrIVr3Xf9GllXLDqmBSKr4mZxpBC/tITTHDW+Rv9ust1EL+moVoIU5I7f5KHjL1vIAVtETZe/AgH1p0LkthOGM4r285RUTaPXc+fJOFnpmFDnwekLvRQkvms+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676552828; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Rhjy4ZuFr2J/YQsYfjypiNp1FTwn/nVolIeKKoKX5g0=; b=bbgViHPeuQqyzngQMCYMCvx1yirP2b1TG0RQS4tqouzRUEazPeGd3K9OKEnvy+T6rCThlFNc0OMRsR+2aRYSzdwUAWRZERV651E4gBF6jGXU3akMJgZg5VamK+eTAZXR0dgSzpexbDLjNUi9d+svaA3W/UOhQ4umiEIJBvrHJVs= 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 1676552828009627.0586147484623; Thu, 16 Feb 2023 05:07:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdx5-0004Tz-4x; Thu, 16 Feb 2023 08:05:31 -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 1pSdww-0004QK-RU for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:22 -0500 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSdwu-0002FV-JA for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:22 -0500 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-15f97c478a8so2376507fac.13 for ; Thu, 16 Feb 2023 05:05:20 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c74-20020a4a4f4d000000b0051f97e8a1d5sm594315oob.35.2023.02.16.05.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 05:05:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Rhjy4ZuFr2J/YQsYfjypiNp1FTwn/nVolIeKKoKX5g0=; b=ojPAbb5G93ZpFTO5nAompoxnSBCg6hpGvRUYFbQ83iAhT3NxnAff99RPPb+y4k7znp 5UaTplX1t1cGk6HahVAmdMtD1IKTFS0yLFNWxZ+gZ4nmH1CcVw2ncjzqeivsDNdKNFZJ wBDtQwwt7vvANWXnkKjKxoaeg/ybOhf4rrbCZyk0YU6VzStBSRy0lTG2SQhdupOgXEdq n6hjnNMpxEyQxwNZPo+hbg0xNpgZ1+VdD5LsIsNlrHSn6FzmJT/XCFLbfmTskxf7szL6 A4gUlwJQ4ZVP+3tEZwTmrQC625/Cp3iboCgQgkhyvy2FFFCrjEA8V2azb0LQS+X+6EqR U70Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rhjy4ZuFr2J/YQsYfjypiNp1FTwn/nVolIeKKoKX5g0=; b=ozTuderdiuFPAOFf5XZbdIJMswYJ0WRltZixLTTX11sKcXBsHwBuseqMJ/PI0O4bBF ojod9ZmFKS4EtGbJe8llE6RTC9ip6I5mMGj1Nt8HGHANd8mPuDlvZ8tz57U2qSS3YHY1 XYwmX9Oyz5gx/GU++rQBaGZX2m7ogLHkaexlkDkATsrOZp/4GcPlkFFGx2QpxCfUqczk FcTh8UFttDuvvlAhM3DKnISoHMv7f8Ac4sM7jbcnPg3xiYN+YGrwulmU+fN2YgB4W6WI v2bMD4+vCwyafE+3wCq96Dy7mllRSQV5AOLaVQe/WjOrUkRR+PUjck7upz5ogUataH2f S7TQ== X-Gm-Message-State: AO0yUKU6KSuDpd6oH08Q33SP7rncmNgL5E8m2YJkORKFtRadNdE637Jw mSbW2rWQRukmjibdoFfiCDSYFQ9SFq/wCBQl X-Google-Smtp-Source: AK7set94LQev3fimvrZwLMQNNg+oWY1lZu9uiqFhmc1zO6RPvcPnzZMo9GB2x0tl/y6/mcprx9x4dQ== X-Received: by 2002:a05:6870:1708:b0:16d:bbb9:9693 with SMTP id h8-20020a056870170800b0016dbbb99693mr3212199oae.57.1676552719096; Thu, 16 Feb 2023 05:05:19 -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, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v4 08/10] hw/riscv/virt.c: do not use RISCV_FEATURE_MMU in create_fdt_socket_cpus() Date: Thu, 16 Feb 2023 10:04:42 -0300 Message-Id: <20230216130444.795997-9-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216130444.795997-1-dbarboza@ventanamicro.com> References: <20230216130444.795997-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::2b; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x2b.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: 1676552829744100003 Content-Type: text/plain; charset="utf-8" Read cpu_ptr->cfg.mmu directly. As a bonus, use cpu_ptr in riscv_isa_string(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- hw/riscv/virt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 86c4adc0c9..49f2c157f7 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -232,20 +232,21 @@ static void create_fdt_socket_cpus(RISCVVirtState *s,= int socket, bool is_32_bit =3D riscv_is_32bit(&s->soc[0]); =20 for (cpu =3D s->soc[socket].num_harts - 1; cpu >=3D 0; cpu--) { + RISCVCPU *cpu_ptr =3D &s->soc[socket].harts[cpu]; + cpu_phandle =3D (*phandle)++; =20 cpu_name =3D g_strdup_printf("/cpus/cpu@%d", s->soc[socket].hartid_base + cpu); qemu_fdt_add_subnode(ms->fdt, cpu_name); - if (riscv_feature(&s->soc[socket].harts[cpu].env, - RISCV_FEATURE_MMU)) { + if (cpu_ptr->cfg.mmu) { qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type", (is_32_bit) ? "riscv,sv32" : "riscv,sv= 48"); } else { qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type", "riscv,none"); } - name =3D riscv_isa_string(&s->soc[socket].harts[cpu]); + name =3D riscv_isa_string(cpu_ptr); qemu_fdt_setprop_string(ms->fdt, cpu_name, "riscv,isa", name); g_free(name); qemu_fdt_setprop_string(ms->fdt, cpu_name, "compatible", "riscv"); --=20 2.39.1 From nobody Sat May 18 21:00:23 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=1676552788; cv=none; d=zohomail.com; s=zohoarc; b=Mrr6iO5NBZ4S2yTlDas/uuoC/wPXcSlYNamDY+2Xnwsg0S9s0j7+kjzDm5/fePA+0okmiWoQ8S4HVmn9iFR7ykppc9UNxdvWhK8+XFe7rCB3wrEfVChoFROyntqy7ZikfxZQ8Cqj3Bz6LmYV/sfEgB3RPZOnCS1vyfUBv4pKTmU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676552788; 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=NRLEkNqvUz0cMLYQBIVFpCwFlbI7QEbZbjKMJjm775U=; b=Rx7b/Q/nhvbvGVq80Ulb2v1ysAQzMQFkrPuMQFlCOJYrJIL2zoSs20CAj+jqoCfM+BhRSCCji/CmXwobhErSmVkSYqVJgV095CK/Wkqh8XONzfb8NsoilocqXRQ+xtZP2E7OFGStXxiZCTnPKmn+Yoe3d+tJrZWlvqJpHSubsEA= 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 16765527884051000.189851796033; Thu, 16 Feb 2023 05:06:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdxD-0004YW-8S; Thu, 16 Feb 2023 08:05: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 1pSdwz-0004S6-Dv for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05: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 1pSdwx-0002HD-Kz for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:25 -0500 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-16dcb07b805so2515872fac.0 for ; Thu, 16 Feb 2023 05:05:23 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c74-20020a4a4f4d000000b0051f97e8a1d5sm594315oob.35.2023.02.16.05.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 05:05:21 -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=NRLEkNqvUz0cMLYQBIVFpCwFlbI7QEbZbjKMJjm775U=; b=m2iWHDurloZfeaQs6B3qNDM6JBzlLKap3mP7xRv4o6AuVhF3evF0WdvxQKJ3/NIuc9 4KcrLpd9ouTV2SeMiEK5uBkPgptnQruQZmfGT4RFHBztTMerkt0YIB/bmAti75ojzTzE 2xRraYnH1HTsnHKWb5tvqzTB67FgdUrTlc7Kd+bPY7J9iZsAFDx44kLblvJoIZEUUL1S ZtMNXwS93SwBfc8c4fLsJNKXhXErdCdwuQnSs6LrZQXPMQkYUa8mhzNzDYphGWyNxVDx cCT9X/gQhp5fxJcYUTBglBSIeWK63huHdRnrUTYrUEBBmTteColNDT8AZbN4yw2hXHir mNoQ== 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=NRLEkNqvUz0cMLYQBIVFpCwFlbI7QEbZbjKMJjm775U=; b=2tpFFx7zA5eNG771Y21xEyxOHMy7aizaZRf8A0/WIC+0N69EwfUcdtDKT682rS3NN4 bNDz6FIdMfTVvEEcm7J+NKzu48h2kHY2p4ocRqFk06RRJnM2c6ivMmP5j/uA+hfX26TM Bfru2lgp7iQze2BzDNaeBPnJ6N0zMAKPuOqhYwg+wWUsUt6zIC49oLpPcWq/dPGkunm8 7gR7wloIUFtUugRC5PIYvPuXNQLjBA3PJf1ToDB6BXvqynHlfFHEyQhcOZzG0TEa5bi6 W1JUbTwvwKlIgfSNWuTZMPvIE8NdIPWFA2DDjrxqroR8/Z9nxSPz2Nn/STdFqHN9AETr 0OBg== X-Gm-Message-State: AO0yUKXA8CymiKXpYqGUNtcOzO6f5n57LqB//RFcJh6ZDni1s7F2eNrd Wp0o1efQVybNy71R1V9RtBlmql05h7HahTUn X-Google-Smtp-Source: AK7set9COB/TV5R2qMl0vc389ebIU7FXy0CNZ39m8yW+JdTirk4/C8TxfsDAnudt6tqqtFY4eQtSbw== X-Received: by 2002:a05:6870:4286:b0:16e:2d42:bb74 with SMTP id y6-20020a056870428600b0016e2d42bb74mr2885823oah.1.1676552722023; Thu, 16 Feb 2023 05:05:22 -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, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v4 09/10] target/riscv: remove RISCV_FEATURE_MMU Date: Thu, 16 Feb 2023 10:04:43 -0300 Message-Id: <20230216130444.795997-10-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216130444.795997-1-dbarboza@ventanamicro.com> References: <20230216130444.795997-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: 1676552789502100001 Content-Type: text/plain; charset="utf-8" RISCV_FEATURE_MMU is set whether cpu->cfg.mmu is set, so let's just use the flag directly instead. With this change the enum is also removed. It is worth noticing that this enum, and all the RISCV_FEATURES_* that were contained in it, predates the existence of the cpu->cfg object. Today, using cpu->cfg is an easier way to retrieve all the features and extensions enabled in the hart. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 4 ---- target/riscv/cpu.h | 7 ------- target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 4 ++-- target/riscv/monitor.c | 2 +- target/riscv/pmp.c | 2 +- 6 files changed, 5 insertions(+), 16 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 7b1360d6ba..075033006c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -919,10 +919,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error = **errp) } } =20 - if (cpu->cfg.mmu) { - riscv_set_feature(env, RISCV_FEATURE_MMU); - } - if (cpu->cfg.epmp && !cpu->cfg.pmp) { /* * Enhanced PMP should only be available diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index bd7ab5fceb..7ff4d90261 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -81,13 +81,6 @@ #define RVH RV('H') #define RVJ RV('J') =20 -/* S extension denotes that Supervisor mode exists, however it is possible - to have a core that support S mode but does not have an MMU and there - is currently no bit in misa to indicate whether an MMU exists or not - so a cpu features bitfield is required, likewise for optional PMP suppo= rt */ -enum { - RISCV_FEATURE_MMU, -}; =20 /* Privileged specification version */ enum { diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 15d9542691..e76b206191 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -796,7 +796,7 @@ static int get_physical_address(CPURISCVState *env, hwa= ddr *physical, mode =3D PRV_U; } =20 - if (mode =3D=3D PRV_M || !riscv_feature(env, RISCV_FEATURE_MMU)) { + if (mode =3D=3D PRV_M || !riscv_cpu_cfg(env).mmu) { *physical =3D addr; *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TRANSLATE_SUCCESS; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index a8a7d0aa34..8c61171a0c 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -2569,7 +2569,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; } @@ -2588,7 +2588,7 @@ static RISCVException write_satp(CPURISCVState *env, = int csrno, { target_ulong vm, mask; =20 - if (!riscv_feature(env, RISCV_FEATURE_MMU)) { + if (!riscv_cpu_cfg(env).mmu) { return RISCV_EXCP_NONE; } =20 diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c index 236f93b9f5..b7b8d0614f 100644 --- a/target/riscv/monitor.c +++ b/target/riscv/monitor.c @@ -218,7 +218,7 @@ void hmp_info_mem(Monitor *mon, const QDict *qdict) return; } =20 - if (!riscv_feature(env, RISCV_FEATURE_MMU)) { + if (!riscv_cpu_cfg(env).mmu) { monitor_printf(mon, "S-mode MMU unavailable\n"); return; } diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 1e7903dffa..c67de36942 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -315,7 +315,7 @@ int pmp_hart_has_privs(CPURISCVState *env, target_ulong= addr, } =20 if (size =3D=3D 0) { - if (riscv_feature(env, RISCV_FEATURE_MMU)) { + if (riscv_cpu_cfg(env).mmu) { /* * If size is unknown (0), assume that all bytes * from addr to the end of the page will be accessed. --=20 2.39.1 From nobody Sat May 18 21:00:23 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=1676552842; cv=none; d=zohomail.com; s=zohoarc; b=MXkprD6dQPy6VPMdg23W3NHiNXaa3FymCnHkK9NDNrEhlvEJuvEYec/HRN1+CrtW/2wFfrp3P8BXlzuZ8WZBX50GEDVJCmQah1dyMArPkT5VDCO4GkzXVd4mS5mxWAzpXaoWHAEbuiqbWzGtCDLGUTj3JgXEfBYlJBeX2IvmYdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676552842; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GvaH81B5hBrpGPqem9kaUkSdCiGN0le0jCxW0/4CJJg=; b=XRtWpgmcN25IubFy4eSyn7zbeX71QdfOk9EdYJMVT0V9ft9CuCq01QGBfOsP3dP+83aiGAY1DA40qFJPjWzr02gBK5NfwT03g1C1nFWKWLWEs8C3QaBE8A6jFoZ6DePuUnt2OB95Ni/h6dS0K2wxiz71CzNsIQVvJoOKdKKnuCA= 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 1676552842561476.4087469127762; Thu, 16 Feb 2023 05:07:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdx7-0004Uh-9M; Thu, 16 Feb 2023 08:05:34 -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 1pSdx3-0004TY-62 for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:29 -0500 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSdx0-0002Jr-QW for qemu-devel@nongnu.org; Thu, 16 Feb 2023 08:05:28 -0500 Received: by mail-oo1-xc2c.google.com with SMTP id l18-20020a4ad9d2000000b0051fdea932cfso169545oou.10 for ; Thu, 16 Feb 2023 05:05:26 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([191.19.40.109]) by smtp.gmail.com with ESMTPSA id c74-20020a4a4f4d000000b0051f97e8a1d5sm594315oob.35.2023.02.16.05.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 05:05: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=GvaH81B5hBrpGPqem9kaUkSdCiGN0le0jCxW0/4CJJg=; b=EQRrHyZJa51674sQhWplIv6fecOyvEHgyYtijEchbT/S8ypIZ1DV+uZ91I21qFNFGy suKo6GRcIcuUCJtyc+JrXSZqKMm4XyoPjufdb+SgftEyA1LiUM17LPug6jT5jxKqBefB 5M/qyzYIe+kq0rwAnJgki+yRNTaPNcijk0T5Kt0iLXICLCJgaljgkGKsIGHmfyWbueOh Zhp8J5P3o6b8k6zKfvWiYlyY/+UV3PjU7uiAtsWbbvNCV9Q8LG27WRv/utOKMwvE79Oq ALNJk1+FqJcI+OwN5jNtMum2xj1ByJSLMhnU3fsxQt6XHAzlAe4Z4ksMSNQ4hVYYKzJl IAOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GvaH81B5hBrpGPqem9kaUkSdCiGN0le0jCxW0/4CJJg=; b=4KCp+HhKMDCmQQh+kvVWUq0xjFjcTkoK1y+HDkfiswfZoRPzpJ7Kv2Jrf8PWRHAC2m TJjKfcYPuVy/J6ZLhqwSAuIgByrmujpJvZrEznptkqPrccHooIeTb9PWB5gbxFkETvOp 1jsFhwqzja4ayx2IyhJpALF8AEvS+nkObSxRNwcr4LVeNYPnx3o81qs/l/aGc7T8CTS3 hz3DaH5Iu6RGlHG1+4nD33oiN4OgfjEQG4oqBf5FzMnPVtJTtHrQWqcqDgUVHSvao5Dt XfdwFboLzxDUeXZtB9XUQYJ0xHpNnXPBwTeM2C3kIVf+V21ZpCpA3ABzUFOhBqdTPnei 9DyA== X-Gm-Message-State: AO0yUKWdRrRMeVb1NzraZL7leVsPRwO9m1cBSHBuhGvC4GgYbNoMQJCq Ok9khPZKNp4bdzRmtbWznu0uvNDabLF4Uhj+ X-Google-Smtp-Source: AK7set9SuXlB4yKcBgavleAnsejW5UCFlavlev4MYns7+uSPv6zvsNpXc4CW/QneGy4hhsjkFnCVxA== X-Received: by 2002:a05:6820:1895:b0:51a:48f4:75de with SMTP id bm21-20020a056820189500b0051a48f475demr889666oob.0.1676552725190; Thu, 16 Feb 2023 05:05:25 -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, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v4 10/10] target/riscv/cpu: remove CPUArchState::features and friends Date: Thu, 16 Feb 2023 10:04:44 -0300 Message-Id: <20230216130444.795997-11-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216130444.795997-1-dbarboza@ventanamicro.com> References: <20230216130444.795997-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::c2c; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2c.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: 1676552843764100001 Content-Type: text/plain; charset="utf-8" The attribute is no longer used since we can retrieve all the enabled features in the hart by using cpu->cfg instead. Remove env->feature, riscv_feature() and riscv_set_feature(). We also need to bump vmstate_riscv_cpu version_id and minimal_version_id since 'features' is no longer being migrated. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Bin Meng Reviewed-by: Andrew Jones --- target/riscv/cpu.h | 12 ------------ target/riscv/machine.c | 5 ++--- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7ff4d90261..671734420b 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -173,8 +173,6 @@ struct CPUArchState { /* 128-bit helpers upper part return value */ target_ulong retxh; =20 - uint32_t features; - #ifdef CONFIG_USER_ONLY uint32_t elf_flags; #endif @@ -524,16 +522,6 @@ static inline int riscv_has_ext(CPURISCVState *env, ta= rget_ulong ext) return (env->misa_ext & ext) !=3D 0; } =20 -static inline bool riscv_feature(CPURISCVState *env, int feature) -{ - return env->features & (1ULL << feature); -} - -static inline void riscv_set_feature(CPURISCVState *env, int feature) -{ - env->features |=3D (1ULL << feature); -} - #include "cpu_user.h" =20 extern const char * const riscv_int_regnames[]; diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 67e9e56853..9c455931d8 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -331,8 +331,8 @@ static const VMStateDescription vmstate_pmu_ctr_state = =3D { =20 const VMStateDescription vmstate_riscv_cpu =3D { .name =3D "cpu", - .version_id =3D 6, - .minimum_version_id =3D 6, + .version_id =3D 7, + .minimum_version_id =3D 7, .post_load =3D riscv_cpu_post_load, .fields =3D (VMStateField[]) { VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32), @@ -351,7 +351,6 @@ const VMStateDescription vmstate_riscv_cpu =3D { VMSTATE_UINT32(env.misa_ext, RISCVCPU), VMSTATE_UINT32(env.misa_mxl_max, RISCVCPU), VMSTATE_UINT32(env.misa_ext_mask, RISCVCPU), - VMSTATE_UINT32(env.features, RISCVCPU), VMSTATE_UINTTL(env.priv, RISCVCPU), VMSTATE_UINTTL(env.virt, RISCVCPU), VMSTATE_UINT64(env.resetvec, RISCVCPU), --=20 2.39.1