Re: [PATCH v3 12/13] PCI/TSM: support TDI related operations for host TSM driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 30, 2025 at 01:00:41PM +1000, Alexey Kardashevskiy wrote:
> 
> 
> On 30/5/25 00:09, Jason Gunthorpe wrote:
> > On Thu, May 29, 2025 at 07:13:54PM +0530, Aneesh Kumar K.V wrote:
> > > Jason Gunthorpe <jgg@xxxxxxxxxx> writes:
> > > 
> > > > On Wed, May 28, 2025 at 01:42:25PM -0300, Jason Gunthorpe wrote:
> > > > > > +int iommufd_vdevice_tsm_bind_ioctl(struct iommufd_ucmd *ucmd)
> > > > > > +{
> > > > > > +	struct iommu_vdevice_id *cmd = ucmd->cmd;
> > > > > > +	struct iommufd_vdevice *vdev;
> > > > > > +	int rc = 0;
> > > > > > +
> > > > > > +	vdev = container_of(iommufd_get_object(ucmd->ictx, cmd->vdevice_id,
> > > > > > +					       IOMMUFD_OBJ_VDEVICE),
> > > > > > +			    struct iommufd_vdevice, obj);
> > > > > > +	if (IS_ERR(vdev))
> > > > > > +		return PTR_ERR(vdev);
> > > > > > +
> > > > > > +	rc = tsm_bind(vdev->dev, vdev->viommu->kvm, vdev->id);
> > > > > 
> > > > > Yeah, that makes alot of sense now, you are passing in the KVM for the
> > > > > VIOMMU and both the vBDF and pBDF to the TSM layer, that should be
> > > > > enough for it to figure out what to do. The only other data would be
> > > > > the TSM's VIOMMU handle..
> > > > 
> > > > Actually it should also check that the viommu type is compatible with
> > > > the TSM, somehow.
> > > > 
> > > > The way I imagine this working is userspace would create a
> > > > IOMMU_VIOMMU_TYPE_TSM_VTD (for example) viommu object which will do a
> > > > TSM call to setup the secure vIOMMU
> > > > 
> > > > Then when you create a VDEVICE against the IOMMU_VIOMMU_TYPE_TSM_VTD
> > > > it will do a TSM call to create the secure vPCI function attached to
> > > > the vIOMMU and register the vBDF. [1]
> > > > 
> > > 
> > > Don’t we create the vdevice before the guest starts?
> > 
> > Yes, vdevice/vPCI creation is before the guest start.
> 
> sorry but I still need clarification :)
> 
> vPCI == passed through PCI function (ethernet nic, etc), visible in guest's "lspci"

Yes

> vdevice == slice (say, AMD's DTE/sDTE) of viommu device (say, AMD vIOMMU PCI device) to handle a specific vPCI

Yes.. with general extensions of what "slice" means into the TSM
world.

vdevice is the hypervisor handle for the vPCI function the guest sees.

> > vPCI device creation is controlled by the hypervisor and is done
> > before starting the VM.
> 
> I am asking (again) because with PCIe hotplug it is not done before starting the VM. Thanks,

Sure, hotplug has to create the vPCI and VDEVICE before notifying the
guest of the hotplug.

Jason




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux