Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3230007ybc; Mon, 18 Nov 2019 11:40:37 -0800 (PST) X-Google-Smtp-Source: APXvYqw9e8Iv47y3THOzzYLmnRVWNm1xu8IG6JeyZee8UCZmKabr1uxKv8TNZd3nbmbhXq4lS6YU X-Received: by 2002:a05:6000:1184:: with SMTP id g4mr17783253wrx.234.1574106037291; Mon, 18 Nov 2019 11:40:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574106037; cv=none; d=google.com; s=arc-20160816; b=nxihTzsnWrwLrES1lsnPcGW99Zhk8UO1JyHRzLbF0MMbWL7FbRxdH9sqRcrWh8yE3k yBJpUdamah477Aksbg+penDqupEudLOlXtpNOFdpqj2Bxp9tejEyR3rEAlVWcvpVaRjW UGkQFYChqn7ihkBxXRum5BTEP8zbpD+oC/Mp3ftC7DnLMl5xTkw6rJA8uHFsIUpAhoff jrkEq8eGhraH5Pge7D8SkLU4x6QZ+AN6klBx0jU+JTkjrgxqtpWbWIMfsXgiAl04IFev l0prfrXZberrqgma5+C1+70ThMf98AvG1Wfyy1pFGWlSOOgxnTW9ugMwkaWs4UvrselK sJVw== 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=DTbuJH+Z+Rw6BGyBMZbi0aeNoUAxa7Rc5MRMKp4rAbfQ/0izFtvGNF+q0snohZsENi 9Y+KEkXCdBYiBo+aHqZrJdF3LApvqau6jjYO1dzLXqITbpKRtazMFoFoEvvOXulbcVlE IGA4hJP1NDPKqgq9DIbJaHc8aHheh5JTjpM6cFndGF+jRLYH9U7miHZ+HdtoL7cQfoPv LhNVqX0vmWT4CaM0JJOPgF2QGKxcLvGyTCCGcifzBVo3rgUKaSrkEK7gUTGzXSE3Jqiw CNGdkx3XuZfYBfXf8K1fo5Y+3WHkDX7ZTEzR8+Rre8Id/SqauMwAMBllM2b9+hMY676u jIwA== 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 d21si14816600edb.180.2019.11.18.11.39.54; Mon, 18 Nov 2019 11:40:37 -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 S1727113AbfKRTiV (ORCPT + 99 others); Mon, 18 Nov 2019 14:38:21 -0500 Received: from mga02.intel.com ([134.134.136.20]:60271 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbfKRTiA (ORCPT ); Mon, 18 Nov 2019 14:38:00 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Nov 2019 11:37:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,321,1569308400"; d="scan'208";a="380760862" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga005.jf.intel.com with ESMTP; 18 Nov 2019 11:37:59 -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 , Jacob Pan Subject: [PATCH v2 06/10] iommu/vt-d: Fix off-by-one in PASID allocation Date: Mon, 18 Nov 2019 11:42:29 -0800 Message-Id: <1574106153-45867-7-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574106153-45867-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1574106153-45867-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