From patchwork Thu Sep 21 17:36:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 142947 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5165019vqi; Thu, 21 Sep 2023 15:02:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGUTvdYC38Z8vv3xohbESxSNweKD5XXkKv/YzhBT3s8lWOaMbe7GqkBD7sm1ShzMiKAeNm X-Received: by 2002:a05:6a00:2187:b0:690:c79c:cca6 with SMTP id h7-20020a056a00218700b00690c79ccca6mr6527482pfi.25.1695333750632; Thu, 21 Sep 2023 15:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695333750; cv=none; d=google.com; s=arc-20160816; b=bC1x+iDjPe/dXavRXL6i50Siu/CTsT9z8R2GpCr5p/aLVvcPuIzRhpBce4xGlZ7xr1 Q+RbOjQcnW4YDQI4Id1xr+p+IfhlgJZkQ9N2kdu+ekFVwHLhQ0cglN/6QZAGZcSdHCWU wI5TbXbg3ai2kHNVPeXBdpDy894tqTqCZffTwDZ/FEtrwQ7nhRJsQ3aez0b8k0eLJm8+ ZsXmEBYw250SHZKj60MQgA/e32WIPRWCKiUB7RdEsVwrz0Y45m/4BXso/yk80uGIIGBe zxvR5zfrhK3SzaqeOlyQRlhuVcf83AmUVvr+ZUljEfWm+6YtnqHXd+8Y6GLqjgzyT8pg yxoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=MpbIu30gcGg96xLSgkfP4+EIIDAxGY+PaJcVDLY/4X0=; fh=51w4OSdjTJF7zPLz9BeYfqokcBXCUA1NOZqhQDttTbc=; b=B5vgsYXHEU7JltN07TcLlsw5qZ/jwFvXu20n+FId3iBbr+eOnUuEVwqkUARKCwBZpa WD//yvG0etmzI5W1zAjaWtQbmu+UKYCkhv+t0k/t6C8sxK3b8te0M8sDCXk/yfKGYJXP k1mGc+oghfe1q4h4/QsKgL2bJOdOn2n1124izQS9j6bONpyHudz5gbz57rv7GQaS7cW2 PQ+VXiTz+gw/8oPGMxvPp+q1FIiMtMEAb4i1Bj6nBgO/1ItdeXPybD8DoirU1a/5zYiQ kf0HoH3W4lhRhBZKBfCIJPBbkS5pzmBSvJIcreCCLJAUaSH44+nenNIFZuPTL8ettAnr zKQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=I9XPLO8X; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id v63-20020a638942000000b005644829012fsi2246122pgd.701.2023.09.21.15.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 15:02:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=I9XPLO8X; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DAC4C8131C16; Thu, 21 Sep 2023 13:41:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232177AbjIUUja (ORCPT + 29 others); Thu, 21 Sep 2023 16:39:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232159AbjIUUjT (ORCPT ); Thu, 21 Sep 2023 16:39:19 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 615CB7C70D; Thu, 21 Sep 2023 10:36:36 -0700 (PDT) Date: Thu, 21 Sep 2023 17:36:06 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695317767; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MpbIu30gcGg96xLSgkfP4+EIIDAxGY+PaJcVDLY/4X0=; b=I9XPLO8Xb5CJfCKnckSQGjGhLbIcmUub8WI4rQQzU1ae+hPhK0o4+ruWkrqbHxrEQ/xLOY /EWkIWeBr15y25A3zNCwgGD5sQNtOog1EJjGTYIJgWuSR+thMT1fA/M1orpELCv9CB2NYE 2Jhlf36gtqKLh1JHsxJUlVHSGs3fXfjRByJWeVn1CM4F8ZyTC0pRX1HD7D1z2McsxwWjFT 7Ch9ZS71bcnOilts4kvGi/OrLb2/VCIKbWvi7ZAS4eeKKRnlg11w+z6Z9KxRiNk0Fb8Uh5 wI8ZklbeG5GOZ+j/ekoHRuIzkbljdS1UuN59WfoqNU3cZLWNbMmIVQwA01IYBw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695317767; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MpbIu30gcGg96xLSgkfP4+EIIDAxGY+PaJcVDLY/4X0=; b=Edz4+DGvOfFybpa++JbC9G1sq+JAKzHZ1GqkvMUerch9KffGRTYrOH442s1g2/AUUXgxm5 Ur4GSKmgZyrickAQ== From: "tip-bot2 for peterz@infradead.org" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] futex: Clarify FUTEX2 flags Cc: "Peter Zijlstra (Intel)" , Thomas Gleixner , andrealmeid@igalia.com, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230921105247.507327749@noisy.programming.kicks-ass.net> References: <20230921105247.507327749@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Message-ID: <169531776669.27769.7129503337742105554.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:41:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777686282637052036 X-GMAIL-MSGID: 1777686282637052036 The following commit has been merged into the locking/core branch of tip: Commit-ID: 4923954bbc4a760e0b2210e0cb5733726ac2e2e9 Gitweb: https://git.kernel.org/tip/4923954bbc4a760e0b2210e0cb5733726ac2e2e9 Author: peterz@infradead.org AuthorDate: Thu, 21 Sep 2023 12:45:06 +02:00 Committer: Peter Zijlstra CommitterDate: Thu, 21 Sep 2023 19:22:04 +02:00 futex: Clarify FUTEX2 flags sys_futex_waitv() is part of the futex2 series (the first and only so far) of syscalls and has a flags field per futex (as opposed to flags being encoded in the futex op). This new flags field has a new namespace, which unfortunately isn't super explicit. Notably it currently takes FUTEX_32 and FUTEX_PRIVATE_FLAG. Introduce the FUTEX2 namespace to clarify this Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Thomas Gleixner Reviewed-by: André Almeida Link: https://lore.kernel.org/r/20230921105247.507327749@noisy.programming.kicks-ass.net --- include/uapi/linux/futex.h | 16 +++++++++++++--- kernel/futex/syscalls.c | 7 +++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/uapi/linux/futex.h b/include/uapi/linux/futex.h index 71a5df8..21d4eff 100644 --- a/include/uapi/linux/futex.h +++ b/include/uapi/linux/futex.h @@ -44,10 +44,20 @@ FUTEX_PRIVATE_FLAG) /* - * Flags to specify the bit length of the futex word for futex2 syscalls. - * Currently, only 32 is supported. + * Flags for futex2 syscalls. */ -#define FUTEX_32 2 + /* 0x00 */ + /* 0x01 */ +#define FUTEX2_SIZE_U32 0x02 + /* 0x04 */ + /* 0x08 */ + /* 0x10 */ + /* 0x20 */ + /* 0x40 */ +#define FUTEX2_PRIVATE FUTEX_PRIVATE_FLAG + +/* do not use */ +#define FUTEX_32 FUTEX2_SIZE_U32 /* historical accident :-( */ /* * Max numbers of elements in a futex_waitv array diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c index a807407..ff696b0 100644 --- a/kernel/futex/syscalls.c +++ b/kernel/futex/syscalls.c @@ -183,8 +183,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, return do_futex(uaddr, op, val, tp, uaddr2, (unsigned long)utime, val3); } -/* Mask of available flags for each futex in futex_waitv list */ -#define FUTEXV_WAITER_MASK (FUTEX_32 | FUTEX_PRIVATE_FLAG) +#define FUTEX2_VALID_MASK (FUTEX2_SIZE_U32 | FUTEX2_PRIVATE) /** * futex_parse_waitv - Parse a waitv array from userspace @@ -205,10 +204,10 @@ static int futex_parse_waitv(struct futex_vector *futexv, if (copy_from_user(&aux, &uwaitv[i], sizeof(aux))) return -EFAULT; - if ((aux.flags & ~FUTEXV_WAITER_MASK) || aux.__reserved) + if ((aux.flags & ~FUTEX2_VALID_MASK) || aux.__reserved) return -EINVAL; - if (!(aux.flags & FUTEX_32)) + if (!(aux.flags & FUTEX2_SIZE_U32)) return -EINVAL; futexv[i].w.flags = aux.flags;