All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: alxchk@gmail.com
Subject: [Qemu-devel] [PATCH for-1.6] exec: fix writing to MMIO area with non-power-of-two length
Date: Mon, 29 Jul 2013 14:28:41 +0200	[thread overview]
Message-ID: <1375100921-12990-1-git-send-email-pbonzini@redhat.com> (raw)

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.

Reported-by: Oleksii Shevchuk <alxchk@gmail.com>
Tested-by: Oleksii Shevchuk <alxchk@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 exec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/exec.c b/exec.c
index c4f2894..e122c81 100644
--- a/exec.c
+++ b/exec.c
@@ -1925,6 +1925,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.8.1.4

             reply	other threads:[~2013-07-29 12:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-29 12:28 Paolo Bonzini [this message]
2013-07-29 12:41 ` [Qemu-devel] [PATCH for-1.6] exec: fix writing to MMIO area with non-power-of-two length Peter Maydell
2013-07-29 13:47   ` Paolo Bonzini
2013-08-30 15:49 ` [Qemu-devel] PING " Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1375100921-12990-1-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alxchk@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.