summaryrefslogtreecommitdiff
path: root/exec.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-07-29 14:27:39 +0200
committerSeokYeon Hwang <syeon.hwang@samsung.com>2013-11-07 13:48:35 +0900
commit62595cf1f0e9aacd4795eff349816d3be02787bb (patch)
tree8cc264810d7082c519d686171cdefb4bae4471ae /exec.c
parent745a3fa26a6278761c1bf573700c54c0694b2465 (diff)
downloadqemu-62595cf1f0e9aacd4795eff349816d3be02787bb.tar.gz
qemu-62595cf1f0e9aacd4795eff349816d3be02787bb.tar.bz2
qemu-62595cf1f0e9aacd4795eff349816d3be02787bb.zip
exec: fix writing to MMIO area with non-power-of-two length
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 <alxchk@gmail.com> Tested-by: Oleksii Shevchuk <alxchk@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> (cherry picked from commit 098178f2749a63fbbb1a626dcc7d939d5cb2bde7) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/exec.c b/exec.c
index 8d415905d5..0245f4e303 100644
--- a/exec.c
+++ b/exec.c
@@ -1944,6 +1944,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;
}