Re: [PATCH v3 6/7] iommu: Park TDISP T=0 devices in the blocking domain
From: Nicolin Chen
Date: Thu Nov 26 2026 - 01:22:16 EST
On Wed, Nov 25, 2026 at 02:07:45PM -0400, Jason Gunthorpe wrote:
> > [ ... 28 lines skipped ... ]
> > @@ -1238,6 +1238,14 @@ static int iommu_create_device_direct_mappings(struct iommu_domain *domain,
> > unsigned long pg_size;
> > int ret = 0;
> >
> > + /*
> > + * The direct-map reserved regions are still fine because the T=0 stream
> > + * always goes to an identity mapping. Skip them: recording the request
> > + * would only refuse the device its blocking domain.
> > + */
> > + if (iommu_using_t0_stream(dev))
> > + return 0;
> > +
>
> Not sure about this. If we are allocating a paging domain then it
> should always have the direct mappings setup in it.
Hmm, is there a paging domain for t0? I thought it's always on the
blocked domain..
Even if there is one, t0 would ignore those mappings, since it goes
through the underlying hypervisor path, right?
> I think this patch is the right idea, but it should probably be
> removed from this series for now if we don't need it to make a basic
> trusted vIOMMU work.
Without it, every device sets dev->iommu->require_direct for RMR:
if (entry->type == IOMMU_RESV_DIRECT)
dev->iommu->require_direct = 1;
Then, __iommu_device_set_domain() would fail the first test:
if (dev->iommu->require_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.\n");
return -EINVAL;
}
> After Leon's trust level series we should have the flow I mentioned
> before where the iommu starts out in BLOCKED naturally and we will
> allocate the paging domain right at driver binding.
>
> With that infrastructure you can make a decision to just not alloc the
> paging domain if the device is not in T=1 mode.
[...]
> > [ ... 30 lines skipped ... ]
> > @@ -4294,8 +4341,9 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
> > return ret;
> >
> > mutex_lock(&group->mutex);
> > - /* An IDENTITY domain must pass through */
> > - if (group->domain && group->domain->type != IOMMU_DOMAIN_IDENTITY) {
> > + /* An IDENTITY domain or a T=0 device must pass through */
> > + if (group->domain && group->domain->type != IOMMU_DOMAIN_IDENTITY &&
> > + !iommu_using_t0_stream(dev)) {
> > switch (group->domain->cookie_type) {
> > case IOMMU_COOKIE_DMA_MSI:
> > case IOMMU_COOKIE_DMA_IOVA:
>
> Hmm. At the moment we expect that MSI is always using T=0, so this
> would be more like '!iommu->confidential' I guess since T=0 will
> always use bypass. It doesn't matter at all though since existing VMMs
> ignore the address selected here :\
Yea, !iommu->confidential is much clearer.
Thanks
Nicolin