render / rpms / qemu

Forked from rpms/qemu 7 months ago
Clone

Blame 0016-exec-fix-writing-to-MMIO-area-with-non-power-of-two-.patch

298366
From 9fab8e1fe15014a4bd147eeedd2491bcfbba4e59 Mon Sep 17 00:00:00 2001
298366
From: Paolo Bonzini <pbonzini@redhat.com>
298366
Date: Mon, 29 Jul 2013 14:27:39 +0200
298366
Subject: [PATCH] exec: fix writing to MMIO area with non-power-of-two length
298366
298366
The problem is introduced by commit 2332616 (exec: Support 64-bit
298366
operations in address_space_rw, 2013-07-08).  Before that commit,
298366
memory_access_size would only return 1/2/4.
298366
298366
Since alignment is already handled above, reduce l to the largest
298366
power of two that is smaller than l.
298366
298366
Cc: qemu-stable@nongnu.org
298366
Reported-by: Oleksii Shevchuk <alxchk@gmail.com>
298366
Tested-by: Oleksii Shevchuk <alxchk@gmail.com>
298366
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
298366
(cherry picked from commit 098178f2749a63fbbb1a626dcc7d939d5cb2bde7)
298366
298366
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
298366
---
298366
 exec.c | 3 +++
298366
 1 file changed, 3 insertions(+)
298366
298366
diff --git a/exec.c b/exec.c
298366
index 3ca9381..394f7e2 100644
298366
--- a/exec.c
298366
+++ b/exec.c
298366
@@ -1928,6 +1928,9 @@ static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr)
298366
     if (l > access_size_max) {
298366
         l = access_size_max;
298366
     }
298366
+    if (l & (l - 1)) {
298366
+        l = 1 << (qemu_fls(l) - 1);
298366
+    }
298366
 
298366
     return l;
298366
 }