public inbox for iommu@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: Yi Sun <yi.y.sun@linux.intel.com>
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: dwmw2@infradead.org, iommu@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/3] iommu/vt-d: Fix prq reporting issues
Date: Wed, 28 Oct 2020 14:05:55 +0800	[thread overview]
Message-ID: <20201028060555.GC27139@yi.y.sun> (raw)
In-Reply-To: <f330e49a-0bf4-08c7-8e24-04606ec4819e@linux.intel.com>

Thanks! Will do the modifications according to your comments in next
version.

On 20-10-28 12:50:37, Lu Baolu wrote:
> Hi Yi,
> 
> On 10/28/20 9:36 AM, Yi Sun wrote:
> >From: Liu Yi L <yi.l.liu@intel.com>
> >
> >Should get correct sid and set it into sdev. Because we execute
> >'sdev->sid != req->rid' in the loop of prq_event_thread().
> 
> How about making the title more accurate, how about something like:
> 
> iommu/vt-d: Fix use before set issue in intel_svm_bind_gpasid()
> 
> >
> >Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
> >Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
> >---
> >  drivers/iommu/intel/svm.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> >diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
> >index f1861fa..75d9dc9 100644
> >--- a/drivers/iommu/intel/svm.c
> >+++ b/drivers/iommu/intel/svm.c
> >@@ -277,6 +277,7 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev,
> >  			  struct iommu_gpasid_bind_data *data)
> >  {
> >  	struct intel_iommu *iommu = device_to_iommu(dev, NULL, NULL);
> >+	struct device_domain_info *info;
> >  	struct intel_svm_dev *sdev = NULL;
> >  	struct dmar_domain *dmar_domain;
> >  	struct intel_svm *svm = NULL;
> >@@ -357,6 +358,8 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev,
> >  		goto out;
> >  	}
> >  	sdev->dev = dev;
> >+	info = get_domain_info(dev);
> >+	sdev->sid = PCI_DEVID(info->bus, info->devfn);
> >  	/* Only count users if device has aux domains */
> >  	if (iommu_dev_feature_enabled(dev, IOMMU_DEV_FEAT_AUX))
> >
> 
> How about moving get_domain_info() up to the sanity check part?
> 
> diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
> index f1861fa3d0e4..75846692f2f2 100644
> --- a/drivers/iommu/intel/svm.c
> +++ b/drivers/iommu/intel/svm.c
> @@ -279,6 +279,7 @@ int intel_svm_bind_gpasid(struct iommu_domain
> *domain, struct device *dev,
>         struct intel_iommu *iommu = device_to_iommu(dev, NULL, NULL);
>         struct intel_svm_dev *sdev = NULL;
>         struct dmar_domain *dmar_domain;
> +       struct device_domain_info *info;
>         struct intel_svm *svm = NULL;
>         int ret = 0;
> 
> @@ -310,6 +311,10 @@ int intel_svm_bind_gpasid(struct iommu_domain
> *domain, struct device *dev,
>         if (data->hpasid <= 0 || data->hpasid >= PASID_MAX)
>                 return -EINVAL;
> 
> +       info = get_domain_info(dev);
> +       if (!info)
> +               return -EINVAL;
> +
>         dmar_domain = to_dmar_domain(domain);
> 
>         mutex_lock(&pasid_mutex);
> @@ -357,6 +362,7 @@ int intel_svm_bind_gpasid(struct iommu_domain
> *domain, struct device *dev,
>                 goto out;
>         }
>         sdev->dev = dev;
> +       sdev->sid = PCI_DEVID(info->bus, info->devfn);
> 
>         /* Only count users if device has aux domains */
>         if (iommu_dev_feature_enabled(dev, IOMMU_DEV_FEAT_AUX))
> 
> Best regards,
> baolu
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2020-10-28  6:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28  1:36 [PATCH v1 0/3] iommu: Fix a few issues related to PRQ Yi Sun
2020-10-28  1:36 ` [PATCH v1 1/3] iommu/vt-d: Fix prq reporting issues Yi Sun
2020-10-28  4:50   ` Lu Baolu
2020-10-28  6:05     ` Yi Sun [this message]
2020-10-28  1:36 ` [PATCH v1 2/3] iommu: Fix an issue in iommu_page_response() flags check Yi Sun
2020-10-28  9:13   ` Jean-Philippe Brucker
2020-10-29  6:30     ` Yi Sun
2020-10-28  1:36 ` [PATCH v1 3/3] iommu/vt-d: Fix a bug for PDP check in prq_event_thread Yi Sun
2020-10-28  5:05   ` Lu Baolu
2020-10-28  6:06     ` Yi Sun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201028060555.GC27139@yi.y.sun \
    --to=yi.y.sun@linux.intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox