From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: alxchk@gmail.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH for-1.6] exec: fix writing to MMIO area with non-power-of-two length
Date: Mon, 29 Jul 2013 15:47:25 +0200 [thread overview]
Message-ID: <51F6726D.5020405@redhat.com> (raw)
In-Reply-To: <CAFEAcA_5M0Vyw=ydbj4FdBTgTZu0bw+zBOJutTBsz=JWtMeY9A@mail.gmail.com>
Il 29/07/2013 14:41, Peter Maydell ha scritto:
> On 29 July 2013 13:28, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> 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);
>> + }
>
> Is this a hot enough code path that we care about going via
> the not-inline qemu_fls() rather than calling clz32() directly?
It is not that hot because of the "if".
> (probably not, I guess.) Alternatively, we seem to have a
> pow2floor() function...
Yeah, pow2floor is also nice. There's still a lot of opportunity for
unification...
Paolo
next prev parent reply other threads:[~2013-07-29 13:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-29 12:28 [Qemu-devel] [PATCH for-1.6] exec: fix writing to MMIO area with non-power-of-two length Paolo Bonzini
2013-07-29 12:41 ` Peter Maydell
2013-07-29 13:47 ` Paolo Bonzini [this message]
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=51F6726D.5020405@redhat.com \
--to=pbonzini@redhat.com \
--cc=alxchk@gmail.com \
--cc=peter.maydell@linaro.org \
--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.