From patchwork Wed Mar 18 11:25:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 451391 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 416B3140083 for ; Wed, 18 Mar 2015 22:34:26 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=SYtDYhK0; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost ([::1]:60949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYCEy-0006SV-F9 for incoming@patchwork.ozlabs.org; Wed, 18 Mar 2015 07:34:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYC7K-0008Fe-OB for qemu-devel@nongnu.org; Wed, 18 Mar 2015 07:26:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYC7J-0001rQ-Sn for qemu-devel@nongnu.org; Wed, 18 Mar 2015 07:26:30 -0400 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:35205) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYC7J-0001rC-Mh for qemu-devel@nongnu.org; Wed, 18 Mar 2015 07:26:29 -0400 Received: by wibdy8 with SMTP id dy8so87371265wib.0 for ; Wed, 18 Mar 2015 04:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=b7tWHDB6McX1xoEQnXNYXOmAz2VxoQSH3OKF6teMuZA=; b=SYtDYhK09PQ568YOUfzicWG7YJTmWgjejjD7S8TJVwlThFzcIv8TOE5WkxIyAq48dU jeL1mAlEXLW31zt8HmEXdkm92QiShdTns7ukw7ZhQ0tB+BayhGQfph8tJeJvXh/1RgZj yxwXhZSRftrjugITVCDgByB/yj3IER5STZgHoWkj1ruo3Xkx6nhIA2bXifm1AAlZht2D 3a/soWkwynfiYCR1phu947CIZZw4PS/hycGhA2AMiHvwHwN5GwTRncfqVbKt/7Diynm1 HQ554r333To+kka/Bh6htS2p2ro7QM32otT7g11DxxikforY/rlbDAJVQAS2kkGW1ACm o2vA== X-Received: by 10.194.193.69 with SMTP id hm5mr11167218wjc.43.1426677989243; Wed, 18 Mar 2015 04:26:29 -0700 (PDT) Received: from localhost.localdomain (net-37-117-129-240.cust.vodafonedsl.it. [37.117.129.240]) by mx.google.com with ESMTPSA id bd1sm2743890wib.13.2015.03.18.04.26.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2015 04:26:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 18 Mar 2015 12:25:06 +0100 Message-Id: <1426677906-51657-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1426677906-51657-1-git-send-email-pbonzini@redhat.com> References: <1426677906-51657-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22d Cc: Peter Crosthwaite Subject: [Qemu-devel] [PULL 19/19] exec: Respect as_tranlsate_internal length clamp X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Crosthwaite 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 Message-Id: <1426570554-15940-1-git-send-email-peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini --- 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;