summaryrefslogtreecommitdiffstats
path: root/drivers/iommu/iommufd/device.c
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@nvidia.com>2022-11-29 21:29:41 +0100
committerJason Gunthorpe <jgg@nvidia.com>2022-12-01 01:16:49 +0100
commit52f528583bb395495f7dd35e6e4d548bccbf8a73 (patch)
tree4f8a4784a2352553acd8895585730ef3924daa5c /drivers/iommu/iommufd/device.c
parentiommufd: Add some fault injection points (diff)
downloadlinux-52f528583bb395495f7dd35e6e4d548bccbf8a73.tar.xz
linux-52f528583bb395495f7dd35e6e4d548bccbf8a73.zip
iommufd: Add additional invariant assertions
These are on performance paths so we protect them using the CONFIG_IOMMUFD_TEST to not take a hit during normal operation. These are useful when running the test suite and syzkaller to find data structure inconsistencies early. Link: https://lore.kernel.org/r/18-v6-a196d26f289e+11787-iommufd_jgg@nvidia.com Tested-by: Yi Liu <yi.l.liu@intel.com> Tested-by: Matthew Rosato <mjrosato@linux.ibm.com> # s390 Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/iommu/iommufd/device.c')
-rw-r--r--drivers/iommu/iommufd/device.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 67ce36152e8a..dd2a415b603e 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -625,6 +625,11 @@ int iommufd_access_pin_pages(struct iommufd_access *access, unsigned long iova,
struct iopt_area *area;
int rc;
+ /* Driver's ops don't support pin_pages */
+ if (IS_ENABLED(CONFIG_IOMMUFD_TEST) &&
+ WARN_ON(access->iova_alignment != PAGE_SIZE || !access->ops->unmap))
+ return -EINVAL;
+
if (!length)
return -EINVAL;
if (check_add_overflow(iova, length - 1, &last_iova))