target/riscv: PMP violation due to wrong size parameter
commit9667e53573f907d4fcd6accff1c8fe525544b749
authorDayeol Lee <dayeol@berkeley.edu>
Tue, 22 Oct 2019 21:21:29 +0000 (22 21:21 +0000)
committerPalmer Dabbelt <palmer@sifive.com>
Mon, 28 Oct 2019 15:46:33 +0000 (28 08:46 -0700)
tree1f183161f449f6d483f66bb2796529a6fa89fb21
parent3aa9004f09c80290e119cd7b93dfca73ab418883
target/riscv: PMP violation due to wrong size parameter

riscv_cpu_tlb_fill() uses the `size` parameter to check PMP violation
using pmp_hart_has_privs().
However, if the size is unknown (=0), the ending address will be
`addr - 1` as it is `addr + size - 1` in `pmp_hart_has_privs()`.
This always causes a false PMP violation on the starting address of the
range, as `addr - 1` is not in the range.

In order to fix, we just assume that all bytes from addr to the end of
the page will be accessed if the size is unknown.

Signed-off-by: Dayeol Lee <dayeol@berkeley.edu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
target/riscv/pmp.c