* [Qemu-devel] [PATCH for-1.6] exec: fix writing to MMIO area with non-power-of-two length
@ 2013-07-29 12:28 Paolo Bonzini
2013-07-29 12:41 ` Peter Maydell
2013-08-30 15:49 ` [Qemu-devel] PING " Paolo Bonzini
0 siblings, 2 replies; 4+ messages in thread
From: Paolo Bonzini @ 2013-07-29 12:28 UTC (permalink / raw)
To: qemu-devel; +Cc: alxchk
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.6] exec: fix writing to MMIO area with non-power-of-two length
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
2013-08-30 15:49 ` [Qemu-devel] PING " Paolo Bonzini
1 sibling, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2013-07-29 12:41 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: alxchk, qemu-devel
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?
(probably not, I guess.) Alternatively, we seem to have a
pow2floor() function...
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.6] exec: fix writing to MMIO area with non-power-of-two length
2013-07-29 12:41 ` Peter Maydell
@ 2013-07-29 13:47 ` Paolo Bonzini
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2013-07-29 13:47 UTC (permalink / raw)
To: Peter Maydell; +Cc: alxchk, qemu-devel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] PING Re: [PATCH for-1.6] exec: fix writing to MMIO area with non-power-of-two length
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-08-30 15:49 ` Paolo Bonzini
1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2013-08-30 15:49 UTC (permalink / raw)
To: qemu-stable; +Cc: alxchk, qemu-devel
Il 29/07/2013 14:28, Paolo Bonzini ha scritto:
> 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;
> }
>
Ping, and adding qemu-stable.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-08-30 15:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2013-08-30 15:49 ` [Qemu-devel] PING " Paolo Bonzini
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.