summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2025-02-03 11:06:00 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-03-07 16:56:50 +0100
commitee3ab05cf710e44bcde6ac54cfbe95f3baaae2c1 (patch)
treeedae11a1b37acd314a800f4f34d72584d73d8174 /arch
parent84586322e010164eedddfcd0a0894206ae7d9317 (diff)
downloadlinux-ee3ab05cf710e44bcde6ac54cfbe95f3baaae2c1.tar.gz
linux-ee3ab05cf710e44bcde6ac54cfbe95f3baaae2c1.tar.bz2
linux-ee3ab05cf710e44bcde6ac54cfbe95f3baaae2c1.zip
riscv/futex: sign extend compare value in atomic cmpxchg
commit 599c44cd21f4967774e0acf58f734009be4aea9a upstream. Make sure the compare value in the lr/sc loop is sign extended to match what lr.w does. Fortunately, due to the compiler keeping the register contents sign extended anyway the lack of the explicit extension didn't result in wrong code so far, but this cannot be relied upon. Fixes: b90edb33010b ("RISC-V: Add futex support.") Signed-off-by: Andreas Schwab <schwab@suse.de> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Björn Töpel <bjorn@rivosinc.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/mvmfrkv2vhz.fsf@suse.de Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/riscv/include/asm/futex.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/riscv/include/asm/futex.h b/arch/riscv/include/asm/futex.h
index fc8130f995c1..6907c456ac8c 100644
--- a/arch/riscv/include/asm/futex.h
+++ b/arch/riscv/include/asm/futex.h
@@ -93,7 +93,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
_ASM_EXTABLE_UACCESS_ERR(1b, 3b, %[r]) \
_ASM_EXTABLE_UACCESS_ERR(2b, 3b, %[r]) \
: [r] "+r" (ret), [v] "=&r" (val), [u] "+m" (*uaddr), [t] "=&r" (tmp)
- : [ov] "Jr" (oldval), [nv] "Jr" (newval)
+ : [ov] "Jr" ((long)(int)oldval), [nv] "Jr" (newval)
: "memory");
__disable_user_access();