Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4449903imu; Sat, 19 Jan 2019 09:37:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN6kWErog1mmuFzagdx1AE15LWAmWJzpg48pPJLRKRoFZc8OS0y/eFRiVldP4Rv7KkjtMG99 X-Received: by 2002:a62:1542:: with SMTP id 63mr24065314pfv.230.1547919472164; Sat, 19 Jan 2019 09:37:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547919472; cv=none; d=google.com; s=arc-20160816; b=CVp3b2/Qtik1o5muXYovJHnAxLoK4OOpS3iaqUy8DcN63ygSdPWF/er9pmuUs9O4GE EH5i38YIvSLiiMHxVq76Z5sw7EnNuHKpwLAkpgf6Kr4AsDwck1oFZO2oYKn25ocV3abj 3MlWoj5Ge3JI9oVY1QdejGTSxmRDeAiiXjyP9H7/ElbUvR/gYO0Hgdns/owsLGr8Jtz1 S7TEX2wr48rw7EnLbU/4AlJyWjp7id7RXzHXi4OFMTzqqjCGjc1kl3BzyobgOM5+Lg5K /S6GhgAV1oVol21lrYv/538acDVRnb4Ky2tzFLhhb+BqHbaAj6koV3lYGdEn9LNFAFb4 ve3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :reply-to:message-id:subject:cc:to:from:date; bh=ypvr+OQYTHNW4uY/rsGS/sj1gVmbytj2ZKJs+P5iF1A=; b=EO8VAqGBvwY1P/Jk7Pacr3Q6YN86dpjx1rn4277oUbL4xx0xkdhlhwcerJHZQ9V2f2 MkIV1m/HGNrzf43A7G3Ntbmz9DH9c0i2eExS40GCl+EUJb9nGF5rlX4iE5ZjHyKCO38J eAMQFiDTdzuW+Kk5g/8vBeRKPCCvLZFg4HsmpWGV++Cedfd7cnVVppRb/OFFSZCnftLP 55BhUzN2nXSfpaEiPET1460u34bAqTIT5hopKgMdHMv4F5jEY9dDB1sr+j5G7Tz4QNiY 1S+V1cinterjUkO4qdxCHqiyZvGYf+ysoKRbC45/5yj4C1zP3MwEE/rGyt1B8XlrjYJt t1sg== 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 y29si6599963pgk.376.2019.01.19.09.37.33; Sat, 19 Jan 2019 09:37:52 -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 S1728770AbfASRgO (ORCPT + 99 others); Sat, 19 Jan 2019 12:36:14 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:41269 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728423AbfASRgO (ORCPT ); Sat, 19 Jan 2019 12:36:14 -0500 Received: by mail-qt1-f195.google.com with SMTP id l12so18732628qtf.8 for ; Sat, 19 Jan 2019 09:36:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=ypvr+OQYTHNW4uY/rsGS/sj1gVmbytj2ZKJs+P5iF1A=; b=G3RIaxSyLP7kAXfSf8cnLEcfuTaueSe/VlmOdKCAkocrfxgWMg2HmDWQdkbnlMEzFy uk6L5pSVm2v5Ik1f5pCyoJ0Xs5nryBWgbeDFdCvG1jRFd1qIb/6rCjE6vSxmrHmEkhXF /iYJoe2wZlGp9RmA5b7mdi+zId0BARspdedRinn7A3Ke2KYJDI68RF27ockP8uHBxFOu au3bdLWpBTjHzrq9v/zyHtlFwortxGVxcMF7RllLnXTD61qmjl4Q8/J4klvOiyKA51M6 U5Q16ytZty/j8crLrHQwTBZdn3V7/OXg3GP1ykbqTcPX9XodT7e3luneGzt68gSbWKOr epQA== X-Gm-Message-State: AJcUuke+Lmao9FWUGXjNrqdDbBzGX3TY5oxzuASz2EHRIxpxHqW9CbjY 5e+3KQgUXX6Vgz3Rv7xLupG5i+qcAGM= X-Received: by 2002:a0c:a9da:: with SMTP id c26mr19630056qvb.140.1547919373462; Sat, 19 Jan 2019 09:36:13 -0800 (PST) Received: from localhost (ip72-223-3-97.ph.ph.cox.net. [72.223.3.97]) by smtp.gmail.com with ESMTPSA id v32sm77821479qta.37.2019.01.19.09.36.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 19 Jan 2019 09:36:12 -0800 (PST) Date: Sat, 19 Jan 2019 10:36:11 -0700 From: Jerry Snitselaar To: iommu@lists.linux-foundation.org Cc: linux-kernel@vger.kernel.org, Joerg Roedel , Suravee Suthikulpanit Subject: Re: [PATCH] iommu: amd: call free_iova_fast with pfn in map_sg Message-ID: <20190119173611.reqzqxwgf2z22gby@cantor> Reply-To: Jerry Snitselaar Mail-Followup-To: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Joerg Roedel , Suravee Suthikulpanit References: <20190117192902.15158-1-jsnitsel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190117192902.15158-1-jsnitsel@redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu Jan 17 19, Jerry Snitselaar wrote: >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 > I forgot to add the Fixes line. Fixes: 80187fd39dcb ("iommu/amd: Optimize map_sg and unmap_sg")