linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yi Liu <yi.l.liu@intel.com>
To: joro@8bytes.org, jgg@nvidia.com, kevin.tian@intel.com,
	baolu.lu@linux.intel.com
Cc: alex.williamson@redhat.com, eric.auger@redhat.com,
	nicolinc@nvidia.com, kvm@vger.kernel.org,
	chao.p.peng@linux.intel.com, yi.l.liu@intel.com,
	iommu@lists.linux.dev, zhenzhong.duan@intel.com,
	linux-kselftest@vger.kernel.org, vasant.hegde@amd.com
Subject: [PATCH v3 0/4] vfio-pci support pasid attach/detach
Date: Thu, 12 Sep 2024 06:17:25 -0700	[thread overview]
Message-ID: <20240912131729.14951-1-yi.l.liu@intel.com> (raw)

This adds the pasid attach/detach uAPIs for userspace to attach/detach
a PASID of a device to/from a given ioas/hwpt. Only vfio-pci driver is
enabled in this series. After this series, PASID-capable devices bound
with vfio-pci can report PASID capability to userspace and VM to enable
PASID usages like Shared Virtual Addressing (SVA).

Based on the discussion about reporting the vPASID to VM [1], it's agreed
that we will let the userspace VMM to synthesize the vPASID capability.
The VMM needs to figure out a hole to put the vPASID cap. This includes
the hidden bits handling for some devices. While, it's up to the userspace,
it's not the focus of this series.

This series first adds the helpers for pasid attach in vfio core and then
adds the device cdev ioctls for pasid attach/detach. In the end of this
series, the IOMMU_GET_HW_INFO ioctl is extended to report the PCI PASID
capability to the userspace. Userspace should check this before using any
PASID related uAPIs provided by VFIO, which is the agreement in [2]. This
series depends on the iommufd pasid attach/detach series [3].

The completed code can be found at [4], tested with a hacky Qemu branch [5].

[1] https://lore.kernel.org/kvm/BN9PR11MB5276318969A212AD0649C7BE8CBE2@BN9PR11MB5276.namprd11.prod.outlook.com/
[2] https://lore.kernel.org/kvm/4f2daf50-a5ad-4599-ab59-bcfc008688d8@intel.com/
[3] https://lore.kernel.org/linux-iommu/20240912131255.13305-1-yi.l.liu@intel.com/
[4] https://github.com/yiliu1765/iommufd/tree/iommufd_pasid
[5] https://github.com/yiliu1765/qemu/tree/wip/zhenzhong/iommufd_nesting_rfcv2-test-pasid

Change log:

v3:
 - Misc enhancement on patch 01 of v2 (Alex, Jason)
 - Add Jason's r-b to patch 03 of v2
 - Drop the logic that report PASID via VFIO_DEVICE_FEATURE ioctl
 - Extend IOMMU_GET_HW_INFO to report PASID support (Kevin, Jason, Alex)

v2: https://lore.kernel.org/kvm/20240412082121.33382-1-yi.l.liu@intel.com/
 - Use IDA to track if PASID is attached or not in VFIO. (Jason)
 - Fix the issue of calling pasid_at[de]tach_ioas callback unconditionally (Alex)
 - Fix the wrong data copy in vfio_df_ioctl_pasid_detach_pt() (Zhenzhong)
 - Minor tweaks in comments (Kevin)

v1: https://lore.kernel.org/kvm/20231127063909.129153-1-yi.l.liu@intel.com/
 - Report PASID capability via VFIO_DEVICE_FEATURE (Alex)

rfc: https://lore.kernel.org/linux-iommu/20230926093121.18676-1-yi.l.liu@intel.com/

Regards,
	Yi Liu

Yi Liu (4):
  ida: Add ida_find_first_range()
  vfio-iommufd: Support pasid [at|de]tach for physical VFIO devices
  vfio: Add VFIO_DEVICE_PASID_[AT|DE]TACH_IOMMUFD_PT
  iommufd: Extend IOMMU_GET_HW_INFO to report PASID capability

 drivers/iommu/iommufd/device.c | 27 +++++++++++++-
 drivers/pci/ats.c              | 32 ++++++++++++++++
 drivers/vfio/device_cdev.c     | 51 ++++++++++++++++++++++++++
 drivers/vfio/iommufd.c         | 50 +++++++++++++++++++++++++
 drivers/vfio/pci/vfio_pci.c    |  2 +
 drivers/vfio/vfio.h            |  4 ++
 drivers/vfio/vfio_main.c       |  8 ++++
 include/linux/idr.h            | 11 ++++++
 include/linux/pci-ats.h        |  3 ++
 include/linux/vfio.h           | 11 ++++++
 include/uapi/linux/iommufd.h   | 14 ++++++-
 include/uapi/linux/vfio.h      | 55 ++++++++++++++++++++++++++++
 lib/idr.c                      | 67 ++++++++++++++++++++++++++++++++++
 13 files changed, 333 insertions(+), 2 deletions(-)

-- 
2.34.1


             reply	other threads:[~2024-09-12 13:17 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-12 13:17 Yi Liu [this message]
2024-09-12 13:17 ` [PATCH v3 1/4] ida: Add ida_find_first_range() Yi Liu
2024-09-12 15:11   ` Matthew Wilcox
2024-09-13 11:45     ` Yi Liu
2024-09-13 15:09       ` Matthew Wilcox
2024-09-14  4:16         ` Yi Liu
2024-09-26 19:11   ` Jason Gunthorpe
2024-09-30  7:49   ` Tian, Kevin
2024-09-12 13:17 ` [PATCH v3 2/4] vfio-iommufd: Support pasid [at|de]tach for physical VFIO devices Yi Liu
2024-09-26 19:13   ` Jason Gunthorpe
2024-09-12 13:17 ` [PATCH v3 3/4] vfio: Add VFIO_DEVICE_PASID_[AT|DE]TACH_IOMMUFD_PT Yi Liu
2024-09-26 19:16   ` Jason Gunthorpe
2024-09-30  7:55   ` Tian, Kevin
2024-10-01 12:11     ` Jason Gunthorpe
2024-10-12 13:49       ` Yi Liu
2024-10-14 15:49         ` Alex Williamson
2024-10-15 11:07           ` Yi Liu
2024-10-15 16:22             ` Alex Williamson
2024-10-16  3:35               ` Yi Liu
2024-10-16 16:11                 ` Alex Williamson
2024-10-18  5:40                   ` Yi Liu
2024-10-30 12:54                     ` Yi Liu
2024-10-30 17:51                       ` Alex Williamson
2024-10-31  7:23                         ` Yi Liu
2024-09-12 13:17 ` [PATCH v3 4/4] iommufd: Extend IOMMU_GET_HW_INFO to report PASID capability Yi Liu
2024-09-26 19:35   ` Jason Gunthorpe
2024-09-27  3:08     ` Yi Liu
2024-09-30  8:03   ` Tian, Kevin
2024-10-22 10:08   ` Vasant Hegde
2024-10-28  6:41   ` Zhangfei Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240912131729.14951-1-yi.l.liu@intel.com \
    --to=yi.l.liu@intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=eric.auger@redhat.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=vasant.hegde@amd.com \
    --cc=zhenzhong.duan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).