Skip to content

Commit 96e654c

Browse files
committed
target/loongarch: Use loongarch_tlb_search_cb in helper_invtlb_page_asid_or_g
With function helper_invtlb_page_asid_or_g(), currently it is to search TLB entry one by one. Instead STLB can be searched at first with hash method, and then search MTLB with one by one method. Here common API loongarch_tlb_search_cb() is used in function helper_invtlb_page_asid_or_g(). Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
1 parent 5e3cced commit 96e654c

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

target/loongarch/tcg/tlb_helper.c

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -559,31 +559,16 @@ void helper_invtlb_page_asid(CPULoongArchState *env, target_ulong info,
559559
void helper_invtlb_page_asid_or_g(CPULoongArchState *env,
560560
target_ulong info, target_ulong addr)
561561
{
562-
uint16_t asid = info & 0x3ff;
563-
564-
for (int i = 0; i < LOONGARCH_TLB_MAX; i++) {
565-
LoongArchTLB *tlb = &env->tlb[i];
566-
uint8_t tlb_g = FIELD_EX64(tlb->tlb_entry0, TLBENTRY, G);
567-
uint16_t tlb_asid = FIELD_EX64(tlb->tlb_misc, TLB_MISC, ASID);
568-
uint64_t vpn, tlb_vppn;
569-
uint8_t tlb_ps, compare_shift;
570-
uint8_t tlb_e = FIELD_EX64(tlb->tlb_misc, TLB_MISC, E);
571-
572-
if (!tlb_e) {
573-
continue;
574-
}
575-
576-
tlb_ps = FIELD_EX64(tlb->tlb_misc, TLB_MISC, PS);
577-
tlb_vppn = FIELD_EX64(tlb->tlb_misc, TLB_MISC, VPPN);
578-
vpn = (addr & TARGET_VIRT_MASK) >> (tlb_ps + 1);
579-
compare_shift = tlb_ps + 1 - R_TLB_MISC_VPPN_SHIFT;
562+
int asid = info & 0x3ff;
563+
LoongArchTLB *tlb;
564+
tlb_match func;
580565

581-
if ((tlb_g || (tlb_asid == asid)) &&
582-
(vpn == (tlb_vppn >> compare_shift))) {
583-
tlb->tlb_misc = FIELD_DP64(tlb->tlb_misc, TLB_MISC, E, 0);
584-
}
566+
func = tlb_match_any;
567+
tlb = loongarch_tlb_search_cb(env, addr, asid, func);
568+
if (tlb) {
569+
tlb->tlb_misc = FIELD_DP64(tlb->tlb_misc, TLB_MISC, E, 0);
570+
tlb_flush(env_cpu(env));
585571
}
586-
tlb_flush(env_cpu(env));
587572
}
588573

589574
bool loongarch_cpu_tlb_fill(CPUState *cs, vaddr address, int size,

0 commit comments

Comments
 (0)