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 6A335C4167B for ; Thu, 7 Dec 2023 10:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231223AbjLGKMl (ORCPT ); Thu, 7 Dec 2023 05:12:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232435AbjLGJ4I (ORCPT ); Thu, 7 Dec 2023 04:56:08 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 228A4132 for ; Thu, 7 Dec 2023 01:56:14 -0800 (PST) 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 E31B512FC; Thu, 7 Dec 2023 01:56:59 -0800 (PST) Received: from [10.57.74.174] (unknown [10.57.74.174]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B579F3F762; Thu, 7 Dec 2023 01:56:12 -0800 (PST) Message-ID: Date: Thu, 7 Dec 2023 09:56:10 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] iommu: Set owner token to sva and nested domains Content-Language: en-GB To: Lu Baolu , Joerg Roedel , Will Deacon , Jason Gunthorpe , Kevin Tian Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20231207021938.306738-1-baolu.lu@linux.intel.com> From: Robin Murphy In-Reply-To: <20231207021938.306738-1-baolu.lu@linux.intel.com> 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 2023-12-07 2:19 am, Lu Baolu wrote: > Commit a9c362db3920 ("iommu: Validate that devices match domains") added > an owner token to an iommu_domain. This token is checked during domain > attachment to RID or PASID through the generic iommu interfaces. > > The sva and nested domains are attached to device or PASID through the > generic iommu interfaces. Therefore, they require the owner token to be > set during allocation. Otherwise, they fail to attach. Oops, I missed that iommu_sva_domain_alloc() is a thing - when did we get such a confusing proliferation of domain allocation paths? Sigh... I think we should set the owner generically there, since presumably it's being missed for SMMUv3/AMD/etc. SVA domains as well. Nested domains are supposed to be OK since both ->domain_alloc_user callsites are covered, or is there some other sneaky path I've also missed? Thanks, Robin. > Set the owner token for sva and nested domains. > > Fixes: a9c362db3920 ("iommu: Validate that devices match domains") > Cc: Robin Murphy > Signed-off-by: Lu Baolu > --- > drivers/iommu/intel/nested.c | 1 + > drivers/iommu/iommu.c | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/drivers/iommu/intel/nested.c b/drivers/iommu/intel/nested.c > index b5a5563ab32c..014d4a4e7586 100644 > --- a/drivers/iommu/intel/nested.c > +++ b/drivers/iommu/intel/nested.c > @@ -108,6 +108,7 @@ struct iommu_domain *intel_nested_domain_alloc(struct iommu_domain *parent, > domain->s1_cfg = vtd; > domain->domain.ops = &intel_nested_domain_ops; > domain->domain.type = IOMMU_DOMAIN_NESTED; > + domain->domain.owner = &intel_iommu_ops; > INIT_LIST_HEAD(&domain->devices); > INIT_LIST_HEAD(&domain->dev_pasids); > spin_lock_init(&domain->lock); > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index 0d25468d53a6..d0a28667479a 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -3617,6 +3617,7 @@ struct iommu_domain *iommu_sva_domain_alloc(struct device *dev, > domain->type = IOMMU_DOMAIN_SVA; > mmgrab(mm); > domain->mm = mm; > + domain->owner = ops; > domain->iopf_handler = iommu_sva_handle_iopf; > domain->fault_data = mm; >