From: David Woodhouse Subject: Re: [PATCH] iommu/vt-d: Fix scatterlist offset handling Date: Tue, 03 Oct 2017 23:16:16 +0100 Message-ID: <1507068976.29211.156.camel@infradead.org> References: <644c3e01654f8bd48d669c36e424959d6ef0e27e.1506607370.git.robin.murphy@arm.com> <1507035334.29211.105.camel@infradead.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg="sha-256"; protocol="application/x-pkcs7-signature"; boundary="=-NTIDuqjczzBO7VMmmGCB" Cc: ashok.raj@intel.com, leedom@chelsio.com, Harsh@chelsio.com, herbert@gondor.apana.org.au, iommu@lists.linux-foundation.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org To: Robin Murphy , joro@8bytes.org Return-path: Received: from twosheds.infradead.org ([90.155.92.209]:54712 "EHLO twosheds.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115AbdJCWQj (ORCPT ); Tue, 3 Oct 2017 18:16:39 -0400 In-Reply-To: Sender: linux-crypto-owner@vger.kernel.org List-ID: --=-NTIDuqjczzBO7VMmmGCB Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2017-10-03 at 19:05 +0100, Robin Murphy wrote: >=20 > Now, there are indeed plenty of drivers and subsystems which do work on > lists of explicitly single pages - anything doing some variant of > "addr =3D kmap_atomic(sg_page(sg)) + sg->offset;" is easy to spot - but I > don't think DMA API implementations are in a position to make any kind > of assumption; nearly all of them just shut up and handle sg->length > bytes from sg_phys(sg) without questioning the caller, and I reckon > that's exactly what they should be doing. So what's the point in sg->page in the first place? If even the *offset* can be greater than page size, it isn't even the *first* page (as you called it). Why aren't we just using a physical address, instead of an arbitrary page and an offset from that? Can we have *negative* sg->offset too? :) --=-NTIDuqjczzBO7VMmmGCB Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgk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