aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2023-12-24 14:52:00 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2023-12-26 01:28:22 +0000
commit30ce85ca11433ba05cdbab8aedceaa15a93bd97a (patch)
treeb0e52276ecf0042286c50b6ff1ab194330d793e0
parenta869643e184a73382ef7939b465fd42785e096d1 (diff)
downloadsrc-30ce85ca11433ba05cdbab8aedceaa15a93bd97a.tar.gz
src-30ce85ca11433ba05cdbab8aedceaa15a93bd97a.zip
iommu_gas: add ddb 'show iommu_domain' command
Sponsored by: The FreeBSD Foundation MFC after: 1 week
-rw-r--r--sys/dev/iommu/iommu_gas.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c
index cc541e748f48..72db5ca871ec 100644
--- a/sys/dev/iommu/iommu_gas.c
+++ b/sys/dev/iommu/iommu_gas.c
@@ -1031,3 +1031,48 @@ SYSCTL_INT(_hw_iommu, OID_AUTO, check_free, CTLFLAG_RWTUN,
&iommu_check_free, 0,
"Check the GPA RBtree for free_down and free_after validity");
#endif
+
+#include "opt_ddb.h"
+#ifdef DDB
+
+#include <ddb/ddb.h>
+
+static void
+iommu_debug_dump_gas(struct iommu_domain *domain)
+{
+ struct iommu_map_entry *entry;
+
+ db_printf("iommu_domain %p tree %p iommu %p fl %#x\n", domain,
+ &domain->rb_root, domain->iommu, domain->flags);
+ db_printf("iommu_domain %p tree %p\n", domain, &domain->rb_root);
+ RB_FOREACH(entry, iommu_gas_entries_tree, &domain->rb_root) {
+ db_printf(
+ " e %p [%#jx %#jx] fl %#x first %#jx last %#jx free_down %#jx",
+ entry, (uintmax_t)entry->start, (uintmax_t)entry->end,
+ entry->flags,
+ (uintmax_t)entry->first, (uintmax_t)entry->last,
+ (uintmax_t)entry->free_down);
+ if (entry == domain->start_gap)
+ db_printf(" start_gap");
+ if (entry == domain->first_place)
+ db_printf(" first_place");
+ if (entry == domain->last_place)
+ db_printf(" last_place");
+ db_printf("\n");
+ }
+}
+
+DB_SHOW_COMMAND(iommu_domain, iommu_domain_show)
+{
+ struct iommu_domain *domain;
+
+ if (!have_addr) {
+ db_printf("show iommu_domain addr\n");
+ return;
+ }
+
+ domain = (void *)addr;
+ iommu_debug_dump_gas(domain);
+}
+
+#endif