computing-offload/generic_vdpa/qemu/Revert-vfio-Force-nested-if-iommu-requires-it.patch
jiangdongxu 79c4324644 add generic_vdpa basecode
Change-Id: I2d302dda68298877c65c99147f5bf22186a59aac
2024-09-19 17:19:46 +08:00

98 lines
3.4 KiB
Diff

From bac64f79264fd95b349004dd20b4ef7e9944fcb7 Mon Sep 17 00:00:00 2001
From: Kunkun Jiang <jiangkunkun@huawei.com>
Date: Fri, 18 Nov 2022 15:22:47 +0800
Subject: [PATCH 26/36] Revert "vfio: Force nested if iommu requires it"
This reverts commit e7eef5af743a53f0415267ebe9bba2e5f0e05816.
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
---
hw/vfio/common.c | 36 ++++++++----------------------------
1 file changed, 8 insertions(+), 28 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index d7533637c9..6cb91e7ffd 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -2045,38 +2045,27 @@ static void vfio_put_address_space(VFIOAddressSpace *space)
* vfio_get_iommu_type - selects the richest iommu_type (v2 first)
*/
static int vfio_get_iommu_type(VFIOContainer *container,
- bool want_nested,
Error **errp)
{
- int iommu_types[] = { VFIO_TYPE1_NESTING_IOMMU,
- VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
+ int iommu_types[] = { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU,
VFIO_SPAPR_TCE_v2_IOMMU, VFIO_SPAPR_TCE_IOMMU };
- int i, ret = -EINVAL;
+ int i;
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 && !want_nested) {
- continue;
- }
- ret = iommu_types[i];
- break;
+ return iommu_types[i];
}
}
- if (ret < 0) {
- error_setg(errp, "No available IOMMU models");
- } else if (want_nested && ret != VFIO_TYPE1_NESTING_IOMMU) {
- error_setg(errp, "Nested mode requested but not supported");
- ret = -EINVAL;
- }
- return ret;
+ error_setg(errp, "No available IOMMU models");
+ return -EINVAL;
}
static int vfio_init_container(VFIOContainer *container, int group_fd,
- bool want_nested, Error **errp)
+ Error **errp)
{
int iommu_type, dirty_log_manual_clear, ret;
- iommu_type = vfio_get_iommu_type(container, want_nested, errp);
+ iommu_type = vfio_get_iommu_type(container, errp);
if (iommu_type < 0) {
return iommu_type;
}
@@ -2188,14 +2177,6 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
VFIOContainer *container;
int ret, fd;
VFIOAddressSpace *space;
- IOMMUMemoryRegion *iommu_mr;
- bool nested = false;
-
- if (memory_region_is_iommu(as->root)) {
- iommu_mr = IOMMU_MEMORY_REGION(as->root);
- memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_VFIO_NESTED,
- (void *)&nested);
- }
space = vfio_get_address_space(as);
@@ -2276,7 +2257,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
QLIST_INIT(&container->vrdl_list);
QLIST_INIT(&container->dma_list);
- ret = vfio_init_container(container, group->fd, nested, errp);
+ ret = vfio_init_container(container, group->fd, errp);
if (ret) {
goto free_container_exit;
}
@@ -2288,7 +2269,6 @@ 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.27.0