src/qemu/src-pmp/accel/tcg/cputlb.c
/* Return true if ADDR is present in the victim tlb, and has been copied
   back to the main tlb.  */
Return true if ADDR is present in the victim tlb, and has been copied
back to the main tlb.
Return true if ADDR is present in the victim tlb and has been copied back to the main tlb .
static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index,
                           size_t elt_ofs, target_ulong page)
{
    size_t vidx;
    assert_cpu_is_self(ENV_GET_CPU(env));
    for (vidx = 0; vidx < CPU_VTLB_SIZE; ++vidx) {
        CPUTLBEntry *vtlb = &env->tlb_v_table[mmu_idx][vidx];
        target_ulong cmp;
#if TCG_OVERSIZED_GUEST
        cmp = *(target_ulong *)((uintptr_t)vtlb + elt_ofs);
#else
        cmp = atomic_read((target_ulong *)((uintptr_t)vtlb + elt_ofs));
#endif
        if (cmp == page) {
            CPUTLBEntry tmptlb, *tlb = &env->tlb_table[mmu_idx][index];
            qemu_spin_lock(&env->tlb_c.lock);
            copy_tlb_helper_locked(&tmptlb, tlb);
            copy_tlb_helper_locked(tlb, vtlb);
            copy_tlb_helper_locked(vtlb, &tmptlb);
            qemu_spin_unlock(&env->tlb_c.lock);
            CPUIOTLBEntry tmpio, *io = &env->iotlb[mmu_idx][index];
            CPUIOTLBEntry *vio = &env->iotlb_v[mmu_idx][vidx];
            tmpio = *io; *io = *vio; *vio = tmpio;
            return true;
        }
    }
    return false;
}
static bool victim_tlb_hit ( CPUArchState * env , size_t mmu_idx , size_t index , size_t elt_ofs , target_ulong page ) { size_t vidx ; assert_cpu_is_self ( ENV_GET_CPU ( env ) ) ; for ( vidx = 0 ; vidx < CPU_VTLB_SIZE ; ++ vidx ) { CPUTLBEntry * vtlb = & env -> tlb_v_table [ mmu_idx ] [ vidx ] ; target_ulong cmp ; #if TCG_OVERSIZED_GUEST cmp = * ( target_ulong * ) ( ( uintptr_t ) vtlb + elt_ofs ) ; #else cmp = atomic_read ( ( target_ulong * ) ( ( uintptr_t ) vtlb + elt_ofs ) ) ; #endif if ( cmp == page ) { CPUTLBEntry tmptlb , * tlb = & env -> tlb_table [ mmu_idx ] [ index ] ; qemu_spin_lock ( & env -> tlb_c . lock ) ; copy_tlb_helper_locked ( & tmptlb , tlb ) ; copy_tlb_helper_locked ( tlb , vtlb ) ; copy_tlb_helper_locked ( vtlb , & tmptlb ) ; qemu_spin_unlock ( & env -> tlb_c . lock ) ; CPUIOTLBEntry tmpio , * io = & env -> iotlb [ mmu_idx ] [ index ] ; CPUIOTLBEntry * vio = & env -> iotlb_v [ mmu_idx ] [ vidx ] ; tmpio = * io ; * io = * vio ; * vio = tmpio ; return true ; } } return false ; }
Return true if ADDR is present in the victim tlb, and has been copied
back to the main tlb.
Return true if ADDR is present in the victim tlb and has been copied back to the main tlb .
/* elt_ofs might correspond to .addr_write, so use atomic_read */ /* Found entry in victim tlb, swap tlb and iotlb.  */