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

selftests: vDSO: vdso_standalone_test_x86: Use vdso_init_form_sysinfo_ehdr

vdso_standalone_test_x86 is the only user of vdso_init_from_auxv().
Instead of combining the parsing the aux vector with the parsing of the
vDSO, split them apart into getauxval() and the regular
vdso_init_from_sysinfo_ehdr().

The implementation of getauxval() is taken from
tools/include/nolibc/stdlib.h.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/all/20250226-parse_vdso-nolibc-v2-10-28e14e031ed8@linutronix.de

authored by

Thomas Weißschuh and committed by
Thomas Gleixner
05c204ac 5caaa0aa

+26 -1
+26 -1
tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
··· 15 15 #include <sys/time.h> 16 16 #include <unistd.h> 17 17 #include <stdint.h> 18 + #include <linux/auxvec.h> 18 19 19 20 #include "parse_vdso.h" 20 21 ··· 85 84 } 86 85 } 87 86 87 + unsigned long getauxval(const unsigned long *auxv, unsigned long type) 88 + { 89 + unsigned long ret; 90 + 91 + if (!auxv) 92 + return 0; 93 + 94 + while (1) { 95 + if (!auxv[0] && !auxv[1]) { 96 + ret = 0; 97 + break; 98 + } 99 + 100 + if (auxv[0] == type) { 101 + ret = auxv[1]; 102 + break; 103 + } 104 + 105 + auxv += 2; 106 + } 107 + 108 + return ret; 109 + } 110 + 88 111 void c_main(void **stack) 89 112 { 90 113 /* Parse the stack */ ··· 121 96 stack++; 122 97 123 98 /* Now we're pointing at auxv. Initialize the vDSO parser. */ 124 - vdso_init_from_auxv((void *)stack); 99 + vdso_init_from_sysinfo_ehdr(getauxval((unsigned long *)stack, AT_SYSINFO_EHDR)); 125 100 126 101 /* Find gettimeofday. */ 127 102 typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);