From patchwork Fri Sep 22 15:16:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liu, Jingqi" X-Patchwork-Id: 14398 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5798991vqi; Fri, 22 Sep 2023 11:54:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbf0vPIXmWAYJJ7s/yUrtYkJKQKCb6MYivPrpgesPHwRlX7HlUvFsb1aWjPJC8mP0IUjVZ X-Received: by 2002:a17:90b:1091:b0:268:ac3:b1f6 with SMTP id gj17-20020a17090b109100b002680ac3b1f6mr519889pjb.24.1695408856860; Fri, 22 Sep 2023 11:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695408856; cv=none; d=google.com; s=arc-20160816; b=n0FvBCZb9I2/jy8n1hh1nZ4MDj1TFqwjVUilJ+i6poMX+nkb/jRGuLX07emNzHyEq1 5e2aH01LuAqZqaK7OIT1lTehx8oDRj/buR/rd0QZnzOEpvMeZMakPTTMo5A3uBF7U1O4 jh80sC4USEWC2KsFBSLjcDbw1OK7RN4A6llJaA4v/Y7iFy2G2dcuKAxjJM0ww5pYNH+7 XcRzboM7ZlWYKxF2lZAOIN60Rsizp0BLufpGhFcurkRexv7iosHkN1OpjGUWfVXTbM+J UWhq8wMB/8/C4TGnFE1ZQEo5MyRaYRMWOoj6CYSrX/krK4Kzk7irhSRZrAsT9ibdMx5j geng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=22EdEjG831bCyjJm1+m4vor0+/j2vMJ8i6f9cQw7xoM=; fh=XFDRxS7z/mPiLWcvDFNXxtez86tw5VSUEAZ1VPulNcQ=; b=NzRI7Le35rGBO6CUTWe25xUrbXGPIUO5Ph+L7ZyGCbNphh/SM0Ay6T3LlSI7owSu27 fnGdBuR8f4YCSsi9hRRKESutlz/FVOtHfy8qC+78x0UjMRmIhwy5cXc9ykrRcOfQOu5m 2xH/VPcgBBsh4o5OxoBCuN2/um11nuDl2tGOwlX6YiNE9D0hXnXrGhh7/8ExAHPONX71 RaFkuIPOGRuUVbEqxjIqkoU9Q0+ayu1h44JR3YHJfxwykFz49r509XxZdBAdc0c5kyfO sAMopGK2+tPdCdhz9NhE3ICPI6QyS0e5XXtO/T/x+k7P3cZd6SQHqEeN85J8Fs5Ufvm0 3q+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CQDEHPLa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u9-20020a17090a410900b00276ac140106si6582320pjf.165.2023.09.22.11.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 11:54:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CQDEHPLa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 36D42838B3E7; Fri, 22 Sep 2023 08:19:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232657AbjIVPTi (ORCPT + 29 others); Fri, 22 Sep 2023 11:19:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229986AbjIVPTg (ORCPT ); Fri, 22 Sep 2023 11:19:36 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D077100 for ; Fri, 22 Sep 2023 08:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695395970; x=1726931970; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=DGjGBqtW0YmDzNhpM7gkO90ycKqRlM8UiiecicTQT7E=; b=CQDEHPLav7kvGIN/jy4/0Cgp1yjDnGHCIllT8OEj+LCpr+Fri5eoxFxx eo7KjFdIfNCQBkR/hiVtwda3W7FPqdWwLxRR47ViWYlW3oGL1e/UZ89al VDftFjgy1shvOdElhDGvFS/doqrLauLXtIcnrt3kHDVgiBqiONQ3f+R6m a7WSbMaRPq3cqFkQT78VQaRrQmgxg5Vfsm/fJQ2kLfZgT3OBwzqgS+mG2 s+TvPwGsbKCiQxD/tZ9d1qOm8Wv0/kvRzU+Fbrx8IRdKMbLPvD7DXwlWC mKHox0NsqkhPx9QBlIgEK1KMrVfaCK0o5FZpjGamCqSCyBLxYgJA1S2y5 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="360235274" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="360235274" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 08:19:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10841"; a="741133124" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="741133124" Received: from cascade.sh.intel.com ([10.239.48.35]) by orsmga007.jf.intel.com with ESMTP; 22 Sep 2023 08:19:27 -0700 From: Jingqi Liu To: iommu@lists.linux.dev, Lu Baolu , Tian Kevin , Joerg Roedel , Will Deacon , Robin Murphy Cc: linux-kernel@vger.kernel.org, Jingqi Liu Subject: [PATCH v2 0/3] iommu/vt-d: debugfs: Enhancements to IOMMU debugfs Date: Fri, 22 Sep 2023 23:16:33 +0800 Message-Id: <20230922151636.77139-1-Jingqi.liu@intel.com> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 22 Sep 2023 08:19:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777765037272855874 X-GMAIL-MSGID: 1777765037272855874 The original debugfs only dumps all IOMMU page tables without pasid supported. It traverses all devices on the pci bus, then dumps all page tables based on device domains. This traversal is from software perspective. This series dumps page tables whose mappings are created and destroyed by the iommu_map/unmap() interfaces, by traversing root tables, context tables, pasid directories and pasid tables from hardware perspective. It supports dumping a specified page table in legacy mode or scalable mode with or without a specified pasid. It adds a debugfs directory per pair of {device, pasid} when attaching device with or without pasid, i.e. /sys/kernel/debug/iommu/intel//. And create a debugfs file in the directory for users to dump the page table corresponding to {device, pasid}. e.g. /sys/kernel/debug/iommu/intel/0000:00:02.0/0/domain_translation_struct. Each device has a PASID#0, i.e. RID_PASID. Remove the corresponding debugfs directory and file when detaching or releasing a device. For legacy mode, according to bus number and DEVFN, traverse the root table and context table to get the pointer of page table in the context table entry, then dump the specified page table. For scalable mode, according to bus number, DEVFN and pasid, traverse the root table, context table, pasid directory and pasid table to get the pointer of page table in the pasid table entry, then dump the specified page table. Examples are as follows: 1) Dump the page table of device "0000:00:01.0" that only supports legacy mode. $ sudo cat /sys/kernel/debug/iommu/intel/0000:00:01.0/0/domain_translation_struct 2) Dump the page table of device "0000:00:02.0" with PASID "1" that supports scalable mode. $ sudo cat /sys/kernel/debug/iommu/intel/0000:00:0a.0/1/domain_translation_struct Change log: v2: - Add a debugfs directory per {dev, pasid} as suggested by Kevin. - Create the debugfs directory when attaching device as suggested by Baolu. - Only dump the page tables whose mappings are created and destroyed by the iommu_map/unmap() interfaces per Baolu's review. - Rename the helpers for creating/removing debugfs directory/file and merge patch 2,3,4,5 to one patch per Baolu's review. v1: https://lore.kernel.org/linux-iommu/20230625150442.42197-1-Jingqi.liu@intel.com Jingqi Liu (3): iommu/vt-d: debugfs: Dump entry pointing to huge page iommu/vt-d: debugfs: Create/remove debugfs file per {device, pasid} iommu/vt-d: debugfs: Support dumping a specified page table drivers/iommu/intel/debugfs.c | 291 ++++++++++++++++++++++++++++------ drivers/iommu/intel/iommu.c | 16 ++ drivers/iommu/intel/iommu.h | 4 + 3 files changed, 261 insertions(+), 50 deletions(-)