From: Brian Cain <bc...@quicinc.com> Reviewed-by: Taylor Simpson <ltaylorsimp...@gmail.com> Signed-off-by: Brian Cain <brian.c...@oss.qualcomm.com> --- target/hexagon/hex_mmu.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/target/hexagon/hex_mmu.c b/target/hexagon/hex_mmu.c index 8f9f16158f..476796265b 100644 --- a/target/hexagon/hex_mmu.c +++ b/target/hexagon/hex_mmu.c @@ -359,7 +359,32 @@ bool hex_tlb_find_match(CPUHexagonState *env, target_ulong VA, static uint32_t hex_tlb_lookup_by_asid(CPUHexagonState *env, uint32_t asid, uint32_t VA) { - g_assert_not_reached(); + uint32_t not_found = 0x80000000; + uint32_t idx = not_found; + int i; + + HexagonCPU *cpu = env_archcpu(env); + for (i = 0; i < cpu->num_tlbs; i++) { + uint64_t entry = env->hex_tlb->entries[i]; + if (hex_tlb_entry_match_noperm(entry, asid, VA)) { + if (idx != not_found) { + env->cause_code = HEX_CAUSE_IMPRECISE_MULTI_TLB_MATCH; + break; + } + idx = i; + } + } + + if (idx == not_found) { + qemu_log_mask(CPU_LOG_MMU, + "%s: 0x%" PRIx32 ", 0x%08" PRIx32 " => NOT FOUND\n", + __func__, asid, VA); + } else { + qemu_log_mask(CPU_LOG_MMU, "%s: 0x%" PRIx32 ", 0x%08" PRIx32 " => %d\n", + __func__, asid, VA, idx); + } + + return idx; } /* Called from tlbp instruction */ @@ -461,7 +486,8 @@ static inline void print_thread_states(const char *str) void hex_tlb_lock(CPUHexagonState *env) { - qemu_log_mask(CPU_LOG_MMU, "hex_tlb_lock: %d\n", env->threadId); + qemu_log_mask(CPU_LOG_MMU, "hex_tlb_lock: " TARGET_FMT_ld "\n", + env->threadId); BQL_LOCK_GUARD(); g_assert((env->tlb_lock_count == 0) || (env->tlb_lock_count == 1)); -- 2.34.1