Blame SOURCES/kvm-intel-iommu-trace-domain-id-during-page-walk.patch

357786
From 2511801028d31c9a6cee77d8a978d2642b82e0df Mon Sep 17 00:00:00 2001
357786
From: Peter Xu <peterx@redhat.com>
357786
Date: Mon, 3 Sep 2018 04:52:39 +0200
357786
Subject: [PATCH 24/29] intel-iommu: trace domain id during page walk
357786
357786
RH-Author: Peter Xu <peterx@redhat.com>
357786
Message-id: <20180903045241.6456-8-peterx@redhat.com>
357786
Patchwork-id: 82028
357786
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 7/9] intel-iommu: trace domain id during page walk
357786
Bugzilla: 1623859
357786
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
357786
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
357786
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
357786
357786
This patch only modifies the trace points.
357786
357786
Previously we were tracing page walk levels.  They are redundant since
357786
we have page mask (size) already.  Now we trace something much more
357786
useful which is the domain ID of the page walking.  That can be very
357786
useful when we trace more than one devices on the same system, so that
357786
we can know which map is for which domain.
357786
357786
CC: QEMU Stable <qemu-stable@nongnu.org>
357786
Signed-off-by: Peter Xu <peterx@redhat.com>
357786
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
357786
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
357786
(cherry picked from commit d118c06ebbee2d23ddf873cae4a809311aa61310)
357786
Signed-off-by: Peter Xu <peterx@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 hw/i386/intel_iommu.c | 16 ++++++++++------
357786
 hw/i386/trace-events  |  2 +-
357786
 2 files changed, 11 insertions(+), 7 deletions(-)
357786
357786
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
357786
index a882894..61bb3d3 100644
357786
--- a/hw/i386/intel_iommu.c
357786
+++ b/hw/i386/intel_iommu.c
357786
@@ -756,6 +756,7 @@ typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private);
357786
  * @notify_unmap: whether we should notify invalid entries
357786
  * @as: VT-d address space of the device
357786
  * @aw: maximum address width
357786
+ * @domain: domain ID of the page walk
357786
  */
357786
 typedef struct {
357786
     VTDAddressSpace *as;
357786
@@ -763,17 +764,18 @@ typedef struct {
357786
     void *private;
357786
     bool notify_unmap;
357786
     uint8_t aw;
357786
+    uint16_t domain_id;
357786
 } vtd_page_walk_info;
357786
 
357786
-static int vtd_page_walk_one(IOMMUTLBEntry *entry, int level,
357786
-                             vtd_page_walk_info *info)
357786
+static int vtd_page_walk_one(IOMMUTLBEntry *entry, vtd_page_walk_info *info)
357786
 {
357786
     vtd_page_walk_hook hook_fn = info->hook_fn;
357786
     void *private = info->private;
357786
 
357786
     assert(hook_fn);
357786
-    trace_vtd_page_walk_one(level, entry->iova, entry->translated_addr,
357786
-                            entry->addr_mask, entry->perm);
357786
+    trace_vtd_page_walk_one(info->domain_id, entry->iova,
357786
+                            entry->translated_addr, entry->addr_mask,
357786
+                            entry->perm);
357786
     return hook_fn(entry, private);
357786
 }
357786
 
357786
@@ -844,7 +846,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,
357786
                 trace_vtd_page_walk_skip_perm(iova, iova_next);
357786
                 goto next;
357786
             }
357786
-            ret = vtd_page_walk_one(&entry, level, info);
357786
+            ret = vtd_page_walk_one(&entry, info);
357786
             if (ret < 0) {
357786
                 return ret;
357786
             }
357786
@@ -856,7 +858,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,
357786
                      * Translated address is meaningless, zero it.
357786
                      */
357786
                     entry.translated_addr = 0x0;
357786
-                    ret = vtd_page_walk_one(&entry, level, info);
357786
+                    ret = vtd_page_walk_one(&entry, info);
357786
                     if (ret < 0) {
357786
                         return ret;
357786
                     }
357786
@@ -1466,6 +1468,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s,
357786
                     .notify_unmap = true,
357786
                     .aw = s->aw_bits,
357786
                     .as = vtd_as,
357786
+                    .domain_id = domain_id,
357786
                 };
357786
 
357786
                 /*
357786
@@ -2947,6 +2950,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n)
357786
                 .notify_unmap = false,
357786
                 .aw = s->aw_bits,
357786
                 .as = vtd_as,
357786
+                .domain_id = VTD_CONTEXT_ENTRY_DID(ce.hi),
357786
             };
357786
 
357786
             vtd_page_walk(&ce, 0, ~0ULL, &info;;
357786
diff --git a/hw/i386/trace-events b/hw/i386/trace-events
357786
index 22d4464..ca23ba9 100644
357786
--- a/hw/i386/trace-events
357786
+++ b/hw/i386/trace-events
357786
@@ -39,7 +39,7 @@ vtd_fault_disabled(void) "Fault processing disabled for context entry"
357786
 vtd_replay_ce_valid(uint8_t bus, uint8_t dev, uint8_t fn, uint16_t domain, uint64_t hi, uint64_t lo) "replay valid context device %02"PRIx8":%02"PRIx8".%02"PRIx8" domain 0x%"PRIx16" hi 0x%"PRIx64" lo 0x%"PRIx64
357786
 vtd_replay_ce_invalid(uint8_t bus, uint8_t dev, uint8_t fn) "replay invalid context device %02"PRIx8":%02"PRIx8".%02"PRIx8
357786
 vtd_page_walk_level(uint64_t addr, uint32_t level, uint64_t start, uint64_t end) "walk (base=0x%"PRIx64", level=%"PRIu32") iova range 0x%"PRIx64" - 0x%"PRIx64
357786
-vtd_page_walk_one(uint32_t level, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "detected page level 0x%"PRIx32" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d"
357786
+vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIu16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d"
357786
 vtd_page_walk_skip_read(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to unable to read"
357786
 vtd_page_walk_skip_perm(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to perm empty"
357786
 vtd_page_walk_skip_reserve(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to rsrv set"
357786
-- 
357786
1.8.3.1
357786