selftests: mm: make protection_keys test work on arm64
authorJoey Gouly <joey.gouly@arm.com>
Thu, 22 Aug 2024 15:11:09 +0000 (16:11 +0100)
committerWill Deacon <will@kernel.org>
Wed, 4 Sep 2024 11:54:06 +0000 (12:54 +0100)
commitf5b5ea51f78f2ebd94d5a77702bbe5eee8924b50
treea2c023b2cc3ed42d6ecf9b283bb9757463052832
parent41bbcf7b4b046b4e7190c1866625aed0fe6f69f6
selftests: mm: make protection_keys test work on arm64

The encoding of the pkey register differs on arm64, than on x86/ppc. On those
platforms, a bit in the register is used to disable permissions, for arm64, a
bit enabled in the register indicates that the permission is allowed.

This drops two asserts of the form:
 assert(read_pkey_reg() <= orig_pkey_reg);
Because on arm64 this doesn't hold, due to the encoding.

The pkey must be reset to both access allow and write allow in the signal
handler. pkey_access_allow() works currently for PowerPC as the
PKEY_DISABLE_ACCESS and PKEY_DISABLE_WRITE have overlapping bits set.

Access to the uc_mcontext is abstracted, as arm64 has a different structure.

Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lore.kernel.org/r/20240822151113.1479789-27-joey.gouly@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
tools/testing/selftests/arm64/signal/testcases/testcases.h
tools/testing/selftests/mm/Makefile
tools/testing/selftests/mm/pkey-arm64.h [new file with mode: 0644]
tools/testing/selftests/mm/pkey-helpers.h
tools/testing/selftests/mm/pkey-powerpc.h
tools/testing/selftests/mm/pkey-x86.h
tools/testing/selftests/mm/protection_keys.c