Message ID | 20211122110230.38783-2-zhiwei_liu@c-sky.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Check PMP rules num before propagation | expand |
On Mon, Nov 22, 2021 at 9:15 PM LIU Zhiwei <zhiwei_liu@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_liu@c-sky.com> Reviewed-by: Alistair Francis <alistair.francis@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 > >
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) {
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_liu@c-sky.com> --- target/riscv/pmp.c | 4 ++++ 1 file changed, 4 insertions(+)