[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3 09/25] vfio: check VFIO_TYPE1_NESTING_IOMMU support
From: |
Liu, Yi L |
Subject: |
[RFC v3 09/25] vfio: check VFIO_TYPE1_NESTING_IOMMU support |
Date: |
Wed, 29 Jan 2020 04:16:40 -0800 |
From: Liu Yi L <address@hidden>
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 0cc7ff5..a5e70b1 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_NESTING_GET_IOMMU_UAPI_VERSION);
+ if (version < IOMMU_UAPI_VERSION) {
+ printf("IOMMU UAPI incompatible for nesting\n");
+ 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 00/25] intel_iommu: expose Shared Virtual Addressing to VMs, Liu, Yi L, 2020/01/29
- [RFC v3 06/25] scripts/update-linux-headers: Import iommu.h, Liu, Yi L, 2020/01/29
- [RFC v3 04/25] hw/pci: introduce pci_device_iommu_context(), Liu, Yi L, 2020/01/29
- [RFC v3 09/25] vfio: check VFIO_TYPE1_NESTING_IOMMU support,
Liu, Yi L <=
- [RFC v3 08/25] vfio: pass IOMMUContext into vfio_get_group(), Liu, Yi L, 2020/01/29
- [RFC v3 02/25] hw/iommu: introduce DualStageIOMMUObject, Liu, Yi L, 2020/01/29
- [RFC v3 07/25] header file update VFIO/IOMMU vSVA APIs, Liu, Yi L, 2020/01/29
- [RFC v3 05/25] intel_iommu: provide get_iommu_context() callback, Liu, Yi L, 2020/01/29
- [RFC v3 03/25] hw/iommu: introduce IOMMUContext, Liu, Yi L, 2020/01/29