On 2025/9/3 下午9:02, Richard Henderson wrote:
On 9/3/25 10:48, Bibo Mao wrote:
With API tlb_flush_range_by_mmuidx(), bitmap of mmu idx should be used
rather than itself. Also MMU_KERNEL_IDX and MMU_USER_IDX are used rather
than current running mmu idx when flush TLB.

Signed-off-by: Bibo Mao <[email protected]>
---
  target/loongarch/tcg/tlb_helper.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c
index 9365860c8c..d58f447555 100644
--- a/target/loongarch/tcg/tlb_helper.c
+++ b/target/loongarch/tcg/tlb_helper.c
@@ -101,8 +101,7 @@ static void invalidate_tlb_entry(CPULoongArchState *env, int index)
      target_ulong addr, mask, pagesize;
      uint8_t tlb_ps;
      LoongArchTLB *tlb = &env->tlb[index];
-
-    int mmu_idx = cpu_mmu_index(env_cpu(env), false);
+    int mmu_idx = BIT(MMU_KERNEL_IDX) | BIT(MMU_USER_IDX);
      uint8_t tlb_v0 = FIELD_EX64(tlb->tlb_entry0, TLBENTRY, V);
      uint8_t tlb_v1 = FIELD_EX64(tlb->tlb_entry1, TLBENTRY, V);
      uint64_t tlb_vppn = FIELD_EX64(tlb->tlb_misc, TLB_MISC, VPPN);

Better to rename the variable too, since this isn't an mmu_idx.
We have used "idxmap" elsewhere for this purpose.
sure, will use idxmap in next version.

Regards
Bibo Mao

Otherwise,
Reviewed-by: Richard Henderson <[email protected]>


r~


Reply via email to