summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAtish Patra <atishp@rivosinc.com>2022-07-21 00:50:33 +0300
committerAnup Patel <anup@brainfault.org>2022-07-30 08:52:50 +0300
commit83db3af5f93dbbffb599af41c58e26a24b1abc1c (patch)
tree955e10549dd22cb3029950be3c5cc372ce384ad6 /include
parent1545afd342f2e22aaf91c4760dc5706965ec7fdf (diff)
downloadopensbi-83db3af5f93dbbffb599af41c58e26a24b1abc1c.tar.xz
lib: sbi: Add the bound check for events during config match
Currently, there is no sanity check for firmware event code. We don't see any issue as Linux kernel driver does a bound check on firmware events already. However, OpenSBI can't assume sane supervisor mode software always. Thus, an invalid event idx can cause a buffer overflow error. For hardware events, the match will fail for invalid event code anyways. However, a search is unecessary if event code is invalid. Add a event ID validation function to solve the issue. Signed-off-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'include')
-rw-r--r--include/sbi/sbi_ecall_interface.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/sbi/sbi_ecall_interface.h b/include/sbi/sbi_ecall_interface.h
index 70a3bf7..a3f2bf4 100644
--- a/include/sbi/sbi_ecall_interface.h
+++ b/include/sbi/sbi_ecall_interface.h
@@ -208,6 +208,12 @@ enum sbi_pmu_ctr_type {
#define SBI_PMU_EVENT_IDX_INVALID 0xFFFFFFFF
+#define SBI_PMU_EVENT_HW_CACHE_OPS_RESULT 0x1
+#define SBI_PMU_EVENT_HW_CACHE_OPS_ID_MASK 0x6
+#define SBI_PMU_EVENT_HW_CACHE_OPS_ID_OFFSET 1
+#define SBI_PMU_EVENT_HW_CACHE_ID_MASK 0xfff8
+#define SBI_PMU_EVENT_HW_CACHE_ID_OFFSET 3
+
/* Flags defined for config matching function */
#define SBI_PMU_CFG_FLAG_SKIP_MATCH (1 << 0)
#define SBI_PMU_CFG_FLAG_CLEAR_VALUE (1 << 1)