linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RESEND v4 0/3] mm/pkey: Add PKEY_UNRESTRICTED macro
@ 2025-01-13 17:06 Yury Khrustalev
  2025-01-13 17:06 ` [RESEND v4 1/3] " Yury Khrustalev
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Yury Khrustalev @ 2025-01-13 17:06 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, Kevin Brodsky, Joey Gouly, Dave Hansen,
	Sandipan Das, Michael Ellerman, Catalin Marinas, linuxppc-dev,
	linux-arm-kernel, x86, linux-mm, linux-kselftest, Andrew Morton,
	nd, Yury Khrustalev

Add PKEY_UNRESTRICTED macro to mman.h and use it in selftests.

For context, this change will also allow for more consistent update of the
Glibc manual which in turn will help with introducing memory protection
keys on AArch64 targets.

Applies to 5bc55a333a2f (tag: v6.13-rc7).

Note that I couldn't build ppc tests so I would appreciate if someone
could check the 3rd patch. Thank you!

Signed-off-by: Yury Khrustalev <yury.khrustalev@arm.com>

---
Changes in v4:
 - Removed change to tools/include/uapi/asm-generic/mman-common.h as it is not
   necessary.

Link to v3: https://lore.kernel.org/all/20241028090715.509527-1-yury.khrustalev@arm.com/

Changes in v3:
 - Replaced previously missed 0-s tools/testing/selftests/mm/mseal_test.c
 - Replaced previously missed 0-s in tools/testing/selftests/mm/mseal_test.c

Link to v2: https://lore.kernel.org/linux-arch/20241027170006.464252-2-yury.khrustalev@arm.com/

Changes in v2:
 - Update tools/include/uapi/asm-generic/mman-common.h as well
 - Add usages of the new macro to selftests.

Link to v1: https://lore.kernel.org/linux-arch/20241022120128.359652-1-yury.khrustalev@arm.com/

---

Yury Khrustalev (3):
  mm/pkey: Add PKEY_UNRESTRICTED macro
  selftests/mm: Use PKEY_UNRESTRICTED macro
  selftests/powerpc: Use PKEY_UNRESTRICTED macro

 include/uapi/asm-generic/mman-common.h               | 1 +
 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 +-
 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 +++---
 10 files changed, 18 insertions(+), 16 deletions(-)

-- 
2.39.5



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RESEND v4 1/3] mm/pkey: Add PKEY_UNRESTRICTED macro
  2025-01-13 17:06 [RESEND v4 0/3] mm/pkey: Add PKEY_UNRESTRICTED macro Yury Khrustalev
@ 2025-01-13 17:06 ` Yury Khrustalev
  2025-01-13 17:06 ` [RESEND v4 2/3] selftests/mm: Use " Yury Khrustalev
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Yury Khrustalev @ 2025-01-13 17:06 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, Kevin Brodsky, Joey Gouly, Dave Hansen,
	Sandipan Das, Michael Ellerman, Catalin Marinas, linuxppc-dev,
	linux-arm-kernel, x86, linux-mm, linux-kselftest, Andrew Morton,
	nd, Yury Khrustalev

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 <yury.khrustalev@arm.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
---
 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 |\
-- 
2.39.5



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RESEND v4 2/3] selftests/mm: Use PKEY_UNRESTRICTED macro
  2025-01-13 17:06 [RESEND v4 0/3] mm/pkey: Add PKEY_UNRESTRICTED macro Yury Khrustalev
  2025-01-13 17:06 ` [RESEND v4 1/3] " Yury Khrustalev
@ 2025-01-13 17:06 ` Yury Khrustalev
  2025-01-13 17:06 ` [RESEND v4 3/3] selftests/powerpc: " Yury Khrustalev
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Yury Khrustalev @ 2025-01-13 17:06 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, Kevin Brodsky, Joey Gouly, Dave Hansen,
	Sandipan Das, Michael Ellerman, Catalin Marinas, linuxppc-dev,
	linux-arm-kernel, x86, linux-mm, linux-kselftest, Andrew Morton,
	nd, Yury Khrustalev

Replace literal 0 with macro PKEY_UNRESTRICTED where pkey_*() functions
are used in mm selftests for memory protection keys.

Signed-off-by: Yury Khrustalev <yury.khrustalev@arm.com>
Suggested-by: Joey Gouly <joey.gouly@arm.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
---
 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 <stdlib.h>
 #include <ucontext.h>
 #include <sys/mman.h>
+#include <linux/mman.h>
 
 #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);
-- 
2.39.5



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RESEND v4 3/3] selftests/powerpc: Use PKEY_UNRESTRICTED macro
  2025-01-13 17:06 [RESEND v4 0/3] mm/pkey: Add PKEY_UNRESTRICTED macro Yury Khrustalev
  2025-01-13 17:06 ` [RESEND v4 1/3] " Yury Khrustalev
  2025-01-13 17:06 ` [RESEND v4 2/3] selftests/mm: Use " Yury Khrustalev
@ 2025-01-13 17:06 ` Yury Khrustalev
  2025-02-12 17:24 ` [RESEND v4 0/3] mm/pkey: Add " Catalin Marinas
  2025-02-17 21:33 ` Catalin Marinas
  4 siblings, 0 replies; 9+ messages in thread
From: Yury Khrustalev @ 2025-01-13 17:06 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, Kevin Brodsky, Joey Gouly, Dave Hansen,
	Sandipan Das, Michael Ellerman, Catalin Marinas, linuxppc-dev,
	linux-arm-kernel, x86, linux-mm, linux-kselftest, Andrew Morton,
	nd, Yury Khrustalev

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 <yury.khrustalev@arm.com>
Suggested-by: Kevin Brodsky <kevin.brodsky@arm.com>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>

---
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);
-- 
2.39.5



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RESEND v4 0/3] mm/pkey: Add PKEY_UNRESTRICTED macro
  2025-01-13 17:06 [RESEND v4 0/3] mm/pkey: Add PKEY_UNRESTRICTED macro Yury Khrustalev
                   ` (2 preceding siblings ...)
  2025-01-13 17:06 ` [RESEND v4 3/3] selftests/powerpc: " Yury Khrustalev
@ 2025-02-12 17:24 ` Catalin Marinas
  2025-02-12 21:29   ` Andrew Morton
  2025-02-17 21:33 ` Catalin Marinas
  4 siblings, 1 reply; 9+ messages in thread
From: Catalin Marinas @ 2025-02-12 17:24 UTC (permalink / raw)
  To: Yury Khrustalev, Andrew Morton, Arnd Bergmann
  Cc: linux-arch, Kevin Brodsky, Joey Gouly, Dave Hansen, Sandipan Das,
	Michael Ellerman, linuxppc-dev, linux-arm-kernel, x86, linux-mm,
	linux-kselftest, nd

On Mon, Jan 13, 2025 at 05:06:16PM +0000, Yury Khrustalev wrote:
> Add PKEY_UNRESTRICTED macro to mman.h and use it in selftests.
> 
> For context, this change will also allow for more consistent update of the
> Glibc manual which in turn will help with introducing memory protection
> keys on AArch64 targets.
[...]
> Yury Khrustalev (3):
>   mm/pkey: Add PKEY_UNRESTRICTED macro
>   selftests/mm: Use PKEY_UNRESTRICTED macro
>   selftests/powerpc: Use PKEY_UNRESTRICTED macro
> 
>  include/uapi/asm-generic/mman-common.h               | 1 +
>  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 +-
>  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 +++---
>  10 files changed, 18 insertions(+), 16 deletions(-)

Andrew, Arnd - are you ok if I take these patches through the arm64
tree?

Thanks.

-- 
Catalin


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RESEND v4 0/3] mm/pkey: Add PKEY_UNRESTRICTED macro
  2025-02-12 17:24 ` [RESEND v4 0/3] mm/pkey: Add " Catalin Marinas
@ 2025-02-12 21:29   ` Andrew Morton
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2025-02-12 21:29 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Yury Khrustalev, Arnd Bergmann, linux-arch, Kevin Brodsky,
	Joey Gouly, Dave Hansen, Sandipan Das, Michael Ellerman,
	linuxppc-dev, linux-arm-kernel, x86, linux-mm, linux-kselftest,
	nd

On Wed, 12 Feb 2025 17:24:58 +0000 Catalin Marinas <catalin.marinas@arm.com> wrote:

> On Mon, Jan 13, 2025 at 05:06:16PM +0000, Yury Khrustalev wrote:
> > Add PKEY_UNRESTRICTED macro to mman.h and use it in selftests.
> > 
> > For context, this change will also allow for more consistent update of the
> > Glibc manual which in turn will help with introducing memory protection
> > keys on AArch64 targets.
> [...]
> > Yury Khrustalev (3):
> >   mm/pkey: Add PKEY_UNRESTRICTED macro
> >   selftests/mm: Use PKEY_UNRESTRICTED macro
> >   selftests/powerpc: Use PKEY_UNRESTRICTED macro
> > 
> >  include/uapi/asm-generic/mman-common.h               | 1 +
> >  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 +-
> >  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 +++---
> >  10 files changed, 18 insertions(+), 16 deletions(-)
> 
> Andrew, Arnd - are you ok if I take these patches through the arm64
> tree?

Sure.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RESEND v4 0/3] mm/pkey: Add PKEY_UNRESTRICTED macro
  2025-01-13 17:06 [RESEND v4 0/3] mm/pkey: Add PKEY_UNRESTRICTED macro Yury Khrustalev
                   ` (3 preceding siblings ...)
  2025-02-12 17:24 ` [RESEND v4 0/3] mm/pkey: Add " Catalin Marinas
@ 2025-02-17 21:33 ` Catalin Marinas
  2025-02-18  9:56   ` Yury Khrustalev
  4 siblings, 1 reply; 9+ messages in thread
