Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp827085ybc; Tue, 19 Nov 2019 09:53:36 -0800 (PST) X-Google-Smtp-Source: APXvYqyc/rdHsRjaILIXitJfXUdamb88IstnH8RgOnDf0uDA6Dp604NwgwHpumq1+xCBG96mPOW3 X-Received: by 2002:adf:f290:: with SMTP id k16mr21605573wro.224.1574186016576; Tue, 19 Nov 2019 09:53:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574186016; cv=none; d=google.com; s=arc-20160816; b=xk8qAhS7oSadI2hcAuhbpFZgIUpGpemviSo7HX10yXOUyeXLk1qGOk4MpLH3jmDpKW +6Pan8zjmmD16Gna+LfEgjdoTi/BQ1yNEcrplnXmPd/W93L+p13dWzdNKE7OrgZmbD96 mm3uEFTtN9RwBs2kQhUoGnb+u2hCNEpYOQY3eWml8tHd2VHlMIr36DRBY7C/s6MWEMJu 3URkbfNLoFonyy3tcJ0KANAz32eXRc5FALqQLuWWyTMGuaX9oEm220uUFCx6tHS5zKcO 1GlWq0l71fb+tuUk+hyLySDQ1sHOwnUDJjOao8O0KVsIlZHp2YqnIeCTPCHg8kaDb9gE 0cYw== 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; bh=YXWkuiyotrAIpay279D2MakQdonDwae+smKwhU9V4tg=; b=Z1ReD/ugzucUyi57HeQUZDcQGdutMx0jEl1nqecq8hdm5Az2G4JkxsakOGt1sU/L5r wfAFlePm1WLQ9ECWNsLPvIvXmscGi+D0bSJgZH4y12AuK2gdu2d5vfN7ueXAoljPnzna OM21mbv0sfDAiNzNoAf7wvqmaw6HkEX5ITGZz6df0K/Q3FYu0ZcjM2P34yFROl4s8JT8 UWy+0Z3n/kd5xpNUUqandBDK54FltXLPGJ2929tBa7ZIHVIVLccBVY5DA/IWyaabWSRW nT4k2qCwPMuuIP3KBRQlOGSmaTG/htW2swryY24/nQLTCpjnDeGGpeIVsz5Xh3VQegGC 2+nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id i24si14575546edr.311.2019.11.19.09.53.12; Tue, 19 Nov 2019 09:53:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727399AbfKSRwC (ORCPT + 99 others); Tue, 19 Nov 2019 12:52:02 -0500 Received: from mga07.intel.com ([134.134.136.100]:14025 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727362AbfKSRwB (ORCPT ); Tue, 19 Nov 2019 12:52:01 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2019 09:52:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,218,1571727600"; d="scan'208";a="209488281" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga006.jf.intel.com with ESMTP; 19 Nov 2019 09:51:58 -0800 From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , "Lu Baolu" , David Woodhouse Cc: "Tian, Kevin" , Raj Ashok , "Yi Liu" , Eric Auger , "Mehta, Sohil" , Jacob Pan Subject: [PATCH v3 5/8] iommu/vt-d: Fix off-by-one in PASID allocation Date: Tue, 19 Nov 2019 09:56:29 -0800 Message-Id: <1574186193-30457-6-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574186193-30457-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1574186193-30457-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 PASID allocator uses IDR which is exclusive for the end of the allocation range. There is no need to decrement pasid_max. Fixes: af39507305fb ("iommu/vt-d: Apply global PASID in SVA") Reported-by: Eric Auger Signed-off-by: Jacob Pan Acked-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 74df10a39dfc..e90d0b914afe 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -338,7 +338,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ /* Do not use PASID 0 in caching mode (virtualised IOMMU) */ ret = intel_pasid_alloc_id(svm, !!cap_caching_mode(iommu->cap), - pasid_max - 1, GFP_KERNEL); + pasid_max, GFP_KERNEL); if (ret < 0) { kfree(svm); kfree(sdev); -- 2.7.4