RE: [RFC PATCH v4 3/3] VFIO Type1 IOMMU: Add support for mediated devices

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

 



> From: Dong Jia [mailto:bjsdjshi@xxxxxxxxxxxxxxxxxx]
> Sent: Friday, June 03, 2016 4:32 PM
> 
> On Thu, 2 Jun 2016 00:56:47 -0700
> Neo Jia <cjia@xxxxxxxxxx> wrote:
> 
> > On Wed, Jun 01, 2016 at 04:40:19PM +0800, Dong Jia wrote:
> > > On Wed, 25 May 2016 01:28:17 +0530
> > > Kirti Wankhede <kwankhede@xxxxxxxxxx> wrote:
> > >
> > > > +
> > > > +/*
> > > > + * Pin a set of guest PFNs and return their associated host PFNs for API
> > > > + * supported domain only.
> > > > + * @vaddr [in]: array of guest PFNs
> > > > + * @npage [in]: count of array elements
> > > > + * @prot [in] : protection flags
> > > > + * @pfn_base[out] : array of host PFNs
> > > > + */
> > > > +long vfio_pin_pages(void *iommu_data, dma_addr_t *vaddr, long npage,
> > > > +		   int prot, dma_addr_t *pfn_base)
> > > > +{
> > > > +	struct vfio_iommu *iommu = iommu_data;
> > > > +	struct vfio_domain *domain = NULL;
> > > > +	int i = 0, ret = 0;
> > > > +	long retpage;
> > > > +	unsigned long remote_vaddr = 0;
> > > > +	dma_addr_t *pfn = pfn_base;
> > > > +	struct vfio_dma *dma;
> > > > +
> > > > +	if (!iommu || !vaddr || !pfn_base)
> > > > +		return -EINVAL;
> > > > +
> > > > +	mutex_lock(&iommu->lock);
> > > > +
> > > > +	if (!iommu->mediated_domain) {
> > > > +		ret = -EINVAL;
> > > > +		goto pin_done;
> > > > +	}
> > > > +
> > > > +	domain = iommu->mediated_domain;
> > > > +
> > > > +	for (i = 0; i < npage; i++) {
> > > > +		struct vfio_pfn *p, *lpfn;
> > > > +		unsigned long tpfn;
> > > > +		dma_addr_t iova;
> > > > +		long pg_cnt = 1;
> > > > +
> > > > +		iova = vaddr[i] << PAGE_SHIFT;
> > > Dear Kirti:
> > >
> > > Got one question for the vaddr-iova conversion here.
> > > Is this a common rule that can be applied to all architectures?
> > > AFAIK, this is wrong for the s390 case. Or I must miss something...
> >
> > I need more details about the "wrong" part.
> > IIUC, you are thinking about the guest iommu case?
> >
> Dear Neo:
> 
> Sorry for the mistake I made. When I saw 'vaddr', I intuitively thought
> it is an user-space virtual address. Now I saw the comment which says it
> is the "array of guest PFNs".
> 
> After I modify my patches according to the right usage of this
> argument, they worked fine. :>
> 

Maybe renaming 'vaddr' to 'iova_array' would be clearer, given that
elements within this array is called 'iova' later and it can differentiate
from 'remote_vaddr' which means a real 'virtual address'.

Thanks
Kevin
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux