target/riscv: Simplify {read, write}_pmpcfg() a little bit

Use the register index that has already been calculated in the
pmpcfg_csr_{read,write} call.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Message-ID: <20230228104035.1879882-9-bmeng@tinylab.org>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
This commit is contained in:
Bin Meng 2023-02-28 18:40:24 +08:00 committed by Palmer Dabbelt
parent a7e407b3f8
commit 77ad639cb1
No known key found for this signature in database
GPG Key ID: 2E1319F35FBB1889
1 changed files with 2 additions and 2 deletions

View File

@ -3360,7 +3360,7 @@ static RISCVException read_pmpcfg(CPURISCVState *env, int csrno,
if (!check_pmp_reg_index(env, reg_index)) {
return RISCV_EXCP_ILLEGAL_INST;
}
*val = pmpcfg_csr_read(env, csrno - CSR_PMPCFG0);
*val = pmpcfg_csr_read(env, reg_index);
return RISCV_EXCP_NONE;
}
@ -3372,7 +3372,7 @@ static RISCVException write_pmpcfg(CPURISCVState *env, int csrno,
if (!check_pmp_reg_index(env, reg_index)) {
return RISCV_EXCP_ILLEGAL_INST;
}
pmpcfg_csr_write(env, csrno - CSR_PMPCFG0, val);
pmpcfg_csr_write(env, reg_index, val);
return RISCV_EXCP_NONE;
}