Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3308889ybc; Mon, 18 Nov 2019 13:03:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzRXFhlnJSf9t1rcjfSXUy3iarm8qAYhxSQrkCSFZVJlm7fLt1SeyN1nSVAR2P+AZUwMDGf X-Received: by 2002:adf:ffd0:: with SMTP id x16mr31236323wrs.86.1574110989999; Mon, 18 Nov 2019 13:03:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574110989; cv=none; d=google.com; s=arc-20160816; b=xIvg7YZelLWNKDqXFzV/Q4jW3vnNMzRr9e+qOIvFofQZdFQ9+KpzZmK/NTwFRMtkQq yjcONI8bzVH2ozsqUw2jqI4MFz15Uk4lm7z1DyogG45jqEZoUrHZLwVvKB836JnL6pQy zuTM1NRB5Zq3koSVPuLX4fDdYG5YyQ522apCmNFLEcwFvqHyP3kOQ3ak0BfLJX+RGv5+ 79UIcg13FUUHBaBeJ0M+NbuZ13Vi1WzWNHbiZhZtDekIchGd6YZCCxAbOqK70xAyhn2z 8dRRBc3gHE2WqkNEJh2Wo8I5nJ0zOHetpvZiwXg/lSGpzCFJl2KLjrmuvvBeZZvMzMsX HoMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=kC6Y3GwIX6OxAnnLNWrf9PEut2lB178HS0m5ycQ+01w=; b=e+wgz3XcnA96BpoztvpAUhPBXHmSp2Nnt4JIxfvGPp3mDis6dVC23S/QdVbnFYZYEl GbPmz8EHADWvagH1Nl+Vdga+/QEKpm/2aWVAHuvpEmtOFHZ0f5EjC6VqQi0w3InGJO5f I1CAfXinvyvLBH701NCd3J3SNeifMLrkytI4b7dNpq/ViTg6Jmzbbe746beRBmGFvL35 Kjo+gmswUHZ/iQL8MppxaEv/OJlVNsYXtrdjKvjN7sN9q86J+i/Lz7xMie5cJobMmI+X BTlV/kHiJRtTgkgtUEVn9GFUsIWnYs1shX7PY//s7mNvqACf6j44M02QWvxWTMdFGZWp ELwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O2I73+ux; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t26si13194342edc.102.2019.11.18.13.02.45; Mon, 18 Nov 2019 13:03:09 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O2I73+ux; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbfKRVAq (ORCPT + 99 others); Mon, 18 Nov 2019 16:00:46 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:55339 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726272AbfKRVAq (ORCPT ); Mon, 18 Nov 2019 16:00:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574110845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kC6Y3GwIX6OxAnnLNWrf9PEut2lB178HS0m5ycQ+01w=; b=O2I73+uxbZ3z9fJNLMbc0cE1dyjTHEWbHA4TpkksaGZ1udqxL7LlGRsI+5gAncdfnqbejO BtrmY/aBFrjzRy8rFuzE2oZH1tTsMs6tmwwAP9YnzMWE/JkAqrZCH5fdDFqtsGo/l06YvG goeuWqnFlb4nbRNwTxf07hg7aj0KdUw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-226-NY0E2NBpOMWsV0CGWrdK0g-1; Mon, 18 Nov 2019 16:00:43 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42B398024D0; Mon, 18 Nov 2019 21:00:42 +0000 (UTC) Received: from [10.36.116.37] (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8DCDB60BE2; Mon, 18 Nov 2019 21:00:39 +0000 (UTC) Subject: Re: [PATCH v2 06/10] iommu/vt-d: Fix off-by-one in PASID allocation To: Jacob Pan , iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Lu Baolu , David Woodhouse Cc: "Tian, Kevin" , Raj Ashok , Yi Liu References: <1574106153-45867-1-git-send-email-jacob.jun.pan@linux.intel.com> <1574106153-45867-7-git-send-email-jacob.jun.pan@linux.intel.com> From: Auger Eric Message-ID: <9226a541-3794-33f2-d4a8-420fff516a5d@redhat.com> Date: Mon, 18 Nov 2019 22:00:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <1574106153-45867-7-git-send-email-jacob.jun.pan@linux.intel.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: NY0E2NBpOMWsV0CGWrdK0g-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacob, On 11/18/19 8:42 PM, Jacob Pan wrote: > PASID allocator uses IDR which is exclusive for the end of the > allocation range. There is no need to decrement pasid_max. >=20 > 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(-) >=20 > 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_ > =09=09/* Do not use PASID 0 in caching mode (virtualised IOMMU) */ > =09=09ret =3D intel_pasid_alloc_id(svm, > =09=09=09=09=09 !!cap_caching_mode(iommu->cap), > -=09=09=09=09=09 pasid_max - 1, GFP_KERNEL); > +=09=09=09=09=09 pasid_max, GFP_KERNEL); > =09=09if (ret < 0) { > =09=09=09kfree(svm); > =09=09=09kfree(sdev); >=20 Reviewed-by: Eric Auger Thanks Eric