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 Wed, May 28, 2025 at 01:42:25PM -0300, Jason Gunthorpe wrote:
> On Wed, May 28, 2025 at 05:47:19PM +0530, Aneesh Kumar K.V wrote:
> 
> > +#if IS_ENABLED(CONFIG_KVM)
> > +#include <linux/kvm_host.h>
> > +
> > +static void viommu_get_kvm_safe(struct iommufd_viommu *viommu, struct kvm *kvm)
> > +{
> > +	void (*put_fn)(struct kvm *kvm);
> > +	bool (*get_fn)(struct kvm *kvm);
> > +	bool ret;
> > +
> > +	if (!kvm)
> > +		return;
> > +
> > +	put_fn = symbol_get(kvm_put_kvm);
> > +	if (WARN_ON(!put_fn))
> > +		return;
> > +
> > +	get_fn = symbol_get(kvm_get_kvm_safe);
> > +	if (WARN_ON(!get_fn)) {
> > +		symbol_put(kvm_put_kvm);
> > +		return;
> > +	}
> > +
> > +	ret = get_fn(kvm);
> > +	symbol_put(kvm_get_kvm_safe);
> > +	if (!ret) {
> > +		symbol_put(kvm_put_kvm);
> > +		return;
> > +	}
> > +
> > +	viommu->put_kvm = put_fn;
> > +	viommu->kvm = kvm;
> > +}
> 
> Shameer was working on something like this too
> 
> I would probably split just the viommu kvm stuff into one patch so you
> two can share it.
> 
> > @@ -68,10 +121,32 @@ int iommufd_viommu_alloc_ioctl(struct iommufd_ucmd *ucmd)
> >  	 */
> >  	viommu->iommu_dev = __iommu_get_iommu_dev(idev->dev);
> >  
> > +	/* get the kvm details if specified. */
> > +	if (cmd->kvm_vm_fd) {
> 
> Pedantically a 0 fd is still valid, you should add a flag to indicate
> if the KVM is being supplied.

Did I miss something? Shameer's patch passed in struct kvm* through
iommufd_device_bind() then to viommu, and has your Reviewed-by. I'm a
little confused...

https://lore.kernel.org/all/20250319232848.GD126678@xxxxxxxx/

Thanks,
Yilun




[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