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

Configure Feed

Select the types of activity you want to include in your feed.

selftests: vDSO: look for arch-specific function name in getrandom test

Don't hard-code x86 specific names. Rather, use vdso_config definitions
to find the correct function matching the architecture.

Add random VDSO function names in names[][]. Remove the #ifdef
CONFIG_VDSO32, as having the name there all the time is harmless and
guaranties a steady index for following strings.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
[Jason: add [6] to variable declaration rather than each usage site.]
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

authored by

Christophe Leroy and committed by
Jason A. Donenfeld
e1bbcab4 f8d92fc5

+9 -7
+3 -5
tools/testing/selftests/vDSO/vdso_config.h
··· 68 68 "LINUX_5.10" 69 69 }; 70 70 71 - static const char *names[2][6] = { 71 + static const char *names[2][7] = { 72 72 { 73 73 "__kernel_gettimeofday", 74 74 "__kernel_clock_gettime", 75 75 "__kernel_time", 76 76 "__kernel_clock_getres", 77 77 "__kernel_getcpu", 78 - #if defined(VDSO_32BIT) 79 78 "__kernel_clock_gettime64", 80 - #endif 79 + "__kernel_getrandom", 81 80 }, 82 81 { 83 82 "__vdso_gettimeofday", ··· 84 85 "__vdso_time", 85 86 "__vdso_clock_getres", 86 87 "__vdso_getcpu", 87 - #if defined(VDSO_32BIT) 88 88 "__vdso_clock_gettime64", 89 - #endif 89 + "__vdso_getrandom", 90 90 }, 91 91 }; 92 92
+6 -2
tools/testing/selftests/vDSO/vdso_test_getrandom.c
··· 21 21 22 22 #include "../kselftest.h" 23 23 #include "parse_vdso.h" 24 + #include "vdso_config.h" 24 25 25 26 #ifndef timespecsub 26 27 #define timespecsub(tsp, usp, vsp) \ ··· 101 100 102 101 static void vgetrandom_init(void) 103 102 { 103 + const char *version = versions[VDSO_VERSION]; 104 + const char *name = names[VDSO_NAMES][6]; 104 105 unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); 106 + 105 107 if (!sysinfo_ehdr) { 106 108 printf("AT_SYSINFO_EHDR is not present!\n"); 107 109 exit(KSFT_SKIP); 108 110 } 109 111 vdso_init_from_sysinfo_ehdr(sysinfo_ehdr); 110 - vgrnd.fn = (__typeof__(vgrnd.fn))vdso_sym("LINUX_2.6", "__vdso_getrandom"); 112 + vgrnd.fn = (__typeof__(vgrnd.fn))vdso_sym(version, name); 111 113 if (!vgrnd.fn) { 112 - printf("__vdso_getrandom is missing!\n"); 114 + printf("%s is missing!\n", name); 113 115 exit(KSFT_FAIL); 114 116 } 115 117 if (vgrnd.fn(NULL, 0, 0, &vgrnd.params, ~0UL) != 0) {