[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210115121342.15093-12-vivek.gautam@arm.com>
Date: Fri, 15 Jan 2021 17:43:38 +0530
From: Vivek Gautam <vivek.gautam@....com>
To: linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
iommu@...ts.linux-foundation.org,
virtualization@...ts.linux-foundation.org
Cc: joro@...tes.org, will.deacon@....com, mst@...hat.com,
robin.murphy@....com, jean-philippe@...aro.org,
eric.auger@...hat.com, alex.williamson@...hat.com,
kevin.tian@...el.com, jacob.jun.pan@...ux.intel.com,
yi.l.liu@...el.com, lorenzo.pieralisi@....com,
shameerali.kolothum.thodi@...wei.com, vivek.gautam@....com
Subject: [PATCH RFC v1 11/15] iommu/virtio: Add headers for binding pasid table in iommu
From: Jean-Philippe Brucker <jean-philippe.brucker@....com>
Add the required UAPI defines for binding pasid tables in virtio-iommu.
This mode allows to hand stage-1 page tables over to the guest.
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@....com>
[Vivek: Refactor to cleanup headers for invalidation]
Signed-off-by: Vivek Gautam <vivek.gautam@....com>
Cc: Joerg Roedel <joro@...tes.org>
Cc: Will Deacon <will.deacon@....com>
Cc: Michael S. Tsirkin <mst@...hat.com>
Cc: Robin Murphy <robin.murphy@....com>
Cc: Jean-Philippe Brucker <jean-philippe@...aro.org>
Cc: Eric Auger <eric.auger@...hat.com>
Cc: Alex Williamson <alex.williamson@...hat.com>
Cc: Kevin Tian <kevin.tian@...el.com>
Cc: Jacob Pan <jacob.jun.pan@...ux.intel.com>
Cc: Liu Yi L <yi.l.liu@...el.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@....com>
Cc: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@...wei.com>
---
include/uapi/linux/virtio_iommu.h | 68 +++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/include/uapi/linux/virtio_iommu.h b/include/uapi/linux/virtio_iommu.h
index 8a0624bab4b2..3481e4a3dd24 100644
--- a/include/uapi/linux/virtio_iommu.h
+++ b/include/uapi/linux/virtio_iommu.h
@@ -16,6 +16,7 @@
#define VIRTIO_IOMMU_F_BYPASS 3
#define VIRTIO_IOMMU_F_PROBE 4
#define VIRTIO_IOMMU_F_MMIO 5
+#define VIRTIO_IOMMU_F_ATTACH_TABLE 6
struct virtio_iommu_range_64 {
__le64 start;
@@ -44,6 +45,8 @@ struct virtio_iommu_config {
#define VIRTIO_IOMMU_T_MAP 0x03
#define VIRTIO_IOMMU_T_UNMAP 0x04
#define VIRTIO_IOMMU_T_PROBE 0x05
+#define VIRTIO_IOMMU_T_ATTACH_TABLE 0x06
+#define VIRTIO_IOMMU_T_INVALIDATE 0x07
/* Status types */
#define VIRTIO_IOMMU_S_OK 0x00
@@ -82,6 +85,37 @@ struct virtio_iommu_req_detach {
struct virtio_iommu_req_tail tail;
};
+struct virtio_iommu_req_attach_table {
+ struct virtio_iommu_req_head head;
+ __le32 domain;
+ __le32 endpoint;
+ __le16 format;
+ __u8 reserved[62];
+ struct virtio_iommu_req_tail tail;
+};
+
+#define VIRTIO_IOMMU_PSTF_ARM_SMMU_V3_LINEAR 0x0
+#define VIRTIO_IOMMU_PSTF_ARM_SMMU_V3_4KL2 0x1
+#define VIRTIO_IOMMU_PSTF_ARM_SMMU_V3_64KL2 0x2
+
+#define VIRTIO_IOMMU_PSTF_ARM_SMMU_V3_DSS_TERM 0x0
+#define VIRTIO_IOMMU_PSTF_ARM_SMMU_V3_DSS_BYPASS 0x1
+#define VIRTIO_IOMMU_PSTF_ARM_SMMU_V3_DSS_0 0x2
+
+/* Arm SMMUv3 PASID Table Descriptor */
+struct virtio_iommu_req_attach_pst_arm {
+ struct virtio_iommu_req_head head;
+ __le32 domain;
+ __le32 endpoint;
+ __le16 format;
+ __u8 s1fmt;
+ __u8 s1dss;
+ __le64 s1contextptr;
+ __le32 s1cdmax;
+ __u8 reserved[48];
+ struct virtio_iommu_req_tail tail;
+};
+
#define VIRTIO_IOMMU_MAP_F_READ (1 << 0)
#define VIRTIO_IOMMU_MAP_F_WRITE (1 << 1)
#define VIRTIO_IOMMU_MAP_F_MMIO (1 << 2)
@@ -188,6 +222,40 @@ struct virtio_iommu_req_probe {
*/
};
+#define VIRTIO_IOMMU_INVAL_G_DOMAIN (1 << 0)
+#define VIRTIO_IOMMU_INVAL_G_PASID (1 << 1)
+#define VIRTIO_IOMMU_INVAL_G_VA (1 << 2)
+
+#define VIRTIO_IOMMU_INV_T_IOTLB (1 << 0)
+#define VIRTIO_IOMMU_INV_T_DEV_IOTLB (1 << 1)
+#define VIRTIO_IOMMU_INV_T_PASID (1 << 2)
+
+#define VIRTIO_IOMMU_INVAL_F_PASID (1 << 0)
+#define VIRTIO_IOMMU_INVAL_F_ARCHID (1 << 1)
+#define VIRTIO_IOMMU_INVAL_F_LEAF (1 << 2)
+
+struct virtio_iommu_req_invalidate {
+ struct virtio_iommu_req_head head;
+ __le16 inv_gran;
+ __le16 inv_type;
+
+ __le16 flags;
+ __u8 reserved1[2];
+ __le32 domain;
+
+ __le32 pasid;
+ __u8 reserved2[4];
+
+ __le64 archid;
+ __le64 virt_start;
+ __le64 nr_pages;
+
+ /* Page size, in nr of bits, typically 12 for 4k, 30 for 2MB, etc.) */
+ __u8 granule;
+ __u8 reserved3[11];
+ struct virtio_iommu_req_tail tail;
+};
+
/* Fault types */
#define VIRTIO_IOMMU_FAULT_R_UNKNOWN 0
#define VIRTIO_IOMMU_FAULT_R_DOMAIN 1
--
2.17.1
Powered by blists - more mailing lists