Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1243563pxa; Thu, 20 Aug 2020 06:35:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5dFKLiQvBFq6iUAiYYRms9cmzOLDzWzbHyH+Dx3JZ9K0DmTi8mZFWk1ZaAADPzC+3ZT2W X-Received: by 2002:a17:906:c310:: with SMTP id s16mr3335240ejz.466.1597930538442; Thu, 20 Aug 2020 06:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597930538; cv=none; d=google.com; s=arc-20160816; b=JAOcBctTwmzfoPlUHjK5Cs8Qa+QGsx53b/ozuKkcRtNE5ZK7Se4uL6n+JzrnzIPLE5 McPaIwO/Au1QqR3SbKYaVPjD3sUHllQnj+PrXqpnsXAlBnzIck791QZLVlrbSlSMW4Ra +n0Uj6uwq4QCFpRklFyC9KN59eNRqqXiR2PzTHrejfk85Z6BL4+LkWYlxJTXQFWNsavc jhOuZxTAE6FXYGlzqMdPb+r4wItgo9ffzx1S8EGHjh5IiS+EoE5yyqP/hGs780Y+bVAy 7X4qLQRlxFO4QGR5g3SoZbI/SP0mfYYLo7ynHz2RrmfB3L48vlYcXr7DDXljKYJAMrKR N7QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MlkYaU3dP/uKgeVBlAgnFXnaxGuOgP9CfB8bJnzt5Tc=; b=U4oOu+6bwR2zxBpXaCSxuJWKDqznw5dExWOlWCrq1AxdQRAVEKDQcjEqegGF1UTp+I GV1hK1XdgkoQTwq6q8eg73kYWp/LbGnkCwLzbZD7gd+y8bDK8axAjLY45ds5itW1bEMh ijV0GhUFtojMzqkO0N7/OcLUS63LXiTGeJOGfpgEDPPKcAJELZQgmoilIwwB/rWaxT4r eTtsIsW5v24BTUNlVs89P65vFY4VA9Eua/Ll7TR1cWWBZ/ldCk0ETIl0VS7syA+CTBcq UrrgFq1T5hBb5HfYFd701CT4FfXZG9SU+ZPY/Nj2HhKenw/896P2e6oOD3+2SVGZZWhP VPTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dndZZdeR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lt7si1116705ejb.272.2020.08.20.06.35.14; Thu, 20 Aug 2020 06:35:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dndZZdeR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729414AbgHTNbs (ORCPT + 99 others); Thu, 20 Aug 2020 09:31:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:44914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728268AbgHTJcc (ORCPT ); Thu, 20 Aug 2020 05:32:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 21EF322B43; Thu, 20 Aug 2020 09:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915948; bh=oXeyNpkxSpAQTKEQp60xwWYuLDvULSId889n38AnUOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dndZZdeRv9i4fI25FG/YRe1hZxo1+cnAqaD3KdyyK1AmkMc8xrjCm+X7p5FPbuHaG sy8f5DdthX40ZY4PPnBcVynl6RalX6Q2xbGP8D4v5a3o1RfbzHX2Eu+yMcTQ+LrPE3 h6SG06MyY07cz3y7d0RHPArUYT2j6/ccHCEelgsw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liu Yi L , Jacob Pan , Lu Baolu , Eric Auger , Kevin Tian , Joerg Roedel , Sasha Levin Subject: [PATCH 5.8 161/232] iommu/vt-d: Disable multiple GPASID-dev bind Date: Thu, 20 Aug 2020 11:20:12 +0200 Message-Id: <20200820091620.610996163@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jacob Pan [ Upstream commit d315e9e684d1efd4cb2e8cd70b8d71dec02fcf1f ] For the unlikely use case where multiple aux domains from the same pdev are attached to a single guest and then bound to a single process (thus same PASID) within that guest, we cannot easily support this case by refcounting the number of users. As there is only one SL page table per PASID while we have multiple aux domains thus multiple SL page tables for the same PASID. Extra unbinding guest PASID can happen due to race between normal and exception cases. Termination of one aux domain may affect others unless we actively track and switch aux domains to ensure the validity of SL page tables and TLB states in the shared PASID entry. Support for sharing second level PGDs across domains can reduce the complexity but this is not available due to the limitations on VFIO container architecture. We can revisit this decision once sharing PGDs are available. Overall, the complexity and potential glitch do not warrant this unlikely use case thereby removed by this patch. Fixes: 56722a4398a30 ("iommu/vt-d: Add bind guest PASID support") Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan Signed-off-by: Lu Baolu Reviewed-by: Eric Auger Cc: Kevin Tian Link: https://lore.kernel.org/r/20200724014925.15523-8-baolu.lu@linux.intel.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/intel/svm.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 6c87c807a0abb..d386853121a26 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -277,20 +277,16 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev, goto out; } + /* + * Do not allow multiple bindings of the same device-PASID since + * there is only one SL page tables per PASID. We may revisit + * once sharing PGD across domains are supported. + */ for_each_svm_dev(sdev, svm, dev) { - /* - * For devices with aux domains, we should allow - * multiple bind calls with the same PASID and pdev. - */ - if (iommu_dev_feature_enabled(dev, - IOMMU_DEV_FEAT_AUX)) { - sdev->users++; - } else { - dev_warn_ratelimited(dev, - "Already bound with PASID %u\n", - svm->pasid); - ret = -EBUSY; - } + dev_warn_ratelimited(dev, + "Already bound with PASID %u\n", + svm->pasid); + ret = -EBUSY; goto out; } } else { -- 2.25.1