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:   Tue, 15 Mar 2022 15:36:20 -0700
From:   Jacob Pan <jacob.jun.pan@...ux.intel.com>
To:     Jason Gunthorpe <jgg@...dia.com>
Cc:     iommu@...ts.linux-foundation.org,
        LKML <linux-kernel@...r.kernel.org>,
        Joerg Roedel <joro@...tes.org>,
        Christoph Hellwig <hch@...radead.org>,
        Lu Baolu <baolu.lu@...ux.intel.com>,
        Jean-Philippe Brucker <jean-philippe@...aro.com>,
        Jacob Pan <jacob.jun.pan@...el.com>,
        Raj Ashok <ashok.raj@...el.com>,
        "Kumar, Sanjay K" <sanjay.k.kumar@...el.com>,
        Dave Jiang <dave.jiang@...el.com>,
        Tony Luck <tony.luck@...el.com>,
        "Zanussi, Tom" <tom.zanussi@...el.com>,
        Dan Williams <dan.j.williams@...el.com>,
        "Tian, Kevin" <kevin.tian@...el.com>, Yi Liu <yi.l.liu@...el.com>,
        jacob.jun.pan@...ux.intel.com
Subject: Re: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach
 ops

Hi Jason,

On Tue, 15 Mar 2022 11:33:22 -0300, Jason Gunthorpe <jgg@...dia.com> wrote:

> On Mon, Mar 14, 2022 at 10:07:07PM -0700, Jacob Pan wrote:
> > +	/*
> > +	 * Each domain could have multiple devices attached with
> > shared or per
> > +	 * device PASIDs. At the domain level, we keep track of unique
> > PASIDs and
> > +	 * device user count.
> > +	 * E.g. If a domain has two devices attached, device A has
> > PASID 0, 1;
> > +	 * device B has PASID 0, 2. Then the domain would have PASID
> > 0, 1, 2.
> > +	 */  
> 
> A 2d array of xarray's seems like a poor data structure for this task.
> 
> AFACIT this wants to store a list of (device, pasid) tuples, so a
> simple linked list, 1d xarray vector or a red black tree seems more
> appropriate..
> 
Agreed.
It might need some surgery for dmar_domain and device_domain_info, which
already has a simple device list. I am trying to leverage the existing data
struct, let me take a closer look.

> > +	if (entry) {
> > +		pinfo = entry;
> > +	} else {
> > +		pinfo = kzalloc(sizeof(*pinfo), GFP_ATOMIC);
> > +		if (!pinfo)
> > +			return -ENOMEM;
> > +		pinfo->pasid = pasid;
> > +		/* Store the new PASID info in the per domain array */
> > +		ret = xa_err(__xa_store(&dmar_domain->pasids, pasid,
> > pinfo,
> > +			     GFP_ATOMIC));
> > +		if (ret)
> > +			goto xa_store_err;
> > +	}
> > +	/* Store PASID in per device-domain array, this is for
> > tracking devTLB */
> > +	ret = xa_err(xa_store(&info->pasids, pasid, pinfo,
> > GFP_ATOMIC));
> > +	if (ret)
> > +		goto xa_store_err;
> > +
> > +	atomic_inc(&pinfo->users);
> > +	xa_unlock(&dmar_domain->pasids);
> > +
> > +	return 0;
> > +
> > +xa_store_err:
> > +	xa_unlock(&dmar_domain->pasids);
> > +	spin_lock_irqsave(&iommu->lock, flags);
> > +	intel_pasid_tear_down_entry(iommu, dev, pasid, false);
> > +	spin_unlock_irqrestore(&iommu->lock, flags);
> > +
> > +	if (!atomic_read(&pinfo->users)) {
> > +		__xa_erase(&dmar_domain->pasids, pasid);  
> 
> This isn't locked right
> 
good catch! need to move under xa_unlock.

Thanks,

Jacob

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