public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: "André Almeida" <andrealmeid@igalia.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	 Will Deacon <will@kernel.org>, Thomas Gleixner <tglx@kernel.org>,
	 Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	 Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Carlos O'Donell <carlos@redhat.com>,
	 Peter Zijlstra <peterz@infradead.org>,
	Florian Weimer <fweimer@redhat.com>,
	 Rich Felker <dalias@aerifal.cx>,
	Torvald Riegel <triegel@redhat.com>,
	 Darren Hart <dvhart@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	 Davidlohr Bueso <dave@stgolabs.net>,
	Arnd Bergmann <arnd@arndb.de>,
	 "Liam R . Howlett" <Liam.Howlett@oracle.com>,
	Uros Bizjak <ubizjak@gmail.com>,
	 linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	 kernel-dev@igalia.com
Subject: Re: [PATCH RFC v2 2/2] arm64: vdso: Implement __vdso_futex_robust_try_unlock()
Date: Mon, 27 Apr 2026 18:48:36 +0200	[thread overview]
Message-ID: <0e1ff958-8550-4380-99c7-499a4ad511a4@t-8ch.de> (raw)
In-Reply-To: <f14b2297-9b6b-46a6-ac9c-57377aaf9031@igalia.com>

On 2026-04-27 13:26:41-0300, André Almeida wrote:
> Em 26/04/2026 15:30, Thomas Weißschuh escreveu:
> > On 2026-04-24 15:56:01-0300, André Almeida wrote:
> > (...)
> > 
> > > Signed-off-by: André Almeida <andrealmeid@igalia.com>
> > > ---
> > > RFC:
> > >   - Should I duplicate the explanation found in the x86 commit or can I just
> > >   point to it?
> > >   - Only LL/SC for now but I can add LSE later if this looks good
> > >   - It the objdump I see that op_pending is store at x2. But how stable is this,
> > >   how can I write it in a way that's always x2?
> > > ---
> > >   arch/arm64/Kconfig                                 |  1 +
> > >   arch/arm64/include/asm/futex_robust.h              | 35 +++++++++++++
> > >   arch/arm64/kernel/vdso/Makefile                    |  9 +++-
> > >   arch/arm64/kernel/vdso/vdso.lds.S                  |  4 ++
> > >   .../kernel/vdso/vfutex_robust_list_try_unlock.c    | 59 ++++++++++++++++++++++
> > >   5 files changed, 107 insertions(+), 1 deletion(-)
> > 
> > What about the actual 32-bit vDSO in arch/arm64/kernel/vdso32/ ?
> > 
> 
> Right, I missed that. Then I should move
> __vdso_futex_robust_list32_try_unlock() to arch/arm64/kernel/vdso32/ right?

Are 64-bit processes supposed to have the list32 variant already?
If so, you need this function, *with the same name* in both vDSOs.
In any case for the 32-bit vDSO you'll need to extend the build system
to create a vdso32-offsets.h. If you have the list32 variant twice, use
differently named VDSO{,32}_ constants to refer to them from kernel code.

> > (...)
> > 
> > > diff --git a/arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c b/arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c
> > > new file mode 100644
> > > index 000000000000..e8a8fb22a2fa
> > > --- /dev/null
> > > +++ b/arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c
> > > @@ -0,0 +1,59 @@
> > > +// SPDX-License-Identifier: GPL-2.0-or-later
> > > +#include <vdso/futex.h>
> > > +#include <linux/stringify.h>
> > > +
> > > +#define LABEL(name, sz) __stringify(__futex_list##sz##_try_unlock_cs_##name)
> > 
> > We should have some defines for these symbols. While they are not
> > userspace ABI, they will be used by the selftests.
> > 
> 
> Do you mean to have this defined at include/uapi/linux/futex.h?

No, they are not UAPI. It should go into include/vdso/futex.h.

