lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <DS0PR11MB7529C791D2B89E1DED570C5EC3D8A@DS0PR11MB7529.namprd11.prod.outlook.com>
Date:   Mon, 23 Oct 2023 11:11:53 +0000
From:   "Liu, Yi L" <yi.l.liu@...el.com>
To:     Baolu Lu <baolu.lu@...ux.intel.com>,
        "joro@...tes.org" <joro@...tes.org>,
        "alex.williamson@...hat.com" <alex.williamson@...hat.com>,
        "jgg@...dia.com" <jgg@...dia.com>,
        "Tian, Kevin" <kevin.tian@...el.com>,
        "robin.murphy@....com" <robin.murphy@....com>
CC:     "cohuck@...hat.com" <cohuck@...hat.com>,
        "eric.auger@...hat.com" <eric.auger@...hat.com>,
        "nicolinc@...dia.com" <nicolinc@...dia.com>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "mjrosato@...ux.ibm.com" <mjrosato@...ux.ibm.com>,
        "chao.p.peng@...ux.intel.com" <chao.p.peng@...ux.intel.com>,
        "yi.y.sun@...ux.intel.com" <yi.y.sun@...ux.intel.com>,
        "peterx@...hat.com" <peterx@...hat.com>,
        "jasowang@...hat.com" <jasowang@...hat.com>,
        "shameerali.kolothum.thodi@...wei.com" 
        <shameerali.kolothum.thodi@...wei.com>,
        "lulu@...hat.com" <lulu@...hat.com>,
        "suravee.suthikulpanit@....com" <suravee.suthikulpanit@....com>,
        "iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
        "Duan, Zhenzhong" <zhenzhong.duan@...el.com>,
        "Martins, Joao" <joao.m.martins@...cle.com>,
        "Zeng, Xin" <xin.zeng@...el.com>
Subject: RE: [PATCH v6 7/8] iommu/vt-d: Add nested domain allocation

> From: Baolu Lu <baolu.lu@...ux.intel.com>
> Sent: Saturday, October 21, 2023 11:08 AM
> 
> On 10/20/23 5:32 PM, Yi Liu wrote:
> > From: Lu Baolu <baolu.lu@...ux.intel.com>
> >
> > This adds the support for IOMMU_HWPT_DATA_VTD_S1 type.
> >
> > Signed-off-by: Lu Baolu <baolu.lu@...ux.intel.com>
> > Signed-off-by: Yi Liu <yi.l.liu@...el.com>
> > ---
> >   drivers/iommu/intel/iommu.c | 39 ++++++++++++++++++++++++++-----------
> >   1 file changed, 28 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> > index b47025fbdea4..c7704e7efd4a 100644
> > --- a/drivers/iommu/intel/iommu.c
> > +++ b/drivers/iommu/intel/iommu.c
> > @@ -4076,7 +4076,7 @@ intel_iommu_domain_alloc_user(struct device *dev, u32
> flags,
> >   			      struct iommu_domain *parent,
> >   			      const struct iommu_user_data *user_data)
> >   {
> > -	struct iommu_domain *domain;
> > +	bool request_nest_parent = flags & IOMMU_HWPT_ALLOC_NEST_PARENT;
> >   	struct intel_iommu *iommu;
> >
> >   	if (flags & (~IOMMU_HWPT_ALLOC_NEST_PARENT))
> > @@ -4086,18 +4086,35 @@ intel_iommu_domain_alloc_user(struct device *dev, u32
> flags,
> >   	if (!iommu)
> >   		return ERR_PTR(-ENODEV);
> >
> > -	if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !ecap_nest(iommu-
> >ecap))
> > +	if (!user_data) { /* Must be PAGING domain */
> > +		struct iommu_domain *domain;
> > +
> > +		if (request_nest_parent && !ecap_nest(iommu->ecap))
> 
> Hardware capability is not sufficient. How about adding below helper:

Yes. But the sm_supported() seems a bit confusing. Is it? actually, it's
a combined check of the sm capability and software choice (use sm or
not). How about renaming it to be sm_enabled()? Although the best
enable status check is to read the SM bit in root address register. No hurry
in this circle, but may be nice to have.

> diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h
> index b5f33a7c1973..b04bbabcd696 100644
> --- a/drivers/iommu/intel/iommu.h
> +++ b/drivers/iommu/intel/iommu.h
> @@ -540,6 +540,8 @@ enum {
>   #define sm_supported(iommu)    (intel_iommu_sm &&
> ecap_smts((iommu)->ecap))
>   #define pasid_supported(iommu) (sm_supported(iommu) &&                 \
>                                   ecap_pasid((iommu)->ecap))
> +#define nested_supported(iommu)        (sm_supported(iommu) &&
>         \
> +                                ecap_nest((iommu)->ecap))
> 
>   struct pasid_entry;
>   struct pasid_state_entry;
> 
> And, use nested_supported() here and bleow
> 
> > +			return ERR_PTR(-EOPNOTSUPP);
> > +		if (parent)
> > +			return ERR_PTR(-EINVAL);
> > +		/*
> > +		 * domain_alloc_user op needs to fully initialize a domain
> > +		 * before return, so uses iommu_domain_alloc() here for
> > +		 * simple.
> > +		 */
> > +		domain = iommu_domain_alloc(dev->bus);
> > +		if (!domain)
> > +			return ERR_PTR(-ENOMEM);
> > +		return domain;
> > +	}
> > +
> > +	/* Must be nested domain */
> > +	if (!ecap_nest(iommu->ecap))
> 
> ...here.
> 
> > +		return ERR_PTR(-EOPNOTSUPP);
> > +	if (user_data->type != IOMMU_HWPT_DATA_VTD_S1)
> >   		return ERR_PTR(-EOPNOTSUPP);
> > +	if (!parent || parent->ops != intel_iommu_ops.default_domain_ops)
> > +		return ERR_PTR(-EINVAL);
> > +	if (request_nest_parent)
> > +		return ERR_PTR(-EINVAL);
> >
> > -	/*
> > -	 * domain_alloc_user op needs to fully initialize a domain
> > -	 * before return, so uses iommu_domain_alloc() here for
> > -	 * simple.
> > -	 */
> > -	domain = iommu_domain_alloc(dev->bus);
> > -	if (!domain)
> > -		domain = ERR_PTR(-ENOMEM);
> > -	return domain;
> > +	return intel_nested_domain_alloc(parent, user_data);
> >   }
> >
> >   static void intel_iommu_domain_free(struct iommu_domain *domain)
> 
> Best regards,
> baolu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