mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-09-08 18:21:29 +01:00
lib: sbi: respect scounteren when emulating timeh
beef2f6937 ("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>
This commit is contained in:
committed by
Anup Patel
parent
c5077d497d
commit
7384968e02
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user