On Fri, 17 May 2019 18:16:50 +0200Hi Alex,
Pierre Morel <pmorel@xxxxxxxxxxxxx> wrote:
We implement the capability interface for VFIO_IOMMU_GET_INFO.
When calling the ioctl, the user must specify
VFIO_IOMMU_INFO_CAPABILITIES to retrieve the capabilities and
must check in the answer if capabilities are supported.
The iommu get_attr callback will be used to retrieve the specific
attributes and fill the capabilities.
Currently two Z-PCI specific capabilities will be queried and
filled by the underlying Z specific s390_iommu:
VFIO_IOMMU_INFO_CAP_QFN for the PCI query function attributes
and
VFIO_IOMMU_INFO_CAP_QGRP for the PCI query function group.
Other architectures may add new capabilities in the same way
after enhancing the architecture specific IOMMU driver.
Signed-off-by: Pierre Morel <pmorel@xxxxxxxxxxxxx>
---
drivers/vfio/vfio_iommu_type1.c | 122 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 121 insertions(+), 1 deletion(-)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index d0f731c..9435647 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -1658,6 +1658,97 @@ static int vfio_domains_have_iommu_cache(struct vfio_iommu *iommu)
return ret;
}
+static int vfio_iommu_type1_zpci_fn(struct iommu_domain *domain,
+ struct vfio_info_cap *caps, size_t size)
+{
+ struct vfio_iommu_type1_info_pcifn *info_fn;
+ int ret;
+
+ info_fn = kzalloc(size, GFP_KERNEL);
+ if (!info_fn)
+ return -ENOMEM;
+
+ ret = iommu_domain_get_attr(domain, DOMAIN_ATTR_ZPCI_FN,
+ &info_fn->response);
What ensures that the 'struct clp_rsp_query_pci' returned from this
get_attr remains consistent with a 'struct vfio_iommu_pci_function'?
Why does the latter contains so many reserved fields (beyond simply
alignment) for a user API? What fields of these structures are
actually useful to userspace? Should any fields not be exposed to the
user? Aren't BAR sizes redundant to what's available through the vfio
PCI API? I'm afraid that simply redefining an internal structure as
the API leaves a lot to be desired too. Thanks,
Alex