From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751845AbdKVT0h (ORCPT ); Wed, 22 Nov 2017 14:26:37 -0500 Received: from mga03.intel.com ([134.134.136.65]:43172 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751557AbdKVTZo (ORCPT ); Wed, 22 Nov 2017 14:25:44 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,436,1505804400"; d="scan'208";a="10816056" From: Sohil Mehta To: Joerg Roedel , Alex Williamson Cc: David Woodhouse , Ashok Raj , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Jacob Pan , Gayatri Kammela , Sohil Mehta , Ravi V Shankar , Andriy Shevchenko , Fenghua Yu Subject: [PATCH v2 3/6] iommu/vt-d: Add Intel IOMMU debugfs to show extended context internals Date: Wed, 22 Nov 2017 11:25:43 -0800 Message-Id: <1511378746-109275-4-git-send-email-sohil.mehta@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511378746-109275-1-git-send-email-sohil.mehta@intel.com> References: <1511378746-109275-1-git-send-email-sohil.mehta@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gayatri Kammela Debugfs extension to dump internals such as extended context table entries for each IOMMU to the userspace. root@OTC-KBLH-01:~# cat /sys/kernel/debug/intel_iommu/intel_iommu_ctx IOMMU dmar1: Extended Root Table Addr:4558a1800 Extended Root tbl entries: Bus 0 L: 4558a6001 H: 0 Lower Context table entries for Bus: 0 [entry] DID :B :D .F Low High [16] 0000:00:02.00 4558a5005 102 Higher Context tbl entries for Bus: 0 [16] 0000:00:02.00 401b0000c 401400000 IOMMU dmar0: Extended Root Table Addr:4558a2800 Extended Root tbl entries: Bus 0 L: 4016f4001 H: 0 Lower Context table entries for Bus: 0 [entry] DID :B :D .F Low High [80] 0000:00:0a.00 4016f3a05 102 Higher Context tbl entries for Bus: 0 [80] 0000:00:0a.00 40150000c 671b80000000 Cc: Sohil Mehta Cc: Fenghua Yu Cc: Jacob Pan Cc: Ashok Raj Signed-off-by: Gayatri Kammela --- v2: No change drivers/iommu/intel-iommu-debug.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/iommu/intel-iommu-debug.c b/drivers/iommu/intel-iommu-debug.c index 90872ed..ef46820 100644 --- a/drivers/iommu/intel-iommu-debug.c +++ b/drivers/iommu/intel-iommu-debug.c @@ -33,6 +33,38 @@ #define TOTAL_BUS_NR (256) /* full bus range 256 */ +#ifdef CONFIG_INTEL_IOMMU_SVM +static void ext_ctx_tbl_entry_show(struct seq_file *m, void *unused, + struct intel_iommu *iommu, int bus, int ctx, + struct context_entry *context, bool new_ext) +{ + u64 ctx_lo; + + if (new_ext) { + seq_printf(m, "Higher Context tbl entries for Bus: %d\n", bus); + ctx_lo = context[0].lo; + + if (!(ctx_lo & CONTEXT_PASIDE)) { + context[1].hi = (u64)virt_to_phys( + iommu->pasid_state_table); + context[1].lo = (u64)virt_to_phys(iommu->pasid_table) | + intel_iommu_get_pts(iommu); + } + + seq_printf(m, "[%d]\t%04x:%02x:%02x.%02x\t%llx\t%llx\n", ctx, + iommu->segment, bus, PCI_SLOT(ctx), PCI_FUNC(ctx), + context[1].lo, context[1].hi); + } +} +#else /* CONFIG_INTEL_IOMMU_SVM */ +static void ext_ctx_tbl_entry_show(struct seq_file *m, void *unused, + struct intel_iommu *iommu, int bus, int ctx, + struct context_entry *context, bool new_ext) +{ + return; +} +#endif /* CONFIG_INTEL_IOMMU_SVM */ + static void ctx_tbl_entry_show(struct seq_file *m, void *unused, struct intel_iommu *iommu, int bus, bool ext, bool new_ext) @@ -56,6 +88,9 @@ static void ctx_tbl_entry_show(struct seq_file *m, void *unused, seq_printf(m, "[%d]\t%04x:%02x:%02x.%02x\t%llx\t%llx\n", ctx, iommu->segment, bus, PCI_SLOT(ctx), PCI_FUNC(ctx), context[0].lo, context[0].hi); + + ext_ctx_tbl_entry_show(m, unused, iommu, bus, ctx, + context, new_ext); } } out: -- 2.7.4