Skip to content

Commit 3d33e05

Browse files
author
Pavel S. Smirnov
committed
FIX(src/target/riscv/riscv.c): CSR_MCOUNTEREN is not available w/o U or S
1 parent afbfc93 commit 3d33e05

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/target/riscv/riscv.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2966,7 +2966,6 @@ riscv_init_registers(struct target *const target)
29662966
case CSR_INSTRET:
29672967
case CSR_MARCHID:
29682968
case CSR_MCAUSE:
2969-
case CSR_MCOUNTEREN:
29702969
case CSR_MCYCLE:
29712970
case CSR_MEPC:
29722971
case CSR_MHARTID:
@@ -2984,6 +2983,12 @@ riscv_init_registers(struct target *const target)
29842983
p_reg->exist = true;
29852984
break;
29862985

2986+
case CSR_MCOUNTEREN:
2987+
p_reg->exist =
2988+
riscv_supports_extension(target, riscv_current_hartid(target), 'S') ||
2989+
riscv_supports_extension(target, riscv_current_hartid(target), 'U');
2990+
break;
2991+
29872992
case CSR_FFLAGS:
29882993
case CSR_FRM:
29892994
case CSR_FCSR:

0 commit comments

Comments
 (0)