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

selftests/mm: remove unused pkey helpers

Commit 5f23f6d082a9 ("x86/pkeys: Add self-tests") introduced a
number of helpers and functions that don't seem to have ever been
used. Let's remove them.

Link: https://lkml.kernel.org/r/20241209095019.1732120-7-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
31fdc965 46036188

-68
-34
tools/testing/selftests/mm/pkey-helpers.h
··· 26 26 #ifndef DEBUG_LEVEL 27 27 #define DEBUG_LEVEL 0 28 28 #endif 29 - #define DPRINT_IN_SIGNAL_BUF_SIZE 4096 30 29 extern int dprint_in_signal; 31 - extern char dprint_in_signal_buffer[DPRINT_IN_SIGNAL_BUF_SIZE]; 32 30 33 31 extern int test_nr; 34 32 extern int iteration_nr; ··· 167 169 shadow_pkey_reg = pkey_reg; 168 170 dprintf4("%s(%016llx) pkey_reg: %016llx\n", __func__, 169 171 pkey_reg, __read_pkey_reg()); 170 - } 171 - 172 - /* 173 - * These are technically racy. since something could 174 - * change PKEY register between the read and the write. 175 - */ 176 - static inline void __pkey_access_allow(int pkey, int do_allow) 177 - { 178 - u64 pkey_reg = read_pkey_reg(); 179 - int bit = pkey * 2; 180 - 181 - if (do_allow) 182 - pkey_reg &= (1<<bit); 183 - else 184 - pkey_reg |= (1<<bit); 185 - 186 - dprintf4("pkey_reg now: %016llx\n", read_pkey_reg()); 187 - write_pkey_reg(pkey_reg); 188 - } 189 - 190 - static inline void __pkey_write_allow(int pkey, int do_allow_write) 191 - { 192 - u64 pkey_reg = read_pkey_reg(); 193 - int bit = pkey * 2 + 1; 194 - 195 - if (do_allow_write) 196 - pkey_reg &= (1<<bit); 197 - else 198 - pkey_reg |= (1<<bit); 199 - 200 - write_pkey_reg(pkey_reg); 201 - dprintf4("pkey_reg now: %016llx\n", read_pkey_reg()); 202 172 } 203 173 204 174 #define ALIGN_UP(x, align_to) (((x) + ((align_to)-1)) & ~((align_to)-1))
-34
tools/testing/selftests/mm/protection_keys.c
··· 53 53 54 54 u64 shadow_pkey_reg; 55 55 int dprint_in_signal; 56 - char dprint_in_signal_buffer[DPRINT_IN_SIGNAL_BUF_SIZE]; 57 56 58 57 void cat_into_file(char *str, char *file) 59 58 { ··· 394 395 pkey_faults++; 395 396 dprintf1("<<<<==================================================\n"); 396 397 dprint_in_signal = 0; 397 - } 398 - 399 - int wait_all_children(void) 400 - { 401 - int status; 402 - return waitpid(-1, &status, 0); 403 398 } 404 399 405 400 void sig_chld(int x) ··· 810 817 return ptr; 811 818 } 812 819 813 - void *malloc_pkey_mmap_dax(long size, int prot, u16 pkey) 814 - { 815 - void *ptr; 816 - int fd; 817 - 818 - dprintf1("doing %s(size=%ld, prot=0x%x, pkey=%d)\n", __func__, 819 - size, prot, pkey); 820 - pkey_assert(pkey < NR_PKEYS); 821 - fd = open("/dax/foo", O_RDWR); 822 - pkey_assert(fd >= 0); 823 - 824 - ptr = mmap(0, size, prot, MAP_SHARED, fd, 0); 825 - pkey_assert(ptr != (void *)-1); 826 - 827 - mprotect_pkey(ptr, size, prot, pkey); 828 - 829 - record_pkey_malloc(ptr, size, prot); 830 - 831 - dprintf1("mmap()'d for pkey %d @ %p\n", pkey, ptr); 832 - close(fd); 833 - return ptr; 834 - } 835 - 836 820 void *(*pkey_malloc[])(long size, int prot, u16 pkey) = { 837 821 838 822 malloc_pkey_with_mprotect, 839 823 malloc_pkey_with_mprotect_subpage, 840 824 malloc_pkey_anon_huge, 841 825 malloc_pkey_hugetlb 842 - /* can not do direct with the pkey_mprotect() API: 843 - malloc_pkey_mmap_direct, 844 - malloc_pkey_mmap_dax, 845 - */ 846 826 }; 847 827 848 828 void *malloc_pkey(long size, int prot, u16 pkey)