From: Robin Murphy <robin.murphy@arm.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
Qian Cai <quic_qiancai@quicinc.com>,
iommu@lists.linux-foundation.org, Will Deacon <will@kernel.org>
Subject: Re: [PATCH] iommu: iommu_group_claim_dma_owner() must always assign a domain
Date: Wed, 4 May 2022 16:29:24 +0100 [thread overview]
Message-ID: <b3e79abf-646b-fa98-5a4d-26fdf5e550a9@arm.com> (raw)
In-Reply-To: <20220504145454.GI49344@nvidia.com>
On 2022-05-04 15:54, Jason Gunthorpe wrote:
> On Wed, May 04, 2022 at 03:42:09PM +0100, Robin Murphy wrote:
>
>>> This fixes an oops with VFIO and SMMUv3 because VFIO will call
>>> iommu_detach_group() and then immediately iommu_domain_free(), but
>>> SMMUv3 has no way to know that the domain it is holding a pointer to
>>> has been freed. Now the iommu_detach_group() will assign the blocking
>>> domain and SMMUv3 will no longer hold a stale domain reference.
>>
>> Thanks for taking this on! I do like the overall structure and naming much
>> more than my initial sketch :)
>
> Thanks, no problem!
>
>>> /*
>>> - * If the group has been claimed already, do not re-attach the default
>>> - * domain.
>>> + * A NULL domain means to call the detach_dev() op. New drivers should
>>> + * use a IOMMU_DOMAIN_IDENTITY domain instead of a NULL default_domain
>>
>> Nit: IOMMU_DOMAIN_DMA is the baseline of default domain support, passthrough
>> is more of an optional extra.
>
> Can you elaborate on this a bit more for the comment, I'm not sure I
> understand all the historical stuff here.
Well, the comment could effectively just be "New drivers should support
default domains."
What supporting default domains means in practice is two things: that
.attach_dev handles moving directly between domains without .detach_dev
being called, and that .domain_alloc supports at least IOMMU_DOMAIN_DMA
- other unsupported default domain types can fall back to that, but not
vice versa, see iommu_group_alloc_default_domain().
> Here we are looking at a case where group->domain becomes NULL - what
> does this mean in the historical world? ie what should the iommu
> driver do when detach_dev is called?
>
> I had guessed it was remove all translation - ie IOMMU_DOMAIN_IDENTITY?
Historically, whatever a NULL domain means is mostly between the IOMMU
driver and the platform DMA ops - I honestly have no idea what the likes
of s390 and fsl-pamu do, for example. For SMMUv3 it was always configurable.
Cheers,
Robin.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-05-04 15:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-04 0:11 [PATCH] iommu: iommu_group_claim_dma_owner() must always assign a domain Jason Gunthorpe via iommu
2022-05-04 8:22 ` Nicolin Chen via iommu
2022-05-04 11:57 ` Jason Gunthorpe via iommu
2022-05-04 11:48 ` Baolu Lu
2022-05-04 11:53 ` Jason Gunthorpe via iommu
2022-05-04 14:35 ` Baolu Lu
2022-05-04 14:38 ` Jason Gunthorpe via iommu
2022-05-04 14:55 ` Baolu Lu
2022-05-04 15:00 ` Jason Gunthorpe via iommu
2022-05-04 14:42 ` Robin Murphy
2022-05-04 14:54 ` Jason Gunthorpe via iommu
2022-05-04 15:29 ` Robin Murphy [this message]
2022-05-04 18:20 ` Jason Gunthorpe via iommu
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=b3e79abf-646b-fa98-5a4d-26fdf5e550a9@arm.com \
--to=robin.murphy@arm.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jgg@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=quic_qiancai@quicinc.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