From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F2E8C433FE for ; Wed, 6 Apr 2022 15:21:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236012AbiDFPXd (ORCPT ); Wed, 6 Apr 2022 11:23:33 -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 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