MIPS: Fix logic errors in bitops.c
Subsystems (2)
PATCH 1/1 MIPS: Fix logic errors in bitops.c
From: David Daney <[email protected]>
commit 92d11594f6 (MIPS: Remove irqflags.h dependency from bitops.h) factored some of the bitops code out into a separate file (arch/mips/lib/bitops.c). Unfortunately the logic converting a bit mask into a boolean result was lost in some of the functions. We had:
int res; unsigned long shifted_result_bit; . . . res = shifted_result_bit; return res;
Which truncates off the high 32 bits (thus yielding an incorrect value) on 64-bit systems.
The manifestation of this is that a non-SMP 64-bit kernel will not boot as the bitmap operations in bootmem.c are all screwed up.
--- arch/mips/lib/bitops.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/mips/lib/bitops.c +8 -8
@@ -90,12 +90,12 @@ int __mips_test_and_set_bit(unsigned long nr,unsigned bit = nr &SZLONG_MASK ;unsigned long mask;unsigned long flags; -unsigned long res; +int res; a += nr >>SZLONG_LOG ; mask =1UL << bit;raw_local_irq_save (flags); - res = (mask & *a); + res = (mask & *a) !=0 ; *a |= mask;raw_local_irq_restore (flags);return res;
@@ -116,12 +116,12 @@ int __mips_test_and_set_bit_lock(unsigned long nr,unsigned bit = nr &SZLONG_MASK ;unsigned long mask;unsigned long flags; -unsigned long res; +int res; a += nr >>SZLONG_LOG ; mask =1UL << bit;raw_local_irq_save (flags); - res = (mask & *a); + res = (mask & *a) !=0 ; *a |= mask;raw_local_irq_restore (flags);return res;
@@ -141,12 +141,12 @@ int __mips_test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)unsigned bit = nr &SZLONG_MASK ;unsigned long mask;unsigned long flags; -unsigned long res; +int res; a += nr >>SZLONG_LOG ; mask =1UL << bit;raw_local_irq_save (flags); - res = (mask & *a); + res = (mask & *a) !=0 ; *a &= ~mask;raw_local_irq_restore (flags);return res;
@@ -166,12 +166,12 @@ int __mips_test_and_change_bit(unsigned long nr, volatile unsigned long *addr)unsigned bit = nr &SZLONG_MASK ;unsigned long mask;unsigned long flags; -unsigned long res; +int res; a += nr >>SZLONG_LOG ; mask =1UL << bit;raw_local_irq_save (flags); - res = (mask & *a); + res = (mask & *a) !=0 ; *a ^= mask;raw_local_irq_restore (flags);return res;
Signature · 1 line
1.7.11.7
Ralf Baechle
AppliedOn Tue, Feb 26, 2013 at 02:35:23PM -0800, David Daney wrote:
Applied.
-stable folks - this patch should be applied to 3.7-stable and 3.8-stable.
Thanks,
Ralf
Quoted 5 lines · Ralf Baechle
On Tue, Feb 26, 2013 at 02:35:23PM -0800, David Daney wrote:
Applied.
-stable folks - this patch should be applied to 3.7-stable and 3.8-stable.
What patch? What is the git commit id of it in Linus's tree?
And there is no 3.7-stable tree anymore, sorry, that kernel is end-of-life now.
greg k-h