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: vdso_test_correctness: Use facilities from parse_vdso.c

The soname from the vDSO is not a public API. Furthermore it requires
libc to implement dlsym() and friends.

Use the facilities from parse_vdso.c instead which uses the official
vDSO ABI to find it, aligned with the other vDSO selftests.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://patch.msgid.link/20260227-vdso-selftest-cleanups-v2-5-d84830fa8beb@linutronix.de

authored by

Thomas Weißschuh and committed by
Borislav Petkov (AMD)
a8b22a15 38bc16aa

+14 -20
+1 -3
tools/testing/selftests/vDSO/Makefile
··· 26 26 $(OUTPUT)/vdso_test_gettimeofday: parse_vdso.c vdso_test_gettimeofday.c 27 27 $(OUTPUT)/vdso_test_getcpu: parse_vdso.c vdso_test_getcpu.c 28 28 $(OUTPUT)/vdso_test_abi: parse_vdso.c vdso_test_abi.c 29 + $(OUTPUT)/vdso_test_correctness: parse_vdso.c vdso_test_correctness.c 29 30 30 31 $(OUTPUT)/vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c | headers 31 32 $(OUTPUT)/vdso_standalone_test_x86: CFLAGS:=$(CFLAGS_NOLIBC) $(CFLAGS) 32 - 33 - $(OUTPUT)/vdso_test_correctness: vdso_test_correctness.c 34 - $(OUTPUT)/vdso_test_correctness: LDFLAGS += -ldl 35 33 36 34 $(OUTPUT)/vdso_test_getrandom: parse_vdso.c 37 35 $(OUTPUT)/vdso_test_getrandom: CFLAGS += -isystem $(top_srcdir)/tools/include \
+13 -17
tools/testing/selftests/vDSO/vdso_test_correctness.c
··· 11 11 #include <time.h> 12 12 #include <stdlib.h> 13 13 #include <unistd.h> 14 + #include <sys/auxv.h> 14 15 #include <sys/syscall.h> 15 - #include <dlfcn.h> 16 16 #include <string.h> 17 17 #include <errno.h> 18 18 #include <sched.h> 19 19 #include <stdbool.h> 20 20 #include <limits.h> 21 21 22 + #include "parse_vdso.h" 22 23 #include "vdso_config.h" 23 24 #include "vdso_call.h" 24 25 #include "kselftest.h" 25 26 27 + static const char *version; 26 28 static const char **name; 27 29 28 30 #ifndef __NR_clock_gettime64 ··· 104 102 105 103 static void fill_function_pointers(void) 106 104 { 107 - void *vdso = dlopen("linux-vdso.so.1", 108 - RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); 109 - if (!vdso) 110 - vdso = dlopen("linux-gate.so.1", 111 - RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); 112 - if (!vdso) 113 - vdso = dlopen("linux-vdso32.so.1", 114 - RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); 115 - if (!vdso) 116 - vdso = dlopen("linux-vdso64.so.1", 117 - RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); 118 - if (!vdso) { 105 + unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); 106 + 107 + if (!sysinfo_ehdr) { 119 108 printf("[WARN]\tfailed to find vDSO\n"); 120 109 return; 121 110 } 122 111 123 - vdso_getcpu = (getcpu_t)dlsym(vdso, name[4]); 112 + vdso_init_from_sysinfo_ehdr(sysinfo_ehdr); 113 + 114 + vdso_getcpu = (getcpu_t)vdso_sym(version, name[4]); 124 115 if (!vdso_getcpu) 125 116 printf("Warning: failed to find getcpu in vDSO\n"); 126 117 127 118 vgetcpu = (getcpu_t) vsyscall_getcpu(); 128 119 129 - vdso_clock_gettime = (vgettime_t)dlsym(vdso, name[1]); 120 + vdso_clock_gettime = (vgettime_t)vdso_sym(version, name[1]); 130 121 if (!vdso_clock_gettime) 131 122 printf("Warning: failed to find clock_gettime in vDSO\n"); 132 123 133 124 #if defined(VDSO_32BIT) 134 - vdso_clock_gettime64 = (vgettime64_t)dlsym(vdso, name[5]); 125 + vdso_clock_gettime64 = (vgettime64_t)vdso_sym(version, name[5]); 135 126 if (!vdso_clock_gettime64) 136 127 printf("Warning: failed to find clock_gettime64 in vDSO\n"); 137 128 #endif 138 129 139 - vdso_gettimeofday = (vgtod_t)dlsym(vdso, name[0]); 130 + vdso_gettimeofday = (vgtod_t)vdso_sym(version, name[0]); 140 131 if (!vdso_gettimeofday) 141 132 printf("Warning: failed to find gettimeofday in vDSO\n"); 142 133 ··· 424 429 425 430 int main(int argc, char **argv) 426 431 { 432 + version = versions[VDSO_VERSION]; 427 433 name = (const char **)&names[VDSO_NAMES]; 428 434 429 435 fill_function_pointers();