diff options
| author | Bibo Mao <maobibo@loongson.cn> | 2025-09-04 16:06:03 +0800 |
|---|---|---|
| committer | Bibo Mao <maobibo@loongson.cn> | 2025-09-28 16:10:34 +0800 |
| commit | 58c5522f1736404e6e6d396c1601ad3a1b15d7ed (patch) | |
| tree | 3a51e470a8874dcc0e22eda92a02ba4cbe26a69a | |
| parent | e49d914ceec98a52e67438a8259768482ace639c (diff) | |
| download | focaccia-qemu-58c5522f1736404e6e6d396c1601ad3a1b15d7ed.tar.gz focaccia-qemu-58c5522f1736404e6e6d396c1601ad3a1b15d7ed.zip | |
target/loongarch: Add common API loongarch_tlb_search_cb()
Common API loongarch_tlb_search_cb() is added here to search TLB entry with specified address. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
| -rw-r--r-- | target/loongarch/tcg/tlb_helper.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c index fda81f190a..5b78146769 100644 --- a/target/loongarch/tcg/tlb_helper.c +++ b/target/loongarch/tcg/tlb_helper.c @@ -203,19 +203,16 @@ static uint32_t get_random_tlb(uint32_t low, uint32_t high) * field in tlb entry contains bit[47:13], so need adjust. * virt_vpn = vaddr[47:13] */ -static bool loongarch_tlb_search(CPULoongArchState *env, vaddr vaddr, - int *index) +static bool loongarch_tlb_search_cb(CPULoongArchState *env, vaddr vaddr, + int *index, int csr_asid, tlb_match func) { LoongArchTLB *tlb; - uint16_t csr_asid, tlb_asid, stlb_idx; + uint16_t tlb_asid, stlb_idx; uint8_t tlb_e, tlb_ps, stlb_ps; bool tlb_g; int i, compare_shift; uint64_t vpn, tlb_vppn; - tlb_match func; - func = tlb_match_any; - csr_asid = FIELD_EX64(env->CSR_ASID, CSR_ASID, ASID); stlb_ps = FIELD_EX64(env->CSR_STLBPS, CSR_STLBPS, PS); vpn = (vaddr & TARGET_VIRT_MASK) >> (stlb_ps + 1); stlb_idx = vpn & 0xff; /* VA[25:15] <==> TLBIDX.index for 16KiB Page */ @@ -259,6 +256,17 @@ static bool loongarch_tlb_search(CPULoongArchState *env, vaddr vaddr, return false; } +static bool loongarch_tlb_search(CPULoongArchState *env, vaddr vaddr, + int *index) +{ + int csr_asid; + tlb_match func; + + func = tlb_match_any; + csr_asid = FIELD_EX64(env->CSR_ASID, CSR_ASID, ASID); + return loongarch_tlb_search_cb(env, vaddr, index, csr_asid, func); +} + void helper_tlbsrch(CPULoongArchState *env) { int index, match; |