Re: [PATCH v2 4/6] iommufd: Deliver fault messages to user space

From: Jason Gunthorpe
Date: Mon Jan 15 2024 - 12:59:09 EST


On Mon, Jan 15, 2024 at 05:44:13PM +0000, Shameerali Kolothum Thodi wrote:

> > If it is valid when userspace does read() then it should be valid when
> > userspace does write() too.
> >
> > It is the only way the kernel can actually match request and response
> > here.
>
> The kernel currently checks the pasid only if IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID
> is set.
>
> https://lore.kernel.org/linux-iommu/20200616144712.748818-1-jean-philippe@xxxxxxxxxx/
>
> > So, I think you have a userspace issue to not provide the right
> > pasid??
>
> This is not just ARM stall resume case, but for some PCI devices as well as per
> the above commit log. So do we really need to track this in userspace ?

Yes, these weird HW details should not leak into userspace.

The PASID is required on the read() side, userspace should provide it
on the write() side. It is trivial for it to do, there is no reason to
accommodate anything else.

Alternatively I'm wondering if we should supply a serial number to
userspace so it can match the request/response instead of relying on
guessing based on pasid/grpid?

Jason