Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8732387rwr; Thu, 11 May 2023 05:39:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ52cNibLEbUrtf0kOtTKa8Xm+M1U0nnTIT4QviKhTdSR6uHCHD+2xKf8+1OVyboCBiNkKDc X-Received: by 2002:a05:6a20:918b:b0:101:4348:3e44 with SMTP id v11-20020a056a20918b00b0010143483e44mr12558817pzd.12.1683808790842; Thu, 11 May 2023 05:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683808790; cv=none; d=google.com; s=arc-20160816; b=tj2ix/1znrBKCc2H/gc+lrvliWydggOYK2RCh5jQ4N790qSAVTaOC93h/UA2KAr0QU fGy3/RNgjz8mLQRuvbWrjYHVZpj52NdF1Vp9axXRt4lTfP/DEZ8y6Y6GS4rCIVi0D4n1 LQtlnMLQPyHVwPu2PLc6WPPFnYz5oA+8LtXobwSGINtLxV65nFyCRKzGvArKuYC7bKib pACZtKb/mkpVc7CIhW3xCX6y3Do1Pl4Xeo91Yw8CToQ+oR9vk8WBxU9BiWfi+ofMidnY 4Od+T0c8PShh+tePF1X3P7lfRAfQOydY9YLBqFtqt/+SIQMOQB2lHTLffYr9w0sFcwRN Nwgg== 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:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=e2ykMRuduqZ8twns+Nw48J7vuwGxOK8hZS6zq8qp9mk=; b=z1Jj6KIthRxIZw35YaaxrP5OmKVXHazsxDWhK5bV9eqfVX9O34OGOWTLxaZlgfMfcD mDIg+y9zsAQ91vGYFZ49mCk6xJ9gSGTQTzTF8KRZD5pzUXG7CV7RrLgSHSaAZNBKAlSN ALzH0Y2LoDxtzzxySINJW6JXQOCr7TIvZUZi8wtplkWVT8WO3u5fvw/fUD6peHGSmJq6 5nPrgKR+QIR+7Vo6SVca7/0X28Wh5N27EOgrBGPEX7S2PEg+pUhylMflhT10FQ8USjmo Wkil3J/OKRZvHQNU8tw0qS8upe4Eevv+j6iucw5vimd2TGwwtoTUMYjHO6vWukSNqinl 6/1Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o29-20020a63921d000000b0052868eb9742si6738799pgd.77.2023.05.11.05.39.38; Thu, 11 May 2023 05:39:50 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237658AbjEKMeN (ORCPT + 99 others); Thu, 11 May 2023 08:34:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237570AbjEKMeL (ORCPT ); Thu, 11 May 2023 08:34:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 91D9F5265 for ; Thu, 11 May 2023 05:34:05 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6A01F1063; Thu, 11 May 2023 05:34:49 -0700 (PDT) Received: from [10.57.83.77] (unknown [10.57.83.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5D2DF3F5A1; Thu, 11 May 2023 05:34:03 -0700 (PDT) Message-ID: <5deb8a32-7f49-06ed-2275-721b93bbfb9b@arm.com> Date: Thu, 11 May 2023 13:33:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH v1 0/5] Add PASID support to SMMUv3 unmanaged domains Content-Language: en-GB To: Jason Gunthorpe , Michael Shavit Cc: Will Deacon , Joerg Roedel , jean-philippe@linaro.org, nicolinc@nvidia.com, baolu.lu@linux.intel.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20230510205054.2667898-1-mshavit@google.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-05-11 05:33, Jason Gunthorpe wrote: > On Thu, May 11, 2023 at 11:52:41AM +0800, Michael Shavit wrote: >>> Logically when an iommu_domain is attached to a device or a PASID a >>> STE or CD is generated from the iommu_domain's configuration but the >>> iommu_domain doesn't "hold" it >>> >> >> Ah yes, I was using iommu domain and arm_smmu_domain interchangeably >> here since there's a 1:1 mapping between the two. In the current >> smmuv3 implementation, arm_smmu_domain holds the s1cfg structure which >> represents the s1 portion of an STE. > > I mean to include the arm_smmu_domain too.. > > Generally this sort of seemed OK in the code, I just wouldn't use the > word 'hold' - the iommu_domain may cache a computed STE or CD value > but that the actual steering or context tables are held else where > > ie you insert an iommu_domain into a steering or context table, it > does not 'hold' a table entry. > >> specific to SVA about this behavior however, SVA will do the same >> amount of work whether the cd table is owned by some special iommu >> domain or by the arm_smmu_master (since we require that special iommu >> domain be attached to the master and disallow detaching it). > > The CD table for SVA definately should not be part of an iommu_domain, > moving it to the master seems reasonable. > >> Gotcha. So this patch series should be less aggressive, but is >> probably still workable with the nested domain patch series: >> 1. For (stage 1) unmanaged/dma and sva domains, arm_smmu_domains >> should hold a single CD. For the nested domain series, arm_smmu_domain >> can alternatively hold an entire s1cfg. > > These are just pre computed values the can help when inserting the > iommu_domain into a steering or CD table Right, a stage 1 domain still logically owns the *contents* of a corresponding CD, however in this design it can no longer own a physical CD structure, because now every device attached to the same domain must maintain its own distinct copy. >> 2. arm_smmu_master should own an s1cfg (which holds a cdtable) that is >> used by unmanaged/dma and sva domains attached to this master. > > The arm_smmu_master's cd table can be inserted into a steering table Not sure what you mean there... STE.S1ContextPtr is essentially just a pointer to an array of CD structures (which only contains 1 element when PASIDs aren't enabled), so every master must own its own CD table directly. There is no viable indirection if you want the abstraction to bear any relation to reality. >> 3. arm_smmu_master also holds a pointer to the live s1cfg, which may >> either points to its owned s1cfg, or the nested domain's s1cfg, or >> null (bypass or stage2) > > The steering table either points to the CD table owned by the > arm_smmu_master, a S1 domain held by an iommu_domain, or a S1 & CD > table owned by userspace represented by a special nested iommu_domain > and its internal parent. > > If a kernel owned S2 it attached then the S1 points at the CD table > owned by the arm_smmu_master and the CD table points to the S2, same > as if there was PASID (IIRC, from memory I don't have the spec here > right now) Nope, CDs *only* represent stage 1 domains, stage 2 configuration is a property of the STE, i.e. is directly connected to the arm_smmu_master. Thanks, Robin.