RE: [PATCH v2 3/6] iommu/vt-d: Make intel_iommu_set_dev_pasid() to handle domain replacement

2024-10-10 Thread Tian, Kevin
> From: Baolu Lu > Sent: Wednesday, October 9, 2024 9:09 AM > > On 2024/9/30 15:19, Tian, Kevin wrote: > >> From: Baolu Lu > >> Sent: Friday, September 13, 2024 10:17 AM > >> > >> On 9/13/24 9:35 AM, Baolu Lu wrote: > >&g

RE: [PATCH v3 4/4] iommufd: Extend IOMMU_GET_HW_INFO to report PASID capability

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:17 PM > > PASID usage requires PASID support in both device and IOMMU. Since the > iommu drivers always enable the PASID capability for the device if it > is supported, so it is reasonable to extend the IOMMU_GET_HW_INFO to > report the PAS

RE: [PATCH v3 3/4] vfio: Add VFIO_DEVICE_PASID_[AT|DE]TACH_IOMMUFD_PT

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:17 PM > > +/* > + * VFIO_DEVICE_PASID_ATTACH_IOMMUFD_PT - _IOW(VFIO_TYPE, > VFIO_BASE + 21, > + * struct > vfio_device_pasid_attach_iommufd_pt) > + * @argsz: User filled size of this data. > + * @fl

RE: [PATCH v3 1/4] ida: Add ida_find_first_range()

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:17 PM > > There is no helpers for user to check if a given ID is allocated or not, > neither a helper to loop all the allocated IDs in an IDA and do something > for cleanup. With the two needs, a helper to get the lowest allocated ID > of a

RE: [PATCH v4 04/10] iommufd: Always pass iommu_attach_handle to iommu core

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:13 PM > > The iommu_attach_handle is optional in the RID attach/replace API and the > PASID attach APIs. But it is a mandatory argument for the PASID replace API. > Without it, the PASID replace path cannot get the old domain. Hence, the >

RE: [PATCH v4 03/10] iommufd: Move the iommufd_handle helpers to iommufd_private.h

2024-09-30 Thread Tian, Kevin
> From: Yi Liu > Sent: Thursday, September 12, 2024 9:13 PM > > iommufd plans to always pass in an iommu_attach_handle to the iommu > core, so it's no longer fault specific, hence move the helpers out > of the fault.c again please put the reason for why iommufd plans to do so. > --- a/drivers/i

RE: [PATCH v4 02/10] iommufd: Refactor __fault_domain_replace_dev() to be a wrapper of iommu_replace_group_handle()

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:13 PM > > @@ -191,13 +187,25 @@ int iommufd_fault_domain_replace_dev(struct > iommufd_device *idev, > return ret; > } > > - ret = __fault_domain_replace_dev(idev, hwpt, old); > + if (hwpt->fault) { > +

RE: [PATCH v4 01/10] iommu: Introduce a replace API for device pasid

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:13 PM > > +/** > + * iommu_replace_device_pasid - Replace the domain that a pasid is > attached to > + * @domain: the new iommu domain > + * @dev: the attached device. > + * @pasid: the pasid of the device. > + * @handle: the attach handle.

RE: [PATCH 3/3] iommu: Add a wrapper for remove_dev_pasid

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:07 PM > > The iommu drivers are on the way to drop the remove_dev_pasid op by > extending the blocked_domain to support PASID. However, this cannot be > done in one shot. So far, the Intel iommu and the ARM SMMUv3 driver have > supported it

RE: [PATCH 2/3] iommu/vt-d: Make blocked domain support PASID

2024-09-30 Thread Tian, Kevin
> From: Yi Liu > Sent: Thursday, September 12, 2024 9:07 PM > > The blocked domain can be extended to park PASID of a device to be the > DMA blocking state. By this the remove_dev_pasid() op is dropped. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

RE: [PATCH 1/3] iommu/arm-smmu-v3: Make smmuv3 blocked domain support PASID

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:07 PM > > From: Jason Gunthorpe > > The blocked domain is used to park RID to be blocking DMA state. This > can be extended to PASID as well. By this, the remove_dev_pasid() op > of ARM SMMUv3 can be dropped. > > Signed-off-by: Jason Gun

RE: [PATCH v2 6/6] iommu: Make set_dev_pasid op support domain replacement

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:04 PM > > The iommu core is going to support domain replacement for pasid, it needs > to make the set_dev_pasid op support replacing domain and keep the old > domain config in the failure case. > > AMD iommu driver does not support domain

RE: [PATCH v2 5/6] iommu/arm-smmu-v3: Make smmuv3 set_dev_pasid() op support replace

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:04 PM > > From: Jason Gunthorpe > > set_dev_pasid() op is going to be enhanced to support domain replacement > of a pasid. This prepares for this op definition. > > Signed-off-by: Jason Gunthorpe > Signed-off-by: Yi Liu Reviewed-by: K

RE: [PATCH v2 4/6] iommu/vt-d: Add set_dev_pasid callback for nested domain

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:04 PM > > From: Lu Baolu > > Extend intel_iommu_set_dev_pasid() to set a nested type domain to a PASID > of a device. > > Signed-off-by: Lu Baolu > Co-developed-by: Yi Liu > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

RE: [PATCH v2 3/6] iommu/vt-d: Make intel_iommu_set_dev_pasid() to handle domain replacement

2024-09-30 Thread Tian, Kevin
> From: Baolu Lu > Sent: Friday, September 13, 2024 10:17 AM > > On 9/13/24 9:35 AM, Baolu Lu wrote: > > On 9/12/24 9:04 PM, Yi Liu wrote: > >> +static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t > >> pasid, > >> + struct iommu_domain *domain) > >> +{ > >> +

RE: [PATCH v2 2/6] iommu/vt-d: Move intel_drain_pasid_prq() into intel_pasid_tear_down_entry()

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:04 PM > > +/* > + * Not all PASID entry destroy requires PRQ drain as it can be handled in > + * the remove_dev_pasid path. Caller should be clear about it and set the > + * @flags properly. > + */ /* * Caller can request to drain PRQ in

RE: [PATCH v2 1/6] iommu: Pass old domain to set_dev_pasid op

2024-09-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, September 12, 2024 9:04 PM > > To support domain replacement for pasid, the underlying iommu driver > needs > to know the old domain hence be able to clean up the existing attachment. > It would be much convenient for iommu layer to pass down the old domain. >

RE: [PATCH rc 2/2] iommu: Do not return 0 from map_pages if it doesn't do anything

2024-08-25 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Thursday, August 22, 2024 10:46 PM > > These three implementations of map_pages() all succeed if a mapping is > requested with no read or write. Since they return back to __iommu_map() > leaving the mapped output as 0 it triggers an infinite loop. Therefore > nothi

RE: [PATCH rc 1/2] iommufd: Do not allow creating areas without READ or WRITE

2024-08-25 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Thursday, August 22, 2024 10:46 PM > > This results in passing 0 or just IOMMU_CACHE to iommu_map(). Most of > the page table formats don't like this: > > amdv1 - -EINVAL > armv7s - returns 0, doesn't update mapped > arm-lpae - returns 0 doesn't update mappe

RE: [PATCH v2 2/3] iommu/dma: Support MSIs through nested domains

2024-08-09 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Friday, August 9, 2024 7:00 AM > > On Thu, Aug 08, 2024 at 01:38:44PM +0100, Robin Murphy wrote: > > On 06/08/2024 9:25 am, Tian, Kevin wrote: > > > > From: Nicolin Chen > > > > Sent: Saturday, August 3, 2024

RE: [PATCH v2 2/3] iommu/dma: Support MSIs through nested domains

2024-08-09 Thread Tian, Kevin
> From: Robin Murphy > Sent: Thursday, August 8, 2024 8:39 PM > > On 06/08/2024 9:25 am, Tian, Kevin wrote: > >> From: Nicolin Chen > >> Sent: Saturday, August 3, 2024 8:32 AM > >> > >> From: Robin Murphy > >> > >> Cur

RE: [PATCH v2 2/3] iommu/dma: Support MSIs through nested domains

2024-08-06 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Saturday, August 3, 2024 8:32 AM > > From: Robin Murphy > > Currently, iommu-dma is the only place outside of IOMMUFD and drivers > which might need to be aware of the stage 2 domain encapsulated within > a nested domain. This would be in the legacy-VFIO-style case

RE: [PATCH RFC 0/5] mm/gup: Introduce exclusive GUP pinning

2024-08-05 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, August 6, 2024 7:23 AM > > On Mon, Aug 05, 2024 at 02:24:42AM +, Tian, Kevin wrote: > > > > According to [3], > > > > " > > With SNP, when pages are marked as guest-owned in the RMP table, > > t

RE: [PATCH RFC 0/5] mm/gup: Introduce exclusive GUP pinning

2024-08-04 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Friday, August 2, 2024 7:22 PM > > On Fri, Aug 02, 2024 at 08:26:48AM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Thursday, June 20, 2024 10:34 PM > > > > > > On Thu, Jun 20, 2024 at 04:14:23PM

RE: [PATCH RFC 0/5] mm/gup: Introduce exclusive GUP pinning

2024-08-02 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Thursday, June 20, 2024 10:34 PM > > On Thu, Jun 20, 2024 at 04:14:23PM +0200, David Hildenbrand wrote: > > > 1) How would the device be able to grab/access "private memory", if not > >via the user page tables? > > The approaches I'm aware of require the secu

RE: [PATCH v3 1/7] iommu: Introduce a replace API for device pasid

2024-07-18 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, June 28, 2024 5:06 PM > > @@ -3289,7 +3290,20 @@ static int __iommu_set_group_pasid(struct > iommu_domain *domain, > > if (device == last_gdev) > break; > - ops->remove_dev_pasid(device->dev, pasid, domain); > +

RE: [PATCH 1/8] iommu: Introduce a replace API for device pasid

2024-03-11 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Sunday, March 10, 2024 9:06 PM > > On 2024/1/16 01:19, Jason Gunthorpe wrote: > > On Sun, Nov 26, 2023 at 10:34:21PM -0800, Yi Liu wrote: > >> +int iommu_replace_device_pasid(struct iommu_domain *domain, > >> + struct device *dev, ioasid_t pasid)

RE: [PATCH] iommu/vt-d: Set SSADE when attaching to a parent with dirty tracking

2024-02-18 Thread Tian, Kevin
> From: Joao Martins > Sent: Friday, February 9, 2024 6:36 PM > > On 08/02/2024 10:31, Joao Martins wrote: > > On 08/02/2024 09:14, Yi Liu wrote: > >> Should set the SSADE (Second Stage Access/Dirty bit Enable) bit of the > >> pasid entry when attaching a device to a nested domain if its parent >

RE: [PATCH rc 8/8] iommu/vt-d: Add missing dirty tracking set for parent domain

2024-02-08 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, February 8, 2024 4:23 PM > > @@ -4760,6 +4790,12 @@ static int intel_iommu_set_dirty_tracking(struct > iommu_domain *domain, > if (ret) > goto err_unwind; > > + if (dmar_domain->nested_parent) { > + ret = parent_domain_set_d

RE: [PATCH rc 7/8] iommu/vt-d: Wrap the dirty tracking loop to be a helper

2024-02-08 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, February 8, 2024 4:23 PM > > Add device_set_dirty_tracking() to loop all the devices and set the dirty > tracking per the @enable parameter. > > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

RE: [PATCH rc 6/8] iommu/vt-d: Remove @domain parameter from intel_pasid_setup_dirty_tracking()

2024-02-08 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, February 8, 2024 4:23 PM > > The only usage of input @domain is to get the domain id (DID) to flush > cache after setting dirty tracking. However, DID can be obtained from > the pasid entry. So no need to pass in domain. This can make this helper > cleaner when

RE: [PATCH rc 5/8] iommu/vt-d: Add missing device iotlb flush for parent domain

2024-02-08 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, February 8, 2024 4:23 PM > > ATS-capable devices cache the result of nested translation. This result > relies on the mappings in s2 domain (a.k.a. parent). When there are > modifications in the s2 domain, the related nested translation caches on > the device sh

RE: [PATCH rc 4/8] iommu/vt-d: Update iotlb in nested domain attach

2024-02-08 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, February 8, 2024 4:23 PM > > Should call domain_update_iotlb() to update the has_iotlb_device flag > of the domain after attaching device to nested domain. Without it, this > flag is not set properly and would result in missing device TLB flush. > > Fixes: 983

RE: [PATCH rc 3/8] iommu/vt-d: Add missing iotlb flush for parent domain

2024-02-08 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, February 8, 2024 4:23 PM > > +/* > + * Flush the relevant caches in nested translation if the domain > + * also serves as a parent > + */ > +static void parent_domain_flush(struct dmar_domain *domain, > + unsigned long pfn, > +

RE: [PATCH rc 2/8] iommu/vt-d: Add __iommu_flush_iotlb_psi()

2024-02-08 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, February 8, 2024 4:23 PM > > Add __iommu_flush_iotlb_psi() to do the psi iotlb flush with a DID input > rather than calculating it within the helper. > > This is useful when flushing cache for parent domain which reuses DIDs of > its nested domains. > > Signe

RE: [PATCH rc 1/8] iommu/vt-d: Track nested domains in parent

2024-02-08 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, February 8, 2024 4:23 PM > > static void intel_nested_domain_free(struct iommu_domain *domain) > { > + struct dmar_domain *dmar_domain = to_dmar_domain(domain); > + struct dmar_domain *s2_domain = dmar_domain->s2_domain; > + > + spin_lock(&s2_doma

RE: [PATCH 3/8] iommufd: Support attach/replace hwpt per pasid

2024-01-16 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, January 16, 2024 8:58 PM > > On Tue, Jan 16, 2024 at 01:18:12AM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Tuesday, January 16, 2024 1:25 AM > > > > > > On Sun

RE: [PATCH 3/8] iommufd: Support attach/replace hwpt per pasid

2024-01-15 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, January 16, 2024 1:25 AM > > On Sun, Nov 26, 2023 at 10:34:23PM -0800, Yi Liu wrote: > > +/** > > + * iommufd_device_pasid_detach - Disconnect a {device, pasid} to an > iommu_domain > > + * @idev: device to detach > > + * @pasid: pasid to detach > > + * >

RE: [PATCH v11 0/8] Add iommufd nesting (part 2/2)

2024-01-10 Thread Tian, Kevin
> From: Yi Liu > Sent: Thursday, January 11, 2024 12:10 PM > > v11: > - Drop hw_error field in vtd cache invalidation uapi. devTLB invalidation >error is a serious security emergency requiring the host kernel to handle. >No need to expose it to userspace (especially given existing VMs do

RE: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2024-01-07 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Friday, January 5, 2024 10:45 PM > > On Fri, Jan 05, 2024 at 02:52:50AM +, Tian, Kevin wrote: > > > but in reality the relation could be identified in an easy way due to a > > > SIOV > > > restriction which we disc

RE: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2024-01-04 Thread Tian, Kevin
> From: Tian, Kevin > Sent: Friday, January 5, 2024 10:16 AM > > > From: Jason Gunthorpe > > Sent: Thursday, January 4, 2024 10:37 PM > > > > On Thu, Dec 14, 2023 at 07:26:39PM +0800, Yi Liu wrote: > > > Per the prior discussion[1], we agreed to move t

RE: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2024-01-04 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Thursday, January 4, 2024 10:37 PM > > On Thu, Dec 14, 2023 at 07:26:39PM +0800, Yi Liu wrote: > > Per the prior discussion[1], we agreed to move the error reporting into the > > driver specific part. On Intel side, we want to report two devTLB > > invalidation err

RE: [PATCH v9 00/10] Add iommufd nesting (part 2/2)

2023-12-28 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 28, 2023 11:06 PM > > This series is based on the first part which was merged [1], this series is to > add the cache invalidation interface or the userspace to invalidate cache > after > modifying the stage-1 page table. This includes both the iommufd

RE: [PATCH v9 10/10] iommu/vt-d: Add iotlb flush for nested domain

2023-12-28 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 28, 2023 11:06 PM > > From: Lu Baolu > > This implements the .cache_invalidate_user() callback to support iotlb > flush for nested domain. > > Signed-off-by: Lu Baolu > Co-developed-by: Yi Liu > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

RE: [PATCH v9 07/10] iommu/vt-d: Allow qi_submit_sync() to return the QI faults

2023-12-28 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 28, 2023 11:06 PM > > From: Lu Baolu > > This allows qi_submit_sync() to return back faults to callers. this might be useful to add a note that the retry logic itself is being discussed in a separate thread [1]. Here we keep it intact and just make

RE: [PATCH v8 10/10] iommu/vt-d: Add iotlb flush for nested domain

2023-12-27 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 28, 2023 12:14 AM > > > +static void nested_flush_pasid_iotlb(struct intel_iommu *iommu, > + struct dmar_domain *domain, u64 addr, > + unsigned long npages, bool ih) > +{ > + u16 di

RE: [PATCH v8 09/10] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2023-12-27 Thread Tian, Kevin
> From: Tian, Kevin > Sent: Thursday, December 28, 2023 2:38 PM > > > From: Liu, Yi L > > Sent: Thursday, December 28, 2023 12:14 AM > > +/** > > + * struct iommu_hwpt_vtd_s1_invalidat

RE: [PATCH v8 09/10] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2023-12-27 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 28, 2023 12:14 AM > +/** > + * struct iommu_hwpt_vtd_s1_invalidate - Intel VT-d cache invalidation > + * (IOMMU_HWPT_INVALIDATE_DATA_VTD_S1) > + * @addr: The start address of the range to be invalidated. It needs to

RE: [PATCH v8 08/10] iommu/vt-d: Convert stage-1 cache invalidation to return QI fault

2023-12-27 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 28, 2023 12:14 AM > > From: Lu Baolu > > This makes the pasid based cache invalidation and device TLB invalidation > to return QI faults to callers. This is needed when usersapce invalidates > cache after modifying the stage-1 page table used in nest

RE: [PATCH v8 07/10] iommu/vt-d: Allow qi_submit_sync() to return the QI faults

2023-12-27 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 28, 2023 12:14 AM > > @@ -1376,6 +1383,8 @@ int qi_submit_sync(struct intel_iommu *iommu, > struct qi_desc *desc, > > restart: > rc = 0; > + if (fault) > + *fault = 0; move it to right before the loop of qi_check_fault() > >

RE: [PATCH v8 06/10] iommufd/selftest: Add coverage for IOMMU_HWPT_INVALIDATE ioctl

2023-12-27 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 28, 2023 12:14 AM > > + /* Negative test: trigger error */ > + num_inv = 1; > + inv_reqs[0].flags = > IOMMU_TEST_INVALIDATE_FLAG_TRIGGER_ERROR; > + inv_reqs[0].iotlb_id = 0; > + test_cmd_hwpt_

RE: [PATCH v8 02/10] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-27 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 28, 2023 12:14 AM > > In nested translation, the stage-1 page table is user-managed but cached > by the IOMMU hardware, so an update on present page table entries in the > stage-1 page table should be followed with a cache invalidation. > > Add an IOM

RE: [PATCH v7 7/9] iommu/vt-d: Allow qi_submit_sync() to return the QI faults

2023-12-27 Thread Tian, Kevin
t; Sent: Tuesday, December 26, 2023 4:44 PM > >>> Subject: Re: [PATCH v7 7/9] iommu/vt-d: Allow qi_submit_sync() to > return > >>> the QI faults > >>> > >>> On 2023/12/26 14:15, Yi Liu wrote: > >>>> > >>>> On 2023/12

RE: [PATCH v7 7/9] iommu/vt-d: Allow qi_submit_sync() to return the QI faults

2023-12-26 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Tuesday, December 26, 2023 4:44 PM > > On 2023/12/26 14:15, Yi Liu wrote: > > > > > > On 2023/12/26 12:13, Tian, Kevin wrote: > >>> From: Liu, Yi L > >>> Sent: Tuesday, December 26, 2023 12:03 PM > >>> &

RE: [PATCH v7 9/9] iommu/vt-d: Add iotlb flush for nested domain

2023-12-25 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Tuesday, December 26, 2023 12:52 PM > >> + > >> + if (!IS_ALIGNED(inv_entry.addr, VTD_PAGE_SIZE) || > >> + ((inv_entry.npages == U64_MAX) && inv_entry.addr)) { > >> + ret = -EINVAL; > >> + break; > >> + } >

RE: [PATCH v7 7/9] iommu/vt-d: Allow qi_submit_sync() to return the QI faults

2023-12-25 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Tuesday, December 26, 2023 12:03 PM > > On 2023/12/22 12:23, Tian, Kevin wrote: > >> From: Liu, Yi L > >> Sent: Thursday, December 21, 2023 11:40 PM > >> > >> + fault &= DMA_FSTS_IQE | DMA_FSTS_ITE | DMA_FST

RE: [PATCH v7 9/9] iommu/vt-d: Add iotlb flush for nested domain

2023-12-21 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, December 22, 2023 3:02 PM > > > > On Dec 22, 2023, at 14:47, Tian, Kevin wrote: > > > > > >> > >> From: Yang, Weijiang > >> Sent: Friday, December 22, 2023 11:56 AM >

RE: [PATCH v7 9/9] iommu/vt-d: Add iotlb flush for nested domain

2023-12-21 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 21, 2023 11:40 PM > > + > +static void intel_nested_flush_cache(struct dmar_domain *domain, u64 > addr, > + unsigned long npages, u32 *error) > +{ > + struct iommu_domain_info *info; > + unsigned long i; > +

RE: [PATCH v7 9/9] iommu/vt-d: Add iotlb flush for nested domain

2023-12-21 Thread Tian, Kevin
> From: Yang, Weijiang > Sent: Friday, December 22, 2023 11:56 AM > > + > > + xa_for_each(&domain->iommu_array, i, info) { > > + nested_flush_pasid_iotlb(info->iommu, domain, addr, > npages, 0); > > + > > + if (domain->has_iotlb_device) > > + continue; > >

RE: [PATCH v7 8/9] iommu/vt-d: Convert pasid based cache invalidation to return QI fault

2023-12-21 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 21, 2023 11:40 PM > > From: Lu Baolu > > This makes the pasid based cache invalidation to return QI faults to callers. it's not just for pasid cache invalidation, e.g. there is also change on qi_flush_dev_iotlb(). > This is needed when usersapce wa

RE: [PATCH v7 7/9] iommu/vt-d: Allow qi_submit_sync() to return the QI faults

2023-12-21 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 21, 2023 11:40 PM > > + fault &= DMA_FSTS_IQE | DMA_FSTS_ITE | DMA_FSTS_ICE; > + if (fault) { > + if (fsts) > + *fsts |= fault; do we expect the fault to be accumulated? otherwise it's clearer to just do direct a

RE: [PATCH v7 6/9] iommufd/selftest: Add coverage for IOMMU_HWPT_INVALIDATE ioctl

2023-12-21 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 21, 2023 11:40 PM > > From: Nicolin Chen > > Add test cases for the IOMMU_HWPT_INVALIDATE ioctl and verify it by using > the new IOMMU_TEST_OP_MD_CHECK_IOTLB. > > Signed-off-by: Nicolin Chen > Co-developed-by: Yi Liu > Signed-off-by: Yi Liu over

RE: [PATCH v7 5/9] iommufd/selftest: Add IOMMU_TEST_OP_MD_CHECK_IOTLB test op

2023-12-21 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 21, 2023 11:40 PM > > From: Nicolin Chen > > Allow to test whether IOTLB has been invalidated or not. > > Signed-off-by: Nicolin Chen > Signed-off-by: Yi Liu Reviewed-by: Kevin Tian

RE: [PATCH v7 4/9] iommufd/selftest: Add mock_domain_cache_invalidate_user support

2023-12-21 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 21, 2023 11:40 PM > + > + > + if ((inv.flags & IOMMU_TEST_INVALIDATE_FLAG_ALL) && > + (inv.flags & > IOMMU_TEST_INVALIDATE_FLAG_TRIGGER_ERROR)) { > + rc = -EINVAL; > + break; > +

RE: [PATCH v7 3/9] iommu: Add iommu_copy_struct_from_user_array helper

2023-12-21 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 21, 2023 11:40 PM > > From: Nicolin Chen > > Wrap up the data pointer/num sanity and __iommu_copy_struct_from_user > call for iommu drivers to copy driver specific data at a specific location > in the struct iommu_user_data_array, and > iommu_respond

RE: [PATCH v7 2/9] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-21 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 21, 2023 11:40 PM > + > +int iommufd_hwpt_invalidate(struct iommufd_ucmd *ucmd) > +{ > + struct iommu_hwpt_invalidate *cmd = ucmd->cmd; > + struct iommu_user_data_array data_array = { > + .type = cmd->req_type, > + .uptr

RE: [PATCH v7 1/9] iommu: Add cache_invalidate_user op

2023-12-21 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 21, 2023 11:40 PM > > From: Lu Baolu > > The updates of the PTEs in the nested page table will be propagated to the > hardware caches on both IOMMU (IOTLB) and devices (DevTLB/ATC). this is incorrect. the scope of this cmd is driver specific. > >

RE: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2023-12-17 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Sunday, December 17, 2023 2:49 AM > > On Fri, Dec 15, 2023 at 12:01:19PM +0800, Yi Liu wrote: > > On 2023/12/15 11:32, Nicolin Chen wrote: > > > On Fri, Dec 15, 2023 at 03:04:44AM +, Tian, Kevin wrote: > > > > >

RE: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2023-12-14 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Friday, December 15, 2023 10:28 AM > > On Fri, Dec 15, 2023 at 01:50:07AM +, Tian, Kevin wrote: > > > From: Liu, Yi L > > > Sent: Thursday, December 14, 2023 7:27 PM > > > > > > On 2023/11/17 21:18, Yi Liu wrote:&

RE: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2023-12-14 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 14, 2023 7:27 PM > > On 2023/11/17 21:18, Yi Liu wrote:> This adds the data structure for > flushing iotlb for the nested domain > > +struct iommu_hwpt_vtd_s1_invalidate { > + __aligned_u64 addr; > + __aligned_u64 npages; > + __u32 flags;

RE: [PATCH v2 3/6] iommufd: Initializing and releasing IO page fault data

2023-12-12 Thread Tian, Kevin
> From: Baolu Lu > Sent: Wednesday, December 13, 2023 10:05 AM > > > >> 2. This is not intended to work only with idxd and uacce. right? > > It should work everywhere, I suspect Intel Team didn't hit this > > because they are testing IDXD SIOV? > > Yes. > > > Can you guys also test it as a PF >

RE: [PATCH 3/3] vfio: Report PASID capability via VFIO_DEVICE_FEATURE ioctl

2023-12-12 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, December 12, 2023 11:35 PM > > On Mon, Dec 11, 2023 at 11:49:49AM -0700, Alex Williamson wrote: > > On Mon, 11 Dec 2023 14:10:28 -0400 > > Jason Gunthorpe wrote: > > > > > On Mon, Dec 11, 2023 at 11:03:45AM -0700, Alex Williamson wrote: > > > > On Sun, 26

RE: [PATCH 3/3] vfio: Report PASID capability via VFIO_DEVICE_FEATURE ioctl

2023-12-12 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, December 12, 2023 11:32 PM > > On Tue, Dec 12, 2023 at 02:20:01AM +, Tian, Kevin wrote: > > > From: Liu, Yi L > > > Sent: Monday, December 11, 2023 4:08 PM > > > > > > On 2023/12/7 16:47, Tian, Kevi

RE: [PATCH 3/3] vfio: Report PASID capability via VFIO_DEVICE_FEATURE ioctl

2023-12-11 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Monday, December 11, 2023 4:08 PM > > On 2023/12/7 16:47, Tian, Kevin wrote: > >> From: Liu, Yi L > >> Sent: Monday, November 27, 2023 2:39 PM > >> > >> +static int vfio_pci_core_featu

RE: [PATCH 3/3] vfio: Report PASID capability via VFIO_DEVICE_FEATURE ioctl

2023-12-11 Thread Tian, Kevin
> From: Alex Williamson > Sent: Tuesday, December 12, 2023 2:04 AM > > On Sun, 26 Nov 2023 22:39:09 -0800 > Yi Liu wrote: > > > This reports the PASID capability data to userspace via > VFIO_DEVICE_FEATURE, > > hence userspace could probe PASID capability by it. This is a bit different > > with

RE: [PATCH v6 0/6] iommufd: Add nesting infrastructure (part 2/2)

2023-12-10 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Saturday, December 9, 2023 9:47 AM > > What is in a Nested domain: > Intel: A single IO page table refereed to by a PASID entry > Each vDomain-ID,PASID allocates a unique nesting domain > AMD: A GCR3 table pointer > Nesting domains are created for e

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-07 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 7, 2023 2:59 PM > > On 2023/11/17 21:07, Yi Liu wrote: > > @@ -613,4 +614,38 @@ struct iommu_hwpt_get_dirty_bitmap { > > #define IOMMU_HWPT_GET_DIRTY_BITMAP _IO(IOMMUFD_TYPE, \ > > > IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP) > > > > +/** > > + * struc

RE: [PATCH 3/3] vfio: Report PASID capability via VFIO_DEVICE_FEATURE ioctl

2023-12-07 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Monday, November 27, 2023 2:39 PM > > +static int vfio_pci_core_feature_pasid(struct vfio_device *device, u32 flags, > +struct vfio_device_feature_pasid __user > *arg, > +size_t argsz) > +{ > + s

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, December 1, 2023 3:05 PM > > On 2023/12/1 13:19, Tian, Kevin wrote: > >> From: Nicolin Chen > >> Sent: Friday, December 1, 2023 12:50 PM > >> > >> On Fri, Dec 01, 2023 at 11:51:26AM +0800, Yi Liu wrote:

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-30 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Friday, December 1, 2023 12:50 PM > > On Fri, Dec 01, 2023 at 11:51:26AM +0800, Yi Liu wrote: > > On 2023/11/29 08:57, Jason Gunthorpe wrote: > > > On Tue, Nov 28, 2023 at 04:51:21PM -0800, Nicolin Chen wrote: > > > > > > I also thought about making this out_driver_er

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-28 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Tuesday, November 28, 2023 3:53 AM > > On Fri, Nov 24, 2023 at 02:36:29AM +, Tian, Kevin wrote: > > > > > > > > >> + * @out_driver_error_code: Report a driver speicifc error code > > > upon > > > > &

RE: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2023-11-23 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, November 22, 2023 9:26 PM > > On Wed, Nov 22, 2023 at 04:58:24AM +, Tian, Kevin wrote: > > then we just define hwpt 'cache' invalidation in vtd always refers to > > both iotlb and devtlb. Then viommu just needs

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-23 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Tuesday, November 21, 2023 1:24 PM > > On Tue, Nov 21, 2023 at 02:50:05AM +, Tian, Kevin wrote: > > > From: Nicolin Chen > > > Sent: Tuesday, November 21, 2023 1:37 AM > > > > > > On Mon, Nov 20, 2023 at 08:34:58

RE: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2023-11-21 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, November 21, 2023 8:17 PM > > On Tue, Nov 21, 2023 at 02:54:15AM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Tuesday, November 21, 2023 7:05 AM > > > > > > On Mon, Nov 20, 2023 at 08:

RE: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2023-11-20 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, November 21, 2023 7:05 AM > > On Mon, Nov 20, 2023 at 08:26:31AM +, Tian, Kevin wrote: > > > From: Liu, Yi L > > > Sent: Friday, November 17, 2023 9:18 PM > > > > > > This adds the data st

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-20 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Tuesday, November 21, 2023 1:37 AM > > On Mon, Nov 20, 2023 at 08:34:58AM +, Tian, Kevin wrote: > > > From: Liu, Yi L > > > Sent: Monday, November 20, 2023 4:30 PM > > > > > > On 2023/11/20 16:09, Tian, Kevi

RE: [PATCH v6 3/6] iommu: Add iommu_copy_struct_from_user_array helper

2023-11-20 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Tuesday, November 21, 2023 1:25 AM > > On Mon, Nov 20, 2023 at 08:17:47AM +, Tian, Kevin wrote: > > > From: Liu, Yi L > > > Sent: Friday, November 17, 2023 9:07 PM > > > > > > +/** > > > + * __iommu

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-20 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Monday, November 20, 2023 4:30 PM > > On 2023/11/20 16:09, Tian, Kevin wrote: > >> From: Liu, Yi L > >> Sent: Friday, November 17, 2023 9:07 PM > >> + * @req_len: Length (in bytes) of a request entry in the request array >

RE: [PATCH v7 3/3] iommu/vt-d: Add iotlb flush for nested domain

2023-11-20 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, November 17, 2023 9:18 PM > + > + if (inv_info.__reserved || (inv_info.flags & > ~IOMMU_VTD_INV_FLAGS_LEAF) || > + !IS_ALIGNED(inv_info.addr, VTD_PAGE_SIZE)) { > + ret = -EINVAL; > + break; > +

RE: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2023-11-20 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, November 17, 2023 9:18 PM > > This adds the data structure for flushing iotlb for the nested domain > allocated with IOMMU_HWPT_DATA_VTD_S1 type. > > This only supports invalidating IOTLB, but no for device-TLB as device-TLB > invalidation will be covered automa

RE: [PATCH v6 3/6] iommu: Add iommu_copy_struct_from_user_array helper

2023-11-20 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, November 17, 2023 9:07 PM > > +/** > + * __iommu_copy_struct_from_user_array - Copy iommu driver specific __iommu_copy_entry_from_user_array?

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-20 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, November 17, 2023 9:07 PM > + > + hwpt = iommufd_hw_pagetable_get_nested(ucmd, cmd->hwpt_id); > + if (IS_ERR(hwpt)) > + return PTR_ERR(hwpt); > + > + rc = hwpt->domain->ops->cache_invalidate_user(hwpt->domain, > &data_array, > +

RE: [PATCH v6 1/6] iommu: Add cache_invalidate_user op

2023-11-19 Thread Tian, Kevin
> From: Yi Liu > Sent: Friday, November 17, 2023 9:07 PM > > +/** > + * struct iommu_user_data_array - iommu driver specific user space data > array > + * @type: The data type of all the entries in the user buffer array > + * @uptr: Pointer to the user buffer array for copy_from_user() remove "f

RE: [PATCH v2 0/6] IOMMUFD: Deliver IO page faults to user space

2023-11-08 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, November 8, 2023 1:54 AM > > On Tue, Nov 07, 2023 at 08:35:10AM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Thursday, November 2, 2023 8:48 PM > > > > > > On Thu, Oct 26, 2023 at 10

RE: [RFC 3/7] iommufd: Add iommufd_device_bind_pasid()

2023-11-08 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Wednesday, November 8, 2023 3:45 PM > > On 2023/10/10 16:19, Tian, Kevin wrote: > >> From: Liu, Yi L > >> Sent: Monday, October 9, 2023 4:51 PM > >> > >> +struct iommufd_device *iommufd_d

RE: [PATCH v2 0/6] IOMMUFD: Deliver IO page faults to user space

2023-11-07 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Thursday, November 2, 2023 8:48 PM > > On Thu, Oct 26, 2023 at 10:49:24AM +0800, Lu Baolu wrote: > > Hi folks, > > > > This series implements the functionality of delivering IO page faults to > > user space through the IOMMUFD framework for nested translation. > Nes

RE: [PATCH v8 7/8] iommu/vt-d: Add nested domain allocation

2023-10-25 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, October 26, 2023 12:42 PM > > From: Lu Baolu > > This adds the support for IOMMU_HWPT_DATA_VTD_S1 type. And > 'nested_parent' > is added to mark the nested parent domain to sanitize the input parent > domain. > > Signed-off-by: Lu Baolu > Signed-off-by: Yi

RE: [PATCH v7 8/8] iommu/vt-d: Disallow read-only mappings to nest parent domain

2023-10-25 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Tuesday, October 24, 2023 11:14 PM > > +/** > + * enum iommu_hw_info_vtd_flags - Flags for VT-d hw_info > + * @IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17: If set, disallow > nesting on domains > + * with read-only mapping. with how it's imple

RE: [PATCH] iommu/vt-d: Enhance capability check for nested parent domain allocation

2023-10-25 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Tuesday, October 24, 2023 11:00 PM > > This adds the scalable mode check before allocating the nested parent > domain > as checking nested capability is not enough. User may turn off scalable mode > which also means no nested support even if the hardware supports it. >

RE: [PATCH v7 7/8] iommu/vt-d: Add nested domain allocation

2023-10-25 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, October 25, 2023 7:03 AM > > @@ -4849,6 +4855,7 @@ static void *intel_iommu_hw_info(struct device > *dev, u32 *length, u32 *type) > if (!vtd) > return ERR_PTR(-ENOMEM); > > + vtd->flags = IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17; th

  1   2   >