Re: [PATCH 6/6] iommu/vt-d: Add domain_alloc_user op

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

 



On Wed, Sep 20, 2023 at 01:10:04PM +0000, Liu, Yi L wrote:
> > From: Jason Gunthorpe <jgg@xxxxxxxxxx>
> > Sent: Wednesday, September 20, 2023 9:05 PM
> > 
> > On Wed, Sep 20, 2023 at 01:28:41PM +0800, Baolu Lu wrote:
> > > >
> > > > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> > > > index 5db283c17e0d..491bcde1ff96 100644
> > > > --- a/drivers/iommu/intel/iommu.c
> > > > +++ b/drivers/iommu/intel/iommu.c
> > > > @@ -4074,6 +4074,25 @@ static struct iommu_domain
> > *intel_iommu_domain_alloc(unsigned type)
> > > >   	return NULL;
> > > >   }
> > > > +static struct iommu_domain *
> > > > +intel_iommu_domain_alloc_user(struct device *dev, u32 flags)
> > > > +{
> > > > +	struct iommu_domain *domain;
> > > > +	struct intel_iommu *iommu;
> > > > +
> > > > +	iommu = device_to_iommu(dev, NULL, NULL);
> > > > +	if (!iommu)
> > > > +		return ERR_PTR(-ENODEV);
> > > > +
> > > > +	if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !ecap_nest(iommu-
> > >ecap))
> > > > +		return ERR_PTR(-EOPNOTSUPP);
> > 
> > There is a check missing for supported flags
> > 
> >  if (flags & (~IOMMU_HWPT_ALLOC_NEST_PARENT))
> > 	return ERR_PTR(-EOPNOTSUPP);
> 
> Well, the iommufd has such check. But I also noticed your another
> reply to Weijiang. So your preference is to do the flags validation
> in iommu driver instead of iommufd. Isn't it?

The core code should check that only kernel known bits are set

The driver code should check that only driver supported bits are set.

Today there is only one bit so the checks are the same code.

Tomorrow when we add a new bit the checks will not be the same

Jason



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux