From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhCkA-0004bR-FA for qemu-devel@nongnu.org; Wed, 30 Sep 2015 04:28:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhCk7-0005Ho-Nd for qemu-devel@nongnu.org; Wed, 30 Sep 2015 04:28:06 -0400 References: <1443579237-9636-1-git-send-email-david@gibson.dropbear.id.au> <1443579237-9636-5-git-send-email-david@gibson.dropbear.id.au> From: Laurent Vivier Message-ID: <560B9D0F.2080700@redhat.com> Date: Wed, 30 Sep 2015 10:27:59 +0200 MIME-Version: 1.0 In-Reply-To: <1443579237-9636-5-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv3 4/7] vfio: Record host IOMMU's available IO page sizes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , alex.williamson@redhat.com, pbonzini@redhat.com Cc: thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, abologna@redhat.com, gwshan@linux.vnet.ibm.com, qemu-ppc@nongnu.org On 30/09/2015 04:13, David Gibson wrote: > Depending on the host IOMMU type we determine and record the available page > sizes for IOMMU translation. We'll need this for other validation in > future patches. > > Signed-off-by: David Gibson > Reviewed-by: Thomas Huth > Reviewed-by: Laurent Vivier > --- > hw/vfio/common.c | 13 +++++++++++++ > include/hw/vfio/vfio-common.h | 1 + > 2 files changed, 14 insertions(+) > > diff --git a/hw/vfio/common.c b/hw/vfio/common.c > index 2faf492..f666de2 100644 > --- a/hw/vfio/common.c > +++ b/hw/vfio/common.c > @@ -677,6 +677,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as) > if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU) || > ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU)) { > bool v2 = !!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU); > + struct vfio_iommu_type1_info info; > > ret = ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &fd); > if (ret) { > @@ -702,6 +703,15 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as) > */ > container->min_iova = 0; > container->max_iova = (hwaddr)-1; > + > + /* Assume just 4K IOVA page size */ > + container->iova_pgsizes = 0x1000; > + info.argsz = sizeof(info); > + ret = ioctl(fd, VFIO_IOMMU_GET_INFO, &info); > + /* Ignore errors */ > + if ((ret == 0) && (info.flags & VFIO_IOMMU_INFO_PGSIZES)) { > + container->iova_pgsizes = info.iova_pgsizes; > + } > } else if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU)) { > struct vfio_iommu_spapr_tce_info info; > > @@ -744,6 +754,9 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as) > } > container->min_iova = info.dma32_window_start; > container->max_iova = container->min_iova + info.dma32_window_size - 1; > + > + /* Assume just 4K IOVA pages for now */ > + container->iova_pgsizes = 0x1000; > } else { > error_report("vfio: No available IOMMU models"); > ret = -EINVAL; > diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h > index 27a14c0..f037f3c 100644 > --- a/include/hw/vfio/vfio-common.h > +++ b/include/hw/vfio/vfio-common.h > @@ -71,6 +71,7 @@ typedef struct VFIOContainer { > * future > */ > hwaddr min_iova, max_iova; > + uint64_t iova_pgsizes; > QLIST_HEAD(, VFIOGuestIOMMU) giommu_list; > QLIST_HEAD(, VFIOGroup) group_list; > QLIST_ENTRY(VFIOContainer) next; > Reviewed-by: Laurent Vivier