70 lines
2.4 KiB
Diff
70 lines
2.4 KiB
Diff
|
|
From ccd8baf4648e6fd6b69e65ee249609904edc92e1 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
Date: Wed, 5 Jun 2024 16:30:33 +0800
|
||
|
|
Subject: [PATCH] backends/iommufd: Introduce helper function
|
||
|
|
iommufd_backend_get_device_info()
|
||
|
|
|
||
|
|
Introduce a helper function iommufd_backend_get_device_info() to get
|
||
|
|
host IOMMU related information through iommufd uAPI.
|
||
|
|
|
||
|
|
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
|
||
|
|
Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
|
||
|
|
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
Reviewed-by: Eric Auger <eric.auger@redhat.com>
|
||
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
---
|
||
|
|
backends/iommufd.c | 22 ++++++++++++++++++++++
|
||
|
|
include/sysemu/iommufd.h | 3 +++
|
||
|
|
2 files changed, 25 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/backends/iommufd.c b/backends/iommufd.c
|
||
|
|
index a2b7f5c3c4..604a8f4e7d 100644
|
||
|
|
--- a/backends/iommufd.c
|
||
|
|
+++ b/backends/iommufd.c
|
||
|
|
@@ -223,6 +223,28 @@ int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t ioas_id,
|
||
|
|
return ret;
|
||
|
|
}
|
||
|
|
|
||
|
|
+bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid,
|
||
|
|
+ uint32_t *type, void *data, uint32_t len,
|
||
|
|
+ Error **errp)
|
||
|
|
+{
|
||
|
|
+ struct iommu_hw_info info = {
|
||
|
|
+ .size = sizeof(info),
|
||
|
|
+ .dev_id = devid,
|
||
|
|
+ .data_len = len,
|
||
|
|
+ .data_uptr = (uintptr_t)data,
|
||
|
|
+ };
|
||
|
|
+
|
||
|
|
+ if (ioctl(be->fd, IOMMU_GET_HW_INFO, &info)) {
|
||
|
|
+ error_setg_errno(errp, errno, "Failed to get hardware info");
|
||
|
|
+ return false;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ g_assert(type);
|
||
|
|
+ *type = info.out_data_type;
|
||
|
|
+
|
||
|
|
+ return true;
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
static const TypeInfo types[] = {
|
||
|
|
{
|
||
|
|
.name = TYPE_IOMMUFD_BACKEND,
|
||
|
|
diff --git a/include/sysemu/iommufd.h b/include/sysemu/iommufd.h
|
||
|
|
index 1a75e82f42..dfade18e6d 100644
|
||
|
|
--- a/include/sysemu/iommufd.h
|
||
|
|
+++ b/include/sysemu/iommufd.h
|
||
|
|
@@ -49,6 +49,9 @@ int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_t ioas_id, hwaddr iova,
|
||
|
|
ram_addr_t size, void *vaddr, bool readonly);
|
||
|
|
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,
|
||
|
|
+ Error **errp);
|
||
|
|
|
||
|
|
#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd"
|
||
|
|
#endif
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|