]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/blobdiff - exec.c
exec: fix writing to MMIO area with non-power-of-two length
[lisovros/qemu_apohw.git] / exec.c
diff --git a/exec.c b/exec.c
index 3ca9381214b8002e0ac32eacb23f56a195d74764..394f7e2b12584b6302be1159bf5ceac02822ed24 100644 (file)
--- 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;
 }