linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>
Subject: [PATCH v1 02/14] iommufd: Add nesting related data structures for ARM SMMUv3
Date: Thu, 9 Mar 2023 02:53:38 -0800	[thread overview]
Message-ID: <364cfbe5b228ab178093db2de13fa3accf7a6120.1678348754.git.nicolinc@nvidia.com> (raw)
In-Reply-To: <cover.1678348754.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

Also, add IOMMU_HW_INFO_TYPE_ARM_SMMUV3 and IOMMU_PGTBL_TYPE_ARM_SMMUV3_S1
to the header and corresponding type/size arrays.

Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 drivers/iommu/iommufd/hw_pagetable.c |  4 +++
 drivers/iommu/iommufd/main.c         |  1 +
 include/uapi/linux/iommufd.h         | 50 ++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+)

diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c
index 8f9985bddeeb..5e798b2f9a3a 100644
--- a/drivers/iommu/iommufd/hw_pagetable.c
+++ b/drivers/iommu/iommufd/hw_pagetable.c
@@ -173,6 +173,7 @@ iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas,
 static const size_t iommufd_hwpt_alloc_data_size[] = {
 	[IOMMU_HWPT_TYPE_DEFAULT] = 0,
 	[IOMMU_HWPT_TYPE_VTD_S1] = sizeof(struct iommu_hwpt_intel_vtd),
+	[IOMMU_HWPT_TYPE_ARM_SMMUV3] = sizeof(struct iommu_hwpt_arm_smmuv3),
 };
 
 /*
@@ -183,6 +184,8 @@ const u64 iommufd_hwpt_type_bitmaps[] =  {
 	[IOMMU_HW_INFO_TYPE_DEFAULT] = BIT_ULL(IOMMU_HWPT_TYPE_DEFAULT),
 	[IOMMU_HW_INFO_TYPE_INTEL_VTD] = BIT_ULL(IOMMU_HWPT_TYPE_DEFAULT) |
 					 BIT_ULL(IOMMU_HWPT_TYPE_VTD_S1),
+	[IOMMU_HW_INFO_TYPE_ARM_SMMUV3] = BIT_ULL(IOMMU_HWPT_TYPE_DEFAULT) |
+					  BIT_ULL(IOMMU_HWPT_TYPE_ARM_SMMUV3),
 };
 
 /* Return true if type is supported, otherwise false */
@@ -329,6 +332,7 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd)
  */
 static const size_t iommufd_hwpt_invalidate_info_size[] = {
 	[IOMMU_HWPT_TYPE_VTD_S1] = sizeof(struct iommu_hwpt_invalidate_intel_vtd),
+	[IOMMU_HWPT_TYPE_ARM_SMMUV3] = sizeof(struct iommu_hwpt_invalidate_arm_smmuv3),
 };
 
 int iommufd_hwpt_invalidate(struct iommufd_ucmd *ucmd)
