Skip to content

Commit 05c204a

Browse files
t-8chKAGA-KOKO
authored andcommitted
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 <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Vincenzo Frascino <[email protected]> Acked-by: Shuah Khan <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 5caaa0a commit 05c204a

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tools/testing/selftests/vDSO/vdso_standalone_test_x86.c

+26-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <sys/time.h>
1616
#include <unistd.h>
1717
#include <stdint.h>
18+
#include <linux/auxvec.h>
1819

1920
#include "parse_vdso.h"
2021

@@ -84,6 +85,30 @@ void to_base10(char *lastdig, time_t n)
8485
}
8586
}
8687

88+
unsigned long getauxval(const unsigned long *auxv, unsigned long type)
89+
{
90+
unsigned long ret;
91+
92+
if (!auxv)
93+
return 0;
94+
95+
while (1) {
96+
if (!auxv[0] && !auxv[1]) {
97+
ret = 0;
98+
break;
99+
}
100+
101+
if (auxv[0] == type) {
102+
ret = auxv[1];
103+
break;
104+
}
105+
106+
auxv += 2;
107+
}
108+
109+
return ret;
110+
}
111+
87112
void c_main(void **stack)
88113
{
89114
/* Parse the stack */
@@ -96,7 +121,7 @@ void c_main(void **stack)
96121
stack++;
97122

98123
/* Now we're pointing at auxv. Initialize the vDSO parser. */
99-
vdso_init_from_auxv((void *)stack);
124+
vdso_init_from_sysinfo_ehdr(getauxval((unsigned long *)stack, AT_SYSINFO_EHDR));
100125

101126
/* Find gettimeofday. */
102127
typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);

0 commit comments

Comments
 (0)