From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYBtA-0002JV-It for qemu-devel@nongnu.org; Wed, 18 Mar 2015 07:11:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYBt7-00052J-CS for qemu-devel@nongnu.org; Wed, 18 Mar 2015 07:11:52 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:33229) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYBt7-00052F-5D for qemu-devel@nongnu.org; Wed, 18 Mar 2015 07:11:49 -0400 Received: by wixw10 with SMTP id w10so61953551wix.0 for ; Wed, 18 Mar 2015 04:11:48 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <55095D70.6000007@redhat.com> Date: Wed, 18 Mar 2015 12:11:44 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1426570554-15940-1-git-send-email-peter.crosthwaite@xilinx.com> In-Reply-To: <1426570554-15940-1-git-send-email-peter.crosthwaite@xilinx.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] exec: Respect as_tranlsate_internal length clamp List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite , qemu-devel@nongnu.org On 17/03/2015 06:35, Peter Crosthwaite wrote: > address_space_translate_internal will clamp the *plen length argument > based on the size of the memory region being queried. The iommu walker > logic in addresss_space_translate was ignoring this by discarding the > post fn call value of *plen. Fix by just always using *plen as the > length argument throughout the fn, removing the len local variable. > > This fixes a bootloader bug when a single elf section spans multiple > QEMU memory regions. > > Signed-off-by: Peter Crosthwaite > --- > exec.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/exec.c b/exec.c > index e97071a..8b922db 100644 > --- a/exec.c > +++ b/exec.c > @@ -380,7 +380,6 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr, > IOMMUTLBEntry iotlb; > MemoryRegionSection *section; > MemoryRegion *mr; > - hwaddr len = *plen; > > rcu_read_lock(); > for (;;) { > @@ -395,7 +394,7 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr, > iotlb = mr->iommu_ops->translate(mr, addr, is_write); > addr = ((iotlb.translated_addr & ~iotlb.addr_mask) > | (addr & iotlb.addr_mask)); > - len = MIN(len, (addr | iotlb.addr_mask) - addr + 1); > + *plen = MIN(*plen, (addr | iotlb.addr_mask) - addr + 1); > if (!(iotlb.perm & (1 << is_write))) { > mr = &io_mem_unassigned; > break; > @@ -406,10 +405,9 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr, > > if (xen_enabled() && memory_access_is_direct(mr, is_write)) { > hwaddr page = ((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - addr; > - len = MIN(page, len); > + *plen = MIN(page, *plen); > } > > - *plen = len; > *xlat = addr; > rcu_read_unlock(); > return mr; > Applied, thanks. Paolo