Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36195589rwd; Mon, 10 Jul 2023 20:00:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHw9kxMEhXlz9HFW8CdeJNyVjwS0urAYksbI1Ijph5Y1x1ilAbLc/YIGBrdtkieP67qFPp0 X-Received: by 2002:a05:6402:2038:b0:51d:95f2:ee76 with SMTP id ay24-20020a056402203800b0051d95f2ee76mr13243672edb.27.1689044444131; Mon, 10 Jul 2023 20:00:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689044444; cv=none; d=google.com; s=arc-20160816; b=na10MGhq2OsEezNffPZvmxL4a5XIqZr6H5B4Low1wWPXWD3hUJqltJbeqKQIhbFWmt 0RjtiEP0931oepR5ezjBJJLXha5zhGB4OF4Gb7CNI9NrscL5E0NzJHWJDvcUxIghOOV8 Shdx05+t1oPSOhE7OWy88K8TakP+K0Jqi4SMNMQ9ySBO2cFdlqc7K8rjF0oNxwBcmbaV pjSav0Nc9UzddmrlTnWIYM3qI7sqQl5xVsBwieaWsIpIUZb9xCbB0aiqQkLvY7uqhti7 ca8FKZ86BBdkg1vK1tKVdk1y2/7GdpcgrC3PlO7hycYpeSok8XgvR48jXUCu/d/c7GIG 1mRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=8RU+Qa6Ri79MzZjxzhOOOK7WlOLiF6Fcm0f8h31tU+A=; fh=p+8vlHcsk479/6LrArrI1o1HCj2hbJgE/b1ARH2I9Bs=; b=mJbkumAsAyJEX+rWfdX/JW70UdHcbK3DFNw+Y6OjhrJdjfTj+RXOYTHtMQ3CY+RAnk 6Vm6g8NDDu9osOedNpTGtYZHAMBf3IUxiNP/0WuVpb2bb8/gs02k9d2nowLyHw+nP5rB H7e96pCwn5Hqbc/Sz9e/xdQOBQT5fpAV8lwZSoHmO8nsukMBl8wD/iqQpzHbVVScc96+ 9TnwpwBL1XYIfxZBvlZ+dcfL0skkk5uPbIjge9N1IyY4JPwxnKpkQJaXu0//69qI5P+s VThpLXo43YHt7AUlp2U6Mq5R1WMGQN8c8YhXbtbaMQOukcwhQtoDZXkIf6eYKxs1jMpw fL1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WwBFZRrP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cd18-20020a170906b35200b00992ac86148bsi1063994ejb.265.2023.07.10.20.00.17; Mon, 10 Jul 2023 20:00:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WwBFZRrP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230225AbjGKCwc (ORCPT + 99 others); Mon, 10 Jul 2023 22:52:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230021AbjGKCwb (ORCPT ); Mon, 10 Jul 2023 22:52:31 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F9501AC for ; Mon, 10 Jul 2023 19:52:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689043950; x=1720579950; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=noYdFbvgl9Bp6GQUz/5z8WucJ+NOT94UdQ0ZDvr+XtI=; b=WwBFZRrPFVBMuD55EnypEacEFZroXsgjNYLwHQY1t0fxZ49EVwpUrdLc f7lXhSEbRtyZoJW4vlQA48AokaCfJWLvbVocwOA+92+jPzCwtKWGzls4L GVLQZnVYZtgJTO2cObUPlxJw/ZLdaT5czY7y2OFxHMYbeGDI3POKUi6Zj Xz0FSqrq44UiG5I7HjzzTrch9iXWjYLFrDCkEndTMjcg8xBdDzPQ28cg9 akbCghKw/AHfuWbeCUdCz/uwmGpMAgo+nlNK7X+BAyaKH+SvHIj2ZOqC5 LQ/R99y8oAAzPMGFcap28jStTmRszUpT6nx0QwfEigs0QZYbe1s61jrRh w==; X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="363374627" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="363374627" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2023 19:52:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="791022671" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="791022671" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.252.187.35]) ([10.252.187.35]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2023 19:52:26 -0700 Message-ID: Date: Tue, 11 Jul 2023 10:52:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: baolu.lu@linux.intel.com, "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 0/5] iommu/vt-d: debugfs: Enhancements to IOMMU debugfs Content-Language: en-US To: "Liu, Jingqi" , "Tian, Kevin" , "iommu@lists.linux.dev" , Joerg Roedel , Will Deacon , Robin Murphy References: <20230625150442.42197-1-Jingqi.liu@intel.com> <4f18a7ca-3a57-0097-51f0-490f876831dc@intel.com> From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, 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 On 2023/7/11 9:40, Liu, Jingqi wrote: > On 7/4/2023 3:54 PM, Tian, Kevin wrote: >>> From: Liu, Jingqi >>> Sent: Monday, July 3, 2023 10:37 PM >>> >>> On 7/3/2023 3:15 PM, Tian, Kevin wrote: >>>>> From: Liu, Jingqi >>>>> Sent: Sunday, June 25, 2023 11:05 PM >>>>> >>>>> 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 by traversing root tables, context >>>>> tables, >>>>> pasid directories and pasid tables from hardware perspective. By >>>>> specifying source identifier and PASID, it supports dumping specified >>>>> page table or all page tables in legacy mode or scalable mode. >>>>> >>>>> For a device that only supports legacy mode, specify the source >>>>> identifier, and search the root table and context table to dump its >>>>> page table. It does not support to specify PASID. >>>>> >>>>> For a device that supports scalable mode, specify a >>>>> {source identifier, PASID} pair and search the root table, context >>>>> table >>>>> and pasid table to dump its page table.  If the pasid is not >>>>> specified, >>>>> it is set to RID_PASID. >>>>> >>>>> Switch to dump all page tables by specifying "auto". >>>>> >>>>> Examples are as follows: >>>>> 1) Dump the page table of device "00:1f.0" that only supports legacy >>>>> mode. >>>>> >>>>> $ sudo echo 00:1f.0 > >>>>> /sys/kernel/debug/iommu/intel/domain_translation_struct >>>>> $ sudo cat /sys/kernel/debug/iommu/intel/domain_translation_struct >>>>> Device 0000:00:1f.0 @0x105407000 >>>>> IOVA_PFN                PML5E                   PML4E >>>>> 0x0000000000000 |       0x0000000000000000      0x0000000105408003 >>>>> 0x0000000000001 |       0x0000000000000000      0x0000000105408003 >>>>> 0x0000000000002 |       0x0000000000000000      0x0000000105408003 >>>>> 0x0000000000003 |       0x0000000000000000      0x0000000105408003 >>>>> >>>>> PDPE                    PDE                     PTE >>>>> 0x0000000105409003      0x000000010540a003      0x0000000000000003 >>>>> 0x0000000105409003      0x000000010540a003      0x0000000000001003 >>>>> 0x0000000105409003      0x000000010540a003      0x0000000000002003 >>>>> 0x0000000105409003      0x000000010540a003      0x0000000000003003 >>>>> >>>>> [...] >>>>> >>>>> 2) Dump the page table of device "00:0a.0" with pasid "2". >>>>> >>>>> $ sudo echo 00:0a.0,2 > >>>>> /sys/kernel/debug/iommu/intel/domain_translation_struct >>>>> $ sudo cat /sys/kernel/debug/iommu/intel/domain_translation_struct >>>> What about creating a directory layout per {dev, pasid} so the user can >>>> easily figure out and dump? >>>> >>>> e.g. >>>> >>>> /sys/kernel/debug/iommu/intel/00:0a.0/0/domain_translation_struct >>>> /sys/kernel/debug/iommu/intel/00:0a.0/2/domain_translation_struct >>> Thanks. >>> >>> Do you mean create a directory for each device, whether it supports >>> PASID or not ? >> every device has PASID#0 valid, i.e. RID2PASID. > Sorry for the late response. > Got it. Thanks. >>> Seems the PASID can be assigned at runtime. >>> So it needs to support creating debugfs file at runtime in IOMMU driver. >>> Looks like this requires modifying IOMMU driver. >>> >> Isn't this patch trying to modify the driver? > I just tried not to modify the driver except debugfs. > I'll try this implementation. I'd second Kevin's suggestion. If you check how usb xhci dumps its contexts for devices, you can see the similar scheme. # ls /sys/kernel/debug/usb/xhci/0000:00:14.0/devices 01 02 03 04 05 In our case, pasid 0 is special which denotes the domain attached to the RID. Best regards, baolu