Skip to contentSkip to conversation

selftests: vdso_test: support ARM64 targets

PATCH Superseded Greg Hackmann 2 participants 2 messages Oct 31, 2017 – Nov 1, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: vdso_test: support ARM64 targets

ARM64's vDSO exports its gettimeofday() implementation with a different name (__kernel_gettimeofday) and version (LINUX_2.6.39) from other architectures. Add a corresponding special-case to vdso_test.

---
 tools/testing/selftests/vDSO/vdso_test.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
tools/testing/selftests/vDSO/vdso_test.c +14 -3
index 8daeb7d7032c..f0f8cc59c195 100644
@@ -21,6 +21,17 @@ extern void vdso_init_from_auxv(void *auxv);
 
 int main(int argc, char **argv)
 {
+	const char *version;
+	const char *name;
+
+#if defined(__aarch64__)
+	version = "LINUX_2.6.39";
+	name = "__kernel_gettimeofday";
+#else
+	version = "LINUX_2.6";
+	name = "__vdso_gettimeofday";
+#endif
+
 	unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
 	if (!sysinfo_ehdr) {
 		printf("AT_SYSINFO_EHDR is not present!\n");
@@ -31,10 +42,10 @@ int main(int argc, char **argv)
 
 	/* Find gettimeofday. */
 	typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);
-	gtod_t gtod = (gtod_t)vdso_sym("LINUX_2.6", "__vdso_gettimeofday");
+	gtod_t gtod = (gtod_t)vdso_sym(version, name);
 
 	if (!gtod) {
-		printf("Could not find __vdso_gettimeofday\n");
+		printf("Could not find %s\n", name);
 		return 1;
 	}
 
@@ -45,7 +56,7 @@ int main(int argc, char **argv)
 		printf("The time is %lld.%06lld\n",
 		       (long long)tv.tv_sec, (long long)tv.tv_usec);
 	} else {
-		printf("__vdso_gettimeofday failed\n");
+		printf("%s failed\n", name);
 	}
 
 	return 0;
Signature · 1 line
2.15.0.403.gc27cc4dac6-goog
maintainer
#1 lore raw

Hi Greg,

Quoted 5 lines · Greg Hackmann

ARM64's vDSO exports its gettimeofday() implementation with a different name (__kernel_gettimeofday) and version (LINUX_2.6.39) from other architectures. Add a corresponding special-case to vdso_test.

Thanks for the patch.

Quoted 13 lines
---
 tools/testing/selftests/vDSO/vdso_test.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
tools/testing/selftests/vDSO/vdso_test.c +1 -0
index 8daeb7d7032c..f0f8cc59c195 100644
@@ -21,6 +21,17 @@ extern void vdso_init_from_auxv(void *auxv);
 
 int main(int argc, char **argv)
 {
+	const char *version;

tools/testing/selftests/vDSO/vdso_test.c extern void vdso_init_from_auxv(void *auxv); · line 34

Quoted 10 lines
tools/testing/selftests/vDSO/vdso_test.c +10 -0
+	const char *name;
+
+#if defined(__aarch64__)
+	version = "LINUX_2.6.39";
+	name = "__kernel_gettimeofday";
+#else
+	version = "LINUX_2.6";
+	name = "__vdso_gettimeofday";
+#endif
+

Could you move these defines up and add them before the main. It will be easier to follow the code that way.

Please capture the change log description as a comment block for these defines.

thanks,
-- Shuah

Quoted 26 lines
tools/testing/selftests/vDSO/vdso_test.c +3 -3
 	unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
 	if (!sysinfo_ehdr) {
 		printf("AT_SYSINFO_EHDR is not present!\n");
@@ -31,10 +42,10 @@ int main(int argc, char **argv)
 
 	/* Find gettimeofday. */
 	typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);
-	gtod_t gtod = (gtod_t)vdso_sym("LINUX_2.6", "__vdso_gettimeofday");
+	gtod_t gtod = (gtod_t)vdso_sym(version, name);
 
 	if (!gtod) {
-		printf("Could not find __vdso_gettimeofday\n");
+		printf("Could not find %s\n", name);
 		return 1;
 	}
 
@@ -45,7 +56,7 @@ int main(int argc, char **argv)
 		printf("The time is %lld.%06lld\n",
 		       (long long)tv.tv_sec, (long long)tv.tv_usec);
 	} else {
-		printf("__vdso_gettimeofday failed\n");
+		printf("%s failed\n", name);
 	}
 
 	return 0;