qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Richard Henderson <rth@twiddle.net>
Cc: Alex Williamson <alex.williamson@redhat.com>,
	lersek@redhat.com, qemu-devel@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses
Date: Fri, 16 Aug 2013 14:04:06 -0600	[thread overview]
Message-ID: <520E85B6.3070004@redhat.com> (raw)
In-Reply-To: <520E817B.3010105@twiddle.net>

[-- Attachment #1: Type: text/plain, Size: 832 bytes --]

On 08/16/2013 01:46 PM, Richard Henderson wrote:
> On 08/16/2013 08:37 AM, Alex Williamson wrote:
>> On Fri, 2013-08-16 at 08:27 -0700, Richard Henderson wrote:
>>> On 08/16/2013 05:50 AM, Alex Williamson wrote:
>>>> +    /* Size must be a power of 2 */
>>>> +    if (l & (l - 1)) {
>>>> +        while (l & (access_size_max - 1)) {
>>>> +            access_size_max >>= 1;
>>>> +        }
>>>> +    }
>>>> +
>>>
>>> Why the loop at all?  x & -x extracts the lsb of x.
>>
>> l = 5, we want 4, not 1.  Thanks,
> 
> It still doesn't require a loop.
> 
>   l = 1 << (31 - clz32(l));

or even pow2floor() declared in qemu-common.h and implemented in
cutils.c.  No need to reinvent what we already have.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

      reply	other threads:[~2013-08-16 20:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-16 12:50 [Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses Alex Williamson
2013-08-16 13:37 ` Laszlo Ersek
2013-08-16 15:27 ` Richard Henderson
2013-08-16 15:37   ` Alex Williamson
2013-08-16 15:43     ` Alex Williamson
2013-08-16 15:46       ` Alex Williamson
2013-08-16 19:46     ` Richard Henderson
2013-08-16 20:04       ` Eric Blake [this message]

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=520E85B6.3070004@redhat.com \
    --to=eblake@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=lersek@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=rth@twiddle.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).