sh: cmpxchg: fix a bit shift bug in big_endian os
PATCH 1/1 sh: cmpxchg: fix a bit shift bug in big_endian os
From: Pan Xinhui <[email protected]>
Correct bitoff in big endian OS.
--- arch/sh/include/asm/cmpxchg-xchg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/include/asm/cmpxchg-xchg.h +1 -1
@@ -21,7 +21,7 @@ static inline u32 __xchg_cmpxchg(volatile void *ptr, u32 x, int size)int off = (unsigned long )ptr %sizeof (u32);volatile u32 *p = ptr - off;#ifdef __BIG_ENDIAN -int bitoff = (sizeof (u32) -1 - off) *BITS_PER_BYTE ; +int bitoff = (sizeof (u32) - size - off) *BITS_PER_BYTE ;#else int bitoff = off *BITS_PER_BYTE ;#endif
Signature · 1 line
1.9.1
Quoted 6 lines · Pan Xinhui
From: Pan Xinhui <[email protected]>
Correct bitoff in big endian OS.
Fixes 3226aad81aa6 ("sh: support 1 and 2 byte xchg")Signed-off-by Pan Xinhui <[email protected]>
I would add: current code works correctly for 1 byte but not for 2 bytes.
Quoted 19 lines
--- arch/sh/include/asm/cmpxchg-xchg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/sh/include/asm/cmpxchg-xchg.h +1
-1@@ -21,7 +21,7 @@ static inline u32 __xchg_cmpxchg(volatile void *ptr, u32 x, int size)int off = (unsigned long )ptr %sizeof (u32);volatile u32 *p = ptr - off;#ifdef __BIG_ENDIAN -int bitoff = (sizeof (u32) -1 - off) *BITS_PER_BYTE ; +int bitoff = (sizeof (u32) - size - off) *BITS_PER_BYTE ;#else int bitoff = off *BITS_PER_BYTE ;#endif Signature · 1 line
1.9.1
PATCH v2 1/1 sh: cmpxchg: fix a bit shift bug in big_endian os
In reply to Pan XinhuiFrom: Pan Xinhui <[email protected]>
Correct bitoff in big endian OS.
Current code works correctly for 1 byte but not for 2 bytes.
---
changes from V1:
just add some patch comments. no code changes.
--- arch/sh/include/asm/cmpxchg-xchg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/include/asm/cmpxchg-xchg.h +1 -1
@@ -21,7 +21,7 @@ static inline u32 __xchg_cmpxchg(volatile void *ptr, u32 x, int size)int off = (unsigned long )ptr %sizeof (u32);volatile u32 *p = ptr - off;#ifdef __BIG_ENDIAN -int bitoff = (sizeof (u32) -1 - off) *BITS_PER_BYTE ; +int bitoff = (sizeof (u32) - size - off) *BITS_PER_BYTE ;#else int bitoff = off *BITS_PER_BYTE ;#endif
Signature · 1 line
1.9.1
Rich Felker
maintainerQuoted 11 lines · Pan Xinhui
From: Pan Xinhui <[email protected]>
Correct bitoff in big endian OS.
Current code works correctly for 1 byte but not for 2 bytes.Fixes 3226aad81aa6 ("sh: support 1 and 2 byte xchg")Signed-off-by Pan Xinhui <[email protected]>---
changes from V1:
just add some patch comments. no code changes.
Looks good. Are you aware of any code affected by this bug that would make it a regression in 4.6? If so I'll try to get this in now as a bugfix; otherwise I'll include it in stuff for 4.7.
Rich
Quoted 19 lines
--- arch/sh/include/asm/cmpxchg-xchg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/sh/include/asm/cmpxchg-xchg.h +1
-1@@ -21,7 +21,7 @@ static inline u32 __xchg_cmpxchg(volatile void *ptr, u32 x, int size)int off = (unsigned long )ptr %sizeof (u32);volatile u32 *p = ptr - off;#ifdef __BIG_ENDIAN -int bitoff = (sizeof (u32) -1 - off) *BITS_PER_BYTE ; +int bitoff = (sizeof (u32) - size - off) *BITS_PER_BYTE ;#else int bitoff = off *BITS_PER_BYTE ;#endif Signature · 1 line
1.9.1
Quoted 13 lines · Rich Felker
Quoted 11 lines · Pan Xinhui
From: Pan Xinhui <[email protected]>
Correct bitoff in big endian OS.
Current code works correctly for 1 byte but not for 2 bytes.Fixes 3226aad81aa6 ("sh: support 1 and 2 byte xchg")Signed-off-by Pan Xinhui <[email protected]>---
changes from V1:
just add some patch comments. no code changes.
Quoted 4 lines
Looks good. Are you aware of any code affected by this bug that would make it a regression in 4.6? If so I'll try to get this in now as a bugfix; otherwise I'll include it in stuff for 4.7.
no idea about what code is affected.
4.7 is okay I think. :)
xinhui
Quoted 23 lines
Rich
Quoted 19 lines
--- arch/sh/include/asm/cmpxchg-xchg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/sh/include/asm/cmpxchg-xchg.h +1
-1@@ -21,7 +21,7 @@ static inline u32 __xchg_cmpxchg(volatile void *ptr, u32 x, int size)int off = (unsigned long )ptr %sizeof (u32);volatile u32 *p = ptr - off;#ifdef __BIG_ENDIAN -int bitoff = (sizeof (u32) -1 - off) *BITS_PER_BYTE ; +int bitoff = (sizeof (u32) - size - off) *BITS_PER_BYTE ;#else int bitoff = off *BITS_PER_BYTE ;#endif Signature · 1 line
1.9.1