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 |\ From patchwork Mon Jan 13 17:06:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 13937786 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 4FF9DC02180 for ; Mon, 13 Jan 2025 17:06:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF2566B008A; Mon, 13 Jan 2025 12:06:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA30A6B008C; Mon, 13 Jan 2025 12:06:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C91A36B0092; Mon, 13 Jan 2025 12:06:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AD01B6B008A for ; Mon, 13 Jan 2025 12:06:51 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 33F8216011C for ; Mon, 13 Jan 2025 17:06:51 +0000 (UTC) X-FDA: 83003058222.14.6DD0F64 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf19.hostedemail.com (Postfix) with ESMTP id 72F1A1A0006 for ; Mon, 13 Jan 2025 17:06:49 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf19.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=1736788009; 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=+b1vwyUt9X+x+fq4vNsQWkXSJqfTlOBMiVr4yBA8vrE=; b=xKX361fkcV6KpIczROKoS+esdtekJuD5kWX0t1vVn7yjt/9MiJ0KbLVs5LFpTQV0AeUNAf GAWTglJBfV0G7bH5OaSRa6csHvXOhfqaNDoZv+yvzKp9Tt1/5aPqr3ArHqWi1UBeRulZ1B n3AktjFU38nWJhNMAqV4eBxzMPGWwgA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf19.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=1736788009; a=rsa-sha256; cv=none; b=2rU/q9GXBygpaVlCMLSoPME+LL0CU8HPwEjnteZPUSqm6n+1NWbyGnoFCbpW1joSA8tin0 OSbwC8/ntChLOpv0hiEHGXzEST/+BQGVaXa7OH5Y7jDP/AMQEJX0UKdls2vZqDG+wkhUjI bX+7/KEvSR+iJjksxeYjF+HTHzuCgsk= 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 EA6671A25; Mon, 13 Jan 2025 09:07:16 -0800 (PST) Received: from udebian.localdomain (unknown [10.1.25.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5D4483F673; Mon, 13 Jan 2025 09:06:46 -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 2/3] selftests/mm: Use PKEY_UNRESTRICTED macro Date: Mon, 13 Jan 2025 17:06:18 +0000 Message-Id: <20250113170619.484698-3-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: 72F1A1A0006 X-Rspamd-Server: rspam12 X-Stat-Signature: xs9jeubhar3phfrrcsbyxd7f7gaq6141 X-Rspam-User: X-HE-Tag: 1736788009-727958 X-HE-Meta: U2FsdGVkX19NBoGAhDNCef724nwjc/wzCnjxmXEffuVfwtaVSzbODIlpG+cz/pzrIzjw6Z7lT0uJ5H+FJJU7JbVuqzy1jqEIH4QmH4SQJA2Bl1m0qo94KDB8h4GokpNe21WXnLR8TkvoWa7oqcOhnYqpxosxmHWqOw65XYSxo5FVPEe1KpirLOoQTB4IqbaWkQh2RMgrP+XMnmiVT885eeOXrUVXxYmGfBwYd4QKkDmBYollpzZ+E/ABkCJVCjrqoNcxVU1fl4GM3IBrb00lVq7n2Pkj50kFhaDvIxqHo0+rBjDHoTkJsdYXpPsBwSeIZkEfRS6w7Ffr3TC7+K3Zzz05Ebq7m5H5CGuyvi5d6+x1QWD8o9jrYkRrPlsZtl3VLRLj3NhNDaKDi7r+k0V5jjdoUSgpcKilmI91PJW3rvZaE8sPieTIQmGMSs59AGZGbME2g1H3S70rD6dTqecMMMwpEcOVrFvyFlXG/Ie7izY6kykcMlxDir4eRz9jcb8qocw/nIiuy9Z+pxLHRXK43bFeVcb0bpmUt/4MgZYA8AQK8Qxec2JaYZPua+bMnHPkAaO8TA/cvyzA3Ipdw/x65PD0NRYDZrO7wQKPAIjLNaN+oVGqtv5ccaC95hxQ5+hwSuH85Z3seTqw3wbYAhuAaNRjVAjxNHhBeLAbAhfTRAJcMBFDhCKRpWTykPz3VVgT+oGhuHluf8KhQwDLfqjDPL8DNpFjRL6tckxXFfmBZydYZgCw6W2tlt41X/cCv905e+yyxPdrbvQkYMpUz3hdTd4Yt+Xw/DHH5p2V2d33hnCCvEkDytD//6q4zyVwYz3iXLqFLxErD5wBKxguK4v31CIT7WVYklZpQujxCouDcInAcFW7S5g96zUnQaSPIYxwNY0toMCj6OcwDYubb14Im6C4XZ3+SWM4YOggaF5FjjRCdFoJH+HlAi9GL1VyqZtTvyNYwC6pmy3oAf2EMGA sg4R+gD5 aWmOPollYG7IxPmqcgcOfYBjqA+oF8cawcR4oRnYT797V1Y1tzyGb6aQuKFueba5cNxuQnbbhJTM+tDepxIdvlYrjDsRJBqklr7u5aWgLlmJ9FKzvQFdFgnt/tjxxkGwy6eBmRiBx2YZY6fTXAC4Sc/OD6nESFwLU5cl4uENIT0uGyEftvL5B48wdFqswvvJ4Xi+qD/EHukiT+1ztlAt4mfGHfI85wPnw4eLR 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: Replace literal 0 with macro PKEY_UNRESTRICTED where pkey_*() functions are used in mm selftests for memory protection keys. Signed-off-by: Yury Khrustalev Suggested-by: Joey Gouly Acked-by: Dave Hansen --- tools/testing/selftests/mm/mseal_test.c | 6 +++--- tools/testing/selftests/mm/pkey-helpers.h | 3 ++- tools/testing/selftests/mm/pkey_sighandler_tests.c | 4 ++-- tools/testing/selftests/mm/protection_keys.c | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c index 01675c412b2a..30ea37e8ecf8 100644 --- a/tools/testing/selftests/mm/mseal_test.c +++ b/tools/testing/selftests/mm/mseal_test.c @@ -218,7 +218,7 @@ bool seal_support(void) bool pkey_supported(void) { #if defined(__i386__) || defined(__x86_64__) /* arch */ - int pkey = sys_pkey_alloc(0, 0); + int pkey = sys_pkey_alloc(0, PKEY_UNRESTRICTED); if (pkey > 0) return true; @@ -1671,7 +1671,7 @@ static void test_seal_discard_ro_anon_on_pkey(bool seal) setup_single_address_rw(size, &ptr); FAIL_TEST_IF_FALSE(ptr != (void *)-1); - pkey = sys_pkey_alloc(0, 0); + pkey = sys_pkey_alloc(0, PKEY_UNRESTRICTED); FAIL_TEST_IF_FALSE(pkey > 0); ret = sys_mprotect_pkey((void *)ptr, size, PROT_READ | PROT_WRITE, pkey); @@ -1683,7 +1683,7 @@ static void test_seal_discard_ro_anon_on_pkey(bool seal) } /* sealing doesn't take effect if PKRU allow write. */ - set_pkey(pkey, 0); + set_pkey(pkey, PKEY_UNRESTRICTED); ret = sys_madvise(ptr, size, MADV_DONTNEED); FAIL_TEST_IF_FALSE(!ret); diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h index f7cfe163b0ff..10fa3ca9b05b 100644 --- a/tools/testing/selftests/mm/pkey-helpers.h +++ b/tools/testing/selftests/mm/pkey-helpers.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "../kselftest.h" @@ -224,7 +225,7 @@ static inline u32 *siginfo_get_pkey_ptr(siginfo_t *si) static inline int kernel_has_pkeys(void) { /* try allocating a key and see if it succeeds */ - int ret = sys_pkey_alloc(0, 0); + int ret = sys_pkey_alloc(0, PKEY_UNRESTRICTED); if (ret <= 0) { return 0; } diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c index c593a426341c..2015ed7e0928 100644 --- a/tools/testing/selftests/mm/pkey_sighandler_tests.c +++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c @@ -314,7 +314,7 @@ static void test_sigsegv_handler_with_different_pkey_for_stack(void) __write_pkey_reg(pkey_reg); /* Protect the new stack with MPK 1 */ - pkey = pkey_alloc(0, 0); + pkey = pkey_alloc(0, PKEY_UNRESTRICTED); pkey_mprotect(stack, STACK_SIZE, PROT_READ | PROT_WRITE, pkey); /* Set up alternate signal stack that will use the default MPK */ @@ -487,7 +487,7 @@ static void test_pkru_sigreturn(void) __write_pkey_reg(pkey_reg); /* Protect the stack with MPK 2 */ - pkey = pkey_alloc(0, 0); + pkey = pkey_alloc(0, PKEY_UNRESTRICTED); pkey_mprotect(stack, STACK_SIZE, PROT_READ | PROT_WRITE, pkey); /* Set up alternate signal stack that will use the default MPK */ diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c index 4990f7ab4cb7..cca7435a7bc5 100644 --- a/tools/testing/selftests/mm/protection_keys.c +++ b/tools/testing/selftests/mm/protection_keys.c @@ -491,7 +491,7 @@ int sys_pkey_alloc(unsigned long flags, unsigned long init_val) int alloc_pkey(void) { int ret; - unsigned long init_val = 0x0; + unsigned long init_val = PKEY_UNRESTRICTED; dprintf1("%s()::%d, pkey_reg: 0x%016llx shadow: %016llx\n", __func__, __LINE__, __read_pkey_reg(), shadow_pkey_reg); From patchwork Mon Jan 13 17:06:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 13937787 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 34F76C02183 for ; Mon, 13 Jan 2025 17:07:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C44E86B008C; Mon, 13 Jan 2025 12:07:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF5316B0092; Mon, 13 Jan 2025 12:07:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE40E6B0095; Mon, 13 Jan 2025 12:07:00 -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 9448E6B008C for ; Mon, 13 Jan 2025 12:07:00 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 51A68A01B8 for ; Mon, 13 Jan 2025 17:07:00 +0000 (UTC) X-FDA: 83003058600.27.1041109 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf11.hostedemail.com (Postfix) with ESMTP id A7FA44000D for ; Mon, 13 Jan 2025 17:06:58 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736788018; a=rsa-sha256; cv=none; b=rdFhH/6h+kUFiVcv6XGympEcrJ54sPfy3ac/E18CvOYopD3dfhq9QaVbAN/aFxPjLi1ACa sBz8ISiif+0hsIFS/ymtJ9rixeXjhwwrD44ivyZjb8Xw3VUd/7OMcyIRNtm70ngBw888S4 fPnjil6oyXXJhgtVt2T/HujR2Eo9sx4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736788018; 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=NoSyfg0H2xdXV8bVJGF6NwXUo5Fiq0F8nFCklb+ts3Y=; b=jOpikeoJbDPn9uRRivJhLliu9Aj11/sFXj/NrAuhSc6OnQpcMYwbdBMEySnorocDl96iD1 +b2glzVKYvDB9gHUBLrsv9GqAiSX/R4bQcNDWAy5r5MfV2tml27rTUxMaE+5ZfILBkSPr7 ejgAB5aIEzzEn6aFDdhMk+Jr9XosEgM= 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 4A2391BB0; Mon, 13 Jan 2025 09:07:26 -0800 (PST) Received: from udebian.localdomain (unknown [10.1.25.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B00D83F673; Mon, 13 Jan 2025 09:06:55 -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 3/3] selftests/powerpc: Use PKEY_UNRESTRICTED macro Date: Mon, 13 Jan 2025 17:06:19 +0000 Message-Id: <20250113170619.484698-4-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-Server: rspam04 X-Rspamd-Queue-Id: A7FA44000D X-Stat-Signature: dz1344sku4fhh9yk69ymzmog7rs3fbg3 X-Rspam-User: X-HE-Tag: 1736788018-231906 X-HE-Meta: U2FsdGVkX1/S7S+Md7zINfxuR2luaaX5goGwX0ZtFgJXg6va+qUmk5E8mnStgmVJAfI8dMMcodOElD18gxpNRT5AZ/RtyCpi9G/o5/pXQ0M6FtBQ923MkRkJt4x31l5Q0RSKAApZhf+ClDGu8n24JdAb9lTTv8CT40sUuzMcPoytDYZRxYk1fXeCOLU1id1a30/CVFs5tAbAJrPlxepN2Ynqojb2+LAYOxXwppPAqKzEcn+ixwtFvnz5lBwvFw5uwPQf6UDHtzd9RstB073t2Ww9zaVBQTPxOZjuHa7Luy4+vC/4dhRBy5h3ehdboDke5UuQSahQ/slXGXuJzs6UcI30mDxAk8DWMvxqvvteSJ4FBhkGqwhL/ya8MQW1RZfoYj1311p12MJllvTqVUOlJUDWDYrNU5rAqqWCgyxvtggZxLnuRbBpiK/SVq3ADiR0inX3Or8ERaS+z92VoA8DnExefO6MC5Ms5Ro04r38/97V/vZbue8MIqLmysKOUDmDoHJ02FglOsxYzjbuaY7KPltPZaz+Q7mI4rzygxbs4VUuEiNXj6NRVbJOp7l3wTE2kA2ijvjvnGf334+kBqUsPtY1hNyt+c7FFvZgtyeRAzaYkHLZ3Anoy8DuGrw2kM2tAJvwo043/FhyUT2ASd9Jytd34i52n1FcADKyiHhTm8KXxCvOpeo55rmBHC+phbdLCqfPePYWBUkJ8/JG40aZ9Yv4ei/H9f3Q39cF1zDZmBq8xOrx7p4FglcrkSMrXUPXi65pWrFwn/5a/f3TZRsadGPqHGSfFfvaccLx7A3+K+ROAsKy3kDCKJqBpXrlG+n4Gm29L4D5T5bAgjYUR6HqAIlTLbxvU6ksyx2AXT4X+DX0om/H26t2XTdJPKC/nXWSV2sz5TR9PWtVZcSFvwip5PpWIvQm0Kbjg7hN7gxIkP3JH9C6W8wP3Kaa9aMLG81e2kT2JRL0/q35iY78xZj esxMzEl5 PabaUoPM8xK4xLoIqnOwbriTUtqCGQYX61bCl72XBPu7bYM893eyf+KiQ74zY9SoFDwig3+IrBDRQdny96851bdagCy3aW5ClCJgdUD5Dt51k9Q1MAmTM1j1eNbkgr7cT7cn59FRfOcmNtvpIrbHUTVdCgwPYT8ahJ2is08vzuhyZeIwkjAvMPe/7G6tqcb2AmZcTepXFK9DRsIc= 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: Replace literal 0 with macro PKEY_UNRESTRICTED where pkey_*() functions are used in mm selftests for memory protection keys for ppc target. Signed-off-by: Yury Khrustalev Suggested-by: Kevin Brodsky Reviewed-by: Kevin Brodsky --- Note that I couldn't build these tests so I would appreciate if someone could check this patch. Thank you! --- tools/testing/selftests/powerpc/include/pkeys.h | 2 +- tools/testing/selftests/powerpc/mm/pkey_exec_prot.c | 2 +- tools/testing/selftests/powerpc/mm/pkey_siginfo.c | 2 +- tools/testing/selftests/powerpc/ptrace/core-pkey.c | 6 +++--- tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/powerpc/include/pkeys.h b/tools/testing/selftests/powerpc/include/pkeys.h index 51729d9a7111..430cb4bd7472 100644 --- a/tools/testing/selftests/powerpc/include/pkeys.h +++ b/tools/testing/selftests/powerpc/include/pkeys.h @@ -85,7 +85,7 @@ int pkeys_unsupported(void) SKIP_IF(!hash_mmu); /* Check if the system call is supported */ - pkey = sys_pkey_alloc(0, 0); + pkey = sys_pkey_alloc(0, PKEY_UNRESTRICTED); SKIP_IF(pkey < 0); sys_pkey_free(pkey); diff --git a/tools/testing/selftests/powerpc/mm/pkey_exec_prot.c b/tools/testing/selftests/powerpc/mm/pkey_exec_prot.c index 0af4f02669a1..29b91b7456eb 100644 --- a/tools/testing/selftests/powerpc/mm/pkey_exec_prot.c +++ b/tools/testing/selftests/powerpc/mm/pkey_exec_prot.c @@ -72,7 +72,7 @@ static void segv_handler(int signum, siginfo_t *sinfo, void *ctx) switch (fault_type) { case PKEY_DISABLE_ACCESS: - pkey_set_rights(fault_pkey, 0); + pkey_set_rights(fault_pkey, PKEY_UNRESTRICTED); break; case PKEY_DISABLE_EXECUTE: /* diff --git a/tools/testing/selftests/powerpc/mm/pkey_siginfo.c b/tools/testing/selftests/powerpc/mm/pkey_siginfo.c index 2db76e56d4cb..e89a164c686b 100644 --- a/tools/testing/selftests/powerpc/mm/pkey_siginfo.c +++ b/tools/testing/selftests/powerpc/mm/pkey_siginfo.c @@ -83,7 +83,7 @@ static void segv_handler(int signum, siginfo_t *sinfo, void *ctx) mprotect(pgstart, pgsize, PROT_EXEC)) _exit(1); else - pkey_set_rights(pkey, 0); + pkey_set_rights(pkey, PKEY_UNRESTRICTED); fault_count++; } diff --git a/tools/testing/selftests/powerpc/ptrace/core-pkey.c b/tools/testing/selftests/powerpc/ptrace/core-pkey.c index f6da4cb30cd6..64c985445cb7 100644 --- a/tools/testing/selftests/powerpc/ptrace/core-pkey.c +++ b/tools/testing/selftests/powerpc/ptrace/core-pkey.c @@ -124,16 +124,16 @@ static int child(struct shared_info *info) /* Get some pkeys so that we can change their bits in the AMR. */ pkey1 = sys_pkey_alloc(0, PKEY_DISABLE_EXECUTE); if (pkey1 < 0) { - pkey1 = sys_pkey_alloc(0, 0); + pkey1 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); FAIL_IF(pkey1 < 0); disable_execute = false; } - pkey2 = sys_pkey_alloc(0, 0); + pkey2 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); FAIL_IF(pkey2 < 0); - pkey3 = sys_pkey_alloc(0, 0); + pkey3 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); FAIL_IF(pkey3 < 0); info->amr |= 3ul << pkeyshift(pkey1) | 2ul << pkeyshift(pkey2); diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c index d89474377f11..37794f82ed66 100644 --- a/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c +++ b/tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c @@ -81,16 +81,16 @@ static int child(struct shared_info *info) /* Get some pkeys so that we can change their bits in the AMR. */ pkey1 = sys_pkey_alloc(0, PKEY_DISABLE_EXECUTE); if (pkey1 < 0) { - pkey1 = sys_pkey_alloc(0, 0); + pkey1 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); CHILD_FAIL_IF(pkey1 < 0, &info->child_sync); disable_execute = false; } - pkey2 = sys_pkey_alloc(0, 0); + pkey2 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); CHILD_FAIL_IF(pkey2 < 0, &info->child_sync); - pkey3 = sys_pkey_alloc(0, 0); + pkey3 = sys_pkey_alloc(0, PKEY_UNRESTRICTED); CHILD_FAIL_IF(pkey3 < 0, &info->child_sync); info->amr1 |= 3ul << pkeyshift(pkey1);