qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 16/38] exec: fix writing to MMIO area with non-power


From: Michael Roth
Subject: [Qemu-devel] [PATCH 16/38] exec: fix writing to MMIO area with non-power-of-two length
Date: Wed, 25 Sep 2013 07:57:44 -0500

From: Paolo Bonzini <address@hidden>

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: address@hidden
Reported-by: Oleksii Shevchuk <address@hidden>
Tested-by: Oleksii Shevchuk <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
(cherry picked from commit 098178f2749a63fbbb1a626dcc7d939d5cb2bde7)

Signed-off-by: Michael Roth <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]