@@ -362,7 +362,6 @@ static int get_physical_address_pmp(CPURISCVState *env, int *prot,
int mode)
{
pmp_priv_t pmp_priv;
- target_ulong tlb_size_pmp = 0;
if (!riscv_feature(env, RISCV_FEATURE_PMP)) {
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
@@ -377,9 +376,7 @@ static int get_physical_address_pmp(CPURISCVState *env, int *prot,
*prot = pmp_priv_to_page_prot(pmp_priv);
if (tlb_size != NULL) {
- if (pmp_is_range_in_tlb(env, addr & ~(*tlb_size - 1), &tlb_size_pmp)) {
- *tlb_size = tlb_size_pmp;
- }
+ pmp_is_range_in_tlb(env, addr & ~(*tlb_size - 1), tlb_size);
}
return TRANSLATE_SUCCESS;
@@ -625,7 +625,8 @@ bool pmp_is_range_in_tlb(CPURISCVState *env, hwaddr tlb_sa,
{
int i;
target_ulong val;
- target_ulong tlb_ea = (tlb_sa + TARGET_PAGE_SIZE - 1);
+ target_ulong tlb_ea = (tlb_sa + *tlb_size - 1);
+ target_ulong old_size = *tlb_size;
if (pmp_get_num_rules(env) == 0) {
return false;
@@ -634,13 +635,13 @@ bool pmp_is_range_in_tlb(CPURISCVState *env, hwaddr tlb_sa,
for (i = 0; i < MAX_RISCV_PMPS; i++) {
val = pmp_get_tlb_size(env, i, tlb_sa, tlb_ea);
if (val) {
- if (*tlb_size == 0 || *tlb_size > val) {
+ if (*tlb_size > val) {
*tlb_size = val;
}
}
}
- if (*tlb_size != 0) {
+ if (*tlb_size != old_size) {
return true;
}
As the caller has given a tlb size parameter, we should use it to keep pace with it. Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> --- target/riscv/cpu_helper.c | 5 +---- target/riscv/pmp.c | 7 ++++--- 2 files changed, 5 insertions(+), 7 deletions(-)