From patchwork Wed Jun 5 12:11:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong-Xuan Wang X-Patchwork-Id: 1943824 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=BIos8k9c; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=hkG3qZXh; 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 4VvRCC26Wwz20Wr for ; Wed, 5 Jun 2024 22:11:35 +1000 (AEST) 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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=GN5rXUZ5C0AL3tTdwxtbVbu7dlUiSY62ILJX94RghWg=; b=BIos8k9ct03vhK d8P6EXWhdRLV2Qkv4L9DwJIuJHYXPwniVR711zEpgXFquPitpN+jTaFR9HtOWpaaMb67DjLUwa7Ko UoL2jM/2qeZ6KzVM5Bj1vlmCP9/xAN/nWqdocQVecymarVTkwh8w3Wtu4UfXz6x9UUIiR7RkOLeJa 8GdxMUvenileCBqZolC9habufGk7DQ6coloWRYVyF9/V4jQjWgqLF6PdWlVL/caA/9It1053Rog+8 xldvaEDuMw5iLPmHKAvwfMmWZuYjJRW8q5z1THCftz52IGE4YANh0+sN+po9KozFngG/7EpslQ0ko O+9jkJFqLQ5Vb+kNd8SA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEpUC-00000005u5W-3Xii; Wed, 05 Jun 2024 12:11:24 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEpU9-00000005u35-1FR5 for opensbi@lists.infradead.org; Wed, 05 Jun 2024 12:11:23 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-70259bdcf7cso3138582b3a.0 for ; Wed, 05 Jun 2024 05:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1717589479; x=1718194279; darn=lists.infradead.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=o1HtEpbG0S2pcu49Z17i2sP7TE1YB8bYzqdMhWddSiY=; b=hkG3qZXhJoFlC+RabZVFi2Gx/e1A3qAEbHpSYtlcZnMgalzNj1M7X/lGDWeNSn9QWM vg2AEkLKrPCRkwUiVgxfmN9yPc+2fWdAmEUyLEBZcvV5wYp9RKLEe5rQwlmOIXgpRs5n yfYOk41OGZzUjV2lX66AJtvPXVUjPD18oHhgGMDqEX8+I1n6P9qPV4EY+aeVqPTgeYgl /AvVh2rsxIJCvoE6RXCHWxK1jW0JuVPcRehlfEE1iIGC164/olYZuB6Yx2n1lAMnANdP Di8qTRftcuWBiZL/pmSYPvi7bQrBy4B37c7TjDnC3Awj5a0RxeEeLfY2p0HvdAdajlF4 dJmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717589479; x=1718194279; h=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=o1HtEpbG0S2pcu49Z17i2sP7TE1YB8bYzqdMhWddSiY=; b=BNFv6ObqHw/HaovtOvqqX5AwjvaiaU6BlP7NAVZmr01Uc/MbhRF+ma6Y6ciJza5cc6 QtndESbWxBt5fNHvGaFmZcTk6kxhwIa0ci7wrzFrO/zAfxAvZ+uEv4U3cHcygHtig7eL MmXvCO2sgBnRRx2DwIFnR1m8eC/anvJG1fKsgppls1nVlgzJB8sOm5UXMpdoeXvvmMLI oZ0/e7714Dl6a2pcNUzCx45iRllGHHgXK1KvZo6U+ejTN04s7oPLhXqGckpvf3WAmUDN ET9/pFS0B/Nt4Ph0rAR6R236wbJk+Pz9CSf056DNjyvy4/skPMMVV8adOfQPrupPWNHY bJ7g== X-Gm-Message-State: AOJu0YwoJE0wSVAetumsYAl18uqoGJ9Wldxc3Gickyqighrv4FSZ3Hsm lwSKhvN9Qzr5whMH4jzjjbYP6Lzkh8DjK1fPAzkW2Ny1yUQa/Eku1I7JyH51gu3c95MVynY1BrI CHcyRK+AyPsYOmNWT5LeVjmI+LW8hU3QMJD3wV42uHHZd9vuBgMaLkN8iYiZsDDoj+KjN2XwPD/ a+GY6JcVOWjeqo+3EXgVI2Ui4XGzguHKH0JLYMjTZ8YdVhMM+7NJFf X-Google-Smtp-Source: AGHT+IELkPXmf4YzZ/6VE8W8XOL0FSTWNK3jdpfFhx/XZlBPDw9yBoOqn3vtRXL5+MR5foMj5GQAHg== X-Received: by 2002:a05:6a20:dd89:b0:1b2:b3a5:22b2 with SMTP id adf61e73a8af0-1b2b71a0859mr2266518637.60.1717589478746; Wed, 05 Jun 2024 05:11:18 -0700 (PDT) Received: from hsinchu26.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-702423dc040sm8524559b3a.56.2024.06.05.05.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:11:18 -0700 (PDT) From: Yong-Xuan Wang To: opensbi@lists.infradead.org Cc: apatel@ventanamicro.com, alex@ghiti.fr, ajones@ventanamicro.com, greentime.hu@sifive.com, vincent.chen@sifive.com, Yong-Xuan Wang Subject: [PATCH v4 1/2] lib: sbi: Add support for Svade and Svadu extensions Date: Wed, 5 Jun 2024 20:11:09 +0800 Message-Id: <20240605121110.14784-2-yongxuan.wang@sifive.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240605121110.14784-1-yongxuan.wang@sifive.com> References: <20240605121110.14784-1-yongxuan.wang@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_051121_359689_1EBE4385 X-CRM114-Status: GOOD ( 11.21 ) X-Spam-Score: -0.2 (/) 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 support for Svade and Svadu extensions. When both are present in the device tree, the M-mode firmware should select the Svade extension to comply with the RVA23 profile, which mandates Svade and l [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42e listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches 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.0 T_SCC_BODY_TEXT_LINE No description available. 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: , MIME-Version: 1.0 Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add support for Svade and Svadu extensions. When both are present in the device tree, the M-mode firmware should select the Svade extension to comply with the RVA23 profile, which mandates Svade and lists Svadu as an optional extension. Signed-off-by: Yong-Xuan Wang Reviewed-by: Anup Patel --- include/sbi/riscv_encoding.h | 1 + include/sbi/sbi_hart.h | 4 ++++ lib/sbi/sbi_hart.c | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/include/sbi/riscv_encoding.h b/include/sbi/riscv_encoding.h index d914828e13af..477fa3a1ad86 100644 --- a/include/sbi/riscv_encoding.h +++ b/include/sbi/riscv_encoding.h @@ -211,6 +211,7 @@ #define ENVCFG_STCE (_ULL(1) << 63) #define ENVCFG_PBMTE (_ULL(1) << 62) +#define ENVCFG_ADUE (_ULL(1) << 61) #define ENVCFG_CDE (_ULL(1) << 60) #define ENVCFG_CBZE (_UL(1) << 7) #define ENVCFG_CBCFE (_UL(1) << 6) diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index cc78eec6f65a..81ec061d36a9 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -63,6 +63,10 @@ enum sbi_hart_extensions { SBI_HART_EXT_SSCSRIND, /** Hart has Ssccfg extension */ SBI_HART_EXT_SSCCFG, + /** Hart has Svade extension */ + SBI_HART_EXT_SVADE, + /** Hart has Svadu extension */ + SBI_HART_EXT_SVADU, /** Maximum index of Hart extension */ SBI_HART_EXT_MAX, diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index cd974cc1a8da..c3667019b9a1 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -135,9 +135,19 @@ static void mstatus_init(struct sbi_scratch *scratch) #endif __set_menvcfg_ext(SBI_HART_EXT_SSTC, ENVCFG_STCE) __set_menvcfg_ext(SBI_HART_EXT_SMCDELEG, ENVCFG_CDE); + __set_menvcfg_ext(SBI_HART_EXT_SVADU, ENVCFG_ADUE); #undef __set_menvcfg_ext + /* + * When both Svade and Svadu are present in DT, the default scheme for managing + * the PTE A/D bits should use Svade. Check Svadu before Svade extension to ensure + * that the ADUE bit is cleared when the Svade support are specified. + */ + + if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SVADE)) + menvcfg_val &= ~ENVCFG_ADUE; + csr_write(CSR_MENVCFG, menvcfg_val); #if __riscv_xlen == 32 csr_write(CSR_MENVCFGH, menvcfg_val >> 32); @@ -668,6 +678,8 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = { __SBI_HART_EXT_DATA(smcdeleg, SBI_HART_EXT_SMCDELEG), __SBI_HART_EXT_DATA(sscsrind, SBI_HART_EXT_SSCSRIND), __SBI_HART_EXT_DATA(ssccfg, SBI_HART_EXT_SSCCFG), + __SBI_HART_EXT_DATA(svade, SBI_HART_EXT_SVADE), + __SBI_HART_EXT_DATA(svadu, SBI_HART_EXT_SVADU), }; _Static_assert(SBI_HART_EXT_MAX == array_size(sbi_hart_ext),