[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 10/22] vfio/pci: set host iommu context to vIOMMU
From: |
Auger Eric |
Subject: |
Re: [PATCH v2 10/22] vfio/pci: set host iommu context to vIOMMU |
Date: |
Tue, 31 Mar 2020 16:30:05 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
Yi,
On 3/30/20 6:24 AM, Liu Yi L wrote:
> For vfio-pci devices, it could use pci_device_set/unset_iommu() to
> expose host iommu context to vIOMMU emulators. vIOMMU emulators
> could make use the methods provided by host iommu context. e.g.
> propagate requests to host iommu.
I think I would squash this patch into the previous one.
>
> 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>
> Cc: Alex Williamson <address@hidden>
> Signed-off-by: Liu Yi L <address@hidden>
> ---
> hw/vfio/pci.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 5e75a95..c140c88 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2717,6 +2717,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
> VFIOPCIDevice *vdev = PCI_VFIO(pdev);
> VFIODevice *vbasedev_iter;
> VFIOGroup *group;
> + VFIOContainer *container;
> char *tmp, *subsys, group_path[PATH_MAX], *group_name;
> Error *err = NULL;
> ssize_t len;
> @@ -3028,6 +3029,11 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
> vfio_register_req_notifier(vdev);
> vfio_setup_resetfn_quirk(vdev);
>
> + container = vdev->vbasedev.group->container;
> + if (container->iommu_ctx.initialized) {
Sin't it possible to dynamically allocate the iommu_ctx so that you can
simply check container->iommu_ctx and discard the initialized field?
> + pci_device_set_iommu_context(pdev, &container->iommu_ctx);
> + }
> +
> return;
>
> out_deregister:
> @@ -3072,9 +3078,16 @@ static void vfio_instance_finalize(Object *obj)
> static void vfio_exitfn(PCIDevice *pdev)
> {
> VFIOPCIDevice *vdev = PCI_VFIO(pdev);
> + VFIOContainer *container;
>
> vfio_unregister_req_notifier(vdev);
> vfio_unregister_err_notifier(vdev);
> +
> + container = vdev->vbasedev.group->container;
> + if (container->iommu_ctx.initialized) {
> + pci_device_unset_iommu_context(pdev);
> + }
> +
> pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
> if (vdev->irqchip_change_notifier.notify) {
> kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
>
Thanks
Eric
- RE: [PATCH v2 03/22] vfio: check VFIO_TYPE1_NESTING_IOMMU support, (continued)
[PATCH v2 06/22] hw/pci: introduce pci_device_set/unset_iommu_context(), Liu Yi L, 2020/03/30
[PATCH v2 10/22] vfio/pci: set host iommu context to vIOMMU, Liu Yi L, 2020/03/30
- Re: [PATCH v2 10/22] vfio/pci: set host iommu context to vIOMMU,
Auger Eric <=
[PATCH v2 07/22] intel_iommu: add set/unset_iommu_context callback, Liu Yi L, 2020/03/30
[PATCH v2 22/22] intel_iommu: modify x-scalable-mode to be string option, Liu Yi L, 2020/03/30
[PATCH v2 09/22] vfio/common: init HostIOMMUContext per-container, Liu Yi L, 2020/03/30
[PATCH v2 02/22] header file update VFIO/IOMMU vSVA APIs, Liu Yi L, 2020/03/30
[PATCH v2 08/22] vfio/common: provide PASID alloc/free hooks, Liu Yi L, 2020/03/30