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]
Date:   Wed, 24 May 2023 05:11:43 +0000
From:   "Tian, Kevin" <kevin.tian@...el.com>
To:     Nicolin Chen <nicolinc@...dia.com>
CC:     "Liu, Yi L" <yi.l.liu@...el.com>,
        "joro@...tes.org" <joro@...tes.org>,
        "alex.williamson@...hat.com" <alex.williamson@...hat.com>,
        "jgg@...dia.com" <jgg@...dia.com>,
        "robin.murphy@....com" <robin.murphy@....com>,
        "baolu.lu@...ux.intel.com" <baolu.lu@...ux.intel.com>,
        "cohuck@...hat.com" <cohuck@...hat.com>,
        "eric.auger@...hat.com" <eric.auger@...hat.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>
Subject: RE: [PATCH v2 04/11] iommufd: Pass parent hwpt and user_data to
 iommufd_hw_pagetable_alloc()

> From: Nicolin Chen <nicolinc@...dia.com>
> Sent: Saturday, May 20, 2023 3:09 AM
> 
> On Fri, May 19, 2023 at 09:06:20AM +0000, Tian, Kevin wrote:
> 
> > > @@ -73,14 +77,22 @@ int iommufd_hw_pagetable_enforce_cc(struct
> > > iommufd_hw_pagetable *hwpt)
> > >   */
> > >  struct iommufd_hw_pagetable *
> > >  iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct
> > > iommufd_ioas *ioas,
> > > -                        struct iommufd_device *idev, bool
> > > immediate_attach)
> > > +                        struct iommufd_device *idev,
> > > +                        struct iommufd_hw_pagetable *parent,
> > > +                        union iommu_domain_user_data *user_data,
> > > +                        bool immediate_attach)
> > >  {
> > >       const struct iommu_ops *ops = dev_iommu_ops(idev->dev);
> > > +     struct iommu_domain *parent_domain = NULL;
> > >       struct iommufd_hw_pagetable *hwpt;
> > > +     bool type_unmanaged, type_nested;
> > >       int rc;
> > >
> > >       lockdep_assert_held(&ioas->mutex);
> > >
> > > +     if ((user_data || parent) && !ops->domain_alloc_user)
> > > +             return ERR_PTR(-EOPNOTSUPP);
> >
> > Do we allow specifying parent w/o user_data?
> 
> I don't think so. Perhaps we should do a double check:
> 
> +	if (!!user_data ^ !!parent)
> +		return ERR_PTR(-EINVAL);

I think we allow creating a s2 hwpt with user_data so it
should be:

	if (parent && !user_data)
		return ERR_PTR(-INVAL);

> > > @@ -99,6 +117,15 @@ iommufd_hw_pagetable_alloc(struct
> iommufd_ctx
> > > *ictx, struct iommufd_ioas *ioas,
> > >               goto out_abort;
> > >       }
> > >
> > > +     /* It must be either NESTED or UNMANAGED, depending on
> > > parent_domain */
> > > +       type_nested = hwpt->domain->type == IOMMU_DOMAIN_NESTED;
> > > +       type_unmanaged = hwpt->domain->type ==
> > > IOMMU_DOMAIN_UNMANAGED;
> >
> > no need of one-time used variables. Just put the conditions directly
> > in WARN_ON.
> 
> It is to improve the readability. Otherwise, we'd have:
> 
> 	if (WARN_ON((parent_domain &&
> 		     hwpt->domain->type != IOMMU_DOMAIN_NESTED) ||
> 		    (!parent_domain &&
> 		     hwpt->domain->type !=
> IOMMU_DOMAIN_UNMANAGED)))

IMHO this is already very clear w/o defining additional variables. 😊

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