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 C972940756B for ; Thu, 19 Mar 2026 23:24:29 +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=1773962669; cv=none; b=dpSeL/WMkNpJTN6WMHrf/YKI+gHwTzCKLwMKKNqnBSCtB6DtB3FXGAzvphNh7BmNH41nzeCQan+1Ty3V8ZZ6hFpLETu+SRGBFx+ZxxVh8PNscpMeaW4O55Up5Eo0azAX13bnMcCPzhUe3DNLoHL8LB2DiX7Nj4z/9S/EQ1fmdr4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773962669; c=relaxed/simple; bh=6yfJuC4d7/avbM+SpT6/RtWq6g7fF+LGPQB1utWZ8EM=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=PTQGawQv4Rn5Rtc3L7viw40RX3g9mLvUj4Ecof7BFlHR+dWZ4QZl8svJENZMVg4Ys9oDQDeWc/8ibyrPW+aBtSi60WAc0XwugtMj8pjgyX/C3hPrTOeQaxKkRZyOf0Wb4MzMeQCOyHM48YOwvFGEOiWk90rxzDe8Y9dptJp7Smo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I+PeGOAo; 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="I+PeGOAo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95155C2BCC6; Thu, 19 Mar 2026 23:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773962669; bh=6yfJuC4d7/avbM+SpT6/RtWq6g7fF+LGPQB1utWZ8EM=; h=Date:From:To:Cc:Subject:References:From; b=I+PeGOAoQd0VB2T84a8eYyL40DwWXUXmQbncBKlhVDy6qTOjIW6dyg98k7WeHg1AA ys3kJsM1esfEOJaIKFM4dvsfP659ltEU9i5g7CzuPMywLXlHWQSYYKuQWLd70JWrt3 2c2IUq+tjlC0NtptCVppusVne7QEkztAE5UY9/BW/3EAevzrdAHWJjnvsN7qAuy117 eHh2gN+bJ4m3GuaUEbelREdc7YnZ15/E5QVDhBXHrpN7fzvxLvBYSHClbJ1IlZcIPi c20rd0wm7uyZtGjJSilT9Uz1CxZblHt04UkgRueTE1cY4c54k4mfgha9oJ39BB2FsX aKCgEIzL0ghRg== Date: Fri, 20 Mar 2026 00:24:25 +0100 Message-ID: <20260319231239.410326941@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" , Uros Bizjak , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [patch v2 04/11] uaccess: Provide unsafe_atomic_store_release_user() References: <20260319225224.853416463@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 The upcoming support for unlocking robust futexes in the kernel requires store release semantics. Syscalls do not imply memory ordering on all architectures so the unlock operation requires a barrier. This barrier can be avoided when stores imply release like on x86. Provide a generic version with a smp_mb() before the unsafe_put_user(), which can be overridden by architectures. Provide also a ARCH_STORE_IMPLIES_RELEASE Kconfig option, which can be selected by architectures where store implies release, so that the smp_mb() in the generic implementation can be avoided. Signed-off-by: Thomas Gleixner --- V2: New patch --- arch/Kconfig | 4 ++++ include/linux/uaccess.h | 9 +++++++++ 2 files changed, 13 insertions(+) --- a/arch/Kconfig +++ b/arch/Kconfig @@ -403,6 +403,10 @@ config ARCH_32BIT_OFF_T config ARCH_32BIT_USTAT_F_TINODE bool +# Selected by architectures when plain stores have release semantics +config ARCH_STORE_IMPLIES_RELEASE + bool + config HAVE_ASM_MODVERSIONS bool help --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -644,6 +644,15 @@ static inline void user_access_restore(u #define user_read_access_end user_access_end #endif +#ifndef unsafe_atomic_store_release_user +# define unsafe_atomic_store_release_user(val, uptr, elbl) \ + do { \ + if (!IS_ENABLED(CONFIG_ARCH_STORE_IMPLIES_RELEASE)) \ + smp_mb(); \ + unsafe_put_user(val, uptr, elbl); \ + } while (0) +#endif + /* Define RW variant so the below _mode macro expansion works */ #define masked_user_rw_access_begin(u) masked_user_access_begin(u) #define user_rw_access_begin(u, s) user_access_begin(u, s)