From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751779AbdJSAo5 (ORCPT ); Wed, 18 Oct 2017 20:44:57 -0400 Received: from mga07.intel.com ([134.134.136.100]:16470 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751726AbdJSAot (ORCPT ); Wed, 18 Oct 2017 20:44:49 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,398,1503385200"; d="scan'208";a="324920796" From: Lu Baolu To: joro@8bytes.org, dwmw2@infradead.org Cc: ashok.raj@intel.com, jacob.jun.pan@linux.intel.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 3/3] iommu/vt-d: Clear pasid table entry when memory unbound Date: Thu, 19 Oct 2017 08:39:16 +0800 Message-Id: <1508373556-5340-3-git-send-email-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508373556-5340-1-git-send-email-baolu.lu@linux.intel.com> References: <1508373556-5340-1-git-send-email-baolu.lu@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In intel_svm_unbind_mm(), pasid table entry must be cleared during svm free. Otherwise, hardware may be set up with a wild pointer. Suggested-by: Ashok Raj Signed-off-by: Lu Baolu --- drivers/iommu/intel-svm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index 43280ca..ed1cf7c 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -458,6 +458,8 @@ int intel_svm_unbind_mm(struct device *dev, int pasid) kfree_rcu(sdev, rcu); if (list_empty(&svm->devs)) { + svm->iommu->pasid_table[svm->pasid].val = 0; + wmb(); idr_remove(&svm->iommu->pasid_idr, svm->pasid); if (svm->mm) -- 2.7.4