@samitouri / QOSamiQemu / commits / 3e79b45e04

backends/iommufd: Update iommufd_backend_get_device_info

The updated IOMMUFD uAPI introduces the ability for userspace to request a specific hardware info data type via IOMMU_GET_HW_INFO. Update iommufd_backend_get_device_info() to set IOMMU_HW_INFO_FLAG_INPUT_TYPE when a non-zero type is supplied, and adjust all callers to pass a type value explicitly initialised to zero (IOMMU_HW_INFO_TYPE_DEFAULT) when no specific type is requested. Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com> Tested-by: Eric Auger <eric.auger@redhat.com> Message-id: 20260609112552.378999-2-skolothumtho@nvidia.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Nicolin Chen committed Jun 9, 2026 at 12:25 UTC 3e79b45e0478de367745aa1f5d3b0a4573c69ab0
3 files changed +10 -3
backends/iommufd.c
+7
@@ -390,16 +390,23 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be,
390 return true;
391 }
392
393 +/*
394 + * @type can carry a desired HW info type defined in the uapi headers. If caller
395 + * doesn't have one, indicating it wants the default type, then @type should be
396 + * zeroed (i.e. IOMMU_HW_INFO_TYPE_DEFAULT).
397 + */
398 bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid,
399 uint32_t *type, void *data, uint32_t len,
400 uint64_t *caps, uint8_t *max_pasid_log2,
401 Error **errp)
402 {
403 struct iommu_hw_info info = {
404 + .flags = (*type) ? IOMMU_HW_INFO_FLAG_INPUT_TYPE : 0,
405 .size = sizeof(info),
406 .dev_id = devid,
407 .data_len = len,
408 .data_uptr = (uintptr_t)data,
409 + .in_data_type = *type,
410 };
411
412 if (ioctl(be->fd, IOMMU_GET_HW_INFO, &info)) {
hw/arm/smmuv3-accel.c
+1 -1
@@ -176,7 +176,7 @@ smmuv3_accel_hw_compatible(SMMUv3State *s, HostIOMMUDeviceIOMMUFD *hiodi,
176 Error **errp)
177 {
178 struct iommu_hw_info_arm_smmuv3 info;
179 - uint32_t data_type;
179 + uint32_t data_type = IOMMU_HW_INFO_TYPE_DEFAULT;
180 uint64_t caps;
181
182 if (!iommufd_backend_get_device_info(hiodi->iommufd, hiodi->devid,
hw/vfio/iommufd.c
+2 -2
@@ -353,7 +353,7 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev,
353 IOMMUFDBackend *iommufd = vbasedev->iommufd;
354 VFIOContainer *bcontainer = VFIO_IOMMU(container);
355 bool viommu_nesting, viommu_nesting_dirty;
356 - uint32_t type, flags = 0;
356 + uint32_t type = IOMMU_HW_INFO_TYPE_DEFAULT, flags = 0;
357 uint64_t hw_caps;
358 VendorCaps caps;
359 VFIOIOASHwpt *hwpt;
@@ -948,7 +948,7 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
948 HostIOMMUDeviceIOMMUFD *hiodi;
949 HostIOMMUDeviceCaps *caps = &hiod->caps;
950 VendorCaps *vendor_caps = &caps->vendor_caps;
951 - enum iommu_hw_info_type type;
951 + uint32_t type = IOMMU_HW_INFO_TYPE_DEFAULT;
952 uint8_t max_pasid_log2;
953 uint64_t hw_caps;
954