[PATCH v9 11/13] iommufd/viommu: Allow vIOMMUs without a parent HWPT

Baolu Lu baolu.lu at linux.intel.com
Mon Nov 30 21:34:57 PST 2026


On 11/24/2026 1:23 PM, Aneesh Kumar K.V wrote:
> Baolu Lu<baolu.lu at linux.intel.com> writes:
> 
>> On 11/16/2026 4:19 PM, Aneesh Kumar K.V (Arm) wrote:
>>> VIOMMU_ALLOC currently requires a nesting parent HWPT_PAGING even when
>>> the selected vIOMMU implementation has no use for one. This would force
>>> implementations such as the following Arm Realm vIOMMU to create an
>>> unused parent.
>>>
>>> Add IOMMUFD_VIOMMU_NO_HWPT so an implementation can opt out. Require
>>> hwpt_id to be zero in that case and pass a NULL parent domain to its
>>> initialization callback. For implementations that require a HWPT, verify
>>> that the parent supports nesting and its domain belongs to the device's
>>> physical IOMMU driver before invoking viommu_init().
>>>
>>> Reject nested domain and hardware queue allocation for a vIOMMU without
>>> a parent, and document the two allocation modes in the UAPI.
>>>
>>> Cc: Jason Gunthorpe<jgg at ziepe.ca>
>>> Cc: Kevin Tian<kevin.tian at intel.com>
>>> Cc: Joerg Roedel<joro at 8bytes.org>
>>> Cc: Will Deacon<will at kernel.org>
>>> Cc: Robin Murphy<robin.murphy at arm.com>
>>> Cc:iommu at lists.linux.dev
>>> Signed-off-by: Aneesh Kumar K.V (Arm)<aneesh.kumar at kernel.org>
>>> ---
>>>    Documentation/userspace-api/iommufd.rst | 44 +++++++++---------
>>>    drivers/iommu/iommufd/hw_pagetable.c    | 14 ++++--
>>>    drivers/iommu/iommufd/viommu.c          | 62 +++++++++++++++----------
>>>    include/linux/iommufd.h                 | 13 ++++--
>>>    include/uapi/linux/iommufd.h            |  3 +-
>>>    5 files changed, 81 insertions(+), 55 deletions(-)
>>>
>> [...]
>>
>>> diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c
>>> index ae62db50885c..52e52ef089a2 100644
>>> --- a/drivers/iommu/iommufd/hw_pagetable.c
>>> +++ b/drivers/iommu/iommufd/hw_pagetable.c
>>> @@ -306,6 +306,10 @@ iommufd_viommu_alloc_hwpt_nested(struct iommufd_viommu *viommu, u32 flags,
>>>    		return ERR_PTR(-EOPNOTSUPP);
>>>    	if (!user_data->len)
>>>    		return ERR_PTR(-EOPNOTSUPP);
>>> +	if (!viommu->hwpt)
>>> +		return ERR_PTR(-EOPNOTSUPP);
>>> +	if (!viommu->iommu_dev)
>>> +		return ERR_PTR(-EOPNOTSUPP);
>>>    	if (!viommu->ops || !viommu->ops->alloc_domain_nested)
>>>    		return ERR_PTR(-EOPNOTSUPP);
>>>    
>>> @@ -404,10 +408,12 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd)
>>>    		struct iommufd_viommu *viommu;
>>>    
>>>    		viommu = container_of(pt_obj, struct iommufd_viommu, obj);
>>> -		iommu_dev = iommufd_device_get_iommu_dev(idev);
>>> -		if (!iommu_dev || viommu->iommu_dev != iommu_dev) {
>>> -			rc = -EINVAL;
>>> -			goto out_unlock;
>>> +		if (viommu->iommu_dev) {
>>> +			iommu_dev = iommufd_device_get_iommu_dev(idev);
>>> +			if (!iommu_dev || viommu->iommu_dev != iommu_dev) {
>>> +				rc = -EINVAL;
>>> +				goto out_unlock;
>>> +			}
>> Is it intended that every tsm-provided viommu has viommu->iommu_dev ==
>> NULL?
>>
>> If so, could the tsm-provider patch make provider selection exclusive by
>> looking up the physical iommu only on the fallback path? All checks
>> against viommu->iommu_dev should be in that patch. This non-parent-hwpt
>> viommu support patch should no longer check viommu->iommu_dev.
>>
> IIUC, you are suggesting moving the iommu_dev check from this patch to
> patch 10?

Yes.



More information about the linux-arm-kernel mailing list