> > > +#define GLOBLS(sz) ".globl " LABEL(start, sz) ", " LABEL(success, sz) ", " LABEL(end, sz) "\n"
> > > +
> > > +__u32 __vdso_futex_robust_list64_try_unlock(__u32 *lock, __u32 tid, __u64 *pop)
> > > +{
> > > +	__u32 val, result;
> > > +
> > > +	asm volatile (
> > > +		GLOBLS(64)
> > > +		"	prfm pstl1strm, %[lock]			\n"
> > > +		LABEL(start, 64)":				\n"
> > > +		"	ldxr %[val], %[lock]			\n"
> > > +		"	cmp %[tid], %[val]			\n"
> > > +		"	bne " LABEL(end, 64)"			\n"
> > > +		"	stlxr %w[result], xzr, %[lock]		\n"
> > > +		"	cbnz %w[result], " LABEL(start, 64)"	\n"
> > > +		LABEL(success, 64)":				\n"
> > > +		"	str xzr, %[pop]				\n"
> > > +		LABEL(end, 64)":				\n"
> > > +
> > > +		: [val] "=&r" (val), [result] "=r" (result)
> > > +		: [tid] "r" (tid), [lock] "Q" (*lock), [pop] "Q" (*pop)
> > > +		: "memory"
> > > +	);
> > 
> > My clang 22.1.3 chokes on the assembly in this patch.
> > 
> 
> Do you mind sharing the output?

arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:26:18: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
   26 |                 : [val] "=&r" (val), [result] "=r" (result)
      |                                ^
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:17:10: note: use constraint modifier "w"
   17 |                 "       ldxr %[val], %[lock]                    \n"
      |                              ^~~~~~
      |                              %w[val]
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:27:16: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
   27 |                 : [tid] "r" (tid), [lock] "Q" (*lock), [pop] "Q" (*pop)
      |                              ^
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:18:9: note: use constraint modifier "w"
   18 |                 "       cmp %[tid], %[val]                      \n"
      |                             ^~~~~~
      |                             %w[tid]
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:26:18: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
   26 |                 : [val] "=&r" (val), [result] "=r" (result)
      |                                ^
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:18:17: note: use constraint modifier "w"
   18 |                 "       cmp %[tid], %[val]                      \n"
      |                                     ^~~~~~
      |                                     %w[val]
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:40:3: error: invalid operand in inline asm: '.globl __futex_list32_try_unlock_cs_start, __futex_list32_try_unlock_cs_success, __futex_list32_try_unlock_cs_end
	prfm pstl1strm, $3			
__futex_list32_try_unlock_cs_start:				
	ldxr ${0:w}, $3			
	cmp ${2:w}, ${0:w}			
	bne __futex_list32_try_unlock_cs_end			
	stlxr ${1:w}, wzr, ${3:w}		
	cbnz ${1:w}, __futex_list32_try_unlock_cs_start	
__futex_list32_try_unlock_cs_success:				
	str wzr, ${4:w}			
__futex_list32_try_unlock_cs_end:				
'
   40 |                 GLOBLS(32)
      |                 ^
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:7:20: note: expanded from macro 'GLOBLS'
    7 | #define GLOBLS(sz) ".globl " LABEL(start, sz) ", " LABEL(success, sz) ", " LABEL(end, sz) "\n"
      |                    ^
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:40:3: error: invalid operand in inline asm: '.globl __futex_list32_try_unlock_cs_start, __futex_list32_try_unlock_cs_success, __futex_list32_try_unlock_cs_end
	prfm pstl1strm, $3			
__futex_list32_try_unlock_cs_start:				
	ldxr ${0:w}, $3			
	cmp ${2:w}, ${0:w}			
	bne __futex_list32_try_unlock_cs_end			
	stlxr ${1:w}, wzr, ${3:w}		
	cbnz ${1:w}, __futex_list32_try_unlock_cs_start	
__futex_list32_try_unlock_cs_success:				
	str wzr, ${4:w}			
__futex_list32_try_unlock_cs_end:				
'
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:7:20: note: expanded from macro 'GLOBLS'
    7 | #define GLOBLS(sz) ".globl " LABEL(start, sz) ", " LABEL(success, sz) ", " LABEL(end, sz) "\n"
      |                    ^
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:46:4: error: unknown token in expression
   46 |                 "       stlxr %w[result], wzr, %w[lock]         \n"
      |                  ^
<inline asm>:7:19: note: instantiated into assembly here
    7 |         stlxr w9, wzr,          
      |                                 ^
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:46:4: error: invalid operand
   46 |                 "       stlxr %w[result], wzr, %w[lock]         \n"
      |                  ^
<inline asm>:7:19: note: instantiated into assembly here
    7 |         stlxr w9, wzr,          
      |                                 ^
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:49:4: error: unknown token in expression
   49 |                 "       str wzr, %w[pop]                        \n"
      |                  ^
<inline asm>:10:14: note: instantiated into assembly here
   10 |         str wzr,                        
      |                                         ^
arch/arm64/kernel/vdso/vfutex_robust_list_try_unlock.c:49:4: error: invalid operand
   49 |                 "       str wzr, %w[pop]                        \n"
      |                  ^
<inline asm>:10:14: note: instantiated into assembly here
   10 |         str wzr,                        
      |                                         ^
3 warnings and 6 errors generated.

> > > +
> > > +	return val;
> > > +}
> > > +
> > > +#ifdef CONFIG_COMPAT_VDSO
> > 
> > I am wondering about the CONFIG_COMPAT{,_VDSO} dependency here.
> > As far as I know the list32 variant is meant to be used by code
> > emulators which run 32-bit code on a 64-bit kernel, for example FEX.
> > But these emulators don't actually seem to need CONFIG_COMPAT.
> > So the dependency does not look correct.
> > The space savings also should be irrelevant.
> 
> Right, good catch. In the new syscall I had to do something similar[1], to
> expose the 32-bit functions to 64-bit kernels as well, and not hide them
> behind CONFIG_COMPAT.
> 
> [1] https://lore.kernel.org/lkml/20251122-tonyk-robust_futex-v6-2-05fea005a0fd@igalia.com/

