summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnup Patel <apatel@ventanamicro.com>2022-03-29 17:25:23 +0300
committerAnup Patel <anup@brainfault.org>2022-04-05 06:23:11 +0300
commit794986f87fb811ed0c5117fa7d3c84849e9b81d5 (patch)
treeafbd60f6e4686d1a4c7452a72d69f2c3b7755cc3
parent47d676570ddb0b50e741e4239d596de4d875e370 (diff)
downloadopensbi-794986f87fb811ed0c5117fa7d3c84849e9b81d5.tar.xz
lib: sbi: Enable Svpbmt extension in the menvcfg CSR
The menvcfg.PBMTE bit is read-only zero when Svpbmt extension is not available so we try to enable menvcfg.PBMTE bit irrespective whether Svpbmt is available or not. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Xiang W <wxjstz@126.com>
-rw-r--r--lib/sbi/sbi_hart.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index d2c7aba..6be9286 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -114,6 +114,16 @@ static void mstatus_init(struct sbi_scratch *scratch)
*/
menvcfg_val |= ENVCFG_CBIE_INV << ENVCFG_CBIE_SHIFT;
+ /*
+ * Set menvcfg.PBMTE == 1 for RV64 or RV128
+ *
+ * If Svpbmt extension is not available then menvcfg.PBMTE
+ * will be read-only zero.
+ */
+#if __riscv_xlen > 32
+ menvcfg_val |= ENVCFG_PBMTE;
+#endif
+
csr_write(CSR_MENVCFG, menvcfg_val);
}