vfio/noiommu: Don't use iommu_present() to track fake groups
authorAlex Williamson <alex.williamson@redhat.com>
Wed, 27 Jan 2016 18:22:25 +0000 (11:22 -0700)
committerAlex Williamson <alex.williamson@redhat.com>
Wed, 27 Jan 2016 18:22:25 +0000 (11:22 -0700)
commit16ab8a5cbea463e4d14bf0ce698f11fa64b70ae1
tree49bd3a070e57777c520a0a258b8f7596a1ad51c4
parent92e963f50fc74041b5e9e744c330dca48e04f08d
vfio/noiommu: Don't use iommu_present() to track fake groups

Using iommu_present() to determine whether an IOMMU group is real or
fake has some problems.  First, apparently Power systems don't
register an IOMMU on the device bus, so the groups and containers get
marked as noiommu and then won't bind to their actual IOMMU driver.
Second, I expect we'll run into the same issue as we try to support
vGPUs through vfio, since they're likely to emulate this behavior of
creating an IOMMU group on a virtual device and then providing a vfio
IOMMU backend tailored to the sort of isolation they provide, which
won't necessarily be fully compatible with the IOMMU API.

The solution here is to use the existing iommudata interface to IOMMU
groups, which allows us to easily identify the fake groups we've
created for noiommu purposes.  The iommudata we set is purely
arbitrary since we're only comparing the address, so we use the
address of the noiommu switch itself.

Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Tested-by: Anatoly Burakov <anatoly.burakov@intel.com>
Tested-by: Santosh Shukla <sshukla@mvista.com>
Fixes: 03a76b60f8ba ("vfio: Include No-IOMMU mode")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio.c