Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1790039imc; Tue, 12 Mar 2019 00:10:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkMRmAijyM8FjD+n+7pGDhPUbZmRb0yUptytXS3Nw92XQkkJSirMob/LKSoH5eL/gAG0BH X-Received: by 2002:a17:902:bd02:: with SMTP id p2mr37843436pls.260.1552374637354; Tue, 12 Mar 2019 00:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552374637; cv=none; d=google.com; s=arc-20160816; b=m4kpe0UDsS0UbVrvTEh2DmqiHiWfekgCak2sKwmYnZpuTUHM5icAEfRgFZNXZOV7qO uSAEHKD4zkNdl5q10R3hcaSTLzrWf7aeCJV2sEH8OcrOjadiMxhdO1D7yJRam/kchjGL up3EKowG1/3gv9/nJkHGOWVb/K6QF/AXeSUMfz/ogbY3ZsgwBIvNTVEyP7lPrExS80y+ 2XR65jKiLkdSMmQ5nlMOoNL3amBp+opTSYuuO00Fxx4ifEsb0DeuB2h6i3xO0pnVbZxV ia+ydrIyUwTfiGlje4Yvd3MdGw8rbjpJhL4alRI3nkS9LV0dslnWaNTDjOBxtZMKSrEy yNoA== 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:message-id:subject:cc :to:from:date; bh=nYu/wB5mDAPYARR53Vipcn+NnwyGm+FGRc074XyTbms=; b=PyfJUQGokcZwcniTTdtT2Vk3Kfd+ZhproWiiQZ3Z6aodRFB08C/EsyZ++05KbXbphY dr/bGY10y6DGZd5ZfwMOh0ERLAeyMrcFPLY8W1Kk2rB/qVIQnwMRq1z+S8pdMJhfc0Gn Tj6gvkOY0tYMVFOSAShiTTC97AdOiEzvXWx8xNx2EgRVIYRup81dJ5umxVGe+Ijgv9oE xc6x+pF0M8FcTQzSH3sNsrFuknADVSeS45hF99ZGILt+8fWUoGf60OJceuK4+7lfnbqm r4LG06HZ/T4y5AE/AWmRSCx7t8bNDePaW90tIrMy4P3LjRrfZKf+/Bx7SNKPNsX1vBOy yxOQ== 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 e1si6671225pgs.451.2019.03.12.00.10.21; Tue, 12 Mar 2019 00:10:37 -0700 (PDT) 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 S1727223AbfCLHIh (ORCPT + 99 others); Tue, 12 Mar 2019 03:08:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49166 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726633AbfCLHIg (ORCPT ); Tue, 12 Mar 2019 03:08:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B496185376; Tue, 12 Mar 2019 07:08:36 +0000 (UTC) Received: from localhost (ovpn-204-138.brq.redhat.com [10.40.204.138]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5317D60C98; Tue, 12 Mar 2019 07:08:34 +0000 (UTC) Date: Tue, 12 Mar 2019 08:08:33 +0100 From: Stanislaw Gruszka To: Alexander Duyck Cc: Rosen Penev , Joerg Roedel , Lorenzo Bianconi , linux-wireless , Samuel Sieb , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, jan.viktorin@gmail.com Subject: Re: [PATCH] iommu/amd: fix sg->dma_address for sg->offset bigger than PAGE_SIZE Message-ID: <20190312070832.GA2483@redhat.com> References: <20190226112407.GB2989@redhat.com> <20190228090411.GA24938@redhat.com> <20190228104223.GA2749@redhat.com> <20190228121948.GD6072@redhat.com> <20190228134029.GC1594@8bytes.org> <20190304071037.GA2787@redhat.com> <20190311084319.GA3310@redhat.com> <20190311090314.GB3310@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 12 Mar 2019 07:08:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 11, 2019 at 08:47:44AM -0700, Alexander Duyck wrote: > > 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 6b0760dafb3e..949621f33624 100644 > > --- a/drivers/iommu/amd_iommu.c > > +++ b/drivers/iommu/amd_iommu.c > > @@ -2604,7 +2604,7 @@ static int map_sg(struct device *dev, struct scatterlist *sglist, > > > > /* Everything is mapped - write the right values into s->dma_address */ > > for_each_sg(sglist, s, nelems, i) { > > - s->dma_address += address + s->offset; > > + s->dma_address += address + (s->offset & ~PAGE_MASK); > > s->dma_length = s->length; > > } > > > > You should add a comment calling out that this is needed because the > sg_phys(s) call above this is masked with PAGE_MASK. Then this makes > much more sense. Otherwise I would have assumed you needed either the > full offset or none. Would something like this /* * Everything is mapped - write the right values into s->dma_address. * Take into account s->offset can be bigger than page size and sg_phys(s) * address has to be aligned to page granularity. */ be appropriate ? Stanislaw