Re: [PATCH RFCv1 07/14] iommufd: Add viommu set/unset_dev_id ops

From: Jason Gunthorpe
Date: Fri May 24 2024 - 09:12:20 EST


On Fri, May 24, 2024 at 07:21:59AM +0000, Tian, Kevin wrote:

> My point was based on Jason's example about 3 VMIDs:
>
> hwpt_alloc(deva, nesting_parent=true) = shared_s2
> viommu_alloc(deva, shared_s2) = viommu1
> viommu_alloc(devb, shared_s2) = viommu2
> hwpt_alloc(deva, viommu1, vste) = deva_vste
> hwpt_alloc(devb, viommu2, vste) = devb_vste
> attach(deva, deva_vste)
> attach(devb, devb_vste)
> attach(devc, shared_s2)
>
> for devc it could be:
> hwpt_alloc(deva, viommu1, vproxy_s1) = devc_proxys1
> attach(devc, devc_proxys1)
>
> then devc will reuse VMID of viommu1 and we save one VMID.

I think that can work, at least I haven't thought of a reason why the
non-vIOMMU device's VMID couldn't be shared with one of the
vIOMMUs.

It is all quite a contrived case, I dont't expect people to want to do
anything like this, it is just showing that the API is properly setup
that it could be done. Userspace is not restricted to a single VIOMMU.

> Does that not work so we need create another viommu to hold the
> proxy identity s1 then still need a 3rd VMID?

Yes, I think that can be OK.

Jason