From: Wu Fei Implement the hw_info op to return the physical IOMMU capabilities register. This allows IOMMU_GET_HW_INFO to report the available host features to a VMM. Signed-off-by: Wu Fei Signed-off-by: Gong Shuai --- drivers/iommu/riscv/iommu.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c index 4df4411be417..97d360318fe2 100644 --- a/drivers/iommu/riscv/iommu.c +++ b/drivers/iommu/riscv/iommu.c @@ -1979,9 +1979,27 @@ static int riscv_viommu_init(struct iommufd_viommu *viommu, return 0; } +static void *riscv_iommu_hw_info(struct device *dev, u32 *length, + enum iommu_hw_info_type *type) +{ + struct iommu_hw_info_riscv *info; + struct riscv_iommu_device *iommu = dev_to_iommu(dev); + + info = kzalloc_obj(*info); + if (!info) + return ERR_PTR(-ENOMEM); + + info->capabilities = iommu->caps; + *length = sizeof(*info); + *type = IOMMU_HW_INFO_TYPE_RISCV; + + return info; +} + static const struct iommu_ops riscv_iommu_ops = { .of_xlate = riscv_iommu_of_xlate, .capable = riscv_iommu_capable, + .hw_info = riscv_iommu_hw_info, .identity_domain = &riscv_iommu_identity_domain, .blocked_domain = &riscv_iommu_blocking_domain, .release_domain = &riscv_iommu_blocking_domain, -- 2.53.0