From: Andreas Schwab <schwab@suse.de>
To: "Björn Töpel" <bjorn@kernel.org>
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] riscv/futex: sign extend compare value in atomic cmpxchg
Date: Mon, 03 Feb 2025 16:44:52 +0100 [thread overview]
Message-ID: <mvmbjvj2ft7.fsf@suse.de> (raw)
In-Reply-To: <87jza7oxep.fsf@all.your.base.are.belong.to.us> ("Björn Töpel"'s message of "Mon, 03 Feb 2025 16:33:50 +0100")
On Feb 03 2025, Björn Töpel wrote:
> Andreas Schwab <schwab@suse.de> writes:
>
>> 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: b90edb33010b ("RISC-V: Add futex support.")
>> Signed-off-by: Andreas Schwab <schwab@suse.de>
>
> Hmm, in this scenario we *can* rely on it, no (inline vs macro)?
No, the issue is that the asm operand (oldval) is u32, but the asm is
using the 64-bit value from the register. You cannot expect that the
compiler keeps the upper half defined in any way at this point. That is
different for the operand that is passed in from newval, because sc.w is
only using the low 32-bits from the operand.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
next prev parent reply other threads:[~2025-02-03 15:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 10:06 [PATCH] riscv/futex: sign extend compare value in atomic cmpxchg Andreas Schwab
2025-02-03 15:33 ` Björn Töpel
2025-02-03 15:44 ` Andreas Schwab [this message]
2025-02-03 21:25 ` Jessica Clarke
2025-02-04 8:28 ` Andreas Schwab
2025-02-04 8:44 ` Alexandre Ghiti
2025-02-13 18:30 ` patchwork-bot+linux-riscv
2025-02-14 4:11 ` [External] " yunhui cui
2025-02-14 6:04 ` [External] " Jessica Clarke
2025-02-14 6:22 ` yunhui cui
2025-02-14 7:17 ` Jessica Clarke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mvmbjvj2ft7.fsf@suse.de \
--to=schwab@suse.de \
--cc=bjorn@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox