Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754233AbdIYULH (ORCPT ); Mon, 25 Sep 2017 16:11:07 -0400 Received: from mail-oi0-f43.google.com ([209.85.218.43]:46549 "EHLO mail-oi0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752167AbdIYULF (ORCPT ); Mon, 25 Sep 2017 16:11:05 -0400 X-Google-Smtp-Source: AOwi7QA+7d/fJtkdDvk2ThK9x8lyjO+Jlvch+dtFKpLFEDEXGUzZ8Ah9APcmIHxRjqnc8g+1R4AAv6+jH5k2HbeU07E= MIME-Version: 1.0 In-Reply-To: References: <20170920080151.GA3348@gondor.apana.org.au> <26992a1e-edb3-ed78-ce8e-31e0739d75f4@arm.com> From: Dan Williams Date: Mon, 25 Sep 2017 13:11:04 -0700 Message-ID: Subject: Re: DMA error when sg->offset value is greater than PAGE_SIZE in Intel IOMMU To: Casey Leedom Cc: Robin Murphy , Herbert Xu , Harsh Jain , "linux-kernel@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "linux-crypto@vger.kernel.org" , "dwmw2@infradead.org" , David Woodhouse Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 669 Lines: 17 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.