[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] milkymist-pfpu: fix GCC 5.0.0 aggressive-lo
From: |
Radim Krčmář |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] milkymist-pfpu: fix GCC 5.0.0 aggressive-loop-optimizations warning |
Date: |
Fri, 20 Feb 2015 16:48:12 +0100 |
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.
[Qemu-devel] [PATCH 1/2] fix GCC 5.0.0 logical-not-parentheses warnings, Radim Krčmář, 2015/02/20