On 2/19/25 9:22 AM, Zhenzhong Duan wrote:
> Implement query of HOST_IOMMU_DEVICE_CAP_ERRATA for IOMMUFD
> backed host IOMMU device.
>
> Query on this capability is not supported for legacy backend
> because there is no plan to support nesting with leacy backend
legacy
> backed host device.
>
> Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com>
> ---
> include/system/host_iommu_device.h | 2 ++
> backends/iommufd.c | 2 ++
> hw/vfio/iommufd.c | 1 +
> 3 files changed, 5 insertions(+)
>
> diff --git a/include/system/host_iommu_device.h
> b/include/system/host_iommu_device.h
> index 18f8b5e5cf..250600fc1d 100644
> --- a/include/system/host_iommu_device.h
> +++ b/include/system/host_iommu_device.h
> @@ -32,6 +32,7 @@ typedef struct HostIOMMUDeviceCaps {
> uint64_t hw_caps;
> bool nesting;
> bool fs1gp;
> + uint32_t errata;
to be consistent with the others yu may have introduced this alongside
with the 2 others?
This is also not usable by other IOMMUs.
Eric
> } HostIOMMUDeviceCaps;
>
> #define TYPE_HOST_IOMMU_DEVICE "host-iommu-device"
> @@ -130,6 +131,7 @@ struct HostIOMMUDeviceClass {
> #define HOST_IOMMU_DEVICE_CAP_AW_BITS 1
> #define HOST_IOMMU_DEVICE_CAP_NESTING 2
> #define HOST_IOMMU_DEVICE_CAP_FS1GP 3
> +#define HOST_IOMMU_DEVICE_CAP_ERRATA 4
>
> #define HOST_IOMMU_DEVICE_CAP_AW_BITS_MAX 64
> #endif
> diff --git a/backends/iommufd.c b/backends/iommufd.c
> index 0a1a40cbba..3c23caef96 100644
> --- a/backends/iommufd.c
> +++ b/backends/iommufd.c
> @@ -374,6 +374,8 @@ static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod,
> int cap, Error **errp)
> return caps->nesting;
> case HOST_IOMMU_DEVICE_CAP_FS1GP:
> return caps->fs1gp;
> + case HOST_IOMMU_DEVICE_CAP_ERRATA:
> + return caps->errata;
> default:
> error_setg(errp, "%s: unsupported capability %x", hiod->name, cap);
> return -EINVAL;
> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
> index df6a12d200..58bff030e1 100644
> --- a/hw/vfio/iommufd.c
> +++ b/hw/vfio/iommufd.c
> @@ -848,6 +848,7 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice
> *hiod, void *opaque,
> case IOMMU_HW_INFO_TYPE_INTEL_VTD:
> caps->nesting = !!(data.vtd.ecap_reg & VTD_ECAP_NEST);
> caps->fs1gp = !!(data.vtd.cap_reg & VTD_CAP_FS1GP);
> + caps->errata = data.vtd.flags &
> IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17;
> break;
> case IOMMU_HW_INFO_TYPE_ARM_SMMUV3:
> case IOMMU_HW_INFO_TYPE_NONE: