Skip to content

Commit 3109864

Browse files
andreas-schwabjfvogel
authored andcommitted
riscv/futex: sign extend compare value in atomic cmpxchg
commit 599c44c 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: b90edb3 ("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> (cherry picked from commit ac354e54dcab1c15addf2c8a540b33b081a0abb4) Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
1 parent fecab26 commit 3109864

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/riscv/include/asm/futex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
9393
_ASM_EXTABLE_UACCESS_ERR(1b, 3b, %[r]) \
9494
_ASM_EXTABLE_UACCESS_ERR(2b, 3b, %[r]) \
9595
: [r] "+r" (ret), [v] "=&r" (val), [u] "+m" (*uaddr), [t] "=&r" (tmp)
96-
: [ov] "Jr" (oldval), [nv] "Jr" (newval)
96+
: [ov] "Jr" ((long)(int)oldval), [nv] "Jr" (newval)
9797
: "memory");
9898
__disable_user_access();
9999

0 commit comments

Comments
 (0)