[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3.1 03/22] vfio: check VFIO_TYPE1_NESTING_IOMMU support
From: |
Liu Yi L |
Subject: |
[RFC v3.1 03/22] vfio: check VFIO_TYPE1_NESTING_IOMMU support |
Date: |
Sat, 22 Feb 2020 00:07:04 -0800 |
VFIO needs to check VFIO_TYPE1_NESTING_IOMMU support with Kernel before
further using it. e.g. requires to check IOMMU UAPI version.
Cc: Kevin Tian <address@hidden>
Cc: Jacob Pan <address@hidden>
Cc: Peter Xu <address@hidden>
Cc: Eric Auger <address@hidden>
Cc: Yi Sun <address@hidden>
Cc: David Gibson <address@hidden>
Cc: Alex Williamson <address@hidden>
Signed-off-by: Liu Yi L <address@hidden>
Signed-off-by: Yi Sun <address@hidden>
---
hw/vfio/common.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 5ca1148..be1a9e5 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1157,12 +1157,21 @@ static void vfio_put_address_space(VFIOAddressSpace
*space)
static int vfio_get_iommu_type(VFIOContainer *container,
Error **errp)
{
- int iommu_types[] = { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
+ int iommu_types[] = { VFIO_TYPE1_NESTING_IOMMU,
+ VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
VFIO_SPAPR_TCE_v2_IOMMU, VFIO_SPAPR_TCE_IOMMU };
- int i;
+ int i, version;
for (i = 0; i < ARRAY_SIZE(iommu_types); i++) {
if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) {
+ if (iommu_types[i] == VFIO_TYPE1_NESTING_IOMMU) {
+ version = ioctl(container->fd, VFIO_CHECK_EXTENSION,
+ VFIO_NESTING_IOMMU_UAPI);
+ if (version < IOMMU_UAPI_VERSION) {
+ info_report("IOMMU UAPI incompatible for nesting");
+ continue;
+ }
+ }
return iommu_types[i];
}
}
@@ -1278,6 +1287,7 @@ static int vfio_connect_container(VFIOGroup *group,
AddressSpace *as,
}
switch (container->iommu_type) {
+ case VFIO_TYPE1_NESTING_IOMMU:
case VFIO_TYPE1v2_IOMMU:
case VFIO_TYPE1_IOMMU:
{
--
2.7.4
- [RFC v3.1 00/22] intel_iommu: expose Shared Virtual Addressing to VMs, Liu Yi L, 2020/02/22
- [RFC v3.1 03/22] vfio: check VFIO_TYPE1_NESTING_IOMMU support,
Liu Yi L <=
- [RFC v3.1 09/22] hw/pci: add pci_device_host_iommu_context(), Liu Yi L, 2020/02/22
- [RFC v3.1 13/22] vfio: add bind stage-1 page table support, Liu Yi L, 2020/02/22
- [RFC v3.1 06/22] vfio/pci: init HostIOMMUContext per-container, Liu Yi L, 2020/02/22
- [RFC v3.1 01/22] scripts/update-linux-headers: Import iommu.h, Liu Yi L, 2020/02/22
- [RFC v3.1 05/22] hw/pci: add pci_device_setup_iommu, Liu Yi L, 2020/02/22
- [RFC v3.1 08/22] vfio/common: add pasid_alloc/free support, Liu Yi L, 2020/02/22
- [RFC v3.1 11/22] intel_iommu: process pasid cache invalidation, Liu Yi L, 2020/02/22
- [RFC v3.1 19/22] intel_iommu: process PASID-based iotlb invalidation, Liu Yi L, 2020/02/22
- [RFC v3.1 04/22] hw/iommu: introduce HostIOMMUContext, Liu Yi L, 2020/02/22
- [RFC v3.1 07/22] vfio: get nesting iommu cap info from Kernel, Liu Yi L, 2020/02/22