Message ID | 20230814011759.102089-2-baolu.lu@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2487539vqi; Sun, 13 Aug 2023 20:08:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpYiwwTsGXuxJtQD9bDP6AqfCBTqSdwgY3MAHsS5R4Tr0RocV42k39PPVi3cM3FSUB8L04 X-Received: by 2002:a05:6870:65a0:b0:1b0:60ff:b73f with SMTP id fp32-20020a05687065a000b001b060ffb73fmr9532036oab.8.1691982492425; Sun, 13 Aug 2023 20:08:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691982492; cv=none; d=google.com; s=arc-20160816; b=gpfN3lZLHetROQtppqGqbRkc6GadH1aSAXI4Ba94bJrgFyZ5OWAxXY1QLiwOwGXfPR m9pNtdPWPugj9/ofsQ30tvVdWCZHz9vS0d8tv+gb+eYP6gmeotzlt/HVI2H+31Aug+y7 os+zthjHWr9bhjHykKGnNB1TgypITnnP60wsFLKuGUrRedSPCRyuhAqw6IMuZLhRSRb6 7d5xA8ftwnLqVRL7QOUF5nQmMNYbSAnm8ycp+h2k6wsYCbBzyI3T71siS7sxjY8493RR siZnUDEI5s3HuFc47nlI59DN19sVwLxr/vzI/rA4B9TCepjZ6AHC+YnDr3WWtwO4GPOb 7TSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lAtE4BR30Yl9zgPzX74U11gG4N8P4nzvzBkfwyOlwCM=; fh=5v0QJkujOnxKSzhmeWiMX/0q9X35NwMz+SRMkKa4moc=; b=cZjKZnB5q2agHKW2txTbUaRYSdMXAuzp/DoSgMW922zPsK1kGSRbjJJO3KRyStqPa3 tYfNBIlOBPD6EVqf9u69zc4/+jANAume6CSHByJKpYQYd5ot7kMpXvDEX73uiVrIqan0 AuVHI9DrKd6fsI1/L/SUdMDziladVBS0Yu7c59VUw2HoC5szpEADaBX8lW3EwiyUtTTO ufib0mQBfM1xqJDWYo/9KeiP7lLzP2U49fXQqhZhKQXxOdJmLprQ97B4OtLR5UCU9hkm HMwvRs1IW04nOVePAbN2KiPLnc21cGkq/Aw2GJlW+AWsDInQQe41sLuTHaNMYE63tKEa h3zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Qrv0sR5e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nv11-20020a17090b1b4b00b00269584b6a10si7676266pjb.15.2023.08.13.20.07.59; Sun, 13 Aug 2023 20:08:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Qrv0sR5e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231768AbjHNBVD (ORCPT <rfc822;274620705z@gmail.com> + 99 others); Sun, 13 Aug 2023 21:21:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231716AbjHNBUd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 13 Aug 2023 21:20:33 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DAF2E6E; Sun, 13 Aug 2023 18:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691976032; x=1723512032; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1VKEBWyIoCdoQh4ifxDFIHU7H3LnyvQp0GU6ahA/QQE=; b=Qrv0sR5eRASz2+cnddIJc2aipVni2jlP8zyLSrTa2yiEXlIPkSy2f3kq 5hbFOFk4l84ZpIq7ncNPOGwAH6DOSayKba1Dx6PGj2LYfmGmQAPUdsVIm 75khmaGbGL3fkKqb8grqrLWCxYI1zVhcFcRGhm5OaOiJlDxMoX/DkyCFD foyKxGLpTPwOvpmmDFU8pCyal3+EAwvk1AsMi7BDyPzHJvC7RBJi1RNdW lzicgRlKgmLhUI76WDmzm1BWFxHeHIwMaqcStcbaXm2bEoeed+0tdkzBy D8De356fcbE5gime2X5E6yP7GqKvSgSe3EcHShadsDCKiaDf4xrdXclQ5 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10801"; a="375645305" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="375645305" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2023 18:20:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10801"; a="726842292" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="726842292" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orsmga007.jf.intel.com with ESMTP; 13 Aug 2023 18:20:28 -0700 From: Lu Baolu <baolu.lu@linux.intel.com> To: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>, Robin Murphy <robin.murphy@arm.com>, Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>, Jean-Philippe Brucker <jean-philippe@linaro.org>, Nicolin Chen <nicolinc@nvidia.com> Cc: Yi Liu <yi.l.liu@intel.com>, Jacob Pan <jacob.jun.pan@linux.intel.com>, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Lu Baolu <baolu.lu@linux.intel.com> Subject: [PATCH v2 1/3] iommu: Make single-device group for PASID explicit Date: Mon, 14 Aug 2023 09:17:57 +0800 Message-Id: <20230814011759.102089-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230814011759.102089-1-baolu.lu@linux.intel.com> References: <20230814011759.102089-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774172233961004971 X-GMAIL-MSGID: 1774172233961004971 |
Series |
iommu: Make pasid array per device
|
|
Commit Message
Baolu Lu
Aug. 14, 2023, 1:17 a.m. UTC
The PASID interfaces have always supported only single-device groups.
This was first introduced in commit 26b25a2b98e45 ("iommu: Bind process
address spaces to devices"), and has been kept consistent in subsequent
commits.
However, the core code doesn't explicitly check for this requirement
after commit 201007ef707a8 ("PCI: Enable PASID only when ACS RR & UF
enabled on upstream path"), which made this requirement implicit.
Restore the check to make it explicit that the PASID interfaces only
support devices belonging to single-device groups.
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
drivers/iommu/iommu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 71b9c41f2a9e..f1eba60e573f 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -3408,6 +3408,11 @@ int iommu_attach_device_pasid(struct iommu_domain *domain, return -ENODEV; mutex_lock(&group->mutex); + if (list_count_nodes(&group->devices) != 1) { + ret = -EINVAL; + goto out_unlock; + } + curr = xa_cmpxchg(&group->pasid_array, pasid, NULL, domain, GFP_KERNEL); if (curr) { ret = xa_err(curr) ? : -EBUSY;