From nobody Sat Jul 25 04:56:16 2026 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E5C042A16A; Fri, 17 Jul 2026 14:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784299347; cv=none; b=a9XumPs8d7vCHcodjsaa5IBIAXhUqFMfUty3qdzUkU1EAEl+2ooVS77dK7reyN52H5I37MDTW53PlFpkHmlGDU+x++UgAqNHYXiICQKH+QodA1wC7R7E2d4lq2Nj724X6DKrZeGuSGGQlPeYruId1MpiTO4EOs6mmM1ponM37hg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784299347; c=relaxed/simple; bh=CZ9nWu43ar/0+mmw8fNonCwPqDGBbGPfQxq8Fqu3CvI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dbjAPrYPw6LHVdlooB3tXbJToKjhG4gqVVSuPxY45TFgNNZVAIqqnN/M6LX5KSeSYO2aoRsVytzTWAQtsUPRIrBBrK8ER1rDC8hPHtx6yvISGbKzrVHIPGL2sQjNx+PWpeSXkRW/QasVF00OC1WIZWYnPowIWf7oZGLF61DlSds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=DnbzZoU0; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="DnbzZoU0" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=Q7O9wWpQXaHzPaJD6V/UTzGw8eK1vlr+XrH7gH9bwDA=; b=DnbzZoU0JvRXdDjBh7SsNAAIOB HM23YwC/xH27m10Sul2fXEPINgihiP1hKa9X1K3hyA/9cg9J4Mu+zIqhr7xamfAgiXoNDKQKYrDtK /qps/4qacX2/rZbarMTrl8nF81GCqwZ4qC2aDMdtvvckZPIQT93LX5HPIL4tjsxeuFO5sG+pZWhU7 cznNKjo6Mt1g25K/HQAX9OlrQO20sJHWqqY0gMHbwN8Yi9MshvJ76qBQCgwbNCRcCV9swjyIQEbXZ nLXqwF/Q3JuM9FKRvzImAfvgzhaC5O36k1xHKUrx0uARxhZMvpMS2vb4ba9/+RoghBb0eCEK+c/NE mgrQz01g==; Received: from [179.118.191.219] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wkjlJ-00GdLF-En; Fri, 17 Jul 2026 16:42:01 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 17 Jul 2026 11:41:40 -0300 Subject: [PATCH v5 1/4] arm64: vdso: Prepare for robust futex unlock support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260717-tonyk-robust_arm-v5-1-ffd1ad318d17@igalia.com> References: <20260717-tonyk-robust_arm-v5-0-ffd1ad318d17@igalia.com> In-Reply-To: <20260717-tonyk-robust_arm-v5-0-ffd1ad318d17@igalia.com> To: Catalin Marinas , Will Deacon , Thomas Gleixner , Mark Rutland , Mathieu Desnoyers , Sebastian Andrzej Siewior , Carlos O'Donell , Peter Zijlstra , Florian Weimer , Rich Felker , Torvald Riegel , Darren Hart , Ingo Molnar , Davidlohr Bueso , Arnd Bergmann , Uros Bizjak , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Liam R. Howlett" Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-dev@igalia.com, LKML , =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.15.2 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=C3=A9 Almeida --- v4: - Guard symbols from vdso.lds.S with ifdef - drop update_ips() from sigpage remap function 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 | 35 ++++++++++++++++++++++++++++++++++- arch/arm64/kernel/vdso/vdso.lds.S | 9 +++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 592dd8668de4..ff43b74e514e 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -57,11 +58,41 @@ static struct vdso_abi_info vdso_info[] __ro_after_init= =3D { #endif /* CONFIG_COMPAT_VDSO */ }; =20 +#ifdef CONFIG_FUTEX_ROBUST_UNLOCK +static void vdso_futex_robust_unlock_update_ips(enum vdso_abi abi, struct = mm_struct *mm) +{ + unsigned long vdso =3D (unsigned long) mm->context.vdso; + struct futex_mm_data *fd =3D &mm->futex; + uintptr_t success, end; + + if (abi =3D=3D VDSO_ABI_AA64) { + success =3D (uintptr_t) VDSO_SYMBOL(vdso, futex_list64_try_unlock_cs_sta= rt); + end =3D (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 =3D (void *)new_vma->vm_start; =20 + vdso_futex_robust_unlock_update_ips(VDSO_ABI_AA64, current->mm); + + return 0; +} + +static int vdso32_mremap(const struct vm_special_mapping *sm, + struct vm_area_struct *new_vma) +{ + current->mm->context.vdso =3D (void *)new_vma->vm_start; + + vdso_futex_robust_unlock_update_ips(VDSO_ABI_AA32, current->mm); + return 0; } =20 @@ -134,6 +165,8 @@ static int __setup_additional_pages(enum vdso_abi abi, if (IS_ERR(ret)) goto up_fail; =20 + vdso_futex_robust_unlock_update_ips(abi, mm); + return 0; =20 up_fail: @@ -174,7 +207,7 @@ static struct vm_special_mapping aarch32_vdso_maps[] = =3D { }, [AA32_MAP_VDSO] =3D { .name =3D "[vdso]", - .mremap =3D vdso_mremap, + .mremap =3D vdso32_mremap, }, }; =20 diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vds= o.lds.S index 52314be29191..225f59bb81d1 100644 --- a/arch/arm64/kernel/vdso/vdso.lds.S +++ b/arch/arm64/kernel/vdso/vdso.lds.S @@ -104,6 +104,9 @@ VERSION __kernel_clock_gettime; __kernel_clock_getres; __kernel_getrandom; +#ifdef CONFIG_FUTEX_ROBUST_UNLOCK + __vdso_futex_robust_list64_try_unlock; +#endif local: *; }; } @@ -112,3 +115,9 @@ VERSION * Make the sigreturn code visible to the kernel. */ VDSO_sigtramp =3D __kernel_rt_sigreturn; + +#ifdef CONFIG_FUTEX_ROBUST_UNLOCK +VDSO_futex_list64_try_unlock_cs_start =3D __futex_list64_try_unlock_cs_sta= rt; +VDSO_futex_list64_try_unlock_cs_success =3D __futex_list64_try_unlock_cs_s= uccess; +VDSO_futex_list64_try_unlock_cs_end =3D __futex_list64_try_unlock_cs_end; +#endif --=20 2.55.0 From nobody Sat Jul 25 04:56:16 2026 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 009AF429CDB; Fri, 17 Jul 2026 14:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784299348; cv=none; b=gFU+ZTIJ3dpzork6TCnHKrN02+Xp07734mmnCg55I3XMnqyicLqTOd9kKCEa9W41UY1JdGfIev269ytJWIvbr8jPNYcYBIiu27fAz4m8GC0Sjv8/ipkRvDJzBZP2y+iWg9zghHiqrlSOhcBXtGHd1W317QX66kYPxRGWTyvRNwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784299348; c=relaxed/simple; bh=tCu3x1GUAtejJXUdG+KzVJ4tcWL/cJSe31+zSWtGpJo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VJGax/l0r0B1XrNBCPGen9SRVMr+T5huguQ/HnP+B6IC3ob7rZ8VZ16rPlHs7gF36qnTl3HFgwx5GG/EAAMkIwvSJY7GvYqdmSGHVz92U8y5JkYtaRJpNtpyUM9dq04rkAO3RaJf3ZzyqoG78bxo6TRcTsWcMxYF9wh8JQvWF+c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=XhTj3Nfc; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="XhTj3Nfc" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=xiHRHGRCN+D8F05AzRxD1qJuLVX4cK/IR40j35eLsPY=; b=XhTj3NfcBSmxdHT6hwbMEqcC1c wnqAPgR+OsPOpU1aiwcqAjKvKW3tgIUCFzC5jrlLJWmUrq3T2GoDex9aNo7BB3UJRs2LTLJV1lAGP F8M/S2fuL0cNPy9467OE5HfIjuhb9Q4Ll1Cw3jd8LAHsfCydInjvPtEfKywWp68YKkhgSG2eOUtaK IpNIetDqg9/AwtyIVXOdKN3k4yCnb3NOWINDk0aTyjDsQnoZ1wk/KPAJ5utuWfBecV2kaMTTOkyhZ e4wLJ3pmd2Y9/ubo5NL0AFeOvt9EquFb/68Ew6KXUcaDMax+XFMoYfgiN8l9dOL4AeJ0Sc6ZbzFab IgeL23EA==; Received: from [179.118.191.219] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wkjlP-00GdLF-8r; Fri, 17 Jul 2026 16:42:07 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 17 Jul 2026 11:41:41 -0300 Subject: [PATCH v5 2/4] arm64: vdso: Implement __vdso_futex_robust_try_unlock() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260717-tonyk-robust_arm-v5-2-ffd1ad318d17@igalia.com> References: <20260717-tonyk-robust_arm-v5-0-ffd1ad318d17@igalia.com> In-Reply-To: <20260717-tonyk-robust_arm-v5-0-ffd1ad318d17@igalia.com> To: Catalin Marinas , Will Deacon , Thomas Gleixner , Mark Rutland , Mathieu Desnoyers , Sebastian Andrzej Siewior , Carlos O'Donell , Peter Zijlstra , Florian Weimer , Rich Felker , Torvald Riegel , Darren Hart , Ingo Molnar , Davidlohr Bueso , Arnd Bergmann , Uros Bizjak , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Liam R. Howlett" Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-dev@igalia.com, LKML , =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.15.2 Based on the x86 implementation, implement the vDSO function for unlocking a robust futex correctly. Commit a2274cc0091e ("x86/vdso: Implement __vdso_futex_robust_try_unlock()") has the full explanation about why this mechanism is needed. The unlock assembly sequence for arm64 is: __vdso_futex_robust_list64_try_unlock: retry: ldxr w8, [x0] // Load the value from *futex cmp w1, w8 // Compare with TID b.ne __vdso_futex_list64_try_unlock_cs_end stlxr w3, wzr, [x0] // Try to zero *futex __vdso_futex_list64_try_unlock_cs_start: cbnz w3, retry str xzr, [x2] // After zeroing *futex, zero *op_pending __vdso_futex_list64_try_unlock_cs_end>: The decision regarding if the pointer should be cleared or not lies on checking the w3 register: return (regs->user_regs[3]) ? NULL : (void __user *) regs->user_regs.regs[2]; If it's zero, that means that the exclusive store worked and the kernel should clear op_pending (if userspace didn't managed to) stored at x2. Signed-off-by: Andr=C3=A9 Almeida --- Notes: - Only LL/SC for now but I can add LSE later if this looks good v4: - Guard makefile for vfutex.o with ifdef - Moved _start label one instruction above - Use results register (w3) to check for store success instead of using ze= ro flag v3: - Managed to get pop to always be stored at x2 --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/futex_robust.h | 19 +++++++++++++++++++ arch/arm64/kernel/vdso/Makefile | 10 ++++++++++ arch/arm64/kernel/vdso/vfutex.c | 35 +++++++++++++++++++++++++++++++= ++++ 4 files changed, 65 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b3afe0688919..0582172811d9 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -221,6 +221,7 @@ config ARM64 select HAVE_RELIABLE_STACKTRACE select HAVE_POSIX_CPU_TIMERS_TASK_WORK select HAVE_FUNCTION_ARG_ACCESS_API + select HAVE_FUTEX_ROBUST_UNLOCK select MMU_GATHER_RCU_TABLE_FREE select HAVE_RSEQ select HAVE_RUST if RUSTC_SUPPORTS_ARM64 diff --git a/arch/arm64/include/asm/futex_robust.h b/arch/arm64/include/asm= /futex_robust.h new file mode 100644 index 000000000000..64f22166756a --- /dev/null +++ b/arch/arm64/include/asm/futex_robust.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_ARM64_FUTEX_ROBUST_H +#define _ASM_ARM64_FUTEX_ROBUST_H + +#include + +static __always_inline void __user *arm64_futex_robust_unlock_get_pop(stru= ct pt_regs *regs) +{ + /* + * w3 is stores the result of the stlxr instruction. If it's zero, the th= en + * the ll/sc cmpxchg succeeded and the pending op pointer needs to be cle= ared. + */ + return (regs->user_regs.regs[3]) ? NULL : (void __user *) regs->user_regs= .regs[2]; +} + +#define arch_futex_robust_unlock_get_pop(regs) \ + arm64_futex_robust_unlock_get_pop(regs) + +#endif /* _ASM_ARM64_FUTEX_ROBUST_H */ diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makef= ile index 7dec05dd33b7..985346c7a0bb 100644 --- a/arch/arm64/kernel/vdso/Makefile +++ b/arch/arm64/kernel/vdso/Makefile @@ -11,6 +11,10 @@ include $(srctree)/lib/vdso/Makefile.include =20 obj-vdso :=3D vgettimeofday.o note.o sigreturn.o vgetrandom.o vgetrandom-c= hacha.o =20 +ifdef CONFIG_FUTEX_ROBUST_UNLOCK + obj-vdso +=3D vfutex.o +endif + # Build rules targets :=3D $(obj-vdso) vdso.so vdso.so.dbg obj-vdso :=3D $(addprefix $(obj)/, $(obj-vdso)) @@ -45,9 +49,11 @@ CC_FLAGS_ADD_VDSO :=3D -O2 -mcmodel=3Dtiny -fasynchronou= s-unwind-tables =20 CFLAGS_REMOVE_vgettimeofday.o =3D $(CC_FLAGS_REMOVE_VDSO) CFLAGS_REMOVE_vgetrandom.o =3D $(CC_FLAGS_REMOVE_VDSO) +CFLAGS_REMOVE_vfutex.o =3D $(CC_FLAGS_REMOVE_VDSO) =20 CFLAGS_vgettimeofday.o =3D $(CC_FLAGS_ADD_VDSO) CFLAGS_vgetrandom.o =3D $(CC_FLAGS_ADD_VDSO) +CFLAGS_vfutex.o =3D $(CC_FLAGS_ADD_VDSO) =20 ifneq ($(c-gettimeofday-y),) CFLAGS_vgettimeofday.o +=3D -include $(c-gettimeofday-y) @@ -57,6 +63,10 @@ ifneq ($(c-getrandom-y),) CFLAGS_vgetrandom.o +=3D -include $(c-getrandom-y) endif =20 +ifneq ($(c-futex-y),) + CFLAGS_vfutex.o +=3D -include $(c-futex-y) +endif + targets +=3D vdso.lds CPPFLAGS_vdso.lds +=3D -P -C -U$(ARCH) =20 diff --git a/arch/arm64/kernel/vdso/vfutex.c b/arch/arm64/kernel/vdso/vfute= x.c new file mode 100644 index 000000000000..4c69d92426fd --- /dev/null +++ b/arch/arm64/kernel/vdso/vfutex.c @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include +#include + +#define LABEL(name, sz) __stringify(__futex_list##sz##_try_unlock_cs_##nam= e) + +#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) +{ + register __u64 *pop_reg asm("x2") =3D pop; + register __u32 result_reg asm("w3") =3D 0; + __u32 val; + + asm volatile ( + GLOBLS(64) + " prfm pstl1strm, %[lock] \n" + "retry: \n" + " ldxr %w[val], %[lock] \n" + " cmp %w[tid], %w[val] \n" + " bne " LABEL(end, 64)" \n" + " stlxr %w[result], wzr, %[lock] \n" + LABEL(start, 64)": \n" + " cbnz %w[result], retry \n" + LABEL(success, 64)": \n" + " str xzr, %[pop_reg] \n" + LABEL(end, 64)": \n" + + : [val] "=3D&r" (val), [result] "=3D&r" (result_reg) + : [tid] "r" (tid), [lock] "Q" (*lock), [pop_reg] "Q" (*pop_reg) + : "cc", "memory" + ); + + return val; +} --=20 2.55.0 From nobody Sat Jul 25 04:56:16 2026 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 838593F0774; Fri, 17 Jul 2026 14:42:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784299348; cv=none; b=sBjYHlsYIwxqNriMOwsmkPI3QceWI19f5q7B3XQo0k4EK3/S55gZTraMukVJPgZwyFyxxd/DYo3ogcZJjk3O3szwdtsruViZK1vV5QIn7XfGDPPcbLzuie9Xj6pehrrtb3cilHllnq3MDGrCLrQTAJPUdJns5I3HjA2BFUPkWaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784299348; c=relaxed/simple; bh=poYqrUsi500s0fQyhLYCsmsHf0i//77QFNaIOGes8ek=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SqOtWhkFtFTdxjYAUJaUzg4sMQ2+VktvjBEqtORZDncmAG+IlwRJmrySOE/1PJpOMJVwjtjN/LJUclxlpjMO5DvNCgFyuX9/O1ad6mFMDw9x1W3VYfBuYs9sOK7fN5LIi1Hv0hxcqB+RMlwBMKjn/lLMiM6rgAx0fNOdUf9N0YU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=WOphFKdy; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="WOphFKdy" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=K8kjW1mgVYNAmXTDHsHgs1H1Tp7aKYu9ZJKgbwnVZzM=; b=WOphFKdyVWS3R6jvupHqZ18tCb 8jN33exbLIxiPoeiYT4sWKOp6MPTa1VxqPC7QheYSnT7S9Ap3a2Yq0Z2BfySiZjjRepCmpaLcI7vP t56zRQYhHd4Mua/g4wiB3HfxNrqzBOm3ozCBx9xbyIlWuhPy2i2wtlQCP8JMDWz3Y6NKa/la/AoCz h9v/4lAMOxV2NQuD0IEmCFfhcMKrDru9EiVNz3v8/eFz3yeic3kqG+C3NgI6ZPHwR/gFXWXW7cdyM FBCJnme9qz8LMUxC6gvPFQm5pWyB3Izg03xK2nxmqgjgatXulig6kQJ/+UmEAjzlYZGR4/+2veBLV rjA2xsJg==; Received: from [179.118.191.219] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wkjlV-00GdLF-2p; Fri, 17 Jul 2026 16:42:13 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 17 Jul 2026 11:41:42 -0300 Subject: [PATCH v5 3/4] arm64: vdso32: Bring vdso32-offsets.h back Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260717-tonyk-robust_arm-v5-3-ffd1ad318d17@igalia.com> References: <20260717-tonyk-robust_arm-v5-0-ffd1ad318d17@igalia.com> In-Reply-To: <20260717-tonyk-robust_arm-v5-0-ffd1ad318d17@igalia.com> To: Catalin Marinas , Will Deacon , Thomas Gleixner , Mark Rutland , Mathieu Desnoyers , Sebastian Andrzej Siewior , Carlos O'Donell , Peter Zijlstra , Florian Weimer , Rich Felker , Torvald Riegel , Darren Hart , Ingo Molnar , Davidlohr Bueso , Arnd Bergmann , Uros Bizjak , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Liam R. Howlett" Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-dev@igalia.com, LKML , =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.15.2 Commit c7767f5c43df ("arm64: vdso32: Remove unused vdso32-offsets.h") removed vdso32-offsets.h because it was empty and therefore useless. With the introduction of __vdso_futex_robust_try_unlock(), there is the need to expose offsets again. Signed-off-by: Andr=C3=A9 Almeida --- arch/arm64/Makefile | 2 +- arch/arm64/include/asm/vdso.h | 3 +++ arch/arm64/kernel/vdso32/Makefile | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 6b005c8fef70..265716644193 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -211,7 +211,7 @@ vdso_prepare: prepare0 include/generated/vdso-offsets.h arch/arm64/kernel/vdso/vdso.so ifdef CONFIG_COMPAT_VDSO $(Q)$(MAKE) $(build)=3Darch/arm64/kernel/vdso32 \ - arch/arm64/kernel/vdso32/vdso.so + include/generated/vdso32-offsets.h arch/arm64/kernel/vdso32/vdso.so endif endif =20 diff --git a/arch/arm64/include/asm/vdso.h b/arch/arm64/include/asm/vdso.h index 232b46969088..43a214b93524 100644 --- a/arch/arm64/include/asm/vdso.h +++ b/arch/arm64/include/asm/vdso.h @@ -10,6 +10,9 @@ #ifndef __ASSEMBLER__ =20 #include +#ifdef CONFIG_COMPAT_VDSO +#include +#endif =20 #define VDSO_SYMBOL(base, name) \ ({ \ diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/M= akefile index bea3675fa668..4bd60f059f4a 100644 --- a/arch/arm64/kernel/vdso32/Makefile +++ b/arch/arm64/kernel/vdso32/Makefile @@ -135,6 +135,14 @@ $(c-obj-vdso-gettimeofday): %.o: %.c FORCE $(asm-obj-vdso): %.o: %.S FORCE $(call if_changed_dep,vdsoas) =20 +# Generate VDSO offsets using helper script +gen-vdsosym :=3D $(src)/../vdso/gen_vdso_offsets.sh +quiet_cmd_vdsosym =3D VDSOSYM $@ + cmd_vdsosym =3D $(NM) $< | $(gen-vdsosym) | LC_ALL=3DC sort > $@ + +include/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE + $(call if_changed,vdsosym) + # Actual build commands quiet_cmd_vdsold_and_vdso_check =3D LD32 $@ cmd_vdsold_and_vdso_check =3D $(cmd_vdsold); $(cmd_vdso_check) --=20 2.55.0 From nobody Sat Jul 25 04:56:16 2026 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7510D42A166; Fri, 17 Jul 2026 14:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784299365; cv=none; b=MzwjFR+LTi75EFzwaf62QMQHu8UfCzqUJTzAV483hqMLlK3MGyN1Eh3KUW2QtmUTPzvzbuya0sqQI8nmA9vICAlZvsCNXgYjhD7G1wNZ/ZycpFKMJ+a99LHxmnwZ5iY7r6BV8BnAhiYR1PwQZuv1rdfL8GAWFR0KUEH+IyQ2nN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784299365; c=relaxed/simple; bh=8661i5Dewl6J/ceBBJfh6Z5VBLi4WUNz1Je1glwiC5M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rRgOlDotvC2LBETP+8EGhLpOAHGRkbg/xb/t5TTfJjopMYLCAvnfQ6b3b7wBde9kAueOF+o0cqHrv/UBmNlPsW3fa1fZCxMwHuzwPn1PtsI1pmFShJO/YPCIQ4WyzYJwV8hR5uh9iepoCt5YJs2HEXoTmpWLXLiCBydc9WDMfK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=YCyANhJG; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="YCyANhJG" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=YYc5hJyDpXGozemY5+yNPTPEczhQbKUOofGE2WesAxA=; b=YCyANhJGY0u/+zoRJNp1IYhhIx lxLYawFBPs6IWX4ig+lhEvjNsHl2zPoSOkQce86/dSv2hGzecKviT8m022/V4TzSsuOXV2d/SlH1y CJ7tP9mwl/7VrGpGVLl6hcRSm7niwYE5C5LQix3YgH4xvK3Zvfga218KpM9zGeOYAWOy47Jkuk1cM LudOFSSION59eCDeifaTpxwHgV3jBC+GPgwG5opJCLmE5opR10Gs41GynKjLALaeLt+DtTThcq27+ j4goMOqn5voq0Ydml8l/PEyydF08juJQ8qJSS1IAlGUtec9OhzeXEnzO3Vjy+VgCNb68aRIYcTOgC +3DCqSIQ==; Received: from [179.118.191.219] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wkjla-00GdLF-T9; Fri, 17 Jul 2026 16:42:19 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Fri, 17 Jul 2026 11:41:43 -0300 Subject: [PATCH v5 4/4] arm64: vdso32: Implement __vdso_futex_robust_try_unlock() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260717-tonyk-robust_arm-v5-4-ffd1ad318d17@igalia.com> References: <20260717-tonyk-robust_arm-v5-0-ffd1ad318d17@igalia.com> In-Reply-To: <20260717-tonyk-robust_arm-v5-0-ffd1ad318d17@igalia.com> To: Catalin Marinas , Will Deacon , Thomas Gleixner , Mark Rutland , Mathieu Desnoyers , Sebastian Andrzej Siewior , Carlos O'Donell , Peter Zijlstra , Florian Weimer , Rich Felker , Torvald Riegel , Darren Hart , Ingo Molnar , Davidlohr Bueso , Arnd Bergmann , Uros Bizjak , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Liam R. Howlett" Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-dev@igalia.com, LKML , =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.15.2 Based on aarch64 implementation, provide a 32 bit entry point for this vDSO. In order to keep compatibility with arm64_futex_robust_unlock_get_pop(), make sure to store the pop address at r2 and the compare result value at r3. Signed-off-by: Andr=C3=A9 Almeida --- arch/arm64/kernel/vdso.c | 9 +++++++++ arch/arm64/kernel/vdso32/Makefile | 4 ++++ arch/arm64/kernel/vdso32/vdso.lds.S | 9 +++++++++ arch/arm64/kernel/vdso32/vfutex.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index ff43b74e514e..1e62af9158b9 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -71,6 +71,15 @@ static void vdso_futex_robust_unlock_update_ips(enum vds= o_abi abi, struct mm_str =20 futex_set_vdso_cs_range(fd, 0, success, end, false); } + +#ifdef CONFIG_COMPAT_VDSO + if (abi =3D=3D VDSO_ABI_AA32) { + success =3D (uintptr_t) VDSO_SYMBOL(vdso, futex_list32_try_unlock_cs_sta= rt); + end =3D (uintptr_t) VDSO_SYMBOL(vdso, futex_list32_try_unlock_cs_end); + + futex_set_vdso_cs_range(fd, 1, success, end, true); + } +#endif } #else static inline void vdso_futex_robust_unlock_update_ips(enum vdso_abi abi, = struct mm_struct *mm) { } diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/M= akefile index 4bd60f059f4a..f3190125c68b 100644 --- a/arch/arm64/kernel/vdso32/Makefile +++ b/arch/arm64/kernel/vdso32/Makefile @@ -97,6 +97,10 @@ munge :=3D ../../../arm/vdso/vdsomunge hostprogs :=3D $(munge) =20 c-obj-vdso :=3D note.o +ifdef CONFIG_FUTEX_ROBUST_UNLOCK + c-obj-vdso +=3D vfutex.o +endif + c-obj-vdso-gettimeofday :=3D vgettimeofday.o =20 ifneq ($(c-gettimeofday-y),) diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32= /vdso.lds.S index c374fb0146f3..46c0123b2684 100644 --- a/arch/arm64/kernel/vdso32/vdso.lds.S +++ b/arch/arm64/kernel/vdso32/vdso.lds.S @@ -87,6 +87,15 @@ VERSION __vdso_clock_getres; __vdso_clock_gettime64; __vdso_clock_getres_time64; +#ifdef CONFIG_FUTEX_ROBUST_UNLOCK + __vdso_futex_robust_list32_try_unlock; +#endif local: *; }; } + +#ifdef CONFIG_FUTEX_ROBUST_UNLOCK +VDSO_futex_list32_try_unlock_cs_success =3D __futex_list32_try_unlock_cs_s= uccess; +VDSO_futex_list32_try_unlock_cs_start =3D __futex_list32_try_unlock_cs_sta= rt; +VDSO_futex_list32_try_unlock_cs_end =3D __futex_list32_try_unlock_cs_end; +#endif diff --git a/arch/arm64/kernel/vdso32/vfutex.c b/arch/arm64/kernel/vdso32/v= futex.c new file mode 100644 index 000000000000..b6ca4b678108 --- /dev/null +++ b/arch/arm64/kernel/vdso32/vfutex.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include +#include + +#define LABEL(name, sz) __stringify(__futex_list##sz##_try_unlock_cs_##nam= e) + +#define GLOBLS(sz) ".globl " LABEL(start, sz) ", " LABEL(success, sz) ", "= LABEL(end, sz) "\n" + +__u32 __vdso_futex_robust_list32_try_unlock(__u32 *lock, __u32 tid, __u32 = *pop) +{ + register __u32 *pop_reg asm("r2") =3D pop, result_reg asm("r3") =3D 0; + __u32 val, zero =3D 0; + + asm volatile ( + GLOBLS(32) + "retry: \n" + " ldrex %[val], %[lock] \n" + " cmp %[tid], %[val] \n" + " bne " LABEL(end, 32)" \n" + " strex %[result], %[zero], %[lock] \n" + LABEL(start, 32)": \n" + " cmp %[result], #0 \n" + " bne retry \n" + LABEL(success, 32)": \n" + " str %[zero], %[pop_reg] \n" + LABEL(end, 32)": \n" + : [val] "=3D&r" (val), [result] "=3Dr" (result_reg) + : [tid] "r" (tid), [lock] "Q" (*lock), [pop_reg] "Q" (*pop_reg), [zero] = "r" (zero) + : "cc", "memory" + ); + + return val; +} --=20 2.55.0