diff options
author | Alistair Francis <alistair.francis@wdc.com> | 2021-04-24 13:33:31 +1000 |
---|---|---|
committer | Alistair Francis <alistair.francis@wdc.com> | 2021-05-11 20:02:07 +1000 |
commit | 419ddf00ed78c7f695a9d318cd8fbcab78b7bede (patch) | |
tree | 5ba1d5da14dccec6ffcef215b381acd532eae840 /target/riscv/csr.c | |
parent | 4fd7455bb39910c0730db66895328cd37b5cee5a (diff) | |
download | qemu-419ddf00ed78c7f695a9d318cd8fbcab78b7bede.zip qemu-419ddf00ed78c7f695a9d318cd8fbcab78b7bede.tar.gz qemu-419ddf00ed78c7f695a9d318cd8fbcab78b7bede.tar.bz2 |
target/riscv: Remove the hardcoded SATP_MODE macro
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 6b701769d6621f45ba1739334198e36a64fe04df.1619234854.git.alistair.francis@wdc.com
Diffstat (limited to 'target/riscv/csr.c')
-rw-r--r-- | target/riscv/csr.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/target/riscv/csr.c b/target/riscv/csr.c index e955753..fe5628f 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -997,16 +997,27 @@ static RISCVException read_satp(CPURISCVState *env, int csrno, static RISCVException write_satp(CPURISCVState *env, int csrno, target_ulong val) { + int vm, mask, asid; + if (!riscv_feature(env, RISCV_FEATURE_MMU)) { return RISCV_EXCP_NONE; } - if (validate_vm(env, get_field(val, SATP_MODE)) && - ((val ^ env->satp) & (SATP_MODE | SATP_ASID | SATP_PPN))) - { + + if (riscv_cpu_is_32bit(env)) { + vm = validate_vm(env, get_field(val, SATP32_MODE)); + mask = (val ^ env->satp) & (SATP32_MODE | SATP32_ASID | SATP32_PPN); + asid = (val ^ env->satp) & SATP32_ASID; + } else { + vm = validate_vm(env, get_field(val, SATP64_MODE)); + mask = (val ^ env->satp) & (SATP64_MODE | SATP64_ASID | SATP64_PPN); + asid = (val ^ env->satp) & SATP64_ASID; + } + + if (vm && mask) { if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) { return RISCV_EXCP_ILLEGAL_INST; } else { - if ((val ^ env->satp) & SATP_ASID) { + if (asid) { tlb_flush(env_cpu(env)); } env->satp = val; |