Skip to content

Commit 58c5522

Browse files
committed
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>
1 parent e49d914 commit 58c5522

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

target/loongarch/tcg/tlb_helper.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,16 @@ static uint32_t get_random_tlb(uint32_t low, uint32_t high)
203203
* field in tlb entry contains bit[47:13], so need adjust.
204204
* virt_vpn = vaddr[47:13]
205205
*/
206-
static bool loongarch_tlb_search(CPULoongArchState *env, vaddr vaddr,
207-
int *index)
206+
static bool loongarch_tlb_search_cb(CPULoongArchState *env, vaddr vaddr,
207+
int *index, int csr_asid, tlb_match func)
208208
{
209209
LoongArchTLB *tlb;
210-
uint16_t csr_asid, tlb_asid, stlb_idx;
210+
uint16_t tlb_asid, stlb_idx;
211211
uint8_t tlb_e, tlb_ps, stlb_ps;
212212
bool tlb_g;
213213
int i, compare_shift;
214214
uint64_t vpn, tlb_vppn;
215-
tlb_match func;
216215

217-
func = tlb_match_any;
218-
csr_asid = FIELD_EX64(env->CSR_ASID, CSR_ASID, ASID);
219216
stlb_ps = FIELD_EX64(env->CSR_STLBPS, CSR_STLBPS, PS);
220217
vpn = (vaddr & TARGET_VIRT_MASK) >> (stlb_ps + 1);
221218
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,
259256
return false;
260257
}
261258

259+
static bool loongarch_tlb_search(CPULoongArchState *env, vaddr vaddr,
260+
int *index)
261+
{
262+
int csr_asid;
263+
tlb_match func;
264+
265+
func = tlb_match_any;
266+
csr_asid = FIELD_EX64(env->CSR_ASID, CSR_ASID, ASID);
267+
return loongarch_tlb_search_cb(env, vaddr, index, csr_asid, func);
268+
}
269+
262270
void helper_tlbsrch(CPULoongArchState *env)
263271
{
264272
int index, match;

0 commit comments

Comments
 (0)