Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: cmpxchg: fix a bit shift bug in big_endian os

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 <xinhui.pan@linux.vnet.ibm.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rich Felker <dalias@libc.org>

authored by

Pan Xinhui and committed by
Rich Felker
ff18143c 7f155c70

+1 -1
+1 -1
arch/sh/include/asm/cmpxchg-xchg.h
··· 21 21 int off = (unsigned long)ptr % sizeof(u32); 22 22 volatile u32 *p = ptr - off; 23 23 #ifdef __BIG_ENDIAN 24 - int bitoff = (sizeof(u32) - 1 - off) * BITS_PER_BYTE; 24 + int bitoff = (sizeof(u32) - size - off) * BITS_PER_BYTE; 25 25 #else 26 26 int bitoff = off * BITS_PER_BYTE; 27 27 #endif