thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
29b115
From 8d45902b4884315ec090e607e9f03606b21001cf Mon Sep 17 00:00:00 2001
29b115
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
29b115
Date: Fri, 24 Jun 2022 17:37:40 +0800
29b115
Subject: [PATCH 05/17] virtio-iommu: Fix migration regression
29b115
29b115
RH-Author: Eric Auger <eric.auger@redhat.com>
29b115
RH-MergeRequest: 105: virtio-iommu: Fix bypass mode for assigned devices
29b115
RH-Commit: [5/5] 9652c4aaaf88e24083fab1fbc3d1423260c93ca6 (eauger1/centos-qemu-kvm)
29b115
RH-Bugzilla: 2100106
29b115
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
29b115
RH-Acked-by: Peter Xu <peterx@redhat.com>
29b115
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
29b115
29b115
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100106
29b115
29b115
We also need to switch to the right address space on dest side
29b115
after loading the device status. DMA to wrong address space is
29b115
destructive.
29b115
29b115
Fixes: 3facd774962fd ("virtio-iommu: Add bypass mode support to assigned device")
29b115
Suggested-by: Eric Auger <eric.auger@redhat.com>
29b115
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
29b115
Message-Id: <20220624093740.3525267-1-zhenzhong.duan@intel.com>
29b115
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
29b115
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
29b115
Reviewed-by: Eric Auger <eric.auger@redhat.com>
29b115
(cherry picked from commit d355566bd958e24e7e384da6ea89a9fc88d7bfed)
29b115
Signed-off-by: Eric Auger <eric.auger@redhat.com>
29b115
---
29b115
 hw/virtio/virtio-iommu.c | 8 ++++++++
29b115
 1 file changed, 8 insertions(+)
29b115
29b115
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
29b115
index 44a041dec9..2012835554 100644
29b115
--- a/hw/virtio/virtio-iommu.c
29b115
+++ b/hw/virtio/virtio-iommu.c
29b115
@@ -1324,6 +1324,14 @@ static int iommu_post_load(void *opaque, int version_id)
29b115
     VirtIOIOMMU *s = opaque;
29b115
 
29b115
     g_tree_foreach(s->domains, reconstruct_endpoints, s);
29b115
+
29b115
+    /*
29b115
+     * Memory regions are dynamically turned on/off depending on
29b115
+     * 'config.bypass' and attached domain type if there is. After
29b115
+     * migration, we need to make sure the memory regions are
29b115
+     * still correct.
29b115
+     */
29b115
+    virtio_iommu_switch_address_space_all(s);
29b115
     return 0;
29b115
 }
29b115
 
29b115
-- 
29b115
2.31.1
29b115