Re: [patch 8/8] x86/vdso: Implement __vdso_futex_robust_try_unlock()
From: Uros Bizjak
Date: Wed Mar 18 2026 - 04:38:47 EST
On Wed, Mar 18, 2026 at 9:22 AM Thomas Gleixner <tglx@xxxxxxxxxx> wrote:
>
> On Tue, Mar 17 2026 at 16:33, Uros Bizjak wrote:
> > On 3/16/26 18:13, Thomas Gleixner wrote:
> >> +#ifdef CONFIG_COMPAT
> >
> > The following asm template can be substantially improved.
>
> In theory.
>
> >> +# define ASM_CLEAR_PTR \
> >> + " testl $1, (%[pop]) \n" \
> >
> > Please use byte-wide instruction, TESTB with address operand modifier,
> > "%a[pop]" instead of "(%[pop])":
> >
> > testb $1, %a[pop]
>
> New fangled %a syntax seems to work. Didn't know about that. Though I'm
> not convinced that this is an improvement. At least not for someone who
> is used to read/write plain old school ASM for several decades.
>
> >> + " jz .Lop64 \n" \
> >> + " movl $0, (%[pad]) \n" \
> >
> > Here you can reuse zero-valued operand "val" and use address operand
> > modifier. Please note %k modifier.
> >
> > movl %k[val], %a[pad]
> ...
> > movq %[val], %a[pad]
>
> But this one does not and _cannot_ work.
>
> Error: incorrect register `%rcx' used with `l' suffix
Ah, I missed:
" lock cmpxchgl %[val], (%[ptr]) \n"
Please use %k[val] here and it will work. %k forces %ecx.
> Which is obvious because of the initalization:
>
> [val] "r" (0UL)
You have to force 0 to %r$$ for x86_64 when movq is used. The
resulting code (xorl %ecx, %ecx) is the same, but the compiler knows
what type of value is created here.
Uros.