From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXRI7-0003qn-1u for qemu-devel@nongnu.org; Wed, 01 May 2013 03:17:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXRI4-0008EU-3n for qemu-devel@nongnu.org; Wed, 01 May 2013 03:17:26 -0400 Received: from mail-ea0-x230.google.com ([2a00:1450:4013:c01::230]:51538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXRI3-0008EO-TA for qemu-devel@nongnu.org; Wed, 01 May 2013 03:17:24 -0400 Received: by mail-ea0-f176.google.com with SMTP id h14so580875eak.21 for ; Wed, 01 May 2013 00:17:23 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5180C173.9030002@redhat.com> Date: Wed, 01 May 2013 09:17:07 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1367378320-9246-1-git-send-email-david@gibson.dropbear.id.au> <1367378320-9246-7-git-send-email-david@gibson.dropbear.id.au> <20130501040239.GM20202@truffula.fritz.box> In-Reply-To: <20130501040239.GM20202@truffula.fritz.box> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/17] memory: add address_space_valid List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: aik@truffula.fritz.box, qemu-devel@nongnu.org Il 01/05/2013 06:02, David Gibson ha scritto: > Hi Paolo, > > I've been looking through your iommu branch, and spotted a few > things, so sending some comments about them. Since I haven't see > where they've been posted before (if anywhere), I've kind of > reconstructed a mail to reply to from the patch in git. I hope the > result isn't too cryptic. It's understandable, and very much appreciated! :) Paolo > On Wed, May 01, 2013 at 01:18:30PM +1000, David Gibson wrote: >> From: Paolo Bonzini >> >> Checking whether an address space is possible in the old-style >> IOMMU implementation, but there is no equivalent in the memory >> API. Implement it with a lookup of the dispatch tree. >> >> Signed-off-by: Paolo Bonzini > [snip] >> --- dma-helpers.c | 5 +++++ exec.c | >> 24 ++++++++++++++++++++++++ include/exec/memory.h | 12 >> ++++++++++++ include/sysemu/dma.h | 3 ++- 4 files changed, 43 >> insertions(+), 1 deletion(-) >> >> diff --git a/dma-helpers.c b/dma-helpers.c index 272632f..2962b69 >> 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -298,6 +298,11 >> @@ bool iommu_dma_memory_valid(DMAContext *dma, dma_addr_t addr, >> dma_addr_t len, plen = len; } >> >> + if (!address_space_valid(dma->as, paddr, len, + >> dir == DMA_DIRECTION_FROM_DEVICE)) { + return false; + >> } > > I think the argument to address_space_valid() should be plen, not > len. Otherwise we're checking that a range the size of the > original area is valid at the target address of just the first > page. Of course, since the target address space will usually be > falt and much bigger than a page, it's unlikely to trigger. >