[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <mvmseov2zdx.fsf@suse.de>
Date: Mon, 03 Feb 2025 09:42:02 +0100
From: Andreas Schwab <schwab@...e.de>
To: David Laight <david.laight.linux@...il.com>
Cc: linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] riscv/atomic: Do proper sign extension also for
unsigned in arch_cmpxchg
On Jan 30 2025, David Laight wrote:
> On Thu, 30 Jan 2025 10:25:38 +0100
> Andreas Schwab <schwab@...e.de> wrote:
>
>> 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.
>
> Doesn't that break things by discarding the high bits of a pointer value?
If you have 32-bit pointers then the conversions are no-ops.
--
Andreas Schwab, SUSE Labs, schwab@...e.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Powered by blists - more mailing lists