From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VAQFp-0005qX-V6 for qemu-devel@nongnu.org; Fri, 16 Aug 2013 16:04:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VAQFl-0005wb-28 for qemu-devel@nongnu.org; Fri, 16 Aug 2013 16:04:13 -0400 Message-ID: <520E85B6.3070004@redhat.com> Date: Fri, 16 Aug 2013 14:04:06 -0600 From: Eric Blake MIME-Version: 1.0 References: <20130816124915.12577.72732.stgit@bling.home> <520E44CA.6050205@twiddle.net> <1376667453.28796.0.camel@ul30vt.home> <520E817B.3010105@twiddle.net> In-Reply-To: <520E817B.3010105@twiddle.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="smJI5dFf4e9lno1sABwevtwmXrM7D0gq3" Subject: Re: [Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: Alex Williamson , lersek@redhat.com, qemu-devel@nongnu.org, qemu-stable@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --smJI5dFf4e9lno1sABwevtwmXrM7D0gq3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 >>=3D 1; >>>> + } >>>> + } >>>> + >>> >>> Why the loop at all? x & -x extracts the lsb of x. >> >> l =3D 5, we want 4, not 1. Thanks, >=20 > It still doesn't require a loop. >=20 > l =3D 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --smJI5dFf4e9lno1sABwevtwmXrM7D0gq3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSDoW2AAoJEKeha0olJ0Nq5iMIAJI+Wd6QZGRmhwSHROPdzYfY ZS1d0vJLh9Xrf7/Qk84TSmh8FliDb20xlQ0QU+gYsr2dJBV4VRwSIvet47ICFO9S +U9NGEw9hOxM99agcvzGrFgYdCY30wFvF23K5R4lnacTJoqt9fryAsjKLozy9veR 3qNghm6umgbc1jNCZRTr/IEMjDeMMaLRvFqMA/+ixsUzaY1fJ8fwAl+cRPdi7sRX 71tWT6sRmGu6fnb63NiXwXfXOLA/UfxpmvxMNz3wL3+BdtPKoddap9c3GF4pcHbT TMWDXRMepcmm62dGSpi9KKFQCWwS8vIpx+SdnJwNo5YuFlT9pCpiJ3a14QtcUBY= =zY3X -----END PGP SIGNATURE----- --smJI5dFf4e9lno1sABwevtwmXrM7D0gq3--