yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
ae23c9
From c79d36500fdf74bbc87b2475b3a95648ee2dff8a Mon Sep 17 00:00:00 2001
ae23c9
From: Peter Xu <peterx@redhat.com>
ae23c9
Date: Thu, 8 Nov 2018 06:29:35 +0000
ae23c9
Subject: [PATCH 07/35] intel_iommu: introduce vtd_reset_caches()
ae23c9
ae23c9
RH-Author: Peter Xu <peterx@redhat.com>
ae23c9
Message-id: <20181108062938.21143-5-peterx@redhat.com>
ae23c9
Patchwork-id: 82963
ae23c9
O-Subject: [RHEL-8 qemu-kvm PATCH 4/7] intel_iommu: introduce vtd_reset_caches()
ae23c9
Bugzilla: 1625173
ae23c9
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
ae23c9
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
ae23c9
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
ae23c9
ae23c9
Bugzilla: 1625173
ae23c9
ae23c9
Provide the function and use it in vtd_init().  Used to reset both
ae23c9
context entry cache and iotlb cache for the whole IOMMU unit.
ae23c9
ae23c9
Signed-off-by: Peter Xu <peterx@redhat.com>
ae23c9
Reviewed-by: Eric Auger <eric.auger@redhat.com>
ae23c9
Reviewed-by: Jason Wang <jasowang@redhat.com>
ae23c9
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
ae23c9
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
ae23c9
(cherry picked from commit 06aba4ca52fd2c8718b8ba486f22f0aa7c99ed55)
ae23c9
Signed-off-by: Peter Xu <peterx@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 hw/i386/intel_iommu.c | 13 +++++++++----
ae23c9
 1 file changed, 9 insertions(+), 4 deletions(-)
ae23c9
ae23c9
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
ae23c9
index aab86e9..48d0ba3 100644
ae23c9
--- a/hw/i386/intel_iommu.c
ae23c9
+++ b/hw/i386/intel_iommu.c
ae23c9
@@ -227,6 +227,14 @@ static void vtd_reset_iotlb(IntelIOMMUState *s)
ae23c9
     vtd_iommu_unlock(s);
ae23c9
 }
ae23c9
 
ae23c9
+static void vtd_reset_caches(IntelIOMMUState *s)
ae23c9
+{
ae23c9
+    vtd_iommu_lock(s);
ae23c9
+    vtd_reset_iotlb_locked(s);
ae23c9
+    vtd_reset_context_cache_locked(s);
ae23c9
+    vtd_iommu_unlock(s);
ae23c9
+}
ae23c9
+
ae23c9
 static uint64_t vtd_get_iotlb_key(uint64_t gfn, uint16_t source_id,
ae23c9
                                   uint32_t level)
ae23c9
 {
ae23c9
@@ -3160,10 +3168,7 @@ static void vtd_init(IntelIOMMUState *s)
ae23c9
         s->cap |= VTD_CAP_CM;
ae23c9
     }
ae23c9
 
ae23c9
-    vtd_iommu_lock(s);
ae23c9
-    vtd_reset_context_cache_locked(s);
ae23c9
-    vtd_reset_iotlb_locked(s);
ae23c9
-    vtd_iommu_unlock(s);
ae23c9
+    vtd_reset_caches(s);
ae23c9
 
ae23c9
     /* Define registers with default values and bit semantics */
ae23c9
     vtd_define_long(s, DMAR_VER_REG, 0x10UL, 0, 0);
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9