qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH for-1.6] exec: fix writing to MMIO area with non


From: Peter Maydell
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 13:41:42 +0100

On 29 July 2013 13:28, Paolo Bonzini <address@hidden> 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 <address@hidden>
> Tested-by: Oleksii Shevchuk <address@hidden>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
>  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



reply via email to

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