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

2024-09-12 Thread Yi Liu
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 PASID capability to userspace. Signed-off-by: Yi Liu --- drivers/iommu

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

2024-09-12 Thread Yi Liu
This adds ioctls for the userspace to attach/detach a given pasid of a vfio device to/from an IOAS/HWPT. Reviewed-by: Jason Gunthorpe Signed-off-by: Yi Liu --- drivers/vfio/device_cdev.c | 51 +++ drivers/vfio/vfio.h| 4 +++ drivers/vfio/vfio_main.c

[PATCH v3 2/4] vfio-iommufd: Support pasid [at|de]tach for physical VFIO devices

2024-09-12 Thread Yi Liu
This adds pasid_at|de]tach_ioas ops for attaching hwpt to pasid of a device and the helpers for it. For now, only vfio-pci supports pasid attach/detach. Signed-off-by: Kevin Tian Signed-off-by: Yi Liu --- drivers/vfio/iommufd.c | 50 + drivers/vfio/pci

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

2024-09-12 Thread Yi Liu
, pasid); } Cc: Matthew Wilcox (Oracle) Suggested-by: Jason Gunthorpe Signed-off-by: Yi Liu --- include/linux/idr.h | 11 lib/idr.c | 67 + 2 files changed, 78 insertions(+) diff --git a/include/linux/idr.h b/include/linux/idr.

[PATCH v3 0/4] vfio-pci support pasid attach/detach

2024-09-12 Thread Yi Liu
6093121.18676-1-yi.l@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/i

[PATCH v4 10/10] iommufd/selftest: Add coverage for iommufd pasid attach/detach

2024-09-12 Thread Yi Liu
This tests iommufd pasid attach/replace/detach. Signed-off-by: Yi Liu --- tools/testing/selftests/iommu/iommufd.c | 256 ++ .../selftests/iommu/iommufd_fail_nth.c| 29 +- tools/testing/selftests/iommu/iommufd_utils.h | 78 ++ 3 files changed, 359 insertions

[PATCH v4 09/10] iommufd/selftest: Add test ops to test pasid attach/detach

2024-09-12 Thread Yi Liu
This adds 4 test ops for pasid attach/replace/detach testing. There are ops to attach/detach pasid, and also op to check the attached domain of a pasid. Signed-off-by: Yi Liu --- drivers/iommu/iommufd/iommufd_test.h | 30 ++ drivers/iommu/iommufd/selftest.c | 138

[PATCH v4 08/10] iommufd/selftest: Add a helper to get test device

2024-09-12 Thread Yi Liu
There is need to get the selftest device (sobj->type == TYPE_IDEV) in multiple places, so have a helper to for it. Signed-off-by: Yi Liu --- drivers/iommu/iommufd/selftest.c | 32 +--- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/io

[PATCH v4 07/10] iommufd/selftest: Add set_dev_pasid and remove_dev_pasid in mock iommu

2024-09-12 Thread Yi Liu
The two callbacks are needed to make pasid_attach/detach path complete for mock device. A nop is enough for set_dev_pasid, a domain type check in the remove_dev_pasid is also helpful. Signed-off-by: Yi Liu --- drivers/iommu/iommufd/selftest.c | 38 1 file

[PATCH v4 05/10] iommufd: Pass pasid through the device attach/replace path

2024-09-12 Thread Yi Liu
. Signed-off-by: Kevin Tian Signed-off-by: Yi Liu --- drivers/iommu/iommufd/device.c | 44 --- drivers/iommu/iommufd/fault.c | 14 +--- drivers/iommu/iommufd/hw_pagetable.c| 5 +-- drivers/iommu/iommufd/iommufd_private.h | 47 - 4

[PATCH v4 06/10] iommufd: Support pasid attach/replace

2024-09-12 Thread Yi Liu
ff-by: Yi Liu --- drivers/iommu/iommufd/Makefile | 1 + drivers/iommu/iommufd/device.c | 12 +- drivers/iommu/iommufd/fault.c | 6 +- drivers/iommu/iommufd/iommufd_private.h | 40 -- drivers/iommu/iommufd/pasid.c | 157 in

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

