151 lines
5.8 KiB
Diff
151 lines
5.8 KiB
Diff
|
|
From 0978556247d968ffc83beff3b2611c93fd9b6b13 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Yi Liu <yi.l.liu@intel.com>
|
||
|
|
Date: Thu, 12 Sep 2024 00:17:31 -0700
|
||
|
|
Subject: [PATCH] backend/iommufd: Report PASID capability
|
||
|
|
|
||
|
|
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
|
||
|
|
---
|
||
|
|
backends/iommufd.c | 4 +++-
|
||
|
|
hw/arm/smmu-common.c | 4 ++--
|
||
|
|
hw/arm/smmuv3.c | 4 +++-
|
||
|
|
hw/vfio/iommufd.c | 4 +++-
|
||
|
|
include/hw/arm/smmu-common.h | 2 +-
|
||
|
|
include/sysemu/host_iommu_device.h | 1 +
|
||
|
|
include/sysemu/iommufd.h | 3 ++-
|
||
|
|
7 files changed, 15 insertions(+), 7 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/backends/iommufd.c b/backends/iommufd.c
|
||
|
|
index e9ce82297b..4f5df63331 100644
|
||
|
|
--- a/backends/iommufd.c
|
||
|
|
+++ b/backends/iommufd.c
|
||
|
|
@@ -326,7 +326,8 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be,
|
||
|
|
|
||
|
|
bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid,
|
||
|
|
uint32_t *type, void *data, uint32_t len,
|
||
|
|
- uint64_t *caps, Error **errp)
|
||
|
|
+ uint64_t *caps, uint8_t *max_pasid_log2,
|
||
|
|
+ Error **errp)
|
||
|
|
{
|
||
|
|
struct iommu_hw_info info = {
|
||
|
|
.size = sizeof(info),
|
||
|
|
@@ -344,6 +345,7 @@ bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid,
|
||
|
|
*type = info.out_data_type;
|
||
|
|
g_assert(caps);
|
||
|
|
*caps = info.out_capabilities;
|
||
|
|
+ *max_pasid_log2 = info.out_max_pasid_log2;
|
||
|
|
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
|
||
|
|
index c382fa16e5..e7028bd4ec 100644
|
||
|
|
--- a/hw/arm/smmu-common.c
|
||
|
|
+++ b/hw/arm/smmu-common.c
|
||
|
|
@@ -853,7 +853,7 @@ SMMUDevice *smmu_find_sdev(SMMUState *s, uint32_t sid)
|
||
|
|
|
||
|
|
/* IOMMUFD helpers */
|
||
|
|
int smmu_dev_get_info(SMMUDevice *sdev, uint32_t *data_type,
|
||
|
|
- uint32_t data_len, void *data)
|
||
|
|
+ uint32_t data_len, uint8_t *pasid, void *data)
|
||
|
|
{
|
||
|
|
uint64_t caps;
|
||
|
|
|
||
|
|
@@ -863,7 +863,7 @@ int smmu_dev_get_info(SMMUDevice *sdev, uint32_t *data_type,
|
||
|
|
|
||
|
|
return !iommufd_backend_get_device_info(sdev->idev->iommufd,
|
||
|
|
sdev->idev->devid, data_type, data,
|
||
|
|
- data_len, &caps, NULL);
|
||
|
|
+ data_len, &caps, pasid, NULL);
|
||
|
|
}
|
||
|
|
|
||
|
|
void smmu_dev_uninstall_nested_ste(SMMUDevice *sdev, bool abort)
|
||
|
|
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
||
|
|
index 30c0ae4c3b..0ca0e96fcc 100644
|
||
|
|
--- a/hw/arm/smmuv3.c
|
||
|
|
+++ b/hw/arm/smmuv3.c
|
||
|
|
@@ -264,6 +264,7 @@ static void smmuv3_nested_init_regs(SMMUv3State *s)
|
||
|
|
SMMUDevice *sdev;
|
||
|
|
uint32_t data_type;
|
||
|
|
uint32_t val;
|
||
|
|
+ uint8_t pasid;
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
if (!bs->nested || !bs->viommu) {
|
||
|
|
@@ -280,7 +281,8 @@ static void smmuv3_nested_init_regs(SMMUv3State *s)
|
||
|
|
goto out;
|
||
|
|
}
|
||
|
|
|
||
|
|
- ret = smmu_dev_get_info(sdev, &data_type, sizeof(sdev->info), &sdev->info);
|
||
|
|
+ ret = smmu_dev_get_info(sdev, &data_type, sizeof(sdev->info), &pasid,
|
||
|
|
+ &sdev->info);
|
||
|
|
if (ret) {
|
||
|
|
error_report("failed to get SMMU device info");
|
||
|
|
return;
|
||
|
|
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
|
||
|
|
index c0eb87c78c..a108beda29 100644
|
||
|
|
--- a/hw/vfio/iommufd.c
|
||
|
|
+++ b/hw/vfio/iommufd.c
|
||
|
|
@@ -871,18 +871,20 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
|
||
|
|
struct iommu_hw_info_vtd vtd;
|
||
|
|
} data;
|
||
|
|
uint64_t hw_caps;
|
||
|
|
+ uint8_t pasids;
|
||
|
|
|
||
|
|
hiod->agent = opaque;
|
||
|
|
|
||
|
|
if (!iommufd_backend_get_device_info(vdev->iommufd, vdev->devid,
|
||
|
|
&type, &data, sizeof(data),
|
||
|
|
- &hw_caps, errp)) {
|
||
|
|
+ &hw_caps, &pasids, errp)) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
hiod->name = g_strdup(vdev->name);
|
||
|
|
caps->type = type;
|
||
|
|
caps->hw_caps = hw_caps;
|
||
|
|
+ caps->max_pasid_log2 = pasids;
|
||
|
|
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
|
||
|
|
index 087a11efc7..8ae33c3753 100644
|
||
|
|
--- a/include/hw/arm/smmu-common.h
|
||
|
|
+++ b/include/hw/arm/smmu-common.h
|
||
|
|
@@ -276,7 +276,7 @@ void smmu_inv_notifiers_all(SMMUState *s);
|
||
|
|
|
||
|
|
/* IOMMUFD helpers */
|
||
|
|
int smmu_dev_get_info(SMMUDevice *sdev, uint32_t *data_type,
|
||
|
|
- uint32_t data_len, void *data);
|
||
|
|
+ uint32_t data_len, uint8_t *pasid, void *data);
|
||
|
|
void smmu_dev_uninstall_nested_ste(SMMUDevice *sdev, bool abort);
|
||
|
|
int smmu_dev_install_nested_ste(SMMUDevice *sdev, uint32_t data_type,
|
||
|
|
uint32_t data_len, void *data,
|
||
|
|
diff --git a/include/sysemu/host_iommu_device.h b/include/sysemu/host_iommu_device.h
|
||
|
|
index 84131f5495..22c76a37a7 100644
|
||
|
|
--- a/include/sysemu/host_iommu_device.h
|
||
|
|
+++ b/include/sysemu/host_iommu_device.h
|
||
|
|
@@ -26,6 +26,7 @@
|
||
|
|
typedef struct HostIOMMUDeviceCaps {
|
||
|
|
uint32_t type;
|
||
|
|
uint64_t hw_caps;
|
||
|
|
+ uint8_t max_pasid_log2;
|
||
|
|
} HostIOMMUDeviceCaps;
|
||
|
|
|
||
|
|
#define TYPE_HOST_IOMMU_DEVICE "host-iommu-device"
|
||
|
|
diff --git a/include/sysemu/iommufd.h b/include/sysemu/iommufd.h
|
||
|
|
index b279184974..29afaa429d 100644
|
||
|
|
--- a/include/sysemu/iommufd.h
|
||
|
|
+++ b/include/sysemu/iommufd.h
|
||
|
|
@@ -57,7 +57,8 @@ int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t ioas_id,
|
||
|
|
hwaddr iova, ram_addr_t size);
|
||
|
|
bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid,
|
||
|
|
uint32_t *type, void *data, uint32_t len,
|
||
|
|
- uint64_t *caps, Error **errp);
|
||
|
|
+ uint64_t *caps, uint8_t *max_pasid_log2,
|
||
|
|
+ Error **errp);
|
||
|
|
bool iommufd_backend_alloc_hwpt(IOMMUFDBackend *be, uint32_t dev_id,
|
||
|
|
uint32_t pt_id, uint32_t flags,
|
||
|
|
uint32_t data_type, uint32_t data_len,
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|