From: Nicolin Chen <nicolinc@nvidia.com>
To: <jgg@nvidia.com>, <kevin.tian@intel.com>
Cc: <robin.murphy@arm.com>, <eric.auger@redhat.com>,
<yi.l.liu@intel.com>, <baolu.lu@linux.intel.com>,
<will@kernel.org>, <joro@8bytes.org>,
<shameerali.kolothum.thodi@huawei.com>,
<jean-philippe@linaro.org>,
<linux-arm-kernel@lists.infradead.org>, <iommu@lists.linux.dev>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH v5 1/4] iommu: Add set/unset_dev_user_data ops
Date: Thu, 27 Jul 2023 14:09:40 -0700 [thread overview]
Message-ID: <6772ccfb71cd1eb3d402d82836ae7e98a853a793.1690487690.git.nicolinc@nvidia.com> (raw)
In-Reply-To: <cover.1690487690.git.nicolinc@nvidia.com>
The device behind an IOMMU might be used in the user space by a VM. So, it
might have some user space data. For example, a device behind an SMMU has
a static stream ID. In a virtualization use case, both a host environment
and a guest environment have their own Stream IDs. A link (a lookup table)
between the physical Stream ID and the virtual (user) Stream ID is needed
when the host handles the user cache invalidation commands.
Add a pair of new ops to allow user space to forward user_data of a device
via iommufd, and a new dev_user_data_len for data structure sanity done by
the iommufd core.
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
include/linux/iommu.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index e4835230d5f0..231920efab84 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -281,6 +281,15 @@ union iommu_domain_user_data {
* @remove_dev_pasid: Remove any translation configurations of a specific
* pasid, so that any DMA transactions with this pasid
* will be blocked by the hardware.
+ * @set/unset_dev_user_data: set/unset an iommu specific device data from user
+ * space. The user device data info will be used by
+ * the driver to take care of user space requests.
+ * The device data structure must be defined in
+ * include/uapi/linux/iommufd.h.
+ * @dev_user_data_len: Length of the device data from user space (in bytes),
+ * simply the "sizeof" the data structure defined in the
+ * include/uapi/linux/iommufd.h. This is used by iommufd
+ * core to run a data length validation.
* @hw_info_type: One of enum iommu_hw_info_type defined in
* include/uapi/linux/iommufd.h. It is used to tag the type
* of data returned by .hw_info callback. The drivers that
@@ -326,6 +335,10 @@ struct iommu_ops {
int (*def_domain_type)(struct device *dev);
void (*remove_dev_pasid)(struct device *dev, ioasid_t pasid);
+ int (*set_dev_user_data)(struct device *dev, const void *user_data);
+ void (*unset_dev_user_data)(struct device *dev);
+ size_t dev_user_data_len;
+
const struct iommu_domain_ops *default_domain_ops;
enum iommu_hw_info_type hw_info_type;
unsigned long pgsize_bitmap;
--
2.41.0
next prev parent reply other threads:[~2023-07-27 21:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-27 21:09 [PATCH v5 0/4] Add set_dev_data and unset_dev_data support Nicolin Chen
2023-07-27 21:09 ` Nicolin Chen [this message]
2023-07-27 21:09 ` [PATCH v5 2/4] iommufd: Add IOMMUFD_CMD_SET_DEV_DATA and IOMMUFD_CMD_UNSET_DEV_DATA Nicolin Chen
2023-07-27 21:09 ` [PATCH v5 3/4] iommufd/selftest: Add IOMMU_TEST_OP_DEV_CHECK_DATA Nicolin Chen
2023-07-27 21:09 ` [PATCH v5 4/4] iommufd/selftest: Add coverage for IOMMU_SET/UNSET_DEV_DATA Nicolin Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6772ccfb71cd1eb3d402d82836ae7e98a853a793.1690487690.git.nicolinc@nvidia.com \
--to=nicolinc@nvidia.com \
--cc=baolu.lu@linux.intel.com \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jean-philippe@linaro.org \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=will@kernel.org \
--cc=yi.l.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®