From patchwork Mon Dec 9 09:47:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 13899159 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 CF73EE77173 for ; Mon, 9 Dec 2024 09:47:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58F8F6B03F2; Mon, 9 Dec 2024 04:47:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 53D5A6B03F3; Mon, 9 Dec 2024 04:47:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 454D86B03F4; Mon, 9 Dec 2024 04:47:44 -0500 (EST) 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 28C4A6B03F2 for ; Mon, 9 Dec 2024 04:47:44 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C618F120366 for ; Mon, 9 Dec 2024 09:47:43 +0000 (UTC) X-FDA: 82874942766.27.08368E9 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf08.hostedemail.com (Postfix) with ESMTP id 8DB3616000E for ; Mon, 9 Dec 2024 09:47:28 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf08.hostedemail.com: domain of yury.khrustalev@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=yury.khrustalev@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737643; a=rsa-sha256; cv=none; b=ipppzBEZxbwj51CMAfE0FAf4OI+Mg5OwtIV8IGQSE7SewEZ1BpO9ldhjwtVPRg4YhymALA qEi+AwEmS+hV/VVXnClsY2IMfiie60wW5lkVfsiRWVMQvzp1AILGDSwzzSTLPc1owoBNfo 1vo8265JUARkv7tNZTiYwvL0sqVuEZQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf08.hostedemail.com: domain of yury.khrustalev@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=yury.khrustalev@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737643; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ni769i74TSTMc2HCIR8rv+ryIDdcPChPeu1Bt8O/pdw=; b=NZXpbK2gH7Zha5UMAWFEjv1uNvjftgbWr1rp63k0NwNFVXNQK04sJ5B27u9ihLA4wtTGbU IbJHq+f7tCAb0R436oOOcmZXMJNo4TrGj+rsuOXLBiErwhdfA2j4RhGT2w+rIe7Jwv2JjC lIPzAChFtjb1Qz0RscBpq3iEe81BhF0= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 25E9A143D; Mon, 9 Dec 2024 01:48:09 -0800 (PST) Received: from udebian.localdomain (unknown [10.1.35.36]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A5B7D3F720; Mon, 9 Dec 2024 01:47:38 -0800 (PST) From: Yury Khrustalev To: linux-arch@vger.kernel.org Cc: Arnd Bergmann , Kevin Brodsky , Joey Gouly , Dave Hansen , Sandipan Das , Michael Ellerman , Catalin Marinas , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, nd@arm.com, Yury Khrustalev Subject: [RESEND v4 1/3] mm/pkey: Add PKEY_UNRESTRICTED macro Date: Mon, 9 Dec 2024 09:47:17 +0000 Message-Id: <20241209094719.2431126-2-yury.khrustalev@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241209094719.2431126-1-yury.khrustalev@arm.com> References: <20241209094719.2431126-1-yury.khrustalev@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8DB3616000E X-Stat-Signature: 6mgcjftgb4ceipd17hpii3xdgo1wo5wk X-Rspam-User: X-HE-Tag: 1733737648-824339 X-HE-Meta: U2FsdGVkX18V6osnP4pKs2wxponkc2YBg2TnwSL1yVsS4gl/PRTDjgyNkRoJ95Rp/k33fDsYLrLSTHYUEsln0/OCPN1EhJZJxj9Uy+DYvPxynGw2v3GtY6DiAcu1JSNp/jspoOGG7vZBswVQPtP/6LVZk7wttMCyEIlGijjKRofelxhQzCJgEK9JMJdm2uSS4oOHTuvwfmIy7JUwnrk1U+dI/dY9PfTzRBNOjFs3hPelFnASBIz5WXRoWmc4yHsDo8KEIpWT9P/+bf+n9IJwoU0UoPI5EdtupRCAr9GfMcHGoCqwvJy6qwSREc8t1mPhHe/sAwo+16mJjkZacuEHPEZ8q1PcBQbw3lh9rUIn2WSnmsjcrxGD9OowF5Pzm4IBviNlCNjdcRI70CVgEIC/OCpmOtGOek38xjDXw2mA5O5H4bPFqJq9/xN4nDMD1Th1STBv+qj6mq/MJJdvj4H6fq4JXx5X5KOmpWB3l7T6s9RJFb6RnRF9vgYmIC5+MYD8Onzygto1D7MLxz5NU1yJq7UlbXMKzKa8q9Rp1njeTvnN0lZB9vHea8KrTmtJFH3YAevTXNbqdln78Ty1Wfbu0cs5akpOR7gXoMlEMD7qoMLiu6RkLnrAejWLIbZuOEra4iUKhGcdLfsG4d8u46VCxOEkrggTJXlrx7tKXGmFMoev1YeniPWW0c6w9Tk2UCdbBpxORp3OOlg7xx9D7hUKdeCg8Lof7GHrdQ+W0I9SqgTTCz8Erx5Dhm+xOJq8SDicK3EnZxuWI683xkSX6ApB8TNGg++AOk2NRRtUdtugtrca6bmecBAZP7iTwamGtIM00NFVywgdehXiIyGWEDNkK6VR+XtJNAAsf/NqlEgyTIbQaGUFYx90z/EdVJwy2RpiVXRbaRodk2jTpcWpE9JKkb8XOlwgLHfQSPOT5GRQQ6U/VmLpozQ7XyS8HtSOVPxxCGlHbri4A069slKmy7h YJ391veR WAYD6hhr7ptqWuKntffcVu1e1lOc7mkPVjrTnlj+rK6eYEX0L+oH1mecmVVb9WL0HbrI2IVJSnzhhS3a6nRqWe/8rE7NgRy+Csd15GNlGRI1ueZn6UYjkhWWfgFkJhwEexUyDQKuLHwLKQkXP6AFmlafjGNs6U+nH6dbonRH2JWV/WeiDiizqfe+I8KWOGbJlaKmIoPlIDiF4nxNDVzVohpYPO4EKo9ty1w5c4B1kQ0GUfhQoH4IRco1B67DwV6kj4POQopsQYrehqozJsn/qRY2y97IU1xv/DyTs8fQ9NYLxYMkAWBlwDw/j2cUXggfy1h7vutA4aj1B+EtKFYS0mdi0xGkhls7BtCNb 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: List-Subscribe: List-Unsubscribe: Memory protection keys (pkeys) uapi has two macros for pkeys restrictions: - PKEY_DISABLE_ACCESS 0x1 - PKEY_DISABLE_WRITE 0x2 with implicit literal value of 0x0 that means "unrestricted". Code that works with pkeys has to use this literal value when implying that a pkey imposes no restrictions. This may reduce readability because 0 can be written in various ways (e.g. 0x0 or 0) and also because 0 in the context of pkeys can be mistaken for "no permissions" (akin PROT_NONE) while it actually means "no restrictions". This is important because pkeys are oftentimes used near mprotect() that uses PROT_ macros. This patch adds PKEY_UNRESTRICTED macro defined as 0x0. Signed-off-by: Yury Khrustalev Acked-by: Dave Hansen --- include/uapi/asm-generic/mman-common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi/asm-generic/mman-common.h index 1ea2c4c33b86..ef1c27fa3c57 100644 --- a/include/uapi/asm-generic/mman-common.h +++ b/include/uapi/asm-generic/mman-common.h @@ -85,6 +85,7 @@ /* compatibility flags */ #define MAP_FILE 0 +#define PKEY_UNRESTRICTED 0x0 #define PKEY_DISABLE_ACCESS 0x1 #define PKEY_DISABLE_WRITE 0x2 #define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\