From: "Björn Töpel" <bjorn@kernel.org>
To: Andreas Schwab <schwab@suse.de>, linux-riscv@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] riscv/futex: sign extend compare value in atomic cmpxchg
Date: Mon, 03 Feb 2025 16:33:50 +0100 [thread overview]
Message-ID: <87jza7oxep.fsf@all.your.base.are.belong.to.us> (raw)
In-Reply-To: <mvmfrkv2vhz.fsf@suse.de>
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)?
Regardless, having an explicit cast there doesn't hurt, and make it more
obvious!
Reviewed-by: Björn Töpel <bjorn@rivosinc.com>
Let's add a link to Jessica's comment as well:
Link: https://lore.kernel.org/linux-riscv/CC2D9220-F8DE-4CC8-ACAD-7B1A21E276FE@jrtc27.com/
> ---
> arch/riscv/include/asm/futex.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/futex.h b/arch/riscv/include/asm/futex.h
> index fc8130f995c1..6907c456ac8c 100644
> --- a/arch/riscv/include/asm/futex.h
> +++ b/arch/riscv/include/asm/futex.h
> @@ -93,7 +93,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
> _ASM_EXTABLE_UACCESS_ERR(1b, 3b, %[r]) \
> _ASM_EXTABLE_UACCESS_ERR(2b, 3b, %[r]) \
> : [r] "+r" (ret), [v] "=&r" (val), [u] "+m" (*uaddr), [t] "=&r" (tmp)
> - : [ov] "Jr" (oldval), [nv] "Jr" (newval)
> + : [ov] "Jr" ((long)(int)oldval), [nv] "Jr" (newval)
> : "memory");
> __disable_user_access();
>
> --
> 2.48.1
>
>
> --
> 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."
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-02-03 15:34 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 [this message]
2025-02-03 15:44 ` Andreas Schwab
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=87jza7oxep.fsf@all.your.base.are.belong.to.us \
--to=bjorn@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=schwab@suse.de \
/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