From: Jason Gunthorpe <jgg@nvidia.com>
To: Baolu Lu <baolu.lu@linux.intel.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
Robin Murphy <robin.murphy@arm.com>,
"Tian, Kevin" <kevin.tian@intel.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Subject: Re: RMRR device on non-Intel platform
Date: Fri, 21 Apr 2023 10:33:53 -0300 [thread overview]
Message-ID: <ZEKQwVjJrMTUlPUR@nvidia.com> (raw)
In-Reply-To: <f0c46e67-c029-a759-5523-d598adb7fd07@linux.intel.com>
On Fri, Apr 21, 2023 at 09:21:12PM +0800, Baolu Lu wrote:
> On 2023/4/21 20:04, Jason Gunthorpe wrote:
> > @@ -2210,6 +2213,22 @@ static int __iommu_device_set_domain(struct iommu_group *group,
> > {
> > int ret;
> > + /*
> > + * If the driver has requested IOMMU_RESV_DIRECT then we cannot allow
> > + * the blocking domain to be attached as it does not contain the
> > + * required 1:1 mapping. This test effectively exclusive the device from
> > + * being used with iommu_group_claim_dma_owner() which will block vfio
> > + * and iommufd as well.
> > + */
> > + if (dev->iommu->requires_direct &&
> > + (new_domain->type == IOMMU_DOMAIN_BLOCKED ||
> > + new_domain == group->blocking_domain)) {
> > + dev_warn(
> > + dev,
> > + "Firmware has requested this device have a 1:1 IOMMU mapping, rejecting configuring the device without a 1:1 mapping. Contact your platform vendor.");
> > + return -EINVAL;
> > + }
> > +
> > if (dev->iommu->attach_deferred) {
> > if (new_domain == group->default_domain)
> > return 0;
>
> How about enforcing this in iommu_group_claim_dma_owner()
It is more general here, since this applies to any attempt to attach a
blocking domain, eg if we future miscode something else it will still
be protected. It is subtle enough, and we all missed this for a long
time already I prefer we be robust.
> and change the iommu drivers to use "atomic replacement" instead of
> blocking translation transition when switching to a new domain?
That seems unlikely to happen on a broad scale..
> Assuming that the kernel drivers should always use the default
> domain, or handle the IOMMU_RESV_DIRECT by themselves if they decide
> to use its own unmanaged domain for kernel DMA.
Long term we want to get to the point where all kernel drivers call
a claim_dma_owner before they mess with the domains. This is our
locking protocol to say that it is actually safe to do it.
If we reach a point where a kernel driver wants to make its own domain
and needs to work with FW that pushes IOMMU_RESV_DIRECT for its device
then we should add a claim_dma_owner variant for trusted users that
avoids using the blocking domain.
Jason
next prev parent reply other threads:[~2023-04-21 13:33 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 6:52 RMRR device on non-Intel platform Tian, Kevin
2023-04-20 14:15 ` Alex Williamson
2023-04-20 14:19 ` Robin Murphy
2023-04-20 14:49 ` Alex Williamson
2023-04-20 16:55 ` Robin Murphy
2023-04-20 21:49 ` Alex Williamson
2023-04-21 4:10 ` Tian, Kevin
2023-04-21 11:33 ` Jason Gunthorpe
2023-04-21 11:34 ` Robin Murphy
2023-04-23 8:23 ` Tian, Kevin
2023-04-21 12:04 ` Jason Gunthorpe
2023-04-21 12:29 ` Robin Murphy
2023-04-21 12:45 ` Jason Gunthorpe
2023-04-21 17:22 ` Robin Murphy
2023-04-21 17:58 ` Jason Gunthorpe
2023-04-25 14:48 ` Robin Murphy
2023-04-25 15:58 ` Jason Gunthorpe
2023-04-26 8:39 ` Tian, Kevin
2023-04-26 12:24 ` Robin Murphy
2023-04-26 12:58 ` Jason Gunthorpe
2023-04-25 16:37 ` Nicolin Chen
2023-04-26 11:57 ` Jason Gunthorpe
2023-04-26 13:53 ` Robin Murphy
2023-04-26 14:17 ` Jason Gunthorpe
2023-04-21 13:21 ` Baolu Lu
2023-04-21 13:33 ` Jason Gunthorpe [this message]
2023-04-23 8:24 ` Tian, Kevin
2023-04-24 2:50 ` Baolu Lu
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=ZEKQwVjJrMTUlPUR@nvidia.com \
--to=jgg@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=robin.murphy@arm.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