Re: [PATCH] riscv/atomic: Do proper sign extension also for unsigned in arch_cmpxchg
From: Andreas Schwab
Date: Thu Jan 30 2025 - 09:52:20 EST
On Jan 30 2025, Alexandre Ghiti wrote:
> That's a nice catch indeed. IIUC, we have the same issue here
> https://elixir.bootlin.com/linux/v6.13/source/arch/riscv/include/asm/futex.h#L89
> right?
Indeed, though it doesn't result in wrong code currently. This is
because the compare value is passed unmodified as u32 to the asm and the
compiler keeps the value sign extended in registers. That would break
if you would add a cast to long like in commit 6c58f25e6938 as that
would erroneously zero extend it.
--
Andreas Schwab, SUSE Labs, schwab@xxxxxxx
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."