From: Peter Zijlstra <peterz@infradead.org>
To: tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
mingo@redhat.com, dvhart@infradead.org, dave@stgolabs.net,
andrealmeid@igalia.com, Andrew Morton <akpm@linux-foundation.org>,
urezki@gmail.com, hch@infradead.org, lstoakes@gmail.com,
Arnd Bergmann <arnd@arndb.de>,
linux-api@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, malteskarupke@web.de, cl@linux.com,
llong@redhat.com
Subject: [PATCH 3/6] futex: Propagate flags into futex_get_value_locked()
Date: Fri, 25 Oct 2024 11:03:50 +0200 [thread overview]
Message-ID: <20241025093944.598921704@infradead.org> (raw)
In-Reply-To: 20241025090347.244183920@infradead.org
In order to facilitate variable sized futexes propagate the flags into
futex_get_value_locked().
No functional change intended.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/futex/core.c | 4 ++--
kernel/futex/futex.h | 2 +-
kernel/futex/pi.c | 8 ++++----
kernel/futex/requeue.c | 4 ++--
kernel/futex/waitwake.c | 4 ++--
5 files changed, 11 insertions(+), 11 deletions(-)
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -528,12 +528,12 @@ int futex_cmpxchg_value_locked(u32 *curv
return ret;
}
-int futex_get_value_locked(u32 *dest, u32 __user *from)
+int futex_get_value_locked(u32 *dest, u32 __user *from, unsigned int flags)
{
int ret;
pagefault_disable();
- ret = __get_user(*dest, from);
+ ret = futex_get_value(dest, from, flags);
pagefault_enable();
return ret ? -EFAULT : 0;
--- a/kernel/futex/futex.h
+++ b/kernel/futex/futex.h
@@ -239,7 +239,7 @@ extern void futex_wake_mark(struct wake_
extern int fault_in_user_writeable(u32 __user *uaddr);
extern int futex_cmpxchg_value_locked(u32 *curval, u32 __user *uaddr, u32 uval, u32 newval);
-extern int futex_get_value_locked(u32 *dest, u32 __user *from);
+extern int futex_get_value_locked(u32 *dest, u32 __user *from, unsigned int flags);
extern struct futex_q *futex_top_waiter(struct futex_hash_bucket *hb, union futex_key *key);
extern void __futex_unqueue(struct futex_q *q);
--- a/kernel/futex/pi.c
+++ b/kernel/futex/pi.c
@@ -240,7 +240,7 @@ static int attach_to_pi_state(u32 __user
* still is what we expect it to be, otherwise retry the entire
* operation.
*/
- if (futex_get_value_locked(&uval2, uaddr))
+ if (futex_get_value_locked(&uval2, uaddr, FLAGS_SIZE_32))
goto out_efault;
if (uval != uval2)
@@ -359,7 +359,7 @@ static int handle_exit_race(u32 __user *
* The same logic applies to the case where the exiting task is
* already gone.
*/
- if (futex_get_value_locked(&uval2, uaddr))
+ if (futex_get_value_locked(&uval2, uaddr, FLAGS_SIZE_32))
return -EFAULT;
/* If the user space value has changed, try again. */
@@ -527,7 +527,7 @@ int futex_lock_pi_atomic(u32 __user *uad
* Read the user space value first so we can validate a few
* things before proceeding further.
*/
- if (futex_get_value_locked(&uval, uaddr))
+ if (futex_get_value_locked(&uval, uaddr, FLAGS_SIZE_32))
return -EFAULT;
if (unlikely(should_fail_futex(true)))
@@ -750,7 +750,7 @@ static int __fixup_pi_state_owner(u32 __
if (!pi_state->owner)
newtid |= FUTEX_OWNER_DIED;
- err = futex_get_value_locked(&uval, uaddr);
+ err = futex_get_value_locked(&uval, uaddr, FLAGS_SIZE_32);
if (err)
goto handle_err;
--- a/kernel/futex/requeue.c
+++ b/kernel/futex/requeue.c
@@ -275,7 +275,7 @@ futex_proxy_trylock_atomic(u32 __user *p
u32 curval;
int ret;
- if (futex_get_value_locked(&curval, pifutex))
+ if (futex_get_value_locked(&curval, pifutex, FLAGS_SIZE_32))
return -EFAULT;
if (unlikely(should_fail_futex(true)))
@@ -453,7 +453,7 @@ int futex_requeue(u32 __user *uaddr1, un
if (likely(cmpval != NULL)) {
u32 curval;
- ret = futex_get_value_locked(&curval, uaddr1);
+ ret = futex_get_value_locked(&curval, uaddr1, FLAGS_SIZE_32);
if (unlikely(ret)) {
double_unlock_hb(hb1, hb2);
--- a/kernel/futex/waitwake.c
+++ b/kernel/futex/waitwake.c
@@ -453,7 +453,7 @@ int futex_wait_multiple_setup(struct fut
u32 val = vs[i].w.val;
hb = futex_q_lock(q);
- ret = futex_get_value_locked(&uval, uaddr);
+ ret = futex_get_value_locked(&uval, uaddr, FLAGS_SIZE_32);
if (!ret && uval == val) {
/*
@@ -621,7 +621,7 @@ int futex_wait_setup(u32 __user *uaddr,
retry_private:
*hb = futex_q_lock(q);
- ret = futex_get_value_locked(&uval, uaddr);
+ ret = futex_get_value_locked(&uval, uaddr, FLAGS_SIZE_32);
if (ret) {
futex_q_unlock(*hb);
next prev parent reply other threads:[~2024-10-25 9:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 9:03 [PATCH 0/6] futex: The remaining futex2 bits Peter Zijlstra
2024-10-25 9:03 ` [PATCH 1/6] mm: Add vmalloc_huge_node() Peter Zijlstra
2024-10-25 9:58 ` Uladzislau Rezki
2024-10-25 16:00 ` Davidlohr Bueso
2024-10-25 9:03 ` [PATCH 2/6] futex: Implement FUTEX2_NUMA Peter Zijlstra
2024-10-25 18:30 ` Davidlohr Bueso
2024-10-28 9:38 ` Peter Zijlstra
2024-10-25 19:28 ` Christoph Lameter (Ampere)
2024-10-28 1:59 ` Davidlohr Bueso
2024-10-28 22:34 ` Christoph Lameter (Ampere)
2024-10-28 9:46 ` Peter Zijlstra
2024-10-28 22:37 ` Christoph Lameter (Ampere)
2024-10-25 21:23 ` André Almeida
2024-10-25 9:03 ` Peter Zijlstra [this message]
2024-10-25 9:03 ` [PATCH 4/6] futex: Enable FUTEX2_{8,16} Peter Zijlstra
2024-10-25 9:03 ` [PATCH 5/6] futex,selftests: Extend the futex selftests Peter Zijlstra
2024-10-25 9:03 ` [PATCH 6/6] futex,selftests: Extend the futex selftests for NUMA Peter Zijlstra
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=20241025093944.598921704@infradead.org \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=andrealmeid@igalia.com \
--cc=arnd@arndb.de \
--cc=cl@linux.com \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=hch@infradead.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=llong@redhat.com \
--cc=lstoakes@gmail.com \
--cc=malteskarupke@web.de \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=urezki@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).