]> git.karo-electronics.de Git - karo-tx-linux.git/commit
arm64: cmpxchg: truncate sub-word signed types before comparison
authorWill Deacon <will.deacon@arm.com>
Thu, 30 Jul 2015 18:19:43 +0000 (19:19 +0100)
committerWill Deacon <will.deacon@arm.com>
Thu, 30 Jul 2015 19:16:53 +0000 (20:16 +0100)
commita14949e09a228dcd4cc5088c90c375429c7d102c
treeab11f9350f85e2becd350780b4e70dbc9c61e15b
parentef5e724b25c9f90b7683bb2d45833ebac0989dcb
arm64: cmpxchg: truncate sub-word signed types before comparison

When performing a cmpxchg operation on a signed sub-word type (e.g. s8),
we need to ensure that the upper register bits of the "old" value used
for comparison are zeroed, otherwise we may erroneously fail the cmpxchg
which may even be interpreted as success by the caller (if the compiler
performs the truncation as part of its check). This has been observed
in mod_state, where negative values where causing problems with
this_cpu_cmpxchg.

This patch fixes the issue by explicitly casting 8-bit and 16-bit "old"
values using unsigned types in our cmpxchg wrappers. 32-bit types can be
left alone, since the underlying asm makes use of W registers in this
case.

Reported-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/include/asm/cmpxchg.h