[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251009143448.GB3839422@nvidia.com>
Date: Thu, 9 Oct 2025 11:34:48 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Sairaj Kodilkar <sarunkod@....com>
Cc: "Suthikulpanit, Suravee" <suravee.suthikulpanit@....com>,
nicolinc@...dia.com, linux-kernel@...r.kernel.org,
robin.murphy@....com, will@...nel.org, joro@...tes.org,
kevin.tian@...el.com, jsnitsel@...hat.com, vasant.hegde@....com,
iommu@...ts.linux.dev, santosh.shukla@....com,
sairaj.arunkodilkar@....com, jon.grimm@....com,
prashanthpra@...gle.com, wvw@...gle.com, wnliu@...gle.com,
gptran@...gle.com, kpsingh@...gle.com, joao.m.martins@...cle.com,
alejandro.j.jimenez@...cle.com
Subject: Re: [PATCH v2 10/12] iommu/amd: Add support for nested domain
allocation
On Thu, Oct 09, 2025 at 11:52:23AM +0530, Sairaj Kodilkar wrote:
>
>
> On 10/8/2025 5:09 AM, Jason Gunthorpe wrote:
> > On Tue, Oct 07, 2025 at 03:36:58PM -0500, Suthikulpanit, Suravee wrote:
> > > The gDTE[DomainID] field contains guest Domain ID (gDomID). The host IOMMU
> > > driver uses the gDomId and guest ID (gid) to index the Domain ID mapping
> > > table, and store the host Domain ID (hDomID) in the table entry. This data
> > > structure is required by hw to translation gDomID->hDomID to virtualize
> > > guest invalidation command. This will be part of the upcoming series to
> > > enable hw-vIOMMU.
> > Sure, this translation is part of viommu
> >
> > > This ndom->id is the hDomID, which is currently allocated per-device to
> > > avoid TLB aliasing i.e. A guest w/ multiple pass-through devices w/ the same
> > > hDomID (same stage 2 table) and different stage-1 tables with same PASID.
> > > IOMMU would use the same TLB tag, which results in TLB aliasing issue.
> > > Therefore, we workaround the issue by allocating per-device hDomID for
> > > nested domain.
> > But this is what I mean here, the gDomId should be 1:1 with the hDomId
> > and here you are making it 1:N.
> Hi Jason,
> The guest will only see V2 page table when we are using hardware vIOMMU.
??
This patch is about adding the gDTE support to the driver and the GDTE
is the mechanism for userspace to inform the kernel about the V2 page
table in the guest.
If the idea at this point is to not support V2 page table then have
this function validate the gDTE to exclude it.
> Since IOMMU driver allocates per device domains when it is using V2
> page table, the mappings are still N:N and invalidations will work
> similar to V2 page table mode in host.
I don't see how this can work. Invalidations will be pushed by the
guest kernel directly to the HW invalidation queue using the
gDOMID. That must translate to a single hDOMID to invalidate the right
stuff.
If there is a hDOMID per device it cannot work unless the guest is
also making per-device IDs.
But we can't make this assumption in the viommu code.
So you must not do this, the gDOMID must be mapped to exactly one
hDOMID, and the viommu object should be managing this. When attaching
a gDTE the kernel should validate that the gDOMID maps to a hDOMID
that has the same V1 page table.
Jason
Powered by blists - more mailing lists