Re: [PATCH v6 06/14] iommufd/viommu: Add iommufd_viommu_get_vdev_id helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 19, 2025 at 09:17:18PM -0800, Nicolin Chen wrote:
> On Tue, Feb 18, 2025 at 11:31:54AM -0400, Jason Gunthorpe wrote:
> > On Fri, Jan 24, 2025 at 04:30:35PM -0800, Nicolin Chen wrote:
> > > This is a reverse search v.s. iommufd_viommu_find_dev, as drivers may want
> > > to convert a struct device pointer (physical) to its virtual device ID for
> > > an event injection to the user space VM.
> > > 
> > > Again, this avoids exposing more core structures to the drivers, than the
> > > iommufd_viommu alone.
> > > 
> > > Reviewed-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
> > > Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
> > > Signed-off-by: Nicolin Chen <nicolinc@xxxxxxxxxx>
> > > ---
> > >  include/linux/iommufd.h        |  9 +++++++++
> > >  drivers/iommu/iommufd/driver.c | 24 ++++++++++++++++++++++++
> > >  2 files changed, 33 insertions(+)
> > 
> > Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> > 
> > > +	xa_lock(&viommu->vdevs);
> > > +	xa_for_each(&viommu->vdevs, index, vdev) {
> > > +		if (vdev->dev == dev) {
> > > +			*vdev_id = (unsigned long)vdev->id;
> > 
> > I don't think we need this cast
> 
> The left side is ulong for xarray index, while the right side is
> __aligned_u64 for uAPI. Could there be a gcc warning when somebody
> builds the kernel having a BITS_PER_LONG=32?

No. The kernel is full of these implicit casts

Jason




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux