From: Nicolin Chen <nicolinc@nvidia.com>
To: <jgg@nvidia.com>, <robin.murphy@arm.com>, <will@kernel.org>
Cc: <eric.auger@redhat.com>, <kevin.tian@intel.com>,
<baolu.lu@linux.intel.com>, <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>, <kvm@vger.kernel.org>,
<alex.williamson@redhat.com>, <yi.l.liu@intel.com>
Subject: [PATCH v2 03/17] iommufd: Add nesting related data structures for ARM SMMUv3
Date: Tue, 9 May 2023 20:33:23 -0700 [thread overview]
Message-ID: <be0135dac695825fdf56f1cc3f0d2181ff35afa5.1683688960.git.nicolinc@nvidia.com> (raw)
In-Reply-To: <cover.1683688960.git.nicolinc@nvidia.com>
Add the following data structures for corresponding ioctls:
iommu_hwpt_arm_smmuv3 => IOMMUFD_CMD_HWPT_ALLOC
iommu_hwpt_invalidate_arm_smmuv3 => IOMMUFD_CMD_HWPT_INVALIDATE
The iommu_hwpt_arm_smmuv3 is a data structure to allocate an SMMU specific
translation table, either a stage-1 Context Descriptor table or a stage-2
translation table, which would need the user Stream Table Entry or just a
simple S2 flag respectively.
The iommu_hwpt_invalidate_arm_smmuv3 is a data structure for a request of
stage-1 cache invalidations that could be for TLB invalidations, Context
Descriptor invalidations, and Address Translation Cache invalidations. The
data structure contains all the necessary information about a user-space
Command Queue, so the kernel can handle all invalidation commands with a
single batch.
Also, add IOMMU_HWPT_TYPE_ARM_SMMUV3 and IOMMU_HW_INFO_TYPE_ARM_SMMUV3.
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
drivers/iommu/iommufd/main.c | 1 +
include/uapi/linux/iommufd.h | 59 ++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/drivers/iommu/iommufd/main.c b/drivers/iommu/iommufd/main.c
index 7d7c11c1c912..8461b12c43b7 100644
--- a/drivers/iommu/iommufd/main.c
+++ b/drivers/iommu/iommufd/main.c
@@ -288,6 +288,7 @@ union ucmd_buffer {
*/
struct iommu_hwpt_invalidate_intel_vtd vtd;
struct iommu_hwpt_invalidate_request_intel_vtd req_vtd;
+ struct iommu_hwpt_invalidate_arm_smmuv3 smmuv3;
};
struct iommufd_ioctl_op {
diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h
index c8f5801d3439..6845ce6e1e76 100644
--- a/include/uapi/linux/iommufd.h
+++ b/include/uapi/linux/iommufd.h
@@ -354,10 +354,12 @@ struct iommu_vfio_ioas {
* enum iommu_hwpt_type - IOMMU HWPT Type
* @IOMMU_HWPT_TYPE_DEFAULT: default
* @IOMMU_HWPT_TYPE_VTD_S1: Intel VT-d stage-1 page table
+ * @IOMMU_HWPT_TYPE_ARM_SMMUV3: ARM SMMUv3 Translation table
*/
enum iommu_hwpt_type {
IOMMU_HWPT_TYPE_DEFAULT,
IOMMU_HWPT_TYPE_VTD_S1,
+ IOMMU_HWPT_TYPE_ARM_SMMUV3,
};
/**
@@ -413,6 +415,32 @@ struct iommu_hwpt_intel_vtd {
__u32 __reserved;
};
+/**
+ * struct iommu_hwpt_arm_smmuv3 - ARM SMMUv3 specific translation table data
+ *
+ * @flags: Translation table entry attributes
+ * @ste_len: Length of the user Stream Table Entry
+ * @ste_uptr: User pointer to a user Stream Table Entry
+ * @event_len: Length of the returning event
+ * @out_event_uptr: User pointer to a returning event, to report a C_BAD_STE upon
+ * an STE configuration failure
+ *
+ * If event_len or out_event_uptr is unset, remainning at value 0, an STE
+ * configuration failure during the hwpt allocation will not be reported.
+ *
+ * The data structure can be used to allocate a stage-2 translation table, in
+ * which case only IOMMU_SMMUV3_FLAG_S2 would matter, i.e. all other ste_* and
+ * envent_* inputs would be ignored.
+ */
+struct iommu_hwpt_arm_smmuv3 {
+#define IOMMU_SMMUV3_FLAG_S2 (1 << 0) /* if unset, stage-1 */
+ __u64 flags;
+ __u64 ste_len;
+ __aligned_u64 ste_uptr;
+ __u64 event_len;
+ __aligned_u64 out_event_uptr;
+};
+
/**
* struct iommu_hwpt_alloc - ioctl(IOMMU_HWPT_ALLOC)
* @size: sizeof(struct iommu_hwpt_alloc)
@@ -448,6 +476,8 @@ struct iommu_hwpt_intel_vtd {
* +------------------------------+-------------------------------------+-----------+
* | IOMMU_HWPT_TYPE_VTD_S1 | struct iommu_hwpt_intel_vtd | HWPT |
* +------------------------------+-------------------------------------+-----------+
+ * | IOMMU_HWPT_TYPE_ARM_SMMUV3 | struct iommu_hwpt_arm_smmuv3 | IOAS/HWPT |
+ * +------------------------------+-------------------------------------------------+
*/
struct iommu_hwpt_alloc {
__u32 size;
@@ -465,10 +495,12 @@ struct iommu_hwpt_alloc {
/**
* enum iommu_hw_info_type - IOMMU Hardware Info Types
* @IOMMU_HW_INFO_TYPE_INTEL_VTD: Intel VT-d iommu info type
+ * @IOMMU_HW_INFO_TYPE_ARM_SMMUV3: ARM SMMUv3 iommu info type
*/
enum iommu_hw_info_type {
IOMMU_HW_INFO_TYPE_NONE,
IOMMU_HW_INFO_TYPE_INTEL_VTD,
+ IOMMU_HW_INFO_TYPE_ARM_SMMUV3,
};
/**
@@ -603,6 +635,31 @@ struct iommu_hwpt_invalidate_intel_vtd {
__u64 inv_data_uptr;
};
+/**
+ * struct iommu_hwpt_invalidate_arm_smmuv3 - ARM SMMUv3 cahce invalidation info
+ * @cmdq_uptr: User pointer to a user command queue
+ * @cmdq_cons_uptr: User pointer to the consumer index of a user command queue,
+ * allowing kernel to read and also update the consumer index
+ * for a successful call or a failure with a CERROR_ILL code.
+ * This pointer must point to a __u32 type of memory location.
+ * @cmdq_prod: Producer index of user command queues
+ * @cmdq_entry_size: Entry size of a user command queue
+ * @cmdq_log2size: Queue size as log2(entries). Refer to 6.3.25 SMMU_CMDQ_BASE
+ * @__reserved: Must be 0
+ *
+ * Both the consumer index and the producer index should be in their raw forms,
+ * i.e. the raw values out of the SMMU_CMDQ_PROD and SMMU_CMDQ_CONS registers,
+ * which include the WRAP bits also instead of simply the two index values.
+ */
+struct iommu_hwpt_invalidate_arm_smmuv3 {
+ __aligned_u64 cmdq_uptr;
+ __aligned_u64 cmdq_cons_uptr;
+ __u32 cmdq_prod;
+ __u32 cmdq_entry_size;
+ __u32 cmdq_log2size;
+ __u32 __reserved;
+};
+
/**
* struct iommu_hwpt_invalidate - ioctl(IOMMU_HWPT_INVALIDATE)
* @size: sizeof(struct iommu_hwpt_invalidate)
@@ -620,6 +677,8 @@ struct iommu_hwpt_invalidate_intel_vtd {
* +------------------------------+----------------------------------------+
* | IOMMU_HWPT_TYPE_VTD_S1 | struct iommu_hwpt_invalidate_intel_vtd |
* +------------------------------+----------------------------------------+
+ * | IOMMU_HWPT_TYPE_ARM_SMMUV3 | struct iommu_hwpt_invalidate_arm_smmuv3|
+ * +------------------------------+----------------------------------------+
*/
struct iommu_hwpt_invalidate {
__u32 size;
--
2.40.1
next prev parent reply other threads:[~2023-05-10 3:35 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 3:33 [PATCH v2 00/17] Add Nested Translation Support for SMMUv3 Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 01/17] vfio: Remove VFIO_TYPE1_NESTING_IOMMU Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 02/17] iommu/dma: Support MSIs through nested domains Nicolin Chen
2023-05-10 3:33 ` Nicolin Chen [this message]
2023-05-10 3:33 ` [PATCH v2 04/17] iommufd/device: Setup MSI on kernel-managed domains Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 05/17] iommu/arm-smmu-v3: Add arm_smmu_hw_info Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 06/17] iommu/arm-smmu-v3: Add arm_smmu_set/unset_dev_user_data Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 07/17] iommu/arm-smmu-v3: Remove ARM_SMMU_DOMAIN_NESTED Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 08/17] iommu/arm-smmu-v3: Unset corresponding STE fields when s2_cfg is NULL Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 09/17] iommu/arm-smmu-v3: Add STRTAB_STE_0_CFG_NESTED for 2-stage translation Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 10/17] iommu/arm-smmu-v3: Allow ARM_SMMU_DOMAIN_S1 stage to access s2_cfg Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 11/17] iommu/arm-smmu-v3: Add s1dss in struct arm_smmu_s1_cfg Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 12/17] iommu/arm-smmu-v3: Pass in user_cfg to arm_smmu_domain_finalise Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 13/17] iommu/arm-smmu-v3: Add arm_smmu_domain_alloc_user Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 14/17] iommu/arm-smmu-v3: Support IOMMU_DOMAIN_NESTED type of allocations Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 15/17] iommu/arm-smmu-v3: Implement arm_smmu_get_msi_mapping_domain Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 16/17] iommu/arm-smmu-v3: Add CMDQ_OP_TLBI_NH_VAA and CMDQ_OP_TLBI_NH_ALL Nicolin Chen
2023-05-10 3:33 ` [PATCH v2 17/17] iommu/arm-smmu-v3: Add arm_smmu_cache_invalidate_user Nicolin Chen
2023-05-10 8:11 ` [PATCH v2 00/17] Add Nested Translation Support for SMMUv3 Tian, Kevin
2023-05-10 8:41 ` Nicolin Chen
2023-05-15 10:00 ` Zhangfei Gao
2023-05-15 15:57 ` Nicolin Chen
2023-05-16 3:12 ` Zhangfei Gao
2023-05-25 23:42 ` Nicolin Chen
2023-05-26 1:58 ` zhangfei gao
2023-05-26 5:10 ` 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=be0135dac695825fdf56f1cc3f0d2181ff35afa5.1683688960.git.nicolinc@nvidia.com \
--to=nicolinc@nvidia.com \
--cc=alex.williamson@redhat.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=kvm@vger.kernel.org \
--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®