From patchwork Thu Sep 21 10:45:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 13393844 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F03DE70718 for ; Thu, 21 Sep 2023 11:01:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C911E6B01A3; Thu, 21 Sep 2023 07:00:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF23E6B01B1; Thu, 21 Sep 2023 07:00:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE0706B01F9; Thu, 21 Sep 2023 07:00:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9CAD36B01A3 for ; Thu, 21 Sep 2023 07:00:59 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6F903C10B6 for ; Thu, 21 Sep 2023 11:00:59 +0000 (UTC) X-FDA: 81260312238.08.956A0B5 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf15.hostedemail.com (Postfix) with ESMTP id 2D556A0041 for ; Thu, 21 Sep 2023 11:00:55 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b="D3oUK/pO"; dmarc=none; spf=none (imf15.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695294056; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:references:dkim-signature; bh=s6qOxGEZJpUErRo7Rj/ShDjtuA5F7i3OQJb+GA/Bkxo=; b=KKWRMsXTl2xmGrltwQhr7zbk9pXpVk4VKYYKVbLuVo2441wKwlLR9hH0+ynKJ8SW6Wq69n Zmll2VVtw/85jWYZqfRFw06gvNLwnA6dylFH51jMgxgoaIPgYi/cyalfvFdHjdyFQNvHBW VlkhFsKhua9bcpDvfOs3z4m/t9uQi9E= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b="D3oUK/pO"; dmarc=none; spf=none (imf15.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695294056; a=rsa-sha256; cv=none; b=CC63KW3eUF3s2bDJ0YvIAn/u6fpWed4r9XNguxbB0ZLpwVe2/DNNFarS7UkTkHp7qtcvp6 MmdLNKMLmxxJINQTuYCH7KEplIyYpkSqacj+DkfI4AshLKyWQ/7A/G5PBGPys9m8++XP2u e3T4e2H6oZ2XjOVr5PCTVoTuYDv36iM= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-Id:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=s6qOxGEZJpUErRo7Rj/ShDjtuA5F7i3OQJb+GA/Bkxo=; b=D3oUK/pO445uaPiP0UtrFW7hXa oKZz9yxvDNPjaKGxg+tuiKw82E47h3XSx1J1DtEx5/rO/Ue7n1RjsT8ClHfs5ISvz5vNJWJsrkIuA 0ui4A/To6UDY07L1ltjrTzUwk7nI3WvMdvonqicjSHRMsq5KyZxf0tb6QrOfqs7ZLA//VIXr/9qFW cze4siUErqj4DLV5JdF5b/Icns3tEaq1kbYbpCZmyI419v1f7F+4SLOHmrjiK5p3eoVvuUByqPDQz eLLWEv5LdNv7XBieo03gAqykd/mkLRixRW1Oph05DbRI73MxCQQfYN3EUx6SKXBr/CbYfTLYJm1Ng Gk8gGfng==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qjHQN-00FJvy-1Y; Thu, 21 Sep 2023 11:00:49 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 20ED33006F6; Thu, 21 Sep 2023 13:00:43 +0200 (CEST) Message-Id: <20230921105249.002168440@noisy.programming.kicks-ass.net> User-Agent: quilt/0.65 Date: Thu, 21 Sep 2023 12:45:18 +0200 From: peterz@infradead.org To: tglx@linutronix.de, axboe@kernel.dk Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, dvhart@infradead.org, dave@stgolabs.net, andrealmeid@igalia.com, Andrew Morton , urezki@gmail.com, hch@infradead.org, lstoakes@gmail.com, Arnd Bergmann , linux-api@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, malteskarupke@web.de Subject: [PATCH v3 13/15] futex: Propagate flags into futex_get_value_locked() References: <20230921104505.717750284@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Disposition: inline; filename=peterz-futex2-get_values_locked.patch X-Rspam-User: X-Stat-Signature: 9kpztqngd6r74f5tj19wgq3m87czgub3 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2D556A0041 X-HE-Tag: 1695294055-489623 X-HE-Meta: U2FsdGVkX1/vu2661eXOGpMyqI3fxxoVOwUmgifcsg+aqxcXAEsRFRNH5GvDL3hAwHhEAH76Ceoi5SVZYTVyH3BY+YzCwgR1HE6aCiuhAGKdZe7LkPuo9d/aaJSF6tbveTMZ5KX9jObZbNgNBNnvIO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Y32fxBFTHnWCL3Ix59pPiENnIlUIdq6Rd9IT8o0SLI0IRGLenv6sf+vcInr2oBfYyZ5kGyC3/YSoLK5IRzttvUndqXzI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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) Reviewed-by: Thomas Gleixner --- 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(-) Index: linux-2.6/kernel/futex/core.c =================================================================== --- linux-2.6.orig/kernel/futex/core.c +++ linux-2.6/kernel/futex/core.c @@ -516,12 +516,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; Index: linux-2.6/kernel/futex/futex.h =================================================================== --- linux-2.6.orig/kernel/futex/futex.h +++ linux-2.6/kernel/futex/futex.h @@ -229,7 +229,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); Index: linux-2.6/kernel/futex/pi.c =================================================================== --- linux-2.6.orig/kernel/futex/pi.c +++ linux-2.6/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 @@ retry: 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; Index: linux-2.6/kernel/futex/requeue.c =================================================================== --- linux-2.6.orig/kernel/futex/requeue.c +++ linux-2.6/kernel/futex/requeue.c @@ -273,7 +273,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))) @@ -451,7 +451,7 @@ retry_private: 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); Index: linux-2.6/kernel/futex/waitwake.c =================================================================== --- linux-2.6.orig/kernel/futex/waitwake.c +++ linux-2.6/kernel/futex/waitwake.c @@ -441,7 +441,7 @@ retry: 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) { /* @@ -609,7 +609,7 @@ retry: 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);