diff options
| author | Ben Zong-You Xie <ben717@andestech.com> | 2026-08-05 17:33:54 +0800 |
|---|---|---|
| committer | Anup Patel <anup@brainfault.org> | 2026-09-04 13:44:57 +0530 |
| commit | 7384968e020f3bf9d524a00c6dc5638f3383aa92 (patch) | |
| tree | f3eefa7aa47e36dba313c763bfae695ce5ce250d | |
| parent | c5077d497d0f7c7c9a74218ef2c448bc1a6d8a31 (diff) | |
| download | opensbi-7384968e020f3bf9d524a00c6dc5638f3383aa92.tar.gz opensbi-7384968e020f3bf9d524a00c6dc5638f3383aa92.zip | |
lib: sbi: respect scounteren when emulating timeh
beef2f693785 ("lib: sbi: Respect scounteren when emulating the time
CSR") restored it for TIME only, so on RV32 supervisor software still
cannot restrict U-mode or VS-mode access to time: rdtime traps as
intended while rdtimeh keeps returning the upper half.
Signed-off-by: Ben Zong-You Xie <ben717@andestech.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260805093354.1022980-1-ben717@andestech.com
Signed-off-by: Anup Patel <anup@brainfault.org>
| -rw-r--r-- | lib/sbi/sbi_emulate_csr.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/sbi/sbi_emulate_csr.c b/lib/sbi/sbi_emulate_csr.c index c2253c82..4558abff 100644 --- a/lib/sbi/sbi_emulate_csr.c +++ b/lib/sbi/sbi_emulate_csr.c @@ -90,7 +90,8 @@ int sbi_emulate_csr_read(int csr_num, struct sbi_trap_regs *regs, *csr_val = csr_read(CSR_MCYCLEH); break; case CSR_TIMEH: - /* Refer comments on TIME CSR above. */ + if (!hpm_allowed(csr_num - CSR_CYCLEH, prev_mode, virt)) + return SBI_ENOTSUPP; *csr_val = (virt) ? sbi_timer_virt_value() >> 32: sbi_timer_value() >> 32; break; |
