On Wed, 4 May 2022 16:14:38 -0300 Jason Gunthorpe <jgg@xxxxxxxxxx> wrote: > This is the other half of removing the vfio_group from the externally > facing VFIO API. > > VFIO provides an API to manipulate its struct file *'s for use by KVM and > VFIO PCI. Instead of converting the struct file into a ref counted struct > vfio_group simply use the struct file as the handle throughout the API. > > Along the way some of the APIs are simplified to be more direct about what > they are trying to do with an eye to making future iommufd implementations > for all of them. > > This also simplifies the container_users ref counting by not holding a > users refcount while KVM holds the group file. > > Removing vfio_group from the external facing API is part of the iommufd > work to modualize and compartmentalize the VFIO container and group object > to be entirely internal to VFIO itself. > > This is on github: https://github.com/jgunthorpe/linux/commits/vfio_kvm_no_group > > v3: > - Use u64_to_user_ptr() to cast attr->addr to a void __user * to avoid > compiler warnings on 32 bit > - Rebase on top of > https://lore.kernel.org/all/0-v2-0f36bcf6ec1e+64d-vfio_get_from_dev_jgg@xxxxxxxxxx/ > - Update commit messages > v2: https://lore.kernel.org/r/0-v2-6a528653a750+1578a-vfio_kvm_no_group_jgg@xxxxxxxxxx > - s/filp/file/ s/filep/file/ > - Drop patch to allow ppc to be compile tested > - Keep symbol_get's Christoph has an alternative approach > v1: https://lore.kernel.org/r/0-v1-33906a626da1+16b0-vfio_kvm_no_group_jgg@xxxxxxxxxx > > Cc: Eric Auger <eric.auger@xxxxxxxxxx> > Cc: Yi Liu <yi.l.liu@xxxxxxxxx> > Cc: Alex Williamson <alex.williamson@xxxxxxxxxx> > Cc: Christoph Hellwig <hch@xxxxxx> > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx> > > Jason Gunthorpe (8): > kvm/vfio: Move KVM_DEV_VFIO_GROUP_* ioctls into functions > kvm/vfio: Store the struct file in the kvm_vfio_group > vfio: Change vfio_external_user_iommu_id() to vfio_file_iommu_group() > vfio: Remove vfio_external_group_match_file() > vfio: Change vfio_external_check_extension() to > vfio_file_enforced_coherent() > vfio: Change vfio_group_set_kvm() to vfio_file_set_kvm() > kvm/vfio: Remove vfio_group from kvm > vfio/pci: Use the struct file as the handle not the vfio_group > > drivers/vfio/pci/vfio_pci_core.c | 42 ++-- > drivers/vfio/vfio.c | 131 +++++------ > include/linux/vfio.h | 15 +- > virt/kvm/vfio.c | 381 ++++++++++++++----------------- > 4 files changed, 262 insertions(+), 307 deletions(-) > > > base-commit: 0f36bcf6ec1e0c95725cdaf9cf3b0fed6f697494 Applied to vfio next branch for v5.19. Thanks, Alex