From: "André Almeida" <andrealmeid@igalia.com>
To: "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>,
"Uros Bizjak" <ubizjak@gmail.com>,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Liam R. Howlett" <liam@infradead.org>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
kernel-dev@igalia.com, LKML <linux-kernel@vger.kernel.org>,
"André Almeida" <andrealmeid@igalia.com>
Subject: [PATCH v4 0/5] arm64: vdso: Implement __vdso_futex_robust_try_unlock()
Date: Sun, 05 Jul 2026 14:56:50 -0300 [thread overview]
Message-ID: <20260705-tonyk-robust_arm-v4-0-e0fd0fa259d3@igalia.com> (raw)
Hi folks,
This is my take on implementing the new vDSO for unlocking a robust futex in
arm64. If you don't know what's that, Thomas wrote a good summary,
including the motivation for this work and the x86 implementation:
https://lore.kernel.org/lkml/878qb89g7b.ffs@tglx/
* Testing
There's one selftest proposed [1] that tests precisely if the task is
interrupted during the critical section, if the kernel will clear op_pending
pointer. I've adapted to arm64 [2] and it works as expected. This test is not
being upstreamed right now because it depends on a better way to expose
vdso.so.dbg [3].
I also used gdb to manually check if the address is cleared when the kernel
interrupts the critical section.
* The patchset
As explained in the Testing section above, we developed a test that puts
breakpoints in the code to test if a user code being interrupted really clears
the op_pending pointer. This test wasn't initially working because of this check
at futex_fixup_robust_unlock():
/*
* Avoid dereferencing current->mm if not returning from interrupt.
* current->rseq.event is going to be used subsequently, so bringing the
* cache line in is not a big deal.
*/
if (!current->rseq.event.user_irq)
return;
rseq.event.user_irq was always false during my tests, and it prevents the fixup
to happen. I figured out that arm64_syscall_enter_from_user_mode() was the
issue because it doesn't set user_irq to true when the task comes from a
syscall. I dropped arm64_syscall_enter_from_user_mode() and replaced with
arm64_enter_from_user_mode() and the test now works fine. I honestly don't know
if this solution is the correct one here, so I would like to hear from the arm64
folks what's the best approach here.
Thanks!
André
[1] https://lore.kernel.org/lkml/20260404093939.7XgeW_54@linutronix.de/
[2] https://lore.kernel.org/lkml/20260529-tonyk-robust_arm-v3-3-a6f02684d4fe@igalia.com/
[3] https://lore.kernel.org/lkml/20260602090536.045586688@kernel.org/
Changes in v4:
- Added commit "arm64/entry: Unify user mode handling"
- Added missing ifdef FUTEX_ROBUST_UNLOCK guards
- Fixed the position of _start and _success labels in the critical section
- Instead of checking the zero flag, check the result register to decide if the
op_pending needs to be cleared
v3: https://patch.msgid.link/20260529-tonyk-robust_arm-v3-0-a6f02684d4fe@igalia.com
Changes in v3:
- Change asm to always use x2 to store *pop
- Fix clang asm errors
- Moved 32 bit entry point to vdso32/ and use littlearm asm
- Adapted Sebastians test for arm
v2: https://patch.msgid.link/20260424-tonyk-robust_arm-v2-0-db4e46f752cf@igalia.com
Changes in v2:
- s/CONFIG_COMPAT/CONFIG_COMPAT_VDSO (Thomas Weißschuh)
- Fixed linker not finding the symbols (Thomas Weißschuh)
v1: https://patch.msgid.link/20260417-tonyk-robust_arm-v1-0-03aa64e2ff1a@igalia.com
---
André Almeida (5):
arm64/entry: Unify user mode handling
arm64: vdso: Prepare for robust futex unlock support
arm64: vdso: Implement __vdso_futex_robust_try_unlock()
arm64: vdso32: Bring vdso32-offsets.h back
arm64: vdso32: Implement __vdso_futex_robust_try_unlock()
arch/arm64/Kconfig | 1 +
arch/arm64/Makefile | 2 +-
arch/arm64/include/asm/futex_robust.h | 19 +++++++++++++++++++
arch/arm64/include/asm/vdso.h | 3 +++
arch/arm64/kernel/entry-common.c | 11 ++---------
arch/arm64/kernel/vdso.c | 32 ++++++++++++++++++++++++++++++++
arch/arm64/kernel/vdso/Makefile | 10 ++++++++++
arch/arm64/kernel/vdso/vdso.lds.S | 9 +++++++++
arch/arm64/kernel/vdso/vfutex.c | 35 +++++++++++++++++++++++++++++++++++
arch/arm64/kernel/vdso32/Makefile | 12 ++++++++++++
arch/arm64/kernel/vdso32/vdso.lds.S | 9 +++++++++
arch/arm64/kernel/vdso32/vfutex.c | 33 +++++++++++++++++++++++++++++++++
12 files changed, 166 insertions(+), 10 deletions(-)
---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260416-tonyk-robust_arm-54ff77d2c4e4
Best regards,
--
André Almeida <andrealmeid@igalia.com>
next reply other threads:[~2026-07-05 17:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-05 17:56 André Almeida [this message]
2026-07-05 17:56 ` [PATCH v4 1/5] arm64/entry: Unify user mode handling André Almeida
2026-07-06 19:03 ` André Almeida
2026-07-05 17:56 ` [PATCH v4 2/5] arm64: vdso: Prepare for robust futex unlock support André Almeida
2026-07-05 17:56 ` [PATCH v4 3/5] arm64: vdso: Implement __vdso_futex_robust_try_unlock() André Almeida
2026-07-05 17:56 ` [PATCH v4 4/5] arm64: vdso32: Bring vdso32-offsets.h back André Almeida
2026-07-05 17:56 ` [PATCH v4 5/5] arm64: vdso32: Implement __vdso_futex_robust_try_unlock() André Almeida
2026-07-05 20:23 ` [PATCH v4 0/5] arm64: vdso: " Thomas Gleixner
2026-07-06 19:02 ` André Almeida
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=20260705-tonyk-robust_arm-v4-0-e0fd0fa259d3@igalia.com \
--to=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=liam@infradead.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--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