2024-09-12 Thread Yi Liu
major user of the RID attach/replace with iommu_attach_handle, this also makes the iommufd always pass the attach handle for the RID path as well. This keeps the RID and PASID path much aligned. Signed-off-by: Yi Liu --- drivers/iommu/iommufd/fault.c | 21 +++-- drivers

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

2024-09-12 Thread Yi Liu
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 Signed-off-by: Yi Liu --- drivers/iommu/iommufd/fault.c | 61 + drivers/iommu/iommufd/iommufd_private.h

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

2024-09-12 Thread Yi Liu
There is a wrapper of iommu_attach_group_handle(), so making a wrapper for iommu_replace_group_handle() for further code refactor. No functional change intended. Signed-off-by: Yi Liu --- drivers/iommu/iommufd/fault.c | 54 --- 1 file changed, 31 insertions

[PATCH v4 00/10] iommufd support pasid attach/replace

2024-09-12 Thread Yi Liu
092651.17041-1-yi.l@intel.com/ Regards, Yi Liu Yi Liu (10): iommu: Introduce a replace API for device pasid iommufd: Refactor __fault_domain_replace_dev() to be a wrapper of iommu_replace_group_handle() iommufd: Move the iommufd_handle helpers to iommufd_private.h iommufd:

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

2024-09-12 Thread Yi Liu
Provide a high-level API to allow replacements of one domain with another for specific pasid of a device. This is similar to iommu_group_replace_domain() and it is expected to be used only by IOMMUFD. Co-developed-by: Lu Baolu Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu

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

2024-09-12 Thread Yi Liu
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 --- drivers/iommu/intel/iommu.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/iommu

[PATCH 0/3] Support attaching PASID to the blocked_domain

2024-09-12 Thread Yi Liu
remove_dev_pasid() op. [1] https://lore.kernel.org/linux-iommu/20240816130202.gb2032...@nvidia.com/ [2] https://lore.kernel.org/linux-iommu/20240912130427.10119-1-yi.l@intel.com/ Regards, Yi Liu Jason Gunthorpe (1): iommu/arm-smmu-v3: Make smmuv3 blocked domain support PASID Yi Liu (2

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

2024-09-12 Thread Yi Liu
IOMMU core needs to support both ways to destroy the attachment of device/PASID and domain. Signed-off-by: Yi Liu --- drivers/iommu/iommu.c | 30 -- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index

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

2024-09-12 Thread Yi Liu
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 Gunthorpe Signed-off-by: Yi Liu --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

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

2024-09-12 Thread Yi Liu
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 --- drivers/iommu/intel/iommu.c | 22 +- drivers/iommu/intel/iommu.h | 3 +++ drivers/iommu

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

2024-09-12 Thread Yi Liu
old config if the input @old is non-NULL. Suggested-by: Jason Gunthorpe Signed-off-by: Yi Liu --- drivers/iommu/amd/pasid.c | 3 +++ include/linux/iommu.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/amd/pasid.c b/drivers/iommu/amd/pasid.c index

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

2024-09-12 Thread Yi Liu
set_dev_pasid op is going to support domain replacement and keep the old hardware config if it fails. Make the Intel iommu driver be prepared for it. Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 98 - 1 file changed, 65 insertions(+), 33 deletions

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

2024-09-12 Thread Yi Liu
, this would duplicate code among the iommu drivers. Or iommu drivers would rely group->pasid_array to get domain, which may not always the correct one. Suggested-by: Jason Gunthorpe Signed-off-by: Yi Liu --- drivers/iommu/amd/amd_iommu.h | 3 ++- drivers/iommu/amd/pasi

[PATCH v2 0/6] Make set_dev_pasid op supporting domain replacement

2024-09-12 Thread Yi Liu
/ Regards, Yi Liu Jason Gunthorpe (1): iommu/arm-smmu-v3: Make smmuv3 set_dev_pasid() op support replace Lu Baolu (1): iommu/vt-d: Add set_dev_pasid callback for nested domain Yi Liu (4): iommu: Pass old domain to set_dev_pasid op iommu/vt-d: Move intel_drain_pasid_prq() into

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

2024-09-12 Thread Yi Liu
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 --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 2 +- drivers/iommu/arm/arm-smmu-v3/arm

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

