Received: from eggs.gnu.org ([2001:4830:134:3::10]:47240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5r02-00066o-KC for qemu-devel@nongnu.org; Fri, 19 Jun 2015 03:46:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5r00-0002Rk-Pz for qemu-devel@nongnu.org; Fri, 19 Jun 2015 03:46:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5r00-0002R9-Gx for qemu-devel@nongnu.org; Fri, 19 Jun 2015 03:46:04 -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 23BDFC6A06 for ; Fri, 19 Jun 2015 07:46:04 +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 t5J7jbhQ019014 for ; Fri, 19 Jun 2015 03:46:03 -0400 From: Paolo Bonzini Date: Fri, 19 Jun 2015 09:45:35 +0200 Message-Id: <1434699936-4433-15-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 14/15] exec: do not clamp accesses to MMIO regions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org It is common for MMIO registers to overlap, for example a 4 byte register at 0xcf8 (totally random choice... :)) and a 1 byte register at 0xcf9. If these registers are implemented via separate MemoryRegions, it is wrong to clamp the accesses as the value written would be truncated. Hence for these regions the effects of commit 23820db (exec: Respect as_translate_internal length clamp, 2015-03-16, previously applied as commit c3c1bb99) must be skipped. Tested-by: Herv=C3=A9 Poussineau Tested-by: Mark Cave-Ayland Signed-off-by: Paolo Bonzini --- exec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 76bfc4a..d00e017 100644 --- a/exec.c +++ b/exec.c @@ -341,6 +341,7 @@ address_space_translate_internal(AddressSpaceDispatch= *d, hwaddr addr, hwaddr *x hwaddr *plen, bool resolve_subpage) { MemoryRegionSection *section; + MemoryRegion *mr; Int128 diff; =20 section =3D address_space_lookup_region(d, addr, resolve_subpage); @@ -350,8 +351,11 @@ address_space_translate_internal(AddressSpaceDispatc= h *d, hwaddr addr, hwaddr *x /* Compute offset within MemoryRegion */ *xlat =3D addr + section->offset_within_region; =20 - diff =3D int128_sub(section->mr->size, int128_make64(addr)); - *plen =3D int128_get64(int128_min(diff, int128_make64(*plen))); + mr =3D section->mr; + if (memory_region_is_ram(mr)) { + diff =3D int128_sub(mr->size, int128_make64(addr)); + *plen =3D int128_get64(int128_min(diff, int128_make64(*plen))); + } return section; } =20 --=20 2.4.3