aboutsummaryrefslogtreecommitdiff
path: root/lib/sbi/sbi_hart.c
diff options
context:
space:
mode:
authorKaiwen Xue <kaiwenx@rivosinc.com>2023-07-20 14:07:02 -0700
committerAnup Patel <anup@brainfault.org>2023-08-18 14:50:38 +0530
commitc104c60912a4ed26093f00a9675ad0286e8dcd29 (patch)
tree5918274955d1c6df51197abdacf8ce1c4ee978ef /lib/sbi/sbi_hart.c
parent94197a8c49751eabe73ff2849fce183ac8ead3fd (diff)
downloadopensbi-c104c60912a4ed26093f00a9675ad0286e8dcd29.zip
opensbi-c104c60912a4ed26093f00a9675ad0286e8dcd29.tar.gz
opensbi-c104c60912a4ed26093f00a9675ad0286e8dcd29.tar.bz2
lib: sbi: Add support for smcntrpmf
This adds the support for ISA extension smcntrpmf. When some inhibit flags are set by a lower privilege mode for new CSRs added by smcntrpmf, OpenSBI sets the appropriate values correspondingly. Signed-off-by: Kaiwen Xue <kaiwenx@andrew.cmu.edu> Signed-off-by: Kaiwen Xue <kaiwenx@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org> Reviewed-by: Atish Patra <atishp@rivosinc.com>
Diffstat (limited to 'lib/sbi/sbi_hart.c')
-rw-r--r--lib/sbi/sbi_hart.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index 252f33d..be795f5 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -606,6 +606,9 @@ static inline char *sbi_hart_extension_id2string(int ext)
case SBI_HART_EXT_SMEPMP:
estr = "smepmp";
break;
+ case SBI_HART_EXT_SMCNTRPMF:
+ estr = "smcntrpmf";
+ break;
default:
break;
}
@@ -872,6 +875,14 @@ __pmp_skip:
SBI_HART_EXT_SMSTATEEN, true);
}
+ /* Detect if hart supports smcntrpmf */
+ if (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_12) {
+ csr_read_allowed(CSR_MCYCLECFG, (unsigned long)&trap);
+ if (!trap.cause)
+ __sbi_hart_update_extension(hfeatures,
+ SBI_HART_EXT_SMCNTRPMF, true);
+ }
+
/* Let platform populate extensions */
rc = sbi_platform_extensions_init(sbi_platform_thishart_ptr(),
hfeatures);