Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1128677pxb; Wed, 6 Apr 2022 09:21:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw65v+uFvLwCDCa00YE95GRqPag/lnFiMBp5CNKpxQlv/hfQwPQtD+/LRj0S3YfBt4pSLDc X-Received: by 2002:a17:902:ccc4:b0:156:5d37:b42f with SMTP id z4-20020a170902ccc400b001565d37b42fmr9363969ple.157.1649262117313; Wed, 06 Apr 2022 09:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649262117; cv=none; d=google.com; s=arc-20160816; b=kzx+zpyVlxh8h66xVfhtRILckNnn1H9xT6Bsv8f9KQVw7C2iYmimAIAR28D5Q8fbHv 8hlP8VGPPUbGkc1rIegoRb8bAjddIJTlkImqty9xXA5Cs+PXLDi56M0fYIQzXv5Cacec kVql7uA/9lPynRBU6J+dirYBSNp4OPGp3W5wSwMNwsZdRkQQBpyzdzdj3MkHtUFZXvNn TKb5MrB6szmzwpvCxH+N/3Ix1xHB18/C24iiCTJCQVJGHGJP5Mg/M8Ntzei3e7q+JP46 3SbGnPAqfIcoQ1wHVFp2GoJ+BpPDCdtHkgobGCXPvAEbZ8KH0dMuwd53hyCzj7LdqbOp Ba5g== 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=e/TFMeU1KO3qkozFtm0vkOUZunQ+t/uvCf7D5OMnKBk=; b=QvyHBOyy1zrg5SeLnkuNsvA17/FzziYf1RezE+Ru+R5PL9Os0vYKfP905dmQlOY3Gi 5Ndt3YLzhujY4ZoN2JHs/GvqI3Bg6KdoFvhnK2JJ1fmaipKfhH5eWr4yMcMQtATL5QuR jXsLx/9Efx4N/wVe/gypsPOmBb46C5N0EV2WHF+4yiZPWQ0esvwHbKEWHZpdK8dQUxOo tZTwi7vMyy/rxIfIJTH/IeBHQmYqBWrE8SqzarNkpShltsiXcNZaaN/2v2KvSL7+Ng9k W2D/LKrsQEOJ+yNCbiSCoMAUhQ7RTfkJMewYuFPC4z/JzuySA/UvrdwG2D3BKge1nJ/4 e8dg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z14-20020a634c0e000000b003816043f00asi15622943pga.511.2022.04.06.09.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 09:21:57 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D4F2029F590; Wed, 6 Apr 2022 08:21:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235936AbiDFPXa (ORCPT + 99 others); Wed, 6 Apr 2022 11:23:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236578AbiDFPXI (ORCPT ); Wed, 6 Apr 2022 11:23:08 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D010651FD6B for ; Wed, 6 Apr 2022 05:32:14 -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 832F81516; Wed, 6 Apr 2022 05:32:14 -0700 (PDT) Received: from [10.57.41.19] (unknown [10.57.41.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 97DBD3F718; Wed, 6 Apr 2022 05:32:12 -0700 (PDT) Message-ID: Date: Wed, 6 Apr 2022 13:32:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH RFC v2 03/11] iommu/sva: Add iommu_domain type for SVA Content-Language: en-GB To: "Tian, Kevin" , Jason Gunthorpe Cc: Lu Baolu , Joerg Roedel , Christoph Hellwig , "Raj, Ashok" , Will Deacon , Jean-Philippe Brucker , Eric Auger , "Liu, Yi L" , "Pan, Jacob jun" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" References: <20220329053800.3049561-1-baolu.lu@linux.intel.com> <20220329053800.3049561-4-baolu.lu@linux.intel.com> <20220330190201.GB2120790@nvidia.com> <20220402233210.GM2120790@nvidia.com> <20220406012334.GZ2120790@nvidia.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=-4.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 2022-04-06 06:58, Tian, Kevin wrote: >> From: Jason Gunthorpe >> Sent: Wednesday, April 6, 2022 9:24 AM >> >> On Wed, Apr 06, 2022 at 01:00:13AM +0000, Tian, Kevin wrote: >> >>>> Because domains wrap more than just the IOPTE format, they have >>>> additional data related to the IOMMU HW block itself. Imagine a SOC >>>> with two IOMMU HW blocks that can both process the CPU IOPTE format, >>>> but have different configuration. >>> >>> Curious. Is it hypothesis or real? If real can you help give a concrete >>> example? >> >> Look at arm_smmu_attach_dev() - the domain has exactly one smmu >> pointer which contains the base address for the SMMU IP block. If the >> domain doesn't match the smmu pointer from the struct device it won't >> allow attaching. >> >> I know of ARM SOCs with many copies of the SMMU IP block. >> >> So at least with current drivers ARM seems to have this limitation. >> > > I saw that code, but before this series it is used only for stage-2 instead > of SVA. and I didn't see similar check in the old sva related paths (though > it doesn't use domain): > > arm_smmu_master_sva_enable_iopf() > arm_smmu_master_enable_sva{} > __arm_smmu_sva_bind() > > If I didn't overlook some trick hiding in the call chain of those functions, > is there a bug in the existing SMMU sva logic or is it conceptually correct > to not have such check for SVA? The current SVA APIs are all device-based, so implicitly reflect whichever SMMU instance serves the given device. Once domains come into the picture, callers are going to have to be more aware that a domain may be specific to a particular IOMMU instance, and potentially allocate separate domains for separate devices to represent the same address space, much like vfio_iommu_type1_attach_group() does. It's not really worth IOMMU drivers trying to support a domain spanning potentially-heterogeneous instances internally, since they can't reasonably know what matters in any particular situation. That's primarily why we've never tried to do it in the SMMU drivers. It's a lot easier for relevant callers to look at what they get and figure out whether any mismatch in capabilities is tolerable or not. Robin. > If the former then yes we have to take SMMU IP block into consideration > thus could have multiple domains per CPU page table. If the latter then > this is not a valid example for that configuration. > > Which one is correct? > > Thanks > Kevin