Skip to content

Commit 599c44c

Browse files
andreas-schwabpalmer-dabbelt
authored andcommitted
riscv/futex: sign extend compare value in atomic cmpxchg
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 <[email protected]> Reviewed-by: Alexandre Ghiti <[email protected]> Reviewed-by: Björn Töpel <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 1898300 commit 599c44c

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)