qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PULL 07/14] vfio/spapr: Create DMA window dynamically


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PULL 07/14] vfio/spapr: Create DMA window dynamically (SPAPR IOMMU v2)
Date: Mon, 11 Jul 2016 15:51:44 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1


On 05/07/2016 07:31, David Gibson wrote:
> +    ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
> +    if (ret) {
> +        error_report("Failed to create a window, ret = %d (%m)", ret);
> +        return -errno;
> +    }
> +
> +    if (create.start_addr != section->offset_within_address_space) {
> +        vfio_spapr_remove_window(container, create.start_addr);
> +
> +        error_report("Host doesn't support DMA window at %"HWADDR_PRIx", 
> must be %"PRIx64,
> +                     section->offset_within_address_space,
> +                     (uint64_t)create.start_addr);
> +        ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_REMOVE, &remove);

Was this ioctl left there by mistake?  It passes the address of the
remove *function* to VFIO_IOMMU_SPAPR_TCE_REMOVE.

Thanks,

Paolo

> +        return -EINVAL;
> +    }
> +    trace_vfio_spapr_create_window(create.page_shift,
> +                                   create.window_size,
> +                                   create.start_addr);
> +    *pgsize = pagesize;
> +
> +    return 0;
> +}
> +
> +int vfio_spapr_remove_window(VFIOContainer *container,
> +                             hwaddr offset_within_address_space)
> +{
> +    struct vfio_iommu_spapr_tce_remove remove = {
> +        .argsz = sizeof(remove),
> +        .start_addr = offset_within_address_space,
> +    };
> +    int ret;
> +
> +    ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_REMOVE, &remove);
> +    if (ret) {
> +        error_report("Failed to remove window at %"PRIx64,
> +                     (uint64_t)remove.start_addr);
> +        return -errno;
> +    }
> +
> +    trace_vfio_spapr_remove_window(offset_within_address_space);
> +
> +    return 0;
> +}
> diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
> index 0b02a3b..4bb7690 100644
> --- a/hw/vfio/trace-events
> +++ b/hw/vfio/trace-events
> @@ -121,3 +121,5 @@ vfio_prereg_listener_region_add_skip(uint64_t start, 
> uint64_t end) "%"PRIx64" -
>  vfio_prereg_listener_region_del_skip(uint64_t start, uint64_t end) 
> "%"PRIx64" - %"PRIx64
>  vfio_prereg_register(uint64_t va, uint64_t size, int ret) "va=%"PRIx64" 
> size=%"PRIx64" ret=%d"
>  vfio_prereg_unregister(uint64_t va, uint64_t size, int ret) "va=%"PRIx64" 
> size=%"PRIx64" ret=%d"
> +vfio_spapr_create_window(int ps, uint64_t ws, uint64_t off) "pageshift=0x%x 
> winsize=0x%"PRIx64" offset=0x%"PRIx64
> +vfio_spapr_remove_window(uint64_t off) "offset=%"PRIx64
> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
> index b1f3e92..07f7188 100644
> --- a/include/hw/vfio/vfio-common.h
> +++ b/include/hw/vfio/vfio-common.h
> @@ -168,4 +168,10 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, 
> uint32_t type,
>  #endif
>  extern const MemoryListener vfio_prereg_listener;
>  
> +int vfio_spapr_create_window(VFIOContainer *container,
> +                             MemoryRegionSection *section,
> +                             hwaddr *pgsize);
> +int vfio_spapr_remove_window(VFIOContainer *container,
> +                             hwaddr offset_within_address_space);
> +
>  #endif /* !HW_VFIO_VFIO_COMMON_H */
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]