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

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