yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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