linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH vdsotest] Use vdso wrapper for gettimeofday()
@ 2020-01-15 12:19 Christophe Leroy
  2020-01-16 16:56 ` Nathan Lynch
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe Leroy @ 2020-01-15 12:19 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: linux-kernel, linuxppc-dev, Thomas Gleixner

To properly handle errors returned by gettimeofday(), the
DO_VDSO_CALL() macro has to be used, otherwise vdsotest
misinterpret VDSO function return on error.

This has gone unnoticed until now because the powerpc VDSO
gettimeofday() always succeed, but while porting powerpc to
generic C VDSO, the following has been encountered:

gettimeofday(valid, UINTPTR_MAX) (VDSO): unexpected return value 14, expected -1
gettimeofday(valid, UINTPTR_MAX) (VDSO): exited with status 1, expected 0
gettimeofday(valid, page (PROT_NONE)) (VDSO): unexpected return value 14, expected -1
gettimeofday(valid, page (PROT_NONE)) (VDSO): exited with status 1, expected 0
gettimeofday(valid, page (PROT_READ)) (VDSO): unexpected return value 14, expected -1
gettimeofday(valid, page (PROT_READ)) (VDSO): exited with status 1, expected 0
gettimeofday(UINTPTR_MAX, valid) (VDSO): unexpected return value 14, expected -1
gettimeofday(UINTPTR_MAX, valid) (VDSO): exited with status 1, expected 0
gettimeofday(UINTPTR_MAX, NULL) (VDSO): unexpected return value 14, expected -1
gettimeofday(UINTPTR_MAX, NULL) (VDSO): exited with status 1, expected 0
gettimeofday(UINTPTR_MAX, UINTPTR_MAX) (VDSO): unexpected return value 14, expected -1
gettimeofday(UINTPTR_MAX, UINTPTR_MAX) (VDSO): exited with status 1, expected 0
gettimeofday(UINTPTR_MAX, page (PROT_NONE)) (VDSO): unexpected return value 14, expected -1
gettimeofday(UINTPTR_MAX, page (PROT_NONE)) (VDSO): exited with status 1, expected 0
gettimeofday(UINTPTR_MAX, page (PROT_READ)) (VDSO): unexpected return value 14, expected -1
gettimeofday(UINTPTR_MAX, page (PROT_READ)) (VDSO): exited with status 1, expected 0
gettimeofday(page (PROT_NONE), valid) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_NONE), valid) (VDSO): exited with status 1, expected 0
gettimeofday(page (PROT_NONE), NULL) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_NONE), NULL) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_NONE), UINTPTR_MAX) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_NONE), UINTPTR_MAX) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_NONE), page (PROT_NONE)) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_NONE), page (PROT_NONE)) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_NONE), page (PROT_READ)) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_NONE), page (PROT_READ)) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_READ), valid) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_READ), valid) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_READ), NULL) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_READ), NULL) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_READ), UINTPTR_MAX) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_READ), UINTPTR_MAX) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_READ), page (PROT_NONE)) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_READ), page (PROT_NONE)) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday(page (PROT_READ), page (PROT_READ)) (VDSO): unexpected return value 14, expected -1
gettimeofday(page (PROT_READ), page (PROT_READ)) (VDSO): exited with status 1, expected 0
Failure threshold (10) reached; stopping test.
gettimeofday/abi: 18 failures/inconsistencies encountered

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 src/gettimeofday.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/gettimeofday.c b/src/gettimeofday.c
index c50ecea..472f372 100644
--- a/src/gettimeofday.c
+++ b/src/gettimeofday.c
@@ -54,11 +54,16 @@ static void gettimeofday_syscall_nofail(struct timeval *tv, struct timezone *tz)
 		error(EXIT_FAILURE, errno, "SYS_gettimeofday");
 }
 
+static int gettimeofday_vdso_wrapper(struct timeval *tv, struct timezone *tz)
+{
+	return DO_VDSO_CALL(gettimeofday_vdso, int, 2, tv, tz);
+}
+
 static void gettimeofday_vdso_nofail(struct timeval *tv, struct timezone *tz)
 {
 	int err;
 
-	err = gettimeofday_vdso(tv, tz);
+	err = gettimeofday_vdso_wrapper(tv, tz);
 	if (err)
 		error(EXIT_FAILURE, errno, "gettimeofday");
 }
@@ -153,7 +158,7 @@ static void gettimeofday_bench(struct ctx *ctx, struct bench_results *res)
 	struct timeval tv;
 
 	if (vdso_has_gettimeofday()) {
-		BENCH(ctx, gettimeofday_vdso(&tv, NULL),
+		BENCH(ctx, gettimeofday_vdso_wrapper(&tv, NULL),
 		      &res->vdso_interval);
 	}
 
@@ -196,7 +201,7 @@ static void do_gettimeofday(void *arg, struct syscall_result *res)
 	if (args->force_syscall)
 		err = gettimeofday_syscall_wrapper(args->tv, args->tz);
 	else
-		err = gettimeofday_vdso(args->tv, args->tz);
+		err = gettimeofday_vdso_wrapper(args->tv, args->tz);
 	record_syscall_result(res, err, errno);
 }
 
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-13 16:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 12:19 [PATCH vdsotest] Use vdso wrapper for gettimeofday() Christophe Leroy
2020-01-16 16:56 ` Nathan Lynch
2020-01-16 17:59   ` Christophe Leroy
2020-04-07 16:11   ` Christophe Leroy
2020-04-13 16:05     ` Nathan Lynch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).