Bug 836 - VFIO API for device to retrive domain
Summary: VFIO API for device to retrive domain
Status: RESOLVED FIXED
Alias: None
Product: ANCK 5.10 Dev
Classification: ANCK
Component: drivers (show other bugs) drivers
Version: unspecified
Hardware: All Linux
: P3-Medium S2-major
Target Milestone: ---
Assignee: GuixinLiu
QA Contact: shuming
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-13 16:18 UTC by yiysun
Modified: 2022-04-21 11:10 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yiysun intel_group 2022-04-13 16:18:49 UTC
Add the API for getting the domain from a vfio group. This could be used
by the physical device drivers which rely on the vfio/mdev framework for
mediated device user level access. The typical use case like below:

        unsigned int pasid;
        struct vfio_group *vfio_group;
        struct iommu_domain *iommu_domain;
        struct device *dev = mdev_dev(mdev);
        struct device *iommu_device = mdev_get_iommu_device(dev);

        if (!iommu_device ||
            !iommu_dev_feature_enabled(iommu_device, IOMMU_DEV_FEAT_AUX))
                return -EINVAL;

        vfio_group = vfio_group_get_external_user_from_dev(dev);
        if (IS_ERR_OR_NULL(vfio_group))
                return -EFAULT;

        iommu_domain = vfio_group_iommu_domain(vfio_group);
        if (IS_ERR_OR_NULL(iommu_domain)) {
                vfio_group_put_external_user(vfio_group);
                return -EFAULT;
        }

        pasid = iommu_aux_get_pasid(iommu_domain, iommu_device);
        if (pasid < 0) {
                vfio_group_put_external_user(vfio_group);
                return -EFAULT;
        }

        /* Program device context with pasid value. */
        ...
Comment 1 GuixinLiu alibaba_cloud_group 2022-04-21 11:10:11 UTC
already merged.