Re: [PATCH 5/6] iommu: init pasid array while doing domain_replace and iopf is active

From: Baolu Lu
Date: Thu Sep 12 2024 - 00:21:53 EST


On 9/11/24 5:55 PM, Joel Granados wrote:
On Thu, Sep 05, 2024 at 11:30:05AM +0800, Baolu Lu wrote:
On 9/4/24 9:17 PM, Joel Granados via B4 Relay wrote:
From: Joel Granados<j.granados@xxxxxxxxxxx>

iommu_report_device_fault expects a pasid array to have an
iommu_attach_handle when a fault is detected.
The iommu_attach_handle is expected only when an iopf-capable domain is
attached to the device or PASID. The iommu_report_device_fault() treats
it as a fault when a fault occurs, but no iopf-capable domain is
attached.
I don't follow. The way that I read it: if the pasid_array x-array does
not have an iommu_attach_handle indexed by either fault->prm.pasid or
IOMMU_NO_PASID, it will follow the err_bad_iopf and return -EINVAL
(please correct me if I'm wrong). So the iommu_attach_handle is*always*
expected.

Would it be more clear for it to be:
"""
The iommu_report_device_fault function expects the pasid_array x-array
to have an iommu_attach_handle indexed by a PASID. Add one indexed with
IOMMU_NO_PASID when the replacing HWPT has a valid iommufd fault object.
Remove it when we release ownership of the group.

Can you please explain why iommu core needs to remove the attach handle
when the ownership of the group is changed?

Thanks,
baolu