From patchwork Mon Jan 13 17:06:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 13937785 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 627FFC02180 for ; Mon, 13 Jan 2025 17:06:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E67BE6B0088; Mon, 13 Jan 2025 12:06:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E181C6B008A; Mon, 13 Jan 2025 12:06:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB8306B008C; Mon, 13 Jan 2025 12:06:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id ADEA16B0088 for ; Mon, 13 Jan 2025 12:06:41 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5609FC0172 for ; Mon, 13 Jan 2025 17:06:41 +0000 (UTC) X-FDA: 83003057802.26.39354D6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf11.hostedemail.com (Postfix) with ESMTP id 9720C40010 for ; Mon, 13 Jan 2025 17:06:39 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of yury.khrustalev@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=yury.khrustalev@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736787999; a=rsa-sha256; cv=none; b=7LrzxVvWycpyaIVul/3aC+pQFJWA1zzYmMhYld+jNOHXjkRN1jJQ43whLErP1cL4FgDHbB pq5NT3Iz0ZebcdDOVYjm6z/15VBprYiDwnGM1WOkpQ84puJSKV5ZSOx8I5+tRqlmLtpunL 1IUXCIX4w6uAlTUhlc8WKIz3xOrz/nc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of yury.khrustalev@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=yury.khrustalev@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736787999; 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=SC7ft5gShDoCJU28uqIQOmcUNl5kD3v28k/jPUtva8mWmo5vwMnK9D2FVk0zV1RhwD//x5 1ocjYhXCuUubXTdjkOd+SGI91aFSzaYUacPRRTWS+eXrqwyUObnKXWJia0v6h49heDB8R8 Cxjs8TSiJ9fQZ7tmDlS/YknLFHdK7v8= 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 01E3C1424; Mon, 13 Jan 2025 09:07:07 -0800 (PST) Received: from udebian.localdomain (unknown [10.1.25.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EFD0E3F673; Mon, 13 Jan 2025 09:06:35 -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, Andrew Morton , nd@arm.com, Yury Khrustalev Subject: [RESEND v4 1/3] mm/pkey: Add PKEY_UNRESTRICTED macro Date: Mon, 13 Jan 2025 17:06:17 +0000 Message-Id: <20250113170619.484698-2-yury.khrustalev@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250113170619.484698-1-yury.khrustalev@arm.com> References: <20250113170619.484698-1-yury.khrustalev@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9720C40010 X-Stat-Signature: fnpbyyfhjf8f5g13r46fbfuxkx4uzydq X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736787999-764915 X-HE-Meta: U2FsdGVkX197FiwGfvlqXYa12ni+56eu8/TsCC3mgVnUHqRmjRgXT5TUQe9jLbM48yrAfWyqtVqGXWAoFH0bvP6CO5q96dxFdR3gnH/16HWjxs7I41VG3GPjbLKlvMOPGEhdTur+zAf/wVDalZWYi79eK+6ZIopFa5xUfl1OW8qNSNJmu/p3UCCi/oh3iZrxIWccZzU1s+ibMHfPBS9SBL6fxaVzsid/RtG/SQTnntOjv4E/Fy4cHWqfsZmVB4hE837w0FWDUpzYbO9nEUFiw14VTQ1E0GF//8v8avB8utzyxT7HP2fawe2A6K3Jx5a2pV0PcYQPgh4QKKKdnGVBSB2Dj0gUHuXu8CYr0AIdp1hXV7HZmkB6GQ1Dy9vWfbL4EA6Gf9KV/78uFzvc+Xs+zHCykQlHyNfleuEMkXaCWDw5SEUV3aitJYdeG+V4Y5qCJL8XYGvsrgVjigZTIcvIQcxZqYus19+0p5kUNd7TtXNV++P3kZglkbPVzWHZ2UVUZkoK0J/jYFIVyXKHNa27eeVyCxgRYCDGteQ0q/4hV+PG731AcSncPIiKFULY2EghMq3xEYNbwGd5ifB97L2lntCAPcE0uVGYl3C91vmfb65deXVL5/vJ6uwJG17IWKvLFtKkBKEg+Z1Kc/lIeBgWAg/KdW+q1T7VQljAVTe+zZD/6w4jW0sDycBuUDlu/YCIb+U+6bIUXUZBbMETL8q5NDW2H8w2lm7pUURJI0f2RVP/z8u1hedOztKSuGN7bnMkHtzaPivjUtwzwY5xwNI8En20HF5bI58kSu9UOFf4fzXzxLsRrtl5v5j/Hr4932q7cRfNeplsmJT3nFEl5vIWsNhUrsJwNnjXg2xFQoPT10AO+U8HZ8mgESBtAkey23c91dZ8ixntHX++7yMqe2WGH64rGo5ULDq876XYsoq4p9TxDgcNNuY3qPkbBLJAKMSWmY1FqZ7sk9po15rJFX+ gU92nPx0 xGsm5pt/erqTbQ2YMy1Vhj1Ak6IcGfatrWVyjAdSZ2mEjMLG7p0FF4rTTmovXwn0S2BYesXgM6inn/d0ewDKzjNfxfVP9GrT/JVPnJH9szTkYFZEmkbZ02TNH260kFi27HkdSW5NVxIXbxl3cY69RvXvz84IGa8saiHxqfrkD5u3NQEWqR7cU+5REJ1//Gz6mJXMLwjyBmGQp2td/27i/W0bVBcVYta9yxjLS 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 |\