Received: from eggs.gnu.org ([2001:4830:134:3::10]:47252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5r04-0006CV-UY for qemu-devel@nongnu.org; Fri, 19 Jun 2015 03:46:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5r02-0002X1-93 for qemu-devel@nongnu.org; Fri, 19 Jun 2015 03:46:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59695) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5r01-0002VY-U4 for qemu-devel@nongnu.org; Fri, 19 Jun 2015 03:46:06 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 87CFA3017D3 for ; Fri, 19 Jun 2015 07:46:05 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-30.ams2.redhat.com [10.36.112.30]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5J7jbhR019014 for ; Fri, 19 Jun 2015 03:46:04 -0400 From: Paolo Bonzini Date: Fri, 19 Jun 2015 09:45:36 +0200 Message-Id: <1434699936-4433-16-git-send-email-pbonzini@redhat.com> In-Reply-To: <1434699936-4433-1-git-send-email-pbonzini@redhat.com> References: <1434699936-4433-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 15/15] exec: clamp accesses against the MemoryRegionSection List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Because the clamping was done against the MemoryRegion, address_space_rw was effectively broken if a write spanned multiple sections that are not linear in underlying memory (with the memory not being under an IOMMU). This is visible with the MIPS rc4030 IOMMU, which is implemented as a series of alias memory regions that point to the actual RAM. Tested-by: Herv=C3=A9 Poussineau Tested-by: Mark Cave-Ayland Signed-off-by: Paolo Bonzini --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exec.c b/exec.c index d00e017..f7883d2 100644 --- a/exec.c +++ b/exec.c @@ -353,7 +353,7 @@ address_space_translate_internal(AddressSpaceDispatch= *d, hwaddr addr, hwaddr *x =20 mr =3D section->mr; if (memory_region_is_ram(mr)) { - diff =3D int128_sub(mr->size, int128_make64(addr)); + diff =3D int128_sub(section->size, int128_make64(addr)); *plen =3D int128_get64(int128_min(diff, int128_make64(*plen))); } return section; --=20 2.4.3