qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
	peterx@redhat.com, Jason Wang <jasowang@redhat.com>
Subject: [Qemu-devel] [PATCH 3/8] intel_iommu: support "info iommu"
Date: Tue, 27 Jun 2017 17:03:34 +0800	[thread overview]
Message-ID: <1498554219-4942-4-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1498554219-4942-1-git-send-email-peterx@redhat.com>

Dump critical information for VT-d. Sample output:

(qemu) info iommu
Version: 1
Cap: 0x12008c22260286
Extended Cap: 0xf00f5a
DMAR: enabled, root=0x7435f000 (extended=0)
IR: enabled, root=0x17a400000, size=0x10000 (eim=1)
QI: enabled, root=0x17aadf000, head=156, tail=156, size=256
Caching-mode: enabled
Misc: next_frr=0, context_gen=2, buggy_eim=0

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 hw/i386/intel_iommu.c       | 39 +++++++++++++++++++++++++++++++++++++++
 hw/i386/x86-iommu.c         | 17 +++++++++++++++++
 include/hw/i386/x86-iommu.h |  5 +++++
 3 files changed, 61 insertions(+)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index a5c83dd..39f772a 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -2991,6 +2991,44 @@ static bool vtd_decide_config(IntelIOMMUState *s, Error **errp)
     return true;
 }
 
+#define DUMP(...) monitor_printf(mon, ## __VA_ARGS__)
+static void vtd_info_dump(X86IOMMUState *x86_iommu, Monitor *mon,
+                          const QDict *qdict)
+{
+    IntelIOMMUState *s = INTEL_IOMMU_DEVICE(x86_iommu);
+
+    DUMP("Version: %d\n", 1);
+    DUMP("Cap: 0x%"PRIx64"\n", s->cap);
+    DUMP("Extended Cap: 0x%"PRIx64"\n", s->ecap);
+
+    DUMP("DMAR: %s", s->dmar_enabled ? "enabled" : "disabled");
+    if (s->dmar_enabled) {
+        DUMP(", root=0x%"PRIx64" (extended=%d)",
+             s->root, s->root_extended);
+    }
+    DUMP("\n");
+
+    DUMP("IR: %s", s->intr_enabled ? "enabled" : "disabled");
+    if (s->intr_enabled) {
+        DUMP(", root=0x%"PRIx64", size=0x%"PRIx32" (eim=%d)",
+             s->intr_root, s->intr_size, s->intr_eime);
+    }
+    DUMP("\n");
+
+    DUMP("QI: %s", s->qi_enabled ? "enabled" : "disabled");
+    if (s->qi_enabled) {
+        DUMP(", root=0x%"PRIx64", head=%u, tail=%u, size=%u",
+             s->iq, s->iq_head, s->iq_tail, s->iq_size);
+    }
+    DUMP("\n");
+
+    DUMP("Caching-mode: %s\n", s->caching_mode ? "enabled" : "disabled");
+    DUMP("Misc: next_frr=%d, context_gen=%d, buggy_eim=%d\n",
+         s->next_frcd_reg, s->context_cache_gen, s->buggy_eim);
+    DUMP("      iotlb_size=%d\n", g_hash_table_size(s->iotlb));
+}
+#undef DUMP
+
 static void vtd_realize(DeviceState *dev, Error **errp)
 {
     MachineState *ms = MACHINE(qdev_get_machine());
@@ -3042,6 +3080,7 @@ static void vtd_class_init(ObjectClass *klass, void *data)
     dc->hotpluggable = false;
     x86_class->realize = vtd_realize;
     x86_class->int_remap = vtd_int_remap;
+    x86_class->info_dump = vtd_info_dump;
     /* Supported by the pc-q35-* machine types */
     dc->user_creatable = true;
 }
diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c
index 293caf8..fed35b4 100644
--- a/hw/i386/x86-iommu.c
+++ b/hw/i386/x86-iommu.c
@@ -76,6 +76,23 @@ IommuType x86_iommu_get_type(void)
     return x86_iommu_default->type;
 }
 
+void arch_iommu_info(Monitor *mon, const QDict *qdict)
+{
+    X86IOMMUState *iommu = x86_iommu_get_default();
+    X86IOMMUClass *class;
+
+    if (!iommu) {
+        monitor_printf(mon, "No IOMMU is detected.\n");
+        return;
+    }
+
+    class = X86_IOMMU_GET_CLASS(iommu);
+
+    if (class->info_dump) {
+        class->info_dump(iommu, mon, qdict);
+    }
+}
+
 static void x86_iommu_realize(DeviceState *dev, Error **errp)
 {
     X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(dev);
diff --git a/include/hw/i386/x86-iommu.h b/include/hw/i386/x86-iommu.h
index ef89c0c..c414b65 100644
--- a/include/hw/i386/x86-iommu.h
+++ b/include/hw/i386/x86-iommu.h
@@ -22,6 +22,8 @@
 
 #include "hw/sysbus.h"
 #include "hw/pci/pci.h"
+#include "hw/iommu.h"
+#include "monitor/monitor.h"
 
 #define  TYPE_X86_IOMMU_DEVICE  ("x86-iommu")
 #define  X86_IOMMU_DEVICE(obj) \
@@ -50,6 +52,9 @@ struct X86IOMMUClass {
     /* MSI-based interrupt remapping */
     int (*int_remap)(X86IOMMUState *iommu, MSIMessage *src,
                      MSIMessage *dst, uint16_t sid);
+    /* Dump IOMMU information */
+    void (*info_dump)(X86IOMMUState *iommu, Monitor *mon,
+                      const QDict *qdict);
 };
 
 /**
-- 
2.7.4

  parent reply	other threads:[~2017-06-27  9:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27  9:03 [Qemu-devel] [PATCH 0/8] VT-d: some enhancements on iotlb and tools Peter Xu
2017-06-27  9:03 ` [Qemu-devel] [PATCH 1/8] intel_iommu: fix VTD_PAGE_MASK Peter Xu
2017-06-27  9:03 ` [Qemu-devel] [PATCH 2/8] hmp: add info iommu Peter Xu
2017-06-27  9:03 ` Peter Xu [this message]
2017-06-27  9:03 ` [Qemu-devel] [PATCH 4/8] intel_iommu: add iotlb/context cache statistics Peter Xu
2017-06-27  9:03 ` [Qemu-devel] [PATCH 5/8] intel_iommu: hmp: allow "-c" for "info iommu" Peter Xu
2017-06-27  9:03 ` [Qemu-devel] [PATCH 6/8] intel_iommu: let iotlb size tunable Peter Xu
2017-06-27  9:03 ` [Qemu-devel] [PATCH 7/8] intel_iommu: use access_flags for iotlb Peter Xu
2017-06-27  9:03 ` [Qemu-devel] [PATCH 8/8] intel_iommu: implement mru list " Peter Xu
2017-06-27  9:22 ` [Qemu-devel] [PATCH 0/8] VT-d: some enhancements on iotlb and tools Peter Xu
2017-06-27 14:42 ` Michael S. Tsirkin
2017-06-28  7:03   ` Peter Xu
2017-06-27 16:30 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498554219-4942-4-git-send-email-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).