From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751591AbdJTAs6 (ORCPT ); Thu, 19 Oct 2017 20:48:58 -0400 Received: from mga09.intel.com ([134.134.136.24]:34284 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360AbdJTAs5 (ORCPT ); Thu, 19 Oct 2017 20:48:57 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,404,1503385200"; d="scan'208";a="164785573" Subject: Re: [PATCH 1/3] iommu/vt-d: Missing checks for pasid tables if allocation fails To: "Liu, Yi L" , "joro@8bytes.org" , "dwmw2@infradead.org" References: <1508373556-5340-1-git-send-email-baolu.lu@linux.intel.com> Cc: "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" From: Lu Baolu Message-ID: <59E947F7.4030402@linux.intel.com> Date: Fri, 20 Oct 2017 08:48:55 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yi, On 10/19/2017 02:40 PM, Liu, Yi L wrote: > >> -----Original Message----- >> From: iommu-bounces@lists.linux-foundation.org [mailto:iommu- >> bounces@lists.linux-foundation.org] On Behalf Of Lu Baolu >> Sent: Thursday, October 19, 2017 8:39 AM >> To: joro@8bytes.org; dwmw2@infradead.org >> Cc: iommu@lists.linux-foundation.org; linux-kernel@vger.kernel.org >> Subject: [PATCH 1/3] iommu/vt-d: Missing checks for pasid tables if allocation fails >> >> intel_svm_alloc_pasid_tables() might return an error but never be checked by the >> callers. Later when intel_svm_bind_mm() is called, there are no checks for valid pasid >> tables before enabling them. >> >> Signed-off-by: Ashok Raj >> Signed-off-by: Lu Baolu >> --- >> drivers/iommu/intel-svm.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index >> f6697e5..43280ca 100644 >> --- a/drivers/iommu/intel-svm.c >> +++ b/drivers/iommu/intel-svm.c >> @@ -292,7 +292,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int >> flags, struct svm_dev_ >> int pasid_max; >> int ret; >> >> - if (WARN_ON(!iommu)) >> + if (WARN_ON(!iommu || !iommu->pasid_table)) > [Liu, Yi L] Hi Baolu, I guess there also need a check to iommu->ecap , see if the pasid bit > is reported. thoughts? > If pasid bit is not set in ecap register, iommu->pasid_table won't be set. We did this by: if (pasid_enabled(iommu)) intel_svm_alloc_pasid_tables(iommu); Best regards, Lu Baolu