[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 10 Feb 2023 20:15:49 -0400
From: Jason Gunthorpe <jgg@...dia.com>
To: Alex Williamson <alex.williamson@...hat.com>
Cc: Yi Liu <yi.l.liu@...el.com>, joro@...tes.org, kevin.tian@...el.com,
robin.murphy@....com, cohuck@...hat.com, eric.auger@...hat.com,
nicolinc@...dia.com, kvm@...r.kernel.org, mjrosato@...ux.ibm.com,
chao.p.peng@...ux.intel.com, yi.y.sun@...ux.intel.com,
peterx@...hat.com, jasowang@...hat.com,
shameerali.kolothum.thodi@...wei.com, lulu@...hat.com,
suravee.suthikulpanit@....com, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
baolu.lu@...ux.intel.com
Subject: Re: [PATCH 2/6] iommu/vt-d: Implement hw_info for iommu capability
query
On Fri, Feb 10, 2023 at 03:44:10PM -0700, Alex Williamson wrote:
> On Wed, 8 Feb 2023 20:16:38 -0800
> Yi Liu <yi.l.liu@...el.com> wrote:
>
> > From: Lu Baolu <baolu.lu@...ux.intel.com>
> >
> > To support nested translation in the userspace, it should check the
> > underlying hardware information for the capabilities.
> >
> > Add intel_iommu_hw_info() to report cap_reg and ecap_reg information.
> >
> > Signed-off-by: Lu Baolu <baolu.lu@...ux.intel.com>
> > Signed-off-by: Yi Liu <yi.l.liu@...el.com>
> > Signed-off-by: Nicolin Chen <nicolinc@...dia.com>
> > Signed-off-by: Yi Sun <yi.y.sun@...ux.intel.com>
> > ---
> > drivers/iommu/intel/iommu.c | 19 +++++++++++++++++++
> > drivers/iommu/intel/iommu.h | 1 +
> > include/uapi/linux/iommufd.h | 21 +++++++++++++++++++++
> > 3 files changed, 41 insertions(+)
> >
> > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> > index 59df7e42fd53..929f600cc350 100644
> > --- a/drivers/iommu/intel/iommu.c
> > +++ b/drivers/iommu/intel/iommu.c
> > @@ -4760,8 +4760,26 @@ static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid)
> > intel_pasid_tear_down_entry(iommu, dev, pasid, false);
> > }
> >
> > +static void *intel_iommu_hw_info(struct device *dev, u32 *length)
> > +{
> > + struct device_domain_info *info = dev_iommu_priv_get(dev);
> > + struct intel_iommu *iommu = info->iommu;
> > + struct iommu_device_info_vtd *vtd;
> > +
> > + vtd = kzalloc(sizeof(*vtd), GFP_KERNEL);
> > + if (!vtd)
> > + return ERR_PTR(-ENOMEM);
> > +
> > + vtd->cap_reg = iommu->cap;
> > + vtd->ecap_reg = iommu->ecap;
>
> Just a friendly reminder that these registers are already exposed to
> userspace under /sys/class/iommu/ and each device has an iommu link
> back to their iommu device there.
I think in cases of mdevs w/ PASID (eg SIOV) it is not general to get
from vfio sysfs to the sysfs path for the iommu.
> This series doesn't really stand on its own without some discussion
> of why that interface is not sufficient for this use case.
IMHO I don't really like the idea of mixing iommufd with sysfs, it
should stand on its own.
In particular there is no generic way to go from a iommufd dev_id to
any sysfs path, userspace would need prior unique knowledge about the
subsystem that is being bound to iommufd first.
So, I think some of those explanations would be good in the commit
message?
I would also add explanation about what userspace is supposed to do
with these bits when it operates the nesting feature.
Jason
Powered by blists - more mailing lists