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

2024-05-24 Thread Jason Gunthorpe
On Mon, May 20, 2024 at 09:24:09AM +0800, Baolu Lu wrote: > 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 resp

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 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 5/9] iommufd: Add iommufd fault object

2024-05-15 Thread Tian, Kevin
> From: Lu Baolu > Sent: Tuesday, April 30, 2024 10:57 PM > > @@ -131,6 +131,9 @@ struct iopf_group { > struct iommu_attach_handle *attach_handle; > /* The device's fault data parameter. */ > struct iommu_fault_param *fault_param; > + /* Used by handler provider to hook the

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

2024-05-15 Thread Tian, Kevin
> 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 100644 > >> --- a/driv

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

2024-05-10 Thread Baolu Lu
On 2024/5/8 8:22, Jason Gunthorpe wrote: On Tue, Apr 30, 2024 at 10:57:06PM +0800, Lu Baolu wrote: +static ssize_t iommufd_fault_fops_read(struct file *filep, char __user *buf, + size_t count, loff_t *ppos) +{ + size_t fault_size = sizeof(struct iommu_h

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

2024-05-08 Thread Baolu Lu
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 100644 --- a/drivers/iommu/iommu-priv.h +++ b/drivers/iommu/iommu-priv.h @@ -36,6 +36,10 @@ str

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

2024-05-07 Thread Jason Gunthorpe
On Tue, Apr 30, 2024 at 10:57:06PM +0800, Lu Baolu wrote: > +static ssize_t iommufd_fault_fops_read(struct file *filep, char __user *buf, > +size_t count, loff_t *ppos) > +{ > + size_t fault_size = sizeof(struct iommu_hwpt_pgfault); > + struct iommufd_fau

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

2024-05-07 Thread Jason Gunthorpe
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 100644 > --- a/drivers/iommu/iommu-priv.h > +++ b/drivers/iommu/iommu-priv.h > @@ -36,6 +36,10 @@ struct iommu_attach_handle { >