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:   Thu, 14 May 2020 08:57:45 -0700
From:   Jacob Pan <jacob.jun.pan@...ux.intel.com>
To:     Christoph Hellwig <hch@...radead.org>
Cc:     Lu Baolu <baolu.lu@...ux.intel.com>,
        iommu@...ts.linux-foundation.org,
        LKML <linux-kernel@...r.kernel.org>,
        Joerg Roedel <joro@...tes.org>,
        David Woodhouse <dwmw2@...radead.org>,
        Jean-Philippe Brucker <jean-philippe@...aro.com>,
        Eric Auger <eric.auger@...hat.com>,
        Yi Liu <yi.l.liu@...el.com>,
        "Tian, Kevin" <kevin.tian@...el.com>,
        Raj Ashok <ashok.raj@...el.com>,
        Alex Williamson <alex.williamson@...hat.com>,
        Jonathan Cameron <jic23@...nel.org>,
        jacob.jun.pan@...ux.intel.com
Subject: Re: [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support

Hi Christoph,

Thanks a lot for the reviews, comments below.

Jacob

On Wed, 13 May 2020 22:59:30 -0700
Christoph Hellwig <hch@...radead.org> wrote:

> > +	if (dev_is_pci(dev)) {
> > +		/* VT-d supports devices with full 20 bit PASIDs
> > only */
> > +		if (pci_max_pasids(to_pci_dev(dev)) != PASID_MAX)
> > +			return -EINVAL;
> > +	} else {
> > +		return -ENOTSUPP;
> > +	}  
> 
> This looks strange.  Why not:
> 
> 	if (!dev_is_pci(dev)) {
> 		return -ENOTSUPP;
> 
> 	/* VT-d supports devices with full 20 bit PASIDs only */
> 	if (pci_max_pasids(to_pci_dev(dev)) != PASID_MAX)
> 		return -EINVAL;
> 
That is better, will do.

> > +		for_each_svm_dev(sdev, svm, dev) {
> > +			/*
> > +			 * For devices with aux domains, we should
> > allow multiple
> > +			 * bind calls with the same PASID and pdev.
> > +			 */
> > +			if (iommu_dev_feature_enabled(dev,
> > IOMMU_DEV_FEAT_AUX)) {
> > +				sdev->users++;
> > +			} else {
> > +				dev_warn_ratelimited(dev, "Already
> > bound with PASID %u\n",
> > +						svm->pasid);
> > +				ret = -EBUSY;
> > +			}
> > +			goto out;  
> 
> Is this intentionally a for loop that jumps out of the loop after
> the first device?
> 
The name is confusing, it is not a loop. I will change it to
find_svm_dev() and comments like this?

/*
 * Find the matching device in a given SVM. The bind code ensures that
 * each device can only be added to the SVM list once.
 */ 
#define find_svm_dev(sdev, svm, d)			\
	list_for_each_entry((sdev), &(svm)->devs, list)	\
		if ((d) != (sdev)->dev) {} else

> > +	/*
> > +	 * PASID table is per device for better security.
> > Therefore, for
> > +	 * each bind of a new device even with an existing PASID,
> > we need to
> > +	 * call the nested mode setup function here.
> > +	 */
> > +	spin_lock(&iommu->lock);
> > +	ret = intel_pasid_setup_nested(iommu,
> > +				       dev,
> > +				       (pgd_t *)data->gpgd,
> > +				       data->hpasid,
> > +				       &data->vtd,
> > +				       dmar_domain,
> > +				       data->addr_width);  
> 
> Why not:
> 
> 	et = intel_pasid_setup_nested(iommu, dev, (pgd_t *)data->gpgd,
> 			data->hpasid, &data->vtd, dmar_domain,
> 			data->addr_width);
> 
> ?
> 
I thought we want to align the parentheses? Either way is fine.
Baolu?

> > +	for_each_svm_dev(sdev, svm, dev) {
> > +		ret = 0;  
> 
> 		...
> 
> > +		break;
> > +	}  
> 
> Same only looks at the first device style.  Why dos it only care about
> the first device?  That needs at least a comment, and probably a
> first_svm_dev or so heper to make it explicit.

Yes, same as above. change to find_svm_dev() since there should be at
most one matching device in the svm list.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