qemu-riscv
[Top][All Lists]
Advanced

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

[PATCH v2 2/5] target/riscv: Give a more generic size for tlb


From: LIU Zhiwei
Subject: [PATCH v2 2/5] target/riscv: Give a more generic size for tlb
Date: Mon, 22 Nov 2021 19:02:27 +0800

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(-)

diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
index 9eeed38c7e..3f53744897 100644
--- a/target/riscv/cpu_helper.c
+++ b/target/riscv/cpu_helper.c
@@ -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;
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
index 190ff59fab..ca38087574 100644
--- a/target/riscv/pmp.c
+++ b/target/riscv/pmp.c
@@ -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;
     }
 
-- 
2.25.1




reply via email to

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