qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 5/5] target/riscv: Modify return and parameter type for pmp_ad


From: LIU Zhiwei
Subject: [PATCH v2 5/5] target/riscv: Modify return and parameter type for pmp_adjust_tlb_size
Date: Mon, 22 Nov 2021 19:02:30 +0800

Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
---
 target/riscv/cpu_helper.c |  3 ++-
 target/riscv/pmp.c        | 13 +++++++------
 target/riscv/pmp.h        |  4 ++--
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
index cf8109197d..45e29e6c01 100644
--- a/target/riscv/cpu_helper.c
+++ b/target/riscv/cpu_helper.c
@@ -376,7 +376,8 @@ static int get_physical_address_pmp(CPURISCVState *env, int 
*prot,
 
     *prot = pmp_priv_to_page_prot(pmp_priv);
     if (tlb_size != NULL) {
-        pmp_adjust_tlb_size(env, addr & ~(*tlb_size - 1), tlb_size);
+        *tlb_size = pmp_adjust_tlb_size(env, addr & ~(*tlb_size - 1),
+                                        *tlb_size);
     }
 
     return TRANSLATE_SUCCESS;
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
index 19baf87384..726974c97c 100644
--- a/target/riscv/pmp.c
+++ b/target/riscv/pmp.c
@@ -620,25 +620,26 @@ static target_ulong pmp_get_tlb_size(CPURISCVState *env, 
int pmp_index,
  * Check is there a PMP entry which range covers this page. If so,
  * try to find the minimum granularity for the TLB size.
  */
-void pmp_adjust_tlb_size(CPURISCVState *env, hwaddr tlb_sa,
-                         target_ulong *tlb_size)
+target_ulong pmp_adjust_tlb_size(CPURISCVState *env, hwaddr tlb_sa,
+                                 target_ulong tlb_size)
 {
     int i;
     target_ulong val;
-    target_ulong tlb_ea = (tlb_sa + *tlb_size - 1);
+    target_ulong tlb_ea = (tlb_sa + tlb_size - 1);
 
     if (pmp_get_num_rules(env) == 0) {
-        return;
+        return tlb_size;
     }
 
     for (i = 0; i < MAX_RISCV_PMPS; i++) {
         val = pmp_get_tlb_size(env, i, tlb_sa, tlb_ea);
         if (val) {
-            if (*tlb_size > val) {
-                *tlb_size = val;
+            if (tlb_size > val) {
+                tlb_size = val;
             }
         }
     }
+    return tlb_size;
 }
 
 /*
diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h
index 600ac65d08..c110fb796b 100644
--- a/target/riscv/pmp.h
+++ b/target/riscv/pmp.h
@@ -71,8 +71,8 @@ target_ulong pmpaddr_csr_read(CPURISCVState *env, uint32_t 
addr_index);
 bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr,
     target_ulong size, pmp_priv_t privs, pmp_priv_t *allowed_privs,
     target_ulong mode);
-void pmp_adjust_tlb_size(CPURISCVState *env, hwaddr tlb_sa,
-                         target_ulong *tlb_size);
+target_ulong pmp_adjust_tlb_size(CPURISCVState *env, hwaddr tlb_sa,
+                                 target_ulong tlb_size);
 void pmp_update_rule_addr(CPURISCVState *env, uint32_t pmp_index);
 void pmp_update_rule_nums(CPURISCVState *env);
 uint32_t pmp_get_num_rules(CPURISCVState *env);
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]