[tip: timers/vdso] selftests: vDSO: vdso_standalone_test_x86: Use vdso_init_form_sysinfo_ehdr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following commit has been merged into the timers/vdso branch of tip:

Commit-ID:     05c204acf5131740f5f4e193c9749b92da4bcb16
Gitweb:        https://git.kernel.org/tip/05c204acf5131740f5f4e193c9749b92da4bcb16
Author:        Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
AuthorDate:    Wed, 26 Feb 2025 12:44:49 +01:00
Committer:     Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CommitterDate: Mon, 03 Mar 2025 20:00:12 +01:00

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@xxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@xxxxxxx>
Acked-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>
Link: https://lore.kernel.org/all/20250226-parse_vdso-nolibc-v2-10-28e14e031ed8@xxxxxxxxxxxxx
---
 tools/testing/selftests/vDSO/vdso_standalone_test_x86.c | 27 +++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
index 6449158..500608f 100644
--- a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
+++ b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c
@@ -15,6 +15,7 @@
 #include <sys/time.h>
 #include <unistd.h>
 #include <stdint.h>
+#include <linux/auxvec.h>
 
 #include "parse_vdso.h"
 
@@ -84,6 +85,30 @@ void to_base10(char *lastdig, time_t n)
 	}
 }
 
+unsigned long getauxval(const unsigned long *auxv, unsigned long type)
+{
+	unsigned long ret;
+
+	if (!auxv)
+		return 0;
+
+	while (1) {
+		if (!auxv[0] && !auxv[1]) {
+			ret = 0;
+			break;
+		}
+
+		if (auxv[0] == type) {
+			ret = auxv[1];
+			break;
+		}
+
+		auxv += 2;
+	}
+
+	return ret;
+}
+
 void c_main(void **stack)
 {
 	/* Parse the stack */
@@ -96,7 +121,7 @@ void c_main(void **stack)
 	stack++;
 
 	/* Now we're pointing at auxv.  Initialize the vDSO parser. */
-	vdso_init_from_auxv((void *)stack);
+	vdso_init_from_sysinfo_ehdr(getauxval((unsigned long *)stack, AT_SYSINFO_EHDR));
 
 	/* Find gettimeofday. */
 	typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);





[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux