From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CE5353CFF68 for ; Mon, 16 Mar 2026 17:13:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773681202; cv=none; b=ALwYA/Coy2sRbJ9GU+tQXUxp+LZ7W8dsjkb1/R3BkmAz193abXVRoC69XM+QYv4dYqHa4dT6R9p0Gh00TibcPBJIkabjB5q6qShQitybgUEzZXc1fFZVFLmXsjShdHr4TEA5uJrf804Xfcq/BDNakSka7SqOHqxInnO/B77bGKc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773681202; c=relaxed/simple; bh=igHKbK3BClquVFqMW+rw/fWxzpB0BWH+cD4RYKhTHfM=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=U/Pg3rX6ghn8KXaclihu6BRfHp5Jo3le9RxkSHwtN4VN9lHdqjZZ24as+YQc+R+7EjTZYK53qvhEjYoeB99KS5OjaaM4B9RO8aIfFMW/tBQEbdMxPF+2Gjx9dv/Gtq60k//jOu1FrHhWTuRe64NmDRfJQ0c2k4Yjy5TzGilr6/o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NowuCcEm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NowuCcEm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95911C19421; Mon, 16 Mar 2026 17:13:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773681202; bh=igHKbK3BClquVFqMW+rw/fWxzpB0BWH+cD4RYKhTHfM=; h=Date:From:To:Cc:Subject:References:From; b=NowuCcEmueJXF5BfgNtYpfX8lQ5R96e2eHpck7HPue/DU09SFtwd4mKtjQgCAB06i Jc4dvRCmbgoKE/bJRJCdFSeh8giAD3MB54+iJk/mUPATC+W0dVvXKZ5i7mjhY/Ja3T IvddWVwZOT3LvjTRKDj6IJwhTsS0b7PZXHwMADsC+m+/xKSHbcHU+LBDwPQs0O4pMn UIn3iptgW8+Z7UIJOpP5pTHCc7TdXRVPBlswfL7OsfjnFd8zGF3zuDJF5LY3z7APh7 f6Wfaeo9Kb5J59V6IjMgFNFO7PNHwRRfMikWSLvVBkudM9BMitIPofBaUO5f1SeKMY UH0MSsnODJ9KQ== Date: Mon, 16 Mar 2026 18:13:18 +0100 Message-ID: <20260316164951.277660913@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Mathieu Desnoyers , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Sebastian Andrzej Siewior , Carlos O'Donell , Peter Zijlstra , Florian Weimer , Rich Felker , Torvald Riegel , Darren Hart , Ingo Molnar , Davidlohr Bueso , Arnd Bergmann , "Liam R . Howlett" Subject: [patch 5/8] futex: Add robust futex unlock IP range References: <20260316162316.356674433@kernel.org> 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 There will be a VDSO function to unlock robust futexes in user space. The unlock sequence is racy vs. clearing the list_pending_op pointer in the tasks robust list head. To plug this race the kernel needs to know the instruction window. As the VDSO is per MM the addresses are stored in mm_struct::futex. Architectures which implement support for this have to update these addresses when the VDSO is (re)mapped. Arguably this could be resolved by chasing mm->context->vdso->image, but that that's architecture specific and requires to touch quite some cache lines. Having it in mm::futex reduces the cache line impact and avoids having yet another set of architecture specific functionality. Signed-off-by: Thomas Gleixner --- include/linux/futex_types.h | 32 +++++++++++++++++++++++++------- include/linux/mm_types.h | 1 + init/Kconfig | 6 ++++++ 3 files changed, 32 insertions(+), 7 deletions(-) --- a/include/linux/futex_types.h +++ b/include/linux/futex_types.h @@ -33,13 +33,26 @@ struct futex_ctrl { }; /** * struct futex_mm_data - Futex related per MM data - * @phash_lock: Mutex to protect the private hash operations - * @phash: RCU managed pointer to the private hash - * @phash_new: Pointer to a newly allocated private hash - * @phash_batches: Batch state for RCU synchronization - * @phash_rcu: RCU head for call_rcu() - * @phash_atomic: Aggregate value for @phash_ref - * @phash_ref: Per CPU reference counter for a private hash + * @phash_lock: Mutex to protect the private hash operations + * @phash: RCU managed pointer to the private hash + * @phash_new: Pointer to a newly allocated private hash + * @phash_batches: Batch state for RCU synchronization + * @phash_rcu: RCU head for call_rcu() + * @phash_atomic: Aggregate value for @phash_ref + * @phash_ref: Per CPU reference counter for a private hash + * + * @unlock_cs_start_ip: The start IP of the robust futex unlock critical section + * + * @unlock_cs_success_ip: The IP of the robust futex unlock critical section which + * indicates that the unlock (cmpxchg) was successful + * Required to handle the compat size insanity for mixed mode + * game emulators. + * + * Not evaluated by the core code as that only + * evaluates the start/end range. Can therefore be 0 if the + * architecture does not care. + * + * @unlock_cs_end_ip: The end IP of the robust futex unlock critical section */ struct futex_mm_data { #ifdef CONFIG_FUTEX_PRIVATE_HASH @@ -51,6 +64,11 @@ struct futex_mm_data { atomic_long_t phash_atomic; unsigned int __percpu *phash_ref; #endif +#ifdef CONFIG_FUTEX_ROBUST_UNLOCK + unsigned long unlock_cs_start_ip; + unsigned long unlock_cs_success_ip; + unsigned long unlock_cs_end_ip; +#endif }; #endif /* _LINUX_FUTEX_TYPES_H */ --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -22,6 +22,7 @@ #include #include #include +#include #include --- a/init/Kconfig +++ b/init/Kconfig @@ -1822,6 +1822,12 @@ config FUTEX_MPOL depends on FUTEX && NUMA default y +config HAVE_FUTEX_ROBUST_UNLOCK + bool + +config FUTEX_ROBUST_UNLOCK + def_bool FUTEX && HAVE_GENERIC_VDSO && GENERIC_IRQ_ENTRY && RSEQ && HAVE_FUTEX_ROBUST_UNLOCK + config EPOLL bool "Enable eventpoll support" if EXPERT default y