summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/vDSO
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@csgroup.eu>2024-08-22 10:13:22 +0300
committerJason A. Donenfeld <Jason@zx2c4.com>2024-08-30 16:44:38 +0300
commite1bbcab496f745d963e43a6e0f669359e82c4934 (patch)
treeef746a10f9dc8ca8f673a1c3cc0937c8add2630f /tools/testing/selftests/vDSO
parentf8d92fc527ff0388b2e94c101afb0e5c7496199f (diff)
downloadlinux-e1bbcab496f745d963e43a6e0f669359e82c4934.tar.xz
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>
Diffstat (limited to 'tools/testing/selftests/vDSO')
-rw-r--r--tools/testing/selftests/vDSO/vdso_config.h8
-rw-r--r--tools/testing/selftests/vDSO/vdso_test_getrandom.c8
2 files changed, 9 insertions, 7 deletions
diff --git a/tools/testing/selftests/vDSO/vdso_config.h b/tools/testing/selftests/vDSO/vdso_config.h
index 7b543e7f04d7..b5ba5ded3a61 100644
--- a/tools/testing/selftests/vDSO/vdso_config.h
+++ b/tools/testing/selftests/vDSO/vdso_config.h
@@ -68,16 +68,15 @@ static const char *versions[7] = {
"LINUX_5.10"
};
-static const char *names[2][6] = {
+static const char *names[2][7] = {
{
"__kernel_gettimeofday",
"__kernel_clock_gettime",
"__kernel_time",
"__kernel_clock_getres",
"__kernel_getcpu",
-#if defined(VDSO_32BIT)
"__kernel_clock_gettime64",
-#endif
+ "__kernel_getrandom",
},
{
"__vdso_gettimeofday",
@@ -85,9 +84,8 @@ static const char *names[2][6] = {
"__vdso_time",
"__vdso_clock_getres",
"__vdso_getcpu",
-#if defined(VDSO_32BIT)
"__vdso_clock_gettime64",
-#endif
+ "__vdso_getrandom",
},
};
diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
index 89c961175956..20bbef992c48 100644
--- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c
+++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
@@ -21,6 +21,7 @@
#include "../kselftest.h"
#include "parse_vdso.h"
+#include "vdso_config.h"
#ifndef timespecsub
#define timespecsub(tsp, usp, vsp) \
@@ -100,15 +101,18 @@ static void vgetrandom_put_state(void *state)
static void vgetrandom_init(void)
{
+ const char *version = versions[VDSO_VERSION];
+ const char *name = names[VDSO_NAMES][6];
unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
+
if (!sysinfo_ehdr) {
printf("AT_SYSINFO_EHDR is not present!\n");
exit(KSFT_SKIP);
}
vdso_init_from_sysinfo_ehdr(sysinfo_ehdr);
- vgrnd.fn = (__typeof__(vgrnd.fn))vdso_sym("LINUX_2.6", "__vdso_getrandom");
+ vgrnd.fn = (__typeof__(vgrnd.fn))vdso_sym(version, name);
if (!vgrnd.fn) {
- printf("__vdso_getrandom is missing!\n");
+ printf("%s is missing!\n", name);
exit(KSFT_FAIL);
}
if (vgrnd.fn(NULL, 0, 0, &vgrnd.params, ~0UL) != 0) {