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 7337EC4167B for ; Thu, 7 Dec 2023 02:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443028AbjLGCYM (ORCPT ); Wed, 6 Dec 2023 21:24:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbjLGCYL (ORCPT ); Wed, 6 Dec 2023 21:24:11 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F0B5D5C for ; Wed, 6 Dec 2023 18:24:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701915858; x=1733451858; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BlyFybv+wIkSnOIH0bgSDQUnQo1Qmc4Q1qqIz58xmyg=; b=DcLqoK4uqAI3ePp5gUDv8cm6mF0CGB6ehXBTMa8cy8SZTQAYPBNfbcvf xD/Hy4NxV0dxj0d3oU+GW5OEd9E9khrH0ONj1/SolBVLXxmwHdvuZ772C SOtgYJEgYG090IXdDCpDmxxLzVj0Q8Xg4v3Zbva1PKvlv10YXoW0fh9xy Fp8SRnFlH5nkZzNa06qKMsDBI51u6fQ39WjOTZPuCL68OX0ZapiFdPY2M G65JDkVszESdOOwseIyJHgGBRfy66ZOIWHSnaE2KGJzZJ5OBnPowqB8V+ Mreu8qk4wOnG/C7Ib6ULdS4d3HL9ibbhVjkSUCmnbeYHO1MP6//IMj1+g A==; X-IronPort-AV: E=McAfee;i="6600,9927,10916"; a="391331282" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="391331282" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2023 18:24:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10916"; a="805848827" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="805848827" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orsmga001.jf.intel.com with ESMTP; 06 Dec 2023 18:24:15 -0800 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 1/1] iommu: Set owner token to sva and nested domains Date: Thu, 7 Dec 2023 10:19:38 +0800 Message-Id: <20231207021938.306738-1-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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; -- 2.34.1