RE: [PATCH v5 4/9] iommufd: Add fault and response message definitions

2024-05-19 Thread Tian, Kevin
> From: Baolu Lu > Sent: Monday, May 20, 2024 11:33 AM > > On 5/20/24 11:24 AM, Tian, Kevin wrote: > >> From: Baolu Lu > >> Sent: Sunday, May 19, 2024 10:38 PM > >> > >> On 2024/5/15 15:43, Tian, Kevin wrote: > From: Lu Baolu > Sent: Tuesday, April 30, 2024 10:57 PM > > + *

Re: [PATCH v5 7/9] iommufd: Associate fault object with iommufd_hw_pgtable

2024-05-19 Thread Baolu Lu
On 5/20/24 11:39 AM, Tian, Kevin wrote: From: Baolu Lu Sent: Monday, May 20, 2024 10:19 AM On 5/15/24 4:50 PM, Tian, Kevin wrote: From: Lu Baolu Sent: Tuesday, April 30, 2024 10:57 PM @@ -308,6 +314,19 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) goto out_put_pt;

Re: [PATCH v5 6/9] iommufd: Fault-capable hwpt attach/detach/replace

2024-05-19 Thread Baolu Lu
On 5/20/24 11:35 AM, Tian, Kevin wrote: From: Baolu Lu Sent: Monday, May 20, 2024 10:10 AM On 5/15/24 4:43 PM, Tian, Kevin wrote: From: Lu Baolu Sent: Tuesday, April 30, 2024 10:57 PM + +int iommufd_fault_domain_replace_dev(struct iommufd_device *idev, +str

RE: [PATCH v5 7/9] iommufd: Associate fault object with iommufd_hw_pgtable

2024-05-19 Thread Tian, Kevin
> From: Baolu Lu > Sent: Monday, May 20, 2024 10:19 AM > > On 5/15/24 4:50 PM, Tian, Kevin wrote: > >> From: Lu Baolu > >> Sent: Tuesday, April 30, 2024 10:57 PM > >> > >> @@ -308,6 +314,19 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd > >> *ucmd) > >>goto out_put_pt; > >>} > >>

RE: [PATCH v5 6/9] iommufd: Fault-capable hwpt attach/detach/replace

2024-05-19 Thread Tian, Kevin
> From: Baolu Lu > Sent: Monday, May 20, 2024 10:10 AM > > On 5/15/24 4:43 PM, Tian, Kevin wrote: > >> From: Lu Baolu > >> Sent: Tuesday, April 30, 2024 10:57 PM > >> + > >> +int iommufd_fault_domain_replace_dev(struct iommufd_device *idev, > >> + struct iommufd_hw_

Re: [PATCH v5 4/9] iommufd: Add fault and response message definitions

2024-05-19 Thread Baolu Lu
On 5/20/24 11:24 AM, Tian, Kevin wrote: From: Baolu Lu Sent: Sunday, May 19, 2024 10:38 PM On 2024/5/15 15:43, Tian, Kevin wrote: From: Lu Baolu Sent: Tuesday, April 30, 2024 10:57 PM iommu_hwpt_pgfaults represent fault messages that the userspace can retrieve. Multiple iommu_hwpt_pgfaults m

RE: [PATCH v5 5/9] iommufd: Add iommufd fault object

2024-05-19 Thread Tian, Kevin
> From: Baolu Lu > Sent: Monday, May 20, 2024 9:34 AM > > On 5/15/24 4:37 PM, Tian, Kevin wrote: > >> + > >> + iopf_group_response(group, response.code); > > PCIe spec states that a response failure disables the PRI interface. For SR- > IOV > > it'd be dangerous allowing user to trigger

Re: [PATCH v5 5/9] iommufd: Add iommufd fault object

2024-05-19 Thread Baolu Lu
On 5/20/24 11:26 AM, Tian, Kevin wrote: From: Baolu Lu Sent: Monday, May 20, 2024 8:41 AM On 5/15/24 3:57 PM, Tian, Kevin wrote: From: Baolu Lu Sent: Wednesday, May 8, 2024 6:05 PM On 2024/5/8 8:11, Jason Gunthorpe wrote: On Tue, Apr 30, 2024 at 10:57:06PM +0800, Lu Baolu wrote: diff --git

RE: [PATCH v5 5/9] iommufd: Add iommufd fault object

2024-05-19 Thread Tian, Kevin
> From: Baolu Lu > Sent: Monday, May 20, 2024 8:41 AM > > On 5/15/24 3:57 PM, Tian, Kevin wrote: > >> From: Baolu Lu > >> Sent: Wednesday, May 8, 2024 6:05 PM > >> > >> On 2024/5/8 8:11, Jason Gunthorpe wrote: > >>> On Tue, Apr 30, 2024 at 10:57:06PM +0800, Lu Baolu wrote: > diff --git a/dr

RE: [PATCH v5 4/9] iommufd: Add fault and response message definitions

2024-05-19 Thread Tian, Kevin
> From: Baolu Lu > Sent: Sunday, May 19, 2024 10:38 PM > > On 2024/5/15 15:43, Tian, Kevin wrote: > >> From: Lu Baolu > >> Sent: Tuesday, April 30, 2024 10:57 PM > >> > >> iommu_hwpt_pgfaults represent fault messages that the userspace can > >> retrieve. Multiple iommu_hwpt_pgfaults might be put

RE: [PATCH v5 3/9] iommu: Add attachment handle to struct iopf_group

2024-05-19 Thread Tian, Kevin
> From: Baolu Lu > Sent: Sunday, May 19, 2024 10:04 PM > > On 2024/5/15 15:31, Tian, Kevin wrote: > >> From: Lu Baolu > >> Sent: Tuesday, April 30, 2024 10:57 PM > >> > >> + handle = iommu_attach_handle_get(dev->iommu_group, pasid, 0); > >> + if (IS_ERR(handle)) > >> + return PTR_ERR(

RE: [PATCH v5 2/9] iommu: Replace sva_iommu with iommu_attach_handle

2024-05-19 Thread Tian, Kevin
> From: Baolu Lu > Sent: Sunday, May 19, 2024 6:14 PM > > On 5/15/24 3:21 PM, Tian, Kevin wrote: > >> From: Lu Baolu > >> Sent: Tuesday, April 30, 2024 10:57 PM > >> > >> #else > >> -static inline struct iommu_sva * > >> +static inline struct iommu_attach_handle * > >> iommu_sva_bind_device(

Re: [PATCH v5 7/9] iommufd: Associate fault object with iommufd_hw_pgtable

2024-05-19 Thread Baolu Lu
On 5/15/24 4:50 PM, Tian, Kevin wrote: From: Lu Baolu Sent: Tuesday, April 30, 2024 10:57 PM @@ -227,7 +233,7 @@ iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx, refcount_inc(&parent->common.obj.users); hwpt_nested->parent = parent; - hwpt->domain = ops->domain_alloc_u

Re: [PATCH v5 6/9] iommufd: Fault-capable hwpt attach/detach/replace

2024-05-19 Thread Baolu Lu
On 5/15/24 4:43 PM, Tian, Kevin wrote: From: Lu Baolu Sent: Tuesday, April 30, 2024 10:57 PM + +int iommufd_fault_domain_replace_dev(struct iommufd_device *idev, +struct iommufd_hw_pagetable *hwpt, +struct iommufd_hw_pagetab

Re: [PATCH v5 5/9] iommufd: Add iommufd fault object

2024-05-19 Thread Baolu Lu
On 5/15/24 4:37 PM, Tian, Kevin wrote: + iopf_free_group(group); + done += response_size; + + iommufd_put_object(fault->ictx, &idev->obj); get/put is unpaired: if (!idev || idev->obj.id != response.dev_id) idev =

Re: [PATCH v5 5/9] iommufd: Add iommufd fault object

2024-05-19 Thread Baolu Lu
On 5/15/24 4:37 PM, Tian, Kevin wrote: + + iopf_group_response(group, response.code); PCIe spec states that a response failure disables the PRI interface. For SR-IOV it'd be dangerous allowing user to trigger such code to VF to close the entire shared PRI interface. Just another e

Re: [PATCH v5 5/9] iommufd: Add iommufd fault object

2024-05-19 Thread Baolu Lu
On 5/15/24 4:37 PM, Tian, Kevin wrote: +static ssize_t iommufd_fault_fops_write(struct file *filep, const char __user *buf, + size_t count, loff_t *ppos) +{ + size_t response_size = sizeof(struct iommu_hwpt_page_response); + struct iommufd_fault *

Re: [PATCH v5 5/9] iommufd: Add iommufd fault object

2024-05-19 Thread Baolu Lu
On 5/15/24 4:37 PM, Tian, Kevin wrote: @@ -395,6 +396,8 @@ struct iommufd_device { /* always the physical device */ struct device *dev; bool enforce_cache_coherency; + /* outstanding faults awaiting response indexed by fault group id */ + struct xarray faults;

Re: [PATCH v5 5/9] iommufd: Add iommufd fault object

2024-05-19 Thread Baolu Lu
On 5/15/24 3:57 PM, Tian, Kevin wrote: From: Baolu Lu Sent: Wednesday, May 8, 2024 6:05 PM On 2024/5/8 8:11, Jason Gunthorpe wrote: On Tue, Apr 30, 2024 at 10:57:06PM +0800, Lu Baolu wrote: diff --git a/drivers/iommu/iommu-priv.h b/drivers/iommu/iommu-priv.h index ae65e0b85d69..1a0450a83bd0 1

Re: [PATCH v5 4/9] iommufd: Add fault and response message definitions

2024-05-19 Thread Baolu Lu
On 2024/5/15 15:43, Tian, Kevin wrote: From: Lu Baolu Sent: Tuesday, April 30, 2024 10:57 PM iommu_hwpt_pgfaults represent fault messages that the userspace can retrieve. Multiple iommu_hwpt_pgfaults might be put in an iopf group, with the IOMMU_PGFAULT_FLAGS_LAST_PAGE flag set only for the las

Re: [PATCH v5 3/9] iommu: Add attachment handle to struct iopf_group

2024-05-19 Thread Baolu Lu
On 2024/5/15 15:31, Tian, Kevin wrote: From: Lu Baolu Sent: Tuesday, April 30, 2024 10:57 PM Previously, the domain that a page fault targets is stored in an iopf_group, which represents a minimal set of page faults. With the introduction of attachment handle, replace the domain with the handle

Re: [PATCH v5 2/9] iommu: Replace sva_iommu with iommu_attach_handle

2024-05-19 Thread Baolu Lu
On 5/15/24 3:21 PM, Tian, Kevin wrote: From: Lu Baolu Sent: Tuesday, April 30, 2024 10:57 PM #else -static inline struct iommu_sva * +static inline struct iommu_attach_handle * iommu_sva_bind_device(struct device *dev, struct mm_struct *mm) { - return NULL; + return ERR_PTR(-E

Re: [PATCH v5 1/9] iommu: Introduce domain attachment handle

2024-05-19 Thread Baolu Lu
On 5/15/24 3:17 PM, Tian, Kevin wrote: From: Lu Baolu Sent: Tuesday, April 30, 2024 10:57 PM +/* Add an attach handle to the group's pasid array. */ +static struct iommu_attach_handle * +iommu_attach_handle_set(struct iommu_domain *domain, + struct iommu_group *group, ioas