Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969040AbdIZNFd (ORCPT ); Tue, 26 Sep 2017 09:05:33 -0400 Received: from stargate.chelsio.com ([12.32.117.8]:38379 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965798AbdIZNFb (ORCPT ); Tue, 26 Sep 2017 09:05:31 -0400 Subject: Re: DMA error when sg->offset value is greater than PAGE_SIZE in Intel IOMMU To: Dan Williams , Casey Leedom Cc: Robin Murphy , Herbert Xu , "linux-kernel@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "linux-crypto@vger.kernel.org" , "dwmw2@infradead.org" , David Woodhouse References: <20170920080151.GA3348@gondor.apana.org.au> <26992a1e-edb3-ed78-ce8e-31e0739d75f4@arm.com> From: Harsh Jain Message-ID: <9412dba0-8e52-3361-f51d-0a8c70364d7f@chelsio.com> Date: Tue, 26 Sep 2017 18:34:54 +0530 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 795 Lines: 20 On 26-09-2017 01:41, Dan Williams wrote: > On Mon, Sep 25, 2017 at 1:05 PM, Casey Leedom wrote: >> | From: Dan Williams >> | Sent: Monday, September 25, 2017 12:31 PM >> | ... >> | IIUC it looks like this has been broken ever since commit e1605495c716 >> | "intel-iommu: Introduce domain_sg_mapping() to speed up >> | intel_map_sg()". I.e. it looks like the calculation for pte_val should >> | be: >> | >> | pteval = (page_to_phys(sg_page(sg)) + sg->offset) | prot; >> >> Hhmmm, shouldn't that be: >> >> pteval = (page_to_phys(sg_page(sg)) + (sg->offset>>PAGE_SHIFT)) | prot; > Yes, I think you're right. We do want to mask off the page-unaligned > portion of sg->offset. Tried changing above line in "__domain_mapping" but didn't help.