From 5845f3b71c09bb1a16bd6fec18e876708aaf02d6 Mon Sep 17 00:00:00 2001 From: Parshintsev Anatoly Date: Fri, 10 Feb 2023 02:08:40 +0300 Subject: [PATCH] CSR_MCOUNTEREN should not exist if U-mode is not supported Change-Id: I1a2420fb88bd3ee37f6a539992e8dc119fdd6e0e --- src/target/riscv/riscv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 378704175..d198010dc 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -5193,6 +5193,9 @@ int riscv_init_registers(struct target *target) case CSR_VLENB: r->exist = (info->vlenb > 0); break; + case CSR_MCOUNTEREN: + r->exist = riscv_supports_extension(target, 'U'); + break; } if (!r->exist && !list_empty(&info->expose_csr)) {