@@ -199,12 +199,6 @@ int vfio_set_dirty_page_tracking(VFIOLegacyContainer *container, bool start);
int vfio_query_dirty_bitmap(VFIOLegacyContainer *container, VFIOBitmap *vbmap,
hwaddr iova, hwaddr size);
-int vfio_container_add_section_window(VFIOLegacyContainer *container,
- MemoryRegionSection *section,
- Error **errp);
-void vfio_container_del_section_window(VFIOLegacyContainer *container,
- MemoryRegionSection *section);
-
void vfio_disable_irqindex(VFIODevice *vbasedev, int index);
void vfio_unmask_single_irqindex(VFIODevice *vbasedev, int index);
void vfio_mask_single_irqindex(VFIODevice *vbasedev, int index);
@@ -69,6 +69,11 @@ int vfio_container_dma_map(VFIOContainer *bcontainer,
int vfio_container_dma_unmap(VFIOContainer *bcontainer,
hwaddr iova, ram_addr_t size,
IOMMUTLBEntry *iotlb);
+int vfio_container_add_section_window(VFIOContainer *bcontainer,
+ MemoryRegionSection *section,
+ Error **errp);
+void vfio_container_del_section_window(VFIOContainer *bcontainer,
+ MemoryRegionSection *section);
void vfio_container_init(VFIOContainer *bcontainer,
VFIOAddressSpace *space,
@@ -655,7 +655,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
return;
}
- if (vfio_container_add_section_window(container, section, &err)) {
+ if (vfio_container_add_section_window(bcontainer, section, &err)) {
goto fail;
}
@@ -879,7 +879,7 @@ static void vfio_listener_region_del(MemoryListener *listener,
memory_region_unref(section->mr);
- vfio_container_del_section_window(container, section);
+ vfio_container_del_section_window(&container->bcontainer, section);
}
typedef struct VFIODirtyRanges {
@@ -48,6 +48,27 @@ int vfio_container_dma_unmap(VFIOContainer *bcontainer,
return bcontainer->ops->dma_unmap(bcontainer, iova, size, iotlb);
}
+int vfio_container_add_section_window(VFIOContainer *bcontainer,
+ MemoryRegionSection *section,
+ Error **errp)
+{
+ if (!bcontainer->ops->add_window) {
+ return 0;
+ }
+
+ return bcontainer->ops->add_window(bcontainer, section, errp);
+}
+
+void vfio_container_del_section_window(VFIOContainer *bcontainer,
+ MemoryRegionSection *section)
+{
+ if (!bcontainer->ops->del_window) {
+ return;
+ }
+
+ return bcontainer->ops->del_window(bcontainer, section);
+}
+
void vfio_container_init(VFIOContainer *bcontainer,
VFIOAddressSpace *space,
struct VFIOIOMMUBackendOpsClass *ops)
@@ -215,10 +215,13 @@ static int vfio_legacy_dma_map(VFIOContainer *bcontainer, hwaddr iova,
return -errno;
}
-int vfio_container_add_section_window(VFIOLegacyContainer *container,
- MemoryRegionSection *section,
- Error **errp)
+static int vfio_legacy_add_section_window(VFIOContainer *bcontainer,
+ MemoryRegionSection *section,
+ Error **errp)
{
+ VFIOLegacyContainer *container = container_of(bcontainer,
+ VFIOLegacyContainer,
+ bcontainer);
VFIOHostDMAWindow *hostwin;
hwaddr pgsize = 0;
int ret;
@@ -283,9 +286,13 @@ int vfio_container_add_section_window(VFIOLegacyContainer *container,
return 0;
}
-void vfio_container_del_section_window(VFIOLegacyContainer *container,
- MemoryRegionSection *section)
+static void vfio_legacy_del_section_window(VFIOContainer *bcontainer,
+ MemoryRegionSection *section)
{
+ VFIOLegacyContainer *container = container_of(bcontainer,
+ VFIOLegacyContainer,
+ bcontainer);
+
if (container->iommu_type != VFIO_SPAPR_TCE_v2_IOMMU) {
return;
}
@@ -1174,6 +1181,8 @@ static void vfio_iommu_backend_legacy_ops_class_init(ObjectClass *oc,
ops->dma_map = vfio_legacy_dma_map;
ops->dma_unmap = vfio_legacy_dma_unmap;
+ ops->add_window = vfio_legacy_add_section_window;
+ ops->del_window = vfio_legacy_del_section_window;
}
static const TypeInfo vfio_iommu_backend_legacy_ops_type = {