From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOozw-00016s-O8 for qemu-devel@nongnu.org; Fri, 20 Feb 2015 09:56:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOozu-0001pR-0B for qemu-devel@nongnu.org; Fri, 20 Feb 2015 09:56:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOozt-0001pN-OX for qemu-devel@nongnu.org; Fri, 20 Feb 2015 09:56:05 -0500 Message-ID: <54E74AFE.6030004@redhat.com> Date: Fri, 20 Feb 2015 15:55:58 +0100 From: Paolo Bonzini MIME-Version: 1.0 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> In-Reply-To: <31761482c674426717c95680d6e1ba02@walle.cc> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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: Michael Walle Cc: Paolo Bonzini , qemu-devel@nongnu.org, =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= 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. Paolo