From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VAkpi-000586-6d for qemu-devel@nongnu.org; Sat, 17 Aug 2013 14:02:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VAkpZ-0002T6-Oc for qemu-devel@nongnu.org; Sat, 17 Aug 2013 14:02:38 -0400 Sender: Paolo Bonzini Message-ID: <520FB9BB.7060907@redhat.com> Date: Sat, 17 Aug 2013 19:58:19 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <20130816215706.23647.80992.stgit@bling.home> <520F32F9.7080504@redhat.com> In-Reply-To: <520F32F9.7080504@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4] exec: Fix non-power-of-2 sized accesses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek Cc: Alex Williamson , qemu-stable@nongnu.org, qemu-devel@nongnu.org, rth@twiddle.net Il 17/08/2013 10:23, Laszlo Ersek ha scritto: > What Paolo posted seems almost identical. > > clz32(l): leading zeros in "l" > qemu_fls(l) == 32 - clz32(l): position of leftmost bit set, 1-based > qemu_fls(l) - 1: position of leftmost bit set, 0-based > > Not sure if the (l & (l - 1)) check is needed in Paolo's patch. clz32() > is not generally usable when l==0, so maybe that's (too) what the check > is for. OTOH maybe l==0 is not even possible when entering > memory_access_size(). The check was an attempt at placating complaints about possible performance problems. :) > Second, Paolo's patch might lack the "max(3, ...)" part. Since you > didn't call my previous example with l==9 retarded, I guess clamping > (qemu_fls(l) - 1) at 3 would be necessary. That shouldn't happen, since an uint64_t is all you have for the datum. access_size_max should never exceed 8. I don't really care which patch goes in, Alex's is fine as well. Paolo