From: Lu Baolu <baolu.lu@linux.intel.com>
To: Fenghua Yu <fenghua.yu@intel.com>, Joerg Roedel <joro@8bytes.org>,
David Woodhouse <dwmw2@infradead.org>,
Ashok Raj <ashok.raj@intel.com>,
Dave Hansen <dave.hansen@intel.com>,
Jacob Jun Pan <jacob.jun.pan@intel.com>,
Ravi V Shankar <ravi.v.shankar@intel.com>
Cc: iommu@lists.linux-foundation.org
Subject: Re: [PATCH] iommu/vt-d: Fix PASID reference leak
Date: Sun, 15 Aug 2021 13:00:12 +0800 [thread overview]
Message-ID: <51d97b07-5d72-771b-f437-c04e2596c4b0@linux.intel.com> (raw)
In-Reply-To: <20210813181345.1870742-1-fenghua.yu@intel.com>
On 2021/8/14 2:13, Fenghua Yu wrote:
> A PASID reference is increased whenever a device is bound to an mm (and
> its PASID) successfully (i.e. the device's sdev user count is increased).
> But the reference is not dropped every time the device is unbound
> successfully from the mm (i.e. the device's sdev user count is decreased).
> The reference is dropped only once by calling intel_svm_free_pasid() when
> there isn't any device bound to the mm. intel_svm_free_pasid() drops the
> reference and only frees the PASID on zero reference.
>
> Fix the issue by dropping the PASID reference and freeing the PASID when
> no reference on successful unbinding the device by calling
> intel_svm_free_pasid() .
>
> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Nice catch! Thanks!
Fixes: 4048377414162 ("iommu/vt-d: Use iommu_sva_alloc(free)_pasid()
helpers")
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Best regards,
baolu
> ---
> drivers/iommu/intel/svm.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
> index 9b0f22bc0514..4b9b3f35ba0e 100644
> --- a/drivers/iommu/intel/svm.c
> +++ b/drivers/iommu/intel/svm.c
> @@ -675,7 +675,6 @@ static int intel_svm_unbind_mm(struct device *dev, u32 pasid)
> kfree_rcu(sdev, rcu);
>
> if (list_empty(&svm->devs)) {
> - intel_svm_free_pasid(mm);
> if (svm->notifier.ops) {
> mmu_notifier_unregister(&svm->notifier, mm);
> /* Clear mm's pasid. */
> @@ -690,6 +689,8 @@ static int intel_svm_unbind_mm(struct device *dev, u32 pasid)
> kfree(svm);
> }
> }
> + /* Drop a PASID reference and free it if no reference. */
> + intel_svm_free_pasid(mm);
> }
> out:
> return ret;
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2021-08-15 5:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-13 18:13 [PATCH] iommu/vt-d: Fix PASID reference leak Fenghua Yu
2021-08-15 5:00 ` Lu Baolu [this message]
2021-08-17 12:51 ` Lu Baolu
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=51d97b07-5d72-771b-f437-c04e2596c4b0@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=dave.hansen@intel.com \
--cc=dwmw2@infradead.org \
--cc=fenghua.yu@intel.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@intel.com \
--cc=joro@8bytes.org \
--cc=ravi.v.shankar@intel.com \
/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