aboutsummaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
authorAtish Patra <atishp@rivosinc.com>2022-07-20 14:50:32 -0700
committerAnup Patel <anup@brainfault.org>2022-07-30 11:09:18 +0530
commit1545afd342f2e22aaf91c4760dc5706965ec7fdf (patch)
treeaffabfba9fc05a9814ddeedba94abe8eaec31795 /lib/utils
parent88b790f1291618274f94b6d5110ed09e20148bb2 (diff)
downloadopensbi-1545afd342f2e22aaf91c4760dc5706965ec7fdf.zip
opensbi-1545afd342f2e22aaf91c4760dc5706965ec7fdf.tar.gz
opensbi-1545afd342f2e22aaf91c4760dc5706965ec7fdf.tar.bz2
lib: sbi: Fix counter index sanity check
The current implementation computes the possible counter range by doing a left shift of counter base. However, this may overflow depending on the counter base value. In case of overflow, the highest counter id may be computed incorrectly. As per the SBI specification, the respective function should return an error if any of the counter is not valid. Fix the counter index check by avoiding left shifting while doing the sanity checks. Without the shift, the implementation just iterates over the counter mask and computes the correct counter index by adding the base to it. Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'lib/utils')
0 files changed, 0 insertions, 0 deletions