Unverified Commit 1898300a authored by Andreas Schwab's avatar Andreas Schwab Committed by Palmer Dabbelt
Browse files

riscv/atomic: Do proper sign extension also for unsigned in arch_cmpxchg



Sign extend also an unsigned compare value to match what lr.w is doing.
Otherwise try_cmpxchg may spuriously return true when used on a u32 value
that has the sign bit set, as it happens often in inode_set_ctime_current.

Do this in three conversion steps.  The first conversion to long is needed
to avoid a -Wpointer-to-int-cast warning when arch_cmpxchg is used with a
pointer type.  Then convert to int and back to long to always sign extend
the 32-bit value to 64-bit.

Fixes: 6c58f25e ("riscv/atomic: Fix sign extension for RV64I")
Signed-off-by: default avatarAndreas Schwab <schwab@suse.de>
Reviewed-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
Tested-by: default avatarXi Ruoyao <xry111@xry111.site>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/mvmed0k4prh.fsf@suse.de


Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent c6ec1e1b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment