RE: [PATCH 1/1] iommu/vt-d: Decouple igfx_off from graphic identity mapping

2024-04-27 Thread Tian, Kevin
; int intel_iommu_enabled = 0; > EXPORT_SYMBOL_GPL(intel_iommu_enabled); > > -static int dmar_map_gfx = 1; > static int intel_iommu_superpage = 1; > static int iommu_identity_mapping; > static int iommu_skip_te_disable; > +static int disable_igfx_dedicated_iommu; > what about 'no_igfx_iommu"? dedicated is implied for igfx so a shorter name might be slightly better. otherwise it looks good: Reviewed-by: Kevin Tian

RE: [PATCH v2 1/1] iommu/vt-d: Remove INTEL_IOMMU_BROKEN_GFX_WA

2024-01-29 Thread Tian, Kevin
> From: Lu Baolu > Sent: Tuesday, January 30, 2024 2:08 PM > > Commit 62edf5dc4a524 ("intel-iommu: Restore DMAR_BROKEN_GFX_WA > option for > broken graphics drivers") was introduced 24 years ago as a temporary > workaround for graphics drivers that used physical addresses for DMA and > avoided DM

[Intel-gfx] Intel Arc 770m GPU won't load on Fedora 38 kernel versions > 6.4.12

2023-11-29 Thread Kevin Quillen
Posting here for visibility. I have tried up to the latest 6.6.2 kernel with the same result. https://bugzilla.redhat.com/show_bug.cgi?id=2248917 1. Please describe the problem: All kernel versions after 6.4.12 are refusing to boot. I took this error out of the logs: ``` Nov 05 17:56:01 fedora

Re: [Intel-gfx] [PATCH v12 21/24] vfio: Determine noiommu device in __vfio_register_dev()

2023-06-13 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, June 14, 2023 2:14 PM > > > > With that I think Jason's suggestion is to lift that test into main.c: > > > > int vfio_register_group_dev(struct vfio_device *device) > > { > > /* > > * VFIO always sets IOMMU_CACHE because we offer no way for > userspa

Re: [Intel-gfx] [PATCH v12 21/24] vfio: Determine noiommu device in __vfio_register_dev()

2023-06-13 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, June 14, 2023 11:24 AM > > > From: Alex Williamson > > Sent: Wednesday, June 14, 2023 4:11 AM > > > > On Tue, 13 Jun 2023 14:35:09 -0300 > > Jason Gunthorpe wrote: > > > > > On Tue, Jun 13, 2023 at 11:15:11AM -0600, Alex Williamson wrote: > > > > [Sorry for

Re: [Intel-gfx] [PATCH v11 19/23] vfio: Add VFIO_DEVICE_BIND_IOMMUFD

2023-05-23 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, May 24, 2023 10:21 AM > > > > > > > vfio_device_open_file() > > > { > > > dev_warn(device->dev, "vfio-noiommu device opened by user " > > > "(%s:%d)\n", current->comm, task_pid_nr(current)); > > > } > > > > There needs to be a taint when VFIO_GR

Re: [Intel-gfx] [PATCH v5 06/10] vfio-iommufd: Add helper to retrieve iommufd_ctx and devid for vfio_device

2023-05-19 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, May 18, 2023 9:26 PM > > > +int vfio_iommufd_physical_devid(struct vfio_device *vdev) > > > +{ > > > + if (vdev->iommufd_device) > > > + return iommufd_device_to_id(vdev->iommufd_device); > > > + if (vdev->noiommu_access) > > > + return iommufd_a

Re: [Intel-gfx] [PATCH v4 2/9] vfio-iommufd: Create iommufd_access for noiommu devices

2023-04-28 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, April 28, 2023 2:21 PM > > On 2023/4/28 02:32, Alex Williamson wrote: > > On Thu, 27 Apr 2023 06:59:17 + > > "Liu, Yi L" wrote: > > > >>> From: Tian, Kevin > >>> Sent: Thursday, April 27, 2

Re: [Intel-gfx] [PATCH v4 9/9] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-04-26 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, April 26, 2023 10:54 PM > > +static bool vfio_dev_in_iommufd_ctx(struct vfio_pci_core_device *vdev, > + struct iommufd_ctx *iommufd_ctx) > +{ > + struct iommufd_ctx *iommufd = vfio_iommufd_physical_ictx(&vdev- > >vdev); > +

Re: [Intel-gfx] [PATCH v4 8/9] vfio/pci: Extend VFIO_DEVICE_GET_PCI_HOT_RESET_INFO for vfio device cdev

2023-04-26 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, April 26, 2023 10:54 PM > + > +/* > + * Check if a given iommu_group has been bound to an iommufd within a > + * devset. Returns true if there is device in the devset which is in > + * the input iommu_group and meanwhile bound to the input iommufd. > + * Other

Re: [Intel-gfx] [PATCH v4 7/9] vfio-iommufd: Add helper to retrieve iommufd_ctx and devid for vfio_device

2023-04-26 Thread Tian, Kevin
> From: Yi Liu > Sent: Wednesday, April 26, 2023 10:54 PM > + > +/* > + * Return devid for devices that have been bound with iommufd, > + * returns 0 if not bound yet. > + */ > +u32 vfio_iommufd_physical_devid(struct vfio_device *vdev) > +{ > + if (WARN_ON(!vdev->iommufd_device && !vdev->iommuf

Re: [Intel-gfx] [PATCH v4 6/9] iommufd: Reserved -1 in the iommufd xarray

2023-04-26 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, April 26, 2023 10:54 PM > > VFIO needs two reserved values. 0 is already reserved by initializing > xarray with XA_FLAGS_ALLOC1. This reserves -1 by limiting the xa alloc > range. > > Signed-off-by: Yi Liu > --- > drivers/iommu/iommufd/main.c | 5 - > 1

Re: [Intel-gfx] [PATCH v4 5/9] vfio: Mark cdev usage in vfio_device

2023-04-26 Thread Tian, Kevin
v. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v4 4/9] vfio/pci: Move the existing hot reset logic to be a helper

2023-04-26 Thread Tian, Kevin
rpe > Signed-off-by: Jason Gunthorpe > Reviewed-by: Jason Gunthorpe > Reviewed-by: Eric Auger > Tested-by: Yanting Jiang > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v4 2/9] vfio-iommufd: Create iommufd_access for noiommu devices

2023-04-26 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, April 26, 2023 10:54 PM > @@ -121,7 +128,8 @@ static void vfio_emulated_unmap(void *data, > unsigned long iova, > { > struct vfio_device *vdev = data; > > - if (vdev->ops->dma_unmap) > + /* noiommu devices cannot do map/unmap */ > + if (vdev

Re: [Intel-gfx] [PATCH v4 1/9] vfio: Determine noiommu in vfio_device registration

2023-04-26 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, April 26, 2023 10:54 PM > > -static inline bool vfio_device_is_noiommu(struct vfio_device *vdev) > +static inline int vfio_device_set_noiommu(struct vfio_device *device) > { > - return IS_ENABLED(CONFIG_VFIO_NOIOMMU) && > -vdev->group->type ==

Re: [Intel-gfx] [PATCH v3 12/12] vfio/pci: Report dev_id in VFIO_DEVICE_GET_PCI_HOT_RESET_INFO

2023-04-17 Thread Tian, Kevin
> From: Alex Williamson > Sent: Tuesday, April 18, 2023 12:11 PM > > On Tue, 18 Apr 2023 03:24:46 +0000 > "Tian, Kevin" wrote: > > > > From: Alex Williamson > > > Sent: Tuesday, April 18, 2023 4:07 AM > > > > > >

Re: [Intel-gfx] [PATCH v3 12/12] vfio/pci: Report dev_id in VFIO_DEVICE_GET_PCI_HOT_RESET_INFO

2023-04-17 Thread Tian, Kevin
> From: Alex Williamson > Sent: Tuesday, April 18, 2023 4:07 AM > > On Mon, 17 Apr 2023 16:31:56 -0300 > Jason Gunthorpe wrote: > > > On Mon, Apr 17, 2023 at 01:01:40PM -0600, Alex Williamson wrote: > > > Yes, it's not trivial, but Jason is now proposing that we consider > > > mixing groups, cd

Re: [Intel-gfx] [PATCH v3 12/12] vfio/pci: Report dev_id in VFIO_DEVICE_GET_PCI_HOT_RESET_INFO

2023-04-17 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Monday, April 17, 2023 9:39 PM > > On Fri, Apr 14, 2023 at 09:11:30AM +, Tian, Kevin wrote: > > > The only corner case with this option is when a user mixes group > > and cdev usages. iirc you mentioned it's a valid usage to be

Re: [Intel-gfx] [PATCH v3 12/12] vfio/pci: Report dev_id in VFIO_DEVICE_GET_PCI_HOT_RESET_INFO

2023-04-14 Thread Tian, Kevin
> From: Alex Williamson > Sent: Friday, April 14, 2023 2:07 AM > > We had already iterated a proposal where the group-id is replaced with > a dev-id in the existing ioctl and a flag indicates when the return > value is a dev-id vs group-id. This had a gap that userspace cannot > determine if a r

Re: [Intel-gfx] [PATCH v3 12/12] vfio/pci: Report dev_id in VFIO_DEVICE_GET_PCI_HOT_RESET_INFO

2023-04-13 Thread Tian, Kevin
oup id if VFIO_GROUP=y then same case. For noiommu if VFIO_GROUP=n just do exact match based on BDF. Either way the information returned by INFO is a superset of knowing the reset scope between opened devices. Thanks Kevin

Re: [Intel-gfx] [PATCH v3 12/12] vfio/pci: Report dev_id in VFIO_DEVICE_GET_PCI_HOT_RESET_INFO

2023-04-12 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, April 12, 2023 11:06 PM > > On Wed, Apr 12, 2023 at 07:27:43AM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Wednesday, April 12, 2023 8:01 AM > > > > > > I see this prob

Re: [Intel-gfx] [PATCH v3 12/12] vfio/pci: Report dev_id in VFIO_DEVICE_GET_PCI_HOT_RESET_INFO

2023-04-12 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, April 12, 2023 8:01 AM > > I see this problem as a few basic requirements from a qemu-like > application: > > 1) Does the configuration I was given support reset right now? > 2) Will the configuration I was given support reset for the duration > of

Re: [Intel-gfx] [PATCH v3 12/12] vfio/pci: Report dev_id in VFIO_DEVICE_GET_PCI_HOT_RESET_INFO

2023-04-12 Thread Tian, Kevin
your earlier replies you pointed out the issue of unpredictable ordering on a multi-function device e.g. upon which one runs first dpdk or qmeu will block the other. But I wonder what is the actual use of allowing both running while both can't do reset due to affected reset scope in current model. If a vfio user cannot do reset doesn't it imply it hasn't acquired the full permission on the device then Jason's proposal of explicitly failing it is actually a cleaner model? Thanks Kevin

Re: [Intel-gfx] [PATCH v3 2/6] iommufd: Create access in vfio_iommufd_emulated_bind()

2023-03-31 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Thursday, March 30, 2023 4:00 AM > > On Mon, Mar 27, 2023 at 02:33:47AM -0700, Yi Liu wrote: > > @@ -494,6 +479,30 @@ void iommufd_access_destroy(struct > iommufd_access *access) > > } > > EXPORT_SYMBOL_NS_GPL(iommufd_access_destroy, IOMMUFD); > > > > +int iommuf

Re: [Intel-gfx] [PATCH v2 10/10] vfio/pci: Add VFIO_DEVICE_GET_PCI_HOT_RESET_GROUP_INFO

2023-03-29 Thread Tian, Kevin
> From: Tian, Kevin > Sent: Thursday, March 30, 2023 9:10 AM > > > From: Jason Gunthorpe > > Sent: Wednesday, March 29, 2023 11:50 PM > > > > On Wed, Mar 29, 2023 at 09:41:26AM +, Tian, Kevin wrote: > > > > > We could extend bind_iommufd to re

Re: [Intel-gfx] [PATCH v2 10/10] vfio/pci: Add VFIO_DEVICE_GET_PCI_HOT_RESET_GROUP_INFO

2023-03-29 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, March 29, 2023 11:58 PM > > On Wed, Mar 29, 2023 at 09:49:44AM -0600, Alex Williamson wrote: > > > > We could extend bind_iommufd to return the group id or introduce a > > > new ioctl to query it per dev_id. > > > > That would be ironic to go to all thi

Re: [Intel-gfx] [PATCH v2 10/10] vfio/pci: Add VFIO_DEVICE_GET_PCI_HOT_RESET_GROUP_INFO

2023-03-29 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, March 29, 2023 11:50 PM > > On Wed, Mar 29, 2023 at 09:41:26AM +, Tian, Kevin wrote: > > > We could extend bind_iommufd to return the group id or introduce a > > new ioctl to query it per dev_id. > > > Once th

Re: [Intel-gfx] [PATCH v2 10/10] vfio/pci: Add VFIO_DEVICE_GET_PCI_HOT_RESET_GROUP_INFO

2023-03-29 Thread Tian, Kevin
so needs such knowledge when constructing guest topology. with fd passed in Qemu has no way to associate the fd to a group. We could extend bind_iommufd to return the group id or introduce a new ioctl to query it per dev_id. Once that is in place looks we don't need a new _INFO ioctl? Thanks Kevin

Re: [Intel-gfx] [PATCH v8 19/24] vfio: Name noiommu vfio_device with "noiommu-" prefix

2023-03-27 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Monday, March 27, 2023 5:41 PM > > For noiommu device, vfio core names the cdev node with prefix "noiommu-". > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v8 18/24] vfio: Determine noiommu in vfio_device registration

2023-03-27 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Monday, March 27, 2023 5:41 PM > > This adds a noiommu flag in vfio_device, hence caller of the > vfio_device_is_noiommu() just refers to the flag for noiommu > check. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v2 10/10] vfio/pci: Add VFIO_DEVICE_GET_PCI_HOT_RESET_GROUP_INFO

2023-03-27 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Tuesday, March 28, 2023 11:32 AM > > > From: Alex Williamson > > Sent: Tuesday, March 28, 2023 3:26 AM > > > > Additionally, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO has a flags arg that > > isn't used, why do we need a new ioctl vs defining > > VFIO_PCI_HOT_RESET_FLAG_IOMMUF

Re: [Intel-gfx] [PATCH v3 1/6] iommu/iommufd: Pass iommufd_ctx pointer in iommufd_get_ioas()

2023-03-27 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Monday, March 27, 2023 5:34 PM > > no need to pass the iommufd_ucmd pointer. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v6 12/24] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-24 Thread Tian, Kevin
> From: Alex Williamson > Sent: Wednesday, March 22, 2023 5:01 AM > > On Tue, 21 Mar 2023 17:50:08 -0300 > Jason Gunthorpe wrote: > > > > > Though it would be nice if qemu didn't need two implementations so Yi > > I'd rather see a new info in this series as well and qemu can just > > consistent

Re: [Intel-gfx] [PATCH v6 21/24] vfio: Add VFIO_DEVICE_BIND_IOMMUFD

2023-03-20 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, March 21, 2023 1:17 AM > > On Mon, Mar 20, 2023 at 10:31:53PM +0800, Yi Liu wrote: > > On 2023/3/20 22:09, Jason Gunthorpe wrote: > > > On Wed, Mar 15, 2023 at 04:40:19AM +, Liu, Yi L wrote: > > > > > > > # if IS_ENABLED(CONFIG_VFIO_GROUP) > > > > stat

Re: [Intel-gfx] [PATCH v7 15/22] vfio-iommufd: Add detach_ioas support for physical VFIO devices

2023-03-16 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, March 17, 2023 11:07 AM > > > From: Tian, Kevin > > Sent: Friday, March 17, 2023 10:14 AM > > > > > From: Liu, Yi L > > > Sent: Thursday, March 16, 2023 8:55 PM > > > > > > +

Re: [Intel-gfx] [PATCH v7 22/22] docs: vfio: Add vfio device cdev description

2023-03-16 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, March 16, 2023 8:56 PM > > This gives notes for userspace applications on device cdev usage. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v7 19/22] vfio: Add VFIO_DEVICE_BIND_IOMMUFD

2023-03-16 Thread Tian, Kevin
> + return -EPERM; > + > + return 0; > +} it makes more sense to check CAP first. Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v7 17/22] vfio-iommufd: Add detach_ioas support for emulated VFIO devices

2023-03-16 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, March 16, 2023 8:55 PM > + > +void vfio_iommufd_emulated_detach_ioas(struct vfio_device *vdev) > +{ > + lockdep_assert_held(&vdev->dev_set->lock); > + > + if (WARN_ON(!vdev->iommufd_access) || !vdev->iommufd_attached) > + return; > + ditto t

Re: [Intel-gfx] [PATCH v7 15/22] vfio-iommufd: Add detach_ioas support for physical VFIO devices

2023-03-16 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, March 16, 2023 8:55 PM > > +void vfio_iommufd_physical_detach_ioas(struct vfio_device *vdev) > +{ > + lockdep_assert_held(&vdev->dev_set->lock); > + > + if (WARN_ON(!vdev->iommufd_device) || !vdev->iommufd_attached) > + return; > + the 2nd

Re: [Intel-gfx] [PATCH v7 16/22] iommufd/device: Add iommufd_access_detach() API

2023-03-16 Thread Tian, Kevin
s_unpin_pages() callback to happen via > this unmap() call, add an ioas_unpin pointer, so the unpin routine won't > be affected by the "access->ioas = NULL" trick. > > Signed-off-by: Nicolin Chen > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v7 14/22] vfio: Record devid in vfio_device_file

2023-03-16 Thread Tian, Kevin
by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v7 13/22] vfio-iommufd: Split bind/attach into two steps

2023-03-16 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, March 16, 2023 8:55 PM > > to align with the coming vfio device cdev support. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v7 12/22] vfio-iommufd: Move noiommu support out of vfio_iommufd_bind()

2023-03-16 Thread Tian, Kevin
gt; + if (device->group->iommufd && vfio_device_is_noiommu(device)) { > + if (device->open_count == 0) { > + ret = > vfio_iommufd_enable_noiommu_compat(device, > + device- > >

Re: [Intel-gfx] [PATCH v7 11/22] vfio: Make vfio_device_first_open() to accept NULL iommufd for noiommu

2023-03-16 Thread Tian, Kevin
gt; support in device cdev path it's extended to allow both being NULL. The > caller is expected to verify noiommu permission before passing NULL > to this function. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v7 06/22] kvm/vfio: Accept vfio device file from userspace

2023-03-16 Thread Tian, Kevin
-by: Nicolin Chen > Tested-by: Matthew Rosato > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v7 03/22] vfio: Remove vfio_file_is_group()

2023-03-16 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, March 16, 2023 8:55 PM > > since no user of vfio_file_is_group() now. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH 7/7] vfio/pci: Accept device fd in VFIO_DEVICE_PCI_HOT_RESET ioctl

2023-03-16 Thread Tian, Kevin
Yi Liu this may be adjusted upon whether zero-length approach will be included finally. but on its own: Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH 6/7] vfio: Accpet device file from vfio PCI hot reset path

2023-03-16 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, March 16, 2023 8:42 PM > > This extends both vfio_file_is_valid() and vfio_file_has_dev() to accept > device file from the vfio PCI hot reset. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH 5/7] vfio: Refine vfio file kAPIs for vfio PCI hot reset

2023-03-16 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, March 16, 2023 8:42 PM > > This prepares vfio core to accept vfio device file from the vfio PCI > hot reset path. vfio_file_is_group() is still kept for KVM usage. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH 4/7] vfio/pci: Renaming for accepting device fd in hot reset path

2023-03-16 Thread Tian, Kevin
Otherwise all opened devices in the dev_set must be > - * contained by the set of groups provided by the user. > + * contained by the set of groups/devices provided by > + * the user. just a nit. You may want to add "devices" in the last patch. Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH 3/7] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-16 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, March 16, 2023 8:42 PM > > as an alternative method for ownership check when iommufd is used. In > this case all opened devices in the affected dev_set are verified to > be bound to a same valid iommufd value to allow reset. It's simpler > and faster as user do

Re: [Intel-gfx] [PATCH v2 5/5] vfio: Check the presence for iommufd callbacks in __vfio_register_dev()

2023-03-16 Thread Tian, Kevin
ason Gunthorpe > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v2 4/5] vfio/mdev: Uses the vfio emulated iommufd ops set in the mdev sample drivers

2023-03-16 Thread Tian, Kevin
to > represent the device/iommufd bond. > > Reviewed-by: Jason Gunthorpe > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v2 2/5] vfio-iommufd: No need to record iommufd_ctx in vfio_device

2023-03-16 Thread Tian, Kevin
eviewed-by: Jason Gunthorpe > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v6 12/24] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-16 Thread Tian, Kevin
> From: Alex Williamson > Sent: Friday, March 17, 2023 8:23 AM > > On Thu, 16 Mar 2023 23:29:21 +0000 > "Tian, Kevin" wrote: > > > > From: Alex Williamson > > > Sent: Friday, March 17, 2023 2:46 AM > > > > > > On Wed, 15 Mar 2023

Re: [Intel-gfx] [PATCH v6 12/24] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-16 Thread Tian, Kevin
> From: Alex Williamson > Sent: Friday, March 17, 2023 2:46 AM > > On Wed, 15 Mar 2023 23:31:23 +0000 > "Tian, Kevin" wrote: > > > > From: Alex Williamson > > > Sent: Thursday, March 16, 2023 6:53 AM > > > I'm afraid this pro

Re: [Intel-gfx] [PATCH v6 12/24] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-15 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, March 16, 2023 11:55 AM > > > From: Tian, Kevin > > Sent: Thursday, March 16, 2023 7:31 AM > > > > > From: Alex Williamson > > > Sent: Thursday, March 16, 2023 6:53 AM > > > > > > On Wed, 8 Mar

Re: [Intel-gfx] [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()

2023-03-15 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Thursday, March 16, 2023 1:44 PM > > On Thu, Mar 16, 2023 at 05:38:41AM +, Tian, Kevin wrote: > > External email: Use caution opening links or attachments > > > > > > > From: Nicolin Chen > > > Sent: Thurs

Re: [Intel-gfx] [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()

2023-03-15 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Thursday, March 16, 2023 1:33 PM > > Hi Kevin, > > I've fixed the other two commits. Here is the one that I am > not sure about: > > On Thu, Mar 16, 2023 at 02:53:50AM +, Tian, Kevin wrote: > > > > [2] This add

Re: [Intel-gfx] [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()

2023-03-15 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Wednesday, March 15, 2023 5:03 PM > > Hi, > > On Wed, Mar 15, 2023 at 06:50:53AM +, Tian, Kevin wrote: > > > > So, this preparatory series will add a pair of simple attach() > > > and detach() APIs. Then the cdev se

Re: [Intel-gfx] [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()

2023-03-15 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 15, 2023 4:53 PM > > > From: Tian, Kevin > > Sent: Wednesday, March 15, 2023 2:52 PM > > > > > From: Nicolin Chen > > > Sent: Wednesday, March 15, 2023 2:22 PM > > > > > > On Wed, Mar 15

Re: [Intel-gfx] [PATCH v6 12/24] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-15 Thread Tian, Kevin
> From: Alex Williamson > Sent: Thursday, March 16, 2023 6:53 AM > > On Wed, 8 Mar 2023 05:28:51 -0800 > Yi Liu wrote: > > > This is another method to issue PCI hot reset for the users that bounds > > device to a positive iommufd value. In such case, iommufd is a proof of > > device ownership.

Re: [Intel-gfx] [PATCH v6 21/24] vfio: Add VFIO_DEVICE_BIND_IOMMUFD

2023-03-14 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 15, 2023 12:40 PM > > > From: Tian, Kevin > > Sent: Friday, March 10, 2023 6:07 PM > > > > > From: Liu, Yi L > > > Sent: Friday, March 10, 2023 5:58 PM > > > > > > &g

Re: [Intel-gfx] [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()

2023-03-14 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Wednesday, March 15, 2023 2:22 PM > > On Wed, Mar 15, 2023 at 06:16:37AM +, Tian, Kevin wrote: > > External email: Use caution opening links or attachments > > > > > > > From: Nicolin Chen > > > Sent: Wednesday, M

Re: [Intel-gfx] [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()

2023-03-14 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Wednesday, March 15, 2023 2:33 PM > > On Wed, Mar 15, 2023 at 06:15:23AM +, Tian, Kevin wrote: > > External email: Use caution opening links or attachments > > > > > > > From: Nicolin Chen > > > Sent: Wednesday, M

Re: [Intel-gfx] [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()

2023-03-14 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Wednesday, March 15, 2023 2:51 AM > > On Fri, Mar 10, 2023 at 02:08:15AM +, Tian, Kevin wrote: > > External email: Use caution opening links or attachments > > > > > > > From: Liu, Yi L > > > Sent: Wednesday, Marc

Re: [Intel-gfx] [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()

2023-03-14 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Wednesday, March 15, 2023 9:01 AM > > Hi Jason/Kevin, > > > > > Perhaps we can have iommufd_access_attach/detach in this series > > along with a vfio_iommufd_emulated_detach_ioas, and the locking > > will come with another patc

Re: [Intel-gfx] [PATCH v6 13/24] vfio/iommufd: Split the compat_ioas attach out from vfio_iommufd_bind()

2023-03-12 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Saturday, March 11, 2023 6:24 PM > > > > > > > > - ret = vdev->ops->bind_iommufd(vdev, ictx, &device_id); > > > > - if (ret) > > > > - return ret; > > > > + /* The legacy path has no way to return the device id */ > > > > + return vde

Re: [Intel-gfx] [PATCH v1 5/5] vfio: Check the presence for iommufd callbacks in __vfio_register_dev()

2023-03-12 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Friday, March 10, 2023 10:04 PM > > On Fri, Mar 10, 2023 at 02:15:32AM +, Tian, Kevin wrote: > > > From: Liu, Yi L > > > Sent: Wednesday, March 8, 2023 9:14 PM > > > > > > After making the no-DMA drivers (sample

Re: [Intel-gfx] [PATCH v6 21/24] vfio: Add VFIO_DEVICE_BIND_IOMMUFD

2023-03-10 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, March 10, 2023 5:58 PM > > > From: Tian, Kevin > > Sent: Friday, March 10, 2023 5:02 PM > > > > > From: Liu, Yi L > > > Sent: Wednesday, March 8, 2023 9:29 PM > > > + > > > +stati

Re: [Intel-gfx] [PATCH v6 13/24] vfio/iommufd: Split the compat_ioas attach out from vfio_iommufd_bind()

2023-03-10 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, March 10, 2023 4:22 PM > > > > > > +int vfio_iommufd_attach_compat_ioas(struct vfio_device *vdev, > > > + struct iommufd_ctx *ictx) > > > +{ > > > + u32 ioas_id; > > > + int ret; > > > + > > > + lockdep_assert_held(&vdev->dev_set->lock

Re: [Intel-gfx] [PATCH v6 12/24] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-10 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, March 10, 2023 2:04 PM > > > + * > > > + * In the last case all affected devices which are opened by this user > > > + * must have been bound to a same iommufd_ctx. This approach is only > > > + * available for devices bound to positive iommufd. > > > > As we cha

Re: [Intel-gfx] [PATCH v6 23/24] vfio: Compile group optionally

2023-03-10 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:29 PM > > group code is not needed for vfio device cdev, so with vfio device cdev > introduced, the group infrastructures can be compiled out if only cdev > is needed. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v6 21/24] vfio: Add VFIO_DEVICE_BIND_IOMMUFD

2023-03-10 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:29 PM > + > +static int vfio_device_cdev_probe_noiommu(struct vfio_device *device) > +{ > + struct iommu_group *iommu_group; > + int ret = 0; > + > + if (!IS_ENABLED(CONFIG_VFIO_NOIOMMU) || !vfio_noiommu) > + return -EINV

Re: [Intel-gfx] [PATCH v6 20/24] vfio: Add cdev for vfio_device

2023-03-10 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:29 PM > > + /* > + * Placing it before vfio_device_put_registration() to prevent > + * new registration refcount increment by > VFIO_GROUP_GET_DEVICE_FD > + * during the unregister time. > + */ > + vfio_device_group_

Re: [Intel-gfx] [PATCH v6 17/24] vfio-iommufd: Make vfio_iommufd_bind() selectively return devid

2023-03-10 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:29 PM > > bind_iommufd() will generate an ID to represent this bond, it is needed > by userspace for further usage. devid is stored in vfio_device_file to > avoid passing devid pointer in multiple places. after removing vfio_iommufd_bind() the

Re: [Intel-gfx] [PATCH v6 16/24] vfio: Make vfio_device_first_open() to cover the noiommu mode in cdev path

2023-03-10 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:29 PM > > +/* > + * This shall be used without group lock as group and group->container > + * should be fixed before group is set to df->group. > + */ /* No group lock since df->group and df->group->container cannot change */ > +bool vfio_dev

Re: [Intel-gfx] [PATCH v6 13/24] vfio/iommufd: Split the compat_ioas attach out from vfio_iommufd_bind()

2023-03-10 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:29 PM > > @@ -177,7 +177,7 @@ static int vfio_device_group_open(struct > vfio_device_file *df) > mutex_lock(&device->group->group_lock); > if (!vfio_group_has_iommu(device->group)) { > ret = -EINVAL; > - go

Re: [Intel-gfx] [PATCH v6 12/24] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-09 Thread Tian, Kevin
> From: Yi Liu > Sent: Wednesday, March 8, 2023 9:29 PM > > This is another method to issue PCI hot reset for the users that bounds > device to a positive iommufd value. In such case, iommufd is a proof of > device ownership. By passing a zero-length fd array, user indicates kernel > to do ownersh

Re: [Intel-gfx] [PATCH v6 11/24] vfio/pci: Accept device fd in VFIO_DEVICE_PCI_HOT_RESET ioctl

2023-03-09 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:29 PM > > @@ -1319,8 +1319,14 @@ static int vfio_pci_ioctl_pci_hot_reset(struct > vfio_pci_core_device *vdev, > break; > } > > - /* Ensure the FD is a vfio group FD.*/ > - if (!vfio_f

Re: [Intel-gfx] [PATCH v6 10/24] vfio/pci: Rename the helpers and data in hot reset path to accept device fd

2023-03-09 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:29 PM > > No function change is intended, just to make the helpers and structures > to be prepared to accept device fds as proof of device ownership. > > Signed-off-by: Yi Liu > --- > drivers/vfio/pci/vfio_pci_core.c | 40 ---

Re: [Intel-gfx] [PATCH v6 09/24] vfio/pci: Only need to check opened devices in the dev_set for hot reset

2023-03-09 Thread Tian, Kevin
is safe, because * dev_set->lock is held in hot reset path so this device * cannot race being opened by another user simultaneously. * * Otherwise all opened devices in the dev_set must be * contained by the set of groups provided by the user. the rest looks good: Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v6 07/24] vfio: Block device access via device fd until device is opened

2023-03-09 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:29 PM > > @@ -1114,6 +1114,10 @@ static long vfio_device_fops_unl_ioctl(struct file > *filep, > struct vfio_device *device = df->device; > int ret; > > + /* Paired with smp_store_release() in vfio_device_group_open() */ > +

Re: [Intel-gfx] [PATCH v1 5/5] vfio: Check the presence for iommufd callbacks in __vfio_register_dev()

2023-03-09 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:14 PM > > After making the no-DMA drivers (samples/vfio-mdev) providing iommufd > callbacks, __vfio_register_dev() should check the presence of the iommufd > callbacks if CONFIG_IOMMUFD is enabled. > > Signed-off-by: Yi Liu > --- > drivers/v

Re: [Intel-gfx] [PATCH v1 4/5] Samples/mdev: Uses the vfio emulated iommufd ops set in the mdev sample drivers

2023-03-09 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:14 PM > > @@ -32,12 +32,8 @@ int vfio_iommufd_bind(struct vfio_device *vdev, > struct iommufd_ctx *ictx) > return 0; > } > > - /* > - * If the driver doesn't provide this op then it means the device does > - *

Re: [Intel-gfx] [PATCH v1 3/5] vfio-iommufd: Make vfio_iommufd_emulated_bind() return iommufd_access ID

2023-03-09 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:14 PM > > vfio device cdev needs to return iommufd_access ID to userspace if > bind_iommufd succeeds. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

Re: [Intel-gfx] [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind()

2023-03-09 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 9:14 PM > > @@ -449,33 +450,18 @@ iommufd_access_create(struct iommufd_ctx *ictx, > u32 ioas_id, > access->data = data; > access->ops = ops; > > - obj = iommufd_get_object(ictx, ioas_id, IOMMUFD_OBJ_IOAS); > - if (IS_ERR(obj))

Re: [Intel-gfx] [PATCH v5 09/19] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-08 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 4:01 PM > > > From: Tian, Kevin > > Sent: Wednesday, March 8, 2023 3:55 PM > > > > > From: Liu, Yi L > > > Sent: Wednesday, March 8, 2023 3:47 PM > > > > > > >

Re: [Intel-gfx] [PATCH v5 09/19] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-07 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, March 8, 2023 3:47 PM > > > From: Tian, Kevin > > Sent: Wednesday, March 8, 2023 3:26 PM > > > > > From: Liu, Yi L > > > Sent: Tuesday, March 7, 2023 9:29 PM > > > > > > > > >

Re: [Intel-gfx] [PATCH v5 09/19] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-07 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Tuesday, March 7, 2023 9:29 PM > > > > > I really prefer the 'use the iommufd option' still exist, it is so > > much cleaner and easier for the actual users of this API. We've lost > > the point by worrying about no iommu. > > Hmmm, so you are suggesting to have both th

Re: [Intel-gfx] [PATCH v5 16/19] vfio: Add VFIO_DEVICE_BIND_IOMMUFD

2023-03-07 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Tuesday, March 7, 2023 9:04 PM > > > From: Jason Gunthorpe > > Sent: Tuesday, March 7, 2023 8:38 PM > > > > On Tue, Mar 07, 2023 at 06:38:59AM +, Tian, Kevin wrote: > > > > From: Liu, Yi L > > > > Sent: Fr

Re: [Intel-gfx] [PATCH v5 16/19] vfio: Add VFIO_DEVICE_BIND_IOMMUFD

2023-03-06 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, March 3, 2023 2:58 PM > > > What should we return here anyhow if an access was created? > > iommufd_access->obj.id. should be fine. Is it? > Thinking more I'm not sure whether it's a good idea to fill the dev_id field with an access object id and then later co

Re: [Intel-gfx] [PATCH v5 09/19] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-06 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Monday, March 6, 2023 9:17 PM > > On Fri, Mar 03, 2023 at 09:55:42AM -0700, Alex Williamson wrote: > > > I can't think of a reason DPDK couldn't use hot-reset. If we want to > > make it a policy, it should be enforced by code, but creating that > > policy based o

Re: [Intel-gfx] [PATCH v5 09/19] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-06 Thread Tian, Kevin
> From: Tian, Kevin > Sent: Monday, March 6, 2023 4:17 PM > > > From: Liu, Yi L > > Sent: Sunday, March 5, 2023 10:49 PM > > > > > > How about falling back to prior solution. Allow userspace to pass a set > > of device fd, and the kernel just chec

Re: [Intel-gfx] [PATCH v5 09/19] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-06 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Sunday, March 5, 2023 10:49 PM > > > From: Alex Williamson > > Sent: Saturday, March 4, 2023 12:56 AM > > > > On Fri, 3 Mar 2023 06:36:35 + > > "Tian, Kevin" wrote: > > > > > use of noiommu should be

Re: [Intel-gfx] [PATCH v5 09/19] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-02 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, March 2, 2023 10:20 PM > > > From: Jason Gunthorpe > > Sent: Thursday, March 2, 2023 8:35 PM > > > > On Thu, Mar 02, 2023 at 09:55:46AM +, Tian, Kevin wrote: > > > > From: Liu, Yi L

Re: [Intel-gfx] [PATCH v5 09/19] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

2023-03-02 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, March 2, 2023 2:07 PM > > > - if (!vfio_dev_in_groups(cur_vma, groups)) { > > + if (cur_vma->vdev.open_count && > > + !vfio_dev_in_groups(cur_vma, groups) && > > + !vfio_dev_in_iommufd_ctx(cur_vma, iommufd_ctx)) {

Re: [Intel-gfx] [PATCH v4 09/19] vfio/pci: Accept device fd for hot reset

2023-02-23 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, February 24, 2023 11:44 AM > > > Upon reflection we can probably make it even simpler and just have a 0 > > > length fd array mean to use the iommufd the vfio_device is already > > > associated with > > > > > > And the check for correctness can be simplified to si

Re: [Intel-gfx] [PATCH v4 09/19] vfio/pci: Accept device fd for hot reset

2023-02-23 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Friday, February 24, 2023 10:36 AM > > On Fri, Feb 24, 2023 at 02:21:33AM +, Tian, Kevin wrote: > > > Yi, while you are incorporating this change please also update the > > uapi header. Rename 'group_fds[]' to 'fds

  1   2   3   4   5   >