On 4/2/21 1:02 PM, Alistair Francis wrote:
Signed-off-by: Alistair Francis <alistair.fran...@wdc.com> --- target/riscv/cpu_bits.h | 11 ----------- target/riscv/cpu_helper.c | 21 ++++++++++++++++----- 2 files changed, 16 insertions(+), 16 deletions(-)
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
@@ -621,9 +626,15 @@ static void raise_mmu_exception(CPURISCVState *env, target_ulong address, get_field(env->satp, SATP_MODE) != VM_1_10_MBARE && !pmp_violation; } else { - page_fault_exceptions = - get_field(env->hgatp, HGATP_MODE) != VM_1_10_MBARE && - !pmp_violation; + if (riscv_cpu_is_32bit(env)) { + page_fault_exceptions = + get_field(env->hgatp, SATP32_MODE) != VM_1_10_MBARE && + !pmp_violation; + } else { + page_fault_exceptions = + get_field(env->hgatp, SATP64_MODE) != VM_1_10_MBARE && + !pmp_violation; + }
Looks like you could simplify this to extract the vm in each if branch, then do the comparison afterward.
if (first) { vm = ... } else if (32bit) { vm = ... } else { vm = ... } page_fault_exceptions = vm != VM_1_10_MBARE && !pmp_violation; r~