[RFC PATCH 1/1] lib/sbi: Enable menvcfg.CDE for Sspesa
Mayuresh Chitale <[email protected]>
| Newsgroups | org.infradead.lists.opensbi |
|---|---|
| Message-ID | <[email protected]> |
The Sspesa (Precise Event Sample Attribution) extension exposes the shpmspc and shpmsdata CSRs and S-mode access to these CSRs is gated by menvcfg.CDE. Hence set menvcfg.CDE when Sspesa is enabled. Signed-off-by: Mayuresh Chitale <[email protected]> --- include/sbi/riscv_encoding.h | 4 ++++ include/sbi/sbi_hart.h | 2 ++ lib/sbi/sbi_hart.c | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/sbi/riscv_encoding.h b/include/sbi/riscv_encoding.h index ffe7666c..12cc0b0c 100644 --- a/include/sbi/riscv_encoding.h +++ b/include/sbi/riscv_encoding.h @@ -751,6 +751,10 @@ /* Counter Overflow CSR */ #define CSR_SCOUNTOVF 0xda0 +/* Temporary addresses for Sspesa (Precise Event Sample Attribution) CSRs. */ +#define CSR_SHPMSPC 0x5d0 +#define CSR_SHPMSDATA 0x5d1 + /* Debug/Trace Registers */ #define CSR_TSELECT 0x7a0 #define CSR_TDATA1 0x7a1 diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index 543393bb..2abdc504 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -95,6 +95,8 @@ enum sbi_hart_extensions { SBI_HART_EXT_F, /** Hart has D extension */ SBI_HART_EXT_D, + /** Hart has Sspesa extension */ + SBI_HART_EXT_SSPESA, /** Maximum index of Hart extension */ SBI_HART_EXT_MAX, diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index bee88557..783a0773 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -160,7 +160,8 @@ static void mstatus_init(struct sbi_scratch *scratch) __set_menvcfg_ext(SBI_HART_EXT_SVPBMT, ENVCFG_PBMTE) #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_SMCDELEG, ENVCFG_CDE) + __set_menvcfg_ext(SBI_HART_EXT_SSPESA, ENVCFG_CDE); /* * Assume only Svadu is supported when it is the only extension @@ -360,6 +361,7 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = { __SBI_HART_EXT_DATA(v, SBI_HART_EXT_V), __SBI_HART_EXT_DATA(f, SBI_HART_EXT_F), __SBI_HART_EXT_DATA(d, SBI_HART_EXT_D), + __SBI_HART_EXT_DATA(sspesa, SBI_HART_EXT_SSPESA), }; _Static_assert(SBI_HART_EXT_MAX == array_size(sbi_hart_ext), @@ -629,6 +631,9 @@ __pmp_skip: /* Detect if hart supports sscofpmf */ __check_ext_csr(SBI_HART_PRIV_VER_1_11, CSR_SCOUNTOVF, SBI_HART_EXT_SSCOFPMF); + /* Detect if hart supports Sspesa (precise sample attribution) */ + __check_ext_csr(SBI_HART_PRIV_VER_1_12, + CSR_SHPMSPC, SBI_HART_EXT_SSPESA); /* Detect if hart has AIA local interrupt CSRs */ __check_ext_csr(SBI_HART_PRIV_VER_UNKNOWN, CSR_MTOPI, SBI_HART_EXT_SMAIA); -- 2.43.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi