]> git.baikalelectronics.ru Git - kernel.git/commit
vfio: Move IOMMU_CAP_CACHE_COHERENCY test to after we know we have a group
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 5 Jul 2022 01:10:50 +0000 (22:10 -0300)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 5 Jul 2022 22:06:50 +0000 (16:06 -0600)
commitada897909e06f2a348b978d839d03c8d22d4f3fd
tree89e345299ad4ff7242765f11edc7694603b6756d
parent17aa3251ca69d5289712bca6b152158fdac13263
vfio: Move IOMMU_CAP_CACHE_COHERENCY test to after we know we have a group

The test isn't going to work if a group doesn't exist. Normally this isn't
a problem since VFIO isn't going to create a device if there is no group,
but the special CONFIG_VFIO_NOIOMMU behavior allows bypassing this
prevention. The new cap test effectively forces a group and breaks this
config option.

Move the cap test to vfio_group_find_or_alloc() which is the earliest time
we know we have a group available and thus are not running in noiommu mode.

Fixes: 559c1ab0746f ("vfio: Require that devices support DMA cache coherence")
Reported-by: Xiang Chen <chenxiang66@hisilicon.com>
Tested-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/0-v1-e8934b490f36+f4-vfio_cap_fix_jgg@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio.c