Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2289502imu; Thu, 17 Jan 2019 11:31:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN6uCElBlcQebNaomZVHU9qXKrEfkrjLCJrs6ngnTO/0OphiiUl8H4BV60ypMHSH4VZttzTT X-Received: by 2002:a62:ca9c:: with SMTP id y28mr16151305pfk.236.1547753491859; Thu, 17 Jan 2019 11:31:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547753491; cv=none; d=google.com; s=arc-20160816; b=v53BNr8aSIlpaZfc6TTtG/5PeCKTmr3j0UNa0khDAGKjFBA0OtLACPC+f4xAcg82cN 1O4jbZtu44TlJHrdMm6rCesi2b70xBtPtM8FOqvYfr8qlTgNVY+ezDE0YpQhgWwEki0p NHR2nZ+zOgIzNQZnexUVwwK8eNMCF0DEip5HRDGosl65H3SSG49e7MWRJ0JaBd3QM9vl zypKbQDW1VZJLQPxpgBanuNtUkfdY+LmNFl63LayOUZ0CNevzRcCbYia5cpKviMcvpjp LiliNOR0I9oSlGhzfKEueuH1sYpoB+TrXdb++S5BtXI5NqAG1PahIi1L2fDIMl6wQk6c m1DA== 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 :message-id:date:subject:cc:to:from; bh=XZ19e0aVOQu4I5CqgGY722pvpwkYayODucgdcf+wPSA=; b=KCmRiYkuEgxSfxEFIzieVWRIAWbkoKwCmyhMKOCAzbo/PUdaP4dNaCpbJ2RdBl6BA4 z+UowBDijPQK5qHzKr2d8s38g0IJte13dkOHutoa1HxxeaBWuYtOlKhIxzikhen3XQDD jGAZu/cdJ7GRmpvOcGXN0ubJ4C4fKlKO7a3o6cx6Zpwx31blQMQb7g4H5o+xjdvmZQXR sN8KtbRZdQI/Qum1XkJeVSO0IsKk8bB+tF+Opb6owBhvpn4WoYY2xJ/m/T653apglwMw HHRMjCCJ34Xccl8sSt2qFDXRPypwUmu1b1Vl4CjAeXSBgfosHcA54IJXpqtYHE1hbKJH Tr5g== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s11si2502505pgi.324.2019.01.17.11.31.14; Thu, 17 Jan 2019 11:31:31 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728578AbfAQT3Q (ORCPT + 99 others); Thu, 17 Jan 2019 14:29:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59230 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727672AbfAQT3Q (ORCPT ); Thu, 17 Jan 2019 14:29:16 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD8DC7D0DF; Thu, 17 Jan 2019 19:29:15 +0000 (UTC) Received: from cantor.redhat.com (ovpn-117-84.phx2.redhat.com [10.3.117.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 964AF600C0; Thu, 17 Jan 2019 19:29:15 +0000 (UTC) From: Jerry Snitselaar To: iommu@lists.linux-foundation.org Cc: linux-kernel@vger.kernel.org, Joerg Roedel , Suravee Suthikulpanit Subject: [PATCH] iommu: amd: call free_iova_fast with pfn in map_sg Date: Thu, 17 Jan 2019 12:29:02 -0700 Message-Id: <20190117192902.15158-1-jsnitsel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 17 Jan 2019 19:29:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the error path of map_sg, free_iova_fast is being called with address instead of the pfn. This results in a bad value getting into the rcache, and can result in hitting a BUG_ON when iova_magazine_free_pfns is called. Cc: Joerg Roedel Cc: Suravee Suthikulpanit Signed-off-by: Jerry Snitselaar --- drivers/iommu/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 87ba23a75b38..418df8ff3e50 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2623,7 +2623,7 @@ static int map_sg(struct device *dev, struct scatterlist *sglist, } out_free_iova: - free_iova_fast(&dma_dom->iovad, address, npages); + free_iova_fast(&dma_dom->iovad, address >> PAGE_SHIFT, npages); out_err: return 0; -- 2.20.1.98.gecbdaf0899