From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOpoV-00069P-46 for qemu-devel@nongnu.org; Fri, 20 Feb 2015 10:48:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOpoR-0001s2-UX for qemu-devel@nongnu.org; Fri, 20 Feb 2015 10:48:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOpoR-0001rt-MQ for qemu-devel@nongnu.org; Fri, 20 Feb 2015 10:48:19 -0500 Date: Fri, 20 Feb 2015 16:48:12 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Message-ID: <20150220154811.GC3974@potion.brq.redhat.com> References: <1424441905-5735-1-git-send-email-rkrcmar@redhat.com> <1424441905-5735-3-git-send-email-rkrcmar@redhat.com> <54E74662.5090203@redhat.com> <31761482c674426717c95680d6e1ba02@walle.cc> <54E74AFE.6030004@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54E74AFE.6030004@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/2] milkymist-pfpu: fix GCC 5.0.0 aggressive-loop-optimizations warning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Michael Walle , Paolo Bonzini , qemu-devel@nongnu.org 2015-02-20 15:55+0100, Paolo Bonzini: > > > On 20/02/2015 15:52, Michael Walle wrote: > >>> > >>> - i = 0; > >>> - while (pfpu_decode_insn(s)) { > >>> - /* decode at most MICROCODE_WORDS instructions */ > >>> - if (i++ >= MICROCODE_WORDS) { > >> > >> Isn't the fix just to say "++i" instead of "i++"? > > > > In the first run, s->regs[R_PC] may have any value, therefore the "insn > > = s->microcode[pc]" from above may access out of bounds. > > Then should pfpu_decode_insn access s->microcode[pc & (MICROCODE_WORDS - > 1)]? That's likely what happens in hardware, and the purpose of the > error is just to avoid an infinite loop in device code. http://www.milkymist.org/socdoc/pfpu.pdf is dead, but the source isn't: https://github.com/m-labs/milkymist/blob/master/cores/pfpu/doc/pfpu.tex I don't see the PC register mentioned in interface, so hiding it would probably be a good start.