|
From: | Paolo Bonzini |
Subject: | Re: [Qemu-devel] [PATCH 2/2] milkymist-pfpu: fix GCC 5.0.0 aggressive-loop-optimizations warning |
Date: | Fri, 20 Feb 2015 15:55:58 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |