Add a page-level counterpart to helper_tlb_flush(), and condition its
internal call to tlb_flush_page() on return value from the new
sfence_vma_allowed() function.

Signed-off-by: Trevor Gamblin <[email protected]>
---
 target/riscv/helper.h        | 1 +
 target/riscv/tcg/op_helper.c | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/target/riscv/helper.h b/target/riscv/helper.h
index 4fc2d3a155..652f85a5c7 100644
--- a/target/riscv/helper.h
+++ b/target/riscv/helper.h
@@ -137,6 +137,7 @@ DEF_HELPER_1(ctr_clear, void, env)
 DEF_HELPER_1(wfi, void, env)
 DEF_HELPER_1(wrs_nto, void, env)
 DEF_HELPER_1(tlb_flush, void, env)
+DEF_HELPER_2(tlb_flush_page, void, env, tl)
 DEF_HELPER_1(tlb_flush_all, void, env)
 DEF_HELPER_4(ctr_add_entry, void, env, tl, tl, tl)
 /* Native Debug */
diff --git a/target/riscv/tcg/op_helper.c b/target/riscv/tcg/op_helper.c
index 8039df2b48..723a45d181 100644
--- a/target/riscv/tcg/op_helper.c
+++ b/target/riscv/tcg/op_helper.c
@@ -610,6 +610,13 @@ void helper_tlb_flush(CPURISCVState *env)
     }
 }
 
+void helper_tlb_flush_page(CPURISCVState *env, target_ulong addr)
+{
+    if (sfence_vma_allowed(env, GETPC())) {
+        tlb_flush_page(env_cpu(env), addr);
+    }
+}
+
 void helper_tlb_flush_all(CPURISCVState *env)
 {
     CPUState *cs = env_cpu(env);

-- 
2.55.0


Reply via email to