]> git.ipfire.org Git - thirdparty/linux.git/commit
selftests/mm: Use generic pkey register manipulation
authorKevin Brodsky <kevin.brodsky@arm.com>
Tue, 29 Oct 2024 14:45:38 +0000 (14:45 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Mon, 4 Nov 2024 16:31:25 +0000 (16:31 +0000)
commit6e182dc9f2680681ffb0b6d9757927f1bd321b38
tree100e788b505662bf02e6eda8bcc3f50a2baba3dc
parent8edbbfcc1ed3ca2170a2c5e888a76ba3652e62c9
selftests/mm: Use generic pkey register manipulation

pkey_sighandler_tests.c currently hardcodes x86 PKRU encodings. The
first step towards running those tests on arm64 is to abstract away
the pkey register values.

Since those tests want to deny access to all keys except a few,
we have each arch define PKEY_REG_ALLOW_NONE, the pkey register value
denying access to all keys. We then use the existing set_pkey_bits()
helper to grant access to specific keys.

Because pkeys may also remove the execute permission on arm64, we
need to be a little careful: all code is mapped with pkey 0, and we
need it to remain executable. pkey_reg_restrictive_default() is
introduced for that purpose: the value it returns prevents RW access
to all pkeys, but retains X permission for pkey 0.

test_pkru_preserved_after_sigusr1() only checks that the pkey
register value remains unchanged after a signal is delivered, so the
particular value is irrelevant. We enable pkey 0 and a few more
arbitrary keys in the smallest range available on all architectures
(8 keys on arm64).

Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lore.kernel.org/r/20241029144539.111155-5-kevin.brodsky@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
tools/testing/selftests/mm/pkey-arm64.h
tools/testing/selftests/mm/pkey-x86.h
tools/testing/selftests/mm/pkey_sighandler_tests.c