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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 948EDC43334 for ; Fri, 24 Jun 2022 18:32:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4QZIZrxv32O2DTlTZzPr7qRJKGYdXktq4RK6QJQM9kA=; b=QzWaJ3S0jQanFiGryxBSIpTbly XIEuPTLaxWK6YRGV8kGQpAha9CcOPuphGBEgAPz611TAeJLyvgutqGAay1ThA+VdoGfQOxxmg+Q0U hxHBeDdQlXm+jTQwF49SR3woEOm1lG9/+hjUjWL0M7U7JJJbfVqe7gf7WlbFgXZ8REZXTtIZd1/Hp QkphFkwaAkJWtQp+8tDNNHpV3lifxKGn1G1i5VHYMjOy2iXbwSgbPMdc12kR4REM5kBKbqI7vA0D1 3Sfbk7xeCxSQi5Hy5yGIeoNR6IUib5v+G3ceP4ucrORXyK5fSRQ6mz73vXN3prnWJ8kF3uz4LylE+ KFnzmIKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4o6J-003TaG-A9; Fri, 24 Jun 2022 18:32:15 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4o66-003TVV-HW; Fri, 24 Jun 2022 18:32:04 +0000 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 E9BE31042; Fri, 24 Jun 2022 11:31:59 -0700 (PDT) Received: from [10.57.84.111] (unknown [10.57.84.111]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 862573F792; Fri, 24 Jun 2022 11:31:53 -0700 (PDT) Message-ID: Date: Fri, 24 Jun 2022 19:31:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v2 3/5] vfio/iommu_type1: Remove the domain->ops comparison Content-Language: en-GB To: Jason Gunthorpe Cc: Nicolin Chen , "Tian, Kevin" , "joro@8bytes.org" , "will@kernel.org" , "marcan@marcan.st" , "sven@svenpeter.dev" , "robdclark@gmail.com" , "baolu.lu@linux.intel.com" , "matthias.bgg@gmail.com" , "orsonzhai@gmail.com" , "baolin.wang7@gmail.com" , "zhang.lyra@gmail.com" , "jean-philippe@linaro.org" , "alex.williamson@redhat.com" , "suravee.suthikulpanit@amd.com" , "alyssa@rosenzweig.io" , "dwmw2@infradead.org" , "yong.wu@mediatek.com" , "mjrosato@linux.ibm.com" , "gerald.schaefer@linux.ibm.com" , "thierry.reding@gmail.com" , "vdumpa@nvidia.com" , "jonathanh@nvidia.com" , "cohuck@redhat.com" , "thunder.leizhen@huawei.com" , "tglx@linutronix.de" , "christophe.jaillet@wanadoo.fr" , "john.garry@huawei.com" , "chenxiang66@hisilicon.com" , "saiprakash.ranjan@codeaurora.org" , "isaacm@codeaurora.org" , "yangyingliang@huawei.com" , "jordan@cosmicpenguin.net" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-arm-msm@vger.kernel.org" , "linux-mediatek@lists.infradead.org" , "linux-s390@vger.kernel.org" , "linux-tegra@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "kvm@vger.kernel.org" References: <20220616000304.23890-1-nicolinc@nvidia.com> <20220616000304.23890-4-nicolinc@nvidia.com> <6e1280c5-4b22-ebb3-3912-6c72bc169982@arm.com> <20220624131611.GM4147@nvidia.com> From: Robin Murphy In-Reply-To: <20220624131611.GM4147@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220624_113202_727837_50EC17E4 X-CRM114-Status: GOOD ( 17.92 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On 2022-06-24 14:16, Jason Gunthorpe wrote: > On Wed, Jun 22, 2022 at 08:54:45AM +0100, Robin Murphy wrote: >> On 2022-06-16 23:23, Nicolin Chen wrote: >>> On Thu, Jun 16, 2022 at 06:40:14AM +0000, Tian, Kevin wrote: >>> >>>>> The domain->ops validation was added, as a precaution, for mixed-driver >>>>> systems. However, at this moment only one iommu driver is possible. So >>>>> remove it. >>>> >>>> It's true on a physical platform. But I'm not sure whether a virtual platform >>>> is allowed to include multiple e.g. one virtio-iommu alongside a virtual VT-d >>>> or a virtual smmu. It might be clearer to claim that (as Robin pointed out) >>>> there is plenty more significant problems than this to solve instead of simply >>>> saying that only one iommu driver is possible if we don't have explicit code >>>> to reject such configuration. 😊 >>> >>> Will edit this part. Thanks! >> >> Oh, physical platforms with mixed IOMMUs definitely exist already. The main >> point is that while bus_set_iommu still exists, the core code effectively >> *does* prevent multiple drivers from registering - even in emulated cases >> like the example above, virtio-iommu and VT-d would both try to >> bus_set_iommu(&pci_bus_type), and one of them will lose. The aspect which >> might warrant clarification is that there's no combination of supported >> drivers which claim non-overlapping buses *and* could appear in the same >> system - even if you tried to contrive something by emulating, say, VT-d >> (PCI) alongside rockchip-iommu (platform), you could still only describe one >> or the other due to ACPI vs. Devicetree. > > Right, and that is still something we need to protect against with > this ops check. VFIO is not checking that the bus's are the same > before attempting to re-use a domain. > > So it is actually functional and does protect against systems with > multiple iommu drivers on different busses. But as above, which systems *are* those? Everything that's on my radar would have drivers all competing for the platform bus - Intel and s390 are somewhat the odd ones out in that respect, but are also non-issues as above. FWIW my iommu/bus dev branch has got as far as the final bus ops removal and allowing multiple driver registrations, and before it allows that, it does now have the common attach check that I sketched out in the previous discussion of this. It's probably also noteworthy that domain->ops is no longer the same domain->ops that this code was written to check, and may now be different between domains from the same driver. Thanks, Robin.