Message ID | 246b1d1fa8d1ad334152ace0cad21e8f40d53e7f.1588878756.git.alistair.francis@wdc.com |
---|---|
State | New |
Headers | show |
Series | RISC-V Add the OpenTitan Machine | expand |
On Fri, May 8, 2020 at 3:29 AM Alistair Francis <alistair.francis@wdc.com> wrote: > > Signed-off-by: Alistair Francis <alistair.francis@wdc.com> > --- > target/riscv/pmp.c | 19 ++++++++++++++----- > 1 file changed, 14 insertions(+), 5 deletions(-) > > diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c > index 0e6b640fbd..5aba4d13ea 100644 > --- a/target/riscv/pmp.c > +++ b/target/riscv/pmp.c > @@ -233,12 +233,21 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, > return true; > } > > - /* > - * if size is unknown (0), assume that all bytes > - * from addr to the end of the page will be accessed. > - */ > if (size == 0) { > - pmp_size = -(addr | TARGET_PAGE_MASK); > + if (!riscv_feature(env, RISCV_FEATURE_MMU)) { > + /* > + * if size is unknown (0), assume that all bytes > + * from addr to the end of the page will be accessed. > + */ > + pmp_size = -(addr | TARGET_PAGE_MASK); > + } else { > + /* > + * If size is unknown (0) and we don't have an MMU, > + * just guess the size as the xlen as we don't want to > + * access an entire page worth. > + */ It looks the comment does not match the code logic. This else branch is the MMU branch. > + pmp_size = sizeof(target_ulong); > + } > } else { > pmp_size = size; > } > -- Regards, Bin
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 0e6b640fbd..5aba4d13ea 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -233,12 +233,21 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, return true; } - /* - * if size is unknown (0), assume that all bytes - * from addr to the end of the page will be accessed. - */ if (size == 0) { - pmp_size = -(addr | TARGET_PAGE_MASK); + if (!riscv_feature(env, RISCV_FEATURE_MMU)) { + /* + * if size is unknown (0), assume that all bytes + * from addr to the end of the page will be accessed. + */ + pmp_size = -(addr | TARGET_PAGE_MASK); + } else { + /* + * If size is unknown (0) and we don't have an MMU, + * just guess the size as the xlen as we don't want to + * access an entire page worth. + */ + pmp_size = sizeof(target_ulong); + } } else { pmp_size = size; }
Signed-off-by: Alistair Francis <alistair.francis@wdc.com> --- target/riscv/pmp.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)