Re: [RFC PATCH v6 05/11] iommu: Add a helper to validate a vIOMMU parent
From: Jason Gunthorpe
Date: Fri Sep 25 2026 - 08:23:26 EST
On Fri, Sep 25, 2026 at 11:18:44AM +0530, Aneesh Kumar K.V wrote:
> > The TSM viommu should use a NULL parent domain, it doesn't have an
> > iommufd managed S2.
>
> How would we assign an untrusted device? I currently follow these steps:
> 1. Create an HWPT with IOMMU_HWPT_ALLOC_NEST_PARENT.
> 2. Allocate a vIOMMU with viommu.hwpt_id set to that hwpt_id.
> 3. Allocate a vdevice with alloc_vdev.viommu_id set to that viommu_id.
> 4. Use VFIO_DEVICE_ATTACH_IOMMUFD_PT with the hwpt_id.
The vmiommu.hwpt_id should be 0.
1. Create a a HWPT with IOMMU_HWPT_ALLOC_NEST_PARENT
2. VFIO_DEVICE_ATTACH_IOMMUFD_PT with the hwpt_id to establish the T=0
identity S2, no T=0 vSMMU
3. Create a VIOMMU with no hwpt_id and the RMM's type. This triggers
RMM to create the the T=1 vSMMU inside the realm
4. Allocate a vdevice on the viommu_id. This triggers RMM to create
the VDEV inside the realm
5. Setup guest ACPI tables/etc to point at the RMM's T=1 vsmmu.
Now both the T=1 VSUMM and T=0 fixed translation are setup.
If we loose our minds someday and want to concurrently have a T=0&1
VSMMU then the the first two steps become:
1. Create a a HWPT with IOMMU_HWPT_ALLOC_NEST_PARENT
2. Create a VIOMMU with no hwpt_id and IOMMU_VIOMMU_TYPE_ARM_SMMUV3
3. Create a vdevice on #2, we'd need to fixup iommufd to support two
vdevices for the same device.
4. Create a nested child HWPT IOMMU_HWPT_DATA_ARM_SMMUV3 from the T=0
vSTE
5. Use VFIO_DEVICE_ATTACH_IOMMUFD_PT on #3
ie there would be two viommu objects inside iommufd.
> I use the same iommufd for both trusted and untrusted devices because
> the guest controls that transition. While operating in untrusted mode, I
> use the iommufd to insert DMA mappings via IOMMU_IOAS_MAP.
Sure, that's not an issue, just don't create the *TSM VIOMMU* with a
hwpt.
TSM viommu driver just asserts the parent is NULL, since it doesn't
use a S2.
Jason