[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <916147db-94a5-46df-8a22-1d301059154c@ghiti.fr>
Date: Tue, 4 Feb 2025 09:44:14 +0100
From: Alexandre Ghiti <alex@...ti.fr>
To: Andreas Schwab <schwab@...e.de>, linux-riscv@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] riscv/futex: sign extend compare value in atomic cmpxchg
Hi Andreas,
On 03/02/2025 11:06, Andreas Schwab 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.
>
> Fixes: b90edb33010b ("RISC-V: Add futex support.")
> Signed-off-by: Andreas Schwab <schwab@...e.de>
> ---
> 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();
>
Reviewed-by: Alexandre Ghiti <alexghiti@...osinc.com>
Thanks,
Alex
Powered by blists - more mailing lists