[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [Qemu-devel] [RFC PATCH 04/10] vfio: Record host IOMMU's
From: |
Thomas Huth |
Subject: |
Re: [Qemu-ppc] [Qemu-devel] [RFC PATCH 04/10] vfio: Record host IOMMU's available IO page sizes |
Date: |
Wed, 23 Sep 2015 12:29:24 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 17/09/15 15:09, 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 <address@hidden>
> ---
> 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 c37f1a1..daaac48 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -680,6 +680,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) {
> @@ -705,6 +706,15 @@ static int vfio_connect_container(VFIOGroup *group,
> AddressSpace *as)
> */
> container->iommu_data.min_iova = 0;
> container->iommu_data.max_iova = (hwaddr)-1;
> +
> + /* Assume just 4K IOVA page size */
> + container->iommu_data.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->iommu_data.iova_pgsizes = info.iova_pgsizes;
> + }
> } else if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU)) {
> struct vfio_iommu_spapr_tce_info info;
>
> @@ -748,6 +758,9 @@ static int vfio_connect_container(VFIOGroup *group,
> AddressSpace *as)
> container->iommu_data.min_iova = info.dma32_window_start;
> container->iommu_data.max_iova = container->iommu_data.min_iova
> + info.dma32_window_size - 1;
> +
> + /* Assume just 4K IOVA pages for now */
> + container->iommu_data.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 88ec213..c09db6d 100644
> --- a/include/hw/vfio/vfio-common.h
> +++ b/include/hw/vfio/vfio-common.h
> @@ -77,6 +77,7 @@ typedef struct VFIOContainer {
> * that in future
> */
> hwaddr min_iova, max_iova;
> + uint64_t iova_pgsizes;
> } iommu_data;
> QLIST_HEAD(, VFIOGuestIOMMU) giommu_list;
> QLIST_HEAD(, VFIOGroup) group_list;
Reviewed-by: Thomas Huth <address@hidden>
- Re: [Qemu-ppc] [RFC PATCH 05/10] memory: Allow replay of IOMMU mapping notifications, (continued)
[Qemu-ppc] [RFC PATCH 06/10] vfio: Allow hotplug of containers onto existing guest IOMMU mappings, David Gibson, 2015/09/17
Re: [Qemu-ppc] [RFC PATCH 06/10] vfio: Allow hotplug of containers onto existing guest IOMMU mappings, Laurent Vivier, 2015/09/23
[Qemu-ppc] [RFC PATCH 10/10] spapr_pci: Allow VFIO devices to work on the normal PCI host bridge, David Gibson, 2015/09/17
[Qemu-ppc] [RFC PATCH 04/10] vfio: Record host IOMMU's available IO page sizes, David Gibson, 2015/09/17
[Qemu-ppc] [RFC PATCH 08/10] spapr_iommu: Rename vfio_accel parameter, David Gibson, 2015/09/17
Re: [Qemu-ppc] [RFC PATCH 00/10] pseries: Allow VFIO devices on spapr-pci-host-bridge, Alex Williamson, 2015/09/17
Re: [Qemu-ppc] [Qemu-devel] [RFC PATCH 00/10] pseries: Allow VFIO devices on spapr-pci-host-bridge, Thomas Huth, 2015/09/23
Re: [Qemu-ppc] [RFC PATCH 00/10] pseries: Allow VFIO devices on spapr-pci-host-bridge, Laurent Vivier, 2015/09/23