[PATCH] 2.4.19-pre8 include/asm-i386/bitops.h ffs() bug

Martin Decky (deckm1am@ss1000.ms.mff.cuni.cz)
Mon, 20 May 2002 22:56:04 +0200 (CEST)


Hello,

asm-i386/bitops.h contains assembler definition of ffs() (find first bit
set), which has wrong operand declaration. The instruction "bsfl" accepts
only memory or register as its first operand, not a direct value.

The bug has stayed unnoticed in the kernel for many months. It expressed
on my system while compiling Gentoo's 2.4.19-r1 patched kernel with XFS
included and using GCC 3.1.

--- bitops.h 2001-11-22 20:46:18.000000000 +0100
+++ bitops.h.working 2002-05-20 22:42:45.000000000 +0200
@@ -347,7 +347,7 @@
__asm__("bsfl %1,%0\n\t"
"jnz 1f\n\t"
"movl $-1,%0\n"
- "1:" : "=r" (r) : "g" (x));
+ "1:" : "=r" (r) : "rm" (x));
return r+1;
}

-- 

------------------------------------------------------------------ Martin Decky Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic

deckm1am@ss1000.ms.mff.cuni.cz martin@decky.cz http://www.ms.mff.cuni.cz/~deckm1am/ http://www.decky.cz ------------------------------------------------------------------

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/