Blame SOURCES/kvm-virtio-iommu-Add-an-assert-check-in-translate-routin.patch

586cba
From 643d9c28ff8b15c333cc748c5e712659ad2a257c Mon Sep 17 00:00:00 2001
586cba
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
586cba
Date: Mon, 13 Jun 2022 14:10:10 +0800
586cba
Subject: [PATCH 03/17] virtio-iommu: Add an assert check in translate routine
586cba
586cba
RH-Author: Eric Auger <eric.auger@redhat.com>
586cba
RH-MergeRequest: 105: virtio-iommu: Fix bypass mode for assigned devices
586cba
RH-Commit: [3/5] 19f309fd0beda40d65f51c454e37936658ac9f38 (eauger1/centos-qemu-kvm)
586cba
RH-Bugzilla: 2100106
586cba
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
586cba
RH-Acked-by: Peter Xu <peterx@redhat.com>
586cba
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
586cba
586cba
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100106
586cba
586cba
With address space switch supported, dma access translation only
586cba
happen after endpoint is attached to a non-bypass domain.
586cba
586cba
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
586cba
Message-Id: <20220613061010.2674054-4-zhenzhong.duan@intel.com>
586cba
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
586cba
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
586cba
(cherry picked from commit 23b5f0ff6d923d3bca11cf44eed3daf7a0a836a8)
586cba
Signed-off-by: Eric Auger <eric.auger@redhat.com>
586cba
---
586cba
 hw/virtio/virtio-iommu.c | 4 ++++
586cba
 1 file changed, 4 insertions(+)
586cba
586cba
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
586cba
index 440a1c28a7..e970d4d5a6 100644
586cba
--- a/hw/virtio/virtio-iommu.c
586cba
+++ b/hw/virtio/virtio-iommu.c
586cba
@@ -866,6 +866,10 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
586cba
     qemu_rec_mutex_lock(&s->mutex);
586cba
 
586cba
     ep = g_tree_lookup(s->endpoints, GUINT_TO_POINTER(sid));
586cba
+
586cba
+    if (bypass_allowed)
586cba
+        assert(ep && ep->domain && !ep->domain->bypass);
586cba
+
586cba
     if (!ep) {
586cba
         if (!bypass_allowed) {
586cba
             error_report_once("%s sid=%d is not known!!", __func__, sid);
586cba
-- 
586cba
2.31.1
586cba