Patch "vfio/powerpc/spapr_tce: Enforce IOMMU type compatibility check" has been added to the 4.9-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
vfio/powerpc/spapr_tce: Enforce IOMMU type compatibility check
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
vfio-powerpc-spapr_tce-enforce-iommu-type-compatibility-check.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Sun Mar 18 16:55:33 CET 2018
From: Alexey Kardashevskiy <[email protected]>
Date: Fri, 24 Mar 2017 17:44:06 +1100
Subject: vfio/powerpc/spapr_tce: Enforce IOMMU type compatibility check
From: Alexey Kardashevskiy <[email protected]>
[ Upstream commit 1282ba7fc28dbc66c3f0e4aaafaaa228361d1ae5 ]
The existing SPAPR TCE driver advertises both VFIO_SPAPR_TCE_IOMMU and VFIO_SPAPR_TCE_v2_IOMMU types to the userspace and the userspace usually picks the v2.
Normally the userspace would create a container, attach an IOMMU group to it and only then set the IOMMU type (which would normally be v2).
However a specific IOMMU group may not support v2, in other words it may not implement set_window/unset_window/take_ownership/ release_ownership and such a group should not be attached to a v2 container.
This adds extra checks that a new group can do what the selected IOMMU type suggests. The userspace can then test the return value from ioctl(VFIO_SET_IOMMU, VFIO_SPAPR_TCE_v2_IOMMU) and try VFIO_SPAPR_TCE_IOMMU.
--- drivers/vfio/vfio_iommu_spapr_tce.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/vfio/vfio_iommu_spapr_tce.c +8 -0
@@ -1332,8 +1332,16 @@ static int tce_iommu_attach_group(void *if (!table_group->ops || !table_group->ops->take_ownership || !table_group->ops->release_ownership) { +if (container->v2) { + ret = -EPERM ; + goto unlock_exit; + } ret =tce_iommu_take_ownership (container, table_group); }else { +if (!container->v2) { + ret = -EPERM ; + goto unlock_exit; + } ret =tce_iommu_take_ownership_ddw (container, table_group);if (!tce_groups_attached (container) && !container->tables[0 ]) container->def_window_pending = true;
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/vfio-spapr_tce-check-kzalloc-return-when-preregistering-memory.patch queue-4.9/vfio-powerpc-spapr_tce-enforce-iommu-type-compatibility-check.patch