]>
Commit | Line | Data |
---|---|---|
d9b1f36d GKH |
1 | From 0e91ec0c06d2cd15071a6021c94840a50e6671aa Mon Sep 17 00:00:00 2001 |
2 | From: James Jones <jajones@nvidia.com> | |
3 | Date: Wed, 24 Nov 2010 00:21:37 +0100 | |
4 | Subject: ARM: 6482/2: Fix find_next_zero_bit and related assembly | |
5 | ||
6 | From: James Jones <jajones@nvidia.com> | |
7 | ||
8 | commit 0e91ec0c06d2cd15071a6021c94840a50e6671aa upstream. | |
9 | ||
10 | The find_next_bit, find_first_bit, find_next_zero_bit | |
11 | and find_first_zero_bit functions were not properly | |
12 | clamping to the maxbit argument at the bit level. They | |
13 | were instead only checking maxbit at the byte level. | |
14 | To fix this, add a compare and a conditional move | |
15 | instruction to the end of the common bit-within-the- | |
16 | byte code used by all the functions and be sure not to | |
17 | clobber the maxbit argument before it is used. | |
18 | ||
19 | Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org> | |
20 | Tested-by: Stephen Warren <swarren@nvidia.com> | |
21 | Signed-off-by: James Jones <jajones@nvidia.com> | |
22 | Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> | |
23 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
24 | ||
25 | --- | |
26 | arch/arm/lib/findbit.S | 6 ++++-- | |
27 | 1 file changed, 4 insertions(+), 2 deletions(-) | |
28 | ||
29 | --- a/arch/arm/lib/findbit.S | |
30 | +++ b/arch/arm/lib/findbit.S | |
31 | @@ -174,8 +174,8 @@ ENDPROC(_find_next_bit_be) | |
32 | */ | |
33 | .L_found: | |
34 | #if __LINUX_ARM_ARCH__ >= 5 | |
35 | - rsb r1, r3, #0 | |
36 | - and r3, r3, r1 | |
37 | + rsb r0, r3, #0 | |
38 | + and r3, r3, r0 | |
39 | clz r3, r3 | |
40 | rsb r3, r3, #31 | |
41 | add r0, r2, r3 | |
42 | @@ -190,5 +190,7 @@ ENDPROC(_find_next_bit_be) | |
43 | addeq r2, r2, #1 | |
44 | mov r0, r2 | |
45 | #endif | |
46 | + cmp r1, r0 @ Clamp to maxbit | |
47 | + movlo r0, r1 | |
48 | mov pc, lr | |
49 |