Re: [PATCH v3 02/19] vfio: Move iova_bitmap into iommu core

Joao Martins
2023-10-13T17:10:44Z

On 13/10/2023 17:00, Joao Martins wrote:
> On 13/10/2023 16:48, Jason Gunthorpe wrote:
>> On Sat, Sep 23, 2023 at 02:24:54AM +0100, Joao Martins wrote:
>>> Both VFIO and IOMMUFD will need iova bitmap for storing dirties and walking
>>> the user bitmaps, so move to the common dependency into IOMMU core. IOMMUFD
>>> can't exactly host it given that VFIO dirty tracking can be used without
>>> IOMMUFD.
>>
>> Hum, this seems strange. Why not just make those VFIO drivers depends
>> on iommufd? That seems harmless to me.
>>
>
> IF you and Alex are OK with it then I can move to IOMMUFD.
>
>> However, I think the real issue is that iommu drivers need to use this
>> API too for their part?
>>
>
> Exactly.
>

My other concern into moving to IOMMUFD instead of core was VFIO_IOMMU_TYPE1,
and if we always make it depend on IOMMUFD then we can't have what is today
something supported because of VFIO_IOMMU_TYPE1 stuff with migration drivers
(i.e. vfio-iommu-type1 with the live migration stuff).

But if it's exists an IOMMUFD_DRIVER kconfig, then VFIO_CONTAINER can instead
select the IOMMUFD_DRIVER alone so long as CONFIG_IOMMUFD isn't required? I am
essentially talking about:

# SPDX-License-Identifier: GPL-2.0-only
menuconfig VFIO
tristate "VFIO Non-Privileged userspace driver framework"
select IOMMU_API
depends on IOMMUFD || !IOMMUFD
select INTERVAL_TREE
select VFIO_GROUP if SPAPR_TCE_IOMMU || IOMMUFD=n
select VFIO_DEVICE_CDEV if !VFIO_GROUP
select VFIO_CONTAINER if IOMMUFD=n
help
VFIO provides a framework for secure userspace device drivers.
See Documentation/driver-api/vfio.rst for more details.

If you don't know what to do here, say N.

... and the fact that VFIO_IOMMU_TYPE1 requires VFIO_GROUP:

config VFIO_CONTAINER
bool "Support for the VFIO container /dev/vfio/vfio"
select VFIO_IOMMU_TYPE1 if MMU && (X86 || S390 || ARM || ARM64)
depends on VFIO_GROUP
default y
help
The VFIO container is the classic interface to VFIO for establishing
IOMMU mappings. If N is selected here then IOMMUFD must be used to
manage the mappings.

Unless testing IOMMUFD say Y here.

if VFIO_CONTAINER
config VFIO_IOMMU_TYPE1
tristate
default n …