On Mon, Nov 22, 2021 at 9:15 PM LIU Zhiwei <zhiwei_...@c-sky.com> wrote: > > When an address is in [0-4K) and no pmp rule configured, the tlb_size will > be set to 1. > > This is caused by pmp_get_tlb_size return a value 1. > > if (pmp_sa >= tlb_sa && pmp_ea <= tlb_ea) { > return pmp_ea - pmp_sa + 1; > } > > Here pmp_sa == 0 and pmp_ea == 0. > > Signed-off-by: LIU Zhiwei <zhiwei_...@c-sky.com>
Reviewed-by: Alistair Francis <alistair.fran...@wdc.com> Alistair > --- > target/riscv/pmp.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c > index 54abf42583..190ff59fab 100644 > --- a/target/riscv/pmp.c > +++ b/target/riscv/pmp.c > @@ -627,6 +627,10 @@ bool pmp_is_range_in_tlb(CPURISCVState *env, hwaddr > tlb_sa, > target_ulong val; > target_ulong tlb_ea = (tlb_sa + TARGET_PAGE_SIZE - 1); > > + if (pmp_get_num_rules(env) == 0) { > + return false; > + } > + > for (i = 0; i < MAX_RISCV_PMPS; i++) { > val = pmp_get_tlb_size(env, i, tlb_sa, tlb_ea); > if (val) { > -- > 2.25.1 > >