[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210919063848.1476776-13-yi.l.liu@intel.com>
Date: Sun, 19 Sep 2021 14:38:40 +0800
From: Liu Yi L <yi.l.liu@...el.com>
To: alex.williamson@...hat.com, jgg@...dia.com, hch@....de,
jasowang@...hat.com, joro@...tes.org
Cc: jean-philippe@...aro.org, kevin.tian@...el.com, parav@...lanox.com,
lkml@...ux.net, pbonzini@...hat.com, lushenming@...wei.com,
eric.auger@...hat.com, corbet@....net, ashok.raj@...el.com,
yi.l.liu@...el.com, yi.l.liu@...ux.intel.com, jun.j.tian@...el.com,
hao.wu@...el.com, dave.jiang@...el.com,
jacob.jun.pan@...ux.intel.com, kwankhede@...dia.com,
robin.murphy@....com, kvm@...r.kernel.org,
iommu@...ts.linux-foundation.org, dwmw2@...radead.org,
linux-kernel@...r.kernel.org, baolu.lu@...ux.intel.com,
david@...son.dropbear.id.au, nicolinc@...dia.com
Subject: [RFC 12/20] iommu/iommufd: Add IOMMU_CHECK_EXTENSION
As aforementioned, userspace should check extension for what formats
can be specified when allocating an IOASID. This patch adds such
interface for userspace. In this RFC, iommufd reports EXT_MAP_TYPE1V2
support and no no-snoop support yet.
Signed-off-by: Liu Yi L <yi.l.liu@...el.com>
---
drivers/iommu/iommufd/iommufd.c | 7 +++++++
include/uapi/linux/iommu.h | 27 +++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/drivers/iommu/iommufd/iommufd.c b/drivers/iommu/iommufd/iommufd.c
index 4839f128b24a..e45d76359e34 100644
--- a/drivers/iommu/iommufd/iommufd.c
+++ b/drivers/iommu/iommufd/iommufd.c
@@ -306,6 +306,13 @@ static long iommufd_fops_unl_ioctl(struct file *filep,
return ret;
switch (cmd) {
+ case IOMMU_CHECK_EXTENSION:
+ switch (arg) {
+ case EXT_MAP_TYPE1V2:
+ return 1;
+ default:
+ return 0;
+ }
case IOMMU_DEVICE_GET_INFO:
ret = iommufd_get_device_info(ictx, arg);
break;
diff --git a/include/uapi/linux/iommu.h b/include/uapi/linux/iommu.h
index 5cbd300eb0ee..49731be71213 100644
--- a/include/uapi/linux/iommu.h
+++ b/include/uapi/linux/iommu.h
@@ -14,6 +14,33 @@
#define IOMMU_TYPE (';')
#define IOMMU_BASE 100
+/*
+ * IOMMU_CHECK_EXTENSION - _IO(IOMMU_TYPE, IOMMU_BASE + 0)
+ *
+ * Check whether an uAPI extension is supported.
+ *
+ * It's unlikely that all planned capabilities in IOMMU fd will be ready
+ * in one breath. User should check which uAPI extension is supported
+ * according to its intended usage.
+ *
+ * A rough list of possible extensions may include:
+ *
+ * - EXT_MAP_TYPE1V2 for vfio type1v2 map semantics;
+ * - EXT_DMA_NO_SNOOP for no-snoop DMA support;
+ * - EXT_MAP_NEWTYPE for an enhanced map semantics;
+ * - EXT_MULTIDEV_GROUP for 1:N iommu group;
+ * - EXT_IOASID_NESTING for what the name stands;
+ * - EXT_USER_PAGE_TABLE for user managed page table;
+ * - EXT_USER_PASID_TABLE for user managed PASID table;
+ * - EXT_DIRTY_TRACKING for tracking pages dirtied by DMA;
+ * - ...
+ *
+ * Return: 0 if not supported, 1 if supported.
+ */
+#define EXT_MAP_TYPE1V2 1
+#define EXT_DMA_NO_SNOOP 2
+#define IOMMU_CHECK_EXTENSION _IO(IOMMU_TYPE, IOMMU_BASE + 0)
+
/*
* IOMMU_DEVICE_GET_INFO - _IOR(IOMMU_TYPE, IOMMU_BASE + 1,
* struct iommu_device_info)
--
2.25.1
Powered by blists - more mailing lists