Skip to content

Commit

Permalink
riscv: Skip checking CSR privilege level in debugger mode
Browse files Browse the repository at this point in the history
If we are in debugger mode, skip the CSR privilege level checking
so that we can read/write all CSRs. Otherwise we get:

(gdb) p/x $mtvec
Could not fetch register "mtvec"; remote failure reply 'E14'

when the hart is currently in S-mode.

Reported-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
  • Loading branch information
lbmeng authored and palmer-dabbelt committed Oct 28, 2019
1 parent 9bb7350 commit e6e03dc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion target/riscv/csr.c
Expand Up @@ -801,7 +801,10 @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value,
#if !defined(CONFIG_USER_ONLY)
int csr_priv = get_field(csrno, 0x300);
int read_only = get_field(csrno, 0xC00) == 3;
if ((write_mask && read_only) || (env->priv < csr_priv)) {
if ((!env->debugger) && (env->priv < csr_priv)) {
return -1;
}
if (write_mask && read_only) {
return -1;
}
#endif
Expand Down

0 comments on commit e6e03dc

Please sign in to comment.