riscvarchive / riscv-qemu

QEMU with RISC-V (RV64G, RV32G) Emulation Support
384 stars 154 forks source link

riscv pmp issues (fetch) #168

Closed wxjstz closed 5 years ago

wxjstz commented 5 years ago

I try to test PMP by qemu/riscv-probe. But I found this issues.

Function riscv_cpu_handle_mmu_fault in target/riscv/cpu_helper.c.

if (riscv_feature(env, RISCV_FEATURE_PMP) &&
        !pmp_hart_has_privs(env, pa, TARGET_PAGE_SIZE, 1 << rw)) {
        ret = TRANSLATE_FAIL;
    }

PMP granularity can be less than one page, so in my test it cause error. I change TARGET_PAGE_SIZE to real size. It passed.

I try to monitor all PMP check (dump info in function pmp_hart_has_privs). I found that only a few fetch will perform a PMP check.

michaeljclark commented 5 years ago

I'm closing this as we have updated the interface to take the request size and the TLB size (inout) which is updated if the matching rule is smaller than the initial TLB size (PAGE_SIZE). Check qemu-for-upstream. It includes our co-authored work including your fixes and mine.