2024-09-12 Thread Yi Liu
Draining PRQ is mostly conjuncted with pasid teardown, and with more callers coming, move it into it in the intel_pasid_tear_down_entry(). But there is scenario that only teardown pasid entry but no PRQ drain, so passing a flag to mark it. Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c

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

2024-09-05 Thread Yi Liu
On 2024/9/6 12:33, Baolu Lu wrote: On 9/6/24 12:21 PM, Yi Liu wrote: On 2024/8/16 21:02, Jason Gunthorpe wrote: On Fri, Aug 16, 2024 at 05:43:18PM +0800, Yi Liu wrote: On 2024/7/18 16:27, Tian, Kevin wrote: From: Liu, Yi L Sent: Friday, June 28, 2024 5:06 PM @@ -3289,7 +3290,20 @@ static

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

2024-09-05 Thread Yi Liu
On 2024/8/16 21:02, Jason Gunthorpe wrote: On Fri, Aug 16, 2024 at 05:43:18PM +0800, Yi Liu wrote: On 2024/7/18 16:27, Tian, Kevin wrote: 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

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

2024-08-16 Thread Yi Liu
llow Jason's suggestion to iommu_group_replace_domain () in Baolu's series, i.e. doing a xa_reserve() first. yeah, I noticed it. But there is a minor difference. In Baolu's series no need to retrieve the old domain, but this path needs to get it and pass it to set_dev_pasid(). -- Regards, Yi Liu

[PATCH v3 7/7] iommufd/selftest: Add coverage for iommufd pasid attach/detach

2024-06-28 Thread Yi Liu
This tests iommufd pasid attach/replace/detach. Signed-off-by: Yi Liu --- tools/testing/selftests/iommu/iommufd.c | 207 ++ .../selftests/iommu/iommufd_fail_nth.c| 28 ++- tools/testing/selftests/iommu/iommufd_utils.h | 78 +++ 3 files changed, 309 insertions

[PATCH v3 6/7] iommufd/selftest: Add test ops to test pasid attach/detach

2024-06-28 Thread Yi Liu
This adds 4 test ops for pasid attach/replace/detach testing. There are ops to attach/detach pasid, and also op to check the attached domain of a pasid. Signed-off-by: Yi Liu --- drivers/iommu/iommufd/iommufd_test.h | 30 ++ drivers/iommu/iommufd/selftest.c | 135

[PATCH v3 5/7] iommufd/selftest: Add a helper to get test device

2024-06-28 Thread Yi Liu
There is need to get the selftest device (sobj->type == TYPE_IDEV) in multiple places, so have a helper to for it. Signed-off-by: Yi Liu --- drivers/iommu/iommufd/selftest.c | 32 +--- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/io

[PATCH v3 3/7] iommufd: Support attach/replace hwpt per pasid

2024-06-28 Thread Yi Liu
nt is still applied to pasid operations since it is about memory accesses post page table walking (no matter the walk is per RID or per PASID). Since the attach is per PASID, this introduces a pasid_hwpts xarray to track the per-pasid attach data. Signed-off-by: Kevin Tian Signed-off-by: Y

[PATCH v3 4/7] iommufd/selftest: Add set_dev_pasid and remove_dev_pasid in mock iommu

2024-06-28 Thread Yi Liu
The two callbacks are needed to make pasid_attach/detach path complete for mock device. A nop is enough for set_dev_pasid, a domain type check in the remove_dev_pasid is also helpful. Signed-off-by: Yi Liu --- drivers/iommu/iommufd/selftest.c | 39 1 file

[PATCH v3 2/7] iommufd: Pass pasid through the device attach/replace path

2024-06-28 Thread Yi Liu
Most of the core logic before conducting the actual device attach/ replace operation can be shared with pasid attach/replace. So pass pasid through the device attach/replace helpers to prepare adding pasid attach/replace. Signed-off-by: Kevin Tian Signed-off-by: Yi Liu --- drivers/iommu

[PATCH v3 0/7] iommufd support pasid attach/replace

