Skip to content

Commit

Permalink
selftests/powerpc: Use PKEY_UNRESTRICTED macro
Browse files Browse the repository at this point in the history
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>
Link: https://lore.kernel.org/r/20250113170619.484698-4-yury.khrustalev@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
  • Loading branch information
Yury Khrustalev authored and Catalin Marinas committed Feb 17, 2025
1 parent 3809cef commit 00894c3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tools/testing/selftests/powerpc/include/pkeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,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);

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/powerpc/mm/pkey_exec_prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
/*
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/powerpc/mm/pkey_siginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
6 changes: 3 additions & 3 deletions tools/testing/selftests/powerpc/ptrace/core-pkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,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);
Expand Down
6 changes: 3 additions & 3 deletions tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,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);
Expand Down

0 comments on commit 00894c3

Please sign in to comment.