riscv/atomic: Fix sign extension for RV64I
authorNathan Huckleberry <nhuck@google.com>
Thu, 11 Jun 2020 18:32:35 +0000 (18:32 +0000)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:37:03 +0000 (15:37 -0400)
commitb8403f7e45e57ee705bcc2fe99d34ea44703ec3a
tree26c18bf57217b614b4364d06bdd285a2f5810bd6
parent81616542adcc777d82e1679c429c87bb44251dd1
riscv/atomic: Fix sign extension for RV64I

[ Upstream commit 6c58f25e6938c073198af8b1e1832f83f8f0df33 ]

The argument passed to cmpxchg is not guaranteed to be sign
extended, but lr.w sign extends on RV64I. This makes cmpxchg
fail on clang built kernels when __old is negative.

To fix this, we just cast __old to long which sign extends on
RV64I. With this fix, clang built RISC-V kernels now boot.

Link: https://github.com/ClangBuiltLinux/linux/issues/867
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/riscv/include/asm/cmpxchg.h