From patchwork Tue Feb 27 02:14:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolu Lu X-Patchwork-Id: 207020 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2466785dyb; Mon, 26 Feb 2024 19:21:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUuZXjYDM/3Jy/0bHBGFwn735bOFmmmg6ouqF+wcTl+lc25/OVnujTjo4XRdFQD/dNZT245P1MLEitMIYDXS7OXaOZPcQ== X-Google-Smtp-Source: AGHT+IHjnvuN3H9VQaBGXqd7CCvFQZq6UiK+OOLwNE+q3W08thJQ+/a2wMIpiBulh3RUuueL/VX+ X-Received: by 2002:a05:6358:768a:b0:176:29cf:7b3a with SMTP id e10-20020a056358768a00b0017629cf7b3amr12196764rwg.12.1709004090022; Mon, 26 Feb 2024 19:21:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709004089; cv=pass; d=google.com; s=arc-20160816; b=H52Cu2Up1Fyy56+cqLDvi9XlYWCVO3KThG0JIXLWIJ/ou2MgfnHIO45PA3b6+qa+Wy ql4B6c8AVAtHy48twWcLdIQK5Ah1N0ShmHh6Elxni55bKIw7HfAOvSOjWxXZPpEwirQ1 aYbMljr+WizK1CvpthnrDg6qHYtACHI+UkFTmiEzh29xheoHiUY7+YfIeh8rLNltXSHW TCf0sWrFwUt9Lmr+or71XRqR2dgzkH15LBcGLBQTyZlfW/2HXS3SVFS2bo3VjPRwyIGo EwQTBLv5Ev5GciWlY8XQFoMEeWhuYeSAo6VtpcbbVhabmWzxjAiaTcC0ao/irUt4S4XT pWPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Ea3D4pU8LutWMjShLW1fHhGkYeTccV96qsYHCinxUOA=; fh=+24AZIOwsB6rN2R5rZXfKkfQNZggrrSJ6wNtGopki7U=; b=Gj3QV8rQ8ZYw1rjtjDUbRurDv3gMyBiwO4QZrwqJyt6E4Qk27+lXvgO3Z6lw13BslW DcPbfT7a8DemespDNPMqO+Va50KTc7CwX264YLP70ONN+7hKc4/AY6Pi/6+1WHbNHA8S kctpJuyX4M8K16Dea6fU7r18Fc5v5x7boVStjY0ZDdF3kPqyacB7IBomE/Zdban/CuVc hRMnQcCRhr5/4Y9Xr2730rWU71HkueW040qVfD1EPMsXmBWcdSgrS7PsuYGJRCKZCXgd JdfcJa4DWnZcQJ0yaTK7RjJ1+9GNyLQAibjG5iTFok3K08NEuQn42VhDuO9GgNgiqs/o O8Aw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YvLh4xIi; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-82591-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82591-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c127-20020a633585000000b005df438d534asi4807336pga.229.2024.02.26.19.21.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 19:21:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82591-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YvLh4xIi; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-82591-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82591-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 127D028D36F for ; Tue, 27 Feb 2024 02:21:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2312D4EB41; Tue, 27 Feb 2024 02:20:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YvLh4xIi" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56F691D6A7 for ; Tue, 27 Feb 2024 02:20:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709000446; cv=none; b=h60m3YUSIl5LceIFo7MvAobAtYwvNrDMelobxk39CReKlTbCwRxjryWrqjg5Lkprt2BEMJQWo2VD9FtXZRqIuglO4PjQsLoTY7xKImoUXkTFXsDfNGwdWoSHHLWks7M5KoI8jDuA9MHKfnsuLSjxM+7KS46sqw+tsWsovoHT5gc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709000446; c=relaxed/simple; bh=NUKxJCGAOdPpnf2spKsXqpsJliAHRz/13+X2P8l+TjE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Bpm9XwCcSR/IlP0sIY4FPJ30NUn39yd07jdp7lmjHqTSa71scwqUvdqTf0gbOSUPpMCZNXmcABHK08ckTj6Ughw/Hg3OMc9juJcI6sqDt1d+MUe9MJ/WsGIhQP+5KswoAWK3o+oSqeJV8j+kuFF1DWGn45r27ytrCKwWa5cP/bY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YvLh4xIi; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709000444; x=1740536444; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NUKxJCGAOdPpnf2spKsXqpsJliAHRz/13+X2P8l+TjE=; b=YvLh4xIiJs7KpSmKcg1Qg+P9vFJyML2EBu3wvWZlWFnf4TQTwnx1Vq9C A0zzHfbhEAoU40jfYfXYAmNSZCrmnU25MjXk0IMvOjKYSDqzVaYkg1orc VjZdIGIOphOTrgEwcmjGKCT7xVx7R+pIw/NOJUSQiBAHlVxAK1Wzq8bDz Y33U6zIzv9fCiP9kQyHYKL2w7Ork3T135F2vmYlHkUJmJfU4MuUt1iap8 FUjsu8wtN9/sY98mFNaCRbpTsWzLgMVbtwaobZXG9UFKfV8lSZ/zPdibl yBm2aN5lIimJo+3JlbIRcSGCXEkz8CqBKGDLoT/nElhK/gmfJKTHrz/3l A==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="6273106" X-IronPort-AV: E=Sophos;i="6.06,187,1705392000"; d="scan'208";a="6273106" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 18:20:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,187,1705392000"; d="scan'208";a="7418291" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 26 Feb 2024 18:20:42 -0800 From: Lu Baolu To: Joerg Roedel Cc: Tina Zhang , Erick Archer , Jingqi Liu , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] iommu/vt-d: Add the document for Intel IOMMU debugfs Date: Tue, 27 Feb 2024 10:14:36 +0800 Message-Id: <20240227021441.50434-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227021441.50434-1-baolu.lu@linux.intel.com> References: <20240227021441.50434-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792020672623756049 X-GMAIL-MSGID: 1792020672623756049 From: Jingqi Liu This document guides users to dump the Intel IOMMU internals by debugfs. Signed-off-by: Jingqi Liu Link: https://lore.kernel.org/r/20240207090742.23857-1-Jingqi.liu@intel.com Signed-off-by: Lu Baolu --- Documentation/ABI/testing/debugfs-intel-iommu | 276 ++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100644 Documentation/ABI/testing/debugfs-intel-iommu diff --git a/Documentation/ABI/testing/debugfs-intel-iommu b/Documentation/ABI/testing/debugfs-intel-iommu new file mode 100644 index 000000000000..2ab8464504a9 --- /dev/null +++ b/Documentation/ABI/testing/debugfs-intel-iommu @@ -0,0 +1,276 @@ +What: /sys/kernel/debug/iommu/intel/iommu_regset +Date: December 2023 +Contact: Jingqi Liu +Description: + This file dumps all the register contents for each IOMMU device. + + Example in Kabylake: + + :: + + $ sudo cat /sys/kernel/debug/iommu/intel/iommu_regset + + IOMMU: dmar0 Register Base Address: 26be37000 + + Name Offset Contents + VER 0x00 0x0000000000000010 + GCMD 0x18 0x0000000000000000 + GSTS 0x1c 0x00000000c7000000 + FSTS 0x34 0x0000000000000000 + FECTL 0x38 0x0000000000000000 + + [...] + + IOMMU: dmar1 Register Base Address: fed90000 + + Name Offset Contents + VER 0x00 0x0000000000000010 + GCMD 0x18 0x0000000000000000 + GSTS 0x1c 0x00000000c7000000 + FSTS 0x34 0x0000000000000000 + FECTL 0x38 0x0000000000000000 + + [...] + + IOMMU: dmar2 Register Base Address: fed91000 + + Name Offset Contents + VER 0x00 0x0000000000000010 + GCMD 0x18 0x0000000000000000 + GSTS 0x1c 0x00000000c7000000 + FSTS 0x34 0x0000000000000000 + FECTL 0x38 0x0000000000000000 + + [...] + +What: /sys/kernel/debug/iommu/intel/ir_translation_struct +Date: December 2023 +Contact: Jingqi Liu +Description: + This file dumps the table entries for Interrupt + remapping and Interrupt posting. + + Example in Kabylake: + + :: + + $ sudo cat /sys/kernel/debug/iommu/intel/ir_translation_struct + + Remapped Interrupt supported on IOMMU: dmar0 + IR table address:100900000 + + Entry SrcID DstID Vct IRTE_high IRTE_low + 0 00:0a.0 00000080 24 0000000000040050 000000800024000d + 1 00:0a.0 00000001 ef 0000000000040050 0000000100ef000d + + Remapped Interrupt supported on IOMMU: dmar1 + IR table address:100300000 + Entry SrcID DstID Vct IRTE_high IRTE_low + 0 00:02.0 00000002 26 0000000000040010 000000020026000d + + [...] + + **** + + Posted Interrupt supported on IOMMU: dmar0 + IR table address:100900000 + Entry SrcID PDA_high PDA_low Vct IRTE_high IRTE_low + +What: /sys/kernel/debug/iommu/intel/dmar_translation_struct +Date: December 2023 +Contact: Jingqi Liu +Description: + This file dumps Intel IOMMU DMA remapping tables, such + as root table, context table, PASID directory and PASID + table entries in debugfs. For legacy mode, it doesn't + support PASID, and hence PASID field is defaulted to + '-1' and other PASID related fields are invalid. + + Example in Kabylake: + + :: + + $ sudo cat /sys/kernel/debug/iommu/intel/dmar_translation_struct + + IOMMU dmar1: Root Table Address: 0x103027000 + B.D.F Root_entry + 00:02.0 0x0000000000000000:0x000000010303e001 + + Context_entry + 0x0000000000000102:0x000000010303f005 + + PASID PASID_table_entry + -1 0x0000000000000000:0x0000000000000000:0x0000000000000000 + + IOMMU dmar0: Root Table Address: 0x103028000 + B.D.F Root_entry + 00:0a.0 0x0000000000000000:0x00000001038a7001 + + Context_entry + 0x0000000000000000:0x0000000103220e7d + + PASID PASID_table_entry + 0 0x0000000000000000:0x0000000000800002:0x00000001038a5089 + + [...] + +What: /sys/kernel/debug/iommu/intel/invalidation_queue +Date: December 2023 +Contact: Jingqi Liu +Description: + This file exports invalidation queue internals of each + IOMMU device. + + Example in Kabylake: + + :: + + $ sudo cat /sys/kernel/debug/iommu/intel/invalidation_queue + + Invalidation queue on IOMMU: dmar0 + Base: 0x10022e000 Head: 20 Tail: 20 + Index qw0 qw1 qw2 + 0 0000000000000014 0000000000000000 0000000000000000 + 1 0000000200000025 0000000100059c04 0000000000000000 + 2 0000000000000014 0000000000000000 0000000000000000 + + qw3 status + 0000000000000000 0000000000000000 + 0000000000000000 0000000000000000 + 0000000000000000 0000000000000000 + + [...] + + Invalidation queue on IOMMU: dmar1 + Base: 0x10026e000 Head: 32 Tail: 32 + Index qw0 qw1 status + 0 0000000000000004 0000000000000000 0000000000000000 + 1 0000000200000025 0000000100059804 0000000000000000 + 2 0000000000000011 0000000000000000 0000000000000000 + + [...] + +What: /sys/kernel/debug/iommu/intel/dmar_perf_latency +Date: December 2023 +Contact: Jingqi Liu +Description: + This file is used to control and show counts of + execution time ranges for various types per DMAR. + + Firstly, write a value to + /sys/kernel/debug/iommu/intel/dmar_perf_latency + to enable sampling. + + The possible values are as follows: + + * 0 - disable sampling all latency data + + * 1 - enable sampling IOTLB invalidation latency data + + * 2 - enable sampling devTLB invalidation latency data + + * 3 - enable sampling intr entry cache invalidation latency data + + Next, read /sys/kernel/debug/iommu/intel/dmar_perf_latency gives + a snapshot of sampling result of all enabled monitors. + + Examples in Kabylake: + + :: + + 1) Disable sampling all latency data: + + $ sudo echo 0 > /sys/kernel/debug/iommu/intel/dmar_perf_latency + + 2) Enable sampling IOTLB invalidation latency data + + $ sudo echo 1 > /sys/kernel/debug/iommu/intel/dmar_perf_latency + + $ sudo cat /sys/kernel/debug/iommu/intel/dmar_perf_latency + + IOMMU: dmar0 Register Base Address: 26be37000 + <0.1us 0.1us-1us 1us-10us 10us-100us 100us-1ms + inv_iotlb 0 0 0 0 0 + + 1ms-10ms >=10ms min(us) max(us) average(us) + inv_iotlb 0 0 0 0 0 + + [...] + + IOMMU: dmar2 Register Base Address: fed91000 + <0.1us 0.1us-1us 1us-10us 10us-100us 100us-1ms + inv_iotlb 0 0 18 0 0 + + 1ms-10ms >=10ms min(us) max(us) average(us) + inv_iotlb 0 0 2 2 2 + + 3) Enable sampling devTLB invalidation latency data + + $ sudo echo 2 > /sys/kernel/debug/iommu/intel/dmar_perf_latency + + $ sudo cat /sys/kernel/debug/iommu/intel/dmar_perf_latency + + IOMMU: dmar0 Register Base Address: 26be37000 + <0.1us 0.1us-1us 1us-10us 10us-100us 100us-1ms + inv_devtlb 0 0 0 0 0 + + >=10ms min(us) max(us) average(us) + inv_devtlb 0 0 0 0 + + [...] + +What: /sys/kernel/debug/iommu/intel//domain_translation_struct +Date: December 2023 +Contact: Jingqi Liu +Description: + This file dumps a specified page table of Intel IOMMU + in legacy mode or scalable mode. + + For a device that only supports legacy mode, dump its + page table by the debugfs file in the debugfs device + directory. e.g. + /sys/kernel/debug/iommu/intel/0000:00:02.0/domain_translation_struct. + + For a device that supports scalable mode, dump the + page table of specified pasid by the debugfs file in + the debugfs pasid directory. e.g. + /sys/kernel/debug/iommu/intel/0000:00:02.0/1/domain_translation_struct. + + Examples in Kabylake: + + :: + + 1) Dump the page table of device "0000:00:02.0" that only supports legacy mode. + + $ sudo cat /sys/kernel/debug/iommu/intel/0000:00:02.0/domain_translation_struct + + Device 0000:00:02.0 @0x1017f8000 + IOVA_PFN PML5E PML4E + 0x000000008d800 | 0x0000000000000000 0x00000001017f9003 + 0x000000008d801 | 0x0000000000000000 0x00000001017f9003 + 0x000000008d802 | 0x0000000000000000 0x00000001017f9003 + + PDPE PDE PTE + 0x00000001017fa003 0x00000001017fb003 0x000000008d800003 + 0x00000001017fa003 0x00000001017fb003 0x000000008d801003 + 0x00000001017fa003 0x00000001017fb003 0x000000008d802003 + + [...] + + 2) Dump the page table of device "0000:00:0a.0" with PASID "1" that + supports scalable mode. + + $ sudo cat /sys/kernel/debug/iommu/intel/0000:00:0a.0/1/domain_translation_struct + + Device 0000:00:0a.0 with pasid 1 @0x10c112000 + IOVA_PFN PML5E PML4E + 0x0000000000000 | 0x0000000000000000 0x000000010df93003 + 0x0000000000001 | 0x0000000000000000 0x000000010df93003 + 0x0000000000002 | 0x0000000000000000 0x000000010df93003 + + PDPE PDE PTE + 0x0000000106ae6003 0x0000000104b38003 0x0000000147c00803 + 0x0000000106ae6003 0x0000000104b38003 0x0000000147c01803 + 0x0000000106ae6003 0x0000000104b38003 0x0000000147c02803 + + [...]