[PATCH v5 14/29] iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl

Nicolin Chen nicolinc at nvidia.com
Fri May 23 17:30:39 PDT 2025


On Fri, May 23, 2025 at 08:00:02AM +0000, Tian, Kevin wrote:
> > From: Nicolin Chen <nicolinc at nvidia.com>
> > Sent: Sunday, May 18, 2025 11:22 AM
> > 
> > + * @nesting_parent_iova: Base address of the queue memory in the guest
> > physical
> > + *                       address space
> 
> 'nesting_parent' is a bit redundant. 'iova' should be sufficient as it
> implies a s2 input address.

Hmm, Jason suggested to highlight "nesting_parent":
https://lore.kernel.org/all/20250515160620.GJ382960@nvidia.com/

> 
> > + * @length: Length of the queue memory
> > + *
> > + * Allocate a HW queue object for a vIOMMU-specific HW-accelerated
> > queue, which
> > + * allows HW to access a guest queue memory described using
> > @nesting_parent_iova
> > + * and @length.
> > + *
> > + * Upon success, the underlying physical pages of the guest queue memory
> > will be
> > + * pinned to prevent VMM from unmapping them in the IOAS until the HW
> > queue gets
> > + * destroyed.
> 
> This is conditional.

Yea, forgot to delete that.

> 
> > +void iommufd_hw_queue_destroy(struct iommufd_object *obj)
> > +{
> > +	struct iommufd_hw_queue *hw_queue =
> > +		container_of(obj, struct iommufd_hw_queue, obj);
> > +	struct iommufd_viommu *viommu = hw_queue->viommu;
> > +
> > +	if (viommu->ops->hw_queue_destroy)
> > +		viommu->ops->hw_queue_destroy(hw_queue);
> > +	iopt_unpin_pages(&viommu->hwpt->ioas->iopt, hw_queue-
> > >base_addr,
> > +			 hw_queue->length, true);
> 
> Check the flag

Oh, right! Will fix.

> > +
> > +		/* Validate if the underlying physical pages are contiguous */
> > +		for (i = 1; i < max_npages && pages[i]; i++) {
> 
> Page[i] must be valid otherwise it's a bug?

Yea, I think so. We can drop this pages[i].

Thanks!
Nicolin



More information about the linux-arm-kernel mailing list