[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC v1 08/18] vfio/pci: add vfio bind/unbind_gpasid im
From: |
Auger Eric |
Subject: |
Re: [Qemu-devel] [RFC v1 08/18] vfio/pci: add vfio bind/unbind_gpasid implementation |
Date: |
Tue, 9 Jul 2019 10:37:47 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
Hi Liu,
On 7/5/19 1:01 PM, Liu Yi L wrote:
> This patch adds vfio implementation PCIPASIDOps.bind_gpasid/unbind_pasid().
> These two functions are used to propagate guest pasid bind and unbind
> requests to host via vfio container ioctl.
>
> Cc: Kevin Tian <address@hidden>
> Cc: Jacob Pan <address@hidden>
> Cc: Peter Xu <address@hidden>
> Cc: Eric Auger <address@hidden>
> Cc: Yi Sun <address@hidden>
> Cc: David Gibson <address@hidden>
> Signed-off-by: Liu Yi L <address@hidden>
> ---
> hw/vfio/pci.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 54 insertions(+)
>
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index ab184ad..892b46c 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2744,9 +2744,63 @@ static int vfio_pci_device_request_pasid_free(PCIBus
> *bus,
> return ret;
> }
>
> +static void vfio_pci_device_bind_gpasid(PCIBus *bus, int32_t devfn,
> + struct gpasid_bind_data *g_bind_data)
> +{
> + PCIDevice *pdev = bus->devices[devfn];
> + VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
> + VFIOContainer *container = vdev->vbasedev.group->container;
> + struct vfio_iommu_type1_bind *bind;
> + struct vfio_iommu_type1_bind_guest_pasid *bind_guest_pasid;
> + unsigned long argsz;
> +
> + argsz = sizeof(*bind) + sizeof(*bind_guest_pasid);
> + bind = g_malloc0(argsz);
> + bind->argsz = argsz;
> + bind->bind_type = VFIO_IOMMU_BIND_GUEST_PASID;
> + bind_guest_pasid = (struct vfio_iommu_type1_bind_guest_pasid *)
> &bind->data;
> + bind_guest_pasid->bind_data = *g_bind_data;
> +
> + rcu_read_lock();
why do you need the rcu_read_lock?
> + if (ioctl(container->fd, VFIO_IOMMU_BIND, bind) != 0) {
> + error_report("vfio_pci_device_bind_gpasid:"
> + " bind failed, contanier: %p", container);
container
> + }
> + rcu_read_unlock();
> + g_free(bind);
> +}
> +
> +static void vfio_pci_device_unbind_gpasid(PCIBus *bus, int32_t devfn,
> + struct gpasid_bind_data *g_bind_data)
> +{
> + PCIDevice *pdev = bus->devices[devfn];
> + VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
> + VFIOContainer *container = vdev->vbasedev.group->container;
> + struct vfio_iommu_type1_bind *bind;
> + struct vfio_iommu_type1_bind_guest_pasid *bind_guest_pasid;
> + unsigned long argsz;
> +
> + argsz = sizeof(*bind) + sizeof(*bind_guest_pasid);
> + bind = g_malloc0(argsz);
> + bind->argsz = argsz;
> + bind->bind_type = VFIO_IOMMU_BIND_GUEST_PASID;
> + bind_guest_pasid = (struct vfio_iommu_type1_bind_guest_pasid *)
> &bind->data;
> + bind_guest_pasid->bind_data = *g_bind_data;
> +
> + rcu_read_lock();
> + if (ioctl(container->fd, VFIO_IOMMU_UNBIND, bind) != 0) {
> + error_report("vfio_pci_device_unbind_gpasid:"
> + " unbind failed, contanier: %p", container);
container
> + }
> + rcu_read_unlock();
> + g_free(bind);
> +}
> +
> static PCIPASIDOps vfio_pci_pasid_ops = {
> .alloc_pasid = vfio_pci_device_request_pasid_alloc,
> .free_pasid = vfio_pci_device_request_pasid_free,
> + .bind_gpasid = vfio_pci_device_bind_gpasid,
> + .unbind_gpasid = vfio_pci_device_unbind_gpasid,
> };
>
> static void vfio_realize(PCIDevice *pdev, Error **errp)
>
Thanks
Eric
- Re: [Qemu-devel] [RFC v1 05/18] vfio/pci: add pasid alloc/free implementation, (continued)
[Qemu-devel] [RFC v1 07/18] hw/pci: add pci_device_bind/unbind_gpasid, Liu Yi L, 2019/07/06
[Qemu-devel] [RFC v1 08/18] vfio/pci: add vfio bind/unbind_gpasid implementation, Liu Yi L, 2019/07/06
- Re: [Qemu-devel] [RFC v1 08/18] vfio/pci: add vfio bind/unbind_gpasid implementation,
Auger Eric <=
[Qemu-devel] [RFC v1 09/18] intel_iommu: process pasid cache invalidation, Liu Yi L, 2019/07/06
[Qemu-devel] [RFC v1 11/18] intel_iommu: create VTDAddressSpace per BDF+PASID, Liu Yi L, 2019/07/06
[Qemu-devel] [RFC v1 10/18] intel_iommu: tag VTDAddressSpace instance with PASID, Liu Yi L, 2019/07/06