On Mon, Dec 11, 2023 at 11:30:00PM -0800, Nicolin Chen wrote: > > > Could the structure just look like this? > > > struct iommu_dev_assign_virtual_id { > > > __u32 size; > > > __u32 dev_id; > > > __u32 id_type; > > > __u32 id; > > > }; > > > > It needs to take in the viommu_id also, and I'd make the id 64 bits > > just for good luck. > > What is viommu_id required for in this context? I thought we > already know which SMMU instance to issue commands via dev_id? The viommu_id would be the container that holds the xarray that maps the vRID to pRID Logically we could have multiple mappings per iommufd as we could have multiple iommu instances working here. > > > > IOMMUFD_DEV_INVALIDATE should be introduced with the same design as > > > > HWPT invalidate. This would be used for AMD/ARM's ATC invalidation > > > > (and just force the stream ID, userspace must direct the vRID to the > > > > correct dev_id). > > > > > > SMMU's CD invalidations could fall into this category too. > > Do we need a different iommu API for this ioctl? We currently > have the cache_invalidate_user as a domain op. The new device > op will be an iommu op? Yes > And should we rename the "cache_invalidate_user"? Would VT-d > still uses it for device cache? I think vt-d will not implement it > > > I previously drafted something to test it out with iommufd. > > > Basically it needs the pairing of vRID/pRID in attach_dev() > > > and another ioctl to mmap/config user queue(s): > > > +struct iommu_hwpt_cache_config_tegra241_vcmdq { > > > + __u32 vcmdq_id; // queue id > > > + __u32 vcmdq_log2size; // queue size > > > + __aligned_u64 vcmdq_base; // queue guest PA > > > +}; > > > > vRID/pRID pairing should come from IOMMUFD_DEV_ASSIGN_VIRTUAL_ID. When > > a HWPT is allocated it would be connected to the viommu_id and then it > > would all be bundled together in the HW somehow > > Since we were talking about sharing stage-2 domain, the HWPT > to the stage-2 domain will be shared among the vIOMMU/pIOMMU > instances too? The HWPT for the stage 2 should be shared > I think I am not quite getting the viommu_id > part yet. From the other side of this thread, viommu object > is created per vIOMMU instance and each one actually tied to > a pIOMMU by nature? Yes Jason