Received: by 10.223.176.5 with SMTP id f5csp91072wra; Fri, 2 Feb 2018 17:30:05 -0800 (PST) X-Google-Smtp-Source: AH8x227NKJ8r+Gp3DTwhQT/Z8c3QMcvx8ntkQte+inEYQsNOx0DrPpQTGatYs+IDIYJEzEdeqrX8 X-Received: by 10.98.16.23 with SMTP id y23mr3587005pfi.111.1517621405156; Fri, 02 Feb 2018 17:30:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517621405; cv=none; d=google.com; s=arc-20160816; b=eYAGO+pXuXlhh50QL6YiPEo7zAKbfhTPE7AUAzIy9gdtuXnm1Go3K9sSYN6YH/EVWo T2tl4Ss9KQaGFW5yLSikJGi79RPc1ZmXkYXrZCXMlc5xXT1TnyHkzlSTz+2AYle0F93A pzEe7j8BndOzh87lEihClO5vAoayFIi7Q+SBGVLrk4MydnXEhUgTvho+BzFRdwNRA9dM 2p99u8+HCnAvAVqaDwjChcmKAuiinK86ZVTEpo1XwNm8rd6Qf32a3ru9+1xhTAkHOj/Y vjESnRgOGeHQVJc0MNfhbdhWJ1J8DBKyZjtt/br0r7r8nOXkTgCrK6M63faUcDXD3owl Q/SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=NX/UQDmgGIacs9c04oC3hFsbfZ/JRf9tKQc3KQt1vE8=; b=LWaR6Ct/AbOHGvwbrTafBBURxeyD0cm4BWYoCcMcYncyE883Hlyne9S+YP1uwfDtJV 1aZqfXY+QB9sEkNx+EKes7NAqU2ZxHnXl6DTw2o3SFb7q9NQD36KWL1zzzqU3nC9Rg09 5XjVPCdGW31mP5xeH3sIgLvd2fbSRPvlMi+Zc40bB6u/BYuWJxgkxD56PXifxWokvr0D qeh5uumWSvc4nXHa1+2eH8MrK9IQAm5rCwDwwsquUKd4SJ7uZnr5Bqvmx3SnCKhw4Rei T2cRybU0XA85EiucHcWd0sEeMGIY1Bt4I4z+GN1HZ01PsWlc/QCqmYwv1szfIhKdLp3A RH9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si2224050pgv.465.2018.02.02.17.29.48; Fri, 02 Feb 2018 17:30:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752921AbeBCAtz (ORCPT + 99 others); Fri, 2 Feb 2018 19:49:55 -0500 Received: from mga18.intel.com ([134.134.136.126]:17237 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753126AbeBCAt3 (ORCPT ); Fri, 2 Feb 2018 19:49:29 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Feb 2018 16:49:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,452,1511856000"; d="scan'208";a="15086262" Received: from sohilbuildbox.sc.intel.com (HELO localhost.localdomain) ([172.25.110.4]) by fmsmga008.fm.intel.com with ESMTP; 02 Feb 2018 16:49:28 -0800 From: Sohil Mehta To: Joerg Roedel Cc: Alex Williamson , Ashok Raj , David Woodhouse , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Jacob Pan , Gayatri Kammela , Sohil Mehta , Ravi V Shankar , Andy Shevchenko , Lu Baolu , Fenghua Yu Subject: [PATCH v7 4/5] iommu/vt-d: Add debugfs support to show Pasid table contents Date: Fri, 2 Feb 2018 16:50:00 -0800 Message-Id: <1517619001-148586-5-git-send-email-sohil.mehta@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517619001-148586-1-git-send-email-sohil.mehta@intel.com> References: <1517619001-148586-1-git-send-email-sohil.mehta@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gayatri Kammela Debugfs extension to dump the internals such as pasid table entries for each IOMMU to the userspace. Example of such dump in Kabylake: root@OTC-KBLH-01:~# cat /sys/kernel/debug/intel_iommu/dmar_translation_struct IOMMU dmar1: Extended Root Table Address:4071d3800 Extended Root Table Entries: Bus 0 L: 4071d7001 H: 0 Lower Context Table Entries for Bus: 0 [entry] Device B:D.F Low High [16] 0000:00:02.0 4071d6005 102 Higher Context Table Entries for Bus: 0 [16] 0000:00:02.0 0 0 Pasid Table Address: 00000000746cb0af Pasid Table Entries for domain 0: [Entry] Contents [0] 12c409801 Cc: Fenghua Yu Cc: Jacob Pan Cc: Ashok Raj Co-Developed-by: Sohil Mehta Signed-off-by: Sohil Mehta Signed-off-by: Gayatri Kammela --- v7: Improve code indentation and formatting v6: No change v5: No change v4: Remove the unused function parameter Fix checkpatch.pl warnings v3: No change v2: Fix seq_printf formatting drivers/iommu/intel-iommu-debug.c | 31 +++++++++++++++++++++++++++++++ drivers/iommu/intel-svm.c | 8 -------- include/linux/intel-svm.h | 8 ++++++++ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/intel-iommu-debug.c b/drivers/iommu/intel-iommu-debug.c index 38651ad..a9a99aa 100644 --- a/drivers/iommu/intel-iommu-debug.c +++ b/drivers/iommu/intel-iommu-debug.c @@ -81,6 +81,36 @@ static const struct iommu_regset iommu_regs[] = { IOMMU_REGSET_ENTRY(MTRRDEF) }; +#ifdef CONFIG_INTEL_IOMMU_SVM +static void pasid_tbl_entry_show(struct seq_file *m, struct intel_iommu *iommu) +{ + int pasid_size = 0, i; + + if (!ecap_pasid(iommu->ecap)) + return; + + pasid_size = intel_iommu_get_pts(iommu); + seq_printf(m, "Pasid Table Address: %p\n", iommu->pasid_table); + + if (!iommu->pasid_table) + return; + + seq_printf(m, "Pasid Table Entries for domain %d:\n", iommu->segment); + seq_puts(m, "[Entry]\t\tContents\n"); + + /* Publish the pasid table entries here */ + for (i = 0; i < pasid_size; i++) { + if (!iommu->pasid_table[i].val) + continue; + + seq_printf(m, "[%d]\t\t%04llx\n", i, iommu->pasid_table[i].val); + } +} +#else /* CONFIG_INTEL_IOMMU_SVM */ +static inline void +pasid_tbl_entry_show(struct seq_file *m, struct intel_iommu *iommu) {} +#endif /* CONFIG_INTEL_IOMMU_SVM */ + static void ctx_tbl_entry_show(struct seq_file *m, struct intel_iommu *iommu, int bus, bool ext) { @@ -116,6 +146,7 @@ static void ctx_tbl_entry_show(struct seq_file *m, struct intel_iommu *iommu, iommu->segment, bus, PCI_SLOT(ctx), PCI_FUNC(ctx), context[1].lo, context[1].hi); } + pasid_tbl_entry_show(m, iommu); out: spin_unlock_irqrestore(&iommu->lock, flags); } diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index ed1cf7c..c646724 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -28,14 +28,6 @@ static irqreturn_t prq_event_thread(int irq, void *d); -struct pasid_entry { - u64 val; -}; - -struct pasid_state_entry { - u64 val; -}; - int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu) { struct page *pages; diff --git a/include/linux/intel-svm.h b/include/linux/intel-svm.h index 733eaf9..a8abad6 100644 --- a/include/linux/intel-svm.h +++ b/include/linux/intel-svm.h @@ -18,6 +18,14 @@ struct device; +struct pasid_entry { + u64 val; +}; + +struct pasid_state_entry { + u64 val; +}; + struct svm_dev_ops { void (*fault_cb)(struct device *dev, int pasid, u64 address, u32 private, int rwxp, int response); -- 2.7.4