2024-06-28 Thread Yi Liu
ressponding attach_fn per the pasid value. rfc: https://lore.kernel.org/linux-iommu/20230926092651.17041-1-yi.l@intel.com/ Regards, Yi Liu Yi Liu (7): iommu: Introduce a replace API for device pasid iommufd: Pass pasid through the device attach/replace path iommufd: Suppor

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

2024-06-28 Thread Yi Liu
Provide a high-level API to allow replacements of one domain with another for specific pasid of a device. This is similar to iommu_group_replace_domain() and it is expected to be used only by IOMMUFD. Co-developed-by: Lu Baolu Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu

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

2024-03-21 Thread Yi Liu
On 2024/3/21 20:20, Jason Gunthorpe wrote: On Thu, Mar 21, 2024 at 07:26:41PM +0800, Yi Liu wrote: yes, the correct way is to undo what have been done before the fail device. However, I somehow remember that pasid capability is only available when the group is singleton. So iterate all devices

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

2024-03-21 Thread Yi Liu
On 2024/3/21 14:16, Yi Liu wrote: On 2024/3/20 20:38, Jason Gunthorpe wrote: On Tue, Mar 19, 2024 at 03:29:39PM +0800, Yi Liu wrote: On 2024/3/19 00:52, Jason Gunthorpe wrote: On Wed, Mar 13, 2024 at 04:11:41PM +0800, Yi Liu wrote: yes. how about your opinion? @Jason. I noticed the

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

2024-03-20 Thread Yi Liu
On 2024/3/20 20:38, Jason Gunthorpe wrote: On Tue, Mar 19, 2024 at 03:29:39PM +0800, Yi Liu wrote: On 2024/3/19 00:52, Jason Gunthorpe wrote: On Wed, Mar 13, 2024 at 04:11:41PM +0800, Yi Liu wrote: yes. how about your opinion? @Jason. I noticed the set_dev_pasid callback and pasid_array

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

2024-03-19 Thread Yi Liu
On 2024/3/19 00:52, Jason Gunthorpe wrote: On Wed, Mar 13, 2024 at 04:11:41PM +0800, Yi Liu wrote: yes. how about your opinion? @Jason. I noticed the set_dev_pasid callback and pasid_array update is under the group->lock, so update it should be fine to adjust the order to update pasid_ar

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

2024-03-13 Thread Yi Liu
On 2024/3/13 11:13, Baolu Lu wrote: On 2024/3/12 11:07, Yi Liu wrote: On 2024/3/11 17:26, Tian, Kevin wrote: 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

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

2024-03-11 Thread Yi Liu
On 2024/3/11 17:26, Tian, Kevin wrote: 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

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

