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>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
"Uros Bizjak" <ubizjak@gmail.com>,
"Thomas Weißschuh" <linux@weissschuh.net>
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 v3 1/5] arm64: vdso: Prepare for robust futex unlock support
Date: Fri, 29 May 2026 13:33:53 -0300 [thread overview]
Message-ID: <20260529-tonyk-robust_arm-v3-1-a6f02684d4fe@igalia.com> (raw)
In-Reply-To: <20260529-tonyk-robust_arm-v3-0-a6f02684d4fe@igalia.com>
There will be a VDSO function to unlock non-contended robust futexes in
user space. The unlock sequence is racy vs. clearing the list_pending_op
pointer in the task's robust list head. To plug this race the kernel needs
to know the critical section window so it can clear the pointer when the
task is interrupted within that race window. The window is determined by
labels in the inline assembly.
Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
Notes:
- The diff futex_set_vdso_cs_range() should happen in the commit that
introduced it, and rebase will clear it from here
- So far I couldn't figure out why current->rseq.event.user_irq is never set in
aarch64
v3:
- Fix adding vdso base addr twice
- Call vdso_futex_robust_unlock_update_ips() on remap as well
v2:
- Fixed linker not finding VDSO symbols
---
arch/arm64/kernel/vdso.c | 25 +++++++++++++++++++++++++
arch/arm64/kernel/vdso/vdso.lds.S | 5 +++++
arch/x86/entry/vdso/vma.c | 4 ++--
include/linux/futex.h | 13 ++-----------
4 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 592dd8668de4..76f22ea8e181 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -11,6 +11,7 @@
#include <linux/clocksource.h>
#include <linux/elf.h>
#include <linux/err.h>
+#include <linux/futex.h>
#include <linux/errno.h>
#include <linux/gfp.h>
#include <linux/kernel.h>
@@ -57,11 +58,31 @@ static struct vdso_abi_info vdso_info[] __ro_after_init = {
#endif /* CONFIG_COMPAT_VDSO */
};
+#ifdef CONFIG_FUTEX_ROBUST_UNLOCK
+static void vdso_futex_robust_unlock_update_ips(enum vdso_abi abi, struct mm_struct *mm)
+{
+ unsigned long vdso = (unsigned long) mm->context.vdso;
+ struct futex_mm_data *fd = &mm->futex;
+ uintptr_t success, end;
+
+ if (abi == VDSO_ABI_AA64) {
+ success = (uintptr_t) VDSO_SYMBOL(vdso, futex_list64_try_unlock_cs_success);
+ end = (uintptr_t) VDSO_SYMBOL(vdso, futex_list64_try_unlock_cs_end);
+
+ futex_set_vdso_cs_range(fd, 0, success, end, false);
+ }
+}
+#else
+static inline void vdso_futex_robust_unlock_update_ips(enum vdso_abi abi, struct mm_struct *mm) { }
+#endif /* CONFIG_FUTEX_ROBUST_UNLOCK */
+
static int vdso_mremap(const struct vm_special_mapping *sm,
struct vm_area_struct *new_vma)
{
current->mm->context.vdso = (void *)new_vma->vm_start;
+ vdso_futex_robust_unlock_update_ips(VDSO_ABI_AA64, current->mm);
+
return 0;
}
@@ -134,6 +155,8 @@ static int __setup_additional_pages(enum vdso_abi abi,
if (IS_ERR(ret))
goto up_fail;
+ vdso_futex_robust_unlock_update_ips(abi, mm);
+
return 0;
up_fail:
@@ -159,6 +182,8 @@ static int aarch32_sigpage_mremap(const struct vm_special_mapping *sm,
{
current->mm->context.sigpage = (void *)new_vma->vm_start;
+ vdso_futex_robust_unlock_update_ips(VDSO_ABI_AA32, current->mm);
+
return 0;
}
diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
index 52314be29191..8633aafe6b81 100644
--- a/arch/arm64/kernel/vdso/vdso.lds.S
+++ b/arch/arm64/kernel/vdso/vdso.lds.S
@@ -104,6 +104,7 @@ VERSION
__kernel_clock_gettime;
__kernel_clock_getres;
__kernel_getrandom;
+ __vdso_futex_robust_list64_try_unlock;
local: *;
};
}
@@ -112,3 +113,7 @@ VERSION
* Make the sigreturn code visible to the kernel.
*/
VDSO_sigtramp = __kernel_rt_sigreturn;
+
+VDSO_futex_list64_try_unlock_cs_start = __futex_list64_try_unlock_cs_start;
+VDSO_futex_list64_try_unlock_cs_success = __futex_list64_try_unlock_cs_success;
+VDSO_futex_list64_try_unlock_cs_end = __futex_list64_try_unlock_cs_end;
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 357e18db0c7a..988568a62a8b 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -85,13 +85,13 @@ static void vdso_futex_robust_unlock_update_ips(void)
futex_reset_cs_ranges(fd);
#ifdef CONFIG_X86_64
- futex_set_vdso_cs_range(fd, idx, vdso, image->sym___futex_list64_try_unlock_cs_start,
+ futex_set_vdso_cs_range(fd, idx, image->sym___futex_list64_try_unlock_cs_start + vdso,
image->sym___futex_list64_try_unlock_cs_end, false);
idx++;
#endif /* CONFIG_X86_64 */
#if defined(CONFIG_X86_32) || defined(CONFIG_COMPAT)
- futex_set_vdso_cs_range(fd, idx, vdso, image->sym___futex_list32_try_unlock_cs_start,
+ futex_set_vdso_cs_range(fd, idx, image->sym___futex_list32_try_unlock_cs_start + vdso,
image->sym___futex_list32_try_unlock_cs_end, true);
#endif /* CONFIG_X86_32 || CONFIG_COMPAT */
}
diff --git a/include/linux/futex.h b/include/linux/futex.h
index 33524dfb3fe4..cb378872e4e7 100644
--- a/include/linux/futex.h
+++ b/include/linux/futex.h
@@ -122,14 +122,6 @@ static inline void futex_fixup_robust_unlock(struct pt_regs *regs)
{
struct futex_unlock_cs_range *csr;
- /*
- * 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;
-
csr = current->mm->futex.unlock.cs_ranges;
/* The loop is optimized out for !COMPAT */
@@ -142,10 +134,9 @@ static inline void futex_fixup_robust_unlock(struct pt_regs *regs)
}
static inline void futex_set_vdso_cs_range(struct futex_mm_data *fd, unsigned int idx,
- unsigned long vdso, unsigned long start,
- unsigned long end, bool sz32)
+ unsigned long start, unsigned long end, bool sz32)
{
- fd->unlock.cs_ranges[idx].start_ip = vdso + start;
+ fd->unlock.cs_ranges[idx].start_ip = start;
fd->unlock.cs_ranges[idx].len = end - start;
fd->unlock.cs_ranges[idx].pop_size32 = sz32;
}
--
2.54.0
next prev parent reply other threads:[~2026-05-29 16:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 16:33 [PATCH v3 0/5] arm64: vdso: Implement __vdso_futex_robust_try_unlock() André Almeida
2026-05-29 16:33 ` André Almeida [this message]
2026-05-29 17:16 ` [PATCH v3 1/5] arm64: vdso: Prepare for robust futex unlock support Thomas Weißschuh
2026-06-01 16:17 ` André Almeida
2026-05-29 16:33 ` [PATCH v3 2/5] arm64: vdso: Implement __vdso_futex_robust_try_unlock() André Almeida
2026-05-29 17:18 ` Thomas Weißschuh
2026-05-29 17:47 ` Mathieu Desnoyers
2026-06-01 16:22 ` André Almeida
2026-05-29 16:33 ` [PATCH v3 3/5] selftests: futex: Add support for aarch64 in robust_list_critical André Almeida
2026-05-29 16:33 ` [PATCH v3 4/5] arm64: vdso32: Bring vdso32-offsets.h back André Almeida
2026-05-29 16:33 ` [PATCH v3 5/5] arm64: vdso32: Implement __vdso_futex_robust_try_unlock() André Almeida
2026-05-29 19:15 ` Mathieu Desnoyers
2026-06-02 8:30 ` Thomas Weißschuh
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=20260529-tonyk-robust_arm-v3-1-a6f02684d4fe@igalia.com \
--to=andrealmeid@igalia.com \
--cc=Liam.Howlett@oracle.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=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
all inboxes | Powered by JetHome®