Skip to contentSkip to conversation

target/riscv: Only flush TLB if SATP.ASID changes

PATCH In review Jonathan Behrens 4 participants 4 messages May 8, 2019 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/riscv: Only flush TLB if SATP.ASID changes

There is an analogous change for ARM here:
https://patchwork.kernel.org/patch/10649857

---
 target/riscv/csr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
target/riscv/csr.c +3 -1
index 6083c782a1..1ec1222da1 100644
@@ -732,7 +732,9 @@ static int write_satp(CPURISCVState *env, int csrno, target_ulong val)
         if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) {
             return -1;
         } else {
-            tlb_flush(CPU(riscv_env_get_cpu(env)));
+            if((val ^ env->satp) & SATP_ASID) {
+                tlb_flush(CPU(riscv_env_get_cpu(env)));
+            }
             env->satp = val;
         }
     }
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Jonathan Behrens
Quoted 5 lines · Jonathan Behrens

There is an analogous change for ARM here:
https://patchwork.kernel.org/patch/10649857

Alistair

Quoted 22 lines
---
 target/riscv/csr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
target/riscv/csr.c +3 -2
index 6083c782a1..1ec1222da1 100644
@@ -732,7 +732,9 @@ static int write_satp(CPURISCVState *env, int csrno, target_ulong val)
         if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) {
             return -1;
         } else {
-            tlb_flush(CPU(riscv_env_get_cpu(env)));
+            if((val ^ env->satp) & SATP_ASID) {
+                tlb_flush(CPU(riscv_env_get_cpu(env)));
+            }
             env->satp = val;
         }
     }
--

2.20.1

#3 lore raw
In reply to Jonathan Behrens
Quoted 13 lines · On Wed, 08 May 2019 10:38:35 PDT (-0700), [email protected] wrote:

There is an analogous change for ARM here:
https://patchwork.kernel.org/patch/10649857

---
 target/riscv/csr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
target/riscv/csr.c +0 -0
index 6083c782a1..1ec1222da1 100644

target/riscv/csr.c static int write_satp(CPURISCVState *env, int csrno, target_ulong val) · line 740

Quoted 10 lines
target/riscv/csr.c +3 -1
@@ -732,7 +732,9 @@ static int write_satp(CPURISCVState *env, int csrno, target_ulong val)
         if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) {
             return -1;
         } else {
-            tlb_flush(CPU(riscv_env_get_cpu(env)));
+            if((val ^ env->satp) & SATP_ASID) {
+                tlb_flush(CPU(riscv_env_get_cpu(env)));
+            }
             env->satp = val;
         }
     }

Thanks! I've taken this into my for-master branch, pending some testing I'll send it up.