From patchwork Sat Oct 28 22:49:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1856620 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Ej5XKkDv; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=BSx+mnGV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SHvrQ6nrGz1yQN for ; Sun, 29 Oct 2023 09:50:30 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3QL8vMo8j2tHe5Cpx20u0K1fs3d0Vmt1waoaqa01MvU=; b=Ej5XKkDvuFjoa9 TP5e/xuDaA8zOLjre/xOtbKR4Hz8w1F4XODLqEW3Yz8lNlmhu+6pOkvCSZw4E+UG0vh5LWR6UiZ8x i7cwIeATaSUW0ipKw8wlZLbVYTTaAyc2Hgs9hwrBGOxgpOvAy+3uoL/oYdbHf3ckowTZu9HrL0JRT TPUalcxgLKKqVpUXXSx1gIHmuKKx5buKIf7KD4jIYb4cvjy91mFr6NnbvMFy7z1T2hYmzXeXyhl7+ KbpB7kq9WcOeYjpwHU66I+rhPeqgwH1Z42Sz+1W3NTHPp+xBcsmFVQ1X6pGBmUun+aPjIHhozAX2u p7kTlVm7G0ta185N8Rqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qws8G-000uQh-1q; Sat, 28 Oct 2023 22:50:16 +0000 Received: from smtp-relay-canonical-0.canonical.com ([185.125.188.120]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qws8C-000uPH-0o for opensbi@lists.infradead.org; Sat, 28 Oct 2023 22:50:13 +0000 Received: from LT2ubnt.fritz.box (ip-178-202-040-247.um47.pools.vodafone-ip.de [178.202.40.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 1C6FF411F8; Sat, 28 Oct 2023 22:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1698533410; bh=3XqlJE/8XjTMAFxddcIU/7kOb4vHvVmNz9bZS9Et8Kw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BSx+mnGVTZ0CAqffNM4VLS2KnwdCwAvrejgQ/3n+JKIP2xgkgS5r9ji7yF8HC1rUh J8kFQRnfpE0KtzwxgXjnWMEuL+6RlCP3oxmbtlwy6Wp5RE/rXuQ0ugcMQFuC1TxJiy 0C2e9iaILkUhQ8kcqSwCfLY1XUJ/keH7+xpAPS8fRPoS2j89+ls+f4CPUWQzoYyTvp LaBrP1so/4j226GFUxw4H2I250XfjYO8cp8NFO4Zahe2vTGIVFvWFJB5Ihp1oyr1Cf HAEqkEleBVLtKNL9Z+JLNBOHmYVgxfFlJs4BFYStDlTar4EJfnkoH20IMYPyUTEKRm pDkyrhyk4JZOQ== From: Heinrich Schuchardt To: Atish Patra , Anup Patel Cc: opensbi@lists.infradead.org, Heinrich Schuchardt Subject: [PATCH 1/3] include: sbi: macros for mseccfg.sseed and .useed Date: Sun, 29 Oct 2023 00:49:57 +0200 Message-Id: <20231028224959.95465-2-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231028224959.95465-1-heinrich.schuchardt@canonical.com> References: <20231028224959.95465-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231028_155012_415059_5B9F50B3 X-CRM114-Status: UNSURE ( 8.08 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.7 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Define macros to access the sseed and the useed bit in the machine security configuration register (mseccfg). Signed-off-by: Heinrich Schuchardt --- Just resending this patch which should be merged independent of how we set mseccfg.sseed in future. --- include/sbi/riscv_enc [...] Content analysis details: (-2.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [185.125.188.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Define macros to access the sseed and the useed bit in the machine security configuration register (mseccfg). Signed-off-by: Heinrich Schuchardt Reviewed-by: Xiang W Reviewed-by: Anup Patel --- Just resending this patch which should be merged independent of how we set mseccfg.sseed in future. --- include/sbi/riscv_encoding.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/sbi/riscv_encoding.h b/include/sbi/riscv_encoding.h index a545242..0996d64 100644 --- a/include/sbi/riscv_encoding.h +++ b/include/sbi/riscv_encoding.h @@ -678,6 +678,10 @@ #define MSECCFG_MMWP (_UL(1) << MSECCFG_MMWP_SHIFT) #define MSECCFG_RLB_SHIFT (2) #define MSECCFG_RLB (_UL(1) << MSECCFG_RLB_SHIFT) +#define MSECCFG_USEED_SHIFT (8) +#define MSECCFG_USEED (_UL(1) << MSECCFG_USEED_SHIFT) +#define MSECCFG_SSEED_SHIFT (9) +#define MSECCFG_SSEED (_UL(1) << MSECCFG_SSEED_SHIFT) /* Counter Overflow CSR */ #define CSR_SCOUNTOVF 0xda0 From patchwork Sat Oct 28 22:49:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1856622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=mkDFydQf; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=l6UFIsTy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SHvrS0CZRz1yQQ for ; Sun, 29 Oct 2023 09:50:31 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/b+TV7NijGzg5hVHV4hsmB7V/aBWRj3vLAChEKSZ4U8=; b=mkDFydQfqX4vTK UDxRVoyfSZJII++bqfnFoErhl/dyqHLqzkENQzcMoGWkyLUQXmjuNz8E7gqDcY4KRNuPO9J2qEdVQ rd48KfHL8Rdna9J69QpNa7MlenfyipcJsT758+rlbCm11sFk8IawuJkUi1Eb/bF1WD7ZuF1mADBct iqdoVJekp4xSKD1/VxTEMI62/vGKUatJzyBdaPhfH/eDsbA42A+rXaYTroIoiBtdhpXcQHPyEE+nl k/tsdnX4B+Vq1YGkuT+hK2CLOEQk7uq0PteRvEqTYJ2OI+xgslZ5c5WxdpX9F1YzrmvnZy70KDMDd NlAvjQILHsrbxJvFV23Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qws8H-000uR2-2I; Sat, 28 Oct 2023 22:50:17 +0000 Received: from smtp-relay-canonical-0.canonical.com ([185.125.188.120]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qws8C-000uPI-0y for opensbi@lists.infradead.org; Sat, 28 Oct 2023 22:50:14 +0000 Received: from LT2ubnt.fritz.box (ip-178-202-040-247.um47.pools.vodafone-ip.de [178.202.40.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id BC68942208; Sat, 28 Oct 2023 22:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1698533410; bh=WAt+AKly+Jmo+EjckAO2lp8SpHUcvbwgFLez10Tia3U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l6UFIsTyYkTwPoe25jAVfiSJuzkSlnkhcoNlp1+NwV4zP+SKaiOzV5VbcTkfZzlRL sg/9ON/MlppKb+EoY+6Bk0V0eochY3M+RAFhatJpXEEh9R1mnoUPKKBRiUE66EV4Sz GzgaYswuOdJPYYUSpoiDOHOxP0lGGPZDU2gZzJSQlK3gXkM3gMfTqlnWbPn6TppSDl sHxb0FEDVmSFTUOY2ma/smawac7k8PlCwmYy2RFshG4r/uUTQzXGrPmBqJaBxCmObN mT6UHB0pIYDSQy5npGqW3Eov+ak+FZUggo9H9lBsfJtVW1u/yGYgUsndTyaMAt07U1 ClOpXWmOWaqfw== From: Heinrich Schuchardt To: Atish Patra , Anup Patel Cc: opensbi@lists.infradead.org, Heinrich Schuchardt Subject: [RFC 2/3] lib: sbi: Add Zkr in hart extensions Date: Sun, 29 Oct 2023 00:49:58 +0200 Message-Id: <20231028224959.95465-3-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231028224959.95465-1-heinrich.schuchardt@canonical.com> References: <20231028224959.95465-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231028_155012_467007_0D0E1DB0 X-CRM114-Status: UNSURE ( 8.65 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.7 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: - Add Zkr as extension in sbi_hart_extensions enum - Return "zkr" string for Zkr extension from sbi_hart_extension_id2string Signed-off-by: Heinrich Schuchardt --- include/sbi/sbi_hart.h | 2 ++ lib/sbi/sbi_hart.c | 3 +++ lib/utils/fdt/fdt_helper.c | 1 + 3 files changed, 6 insertions(+) Content analysis details: (-2.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [185.125.188.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org - Add Zkr as extension in sbi_hart_extensions enum - Return "zkr" string for Zkr extension from sbi_hart_extension_id2string Signed-off-by: Heinrich Schuchardt Reviewed-by: Anup Patel --- include/sbi/sbi_hart.h | 2 ++ lib/sbi/sbi_hart.c | 3 +++ lib/utils/fdt/fdt_helper.c | 1 + 3 files changed, 6 insertions(+) diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index e60f415..fe1124a 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -40,6 +40,8 @@ enum sbi_hart_extensions { SBI_HART_EXT_ZICNTR, /** HART has Zihpm extension */ SBI_HART_EXT_ZIHPM, + /** HART has Zkr extension */ + SBI_HART_EXT_ZKR, /** Hart has Smcntrpmf extension */ SBI_HART_EXT_SMCNTRPMF, diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index 29d6481..569596f 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -678,6 +678,9 @@ static inline char *sbi_hart_extension_id2string(int ext) case SBI_HART_EXT_ZIHPM: estr = "zihpm"; break; + case SBI_HART_EXT_ZKR: + estr = "zkr"; + break; case SBI_HART_EXT_SMEPMP: estr = "smepmp"; break; diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index 9ae7f09..35be7ba 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -376,6 +376,7 @@ static int fdt_parse_isa_one_hart(const char *isa, unsigned long *extensions) } set_multi_letter_ext("smepmp", SBI_HART_EXT_SMEPMP); + set_multi_letter_ext("zkr", SBI_HART_EXT_ZKR); #undef set_multi_letter_ext } From patchwork Sat Oct 28 22:49:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1856621 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=DDqLTLTp; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=Ii5GwzZB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SHvrQ2m0Vz1yQ7 for ; Sun, 29 Oct 2023 09:50:30 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cyjmJd6QaSqThBzFqaqBcD2959uaOwRd4FHpNGHeFjU=; b=DDqLTLTpxexKXY W9DArP7dC1NW/Z4fOy+Y2iJG96wwGaEXxvvp92an54HjOx6QIGmU4hcsU0dEOhAfBXKE5vGW8yiqn vB6klcjLuSReEaOVXTZmZkOdRWgvar5ZzwKh3sO5xJCuFPEd/LV7NpreG2FMlIwUY7jrcbKTEcuYl kvlRVm7JxAgPGLqpXfnOJboYnCLEmPc2raSY4xXHuFyIi9a5L7mBrAOGZBpAaKXn/qm55dNoM0aA7 SEFb87EQ1L1xrQaXBVNisyqRPnhXXmlnlQ4OYISlwTIxqrHP/P8lj2OJxGqVb4cfrU8glXan5D10w h6mIdr+MUI1WFBVTGQiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qws8H-000uQr-0Q; Sat, 28 Oct 2023 22:50:17 +0000 Received: from smtp-relay-canonical-0.canonical.com ([185.125.188.120]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qws8C-000uPJ-1j for opensbi@lists.infradead.org; Sat, 28 Oct 2023 22:50:14 +0000 Received: from LT2ubnt.fritz.box (ip-178-202-040-247.um47.pools.vodafone-ip.de [178.202.40.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 212E942D3C; Sat, 28 Oct 2023 22:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1698533411; bh=Fo2RLrEHboi5qUZI6DTSXWtloWravdmsi7FueK2ka0E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ii5GwzZBQYC1GoKFcj/cA8Im9PKB8y85b4OMlfbAb+BUIadIWEj10C+gzfqnz7dxT XgnqvIucirF7axLRlYqmuZr8eBDmW2y6XkVaOuFYmmCtErRKNBJ9mkrSIVu5IruYZB 2qSfmIkds4hOyPCB5dD/4DB2TmSp3vSsuHXnyX+477hmd10bqhrgce6tLkVtdkjhRd DcXNcmxWzm5c7tFsidkr0sQjXTMIYA9NIpQOLseyu0U3I/2vdJAtD6htfg202MSZRD Rk0e43JHJzMYyf3Ci6BEhvHjzN8eFJwmyrTbNzwKCbvXdKaN3VLRNJsqXxVz4Ijvkw nbPnauP1g3fBg== From: Heinrich Schuchardt To: Atish Patra , Anup Patel Cc: opensbi@lists.infradead.org, Heinrich Schuchardt Subject: [RFC 3/3] lib: sbi: enable seed access in S-mode Date: Sun, 29 Oct 2023 00:49:59 +0200 Message-Id: <20231028224959.95465-4-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231028224959.95465-1-heinrich.schuchardt@canonical.com> References: <20231028224959.95465-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231028_155012_702854_A0458517 X-CRM114-Status: UNSURE ( 7.78 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.7 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: If ISA extension Zkr is available, set mseccfg.sseed=1 mseccfg.useed=0 This enables access to the seed CSR in S-mode but not in U-mode. Content analysis details: (-2.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [185.125.188.120 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org If ISA extension Zkr is available, set mseccfg.sseed=1 mseccfg.useed=0 This enables access to the seed CSR in S-mode but not in U-mode. Signed-off-by: Heinrich Schuchardt Reviewed-by: Anup Patel --- lib/sbi/sbi_hart.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index 569596f..5a3e8ee 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -530,6 +530,15 @@ int sbi_hart_unmap_saddr(void) return pmp_disable(SBI_SMEPMP_RESV_ENTRY); } +static void sbi_hart_zkr_configure(struct sbi_scratch *scratch) +{ + unsigned long mseccfg_val = csr_read(CSR_MSECCFG); + + mseccfg_val |= MSECCFG_SSEED; + mseccfg_val &= ~MSECCFG_USEED; + csr_set(CSR_MSECCFG, mseccfg_val); +} + int sbi_hart_pmp_configure(struct sbi_scratch *scratch) { int rc; @@ -551,6 +560,9 @@ int sbi_hart_pmp_configure(struct sbi_scratch *scratch) rc = sbi_hart_oldpmp_configure(scratch, pmp_count, pmp_gran_log2, pmp_addr_max); + if (sbi_hart_has_extension(scratch, SBI_HART_EXT_ZKR)) + sbi_hart_zkr_configure(scratch); + /* * As per section 3.7.2 of privileged specification v1.12, * virtual address translations can be speculatively performed