From: Yi Liu <yi.l.liu@intel.com>
To: Lizhi Hou <lizhi.hou@amd.com>, <joro@8bytes.org>,
<will@kernel.org>, <robin.murphy@arm.com>
Cc: <iommu@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
<baolu.lu@linux.intel.com>, <vasant.hegde@amd.com>
Subject: Re: [PATCH V1] iommu/sva: Fix crash in iommu_sva_unbind_device()
Date: Wed, 4 Mar 2026 18:10:11 +0800 [thread overview]
Message-ID: <d9d16633-85a8-4e59-9188-289af13eea04@intel.com> (raw)
In-Reply-To: <945476d7-6e2e-b8a1-904b-09c8c87067a2@amd.com>
On 3/4/26 02:33, Lizhi Hou wrote:
>
> On 2/28/26 04:14, Yi Liu wrote:
>>
>> On 2/26/26 06:09, Lizhi Hou wrote:
>>>
>>>>> diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c
>>>>> index 07d64908a05f..523b8c65c86f 100644
>>>>> --- a/drivers/iommu/iommu-sva.c
>>>>> +++ b/drivers/iommu/iommu-sva.c
>>>>> @@ -179,6 +179,7 @@ void iommu_sva_unbind_device(struct iommu_sva
>>>>> *handle)
>>>>> return;
>>>>> }
>>>>>
>>>>> + mmgrab(domain->mm);
>>>>> iommu_detach_device_pasid(domain, dev, iommu_mm->pasid);
>>>>> if (--domain->users == 0) {
>>>>> list_del(&domain->next);
>>>>> @@ -190,6 +191,7 @@ void iommu_sva_unbind_device(struct iommu_sva
>>>>> *handle)
>>>>> if (list_empty(&iommu_sva_mms))
>>>>> iommu_sva_present = false;
>>>>> }
>>>>> + mmdrop(domain->mm);
>>>>>
>>>>> mutex_unlock(&iommu_sva_lock);
>>>>> kfree(handle);
>>>>
>>>> will moving the below hunk in front of iommu_domain_free() simpler?
>>>> Only when (--domain->users == 0), shall the code check if sva_domains
>>>> is empty. right?
>>>
>>> I am not sure if this can be moved in front of iommu_domain_free(). Will
>>> iommu_domain_free() be possible to impact sva_domains?
>>
>> sva_domains is used to track domains associated with the same mm in the
>> generic layer. iommu_domain_free() calls vendor iommu driver's free() op
>> with domain type specific operations. I don't think it should impact the
>> sva_domains.
>>
>>> iommu_domain_free() calls domain->ops->free(). Could this call back free
>>> sva_domain?
>>
>> I think so. Check intel_mm_free_notifier() as an example.
>
> So if this is true, after calling iommu_domain_free(), the following
> check list_empty(&iommu_mm->sva_domains) could become to true because of
> domain free. If we move the check in front (before iommu_domain_free()),
> the check could be false. That seems leading incorrect iommu_sva_present
list_empty(&iommu_mm->sva_domains) can be true because of
list_del(&domain->next), not iommu_domain_free(). Am I missing
anything here?
Regards,
Yi Liu
next prev parent reply other threads:[~2026-03-04 10:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 18:30 [PATCH V1] iommu/sva: Fix crash in iommu_sva_unbind_device() Lizhi Hou
2026-02-25 9:35 ` Yi Liu
2026-02-25 22:09 ` Lizhi Hou
2026-02-28 12:14 ` Yi Liu
2026-03-03 18:33 ` Lizhi Hou
2026-03-04 10:10 ` Yi Liu [this message]
2026-03-04 21:25 ` Lizhi Hou
2026-03-02 6:50 ` Baolu Lu
2026-03-02 11:04 ` Yi Liu
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=d9d16633-85a8-4e59-9188-289af13eea04@intel.com \
--to=yi.l.liu@intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhi.hou@amd.com \
--cc=robin.murphy@arm.com \
--cc=vasant.hegde@amd.com \
--cc=will@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