vfio/common: Move giommu_list in base container
[qemu/ar7.git] / hw / vfio / container-base.c
blob20bcb9669a6122f951119c025b9950854c53f88e
1 /*
2 * VFIO BASE CONTAINER
4 * Copyright (C) 2023 Intel Corporation.
5 * Copyright Red Hat, Inc. 2023
7 * Authors: Yi Liu <yi.l.liu@intel.com>
8 * Eric Auger <eric.auger@redhat.com>
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "qemu/osdep.h"
14 #include "qapi/error.h"
15 #include "qemu/error-report.h"
16 #include "hw/vfio/vfio-container-base.h"
18 int vfio_container_dma_map(VFIOContainerBase *bcontainer,
19 hwaddr iova, ram_addr_t size,
20 void *vaddr, bool readonly)
22 g_assert(bcontainer->ops->dma_map);
23 return bcontainer->ops->dma_map(bcontainer, iova, size, vaddr, readonly);
26 int vfio_container_dma_unmap(VFIOContainerBase *bcontainer,
27 hwaddr iova, ram_addr_t size,
28 IOMMUTLBEntry *iotlb)
30 g_assert(bcontainer->ops->dma_unmap);
31 return bcontainer->ops->dma_unmap(bcontainer, iova, size, iotlb);
34 void vfio_container_init(VFIOContainerBase *bcontainer, const VFIOIOMMUOps *ops)
36 bcontainer->ops = ops;
37 QLIST_INIT(&bcontainer->giommu_list);
40 void vfio_container_destroy(VFIOContainerBase *bcontainer)
42 VFIOGuestIOMMU *giommu, *tmp;
44 QLIST_FOREACH_SAFE(giommu, &bcontainer->giommu_list, giommu_next, tmp) {
45 memory_region_unregister_iommu_notifier(
46 MEMORY_REGION(giommu->iommu_mr), &giommu->n);
47 QLIST_REMOVE(giommu, giommu_next);
48 g_free(giommu);