From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LeDGm-00048N-7U for qemu-devel@nongnu.org; Mon, 02 Mar 2009 13:53:40 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LeDGk-000452-Fu for qemu-devel@nongnu.org; Mon, 02 Mar 2009 13:53:39 -0500 Received: from [199.232.76.173] (port=39063 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LeDGk-00044o-By for qemu-devel@nongnu.org; Mon, 02 Mar 2009 13:53:38 -0500 Received: from mail-fx0-f175.google.com ([209.85.220.175]:43025) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LeDGj-0003gN-SD for qemu-devel@nongnu.org; Mon, 02 Mar 2009 13:53:38 -0500 Received: by fxm23 with SMTP id 23so1959687fxm.34 for ; Mon, 02 Mar 2009 10:53:36 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1236013674-28082-2-git-send-email-agraf@suse.de> References: <1236013674-28082-1-git-send-email-agraf@suse.de> <1236013674-28082-2-git-send-email-agraf@suse.de> Date: Mon, 2 Mar 2009 20:53:35 +0200 Message-ID: From: Blue Swirl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 1/3] PPC: Circumvent overflow in mtcrf Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: Alexander Graf , qemu-devel@nongnu.org On 3/2/09, Alexander Graf wrote: > I had a segmentation fault in mtcrf, where ffs() returned 8 and the > code then accessed cpu_crf[7 - 8]. > > In order to circumvent this, I just put in an & 7 to the ffs result, > so we'll never run negative. This is probably not correct, but makes > things work for me so far. ffs does not return bit number (in power of 2 numbering), but one if the zeroth bit is set, two if the first bit is set etc. So I'd try instead crn = ffs(crm) - 1;