Re: [PATCH 2/2] x86/local: local_add/local_sub: Support large immediate values

From: H. Peter Anvin

Date: Mon Aug 03 2026 - 06:27:13 EST


On 2026-08-03 02:47, David Laight wrote:
> Replace the "ir" constraint with "er" so that constants over 2^31
> get loaded into a register.
>
> Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>

Yep, that's right.

Reviewed-by: H. Peter Anvin <hpa@xxxxxxxxx>

> ---
> arch/x86/include/asm/local.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
> index 4957018fef3e..68af7b74450a 100644
> --- a/arch/x86/include/asm/local.h
> +++ b/arch/x86/include/asm/local.h
> @@ -32,14 +32,14 @@ static inline void local_add(long i, local_t *l)
> {
> asm volatile(_ASM_ADD "%1,%0"
> : "+m" (l->a.counter)
> - : "ir" (i));
> + : "er" (i));
> }
>
> static inline void local_sub(long i, local_t *l)
> {
> asm volatile(_ASM_SUB "%1,%0"
> : "+m" (l->a.counter)
> - : "ir" (i));
> + : "er" (i));
> }
>
> /**