If the regular system calls don't currently support a 32-bit robust list
on 64-bit systems I am wondering why tglx added them to the x86_64 vDSO.
They seem pointless for now. Maybe to be ready for your series?

Also on x86_64, if wine WoW64 should end up using the 32-bit robust list
from a 64-bit process, the CONFIG_COMPAT dependency looks incorrect.

> > The x86 series from Thomas does the same, maybe he will read this
> > comment, otherwise I'll bring it up on his series, too.
> > 
> > > +__u32 __vdso_futex_robust_list32_try_unlock(__u32 *lock, __u32 tid, __u32 *pop)
> > > +{
> > > +	__u32 val, result;
> > > +
> > > +	asm volatile (
> > > +		GLOBLS(32)
> > > +		"	prfm pstl1strm, %[lock]			\n"
> > > +		LABEL(start, 32)":				\n"
> > > +		"	ldxr %w[val], %[lock]			\n"
> > > +		"	cmp %w[tid], %w[val]			\n"
> > > +		"	bne " LABEL(end, 32)"			\n"
> > > +		"	stlxr %w[result], wzr, %w[lock]		\n"
> > > +		"	cbnz %w[result], " LABEL(start, 32)"	\n"
> > > +		LABEL(success, 32)":				\n"
> > > +		"	str wzr, %w[pop]			\n"
> > > +		LABEL(end, 32)":				\n"
> > > +
> > > +		: [val] "=&r" (val), [result] "=r" (result)
> > > +		: [tid] "r" (tid), [lock] "Q" (*lock), [pop] "Q" (*pop)
> > > +		: "memory"
> > > +	);
> > > +
> > > +	return val;
> > > +}
> > > +#endif
> 


  reply	other threads:[~2026-04-27 16:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24 18:55 [PATCH RFC v2 0/2] arm64: vdso: Implement __vdso_futex_robust_try_unlock() André Almeida
2026-04-24 18:56 ` [PATCH RFC v2 1/2] arm64: vdso: Prepare for robust futex unlock support André Almeida
2026-04-26 18:07   ` Thomas Weißschuh
2026-04-27 16:20     ` André Almeida
2026-04-26 19:04   ` Thomas Weißschuh
2026-04-24 18:56 ` [PATCH RFC v2 2/2] arm64: vdso: Implement __vdso_futex_robust_try_unlock() André Almeida
2026-04-26 18:30   ` Thomas Weißschuh
2026-04-27 16:26     ` André Almeida
2026-04-27 16:48       ` Thomas Weißschuh [this message]
2026-04-28 11:00 ` [PATCH RFC v2 0/2] " Sebastian Andrzej Siewior

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=0e1ff958-8550-4380-99c7-499a4ad511a4@t-8ch.de \
    --to=linux@weissschuh.net \
    --cc=Liam.Howlett@oracle.com \
    --cc=andrealmeid@igalia.com \
    --cc=arnd@arndb.de \
    --cc=bigeasy@linutronix.de \
    --cc=carlos@redhat.com \
    --cc=catalin.marinas@arm.com \
    --cc=dalias@aerifal.cx \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=fweimer@redhat.com \
    --cc=kernel-dev@igalia.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    --cc=triegel@redhat.com \
    --cc=ubizjak@gmail.com \
    --cc=will@kernel.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