Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp576777ybt; Mon, 6 Jul 2020 17:07:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIsc35+Rva1/B1Pbc2qLOyoIiWcAoGlqj1zWCWs7xDhsGW5nlvIVaSuCCAS6oynrZkRM+w X-Received: by 2002:aa7:db4f:: with SMTP id n15mr42243460edt.193.1594080420655; Mon, 06 Jul 2020 17:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594080420; cv=none; d=google.com; s=arc-20160816; b=aTWONf+f0l138YlwLW0ryQTcuuk6LvHgfXNL7CF27v+oGBIJaNdI1faKaCXbthJNNQ hAigbLWicxj5b+2Cyue+L750/FnNabYIk/UcjmqjTE4HqchXbKS04mkjPDbHO6z7Linf 6fX+/bO9q0CzoDnpQJkZC9feGoFErpSHdFSLfloKryxZXlORAf9FZijB6Iu7WL7oU8/V 3gCIZKr6xN+wmlbai/tCjgM2wrEMu9xSJIQFBJvrFQYoLi4uC4p1dde/jPK5Nfeoh6vt cecRP7jPrxH/m3V3U/C0SH8K4MhkDQ/v54UqLACYBFGKAbx2d8gJd9W+37Bwr8aam0uQ P2cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=K1tt91l0OZUIgzc7oHxdqHb8UoKkpPjD6khmZDhwQvM=; b=yLtdmZWDV+7br5uvJXu0/On/uEfzvX9U/2vM9S4kX4l+vZsnAn2tyWVoD1zZE1f2Bk xAE9ON5UBVmtVFxfdrNAKkMgSninurlFUbUCtZJNMh0Zidwg+C1Q+MIO7mucgAtyM9iJ 4yMhXqzG4FT7cxtY4FBAzZyvSj1bOwd+ERjP1JifBLkFYY7Uj7QQBTrM23EU44JYOwdh nwqDRNla/H1s8Nz4ePeeA9T3Pbt5Lex2ZJ94kfrKj6EXSdiAE0XGwsmglrihWPYOjjmW klLkL6rRQYSxlO5IBtuG8hFyJXaP5xl/b3pbyqmV6h649W0OohRLiSiapwjFc2ujOTKH DLqw== ARC-Authentication-Results: i=1; mx.google.com; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si19516276edz.250.2020.07.06.17.06.37; Mon, 06 Jul 2020 17:07:00 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726478AbgGGAGY (ORCPT + 99 others); Mon, 6 Jul 2020 20:06:24 -0400 Received: from mga07.intel.com ([134.134.136.100]:18972 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727827AbgGGAGV (ORCPT ); Mon, 6 Jul 2020 20:06:21 -0400 IronPort-SDR: EHK1Ctxpg1qQfZGvYURlSCNT2TIKlLha4gi8Pz9g4b+bUrFH8x65yQKLJToc2jxntR+3LKMlm4 kSN+QL5V0j0Q== X-IronPort-AV: E=McAfee;i="6000,8403,9674"; a="212492295" X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="212492295" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 17:06:17 -0700 IronPort-SDR: zIKUYel984wcBdO+TLjmSOReSJwSakFRRGa9gt4eyUT3zw+W/tvb3jMJlmnjGzGml0C6FqTgnX xPgt4TuSi+Fw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="456913831" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga005.jf.intel.com with ESMTP; 06 Jul 2020 17:06:17 -0700 From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , "Lu Baolu" , Joerg Roedel , David Woodhouse Cc: Yi Liu , "Tian, Kevin" , Raj Ashok , Eric Auger , Jacob Pan Subject: [PATCH v4 7/7] iommu/vt-d: Disable multiple GPASID-dev bind Date: Mon, 6 Jul 2020 17:12:54 -0700 Message-Id: <1594080774-33413-8-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594080774-33413-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1594080774-33413-1-git-send-email-jacob.jun.pan@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") Acked-by: Lu Baolu Cc: Kevin Tian Cc: Lu Baolu Reviewed-by: Eric Auger Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- 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 6c87c807a0ab..d386853121a2 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.7.4