diff options
author | David Daney <david.daney@cavium.com> | 2013-02-26 17:35:23 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2013-03-12 13:57:47 -0400 |
commit | 0c81157b46c533139d6be721d41617020c59a2c3 (patch) | |
tree | dfc722ef55660acb1b963f68cee57eb1404d5cfa /arch/mips/lib/bitops.c | |
parent | e744109fce4b9581acdc23287667e240bcd239b7 (diff) |
MIPS: Fix logic errors in bitops.c
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.
Signed-off-by: David Daney <david.daney@cavium.com>
Cc: linux-mips@linux-mips.org
Cc: Jim Quinlan <jim2101024@gmail.com>
Cc: stable@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/4965/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/lib/bitops.c')
-rw-r--r-- | arch/mips/lib/bitops.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/arch/mips/lib/bitops.c b/arch/mips/lib/bitops.c index 81f1dcfdcab8..a64daee740ee 100644 --- a/arch/mips/lib/bitops.c +++ b/arch/mips/lib/bitops.c | |||
@@ -90,12 +90,12 @@ int __mips_test_and_set_bit(unsigned long nr, | |||
90 | unsigned bit = nr & SZLONG_MASK; | 90 | unsigned bit = nr & SZLONG_MASK; |
91 | unsigned long mask; | 91 | unsigned long mask; |
92 | unsigned long flags; | 92 | unsigned long flags; |
93 | unsigned long res; | 93 | int res; |
94 | 94 | ||
95 | a += nr >> SZLONG_LOG; | 95 | a += nr >> SZLONG_LOG; |
96 | mask = 1UL << bit; | 96 | mask = 1UL << bit; |
97 | raw_local_irq_save(flags); | 97 | raw_local_irq_save(flags); |
98 | res = (mask & *a); | 98 | res = (mask & *a) != 0; |
99 | *a |= mask; | 99 | *a |= mask; |
100 | raw_local_irq_restore(flags); | 100 | raw_local_irq_restore(flags); |
101 | return res; | 101 | return res; |
@@ -116,12 +116,12 @@ int __mips_test_and_set_bit_lock(unsigned long nr, | |||
116 | unsigned bit = nr & SZLONG_MASK; | 116 | unsigned bit = nr & SZLONG_MASK; |
117 | unsigned long mask; | 117 | unsigned long mask; |
118 | unsigned long flags; | 118 | unsigned long flags; |
119 | unsigned long res; | 119 | int res; |
120 | 120 | ||
121 | a += nr >> SZLONG_LOG; | 121 | a += nr >> SZLONG_LOG; |
122 | mask = 1UL << bit; | 122 | mask = 1UL << bit; |
123 | raw_local_irq_save(flags); | 123 | raw_local_irq_save(flags); |
124 | res = (mask & *a); | 124 | res = (mask & *a) != 0; |
125 | *a |= mask; | 125 | *a |= mask; |
126 | raw_local_irq_restore(flags); | 126 | raw_local_irq_restore(flags); |
127 | return res; | 127 | return res; |
@@ -141,12 +141,12 @@ int __mips_test_and_clear_bit(unsigned long nr, volatile unsigned long *addr) | |||
141 | unsigned bit = nr & SZLONG_MASK; | 141 | unsigned bit = nr & SZLONG_MASK; |
142 | unsigned long mask; | 142 | unsigned long mask; |
143 | unsigned long flags; | 143 | unsigned long flags; |
144 | unsigned long res; | 144 | int res; |
145 | 145 | ||
146 | a += nr >> SZLONG_LOG; | 146 | a += nr >> SZLONG_LOG; |
147 | mask = 1UL << bit; | 147 | mask = 1UL << bit; |
148 | raw_local_irq_save(flags); | 148 | raw_local_irq_save(flags); |
149 | res = (mask & *a); | 149 | res = (mask & *a) != 0; |
150 | *a &= ~mask; | 150 | *a &= ~mask; |
151 | raw_local_irq_restore(flags); | 151 | raw_local_irq_restore(flags); |
152 | return res; | 152 | return res; |
@@ -166,12 +166,12 @@ int __mips_test_and_change_bit(unsigned long nr, volatile unsigned long *addr) | |||
166 | unsigned bit = nr & SZLONG_MASK; | 166 | unsigned bit = nr & SZLONG_MASK; |
167 | unsigned long mask; | 167 | unsigned long mask; |
168 | unsigned long flags; | 168 | unsigned long flags; |
169 | unsigned long res; | 169 | int res; |
170 | 170 | ||
171 | a += nr >> SZLONG_LOG; | 171 | a += nr >> SZLONG_LOG; |
172 | mask = 1UL << bit; | 172 | mask = 1UL << bit; |
173 | raw_local_irq_save(flags); | 173 | raw_local_irq_save(flags); |
174 | res = (mask & *a); | 174 | res = (mask & *a) != 0; |
175 | *a ^= mask; | 175 | *a ^= mask; |
176 | raw_local_irq_restore(flags); | 176 | raw_local_irq_restore(flags); |
177 | return res; | 177 | return res; |