Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2467370rwd; Wed, 14 Jun 2023 03:19:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4IDp/3/1AK0qPs8+aCEvgOUl16zSL51K59Ogb8rhNNvKWyW4rYdt1oqPOa334u/7vqjhzz X-Received: by 2002:a05:6a21:789a:b0:114:c11c:7ad5 with SMTP id bf26-20020a056a21789a00b00114c11c7ad5mr1693780pzc.52.1686737982826; Wed, 14 Jun 2023 03:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686737982; cv=none; d=google.com; s=arc-20160816; b=K+RA36NQ3o+BIBHm5hPH/lin4rYZTGkr7s//SU2V7HJ/w7ROxtanw62Gua4/TT84Tz IyOxQOIskBE/SyYnzLwrkPcw5WOtF0gL8TpkY6K/jPu8AwMCEGovZAtKm2QIvurB5rlo /lri6D2CccIxTj+eio7zQB7VnGfWbSOIPusVO9FnOSvtTh0I5+HIykYvdegFI4kiwlB0 g0zz0evNRT1tqPLZA0iALywNKKpYSI8iUVwGwGtrtcQCxT0GaGH31Ruo/D/kU4mCq3L7 6Vdobd789HvqDSUtf98GYc4zWALqR/mortj7QrKx/Ks78v0259u1JTv2rrQhDImLq/jL xvog== 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=pyRrYYpHmuXsJlV624p8wbWm3a7I/sjMs0Ojkr9W+Pk=; b=O83Vah1AKaGXD0WxB09aq57IUryHJ0nqBklrNGld+oS7Jo2KLLYLf+ChUHn0mOD+vV c3hUDEWtpCkAadM3P0ITU5Jb7NsREG0ZkZwEtXzIajI9Mt90kz8pRGqR3jaTvIILj+s8 0EVS74DzM/TC1eqFzS/fme8O1FWfUAmqQiUMPjln21FgJjhbNBxldX+pEcVCu1xINMsu UEDhMOgB6pk67q8R3DhBBuds4uSBQLg+u8CiMCnjYMv32Gqhd1vqjYM1YSDYIZqCs/Hb bTdKYQLrruFRaOjjldMHh948C1K83XywsKw7QDboH8wtUBVNXMAUSXeTpgZtsbTsGHgr tYhQ== 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 j3-20020a170902758300b001b23b699747si2744951pll.10.2023.06.14.03.19.30; Wed, 14 Jun 2023 03:19:42 -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 S243470AbjFNJ5t (ORCPT + 99 others); Wed, 14 Jun 2023 05:57:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243399AbjFNJ5o (ORCPT ); Wed, 14 Jun 2023 05:57:44 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AD7D1AC for ; Wed, 14 Jun 2023 02:57:43 -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 73ACD1FB; Wed, 14 Jun 2023 02:58:27 -0700 (PDT) Received: from [10.57.85.233] (unknown [10.57.85.233]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 91D133F71E; Wed, 14 Jun 2023 02:57:41 -0700 (PDT) Message-ID: <0454d58b-1de0-a4b4-6b93-8c0b99090d96@arm.com> Date: Wed, 14 Jun 2023 10:57:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v2 14/18] iommu/arm-smmu-v3: Support domains with shared CDs Content-Language: en-GB To: Michael Shavit , Jason Gunthorpe 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: <20230606120854.4170244-1-mshavit@google.com> <20230606120854.4170244-15-mshavit@google.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.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-06-14 10:17, Michael Shavit wrote: > On Wed, Jun 7, 2023 at 1:09 AM Jason Gunthorpe wrote: >> >> On Tue, Jun 06, 2023 at 08:07:50PM +0800, Michael Shavit wrote: >>> SVA may attach a CD to masters that have different upstream SMMU >>> devices. The arm_smmu_domain structure can only be attached to a single >>> upstream SMMU device however. >> >> Isn't that pretty much because we don't support replicating >> invalidations to each of the different SMMU instances? > > Looked into this some more, and supporting attach to multiple devices > is still very hard: > 1. When an arm_smmu_domain is first attached to a master, it > initializes an io_pgtable_cfg object whose properties depend on the > master's upstream SMMU device. This io_pgtable_cfg is then used to > allocate an io_pgtable object, and the arm_smmu_ctx_desc's TTBR field > points to that io_pgtable's TTBR (and ditto for the vttbr on stage 2 > domains). So then arm_smmu_domain needs to be split into two, > arm_smmu_domain and arm_smmu_device_domain with the latter containing > a per-SMMU device io_pgtable, arm_smmu_ctx_desc and arm_smmu_s2_cfg. > Each iommu_domain_ops operation now needs to loop over each > arm_smmu_device_domain. > 2. Some of the iommu_domain fields also depend on the per-SMMU > io_pgtable_cfg; specifically pgsize_bitmap and geometry.aperture_end. > These need to be restricted as the domain is attached to more devices. > 3. Attaching a domain to a new SMMU device must be prohibited after > any call to map_pages or if iommu_domain.pgsize_bitmap and > iommu-domain.geometry.aperture_end have been consumed by any system. > The first is something the arm-smmu-v3.c driver could feasibly enforce > on its own, the second requires changes to the iommu framework. In practice it would be entirely reasonable to only support cross-instance attach between instances with matching capabilities such that they *can* share the pagetable directly. > The arm-smmu-v3-sva.c implementation avoids all these problems because it > doesn't need to allocate an io_pgtable; SVA has all the same underlying problems - pagetable sharing is still pagetable sharing regardless of which code happens to allocate the physical pages - they're just avoided up-front by disallowing SVA at all if the relevant capabilities don't line up between SMMU and CPU. Thanks, Robin.