Received: by 10.223.164.221 with SMTP id h29csp3031519wrb; Tue, 3 Oct 2017 15:50:38 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDflyqltw6o6Kj0gIuuzrZTYEmo7yKD0vO4YFHmVpHL5DoJ4cCJuNWkSpzQwbLtMBaUSIu4 X-Received: by 10.98.130.205 with SMTP id w196mr6125485pfd.246.1507071038759; Tue, 03 Oct 2017 15:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507071038; cv=none; d=google.com; s=arc-20160816; b=QvN1ro8ayXMVYN2CXKmtuIsBkmlZGXxYU+mouqRZKOe1ZumOmC73TgaKO/dJBz2eKR wgKs4LJm5q5b96/GjVcsXCxJ4WXY1Y0XKWwuTcu41TVIozkJ7BZqiTTIkZRV6PcaC/50 nutM4fBUUhF2iBtMQdhClGP3j2V1UnUTKCEf4QD7bgNcQRsR5rcdKHXIiF0W3zaFhlJU XS0BjgByiO/ky/15vxilPdrFojv0g3swTKDy/CQJl3SsVhRTFzPcG9Hoglc3QD/08BFL 4e7x+r2MD/zXApkyCDf5aqSzVUnLPlQSOw+7Wssnujkd0+0zL4xNJ1VryffS9Rqys2Vp qOTw== 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:arc-authentication-results; bh=FsnxEwukqCkwZsN4U0NNAmgbgF15/1QgcfJNCPEfuC0=; b=FVzEgKWNjq08yl+PrvGK33WHarKhrdUoPVOyisfP3W7uINHbrhAy2zWMOIa4foIFZF f7PzRk925T8rjc7SQlMxa4U5Wpjau4nGKF41VxZ6OAkBu4FAvLwIXXW65G5ijet2jiI7 9HqePOJtHxCJ71z+BhIycbowlWgZXVpPGeCRahcgKJkW4nvv8kvOKV5DuJx1yHCR5sw7 VpbaB/77ONKku9+mUpsa7nRHGt0TVuqvrL1PbiSF+qwfSudNgo2WlL9miPciEYiOm+CS rRS8TPpfpX4UhS6H+1QzBQHpMpsyyU5uBKeGGSQm6D+LD41NUdL4ZhcWcuy5D+y34K3d Wtdg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o126si7349694pga.518.2017.10.03.15.50.24; Tue, 03 Oct 2017 15:50:38 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751337AbdJCWt7 (ORCPT + 99 others); Tue, 3 Oct 2017 18:49:59 -0400 Received: from mga09.intel.com ([134.134.136.24]:47042 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750865AbdJCWt6 (ORCPT ); Tue, 3 Oct 2017 18:49:58 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Oct 2017 15:49:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,475,1500966000"; d="scan'208";a="1021260588" Received: from otc-nc-03.jf.intel.com (HELO otc-nc-03) ([10.54.39.37]) by orsmga003.jf.intel.com with ESMTP; 03 Oct 2017 15:49:57 -0700 Date: Tue, 3 Oct 2017 12:36:53 -0700 From: "Raj, Ashok" To: Robin Murphy Cc: Casey Leedom , "herbert@gondor.apana.org.au" , "linux-kernel@vger.kernel.org" , Atul Gupta , "iommu@lists.linux-foundation.org" , "linux-crypto@vger.kernel.org" , Michael Werner , "dwmw2@infradead.org" , Harsh Jain Subject: Re: [PATCH] iommu/vt-d: Fix scatterlist offset handling Message-ID: <20171003193653.GA244814@otc-nc-03> References: <644c3e01654f8bd48d669c36e424959d6ef0e27e.1506607370.git.robin.murphy@arm.com> <20170928132942.GA99552@otc-nc-03> <20170928154345.GA101272@otc-nc-03> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170928154345.GA101272@otc-nc-03> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robin I now see your patch and it does seem to be fix the problem. On Thu, Sep 28, 2017 at 08:43:46AM -0700, Ashok Raj wrote: > Hi Robin > > > On Thu, Sep 28, 2017 at 05:59:11PM +0100, Robin Murphy wrote: > > I hope our email server hasn't got blacklisted again... Said patch is > > the top of this very thread we're replying on[1] - you were definitely > > on cc :( > > (sg->dma_address + sg->dma_len) ----+ > sg->dma_address ---------+ | > iov_pfn------+ | | > | | | > v v v > iova: a b c d e f > |--------|--------|--------|--------|--------| > <...calculated....> > [_____mapped______] > pfn: 0 1 2 3 4 5 > |--------|--------|--------|--------|--------| > ^ ^ ^ > | | | > sg->page ----+ | | > sg->offset --------------+ | > (sg->offset + sg->length) ----------+ > > The picture seems right. Looking at the code i'm not sure if i understand > it correctly. > > pgoff = sg->offset & ~PAGE_MASK; > > this gets the offset past the start of page. > > sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + pgoff; > > this would set dma_address at b+off instead of starting at c+off correct? I assumed align_nrpages() would allocate 2 pages when the offset is over PAGE_SIZE, but it seems economical and only allocates 1 page to cover just the sg->length bytes. the pteval also seems correct now, since you changed to sg_phys() that already accounts for sg->offset, so you subtract pgoff. - pteval = page_to_phys(sg_page(sg)) | prot; + pteval = (sg_phys(sg) - pgoff) | prot; Cheers, Ashok From 1580276803205734928@xxx Tue Oct 03 22:23:20 +0000 2017 X-GM-THRID: 1579793157804914964 X-Gmail-Labels: Inbox,Category Forums