[PATCH] riscv/futex: sign extend compare value in atomic cmpxchg

Andreas Schwab schwab at suse.de
Tue Feb 4 00:28:19 PST 2025


On Feb 03 2025, Jessica Clarke wrote:

> On 3 Feb 2025, at 10:06, Andreas Schwab <schwab at suse.de> wrote:
>> 
>> 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.
>
> GCC may guarantee this today,

It doesn't, that's the point!

-- 
Andreas Schwab, SUSE Labs, schwab at suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



More information about the linux-riscv mailing list