[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <04d1de23a2ff14e2709edd8b75e27b81d703bc57.1724309198.git.christophe.leroy@csgroup.eu>
Date: Thu, 22 Aug 2024 09:13:22 +0200
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Michael Ellerman <mpe@...erman.id.au>,
Nicholas Piggin <npiggin@...il.com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Naveen N Rao <naveen@...nel.org>,
Andy Lutomirski <luto@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
"Theodore Ts'o" <tytso@....edu>,
"Jason A. Donenfeld" <Jason@...c4.com>,
Arnd Bergmann <arnd@...db.de>,
Andrew Morton <akpm@...ux-foundation.org>,
Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Vincenzo Frascino <vincenzo.frascino@....com>,
Shuah Khan <shuah@...nel.org>
Cc: linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
linux-arch@...r.kernel.org,
linux-mm@...ck.org,
linux-trace-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org
Subject: [PATCH v2 14/17] selftests: vdso: Make test_vdso_getrandom look for the right vDSO function
Don't hard-code x86 specific names, use vdso_config definitions
to find the correct function matching the architecture.
Add random VDSO function names in names[][]. Remove the #ifdef
CONFIG_VDSO32, having the name there all the time is harmless
and guaranties a steady index for following strings.
Signed-off-by: Christophe Leroy <christophe.leroy@...roup.eu>
---
tools/testing/selftests/vDSO/vdso_config.h | 8 +++-----
tools/testing/selftests/vDSO/vdso_test_getrandom.c | 8 ++++++--
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 00bfed6e4922..740ce8c98d2e 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 05122425a873..02bcffc23e0c 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) \
@@ -107,6 +108,9 @@ static void vgetrandom_put_state(void *state)
static void vgetrandom_init(void)
{
+ const char *version = versions[VDSO_VERSION];
+ const char **name = (const char **)&names[VDSO_NAMES];
+
if (pthread_key_create(&grnd_ctx.key, vgetrandom_put_state) != 0)
return;
unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
@@ -115,9 +119,9 @@ static void vgetrandom_init(void)
exit(KSFT_SKIP);
}
vdso_init_from_sysinfo_ehdr(sysinfo_ehdr);
- grnd_ctx.fn = (__typeof__(grnd_ctx.fn))vdso_sym("LINUX_2.6", "__vdso_getrandom");
+ grnd_ctx.fn = (__typeof__(grnd_ctx.fn))vdso_sym(version, name[6]);
if (!grnd_ctx.fn) {
- printf("__vdso_getrandom is missing!\n");
+ printf("%s is missing!\n", name[6]);
exit(KSFT_FAIL);
}
if (grnd_ctx.fn(NULL, 0, 0, &grnd_ctx.params, ~0UL) != 0) {
--
2.44.0
Powered by blists - more mailing lists