Re: [PATCH v6 06/25] iommufd/access: Allow access->ops to be NULL for internal use

From: Baolu Lu
Date: Mon Jun 16 2025 - 02:26:44 EST


On 6/14/25 15:14, Nicolin Chen wrote:
The access object has been used externally by VFIO mdev devices, allowing
them to pin/unpin physical pages (via needs_pin_pages). Meanwhile, a racy
unmap can occur in this case, so these devices usually implement an unmap
handler, invoked by iommufd_access_notify_unmap().

The new HW queue object will need the same pin/unpin feature, although it
(unlike the mdev case) wants to reject any unmap attempt, during its life
cycle.

To reuse the access object for the new HW queue, allow its access->ops to
be NULL. Error out a NULL access->ops in iommufd_access_notify_unmap() to
reject an unmap operation and propagatethe errno upwards.

Then, update iommufd_access_change_ioas() and iommufd_access_pin_pages(),
to allow this new use case.

Suggested-by: Jason Gunthorpe<jgg@xxxxxxxxxx>
Signed-off-by: Nicolin Chen<nicolinc@xxxxxxxxxx>

Reviewed-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>