Re: [PATCH v10 02/13] iommu/arm-smmu-v3: Make the ASID space per SMMU instance

From: Jason Gunthorpe

Date: Sun Oct 04 2026 - 12:22:37 EST


On Sun, Oct 04, 2026 at 02:23:55PM +0100, Will Deacon wrote:
> On Sun, Aug 30, 2026 at 04:18:03PM -0700, Nicolin Chen wrote:
> > An ASID tags the TLB entries within one SMMU, so two instances can use the
> > same ASID without ever aliasing each other. Yet the driver allocates them
> > out of a single global xarray, which makes the instances share a space that
> > the hardware keeps apart, and lets one instance exhaust the IDs of another.
> >
> > That global space is a leftover from the BTM support that shared ASIDs with
> > the CPU. Now ARM_SMMU_FEAT_BTM is never set, nothing looks a domain up by
> > its ASID, and a domain is pinned to one SMMU at the attach.
>
> We probably need to figure out what we're doing with BTM. Over at:
>
> https://lore.kernel.org/r/20260907184513.GA2543240@xxxxxxxx
>
> Jason was talking about bringing it back once the remaining invs stuff
> has landed. If that happens, what is the correct sequence to allocate
> the same ASID on every SMMU instance after these patches?

The last attempt I had at this already relied on the per-instance
ASID, it made it simpler.

The flow upon SVA domain attach to a device is broadly
- Check if the asid is free in the per instance asid xarray
- If there is a conflict
* Reserve a new empty asid
* Allocate two invs list, first with both ASIDs, second with only
new
* Set the first invs list. Barrier
* Update the CD entries for the conflicted domain to the new ASID
* Flush CDs and IOTLB
* Set the second invs list. Barrier
* Set the SVA as the owner of the replaced asid

This cycle repeats every time the SVA is connected to a domain, we
don't need to do a 'global' operation. That is why the per-instance
approach was simpler

BTM has a per-CD flag to indicate if the CD uses a 'BTM' ASID or a
normal ASID. It is fine for normal ASID's to alias the MM as they
won't participate in DVM, so only SVA needs to do this.

It was the STE that was broken and lacked that bit so you always had
to be careful with the vmid.

So the simplificaiton to do BTM is to only support guest BTM, where
the instance has no S2 support in the IDR. Leave figuring out the vmid
with kvm to another project.

IIRC..

Jason