Received: from eggs.gnu.org ([2001:4830:134:3::10]:50560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOog7-0003Kb-B9 for qemu-devel@nongnu.org; Wed, 25 Sep 2013 08:58:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOog0-0000EF-O5 for qemu-devel@nongnu.org; Wed, 25 Sep 2013 08:58:51 -0400 Sender: fluxion From: Michael Roth Date: Wed, 25 Sep 2013 07:57:44 -0500 Message-Id: <1380113886-16845-17-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1380113886-16845-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1380113886-16845-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 16/38] exec: fix writing to MMIO area with non-power-of-two length List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: Paolo Bonzini The problem is introduced by commit 2332616 (exec: Support 64-bit operations in address_space_rw, 2013-07-08). Before that commit, memory_access_size would only return 1/2/4. Since alignment is already handled above, reduce l to the largest power of two that is smaller than l. Cc: qemu-stable@nongnu.org Reported-by: Oleksii Shevchuk Tested-by: Oleksii Shevchuk Signed-off-by: Paolo Bonzini (cherry picked from commit 098178f2749a63fbbb1a626dcc7d939d5cb2bde7) Signed-off-by: Michael Roth --- exec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/exec.c b/exec.c index 3ca9381..394f7e2 100644 --- a/exec.c +++ b/exec.c @@ -1928,6 +1928,9 @@ static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr) if (l > access_size_max) { l = access_size_max; } + if (l & (l - 1)) { + l = 1 << (qemu_fls(l) - 1); + } return l; } -- 1.7.9.5