mbox series

[v2,0/8] Remove vfio_group from the struct file facing VFIO API

Message ID 0-v2-6a528653a750+1578a-vfio_kvm_no_group_jgg@nvidia.com (mailing list archive)
Headers show
Series Remove vfio_group from the struct file facing VFIO API | expand

Message

Jason Gunthorpe April 20, 2022, 7:23 p.m. UTC
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

v2:
- 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@nvidia.com

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              | 146 ++++++------
 include/linux/vfio.h             |  14 +-
 virt/kvm/vfio.c                  | 377 ++++++++++++++-----------------
 4 files changed, 270 insertions(+), 309 deletions(-)


base-commit: ce522ba9ef7e2d9fb22a39eb3371c0c64e2a433e

Comments

Yi Liu April 21, 2022, 2:51 p.m. UTC | #1
On 2022/4/21 03:23, Jason Gunthorpe 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

passthrough a device from singleton-group passed. will do it test against
non-singleton group as well.

> v2:
> - 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@nvidia.com
> 
> 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              | 146 ++++++------
>   include/linux/vfio.h             |  14 +-
>   virt/kvm/vfio.c                  | 377 ++++++++++++++-----------------
>   4 files changed, 270 insertions(+), 309 deletions(-)
> 
> 
> base-commit: ce522ba9ef7e2d9fb22a39eb3371c0c64e2a433e