[PATCH v1 14/14] iommu/arm-smmu-v3: Add arm_smmu_cache_invalidate_user
Nicolin Chen
nicolinc at nvidia.com
Thu Mar 23 11:13:48 PDT 2023
On Thu, Mar 23, 2023 at 09:16:51AM -0300, Jason Gunthorpe wrote:
> On Wed, Mar 22, 2023 at 01:43:59PM -0700, Nicolin Chen wrote:
>
> > > So I think for ARM we want to reflect the physical SMMU instances into
> > > vSMMU instances and that feels best done by having a unique S2
> > > iommu_domain for each SMMU instance. Then we know that an invalidation
> > > for a SMMU instance is delivered to that S2's singular CMDQ and things
> > > like vCMDQ become possible.
> >
> > In that environment, do we still need a VMID unification?
>
> If each S2 is per-smmu-instance then the VMID can be local to the SMMU
> instance
It sounds like related to the multi-SMMU instance too? Anyway,
it's good to think we that have a way out from requiring this
VMID unification.
> > > > Our approach of setting up a stage-2 mapping in QEMU is to
> > > > map the entire guest memory. I don't see a point in having
> > > > a separate S2 domain, even if there are multiple instances?
> > >
> > > And then this is the drawback, we don't really want to have duplicated
> > > S2 page tables in the system for every stage 2.
> > >
> > > Maybe we have made a mistake by allowing the S2 to be an unmanaged
> > > domain. Perhaps we should create the S2 out of an unmanaged domain
> > > like the S1.
> > >
> > > Then the rules could be
> > > - Unmanaged domain can be used with every smmu instance, only one
> > > copy of the page table. The ASID in the iommu_domain is
> > > kernel-global
> > > - S2 domain is a child of a shared unmanaged domain. It can be used
> > > only with the SMMU it is associated with, it has a per-SMMU VM ID
> > > - S1 domain is a child of a S2 domain, it can be used only with the
> > > SMMU it's S2 is associated with, just because
> >
> > The actual S2 pagetable has to stay at the unmanaged domain
> > for IOAS_MAP, while we maintain an s2_cfg data structure in
> > the shadow S2 domain per SMMU instance that has its own VMID
> > but a shared S2 page table pointer?
>
> Yes
>
> > Hmm... Feels very complicated to me. How does that help?
>
> It de-duplicates the page table across multiple SMMU instances.
Oh. So that the s2_cfg data structures can have a shared S2
IOPT while having different VMIDs. This would be a big rework.
It changes the two-domain design for nesting. Should we do
this at a later stage when supporting multi-SMMU instance or
now? And I am not sure Intel would need this...
> > > So, I have been exploring a different approach by creating an
> > > > internal multiplication inside VCMDQ...
> > >
> > > How can that work?
> > >
> > > You'd have to have the guest VM to know to replicate to different
> > > vCMDQ's? Which isn't the standard SMMU programming model anymore..
> >
> > VCMDQ has multiple VINTFs (Virtual Interfaces) that's supposed
> > to be used by the host to expose to multiple VMs.
> >
> > In a multi-SMMU environment, every single SMMU+VCMDQ instance
> > would have one VINTF only that contains one or more VCMDQs. In
> > this case, passthrough devices behind different physical SMMU
> > instances are straightforwardly attached to different vSMMUs.
>
> Yes, this is the obvious simple impementation
>
> > However, if we can't have multiple vSMMU instances, the guest
> > VM (its HW) would enable multiple VINTFs corresponding to the
> > number of physical SMMU/VCMDQ instances, for devices to attach
> > accordingly. That means I need to figure out a way to pin the
> > devices onto those VINTFs, by somehow passing their physical
> > SMMU IDs.
>
> And a way to request the correctly bound vCMDQ from the guest as well.
> Sounds really messsy, I'd think multi-smmu is the much cleaner choice
Yes. I agree, we would need the entire QEMU community to give
consent to change that though.
Thanks!
Nicolin
More information about the linux-arm-kernel
mailing list