2024-03-10 Thread Yi Liu
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) +{ + struct iommu_group *group = dev->iommu_gr

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

2024-02-22 Thread Yi Liu
On 2024/2/21 23:19, Jason Gunthorpe wrote: On Thu, Feb 08, 2024 at 12:23:02AM -0800, Yi Liu wrote: If a domain is used as the parent in nested translation its mappings might be cached using DID of the nested domain. But the existing code ignores this fact to only invalidate the iotlb entries

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

2024-02-08 Thread Yi Liu
oks even w/o nesting this is missed in the attach path. could be fixed separately. so for this one: it's fixed here. https://lore.kernel.org/linux-iommu/20240208091414.28133-1-yi.l@intel.com/ Reviewed-by: Kevin Tian -- Regards, Yi Liu

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

2024-02-08 Thread Yi Liu
->s2_domain; + + spin_lock(&s2_domain->s1_lock); + list_del(&dmar_domain->s2_link); + spin_unlock(&s2_domain->s1_lock); kfree(to_dmar_domain(domain)); use 'dmar_domain'. Oops. yes it is. Reviewed-by: Kevin Tian -- Regards, Yi Liu

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

2024-02-08 Thread Yi Liu
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 has already enabled dirty tracking. Fixes: 111bf85c68f6 ("iommu/vt-d: Add helper to setup pasid nested translation") Signed-off-by: Yi Liu --- b

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

2024-02-08 Thread Yi Liu
Fixes: b41e38e22539 ("iommu/vt-d: Add nested domain allocation") Signed-off-by: Yi Sun Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 36 1 file changed, 36 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c ind

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

2024-02-08 Thread Yi Liu
Add device_set_dirty_tracking() to loop all the devices and set the dirty tracking per the @enable parameter. Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 32 +--- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/iommu/intel/iommu.c

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

2024-02-08 Thread Yi Liu
use the DID of nested domain. Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 7 +++ drivers/iommu/intel/pasid.c | 3 +-- drivers/iommu/intel/pasid.h | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index

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

2024-02-08 Thread Yi Liu
x27;s s1_domains list and loops the devices list of each s1_domain to flush the entire device iotlb on the devices. Fixes: b41e38e22539 ("iommu/vt-d: Add nested domain allocation") Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 18 ++ 1 file changed, 18 insertions(+

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

2024-02-08 Thread Yi Liu
ned-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 4 +--- drivers/iommu/intel/iommu.h | 1 + drivers/iommu/intel/nested.c | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 46174ff5ae22..b1ceebe13107 100644 ---

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

2024-02-08 Thread Yi Liu
tries related to the target s2 address range. According to VT-d spec there is no need for software to explicitly flush the affected s1 cache. It's implicitly done by HW when s2 cache is invalidated. Fixes: b41e38e22539 ("iommu/vt-d: Add nested domain allocation") Signed-off-by: Yi Liu

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

2024-02-08 Thread Yi Liu
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. Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 79

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

2024-02-08 Thread Yi Liu
ed devices and iommus. Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 18 ++ drivers/iommu/intel/iommu.h | 6 ++ drivers/iommu/intel/nested.c | 10 ++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/i

[PATCH rc 0/8] Add missing cache flush and dirty tracking set for nested parent domain

2024-02-08 Thread Yi Liu
34cd2c8a8e3 Regards, Yi Liu Yi Liu (8): iommu/vt-d: Track nested domains in parent iommu/vt-d: Add __iommu_flush_iotlb_psi() iommu/vt-d: Add missing iotlb flush for parent domain iommu/vt-d: Update iotlb in nested domain attach iommu/vt-d: Add missing device iotlb flush for parent

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

2024-01-19 Thread Yi Liu
On 2024/1/18 21:38, Jason Gunthorpe wrote: On Thu, Jan 18, 2024 at 05:28:01PM +0800, Yi Liu wrote: On 2024/1/17 20:56, Jason Gunthorpe wrote: On Wed, Jan 17, 2024 at 04:24:24PM +0800, Yi Liu wrote: Above indeed makes more sense if there can be concurrent attach/replace/detach on a single

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

2024-01-18 Thread Yi Liu
On 2024/1/17 20:56, Jason Gunthorpe wrote: On Wed, Jan 17, 2024 at 04:24:24PM +0800, Yi Liu wrote: Above indeed makes more sense if there can be concurrent attach/replace/detach on a single pasid. Just have one doubt should we add lock to protect the whole attach/replace/detach paths. In the

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

2024-01-17 Thread Yi Liu
On 2024/1/17 12:17, Tian, Kevin wrote: 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, Nov 26, 2023 at 10:34:23PM -0800, Yi Liu wrote

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

2024-01-15 Thread Yi Liu
On 2023/12/12 23:35, Jason Gunthorpe wrote: 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 Nov 2023 22:39:09 -0800 Yi Liu wrote

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

2024-01-15 Thread Yi Liu
off where stuff in PCI config space needs explicit hypervisor support or it doesn't work in the VM and things get confusing. Jason -- Regards, Yi Liu

[PATCH v11 8/8] iommu/vt-d: Add iotlb flush for nested domain

2024-01-10 Thread Yi Liu
From: Lu Baolu This implements the .cache_invalidate_user() callback to support iotlb flush for nested domain. Reviewed-by: Kevin Tian Signed-off-by: Lu Baolu Co-developed-by: Yi Liu Signed-off-by: Yi Liu --- drivers/iommu/intel/nested.c | 88 1 file

[PATCH v11 6/8] iommufd/selftest: Add coverage for IOMMU_HWPT_INVALIDATE ioctl

2024-01-10 Thread Yi Liu
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. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Co-developed-by: Yi Liu Signed-off-by: Yi Liu --- tools/testing/selftests/iommu/iommufd.c | 148

[PATCH v11 7/8] iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

2024-01-10 Thread Yi Liu
This adds the data structure invalidating caches for the nested domain allocated with IOMMU_HWPT_DATA_VTD_S1 type. Reviewed-by: Kevin Tian Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- include/uapi/linux/iommufd.h | 36 1 file changed, 36 insertions

[PATCH v11 5/8] iommufd/selftest: Add IOMMU_TEST_OP_MD_CHECK_IOTLB test op

2024-01-10 Thread Yi Liu
From: Nicolin Chen Allow to test whether IOTLB has been invalidated or not. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Signed-off-by: Yi Liu --- drivers/iommu/iommufd/iommufd_test.h | 5 drivers/iommu/iommufd/selftest.c | 26 +++ tools

[PATCH v11 4/8] iommufd/selftest: Add mock_domain_cache_invalidate_user support

2024-01-10 Thread Yi Liu
From: Nicolin Chen Add mock_domain_cache_invalidate_user() data structure to support user space selftest program to cover user cache invalidation pathway. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Co-developed-by: Yi Liu Signed-off-by: Yi Liu --- drivers/iommu/iommufd

[PATCH v11 3/8] iommu: Add iommu_copy_struct_from_user_array helper

2024-01-10 Thread Yi Liu
Signed-off-by: Nicolin Chen Co-developed-by: Yi Liu Signed-off-by: Yi Liu --- include/linux/iommu.h | 53 +++ 1 file changed, 53 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 93c0d12dd047..580ba74a3d5d 100644 --- a/include

[PATCH v11 2/8] iommufd: Add IOMMU_HWPT_INVALIDATE

2024-01-10 Thread Yi Liu
Chen Signed-off-by: Yi Liu --- drivers/iommu/iommufd/hw_pagetable.c| 41 +++ drivers/iommu/iommufd/iommufd_private.h | 10 ++ drivers/iommu/iommufd/main.c| 3 ++ include/uapi/linux/iommufd.h| 43 + 4 files changed, 97

[PATCH v11 1/8] iommu: Add cache_invalidate_user op

2024-01-10 Thread Yi Liu
mmufd. Then, pass in invalidation requests in form of a user data array containing a number of invalidation data entries. Reviewed-by: Kevin Tian Signed-off-by: Lu Baolu Signed-off-by: Nicolin Chen Signed-off-by: Yi Liu --- include/linux/iommu.h | 26 ++ 1 file change

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

2024-01-10 Thread Yi Liu
data length for user domain allocation - Rename struct iommu_hwpt_alloc::data_type to be hwpt_type - Store the invalidation data length in iommu_domain_ops::cache_invalidate_user_data_len - Convert cache_invalidate_user op to be int instead of void - Remove @data_type in struct iommu_hwpt_invalidate -

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

2024-01-08 Thread Yi Liu
reported. from this angle whether to record pasid doesn't really matter. intel-iommu driver doesn't batch commands. so it's possible for the driver to figure out the timeout device itself and identify rid plus pasid to find dev_id from iommufd. based on this, even RID is unnecessary. Software should know which device it has sent a devTLB invalidation. -- Regards, Yi Liu

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

2024-01-02 Thread Yi Liu
On 2024/1/3 07:38, Jason Gunthorpe wrote: On Fri, Dec 15, 2023 at 12:01:19PM +0800, Yi Liu wrote: I think I misread Yi's narrative: dev_id is a working approach for VMM to convert to a vRID, while he is asking for a better alternative :) In concept, dev_id works, but in reality we

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

2024-01-02 Thread Yi Liu
On 2024/1/3 02:44, Jason Gunthorpe wrote: On Tue, Jan 02, 2024 at 06:38:34AM -0800, Yi Liu wrote: +static void intel_nested_flush_cache(struct dmar_domain *domain, u64 addr, +unsigned long npages, bool ih, u32 *error) +{ + struct iommu_domain_info

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

2024-01-02 Thread Yi Liu
From: Lu Baolu This implements the .cache_invalidate_user() callback to support iotlb flush for nested domain. Reviewed-by: Kevin Tian Signed-off-by: Lu Baolu Co-developed-by: Yi Liu Signed-off-by: Yi Liu --- drivers/iommu/intel/nested.c | 107 +++ 1 file

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

2024-01-02 Thread Yi Liu
This adds the data structure invalidating caches for the nested domain allocated with IOMMU_HWPT_DATA_VTD_S1 type. Reviewed-by: Kevin Tian Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- include/uapi/linux/iommufd.h | 58 1 file changed, 58 insertions

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

2024-01-02 Thread Yi Liu
user. Reviewed-by: Kevin Tian Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu/intel/dmar.c | 13 +++-- drivers/iommu/intel/iommu.c | 12 ++-- drivers/iommu/intel/iommu.h | 6 +++--- drivers/iommu/intel/pasid.c | 12 +++- drivers/iommu/intel/svm.c | 8

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

2024-01-02 Thread Yi Liu
newly added user domain cache invalidation by checking if the caller is interested in the fault or not. [1] https://lore.kernel.org/all/20231228001646.587653-6-haifeng.z...@linux.intel.com/ Reviewed-by: Kevin Tian Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu/intel/dmar.c

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

2024-01-02 Thread Yi Liu
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. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Co-developed-by: Yi Liu Signed-off-by: Yi Liu --- tools/testing/selftests/iommu/iommufd.c | 186

[PATCH v10 05/10] iommufd/selftest: Add IOMMU_TEST_OP_MD_CHECK_IOTLB test op

2024-01-02 Thread Yi Liu
From: Nicolin Chen Allow to test whether IOTLB has been invalidated or not. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Signed-off-by: Yi Liu --- drivers/iommu/iommufd/iommufd_test.h | 5 drivers/iommu/iommufd/selftest.c | 26 +++ tools

[PATCH v10 04/10] iommufd/selftest: Add mock_domain_cache_invalidate_user support

2024-01-02 Thread Yi Liu
From: Nicolin Chen Add mock_domain_cache_invalidate_user() data structure to support user space selftest program to cover user cache invalidation pathway. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Co-developed-by: Yi Liu Signed-off-by: Yi Liu --- drivers/iommu/iommufd

[PATCH v10 03/10] iommu: Add iommu_copy_struct_from_user_array helper

2024-01-02 Thread Yi Liu
iommu_user_data_array. And expect it to be used in cache_invalidate_user ops for example. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Co-developed-by: Yi Liu Signed-off-by: Yi Liu --- include/linux/iommu.h | 74 +++ 1 file changed, 74 insertions

[PATCH v10 02/10] iommufd: Add IOMMU_HWPT_INVALIDATE

2024-01-02 Thread Yi Liu
Chen Signed-off-by: Yi Liu --- drivers/iommu/iommufd/hw_pagetable.c| 41 +++ drivers/iommu/iommufd/iommufd_private.h | 10 ++ drivers/iommu/iommufd/main.c| 3 ++ include/uapi/linux/iommufd.h| 43 + 4 files changed, 97

[PATCH v10 01/10] iommu: Add cache_invalidate_user op

2024-01-02 Thread Yi Liu
mmufd. Then, pass in invalidation requests in form of a user data array conatining a number of invalidation data entries. Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Signed-off-by: Yi Liu --- include/linux/iommu.h | 26 ++ 1 file change

[PATCH v10 00/10] Add iommufd nesting (part 2/2)

2024-01-02 Thread Yi Liu
main_ops::cache_invalidate_user_data_len - Convert cache_invalidate_user op to be int instead of void - Remove @data_type in struct iommu_hwpt_invalidate - Remove out_hwpt_type_bitmap in struct iommu_hw_info hence drop patch 08 of v1 v1: https://lore.kernel.org/linux-iommu/20230309080910.607396

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

2023-12-29 Thread Yi Liu
n may have a chance to look in his holiday and if ok whether he wants to see a new version or just change it while committing. anyhow, I've updated it in below branch. https://github.com/yiliu1765/iommufd/tree/iommufd_nesting -- Regards, Yi Liu

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

2023-12-28 Thread Yi Liu
return -EAGAIN' the simpler form is: /* No need to retry if the caller is interested in the timeout error */ if (qi->desc_status[wait_index] == QI_ABORT) return fsts ? -ETIMEDOUT : -EAGAIN; otherwise, Reviewed-by: Kevin Tian sure. -- Regards, Yi Liu

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

2023-12-28 Thread Yi Liu
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 --- drivers/iommu/intel/nested.c | 107 +++ 1 file changed, 107 insertions

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

2023-12-28 Thread Yi Liu
This adds the data structure invalidating caches for the nested domain allocated with IOMMU_HWPT_DATA_VTD_S1 type. Reviewed-by: Kevin Tian Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- include/uapi/linux/iommufd.h | 58 1 file changed, 58 insertions

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

2023-12-28 Thread Yi Liu
user. Reviewed-by: Kevin Tian Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu/intel/dmar.c | 13 +++-- drivers/iommu/intel/iommu.c | 12 ++-- drivers/iommu/intel/iommu.h | 6 +++--- drivers/iommu/intel/pasid.c | 12 +++- drivers/iommu/intel/svm.c | 8

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

2023-12-28 Thread Yi Liu
From: Lu Baolu This allows qi_submit_sync() to return back faults to callers. Signed-off-by: Lu Baolu Signed-off-by: Yi Liu --- drivers/iommu/intel/dmar.c | 42 - drivers/iommu/intel/iommu.h | 2 +- drivers/iommu/intel/irq_remapping.c | 2

[PATCH v9 05/10] iommufd/selftest: Add IOMMU_TEST_OP_MD_CHECK_IOTLB test op

2023-12-28 Thread Yi Liu
From: Nicolin Chen Allow to test whether IOTLB has been invalidated or not. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Signed-off-by: Yi Liu --- drivers/iommu/iommufd/iommufd_test.h | 5 drivers/iommu/iommufd/selftest.c | 26 +++ tools

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

2023-12-28 Thread Yi Liu
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. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Co-developed-by: Yi Liu Signed-off-by: Yi Liu --- tools/testing/selftests/iommu/iommufd.c | 186

[PATCH v9 04/10] iommufd/selftest: Add mock_domain_cache_invalidate_user support

2023-12-28 Thread Yi Liu
From: Nicolin Chen Add mock_domain_cache_invalidate_user() data structure to support user space selftest program to cover user cache invalidation pathway. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Co-developed-by: Yi Liu Signed-off-by: Yi Liu --- drivers/iommu/iommufd

[PATCH v9 03/10] iommu: Add iommu_copy_struct_from_user_array helper

2023-12-28 Thread Yi Liu
iommu_user_data_array. And expect it to be used in cache_invalidate_user ops for example. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Co-developed-by: Yi Liu Signed-off-by: Yi Liu --- include/linux/iommu.h | 74 +++ 1 file changed, 74 insertions

[PATCH v9 02/10] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-28 Thread Yi Liu
Chen Signed-off-by: Yi Liu --- drivers/iommu/iommufd/hw_pagetable.c| 41 +++ drivers/iommu/iommufd/iommufd_private.h | 10 ++ drivers/iommu/iommufd/main.c| 3 ++ include/uapi/linux/iommufd.h| 43 + 4 files changed, 97

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

2023-12-28 Thread Yi Liu
user data length for user domain allocation - Rename struct iommu_hwpt_alloc::data_type to be hwpt_type - Store the invalidation data length in iommu_domain_ops::cache_invalidate_user_data_len - Convert cache_invalidate_user op to be int instead of void - Remove @data_type in struct iommu_hwpt_inval

[PATCH v9 01/10] iommu: Add cache_invalidate_user op

2023-12-28 Thread Yi Liu
mmufd. Then, pass in invalidation requests in form of a user data array conatining a number of invalidation data entries. Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Signed-off-by: Yi Liu --- include/linux/iommu.h | 26 ++ 1 file change

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

2023-12-28 Thread Yi Liu
7;s caused only by driver internal bug. +*/ here lack of: *error = 0; yes. + if (fault & DMA_FSTS_ICE) + *error |= IOMMU_HWPT_INVALIDATE_VTD_S1_ICE; + if (fault & DMA_FSTS_ITE) + *error |= IOMMU_HWPT_INVALIDATE_VTD_S1_ITE; +} + -- Regards, Yi Liu

  1   2   3   4   >