Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1613783ybv; Fri, 21 Feb 2020 00:18:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzBzrScgXo14I6r16MaF/Uqu9sQ9ahA3s3/ExGZREq5wuYbJm0n6zJCSFP2uOp5TKvX4WFc X-Received: by 2002:a05:6830:1185:: with SMTP id u5mr25112073otq.147.1582273091915; Fri, 21 Feb 2020 00:18:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273091; cv=none; d=google.com; s=arc-20160816; b=yPit+H7Zd7qGs8N2SvzoGE8f+JfST4FZ3eekADDquQJEqQYo9QUVLGrCNm+/MrIRvO f8r87/Du534B0KjRzo7sWERZdIod8up3RIla14knyVI1J+6pvEYHfuND/EkuJBEIGSKq FXOp+iRX5JXU6L5VWmPPl/zOHz8iumgI2IzE/Fpn5KPI0EUJd8w59m0yE8VApyyO58xv zotkDgFB0XqCoUssSH62DqV8rv5ERItIgZ/4+duO6R9lhAisJw0YYgksYqLKPp3S73Ii mCjdIm8+uOGkL9YWy6HXIoifHgfamsuWnvFMbUJc4tQqFtAm520u6sw43P8CsQ9K6CnP AW1g== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Re/6KM/n98CQrUINBGPDO0Fy8Do8ZRuIisdkf72pCpg=; b=lX88sj1RbeMmUKBWendMh2siy+zgxKOcH6Ln6tck1kFFq4DlI0xCrhBViXhYUljjGa fDCv86zVQgmaItzQpGT9vTgs2jaj0a3nG2Mm+c1gL2DrZmciK9iMox+awK3o+zNffcN5 4XzaRlBqdfJsE7kNyf/zVvOsceiRrPsBdWc2EextJNWLZLXXPj6NdBVCYXomGa7EglkK Mysnr6JTt5gny9MiKC+PN6MuLGlFigTgJlHx1WA+8fgCW8tkIQP4qBmo1CvMYqHY0vaW UUe9hBLpzl/pziFgU5GRt9ahvcL5in7Ut2QFR9VhVvQnMhKqRoO7KsDSK21teqRODyFk zBBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NbamVl0P; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si452145oir.9.2020.02.21.00.17.59; Fri, 21 Feb 2020 00:18:11 -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=@kernel.org header.s=default header.b=NbamVl0P; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387651AbgBUIRS (ORCPT + 99 others); Fri, 21 Feb 2020 03:17:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:54644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387632AbgBUIRQ (ORCPT ); Fri, 21 Feb 2020 03:17:16 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A30D124670; Fri, 21 Feb 2020 08:17:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273035; bh=FTOGElWgnVJw8gJktUCYPCksvhO+Fz5drW+cZvE/jw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NbamVl0PR69AH7j273RKpn38Clcu2KXJDRw6T+/PwBuNKHg8KPPyUlBlptkhGP9ay qKrLhy5ZxW5Idx2XJieLm68gfsut+VZM0XHMxFmYiYqaXuXvoQ0B8mXvfRw0WjxLWa uDfuh5hsKKfr9oetNLXr0IwyUN8WBol7raZ0As0k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Auger , Jacob Pan , Lu Baolu , Joerg Roedel , Sasha Levin Subject: [PATCH 4.19 024/191] iommu/vt-d: Fix off-by-one in PASID allocation Date: Fri, 21 Feb 2020 08:39:57 +0100 Message-Id: <20200221072254.091418459@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jacob Pan [ Upstream commit 39d630e332144028f56abba83d94291978e72df1 ] 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 Reviewed-by: Eric Auger Signed-off-by: Lu Baolu Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- 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 fd8730b2cd46e..5944d3b4dca37 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -377,7 +377,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.20.1