Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/mm: remove empty pkey helper definition

Some of the functions declared in pkey-helpers.h are actually defined in
protections_keys.c, meaning they can only be called from
protections_keys.c. This is less than ideal, but it is hard to avoid as
these helpers are themselves called from inline functions in
pkey-<arch>.h. Let's at least add a comment clarifying that. We can also
remove the empty definition in pkey_sighandler_tests.c:
expected_pkey_fault() is not meant to be called from there.

Link: https://lkml.kernel.org/r/20241209095019.1732120-10-kevin.brodsky@arm.com
Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Joey Gouly <joey.gouly@arm.com>
Cc: Keith Lucas <keith.lucas@oracle.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kevin Brodsky and committed by
Andrew Morton
f3f55597 21309ac2

+4 -4
+4 -2
tools/testing/selftests/mm/pkey-helpers.h
··· 84 84 # define noinline __attribute__((noinline)) 85 85 #endif 86 86 87 - noinline int read_ptr(int *ptr); 88 - void expected_pkey_fault(int pkey); 89 87 int sys_pkey_alloc(unsigned long flags, unsigned long init_val); 90 88 int sys_pkey_free(unsigned long pkey); 89 + 90 + /* For functions called from protection_keys.c only */ 91 + noinline int read_ptr(int *ptr); 92 + void expected_pkey_fault(int pkey); 91 93 int mprotect_pkey(void *ptr, size_t size, unsigned long orig_prot, 92 94 unsigned long pkey); 93 95 void record_pkey_malloc(void *ptr, long size, int prot);
-2
tools/testing/selftests/mm/pkey_sighandler_tests.c
··· 32 32 33 33 #define STACK_SIZE PTHREAD_STACK_MIN 34 34 35 - void expected_pkey_fault(int pkey) {} 36 - 37 35 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 38 36 pthread_cond_t cond = PTHREAD_COND_INITIALIZER; 39 37 siginfo_t siginfo = {0};