qemu/contrib/libvhost-user/libvhost-user.c
/* Translate guest physical address to our virtual address.  */
Translate guest physical address to our virtual address.
Translate guest physical address to our virtual address .
void *
vu_gpa_to_va(VuDev *dev, uint64_t *plen, uint64_t guest_addr)
{
    int i;
    if (*plen == 0) {
        return NULL;
    }
    for (i = 0; i < dev->nregions; i++) {
        VuDevRegion *r = &dev->regions[i];
        if ((guest_addr >= r->gpa) && (guest_addr < (r->gpa + r->size))) {
            if ((guest_addr + *plen) > (r->gpa + r->size)) {
                *plen = r->gpa + r->size - guest_addr;
            }
            return (void *)(uintptr_t)
                guest_addr - r->gpa + r->mmap_addr + r->mmap_offset;
        }
    }
    return NULL;
}
void * vu_gpa_to_va ( VuDev * dev , uint64_t * plen , uint64_t guest_addr ) { int i ; if ( * plen == 0 ) { return NULL ; } for ( i = 0 ; i < dev -> nregions ; i ++ ) { VuDevRegion * r = & dev -> regions [ i ] ; if ( ( guest_addr >= r -> gpa ) && ( guest_addr < ( r -> gpa + r -> size ) ) ) { if ( ( guest_addr + * plen ) > ( r -> gpa + r -> size ) ) { * plen = r -> gpa + r -> size - guest_addr ; } return ( void * ) ( uintptr_t ) guest_addr - r -> gpa + r -> mmap_addr + r -> mmap_offset ; } } return NULL ; }
Translate guest physical address to our virtual address.
Translate guest physical address to our virtual address .
/* Find matching memory region.  */