diff --git a/drivers/iommu/iommufd/main.c b/drivers/iommu/iommufd/main.c
index 514db4c26927..0b0097af7c86 100644
--- a/drivers/iommu/iommufd/main.c
+++ b/drivers/iommu/iommufd/main.c
@@ -280,6 +280,7 @@ union ucmd_buffer {
 	 * path.
 	 */
 	struct iommu_hwpt_invalidate_intel_vtd 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 2a6c326391b2..0d5551b1b2be 100644
--- a/include/uapi/linux/iommufd.h
+++ b/include/uapi/linux/iommufd.h
@@ -352,10 +352,13 @@ 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 stage-1 Context Descriptor
+ *                              table
  */
 enum iommu_hwpt_type {
 	IOMMU_HWPT_TYPE_DEFAULT,
 	IOMMU_HWPT_TYPE_VTD_S1,
+	IOMMU_HWPT_TYPE_ARM_SMMUV3,
 };
 
 /**
@@ -411,6 +414,28 @@ struct iommu_hwpt_intel_vtd {
 	__u32 __reserved;
 };
 
+/**
+ * struct iommu_hwpt_arm_smmuv3 - ARM SMMUv3 specific page table data
+ *
+ * @flags: page table entry attributes
+ * @s2vmid: Virtual machine identifier
+ * @s1ctxptr: Stage-1 context descriptor pointer
+ * @s1cdmax: Number of CDs pointed to by s1ContextPtr
+ * @s1fmt: Stage-1 Format
+ * @s1dss: Default substream
+ */
+struct iommu_hwpt_arm_smmuv3 {
+#define IOMMU_SMMUV3_FLAG_S2	(1 << 0) /* if unset, stage-1 */
+#define IOMMU_SMMUV3_FLAG_VMID	(1 << 1) /* vmid override */
+	__u64 flags;
+	__u32 s2vmid;
+	__u32 __reserved;
+	__u64 s1ctxptr;
+	__u64 s1cdmax;
+	__u64 s1fmt;
+	__u64 s1dss;
+};
+
 /**
  * struct iommu_hwpt_alloc - ioctl(IOMMU_HWPT_ALLOC)
  * @size: sizeof(struct iommu_hwpt_alloc)
@@ -446,6 +471,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;
@@ -463,10 +490,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_DEFAULT,
 	IOMMU_HW_INFO_TYPE_INTEL_VTD,
+	IOMMU_HW_INFO_TYPE_ARM_SMMUV3,
 };
 
 /**
@@ -591,6 +620,25 @@ struct iommu_hwpt_invalidate_intel_vtd {
 	__u64 nb_granules;
 };
 
+/**
+ * struct iommu_hwpt_invalidate_arm_smmuv3 - ARM SMMUv3 cahce invalidation info
+ * @flags: boolean attributes of cache invalidation command
+ * @opcode: opcode of cache invalidation command
+ * @ssid: SubStream ID
+ * @granule_size: page/block size of the mapping in bytes
+ * @range: IOVA range to invalidate
+ */
+struct iommu_hwpt_invalidate_arm_smmuv3 {
+#define IOMMU_SMMUV3_CMDQ_TLBI_VA_LEAF	(1 << 0)
+	__u64 flags;
+	__u8 opcode;
+	__u8 padding[3];
+	__u32 asid;
+	__u32 ssid;
+	__u32 granule_size;
+	struct iommu_iova_range range;
+};
+
 /**
  * struct iommu_hwpt_invalidate - ioctl(IOMMU_HWPT_INVALIDATE)
  * @size: sizeof(struct iommu_hwpt_invalidate)
@@ -609,6 +657,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.39.2


  parent reply	other threads:[~2023-03-09 10:55 UTC|newest]

Thread overview: 165+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09 10:53 [PATCH v1 00/14] Add Nested Translation Support for SMMUv3 Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 01/14] iommu: Add iommu_get_unmanaged_domain helper Nicolin Chen
2023-03-09 12:51   ` Robin Murphy
2023-03-09 14:19     ` Jason Gunthorpe
2023-03-09 19:04       ` Robin Murphy
2023-03-10  0:23         ` Jason Gunthorpe
2023-03-10  8:41     ` Eric Auger
2023-03-10 15:55       ` Jason Gunthorpe
2023-03-16  1:21         ` Nicolin Chen
2023-03-16 18:42           ` Robin Murphy
2023-03-16 20:01             ` Nicolin Chen
2023-03-20 12:51             ` Jason Gunthorpe
2023-03-10 10:14   ` Eric Auger
2023-03-10 15:33     ` Jason Gunthorpe
2023-03-10 15:44       ` Shameerali Kolothum Thodi
2023-03-10 15:56         ` Jason Gunthorpe
2023-03-10 16:07           ` Shameerali Kolothum Thodi
2023-03-10 16:21             ` Jason Gunthorpe
2023-03-10 16:30               ` Shameerali Kolothum Thodi
2023-03-10 17:03                 ` Jason Gunthorpe
2023-03-22 16:07                   ` Eric Auger
2023-03-22 17:02                     ` Jason Gunthorpe
2023-03-22 17:41                       ` Eric Auger
2023-03-22 18:07                         ` Jason Gunthorpe
2023-03-16 19:51                 ` Nicolin Chen
2023-03-16 19:56                   ` Shameerali Kolothum Thodi
2023-03-22 15:44                     ` Eric Auger
2023-03-09 10:53 ` Nicolin Chen [this message]
2023-03-09 13:42   ` [PATCH v1 02/14] iommufd: Add nesting related data structures for ARM SMMUv3 Jean-Philippe Brucker
2023-03-09 14:48     ` Jason Gunthorpe
2023-03-09 18:26       ` Jean-Philippe Brucker
2023-03-09 21:01         ` Jason Gunthorpe
2023-03-10 12:16           ` Jean-Philippe Brucker
2023-03-10 14:52           ` Robin Murphy
2023-03-10 15:25             ` Jason Gunthorpe
2023-03-10 15:57               ` Robin Murphy
2023-03-10 16:03                 ` Jason Gunthorpe
2023-03-17 10:10                   ` Tian, Kevin
2023-03-17 10:04                 ` Tian, Kevin
2023-03-10  4:50       ` Nicolin Chen
2023-03-10 12:54         ` Jean-Philippe Brucker
2023-03-10 14:00           ` Jason Gunthorpe
2023-03-10 16:06         ` Jason Gunthorpe
2023-03-16  0:59           ` Nicolin Chen
2023-03-09 15:26     ` Shameerali Kolothum Thodi
2023-03-09 15:40       ` Jason Gunthorpe
2023-03-09 15:51         ` Shameerali Kolothum Thodi
2023-03-09 15:59           ` Jason Gunthorpe
2023-03-09 16:07             ` Shameerali Kolothum Thodi
2023-03-10  5:26               ` Nicolin Chen
2023-03-10  5:36                 ` Nicolin Chen
2023-03-10 12:55                   ` Jason Gunthorpe
2023-03-10  5:18         ` Nicolin Chen
2023-03-10  5:04     ` Nicolin Chen
2023-03-10 11:33     ` Eric Auger
2023-03-10 12:51       ` Jason Gunthorpe
2023-03-17 10:17         ` Tian, Kevin
2023-03-09 10:53 ` [PATCH v1 03/14] iommufd/device: Setup MSI on kernel-managed domains Nicolin Chen
2023-03-10 16:45   ` Eric Auger
2023-03-11  0:17     ` Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 04/14] iommu/arm-smmu-v3: Add arm_smmu_hw_info Nicolin Chen
2023-03-09 13:03   ` Robin Murphy
2023-03-10  1:17     ` Nicolin Chen
2023-03-10 15:28       ` Robin Murphy
2023-03-16  0:13         ` Nicolin Chen
2023-03-16 15:19           ` Robin Murphy
2023-03-16 20:06             ` Nicolin Chen
2023-04-12  7:47               ` Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 05/14] iommu/arm-smmu-v3: Remove ARM_SMMU_DOMAIN_NESTED Nicolin Chen
2023-03-10 16:39   ` Eric Auger
2023-03-10 17:05     ` Jason Gunthorpe
2023-03-11  0:24       ` Nicolin Chen
2023-03-11  0:23     ` Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 06/14] iommu/arm-smmu-v3: Unset corresponding STE fields when s2_cfg is NULL Nicolin Chen
2023-03-09 13:13   ` Robin Murphy
2023-03-09 18:24     ` Shameerali Kolothum Thodi
2023-03-10  1:54       ` Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 07/14] iommu/arm-smmu-v3: Add STRTAB_STE_0_CFG_NESTED for 2-stage translation Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 08/14] iommu/arm-smmu-v3: Prepare for nested domain support Nicolin Chen
2023-03-10 20:39   ` Robin Murphy
2023-03-11 12:40     ` Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 09/14] iommu/arm-smmu-v3: Implement arm_smmu_get_unmanaged_domain Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 10/14] iommu/arm-smmu-v3: Pass in user_cfg to arm_smmu_domain_finalise Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 11/14] iommu/arm-smmu-v3: Add arm_smmu_domain_alloc_user Nicolin Chen
2023-03-24 15:28   ` Eric Auger
2023-03-24 17:40     ` Nicolin Chen
2023-03-24 17:50       ` Jason Gunthorpe
2023-03-24 18:00         ` Nicolin Chen
2023-03-24 15:33   ` Eric Auger
2023-03-24 17:43     ` Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 12/14] iommu/arm-smmu-v3: Support IOMMU_DOMAIN_NESTED type of allocations Nicolin Chen
2023-03-09 13:20   ` Robin Murphy
2023-03-09 14:28     ` Robin Murphy
2023-03-10  1:34       ` Nicolin Chen
2023-03-24 15:44   ` Eric Auger
2023-03-24 16:30     ` Jason Gunthorpe
2023-03-24 17:50     ` Nicolin Chen
2023-03-24 17:51       ` Jason Gunthorpe
2023-03-24 17:55         ` Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 13/14] iommu/arm-smmu-v3: Add CMDQ_OP_TLBI_NH_VAA and CMDQ_OP_TLBI_NH_ALL Nicolin Chen
2023-03-09 13:44   ` Robin Murphy
2023-03-10  1:19     ` Nicolin Chen
2023-03-09 10:53 ` [PATCH v1 14/14] iommu/arm-smmu-v3: Add arm_smmu_cache_invalidate_user Nicolin Chen
2023-03-09 14:49   ` Robin Murphy
2023-03-09 15:31     ` Jason Gunthorpe
2023-03-10  4:20       ` Nicolin Chen
2023-03-10 16:19         ` Jason Gunthorpe
2023-03-11 11:56           ` Nicolin Chen
2023-03-11 12:53             ` Nicolin Chen
2023-03-20 13:03             ` Jason Gunthorpe
2023-03-20 15:56               ` Nicolin Chen
2023-03-20 16:04                 ` Jason Gunthorpe
2023-03-20 16:59                   ` Nicolin Chen
2023-03-20 18:45                     ` Jason Gunthorpe
2023-03-20 21:22                       ` Nicolin Chen
2023-03-20 22:19                         ` Jason Gunthorpe
2023-03-22 20:57                           ` Nicolin Chen
2023-03-23 12:17                             ` Jason Gunthorpe
2023-03-17  9:41           ` Tian, Kevin
2023-03-17 14:24             ` Nicolin Chen
2023-03-20 12:59             ` Jason Gunthorpe
2023-03-20 16:12               ` Nicolin Chen
2023-03-20 18:00                 ` Jason Gunthorpe
2023-03-21  8:34                   ` Tian, Kevin
2023-03-21 11:48                     ` Jason Gunthorpe
2023-03-22  6:42                       ` Nicolin Chen
2023-03-22 12:43                         ` Jason Gunthorpe
2023-03-22 17:11                           ` Nicolin Chen
2023-03-22 17:28                             ` Jason Gunthorpe
2023-03-22 19:21                               ` Nicolin Chen
2023-03-22 19:41                                 ` Jason Gunthorpe
2023-03-22 20:43                                   ` Nicolin Chen
2023-03-23 12:16                                     ` Jason Gunthorpe
2023-03-23 18:13                                       ` Nicolin Chen
2023-03-23 18:27                                         ` Jason Gunthorpe
2023-03-24  9:02                         ` Tian, Kevin
2023-03-24 14:57                           ` Jason Gunthorpe
2023-03-24 17:35                             ` Nicolin Chen
2023-03-28  3:03                               ` Tian, Kevin
2023-03-24  8:47                       ` Tian, Kevin
2023-03-24 14:44                         ` Jason Gunthorpe
2023-03-28  2:48                           ` Tian, Kevin
2023-03-28 12:26                             ` Jason Gunthorpe
2023-03-31  8:09                               ` Tian, Kevin
2023-03-17  9:24       ` Tian, Kevin
2023-03-10  3:51     ` Nicolin Chen
2023-03-10 17:53       ` Robin Murphy
2023-03-10 18:49         ` Jason Gunthorpe
2023-03-11 12:38         ` Nicolin Chen
2023-03-13 13:07           ` Robin Murphy
2023-03-16  0:01             ` Nicolin Chen
2023-03-16 14:58               ` Robin Murphy
2023-03-16 21:09                 ` Nicolin Chen
2023-03-20  1:32                   ` Nicolin Chen
2023-03-20 13:11                     ` Jason Gunthorpe
2023-03-20 15:28                       ` Nicolin Chen
2023-03-20 16:01                         ` Jason Gunthorpe
2023-03-20 16:35                           ` Nicolin Chen
2023-03-20 18:07                             ` Jason Gunthorpe
2023-03-20 20:46                               ` Nicolin Chen
2023-03-20 22:14                                 ` Jason Gunthorpe
2023-03-22  5:14                                   ` Nicolin Chen
2023-03-24  8:55                                     ` Tian, Kevin
2023-03-17  9:47     ` Tian, Kevin
2023-03-17 14:16       ` 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=364cfbe5b228ab178093db2de13fa3accf7a6120.1678348754.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 \
    /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;
as well as URLs for NNTP newsgroup(s).