From: Catalin Marinas @ 2025-02-17 21:33 UTC (permalink / raw)
  To: linux-arch, Yury Khrustalev
  Cc: Will Deacon, Arnd Bergmann, Kevin Brodsky, Joey Gouly,
	Dave Hansen, Sandipan Das, Michael Ellerman, linuxppc-dev,
	linux-arm-kernel, x86, linux-mm, linux-kselftest, Andrew Morton,
	nd

On Mon, 13 Jan 2025 17:06:16 +0000, Yury Khrustalev wrote:
> Add PKEY_UNRESTRICTED macro to mman.h and use it in selftests.
> 
> For context, this change will also allow for more consistent update of the
> Glibc manual which in turn will help with introducing memory protection
> keys on AArch64 targets.
> 
> Applies to 5bc55a333a2f (tag: v6.13-rc7).
> 
> [...]

Applied to arm64 (for-next/pkey_unrestricted), thanks!

[1/3] mm/pkey: Add PKEY_UNRESTRICTED macro
      https://git.kernel.org/arm64/c/6d61527d931b
[2/3] selftests/mm: Use PKEY_UNRESTRICTED macro
      https://git.kernel.org/arm64/c/3809cefe93f6
[3/3] selftests/powerpc: Use PKEY_UNRESTRICTED macro
      https://git.kernel.org/arm64/c/00894c3fc917

-- 
Catalin



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RESEND v4 0/3] mm/pkey: Add PKEY_UNRESTRICTED macro
  2025-02-17 21:33 ` Catalin Marinas
@ 2025-02-18  9:56   ` Yury Khrustalev
  0 siblings, 0 replies; 9+ messages in thread
From: Yury Khrustalev @ 2025-02-18  9:56 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: linux-arch, Will Deacon, Arnd Bergmann, Kevin Brodsky,
	Joey Gouly, Dave Hansen, Sandipan Das, Michael Ellerman,
	linuxppc-dev, linux-arm-kernel, x86, linux-mm, linux-kselftest,
	Andrew Morton, nd

On Mon, Feb 17, 2025 at 09:33:10PM +0000, Catalin Marinas wrote:
> On Mon, 13 Jan 2025 17:06:16 +0000, Yury Khrustalev wrote:
> > Add PKEY_UNRESTRICTED macro to mman.h and use it in selftests.
> > 
> > For context, this change will also allow for more consistent update of the
> > Glibc manual which in turn will help with introducing memory protection
> > keys on AArch64 targets.
> > 
> > Applies to 5bc55a333a2f (tag: v6.13-rc7).
> > 
> > [...]
> 
> Applied to arm64 (for-next/pkey_unrestricted), thanks!

Thank you!

Kind regards,
Yury

> 
> [1/3] mm/pkey: Add PKEY_UNRESTRICTED macro
>       https://git.kernel.org/arm64/c/6d61527d931b
> [2/3] selftests/mm: Use PKEY_UNRESTRICTED macro
>       https://git.kernel.org/arm64/c/3809cefe93f6
> [3/3] selftests/powerpc: Use PKEY_UNRESTRICTED macro
>       https://git.kernel.org/arm64/c/00894c3fc917
> 
> -- 
> Catalin
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RESEND v4 3/3] selftests/powerpc: Use PKEY_UNRESTRICTED macro
  2024-12-09  9:47 Yury Khrustalev
@ 2024-12-09  9:47 ` Yury Khrustalev
  0 siblings, 0 replies; 9+ messages in thread
From: Yury Khrustalev @ 2024-12-09  9:47 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, Kevin Brodsky, Joey Gouly, Dave Hansen,
	Sandipan Das, Michael Ellerman, Catalin Marinas, linuxppc-dev,
	linux-arm-kernel, x86, linux-mm, linux-kselftest, nd,
	Yury Khrustalev

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 <yury.khrustalev@arm.com>
Suggested-by: Kevin Brodsky <kevin.brodsky@arm.com>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>

---
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);
-- 
2.39.5



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-02-18  9:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-13 17:06 [RESEND v4 0/3] mm/pkey: Add PKEY_UNRESTRICTED macro Yury Khrustalev
2025-01-13 17:06 ` [RESEND v4 1/3] " Yury Khrustalev
2025-01-13 17:06 ` [RESEND v4 2/3] selftests/mm: Use " Yury Khrustalev
2025-01-13 17:06 ` [RESEND v4 3/3] selftests/powerpc: " Yury Khrustalev
2025-02-12 17:24 ` [RESEND v4 0/3] mm/pkey: Add " Catalin Marinas
2025-02-12 21:29   ` Andrew Morton
2025-02-17 21:33 ` Catalin Marinas
2025-02-18  9:56   ` Yury Khrustalev
  -- strict thread matches above, loose matches on Subject: below --
2024-12-09  9:47 Yury Khrustalev
2024-12-09  9:47 ` [RESEND v4 3/3] selftests/powerpc: Use " Yury Khrustalev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox