Re: [PATCH] m68k: Patch for broken lsl64() "old code" with incorrect shift

From: Geert Uytterhoeven
Date: Sat Jun 11 2011 - 08:01:48 EST


On Sat, Jun 11, 2011 at 05:50, Jonathan Elchison <JElchison@xxxxxxxxx> wrote:
> In arch/m68k/math-emu/multi_arith.h, lsl64() doesn't calculate a
> correct HI_WORD(*dest) when count < 32, due to an incorrect shift
> operation. ÂThis line:
>
> Â ÂHI_WORD(*dest) = (HI_WORD(*dest) << count) | (LO_WORD(*dest) >> count);
>
> ...should be...
>
> Â ÂHI_WORD(*dest) = (HI_WORD(*dest) << count) | (LO_WORD(*dest) >>
> (32 - count));
>
> This function is ifdef'd out, marked as "old code". ÂHowever, I fell
> into the same trap into which I suspect others have fallen (or will
> fall): ÂOn rare occasion when I need to implement my own library
> functions, I depend on the Linux kernel to provide solid code. ÂThis
> bug, albeit in old code, led me astray.
>
> I'm asking that this old code (lsl64) be corrected or removed.

I think it's better to just remove all #ifdefed out parts in the code.

> diff -up linux-2.6/arch/m68k/math-emu/multi_arith.h
> linux-2.6_orig/arch/m68k/math-emu/multi_arith.h
> --- linux-2.6/arch/m68k/math-emu/multi_arith.h Â2011-06-10
> 22:50:32.538711320 -0400
> +++ linux-2.6_orig/arch/m68k/math-emu/multi_arith.h   2011-06-10
> 22:47:43.407285452 -0400
> @@ -236,7 +236,7 @@ static inline void lsl64(int count, unsi
> Â{
> Â Â Â Âif (count < 32) {
> Â Â Â Â Â Â Â ÂHI_WORD(*dest) = (HI_WORD(*dest) << count)
> - Â Â Â Â Â Â Â Â Â | (LO_WORD(*dest) >> (32 - count));
> + Â Â Â Â Â Â Â Â Â | (LO_WORD(*dest) >> count);
> Â Â Â Â Â Â Â ÂLO_WORD(*dest) <<= count;
> Â Â Â Â Â Â Â Âreturn;
> Â Â Â Â}

The patch is reversed?

Gr{oetje,eeting}s,

            Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
             Â Â -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/