From nobody Sat May 11 07:03:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 1646333998133687.9800611789834; Thu, 3 Mar 2022 10:59:58 -0800 (PST) Received: from localhost ([::1]:47524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPqg9-0008SW-1B for importer@patchew.org; Thu, 03 Mar 2022 13:59:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPqbG-0007Ja-Pv for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:54:54 -0500 Received: from [2607:f8b0:4864:20::c2b] (port=46905 helo=mail-oo1-xc2b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPqbE-0001k5-I8 for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:54:54 -0500 Received: by mail-oo1-xc2b.google.com with SMTP id w3-20020a4ac183000000b0031d806bbd7eso6793054oop.13 for ; Thu, 03 Mar 2022 10:54:52 -0800 (PST) Received: from rivos-atish.. (adsl-70-228-75-190.dsl.akrnoh.ameritech.net. [70.228.75.190]) by smtp.gmail.com with ESMTPSA id u24-20020a4ae698000000b0031c286f2e0csm1331052oot.29.2022.03.03.10.54.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 10:54:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h7K10PVkFg7lIGvwJ0Hq+fi9pulMgiLjM/TrtSEBCu4=; b=LlTR/1BTLQoVb5pkZx0kp/gSo6a+KgJX5hOdbPpyOYHY3WPDDewef3kngjfax9LwK+ oHUKakeu62YeJpPOg0r9PUx0nQJAusIYphA7lv3PJrLbitPQ1Ir+YlOo4fG2oxd4taNo +jxIgYcaUEwe/NQ19VZBYguGQHzjXPHNWkC/ryjwjrTi+qmhpk6IWyWSzTqs/pzBQ3mo RE+yAD5DrhXnZbW4zv6A9Kh0t0s5RDchcIGpKcTHT7sByzdNZbhTlVuAwWJrEdLGKLyq 7q6f1PqYncikOZaNex792tsMsSLS2WyiXHxPuKHdjR5zUh/vi2qJLc7amaUcHE8qJzpE 0+PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h7K10PVkFg7lIGvwJ0Hq+fi9pulMgiLjM/TrtSEBCu4=; b=q18uddP1BPGWbE1AnYwzMfE5UuAg0bMnTywjCMdjMsVAY8YxekXac0J6zTzFL27mOa 5VgEwmUU7C+OHSyg4M2EjmvMMtCg16pqBUIsBJ9l7MEg7OrKbZZnZcRLfhjV3FfIQ/Il tpeJWA31+mP0lTOrInPW0T0/AIsHw3tTOImz/zIYHRZkh2LOt+tREX9/1xDGOs5M9dQG jLTtM1AS3Z3ec0rIHP+m4bklfnKcWq00029Tda1wriBxfv9R2uKJ4R3g8jKEa4uonYY7 kcODFKP2FbAmFg3v5wlEf/HBWIvXbyiEl0yBDwve3rwyvWzXl8s06GEOwOSgLRjouRZK bZPQ== X-Gm-Message-State: AOAM531a5CSOs1pwwcTeMtvTYULtW/dk+qLndifzKTv81UiBLLNxF+wR Rceru/lqoiWJ6cHqmUVP2ZUdJ5rkGfOWOg== X-Google-Smtp-Source: ABdhPJx77Wvy5SKAFimIwidjpSk+vdlOVoyXj/vjoC3/DtnIOjs9eD91LBicJ0AJk182/7Kt9Jn2Aw== X-Received: by 2002:a05:6870:7991:b0:d6:ce21:ebfe with SMTP id he17-20020a056870799100b000d6ce21ebfemr5067876oab.125.1646333691299; Thu, 03 Mar 2022 10:54:51 -0800 (PST) From: Atish Patra To: qemu-devel@nongnu.org Subject: [PATCH v5 1/6] target/riscv: Define simpler privileged spec version numbering Date: Thu, 3 Mar 2022 10:54:35 -0800 Message-Id: <20220303185440.512391-2-atishp@rivosinc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220303185440.512391-1-atishp@rivosinc.com> References: <20220303185440.512391-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::c2b (failed) 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::c2b; envelope-from=atishp@rivosinc.com; helo=mail-oo1-xc2b.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: qemu-riscv@nongnu.org, Atish Patra , Bin Meng , Richard Henderson , Alistair Francis , Palmer Dabbelt Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646333999467100001 Content-Type: text/plain; charset="utf-8" Currently, the privileged specification version are defined in a complex manner for no benefit. Simplify it by changing it to a simple enum based on. Suggested-by: Richard Henderson Reviewed-by: Alistair Francis Signed-off-by: Atish Patra --- target/riscv/cpu.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 9ba05042ede0..cf748102efa2 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -82,8 +82,11 @@ enum { RISCV_FEATURE_AIA }; =20 -#define PRIV_VERSION_1_10_0 0x00011000 -#define PRIV_VERSION_1_11_0 0x00011100 +/* Privileged specification version */ +enum { + PRIV_VERSION_1_10_0 =3D 0, + PRIV_VERSION_1_11_0, +}; =20 #define VEXT_VERSION_1_00_0 0x00010000 =20 --=20 2.30.2 From nobody Sat May 11 07:03:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 1646334243100359.6199383216134; Thu, 3 Mar 2022 11:04:03 -0800 (PST) Received: from localhost ([::1]:58766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPqk5-0007cB-Vu for importer@patchew.org; Thu, 03 Mar 2022 14:04:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPqbH-0007Na-Pn for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:54:55 -0500 Received: from [2607:f8b0:4864:20::c2d] (port=36772 helo=mail-oo1-xc2d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPqbF-0001nJ-Rp for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:54:55 -0500 Received: by mail-oo1-xc2d.google.com with SMTP id n5-20020a4a9545000000b0031d45a442feso6817786ooi.3 for ; Thu, 03 Mar 2022 10:54:53 -0800 (PST) Received: from rivos-atish.. (adsl-70-228-75-190.dsl.akrnoh.ameritech.net. [70.228.75.190]) by smtp.gmail.com with ESMTPSA id u24-20020a4ae698000000b0031c286f2e0csm1331052oot.29.2022.03.03.10.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 10:54:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KVrxFJG9XKBpol7NLsKIXCTAGZL6CqEwO0MNz8y3nng=; b=QEklmtMv+4cB1kAvuhgrcvidwEgXat61HJnbb0BrBo5wPe75J/7Uw4b7FtTI188tG4 2m7HwTW1Du2gDwzLqdB4Y3EPa1UP/LlJ9MiqBunEYcFp9fH4lyDZ4lMQDce4yRIoo/Jj y3AkXx3sz/4wrltjlF2f8/KSrKjA0U08kpEc9VJqAwj4STKs5JNx5SdxUnIyWvcHq0Lt UyFVPQq8qY1kpp/n4x50Ty81Ur7GT0ANuSBXjNqD3YAODjuFmij55fWTHBuXcpBde7pa fYT9t1JAFdA3/IR+ebIEtk5wRWLvQaWBJ2X6KW5cATlHbDPQjUFNHqLY+Qx5QwKHlTcf x4wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KVrxFJG9XKBpol7NLsKIXCTAGZL6CqEwO0MNz8y3nng=; b=CmAXhszu+q915wPj03NPy3ji4nOf6WMOebLvf2PjdWWPJPlXTNHxQBEQTyF+no0rlt J4pN9yTI1Lp8eB3jNIPOat6wZpqtKSbvXqwYrsfDwZG9aowtg1Cf1yMXOeVpQUqYtQwk UwnZov9MrJzt67B4HemlSS1EQ6orspbv1ftOiXQXabsZIHyF8vMFSPCSsuN6wsK5vctt dkLm+fsfdV/19hGWbnauINtJu4x9276DF55P2ecL7zBXvTj2+gqr8qgLWurwsiPfvdv/ JNTGnqptafjebQWk9xP4ajr/bQ+uYvb80Gmon0kScUkivxPz4JgXJl7VYOQJUtCwKxuf ki+w== X-Gm-Message-State: AOAM533zov3j4FlEdL6WT3XrS/d8nvRZJQKNV5DLB4GCV4xMHuGHMeyw VFWslDzj50NciDIFKdyzKCsjmUlVCosQZQ== X-Google-Smtp-Source: ABdhPJwX2p++7KN9Jh5qD18EABRv9cstK+nZAkqt9XUBrBQR4F1MTefloBnmu/XXe3OThltTHUoQTg== X-Received: by 2002:a05:6870:6394:b0:d6:e1a0:22c5 with SMTP id t20-20020a056870639400b000d6e1a022c5mr5082494oap.138.1646333692560; Thu, 03 Mar 2022 10:54:52 -0800 (PST) From: Atish Patra To: qemu-devel@nongnu.org Subject: [PATCH v5 2/6] target/riscv: Add the privileged spec version 1.12.0 Date: Thu, 3 Mar 2022 10:54:36 -0800 Message-Id: <20220303185440.512391-3-atishp@rivosinc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220303185440.512391-1-atishp@rivosinc.com> References: <20220303185440.512391-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::c2d (failed) 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::c2d; envelope-from=atishp@rivosinc.com; helo=mail-oo1-xc2d.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Alistair Francis , Bin Meng , Atish Patra , Palmer Dabbelt , qemu-riscv@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646334246453100001 Content-Type: text/plain; charset="utf-8" Add the definition for ratified privileged specification version v1.12 Reviewed-by: Alistair Francis Signed-off-by: Atish Patra --- target/riscv/cpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index cf748102efa2..7f67e920c650 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -86,6 +86,7 @@ enum { enum { PRIV_VERSION_1_10_0 =3D 0, PRIV_VERSION_1_11_0, + PRIV_VERSION_1_12_0, }; =20 #define VEXT_VERSION_1_00_0 0x00010000 --=20 2.30.2 From nobody Sat May 11 07:03:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 1646333876428294.5557652624143; Thu, 3 Mar 2022 10:57:56 -0800 (PST) Received: from localhost ([::1]:40642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPqeB-0003ao-8L for importer@patchew.org; Thu, 03 Mar 2022 13:57:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPqbJ-0007Su-Er for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:54:57 -0500 Received: from [2607:f8b0:4864:20::334] (port=44850 helo=mail-ot1-x334.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPqbH-0001sy-4C for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:54:57 -0500 Received: by mail-ot1-x334.google.com with SMTP id u17-20020a056830231100b005ad13358af9so5379024ote.11 for ; Thu, 03 Mar 2022 10:54:54 -0800 (PST) Received: from rivos-atish.. (adsl-70-228-75-190.dsl.akrnoh.ameritech.net. [70.228.75.190]) by smtp.gmail.com with ESMTPSA id u24-20020a4ae698000000b0031c286f2e0csm1331052oot.29.2022.03.03.10.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 10:54:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3apVKTkl7xTSgH68JnVCZIoSiOD759Y37jslcQcAbgI=; b=dUnuo9wOtLEbFCUBvbZkf+9HzvwDPq/vWz37vbKg/X8HAM/6fKzXCb6MnA7EyY6Jut IVrjME3orzgsPLNk7cZdjfo12FPjGUcvzyEmfrDy40iy9wgDynIvfw8tHW6odGYI3T7V tPF6CNTQ+ViG8Ba3tPn1bOxY7r9FSVbq0X4qygpwInb8dotUQ8OQtXca4hOcNy/1X49P cDbce2sL/wjvrl2GZ+Sk3EVV6jvTn8dZsQtM+3hZ6Xk+NC6l10oslcFhWueZN76FD5eV BM2kHAFw9joIGibS94XZdcW7CeaacGKpTRArW3EOU0IlRLb7mj4Z0sUT9RpEnB0lVgIt LQog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3apVKTkl7xTSgH68JnVCZIoSiOD759Y37jslcQcAbgI=; b=0nL6g3hBYlvQB2RPGETf5QUVaxs18dDDO8cHvqVjFOsKUez4ncp7DqUHR4UQd0Kkme VuCskc9yOeyVZgckBeA+7E10QEiU7+qkAUBPWvEGTj0dTCwGuXrQ+tmJXdsSBgfhGHXn 8P7edoR0Hn4Tz8AbNell9IV43h9sQakSMAcBjKIRzJq8xanZo+73W/UlVOlJL7chVOh0 SzSZ0a/Mg6s9YxQqYwWlEuMkYIaq7nxAW8CZ54DF0Z6815zhMgPSInhURKDhV2LCT6Ej aSfYiFQkUA39XuqQDwUYMYrXDtX7bpQfioqgg7ugsOmGLVu9Fh3zseuNIyU++ZsjMdPw /xTw== X-Gm-Message-State: AOAM531EqWuwJxzL5RQpM3f6QfmEfITDyTDMhUXOSkCJ1aNea47jar/7 W45Nf+/JLUGLAfMw5oqS/oPOI+LWSjtzzg== X-Google-Smtp-Source: ABdhPJwrHkIfbLtkWElzeEPNKtKYYKqQn4ysXbpU6eZh/2rEUcnhPObb7eCY35lKHCNODb9VWqgBdw== X-Received: by 2002:a9d:6409:0:b0:5ad:2055:9bdc with SMTP id h9-20020a9d6409000000b005ad20559bdcmr19717972otl.93.1646333693805; Thu, 03 Mar 2022 10:54:53 -0800 (PST) From: Atish Patra To: qemu-devel@nongnu.org Subject: [PATCH v5 3/6] target/riscv: Introduce privilege version field in the CSR ops. Date: Thu, 3 Mar 2022 10:54:37 -0800 Message-Id: <20220303185440.512391-4-atishp@rivosinc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220303185440.512391-1-atishp@rivosinc.com> References: <20220303185440.512391-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::334 (failed) 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::334; envelope-from=atishp@rivosinc.com; helo=mail-ot1-x334.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Alistair Francis , Bin Meng , Atish Patra , Palmer Dabbelt , qemu-riscv@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646333877275100001 Content-Type: text/plain; charset="utf-8" To allow/disallow the CSR access based on the privilege spec, a new field in the csr_ops is introduced. It also adds the privileged specification version (v1.12) for the CSRs introduced in the v1.12. This includes the new ratified extensions such as Vector, Hypervisor and secconfig CSR. However, it doesn't enforce the privilege version in this commit. Reviewed-by: Alistair Francis Signed-off-by: Atish Patra --- target/riscv/cpu.h | 2 + target/riscv/csr.c | 103 ++++++++++++++++++++++++++++++--------------- 2 files changed, 70 insertions(+), 35 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7f67e920c650..e7133f4c8ac9 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -661,6 +661,8 @@ typedef struct { riscv_csr_op_fn op; riscv_csr_read128_fn read128; riscv_csr_write128_fn write128; + /* The default priv spec version should be PRIV_VERSION_1_10_0 (i.e 0)= */ + uint32_t min_priv_ver; } riscv_csr_operations; =20 /* CSR function table constants */ diff --git a/target/riscv/csr.c b/target/riscv/csr.c index aea82dff4aff..ec41a5363f6b 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -3067,13 +3067,20 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D { [CSR_FRM] =3D { "frm", fs, read_frm, write_frm }, [CSR_FCSR] =3D { "fcsr", fs, read_fcsr, write_fcsr }, /* Vector CSRs */ - [CSR_VSTART] =3D { "vstart", vs, read_vstart, write_vstart }, - [CSR_VXSAT] =3D { "vxsat", vs, read_vxsat, write_vxsat }, - [CSR_VXRM] =3D { "vxrm", vs, read_vxrm, write_vxrm }, - [CSR_VCSR] =3D { "vcsr", vs, read_vcsr, write_vcsr }, - [CSR_VL] =3D { "vl", vs, read_vl }, - [CSR_VTYPE] =3D { "vtype", vs, read_vtype }, - [CSR_VLENB] =3D { "vlenb", vs, read_vlenb }, + [CSR_VSTART] =3D { "vstart", vs, read_vstart, write_vstart, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, + [CSR_VXSAT] =3D { "vxsat", vs, read_vxsat, write_vxsat, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, + [CSR_VXRM] =3D { "vxrm", vs, read_vxrm, write_vxrm, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, + [CSR_VCSR] =3D { "vcsr", vs, read_vcsr, write_vcsr, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, + [CSR_VL] =3D { "vl", vs, read_vl, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, + [CSR_VTYPE] =3D { "vtype", vs, read_vtype, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, + [CSR_VLENB] =3D { "vlenb", vs, read_vlenb, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, /* User Timers and Counters */ [CSR_CYCLE] =3D { "cycle", ctr, read_instret }, [CSR_INSTRET] =3D { "instret", ctr, read_instret }, @@ -3182,33 +3189,58 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D { [CSR_SIEH] =3D { "sieh", aia_smode32, NULL, NULL, rmw_sieh }, [CSR_SIPH] =3D { "siph", aia_smode32, NULL, NULL, rmw_siph }, =20 - [CSR_HSTATUS] =3D { "hstatus", hmode, read_hstatus, writ= e_hstatus }, - [CSR_HEDELEG] =3D { "hedeleg", hmode, read_hedeleg, writ= e_hedeleg }, - [CSR_HIDELEG] =3D { "hideleg", hmode, NULL, NULL, rmw_= hideleg }, - [CSR_HVIP] =3D { "hvip", hmode, NULL, NULL, rmw_= hvip }, - [CSR_HIP] =3D { "hip", hmode, NULL, NULL, rmw_= hip }, - [CSR_HIE] =3D { "hie", hmode, NULL, NULL, rmw_= hie }, - [CSR_HCOUNTEREN] =3D { "hcounteren", hmode, read_hcounteren, writ= e_hcounteren }, - [CSR_HGEIE] =3D { "hgeie", hmode, read_hgeie, writ= e_hgeie }, - [CSR_HTVAL] =3D { "htval", hmode, read_htval, writ= e_htval }, - [CSR_HTINST] =3D { "htinst", hmode, read_htinst, writ= e_htinst }, - [CSR_HGEIP] =3D { "hgeip", hmode, read_hgeip, NULL= }, - [CSR_HGATP] =3D { "hgatp", hmode, read_hgatp, writ= e_hgatp }, - [CSR_HTIMEDELTA] =3D { "htimedelta", hmode, read_htimedelta, writ= e_htimedelta }, - [CSR_HTIMEDELTAH] =3D { "htimedeltah", hmode32, read_htimedeltah, writ= e_htimedeltah }, - - [CSR_VSSTATUS] =3D { "vsstatus", hmode, read_vsstatus, writ= e_vsstatus }, - [CSR_VSIP] =3D { "vsip", hmode, NULL, NULL, rmw_= vsip }, - [CSR_VSIE] =3D { "vsie", hmode, NULL, NULL, rmw_= vsie }, - [CSR_VSTVEC] =3D { "vstvec", hmode, read_vstvec, writ= e_vstvec }, - [CSR_VSSCRATCH] =3D { "vsscratch", hmode, read_vsscratch, writ= e_vsscratch }, - [CSR_VSEPC] =3D { "vsepc", hmode, read_vsepc, writ= e_vsepc }, - [CSR_VSCAUSE] =3D { "vscause", hmode, read_vscause, writ= e_vscause }, - [CSR_VSTVAL] =3D { "vstval", hmode, read_vstval, writ= e_vstval }, - [CSR_VSATP] =3D { "vsatp", hmode, read_vsatp, writ= e_vsatp }, - - [CSR_MTVAL2] =3D { "mtval2", hmode, read_mtval2, writ= e_mtval2 }, - [CSR_MTINST] =3D { "mtinst", hmode, read_mtinst, writ= e_mtinst }, + [CSR_HSTATUS] =3D { "hstatus", hmode, read_hstatus, write_= hstatus, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HEDELEG] =3D { "hedeleg", hmode, read_hedeleg, write_= hedeleg, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HIDELEG] =3D { "hideleg", hmode, NULL, NULL, rmw_hide= leg, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HVIP] =3D { "hvip", hmode, NULL, NULL, rmw_hv= ip, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HIP] =3D { "hip", hmode, NULL, NULL, rmw_hi= p, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HIE] =3D { "hie", hmode, NULL, NULL, rmw_h= ie, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HCOUNTEREN] =3D { "hcounteren", hmode, read_hcounteren, write= _hcounteren, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HGEIE] =3D { "hgeie", hmode, read_hgeie, writ= e_hgeie, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HTVAL] =3D { "htval", hmode, read_htval, write_= htval, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HTINST] =3D { "htinst", hmode, read_htinst, write_= htinst, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HGEIP] =3D { "hgeip", hmode, read_hgeip, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HGATP] =3D { "hgatp", hmode, read_hgatp, write_= hgatp, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HTIMEDELTA] =3D { "htimedelta", hmode, read_htimedelta, write= _htimedelta, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_HTIMEDELTAH] =3D { "htimedeltah", hmode32, read_htimedeltah, writ= e_htimedeltah, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + + [CSR_VSSTATUS] =3D { "vsstatus", hmode, read_vsstatus, write_= vsstatus, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_VSIP] =3D { "vsip", hmode, NULL, NULL, rmw_vs= ip, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_VSIE] =3D { "vsie", hmode, NULL, NULL, rmw_= vsie , + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_VSTVEC] =3D { "vstvec", hmode, read_vstvec, write_= vstvec, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_VSSCRATCH] =3D { "vsscratch", hmode, read_vsscratch, write_= vsscratch, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_VSEPC] =3D { "vsepc", hmode, read_vsepc, write_= vsepc, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_VSCAUSE] =3D { "vscause", hmode, read_vscause, write_= vscause, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_VSTVAL] =3D { "vstval", hmode, read_vstval, write_= vstval, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_VSATP] =3D { "vsatp", hmode, read_vsatp, write_= vsatp, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + + [CSR_MTVAL2] =3D { "mtval2", hmode, read_mtval2, write_= mtval2, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, + [CSR_MTINST] =3D { "mtinst", hmode, read_mtinst, write_= mtinst, + .min_priv_ver =3D PRIV_VERSION_1_= 12_0 }, =20 /* Virtual Interrupts and Interrupt Priorities (H-extension with AIA) = */ [CSR_HVIEN] =3D { "hvien", aia_hmode, read_zero, write_ign= ore }, @@ -3242,7 +3274,8 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D { [CSR_VSIPH] =3D { "vsiph", aia_hmode32, NULL, NULL, rmw_vs= iph }, =20 /* Physical Memory Protection */ - [CSR_MSECCFG] =3D { "mseccfg", epmp, read_mseccfg, write_mseccfg }, + [CSR_MSECCFG] =3D { "mseccfg", epmp, read_mseccfg, write_mseccfg, + .min_priv_ver =3D PRIV_VERSION_1_12_0= }, [CSR_PMPCFG0] =3D { "pmpcfg0", pmp, read_pmpcfg, write_pmpcfg }, [CSR_PMPCFG1] =3D { "pmpcfg1", pmp, read_pmpcfg, write_pmpcfg }, [CSR_PMPCFG2] =3D { "pmpcfg2", pmp, read_pmpcfg, write_pmpcfg }, --=20 2.30.2 From nobody Sat May 11 07:03:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 164633450569832.02227389720906; Thu, 3 Mar 2022 11:08:25 -0800 (PST) Received: from localhost ([::1]:41480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPqoK-0006bg-FZ for importer@patchew.org; Thu, 03 Mar 2022 14:08:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPqbK-0007Uo-12 for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:54:58 -0500 Received: from [2607:f8b0:4864:20::c2a] (port=37577 helo=mail-oo1-xc2a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPqbI-0001uV-Gg for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:54:57 -0500 Received: by mail-oo1-xc2a.google.com with SMTP id x6-20020a4a4106000000b003193022319cso6826464ooa.4 for ; Thu, 03 Mar 2022 10:54:56 -0800 (PST) Received: from rivos-atish.. (adsl-70-228-75-190.dsl.akrnoh.ameritech.net. [70.228.75.190]) by smtp.gmail.com with ESMTPSA id u24-20020a4ae698000000b0031c286f2e0csm1331052oot.29.2022.03.03.10.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 10:54:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/tS8r6MLk9Ys/DbcleIob127V9NYv9KycItEsxaklD8=; b=F1JDBHzBMIK0U/4m5qJk6zYTebgB9PELFz3b/qjqaWyFTKZGGH4iSGIZHmEgMdzohG N9+ixkBXvjay+mKOn0btsO1kHvA5EpbY8VElnFfznBYnQX8EL+2RqDTWncpOpdqtg4kZ naEDI6pSzzpLv4aKkTByKG7Fmsbeg2jHWmlv0+TVnR0CbVNO4MrUoez/R+aPJPM7mBOp eSJC8VGbLn+h8hrKiRRGXI5raVCaXOc04IZCd+VMGgU1AkIPG7pAXB7GyM5Q6ueWlUfK xezDfjOkaU/r0lGifuqhFGIIKpo7vbY+OR3eMXkA5gwFloqBFIMq+Am3Ye6sgWRMeOYc Mkvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/tS8r6MLk9Ys/DbcleIob127V9NYv9KycItEsxaklD8=; b=lvyO3zxj2Nb17RrufPSpfOl4rEKN7AbHvPqeGgE32hG5OZxrfBEvig0ygaXfFZ4QL0 0L9iKR/lQASCys+OXb6SkghwEB5CPw+uaqo32Zs9UUffUmOKUex8CTTKunIInQZWFOyL GFOYokFVyIJlKbHPhEZWhCpQ9USObAesIrKZJHifzRwpszrkRXABJ0NBMDmtlxyFpgAk duULxBGFRMY5l0ILLXfDfP7zfqygjrSeieNp3FIXmyF1SpnS+lmGCvvrtbli6jatIRa0 jOIPNaH5JgyluG/uUd5O+OmAx6CvMuQpiqm9AQQm2sHG8vvaA4IibAGcAUswV1OF3+WG w9JQ== X-Gm-Message-State: AOAM532D+IeqV0oyZ6Aj+ec6rI7IIWxDBKKbWVtNDtWtEkOep8D7W7oH lVrLMt8zgUdmboWNlExA2dwg9vktlLBpXg== X-Google-Smtp-Source: ABdhPJzGW29hc70GAUKLV3jekc71n2hCm6cz6pwLb1P2FNUYZ0SWjJeKHX23EIGuIE3OAz0rgrl+fw== X-Received: by 2002:a05:6870:a686:b0:d7:91:e56b with SMTP id i6-20020a056870a68600b000d70091e56bmr5169651oam.86.1646333695037; Thu, 03 Mar 2022 10:54:55 -0800 (PST) From: Atish Patra To: qemu-devel@nongnu.org Subject: [PATCH v5 4/6] target/riscv: Add support for mconfigptr Date: Thu, 3 Mar 2022 10:54:38 -0800 Message-Id: <20220303185440.512391-5-atishp@rivosinc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220303185440.512391-1-atishp@rivosinc.com> References: <20220303185440.512391-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::c2a (failed) 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=atishp@rivosinc.com; helo=mail-oo1-xc2a.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Alistair Francis , Bin Meng , Atish Patra , Palmer Dabbelt , qemu-riscv@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646334506680100001 Content-Type: text/plain; charset="utf-8" RISC-V privileged specification v1.12 introduced a mconfigptr which will hold the physical address of a configuration data structure. As Qemu doesn't have a configuration data structure, is read as zero which is valid as per the priv spec. Reviewed-by: Alistair Francis Signed-off-by: Atish Patra --- target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 0fe01d7da57f..48d92a81c3ee 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -148,6 +148,7 @@ #define CSR_MARCHID 0xf12 #define CSR_MIMPID 0xf13 #define CSR_MHARTID 0xf14 +#define CSR_MCONFIGPTR 0xf15 =20 /* Machine Trap Setup */ #define CSR_MSTATUS 0x300 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index ec41a5363f6b..699d72b6c6f1 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -3107,6 +3107,8 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D { [CSR_MIMPID] =3D { "mimpid", any, read_zero }, [CSR_MHARTID] =3D { "mhartid", any, read_mhartid }, =20 + [CSR_MCONFIGPTR] =3D { "mconfigptr", any, read_zero, + .min_priv_ver =3D PRIV_VERSION_1_1= 2_0 }, /* Machine Trap Setup */ [CSR_MSTATUS] =3D { "mstatus", any, read_mstatus, write_m= status, NULL, read_mstatus_i128 = }, --=20 2.30.2 From nobody Sat May 11 07:03:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 1646334354752673.2735566923521; Thu, 3 Mar 2022 11:05:54 -0800 (PST) Received: from localhost ([::1]:34726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPqlt-00022R-BW for importer@patchew.org; Thu, 03 Mar 2022 14:05:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPqbL-0007Zi-HJ for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:54:59 -0500 Received: from [2607:f8b0:4864:20::330] (port=42594 helo=mail-ot1-x330.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPqbJ-00021o-MD for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:54:59 -0500 Received: by mail-ot1-x330.google.com with SMTP id l21-20020a056830239500b005afd2a7eaa2so5405369ots.9 for ; Thu, 03 Mar 2022 10:54:57 -0800 (PST) Received: from rivos-atish.. (adsl-70-228-75-190.dsl.akrnoh.ameritech.net. [70.228.75.190]) by smtp.gmail.com with ESMTPSA id u24-20020a4ae698000000b0031c286f2e0csm1331052oot.29.2022.03.03.10.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 10:54:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JWwiQ3EURDf/PZzEHNL60Y3bE1HhKrkufF/XAzDqPJ8=; b=iadEvyGyn2gvXAOptgeaOrvAriHkMduiRfqx4ovptsGfHBVBcE5/nQp5c0YMNXWq3C 4sYweTA2be5ADNaFiO+WmaTg9AfFLvcuafMjGYEIeovkGBrqBW0WbEYf68eE/+3IRlCZ ybVb5W+tcbdk1l20Dn3M7tWaujYaOe0+dv7Pt5ln6ZcVAByFZbzNdaf9QDXhCLFBP6KO f8CWUuM6PjMpaw5NJH0d7uOraKb3NRZvyGv/t77LhaMtibSmB5zXqoXkEGIhxLIewJg6 PZZtZXwvdyqh7FWcZBD3QY2Ix5yN6nuEZLgW8S+BA6IjpGPjZB4/C/kHQqx60FREcQ5P pipQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JWwiQ3EURDf/PZzEHNL60Y3bE1HhKrkufF/XAzDqPJ8=; b=UrLPXxnpnu44Pa85hy1c9OFaOxlcfAMwKi58BCMSiCzlJ8fzsLY2K2WD1tC62LeyPS VwrdaEcNQyFkNjbpteHKphFQ7uvLmGHpTW9Nam1FYzKogBD/Q7kLIEY2CQyRPVkPd/PR dyE0B9r9V5B8qQ3clpLyV4tyc5xLq5nXuj6QFXjUKfCY6Rnd2g62jpG/+mDPdCQfNczz Y/UNS0UtuoH7zfgK66EnHAGNlHY94z5Sih47Gg3X7+h3XhyyMVmFo7g9YxcUE4+EaaRn cRGrjmbE7R2xkC65giS5TBe+jkPsxvzpSjFQ6dhxRJt10+/toLspeHF0Psoy38Xoo2t9 XIyg== X-Gm-Message-State: AOAM5333unjKeV5QZTMFSQ6QO68Rq60qAr5jcH08vvjGWs+CrJPcPXVq LftSE+R/ON1PIKl/+Pl/Io9/l/aSbp+TNg== X-Google-Smtp-Source: ABdhPJzdO5MF5s0E8ZLfbpLljYUwNkzDc//MhZX0/nPEC3smCd2c3C+Sjo33TymJKxgP5x8RJN69dw== X-Received: by 2002:a9d:6f0e:0:b0:5af:63df:75bd with SMTP id n14-20020a9d6f0e000000b005af63df75bdmr19318189otq.293.1646333696249; Thu, 03 Mar 2022 10:54:56 -0800 (PST) From: Atish Patra To: qemu-devel@nongnu.org Subject: [PATCH v5 5/6] target/riscv: Add *envcfg* CSRs support Date: Thu, 3 Mar 2022 10:54:39 -0800 Message-Id: <20220303185440.512391-6-atishp@rivosinc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220303185440.512391-1-atishp@rivosinc.com> References: <20220303185440.512391-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::330 (failed) 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::330; envelope-from=atishp@rivosinc.com; helo=mail-ot1-x330.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Alistair Francis , Bin Meng , Atish Patra , Palmer Dabbelt , qemu-riscv@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646334356255100001 Content-Type: text/plain; charset="utf-8" The RISC-V privileged specification v1.12 defines few execution environment configuration CSRs that can be used enable/disable extensions per privilege levels. Add the basic support for these CSRs. Reviewed-by: Alistair Francis Signed-off-by: Atish Patra --- target/riscv/cpu.h | 5 ++ target/riscv/cpu_bits.h | 39 +++++++++++++++ target/riscv/csr.c | 107 ++++++++++++++++++++++++++++++++++++++++ target/riscv/machine.c | 23 +++++++++ 4 files changed, 174 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index e7133f4c8ac9..d67e0ba6f7e1 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -304,6 +304,11 @@ struct CPURISCVState { target_ulong spmbase; target_ulong upmmask; target_ulong upmbase; + + /* CSRs for execution enviornment configuration */ + uint64_t menvcfg; + target_ulong senvcfg; + uint64_t henvcfg; #endif target_ulong cur_pmmask; target_ulong cur_pmbase; diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 48d92a81c3ee..bb47cf7e77a2 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -202,6 +202,9 @@ #define CSR_STVEC 0x105 #define CSR_SCOUNTEREN 0x106 =20 +/* Supervisor Configuration CSRs */ +#define CSR_SENVCFG 0x10A + /* Supervisor Trap Handling */ #define CSR_SSCRATCH 0x140 #define CSR_SEPC 0x141 @@ -247,6 +250,10 @@ #define CSR_HTIMEDELTA 0x605 #define CSR_HTIMEDELTAH 0x615 =20 +/* Hypervisor Configuration CSRs */ +#define CSR_HENVCFG 0x60A +#define CSR_HENVCFGH 0x61A + /* Virtual CSRs */ #define CSR_VSSTATUS 0x200 #define CSR_VSIE 0x204 @@ -290,6 +297,10 @@ #define CSR_VSIEH 0x214 #define CSR_VSIPH 0x254 =20 +/* Machine Configuration CSRs */ +#define CSR_MENVCFG 0x30A +#define CSR_MENVCFGH 0x31A + /* Enhanced Physical Memory Protection (ePMP) */ #define CSR_MSECCFG 0x747 #define CSR_MSECCFGH 0x757 @@ -663,6 +674,34 @@ typedef enum RISCVException { #define PM_EXT_CLEAN 0x00000002ULL #define PM_EXT_DIRTY 0x00000003ULL =20 +/* Execution enviornment configuration bits */ +#define MENVCFG_FIOM BIT(0) +#define MENVCFG_CBIE (3UL << 4) +#define MENVCFG_CBCFE BIT(6) +#define MENVCFG_CBZE BIT(7) +#define MENVCFG_PBMTE BIT(62) +#define MENVCFG_STCE BIT(63) + +/* For RV32 */ +#define MENVCFGH_PBMTE BIT(30) +#define MENVCFGH_STCE BIT(31) + +#define SENVCFG_FIOM MENVCFG_FIOM +#define SENVCFG_CBIE MENVCFG_CBIE +#define SENVCFG_CBCFE MENVCFG_CBCFE +#define SENVCFG_CBZE MENVCFG_CBZE + +#define HENVCFG_FIOM MENVCFG_FIOM +#define HENVCFG_CBIE MENVCFG_CBIE +#define HENVCFG_CBCFE MENVCFG_CBCFE +#define HENVCFG_CBZE MENVCFG_CBZE +#define HENVCFG_PBMTE MENVCFG_PBMTE +#define HENVCFG_STCE MENVCFG_STCE + +/* For RV32 */ +#define HENVCFGH_PBMTE MENVCFGH_PBMTE +#define HENVCFGH_STCE MENVCFGH_STCE + /* Offsets for every pair of control bits per each priv level */ #define XS_OFFSET 0ULL #define U_OFFSET 2ULL diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 699d72b6c6f1..c34722caf97f 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1397,6 +1397,101 @@ static RISCVException write_mtval(CPURISCVState *en= v, int csrno, return RISCV_EXCP_NONE; } =20 +/* Execution environment configuration setup */ +static RISCVException read_menvcfg(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D env->menvcfg; + return RISCV_EXCP_NONE; +} + +static RISCVException write_menvcfg(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mask =3D MENVCFG_FIOM | MENVCFG_CBIE | MENVCFG_CBCFE | MENVCF= G_CBZE; + + if (riscv_cpu_mxl(env) =3D=3D MXL_RV64) { + mask |=3D MENVCFG_PBMTE | MENVCFG_STCE; + } + env->menvcfg =3D (env->menvcfg & ~mask) | (val & mask); + + return RISCV_EXCP_NONE; +} + +static RISCVException read_menvcfgh(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D env->menvcfg >> 32; + return RISCV_EXCP_NONE; +} + +static RISCVException write_menvcfgh(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mask =3D MENVCFG_PBMTE | MENVCFG_STCE; + uint64_t valh =3D (uint64_t)val << 32; + + env->menvcfg =3D (env->menvcfg & ~mask) | (valh & mask); + + return RISCV_EXCP_NONE; +} + +static RISCVException read_senvcfg(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D env->senvcfg; + return RISCV_EXCP_NONE; +} + +static RISCVException write_senvcfg(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mask =3D SENVCFG_FIOM | SENVCFG_CBIE | SENVCFG_CBCFE | SENVCF= G_CBZE; + + env->senvcfg =3D (env->senvcfg & ~mask) | (val & mask); + + return RISCV_EXCP_NONE; +} + +static RISCVException read_henvcfg(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D env->henvcfg; + return RISCV_EXCP_NONE; +} + +static RISCVException write_henvcfg(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mask =3D HENVCFG_FIOM | HENVCFG_CBIE | HENVCFG_CBCFE | HENVCF= G_CBZE; + + if (riscv_cpu_mxl(env) =3D=3D MXL_RV64) { + mask |=3D HENVCFG_PBMTE | HENVCFG_STCE; + } + + env->henvcfg =3D (env->henvcfg & ~mask) | (val & mask); + + return RISCV_EXCP_NONE; +} + +static RISCVException read_henvcfgh(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D env->henvcfg >> 32; + return RISCV_EXCP_NONE; +} + +static RISCVException write_henvcfgh(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mask =3D HENVCFG_PBMTE | HENVCFG_STCE; + uint64_t valh =3D (uint64_t)val << 32; + + env->henvcfg =3D (env->henvcfg & ~mask) | (valh & mask); + + return RISCV_EXCP_NONE; +} + static RISCVException rmw_mip64(CPURISCVState *env, int csrno, uint64_t *ret_val, uint64_t new_val, uint64_t wr_mask) @@ -3155,6 +3250,18 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D { [CSR_MVIPH] =3D { "mviph", aia_any32, read_zero, write_ignore }, [CSR_MIPH] =3D { "miph", aia_any32, NULL, NULL, rmw_miph }, =20 + /* Execution environment configuration */ + [CSR_MENVCFG] =3D { "menvcfg", any, read_menvcfg, write_menvcfg, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, + [CSR_MENVCFGH] =3D { "menvcfgh", any32, read_menvcfgh, write_menvcfgh, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, + [CSR_SENVCFG] =3D { "senvcfg", smode, read_senvcfg, write_senvcfg, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, + [CSR_HENVCFG] =3D { "henvcfg", hmode, read_henvcfg, write_henvcfg, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, + [CSR_HENVCFGH] =3D { "henvcfgh", hmode32, read_henvcfgh, write_henvcfg= h, + .min_priv_ver =3D PRIV_VERSION_1= _12_0 }, + /* Supervisor Trap Setup */ [CSR_SSTATUS] =3D { "sstatus", smode, read_sstatus, write_sst= atus, NULL, read_sstatus_i128 = }, diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 5178b3fec92a..243f567949ea 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -231,6 +231,28 @@ static int riscv_cpu_post_load(void *opaque, int versi= on_id) return 0; } =20 +static bool envcfg_needed(void *opaque) +{ + RISCVCPU *cpu =3D opaque; + CPURISCVState *env =3D &cpu->env; + + return (env->priv_ver >=3D PRIV_VERSION_1_12_0 ? 1 : 0); +} + +static const VMStateDescription vmstate_envcfg =3D { + .name =3D "cpu/envcfg", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D envcfg_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(env.menvcfg, RISCVCPU), + VMSTATE_UINTTL(env.senvcfg, RISCVCPU), + VMSTATE_UINT64(env.henvcfg, RISCVCPU), + + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_riscv_cpu =3D { .name =3D "cpu", .version_id =3D 3, @@ -292,6 +314,7 @@ const VMStateDescription vmstate_riscv_cpu =3D { &vmstate_pointermasking, &vmstate_rv128, &vmstate_kvmtimer, + &vmstate_envcfg, NULL } }; --=20 2.30.2 From nobody Sat May 11 07:03:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 1646334136095801.3526946057244; Thu, 3 Mar 2022 11:02:16 -0800 (PST) Received: from localhost ([::1]:53590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPqiN-00045Q-Kt for importer@patchew.org; Thu, 03 Mar 2022 14:02:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPqbM-0007cO-6J for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:55:00 -0500 Received: from [2607:f8b0:4864:20::330] (port=41574 helo=mail-ot1-x330.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPqbK-00027T-M3 for qemu-devel@nongnu.org; Thu, 03 Mar 2022 13:54:59 -0500 Received: by mail-ot1-x330.google.com with SMTP id k22-20020a9d4b96000000b005ad5211bd5aso5399950otf.8 for ; Thu, 03 Mar 2022 10:54:58 -0800 (PST) Received: from rivos-atish.. (adsl-70-228-75-190.dsl.akrnoh.ameritech.net. [70.228.75.190]) by smtp.gmail.com with ESMTPSA id u24-20020a4ae698000000b0031c286f2e0csm1331052oot.29.2022.03.03.10.54.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 10:54:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/HJyg2t4f3FC3j2AtaIbs2iFCNzMPxA4uZU0p+mRihM=; b=s/W4FBrAE8GbdU9WutV1NYh8BjCeNwN9phCSBmxeSnd92HJNsj1o8EY5u4y+Bads5A CKbHQdbqUoJFf7sHdluFyD0B7ZpWATYNz3voKrAjAUfIYfWXRVxoR7QS9MEjseJTDdQ6 RxrwJrsTGa82yXz8stf5Wbu3rFsCv6gSgJPXUxceTPWzIWB1mo+IFqQoE0zgKesFfWHu dy7Mw5JtDzVKC9W6zhTVhqa9uPsBua2Qtjr9TG0RUcQXQtrDxsZJeWLkOon/OZXqcAD7 eRXP4jkRwoOumcxfrF4Z42gUKLcKCLxI8k4d8nKN+dl3M4TfcPOAS9nPgqu5V1CR0VWo XTow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/HJyg2t4f3FC3j2AtaIbs2iFCNzMPxA4uZU0p+mRihM=; b=sbWxzEwvK1aJQkl5dWD/Q63OQW/RUoOItsdeyYhkNqA+/BQf9N7gHYor77mUfb+AcV ua22AsYzGTN3L1OHZwz2UAd0u2ynBKJ9qpGJ5QjtXBcTyp8JjBbReX4fZ/+PC8X7ZwQc CQxH+cahYVK8z5uAbSf0NmcVPXQgrWIXG5EBBbWH8u8CYG/FsuxVaMrlS9rR2gS5lGkQ eDndo4Y8ECMSP2m3tpxeg4RrOOu2ZB3GqyqJJ8K1MLxhBZUjCgOcDGee8Yvp8+UBjwvB IIJZ48HKLMkIqNeOaLxqckrI/OBRAv+nKxJMdZgMwr8Acc/6P1cgKCrmQBPKcF26JMDO 4UXQ== X-Gm-Message-State: AOAM532iJIIr3XjrZ/z3q1s0QzLDPu9wEUR7YCQiYMeblmLQdWRrS2C2 LyDxYJFM125OTMEhli98NfjOpiCngmnulw== X-Google-Smtp-Source: ABdhPJxtOUmh2ddyvGGTqdd48JHlAJKx8wCs8996e+cDPi5ogtC1w5jeETZh2fDPQ96I5Q6pGNo01g== X-Received: by 2002:a9d:f26:0:b0:5af:43f9:8a1f with SMTP id 35-20020a9d0f26000000b005af43f98a1fmr19977606ott.375.1646333697486; Thu, 03 Mar 2022 10:54:57 -0800 (PST) From: Atish Patra To: qemu-devel@nongnu.org Subject: [PATCH v5 6/6] target/riscv: Enable privileged spec version 1.12 Date: Thu, 3 Mar 2022 10:54:40 -0800 Message-Id: <20220303185440.512391-7-atishp@rivosinc.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220303185440.512391-1-atishp@rivosinc.com> References: <20220303185440.512391-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::330 (failed) 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::330; envelope-from=atishp@rivosinc.com; helo=mail-ot1-x330.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: Alistair Francis , Bin Meng , Atish Patra , Palmer Dabbelt , qemu-riscv@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646334137409100001 Content-Type: text/plain; charset="utf-8" Virt machine uses privileged specification version 1.12 now. All other machine continue to use the default one defined for that machine unless changed to 1.12 by the user explicitly. This commit enforces the privilege version for csrs introduced in v1.12 or after. Reviewed-by: Alistair Francis Signed-off-by: Atish Patra --- target/riscv/cpu.c | 8 +++++--- target/riscv/csr.c | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ddda4906ffb7..c3fd018ecb6e 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -150,7 +150,7 @@ static void riscv_any_cpu_init(Object *obj) #elif defined(TARGET_RISCV64) set_misa(env, MXL_RV64, RVI | RVM | RVA | RVF | RVD | RVC | RVU); #endif - set_priv_version(env, PRIV_VERSION_1_11_0); + set_priv_version(env, PRIV_VERSION_1_12_0); } =20 #if defined(TARGET_RISCV64) @@ -503,7 +503,9 @@ static void riscv_cpu_realize(DeviceState *dev, Error *= *errp) } =20 if (cpu->cfg.priv_spec) { - if (!g_strcmp0(cpu->cfg.priv_spec, "v1.11.0")) { + if (!g_strcmp0(cpu->cfg.priv_spec, "v1.12.0")) { + priv_version =3D PRIV_VERSION_1_12_0; + } else if (!g_strcmp0(cpu->cfg.priv_spec, "v1.11.0")) { priv_version =3D PRIV_VERSION_1_11_0; } else if (!g_strcmp0(cpu->cfg.priv_spec, "v1.10.0")) { priv_version =3D PRIV_VERSION_1_10_0; @@ -518,7 +520,7 @@ static void riscv_cpu_realize(DeviceState *dev, Error *= *errp) if (priv_version) { set_priv_version(env, priv_version); } else if (!env->priv_ver) { - set_priv_version(env, PRIV_VERSION_1_11_0); + set_priv_version(env, PRIV_VERSION_1_12_0); } =20 if (cpu->cfg.mmu) { diff --git a/target/riscv/csr.c b/target/riscv/csr.c index c34722caf97f..b1876b3b6466 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -2972,6 +2972,7 @@ static inline RISCVException riscv_csrrw_check(CPURIS= CVState *env, { /* check privileges and return RISCV_EXCP_ILLEGAL_INST if check fails = */ int read_only =3D get_field(csrno, 0xC00) =3D=3D 3; + int csr_min_priv =3D csr_ops[csrno].min_priv_ver; #if !defined(CONFIG_USER_ONLY) int effective_priv =3D env->priv; =20 @@ -3004,6 +3005,10 @@ static inline RISCVException riscv_csrrw_check(CPURI= SCVState *env, return RISCV_EXCP_ILLEGAL_INST; } =20 + if (env->priv_ver < csr_min_priv) { + return RISCV_EXCP_ILLEGAL_INST; + } + return csr_ops[csrno].predicate(env, csrno); } =20 --=20 2.30.2